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

Commit faf1520b authored by Jason Sams's avatar Jason Sams
Browse files

Filmstrip work and boxed bitmap load bugfixes.

parent 31b532ee
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ int main(int index)


    // Start of images.
    bindProgramFragmentStore(NAMED_PFImages);
    bindProgramFragment(NAMED_PFSImages);
    bindProgramFragmentStore(NAMED_PFSImages);
    bindProgramFragment(NAMED_PFImages);
    bindProgramVertex(NAMED_PVImages);

    float focusPos = loadF(1, POS_FOCUS);
@@ -87,7 +87,16 @@ int main(int index)

        offset = offset + triangleOffsetsCount / 2;

        if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
    int drawit = 1;
    if (offset < 0) {
        drawit = 0;
    }
    if (offset >= triangleOffsetsCount) {
        drawit = 0;
    }

        //if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
        if (drawit) {
            int start = offset -2;
            int end = offset + 2;

@@ -99,11 +108,9 @@ int main(int index)
            }

            bindTexture(NAMED_PFImages, 0, loadI32(0, imgId - 1));
    /*
            matrixLoadTranslate(con, &m, -pos - env->triangleOffsetsTex[env->triangleOffsetsCount / 2], 0, 0);
            storeEnvMatrix(con, 3, RS_PROGRAM_VERTEX_TEXTURE_OFFSET, &m);
            renderTriangleMeshRange(con, env->mesh, env->triangleOffsets[start], env->triangleOffsets[end] - env->triangleOffsets[start]);
    */
            matrixLoadTranslate(&f16, -pos - loadF(5, triangleOffsetsCount / 2), 0, 0);
            vpLoadTextureMatrix(&f16);
            drawTriangleMeshRange(NAMED_mesh, loadI32(4, start), loadI32(4, end) - loadI32(4, start));
        }
    }
    return 0;
+37 −19
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public class FilmRS {
        float anim = ((float)x-50) / 270.f;
        mBufferPos[POS_TRANSLATE] = 2f * anim + 0.5f;   // translation
        mBufferPos[POS_ROTATE] = (anim * 40);  // rotation
        mBufferPos[POS_FOCUS] = ((float)y) / 16.f - 8;  // focusPos
        mBufferPos[POS_FOCUS] = ((float)y) / 16.f - 10.f;  // focusPos
        mAllocPos.data(mBufferPos);
    }

@@ -92,6 +92,9 @@ public class FilmRS {
    private RenderScript.Allocation mAllocPos;
    private RenderScript.Allocation mAllocState;
    private RenderScript.Allocation mAllocPV;
    private RenderScript.Allocation mAllocOffsetsTex;
    private RenderScript.Allocation mAllocOffsets;

    private RenderScript.TriangleMesh mMesh;
    private RenderScript.Light mLight;

@@ -101,21 +104,11 @@ public class FilmRS {
    private float[] mBufferPos = new float[3];
    private int[] mBufferState;

    private void initSamplers() {
        mRS.samplerBegin();
        mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN,
                       RenderScript.SamplerValue.LINEAR_MIP_LINEAR);
        mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_S,
                       RenderScript.SamplerValue.CLAMP);
        mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_T,
                       RenderScript.SamplerValue.CLAMP);
        mSampler = mRS.samplerCreate();
    }

    private void initPFS() {
        mRS.programFragmentStoreBegin(null, null);
        mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.LESS);
        mRS.programFragmentStoreDitherEnable(true);
        mRS.programFragmentStoreDepthMask(true);
        mPFSBackground = mRS.programFragmentStoreCreate();
        mPFSBackground.setName("PFSBackground");

@@ -130,15 +123,27 @@ public class FilmRS {
    }

    private void initPF() {
        mRS.samplerBegin();
        mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN,
                       RenderScript.SamplerValue.LINEAR);//_MIP_LINEAR);
        mRS.samplerSet(RenderScript.SamplerParam.FILTER_MAG,
                       RenderScript.SamplerValue.LINEAR);
        mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_S,
                       RenderScript.SamplerValue.CLAMP);
        mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_T,
                       RenderScript.SamplerValue.WRAP);
        mSampler = mRS.samplerCreate();


        mRS.programFragmentBegin(null, null);
        mPFBackground = mRS.programFragmentCreate();
        mPFBackground.setName("PFBackground");

        mRS.programFragmentBegin(null, null);
        mRS.programFragmentSetTexEnable(0, true);
        //mRS.programFragmentSetEnvMode(0, RS_TEX_ENV_MODE_REPLACE);
        //rsProgramFragmentSetType(0, gEnv.tex[0]->getType());
        mRS.programFragmentSetTexEnvMode(0, RenderScript.EnvMode.REPLACE);
        mPFImages = mRS.programFragmentCreate();
        mPFImages.bindSampler(mSampler, 0);
        mPFImages.setName("PFImages");
    }

