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

Commit 2525a815 authored by Jason Sams's avatar Jason Sams
Browse files

Improve structure support using symbol lookup of named structures in scripts...

Improve structure support using symbol lookup of named structures in scripts to allow them to appear as just pointers to structs.
parent 1c1ffa0c
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -110,9 +110,12 @@ public class Allocation extends BaseObj {
    }

    public void data(Object o) {
        mRS.nAllocationDataFromObject(mID, mType, o);
        mRS.nAllocationSubDataFromObject(mID, mType, 0, o);
    }

    public void subData(int offset, Object o) {
        mRS.nAllocationSubDataFromObject(mID, mType, offset, o);
    }

    public class Adapter1D extends BaseObj {
        Adapter1D(int id, RenderScript rs) {
+23 −23
Original line number Diff line number Diff line
@@ -244,8 +244,8 @@ public class Element extends BaseObj {
        }

        public Builder addFloatXY(String prefix) {
            add(DataType.FLOAT, DataKind.X, false, 32, prefix + "X");
            add(DataType.FLOAT, DataKind.Y, false, 32, prefix + "Y");
            add(DataType.FLOAT, DataKind.X, false, 32, prefix + "x");
            add(DataType.FLOAT, DataKind.Y, false, 32, prefix + "y");
            return this;
        }

@@ -257,9 +257,9 @@ public class Element extends BaseObj {
        }

        public Builder addFloatXYZ(String prefix) {
            add(DataType.FLOAT, DataKind.X, false, 32, prefix + "X");
            add(DataType.FLOAT, DataKind.Y, false, 32, prefix + "Y");
            add(DataType.FLOAT, DataKind.Z, false, 32, prefix + "Z");
            add(DataType.FLOAT, DataKind.X, false, 32, prefix + "x");
            add(DataType.FLOAT, DataKind.Y, false, 32, prefix + "y");
            add(DataType.FLOAT, DataKind.Z, false, 32, prefix + "z");
            return this;
        }

@@ -270,8 +270,8 @@ public class Element extends BaseObj {
        }

        public Builder addFloatST(String prefix) {
            add(DataType.FLOAT, DataKind.S, false, 32, prefix + "S");
            add(DataType.FLOAT, DataKind.T, false, 32, prefix + "T");
            add(DataType.FLOAT, DataKind.S, false, 32, prefix + "s");
            add(DataType.FLOAT, DataKind.T, false, 32, prefix + "t");
            return this;
        }

@@ -283,9 +283,9 @@ public class Element extends BaseObj {
        }

        public Builder addFloatNorm(String prefix) {
            add(DataType.FLOAT, DataKind.NX, false, 32, prefix + "NX");
            add(DataType.FLOAT, DataKind.NY, false, 32, prefix + "NY");
            add(DataType.FLOAT, DataKind.NZ, false, 32, prefix + "NZ");
            add(DataType.FLOAT, DataKind.NX, false, 32, prefix + "nx");
            add(DataType.FLOAT, DataKind.NY, false, 32, prefix + "ny");
            add(DataType.FLOAT, DataKind.NZ, false, 32, prefix + "nz");
            return this;
        }

@@ -294,8 +294,8 @@ public class Element extends BaseObj {
            return this;
        }

        public Builder addFloatPointSize(String name) {
            add(DataType.FLOAT, DataKind.POINT_SIZE, false, 32, name);
        public Builder addFloatPointSize(String prefix) {
            add(DataType.FLOAT, DataKind.POINT_SIZE, false, 32, prefix + "pointSize");
            return this;
        }

@@ -307,9 +307,9 @@ public class Element extends BaseObj {
        }

        public Builder addFloatRGB(String prefix) {
            add(DataType.FLOAT, DataKind.RED, false, 32, prefix + "R");
            add(DataType.FLOAT, DataKind.GREEN, false, 32, prefix + "G");
            add(DataType.FLOAT, DataKind.BLUE, false, 32, prefix + "B");
            add(DataType.FLOAT, DataKind.RED, false, 32, prefix + "r");
            add(DataType.FLOAT, DataKind.GREEN, false, 32, prefix + "g");
            add(DataType.FLOAT, DataKind.BLUE, false, 32, prefix + "b");
            return this;
        }

@@ -322,10 +322,10 @@ public class Element extends BaseObj {
        }

        public Builder addFloatRGBA(String prefix) {
            add(DataType.FLOAT, DataKind.RED, false, 32, prefix + "R");
            add(DataType.FLOAT, DataKind.GREEN, false, 32, prefix + "G");
            add(DataType.FLOAT, DataKind.BLUE, false, 32, prefix + "B");
            add(DataType.FLOAT, DataKind.ALPHA, false, 32, prefix + "A");
            add(DataType.FLOAT, DataKind.RED, false, 32, prefix + "r");
            add(DataType.FLOAT, DataKind.GREEN, false, 32, prefix + "g");
            add(DataType.FLOAT, DataKind.BLUE, false, 32, prefix + "b");
            add(DataType.FLOAT, DataKind.ALPHA, false, 32, prefix + "a");
            return this;
        }

@@ -338,10 +338,10 @@ public class Element extends BaseObj {
        }

        public Builder addUNorm8RGBA(String prefix) {
            add(DataType.UNSIGNED, DataKind.RED, true, 8, prefix + "R");
            add(DataType.UNSIGNED, DataKind.GREEN, true, 8, prefix + "G");
            add(DataType.UNSIGNED, DataKind.BLUE, true, 8, prefix + "B");
            add(DataType.UNSIGNED, DataKind.ALPHA, true, 8, prefix + "A");
            add(DataType.UNSIGNED, DataKind.RED, true, 8, prefix + "r");
            add(DataType.UNSIGNED, DataKind.GREEN, true, 8, prefix + "g");
            add(DataType.UNSIGNED, DataKind.BLUE, true, 8, prefix + "b");
            add(DataType.UNSIGNED, DataKind.ALPHA, true, 8, prefix + "a");
            return this;
        }

+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public class RenderScript {
    native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, float[] d, int sizeBytes);
    native void nAllocationRead(int id, int[] d);
    native void nAllocationRead(int id, float[] d);
    native void nAllocationDataFromObject(int id, Type t, Object o);
    native void nAllocationSubDataFromObject(int id, Type t, int offset, Object o);

    native void nTriangleMeshBegin(int vertex, int index);
    native void nTriangleMeshAddVertex_XY (float x, float y);
+7 −0
Original line number Diff line number Diff line
@@ -50,6 +50,13 @@ public class SimpleMesh extends BaseObj {
        return Allocation.createTyped(mRS, mIndexType);
    }

    public Type getVertexType(int slot) {
        return mVertexTypes[slot];
    }

    public Type getIndexType() {
        return mIndexType;
    }

    public static class Builder {
        RenderScript mRS;
+3 −3
Original line number Diff line number Diff line
@@ -543,7 +543,7 @@ nAllocationRead_f(JNIEnv *_env, jobject _this, jint alloc, jfloatArray data)

//{"nAllocationDataFromObject",      "(ILandroid/renderscript/Type;Ljava/lang/Object;)V",   (void*)nAllocationDataFromObject },
static void
nAllocationDataFromObject(JNIEnv *_env, jobject _this, jint alloc, jobject _type, jobject _o)
nAllocationSubDataFromObject(JNIEnv *_env, jobject _this, jint alloc, jobject _type, jint offset, jobject _o)
{
    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
    LOG_API("nAllocationDataFromObject con(%p), alloc(%p)", con, (RsAllocation)alloc);
@@ -556,7 +556,7 @@ nAllocationDataFromObject(JNIEnv *_env, jobject _this, jint alloc, jobject _type
        const TypeFieldCache *tfc = &tc->fields[ct];
        buf = tfc->ptr(_env, _o, tfc->field, buf);
    }
    rsAllocationData(con, (RsAllocation)alloc, bufAlloc, tc->size);
    rsAllocation1DSubData(con, (RsAllocation)alloc, offset, 1, bufAlloc, tc->size);
    const uint32_t * tmp = (const uint32_t *)bufAlloc;
    free(bufAlloc);
}
@@ -1282,7 +1282,7 @@ static JNINativeMethod methods[] = {
{"nAllocationSubData2D",           "(IIIII[FI)V",                          (void*)nAllocationSubData2D_f },
{"nAllocationRead",                "(I[I)V",                               (void*)nAllocationRead_i },
{"nAllocationRead",                "(I[F)V",                               (void*)nAllocationRead_f },
{"nAllocationDataFromObject",      "(ILandroid/renderscript/Type;Ljava/lang/Object;)V",   (void*)nAllocationDataFromObject },
{"nAllocationSubDataFromObject",   "(ILandroid/renderscript/Type;ILjava/lang/Object;)V",   (void*)nAllocationSubDataFromObject },

{"nTriangleMeshBegin",             "(II)V",                                (void*)nTriangleMeshBegin },
{"nTriangleMeshAddVertex_XY",      "(FF)V",                                (void*)nTriangleMeshAddVertex_XY },
Loading