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

Commit b93cdae7 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 21570 into eclair

* changes:
  Update fountain and add writable flag to script slots.
parents 5e787c42 334ea0c9
Loading
Loading
Loading
Loading
+46 −0
Original line number Original line Diff line number Diff line
@@ -223,6 +223,52 @@ public class Element extends BaseObj {
            return this;
            return this;
        }
        }


        public Builder addFloat(Element.DataKind dk) {
            add(DataType.FLOAT, dk, false, 32, null);
            return this;
        }

        public Builder addFloat(Element.DataKind dk, String name) {
            add(DataType.FLOAT, dk, false, 32, name);
            return this;
        }

        public Builder addFloatXY() {
            add(DataType.FLOAT, DataKind.X, false, 32, null);
            add(DataType.FLOAT, DataKind.Y, false, 32, null);
            return this;
        }

        public Builder addFloatXYZ() {
            add(DataType.FLOAT, DataKind.X, false, 32, null);
            add(DataType.FLOAT, DataKind.Y, false, 32, null);
            add(DataType.FLOAT, DataKind.Z, false, 32, null);
            return this;
        }

        public Builder addFloatRGB() {
            add(DataType.FLOAT, DataKind.RED, false, 32, null);
            add(DataType.FLOAT, DataKind.GREEN, false, 32, null);
            add(DataType.FLOAT, DataKind.BLUE, false, 32, null);
            return this;
        }

        public Builder addFloatRGBA() {
            add(DataType.FLOAT, DataKind.RED, false, 32, null);
            add(DataType.FLOAT, DataKind.GREEN, false, 32, null);
            add(DataType.FLOAT, DataKind.BLUE, false, 32, null);
            add(DataType.FLOAT, DataKind.ALPHA, false, 32, null);
            return this;
        }

        public Builder addUNorm8RGBA() {
            add(DataType.UNSIGNED, DataKind.RED, true, 8, null);
            add(DataType.UNSIGNED, DataKind.GREEN, true, 8, null);
            add(DataType.UNSIGNED, DataKind.BLUE, true, 8, null);
            add(DataType.UNSIGNED, DataKind.ALPHA, true, 8, null);
            return this;
        }

        static synchronized Element internalCreate(RenderScript rs, Builder b) {
        static synchronized Element internalCreate(RenderScript rs, Builder b) {
            rs.nElementBegin();
            rs.nElementBegin();
            for (int ct=0; ct < b.mEntryCount; ct++) {
            for (int ct=0; ct < b.mEntryCount; ct++) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -142,7 +142,7 @@ public class RenderScript {
    native void nScriptSetClearDepth(int script, float depth);
    native void nScriptSetClearDepth(int script, float depth);
    native void nScriptSetClearStencil(int script, int stencil);
    native void nScriptSetClearStencil(int script, int stencil);
    native void nScriptSetTimeZone(int script, byte[] timeZone);
    native void nScriptSetTimeZone(int script, byte[] timeZone);
    native void nScriptSetType(int type, String name, int slot);
    native void nScriptSetType(int type, boolean writable, String name, int slot);
    native void nScriptSetRoot(boolean isRoot);
    native void nScriptSetRoot(boolean isRoot);


    native void nScriptCBegin();
    native void nScriptCBegin();
+8 −1
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ public class Script extends BaseObj {


    boolean mIsRoot;
    boolean mIsRoot;
    Type[] mTypes;
    Type[] mTypes;
    boolean[] mWritable;


    Script(int id, RenderScript rs) {
    Script(int id, RenderScript rs) {
        super(rs);
        super(rs);
@@ -67,11 +68,13 @@ public class Script extends BaseObj {
        boolean mIsRoot = false;
        boolean mIsRoot = false;
        Type[] mTypes;
        Type[] mTypes;
        String[] mNames;
        String[] mNames;
        boolean[] mWritable;


        Builder(RenderScript rs) {
        Builder(RenderScript rs) {
            mRS = rs;
            mRS = rs;
            mTypes = new Type[MAX_SLOT];
            mTypes = new Type[MAX_SLOT];
            mNames = new String[MAX_SLOT];
            mNames = new String[MAX_SLOT];
            mWritable = new boolean[MAX_SLOT];
        }
        }


        public void setType(Type t, int slot) {
        public void setType(Type t, int slot) {
@@ -84,11 +87,15 @@ public class Script extends BaseObj {
            mNames[slot] = name;
            mNames[slot] = name;
        }
        }


        public void setType(boolean writable, int slot) {
            mWritable[slot] = writable;
        }

        void transferCreate() {
        void transferCreate() {
            mRS.nScriptSetRoot(mIsRoot);
            mRS.nScriptSetRoot(mIsRoot);
            for(int ct=0; ct < mTypes.length; ct++) {
            for(int ct=0; ct < mTypes.length; ct++) {
                if(mTypes[ct] != null) {
                if(mTypes[ct] != null) {
                    mRS.nScriptSetType(mTypes[ct].mID, mNames[ct], ct);
                    mRS.nScriptSetType(mTypes[ct].mID, mWritable[ct], mNames[ct], ct);
                }
                }
            }
            }
        }
        }
+4 −4
Original line number Original line Diff line number Diff line
@@ -825,15 +825,15 @@ nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone
}
}


static void
static void
nScriptSetType(JNIEnv *_env, jobject _this, jint type, jstring _str, jint slot)
nScriptSetType(JNIEnv *_env, jobject _this, jint type, jboolean writable, jstring _str, jint slot)
{
{
    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
    LOG_API("nScriptCAddType, con(%p), type(%p), slot(%i)", con, (RsType)type, slot);
    LOG_API("nScriptCAddType, con(%p), type(%p), writable(%i), slot(%i)", con, (RsType)type, writable, slot);
    const char* n = NULL;
    const char* n = NULL;
    if (_str) {
    if (_str) {
        n = _env->GetStringUTFChars(_str, NULL);
        n = _env->GetStringUTFChars(_str, NULL);
    }
    }
    rsScriptSetType((RsType)type, slot, n);
    rsScriptSetType((RsType)type, slot, writable, n);
    if (n) {
    if (n) {
        _env->ReleaseStringUTFChars(_str, n);
        _env->ReleaseStringUTFChars(_str, n);
    }
    }
@@ -1381,7 +1381,7 @@ static JNINativeMethod methods[] = {
{"nScriptSetClearDepth",           "(IF)V",                                (void*)nScriptSetClearDepth },
{"nScriptSetClearDepth",           "(IF)V",                                (void*)nScriptSetClearDepth },
{"nScriptSetClearStencil",         "(II)V",                                (void*)nScriptSetClearStencil },
{"nScriptSetClearStencil",         "(II)V",                                (void*)nScriptSetClearStencil },
{"nScriptSetTimeZone",             "(I[B)V",                               (void*)nScriptSetTimeZone },
{"nScriptSetTimeZone",             "(I[B)V",                               (void*)nScriptSetTimeZone },
{"nScriptSetType",                 "(ILjava/lang/String;I)V",              (void*)nScriptSetType },
{"nScriptSetType",                 "(IZLjava/lang/String;I)V",             (void*)nScriptSetType },
{"nScriptSetRoot",                 "(Z)V",                                 (void*)nScriptSetRoot },
{"nScriptSetRoot",                 "(Z)V",                                 (void*)nScriptSetRoot },


{"nScriptCBegin",                  "()V",                                  (void*)nScriptCBegin },
{"nScriptCBegin",                  "()V",                                  (void*)nScriptCBegin },
+31 −65
Original line number Original line Diff line number Diff line
// Fountain test script
// Fountain test script

#pragma version(1)
#pragma version(1)
#pragma stateVertex(default)
#pragma stateVertex(default)
#pragma stateFragment(PgmFragParts)
#pragma stateFragment(default)
#pragma stateFragmentStore(PFSBlend)
#pragma stateFragmentStore(default)



int main(int launchID) {
int main(int launchID) {
    int ct;
    int ct;
    int count = loadI32(0, OFFSETOF_SomeData_count);
    int count = Control_count - 1;
    int touch = loadI32(0, OFFSETOF_SomeData_touch);
    int rate = Control_rate;
    int rate = 4;
    float *dataF = loadArrayF(1, 0);
    int maxLife = (count / rate) - 1;
    float height = getHeight();


    if (touch) {
    if (rate) {
        int x = loadI32(0, OFFSETOF_SomeData_x);
        debugI32("rate", rate);
        int y = loadI32(0, OFFSETOF_SomeData_y);
        int *dataI = loadArrayI32(1, 0);
        int newPart = loadI32(2, 0);
        float rMax = ((float)rate) * 0.005f;
        for (ct=0; ct<rate; ct++) {
        int x = Control_x;
            int idx = newPart * 5 + 1;
        int y = Control_y;
            storeF(2, idx, randf(1.f) - 0.5f);
        int newPart = loadI32(1, count * 5);
            storeF(2, idx + 1, randf(1.f) - 0.5f);
        int c = colorFloatRGBAtoUNorm8(Control_r, Control_g, Control_b, 0.99f);
            storeI32(2, idx + 2, maxLife);

            storeF(2, idx + 3, x);
        while (rate--) {
            storeF(2, idx + 4, y);
            int idx = newPart * 5;
            vec2Rand(dataF + idx, rMax);
            dataF[idx + 2] = x;
            dataF[idx + 3] = y;
            dataI[idx + 4] = c;
            newPart++;
            newPart++;
            if (newPart >= count) {
            if (newPart >= count) {
                newPart = 0;
                newPart = 0;
            }
            }
        }
        }
        storeI32(2, 0, newPart);
        storeI32(1, count * 5, newPart);
    }
    }


    int drawCount = 0;
    float height = getHeight();
    for (ct=0; ct < count; ct++) {
    for (ct=0; ct < count; ct++) {
        int srcIdx = ct * 5 + 1;
        float dy = dataF[1] + 0.15f;

        float posy = dataF[3] + dy;
        int life = loadI32(2, srcIdx + 2);
        if ((posy > height) && (dy > 0)) {

            dy *= -0.3f;
        if (life) {
            float posx = loadF(2, srcIdx + 3);
            float posy = loadF(2, srcIdx + 4);
            float dx = loadF(2, srcIdx);
            float dy = loadF(2, srcIdx + 1);
            if (posy < height) {
                int dstIdx = drawCount * 9;
                int c = 0xcfcfcfcf;

                storeI32(1, dstIdx, c);
                storeF(1, dstIdx + 1, posx);
                storeF(1, dstIdx + 2, posy);

                storeI32(1, dstIdx + 3, c);
                storeF(1, dstIdx + 4, posx + 1.f);
                storeF(1, dstIdx + 5, posy + dy);

                storeI32(1, dstIdx + 6, c);
                storeF(1, dstIdx + 7, posx - 1.f);
                storeF(1, dstIdx + 8, posy + dy);
                drawCount ++;
            } else {
                if (dy > 0) {
                    dy *= -0.5f;
                }
            }

            posx = posx + dx;
            posy = posy + dy;
            dy = dy + 0.05f;
            life --;

            //storeI32(2, srcIdx, dx);
            storeF(2, srcIdx + 1, dy);
            storeI32(2, srcIdx + 2, life);
            storeF(2, srcIdx + 3, posx);
            storeF(2, srcIdx + 4, posy);
        }
        }
        dataF[1] = dy;
        dataF[2] += dataF[0];
        dataF[3] = posy;
        dataF += 5;
    }
    }


    //drawTriangleArray(NAMED_PartBuffer, drawCount);
    uploadToBufferObject(NAMED_PartBuffer);
    uploadToBufferObject(NAMED_PartBuffer);
    drawSimpleMeshRange(NAMED_PartMesh, 0, drawCount * 3);
    drawSimpleMeshRange(NAMED_PartMesh, 0, count);
    return 1;
    return 1;
}
}
Loading