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

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

Fix fountain and more rollo ui work.

parent 7df07026
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
    package="com.android.fountain">
    <application android:label="Fountain">
        <activity android:name="Fountain"
                  android:theme="@android:style/Theme.Black.NoTitleBar">
                  android:theme="@android:style/Theme.Translucent">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
+7 −11
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@

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


int main(int launchID) {
@@ -34,15 +34,11 @@ int main(int launchID) {
        }
    }

    drawRect(0, 256, 0, 512);
    contextBindProgramFragment(NAMED_PgmFragParts);
    contextBindProgramFragmentStore(NAMED_PFSBlend);

    if (touch) {
        newPart = loadI32(2, 0);
        for (ct2=0; ct2<rate; ct2++) {
            dx = scriptRand(0x10000) - 0x8000;
            dy = scriptRand(0x10000) - 0x8000;
            dx = (int)((randf(1.f) - 0.5f) * 0x10000);
            dy = (int)((randf(1.f) - 0.5f) * 0x10000);

            idx = newPart * 5 + 1;
            storeI32(2, idx, dx);
@@ -74,15 +70,15 @@ int main(int launchID) {
                dstIdx = drawCount * 9;
                c = 0xffafcf | ((life >> lifeShift) << 24);

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

                storeU32(1, dstIdx + 3, c);
                storeI32(1, dstIdx + 3, c);
                storeI32(1, dstIdx + 4, posx + 0x10000);
                storeI32(1, dstIdx + 5, posy + dy * 4);

                storeU32(1, dstIdx + 6, c);
                storeI32(1, dstIdx + 6, c);
                storeI32(1, dstIdx + 7, posx - 0x10000);
                storeI32(1, dstIdx + 8, posy + dy * 4);
                drawCount ++;
+0 −37
Original line number Diff line number Diff line
@@ -56,11 +56,7 @@ public class FountainRS {
    private RenderScript.Allocation mVertAlloc;
    private RenderScript.Script mScript;
    private RenderScript.ProgramFragmentStore mPFS;
    private RenderScript.ProgramFragmentStore mPFS2;
    private RenderScript.ProgramFragment mPF;
    private RenderScript.ProgramFragment mPF2;
    private RenderScript.Allocation mTexture;
    private RenderScript.Sampler mSampler;

    private Bitmap mBackground;

@@ -74,16 +70,6 @@ public class FountainRS {
        mPartAlloc.setName("PartBuffer");
        mVertAlloc = mRS.allocationCreatePredefSized(RenderScript.ElementPredefined.USER_I32, partCount * 5 + 1);

        {
            Drawable d = mRes.getDrawable(R.drawable.gadgets_clock_mp3);
            BitmapDrawable bd = (BitmapDrawable)d;
            Bitmap b = bd.getBitmap();
            mTexture = mRS.allocationCreateFromBitmap(b,
                                                      RenderScript.ElementPredefined.RGB_565,
                                                      false);
            mTexture.uploadToTexture(0);
        }

        mRS.programFragmentStoreBegin(null, null);
        mRS.programFragmentStoreBlendFunc(RenderScript.BlendSrcFunc.SRC_ALPHA, RenderScript.BlendDstFunc.ONE);
        mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS);
@@ -92,33 +78,10 @@ public class FountainRS {
        mPFS = mRS.programFragmentStoreCreate();
        mPFS.setName("PFSBlend");

        mRS.programFragmentStoreBegin(null, null);
        mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS);
        mRS.programFragmentStoreDepthMask(false);
        mRS.programFragmentStoreDitherEnable(false);
        mPFS2 = mRS.programFragmentStoreCreate();
        mPFS2.setName("PFSReplace");
        mRS.contextBindProgramFragmentStore(mPFS2);

        mRS.samplerBegin();
        mRS.samplerSet(RenderScript.SamplerParam.FILTER_MAG, RenderScript.SamplerValue.NEAREST);
        mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN, RenderScript.SamplerValue.NEAREST);
        mSampler = mRS.samplerCreate();


        mRS.programFragmentBegin(null, null);
        mPF = mRS.programFragmentCreate();
        mPF.setName("PgmFragParts");

        mRS.programFragmentBegin(null, null);
        mRS.programFragmentSetTexEnable(0, true);
        mPF2 = mRS.programFragmentCreate();
        mRS.contextBindProgramFragment(mPF2);
        mPF2.bindTexture(mTexture, 0);
        mPF2.bindSampler(mSampler, 0);
        mPF2.setName("PgmFragBackground");


        mParams[0] = 0;
        mParams[1] = partCount;
        mParams[2] = 0;
+4 −0
Original line number Diff line number Diff line
@@ -846,6 +846,10 @@ public class RenderScript {
        nProgramFragmentSetTexEnable(slot, enable);
    }

    public void programFragmentSetTexEnvMode(int slot, EnvMode env) {
        nProgramFragmentSetEnvMode(slot, env.mID);
    }

    public ProgramFragment programFragmentCreate() {
        int id = nProgramFragmentCreate();
        return new ProgramFragment(id);
+27 −11
Original line number Diff line number Diff line
@@ -8,11 +8,11 @@
#define SCRATCH_ZOOM 1
#define SCRATCH_ROT 2

#define STATE_POS_X             0
#define STATE_POS_Y             1
#define STATE_PRESSURE          2
//#define STATE_POS_X             0
#define STATE_DONE              1
//#define STATE_PRESSURE          2
#define STATE_ZOOM              3
#define STATE_WARP              4
//#define STATE_WARP              4
#define STATE_ORIENTATION       5
#define STATE_SELECTION         6
#define STATE_FIRST_VISIBLE     7
@@ -31,21 +31,31 @@ int main(void* con, int ft, int launchID)
    int row;
    int col;
    int imageID;
    int iconCount;
    int done = loadI32(0, STATE_DONE);
    int selectedID = loadI32(0, STATE_SELECTION);

    float f = loadF(2, 0);

    pfClearColor(0.0f, 0.0f, 0.0f, f);
    if (done) {
        if (f > 0.02f) {
            //f = f - 0.02f;
            //storeF(2, 0, f);
        }
    } else {
        if (f < 0.8f) {
            f = f + 0.02f;
            storeF(2, 0, f);
        }
    }

    float touchCut = 1.f;
    if (loadI32(0, STATE_TOUCH)) {
        touchCut = 5.f;
    }

    float targetZoom = ((float)loadI32(0, STATE_ZOOM)) / 10.f;

    float targetZoom = ((float)loadI32(0, STATE_ZOOM)) / 1000.f;
    float zoom = filter(loadF(2, SCRATCH_ZOOM), targetZoom, 0.15 * touchCut);
    storeF(2, SCRATCH_ZOOM, zoom);

@@ -59,7 +69,8 @@ int main(void* con, int ft, int launchID)
    rot = rot * scale;
    float rotStep = 20.0f / 180.0f * 3.14f * scale;
    rowCount = 4;
    iconCount = 32;//loadI32(0, 1);
    int index = 0;
    int iconCount = loadI32(0, STATE_COUNT);
    while (iconCount) {
        float tmpSin = sinf(rot);
        float tmpCos = cosf(rot);
@@ -70,15 +81,20 @@ int main(void* con, int ft, int launchID)
        float tz2 = tz1 - (tmpSin * scale * 2.f);

        int y;
        for (y = 0; (y < rowCount) && iconCount; y++) {
        for (y = rowCount -1; (y >= 0) && iconCount; y--) {
            float ty1 = ((y * 3.0f) - 4.5f) * scale;
            float ty2 = ty1 + scale * 2.f;
            pfBindTexture(NAMED_PF, 0, loadI32(1, y));
            color(1.0f, 1.0f, 1.0f, 1.0f);
            if (done && (index != selectedID)) {
                color(0.4f, 0.4f, 0.4f, 1.0f);
            }
            drawQuad(tx1, ty1, tz1,
                     tx2, ty1, tz2,
                     tx2, ty2, tz2,
                     tx1, ty2, tz1);
            iconCount--;
            index++;
        }
        rot = rot + rotStep;
    }
Loading