Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0de9444a authored by Alex Sakhartchouk's avatar Alex Sakhartchouk
Browse files

Preparing renderscript java code for use with phanton references.

Changing rs_quaternion to be float4

Change-Id: Ibf49f412be8979eaa04cb252b407467eacd9dbf0
parent aa56ede8
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -35,14 +35,12 @@ public class Allocation extends BaseObj {
    Bitmap mBitmap;

    Allocation(int id, RenderScript rs, Type t) {
        super(rs);
        mID = id;
        super(id, rs);
        mType = t;
    }

    Allocation(int id, RenderScript rs) {
        super(rs);
        mID = id;
        super(id, rs);
    }

    @Override
@@ -182,8 +180,7 @@ public class Allocation extends BaseObj {

    public class Adapter1D extends BaseObj {
        Adapter1D(int id, RenderScript rs) {
            super(rs);
            mID = id;
            super(id, rs);
        }

        public void setConstraint(Dimension dim, int value) {
@@ -225,8 +222,7 @@ public class Allocation extends BaseObj {

    public class Adapter2D extends BaseObj {
        Adapter2D(int id, RenderScript rs) {
            super(rs);
            mID = id;
            super(id, rs);
        }

        public void setConstraint(Dimension dim, int value) {
+2 −2
Original line number Diff line number Diff line
@@ -24,10 +24,10 @@ import android.util.Log;
 **/
class BaseObj {

    BaseObj(RenderScript rs) {
    BaseObj(int id, RenderScript rs) {
        rs.validate();
        mRS = rs;
        mID = 0;
        mID = id;
        mDestroyed = false;
    }

+32 −18
Original line number Diff line number Diff line
@@ -286,32 +286,27 @@ public class Element extends BaseObj {
    }


    Element(RenderScript rs, Element[] e, String[] n) {
        super(rs);
    Element(int id, RenderScript rs, Element[] e, String[] n) {
        super(id, rs);
        mSize = 0;
        mElements = e;
        mElementNames = n;
        int[] ids = new int[mElements.length];
        for (int ct = 0; ct < mElements.length; ct++ ) {
            mSize += mElements[ct].mSize;
            ids[ct] = mElements[ct].mID;
        }
        mID = rs.nElementCreate2(ids, mElementNames);
    }

    Element(RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) {
        super(rs);
    Element(int id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) {
        super(id, rs);
        mSize = dt.mSize * size;
        mType = dt;
        mKind = dk;
        mNormalized = norm;
        mVectorSize = size;
        mID = rs.nElementCreate(dt.mID, dk.mID, norm, size);
    }

    Element(RenderScript rs, int id) {
        super(rs);
        mID = id;
    Element(int id, RenderScript rs) {
        super(id, rs);
    }

    @Override
@@ -320,9 +315,14 @@ public class Element extends BaseObj {
        // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
        int[] dataBuffer = new int[5];
        mRS.nElementGetNativeData(mID, dataBuffer);

        mNormalized = dataBuffer[2] == 1 ? true : false;
        mVectorSize = dataBuffer[3];
        mSize = 0;
        for (DataType dt: DataType.values()) {
            if(dt.mID == dataBuffer[0]){
                mType = dt;
                mSize = mType.mSize * mVectorSize;
            }
        }
        for (DataKind dk: DataKind.values()) {
@@ -331,8 +331,6 @@ public class Element extends BaseObj {
            }
        }

        mNormalized = dataBuffer[2] == 1 ? true : false;
        mVectorSize = dataBuffer[3];
        int numSubElements = dataBuffer[4];
        if(numSubElements > 0) {
            mElements = new Element[numSubElements];
@@ -341,8 +339,9 @@ public class Element extends BaseObj {
            int[] subElementIds = new int[numSubElements];
            mRS.nElementGetSubElements(mID, subElementIds, mElementNames);
            for(int i = 0; i < numSubElements; i ++) {
                mElements[i] = new Element(mRS, subElementIds[i]);
                mElements[i] = new Element(subElementIds[i], mRS);
                mElements[i].updateFromNative();
                mSize += mElements[i].mSize;
            }
        }

@@ -354,14 +353,21 @@ public class Element extends BaseObj {

    /////////////////////////////////////////
    public static Element createUser(RenderScript rs, DataType dt) {
        return new Element(rs, dt, DataKind.USER, false, 1);
        DataKind dk = DataKind.USER;
        boolean norm = false;
        int vecSize = 1;
        int id = rs.nElementCreate(dt.mID, dk.mID, norm, vecSize);
        return new Element(id, rs, dt, dk, norm, vecSize);
    }

    public static Element createVector(RenderScript rs, DataType dt, int size) {
        if (size < 2 || size > 4) {
            throw new IllegalArgumentException("Bad size");
        }
        return new Element(rs, dt, DataKind.USER, false, size);
        DataKind dk = DataKind.USER;
        boolean norm = false;
        int id = rs.nElementCreate(dt.mID, dk.mID, norm, size);
        return new Element(id, rs, dt, dk, norm, size);
    }

    public static Element createPixel(RenderScript rs, DataType dt, DataKind dk) {
@@ -399,7 +405,9 @@ public class Element extends BaseObj {
            size = 4;
        }

        return new Element(rs, dt, dk, true, size);
        boolean norm = true;
        int id = rs.nElementCreate(dt.mID, dk.mID, norm, size);
        return new Element(id, rs, dt, dk, norm, size);
    }

    public static class Builder {
@@ -435,7 +443,13 @@ public class Element extends BaseObj {
            String[] sin = new String[mCount];
            java.lang.System.arraycopy(mElements, 0, ein, 0, mCount);
            java.lang.System.arraycopy(mElementNames, 0, sin, 0, mCount);
            return new Element(mRS, ein, sin);

            int[] ids = new int[ein.length];
            for (int ct = 0; ct < ein.length; ct++ ) {
                ids[ct] = ein[ct].mID;
            }
            int id = mRS.nElementCreate2(ids, sin);
            return new Element(id, mRS, ein, sin);
        }
    }

+1 −2
Original line number Diff line number Diff line
@@ -146,8 +146,7 @@ public class FileA3D extends BaseObj {
    IndexEntry[] mFileEntries;

    FileA3D(int id, RenderScript rs) {
        super(rs);
        mID = id;
        super(id, rs);
    }

    private void initEntries() {
+1 −2
Original line number Diff line number Diff line
@@ -31,8 +31,7 @@ import android.util.TypedValue;
public class Font extends BaseObj {

    Font(int id, RenderScript rs) {
        super(rs);
        mID = id;
        super(id, rs);
    }

    static public Font create(RenderScript rs, Resources res, String fileName, int size)
Loading