@@ -148,12 +153,12 @@ public class FilmRS {
        mLight.setPosition(0, -0.5f, -1.0f);

        mRS.programVertexBegin(null, null);
        mRS.programVertexSetTextureMatrixEnable(true);
        mRS.programVertexAddLight(mLight);
        mPVBackground = mRS.programVertexCreate();
        mPVBackground.setName("PVBackground");

        mRS.programVertexBegin(null, null);
        mRS.programVertexSetTextureMatrixEnable(true);
        mPVImages = mRS.programVertexCreate();
        mPVImages.setName("PVImages");
    }
@@ -179,8 +184,8 @@ public class FilmRS {
        b = BitmapFactory.decodeResource(mRes, R.drawable.p03, opts);
        mImages[2] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);

        b = BitmapFactory.decodeResource(mRes, R.drawable.p04, opts);
        mImages[3] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
        b = BitmapFactory.decodeResource(mRes, R.drawable.path1927, opts);
        mImages[3] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);

        b = BitmapFactory.decodeResource(mRes, R.drawable.p05, opts);
        mImages[4] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
@@ -242,10 +247,8 @@ public class FilmRS {
        mMesh.setName("mesh");

        initPFS();
        initSamplers();
        initPF();
        initPV();
        mPFImages.bindSampler(mSampler, 0);

        Log.e("rs", "Done loading named");

@@ -274,6 +277,21 @@ public class FilmRS {
        mScriptStrip.bindAllocation(mPVA.mAlloc, 3);


        mAllocOffsets = mRS.allocationCreatePredefSized(
            RenderScript.ElementPredefined.USER_I32,
            mFSM.mTriangleOffsets.length);
        mAllocOffsets.data(mFSM.mTriangleOffsets);
        mScriptStrip.bindAllocation(mAllocOffsets, 4);

        mAllocOffsetsTex = mRS.allocationCreatePredefSized(
            RenderScript.ElementPredefined.USER_FLOAT,
            mFSM.mTriangleOffsetsTex.length);
        mAllocOffsetsTex.data(mFSM.mTriangleOffsetsTex);
        mScriptStrip.bindAllocation(mAllocOffsetsTex, 5);




/*
        {
            Resources res = getResources();
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ public class FilmView extends RSSurfaceView {
        if (act == ev.ACTION_UP) {
            ret = false;
        }
        mRender.setFilmStripPosition((int)ev.getX(), (int)ev.getY());
        mRender.setFilmStripPosition((int)ev.getX(), (int)ev.getY() / 5);
        return ret;
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -80,15 +80,15 @@ int main(void* con, int ft, int launchID)
        float tmpCos = cosf(rot);
            //debugF("rot", rot);

        float tx1 = tmpSin * diam - (tmpCos * scale);
        float tx2 = tx1 + (tmpCos * scale * 2.f);
        float tz1 = tmpCos * diam + (tmpSin * scale);
        float tz2 = tz1 - (tmpSin * scale * 2.f);
        float tx1 = tmpSin * diam - (tmpCos * scale * 0.9f);
        float tx2 = tx1 + (tmpCos * scale * 1.8f);
        float tz1 = tmpCos * diam + (tmpSin * scale * 0.9f);
        float tz2 = tz1 - (tmpSin * scale * 1.8f);

        int y;
        for (y = rowCount -1; (y >= 0) && iconCount; y--) {
            float ty1 = ((y * 3.1f) - 5.f) * scale;
            float ty2 = ty1 + scale * 2.f;
            float ty2 = ty1 + scale * 1.8f;
            bindTexture(NAMED_PF, 0, loadI32(1, index));
            //if (done && (index != selectedID)) {
                //color(0.4f, 0.4f, 0.4f, 1.0f);
+2 −5
Original line number Diff line number Diff line
@@ -200,9 +200,6 @@ public class RolloRS {
        mRS.contextBindProgramVertex(mPV);

        mAllocScratchBuf = new int[32];
        for(int ct=0; ct < mAllocScratchBuf.length; ct++) {
            mAllocScratchBuf[ct] = 0;
        }
        mAllocScratch = mRS.allocationCreatePredefSized(
            RenderScript.ElementPredefined.USER_I32, mAllocScratchBuf.length);
        mAllocScratch.data(mAllocScratchBuf);
@@ -417,9 +414,9 @@ public class RolloRS {
        Canvas c = new Canvas(b);
        Paint p = new Paint();
        p.setTypeface(Typeface.DEFAULT_BOLD);
        p.setTextSize(16);
        p.setTextSize(20);
        p.setColor(0xffffffff);
        c.drawText(t, 2, 20, p);
        c.drawText(t, 2, 26, p);
        return mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
    }

Loading