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

Commit 462d11b8 authored by Jason Sams's avatar Jason Sams
Browse files

checkpoint filmstrip, implemented TLS.

parent 2d9c39d6
Loading
Loading
Loading
Loading
+40 −40
Original line number Diff line number Diff line
@@ -30,64 +30,64 @@ typedef struct {
#define RS_PROGRAM_VERTEX_TEXTURE_OFFSET 32

typedef struct {
    const void * (*loadEnvVp)(void *con, uint32_t bank, uint32_t offset);
    const void * (*loadEnvVp)(uint32_t bank, uint32_t offset);

    float (*loadEnvF)(void *con, uint32_t bank, uint32_t offset);
    int32_t (*loadEnvI32)(void *con, uint32_t bank, uint32_t offset);
    uint32_t (*loadEnvU32)(void *con, uint32_t bank, uint32_t offset);
    void (*loadEnvVec4)(void *con, uint32_t bank, uint32_t offset, rsc_Vector4 *);
    void (*loadEnvMatrix)(void *con, uint32_t bank, uint32_t offset, rsc_Matrix *);
    float (*loadEnvF)(uint32_t bank, uint32_t offset);
    int32_t (*loadEnvI32)(uint32_t bank, uint32_t offset);
    uint32_t (*loadEnvU32)(uint32_t bank, uint32_t offset);
    void (*loadEnvVec4)(uint32_t bank, uint32_t offset, rsc_Vector4 *);
    void (*loadEnvMatrix)(uint32_t bank, uint32_t offset, rsc_Matrix *);

    void (*storeEnvF)(void *con, uint32_t bank, uint32_t offset, float);
    void (*storeEnvI32)(void *con, uint32_t bank, uint32_t offset, int32_t);
    void (*storeEnvU32)(void *con, uint32_t bank, uint32_t offset, uint32_t);
    void (*storeEnvVec4)(void *con, uint32_t bank, uint32_t offset, const rsc_Vector4 *);
    void (*storeEnvMatrix)(void *con, uint32_t bank, uint32_t offset, const rsc_Matrix *);
    void (*storeEnvF)(uint32_t bank, uint32_t offset, float);
    void (*storeEnvI32)(uint32_t bank, uint32_t offset, int32_t);
    void (*storeEnvU32)(uint32_t bank, uint32_t offset, uint32_t);
    void (*storeEnvVec4)(uint32_t bank, uint32_t offset, const rsc_Vector4 *);
    void (*storeEnvMatrix)(uint32_t bank, uint32_t offset, const rsc_Matrix *);

    void (*matrixLoadIdentity)(void *con, rsc_Matrix *);
    void (*matrixLoadFloat)(void *con, rsc_Matrix *, const float *);
    void (*matrixLoadMat)(void *con, rsc_Matrix *, const rsc_Matrix *);
    void (*matrixLoadRotate)(void *con, rsc_Matrix *, float rot, float x, float y, float z);
    void (*matrixLoadScale)(void *con, rsc_Matrix *, float x, float y, float z);
    void (*matrixLoadTranslate)(void *con, rsc_Matrix *, float x, float y, float z);
    void (*matrixLoadMultiply)(void *con, rsc_Matrix *, const rsc_Matrix *lhs, const rsc_Matrix *rhs);
    void (*matrixMultiply)(void *con, rsc_Matrix *, const rsc_Matrix *rhs);
    void (*matrixRotate)(void *con, rsc_Matrix *, float rot, float x, float y, float z);
    void (*matrixScale)(void *con, rsc_Matrix *, float x, float y, float z);
    void (*matrixTranslate)(void *con, rsc_Matrix *, float x, float y, float z);
    void (*matrixLoadIdentity)(rsc_Matrix *);
    void (*matrixLoadFloat)(rsc_Matrix *, const float *);
    void (*matrixLoadMat)(rsc_Matrix *, const rsc_Matrix *);
    void (*matrixLoadRotate)(rsc_Matrix *, float rot, float x, float y, float z);
    void (*matrixLoadScale)(rsc_Matrix *, float x, float y, float z);
    void (*matrixLoadTranslate)(rsc_Matrix *, float x, float y, float z);
    void (*matrixLoadMultiply)(rsc_Matrix *, const rsc_Matrix *lhs, const rsc_Matrix *rhs);
    void (*matrixMultiply)(rsc_Matrix *, const rsc_Matrix *rhs);
    void (*matrixRotate)(rsc_Matrix *, float rot, float x, float y, float z);
    void (*matrixScale)(rsc_Matrix *, float x, float y, float z);
    void (*matrixTranslate)(rsc_Matrix *, float x, float y, float z);

    void (*color)(void *con, float r, float g, float b, float a);
    void (*color)(float r, float g, float b, float a);

    void (*programFragmentBindTexture)(void *con, RsProgramFragment, uint32_t slot, RsAllocation);
    void (*programFragmentBindSampler)(void *con, RsProgramFragment, uint32_t slot, RsAllocation);
    void (*programFragmentBindTexture)(RsProgramFragment, uint32_t slot, RsAllocation);
    void (*programFragmentBindSampler)(RsProgramFragment, uint32_t slot, RsAllocation);

    void (*materialDiffuse)(void *con, float r, float g, float b, float a);
    void (*materialSpecular)(void *con, float r, float g, float b, float a);
    void (*lightPosition)(void *con, float x, float y, float z, float w);
    void (*materialShininess)(void *con, float s);
    void (*materialDiffuse)(float r, float g, float b, float a);
    void (*materialSpecular)(float r, float g, float b, float a);
    void (*lightPosition)(float x, float y, float z, float w);
    void (*materialShininess)(float s);

    void (*uploadToTexture)(void *con, RsAllocation va, uint32_t baseMipLevel);
    void (*uploadToTexture)(RsAllocation va, uint32_t baseMipLevel);

    void (*enable)(void *con, uint32_t);
    void (*disable)(void *con, uint32_t);
    void (*enable)(uint32_t);
    void (*disable)(uint32_t);

    uint32_t (*rand)(void *con, uint32_t max);
    uint32_t (*rand)(uint32_t max);

    void (*contextBindProgramFragment)(void *con, RsProgramFragment pf);
    void (*contextBindProgramFragmentStore)(void *con, RsProgramFragmentStore pfs);
    void (*contextBindProgramFragment)(RsProgramFragment pf);
    void (*contextBindProgramFragmentStore)(RsProgramFragmentStore pfs);


    // Drawing funcs
    void (*renderTriangleMesh)(void *con, RsTriangleMesh);
    void (*renderTriangleMeshRange)(void *con, RsTriangleMesh, uint32_t start, uint32_t count);
    void (*renderTriangleMesh)(RsTriangleMesh);
    void (*renderTriangleMeshRange)(RsTriangleMesh, uint32_t start, uint32_t count);

    // Assumes (GL_FIXED) x,y,z (GL_UNSIGNED_BYTE)r,g,b,a
    void (*drawTriangleArray)(void *con, RsAllocation alloc, uint32_t count);
    void (*drawTriangleArray)(RsAllocation alloc, uint32_t count);

    void (*drawRect)(void *con, int32_t x1, int32_t x2, int32_t y1, int32_t y2);
    void (*drawRect)(int32_t x1, int32_t x2, int32_t y1, int32_t y2);
} rsc_FunctionTable;

typedef int (*rsc_RunScript)(void *con, const rsc_FunctionTable *, uint32_t launchIndex);
typedef int (*rsc_RunScript)(uint32_t launchIndex, const rsc_FunctionTable *);


/* EnableCap */
+25 −0
Original line number Diff line number Diff line
#
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript

LOCAL_PACKAGE_NAME := Film

include $(BUILD_PACKAGE)
+13 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.film">
    <application android:label="Film">
        <activity android:name="Film"
                  android:theme="@android:style/Theme.Black.NoTitleBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
+110 −0
Original line number Diff line number Diff line
// Fountain test script

#pragma version(1)
#pragma stateVertex(orthoWindow)
#pragma stateRaster(flat)
#pragma stateFragment(PgmFragBackground)
#pragma stateFragmentStore(MyBlend)


int main(void* con, int ft, int launchID) {
    int count, touch, x, y, rate, maxLife, lifeShift;
    int life;
    int ct, ct2;
    int newPart;
    int drawCount;
    int dx, dy, idx;
    int posx,posy;
    int c;
    int srcIdx;
    int dstIdx;

    count = loadI32(con, 0, 1);
    touch = loadI32(con, 0, 2);
    x = loadI32(con, 0, 3);
    y = loadI32(con, 0, 4);

    rate = 4;
    maxLife = (count / rate) - 1;
    lifeShift = 0;
    {
        life = maxLife;
        while (life > 255) {
            life = life >> 1;
            lifeShift ++;
        }
    }

    drawRect(con, 0, 256, 0, 512);
    contextBindProgramFragment(con, NAMED_PgmFragParts);

    if (touch) {
        newPart = loadI32(con, 2, 0);
        for (ct2=0; ct2<rate; ct2++) {
            dx = scriptRand(con, 0x10000) - 0x8000;
            dy = scriptRand(con, 0x10000) - 0x8000;

            idx = newPart * 5 + 1;
            storeI32(con, 2, idx, dx);
            storeI32(con, 2, idx + 1, dy);
            storeI32(con, 2, idx + 2, maxLife);
            storeI32(con, 2, idx + 3, x << 16);
            storeI32(con, 2, idx + 4, y << 16);

            newPart++;
            if (newPart >= count) {
                newPart = 0;
            }
        }
        storeI32(con, 2, 0, newPart);
    }

    drawCount = 0;
    for (ct=0; ct < count; ct++) {
        srcIdx = ct * 5 + 1;

        dx = loadI32(con, 2, srcIdx);
        dy = loadI32(con, 2, srcIdx + 1);
        life = loadI32(con, 2, srcIdx + 2);
        posx = loadI32(con, 2, srcIdx + 3);
        posy = loadI32(con, 2, srcIdx + 4);

        if (life) {
            if (posy < (480 << 16)) {
                dstIdx = drawCount * 9;
                c = 0xffafcf | ((life >> lifeShift) << 24);

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

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

                storeU32(con, 1, dstIdx + 6, c);
                storeI32(con, 1, dstIdx + 7, posx - 0x10000);
                storeI32(con, 1, dstIdx + 8, posy + dy * 4);
                drawCount ++;
            } else {
                if (dy > 0) {
                    dy = (-dy) >> 1;
                }
            }

            posx = posx + dx;
            posy = posy + dy;
            dy = dy + 0x400;
            life --;

            //storeI32(con, 2, srcIdx, dx);
            storeI32(con, 2, srcIdx + 1, dy);
            storeI32(con, 2, srcIdx + 2, life);
            storeI32(con, 2, srcIdx + 3, posx);
            storeI32(con, 2, srcIdx + 4, posy);
        }
    }

    drawTriangleArray(con, NAMED_PartBuffer, drawCount);
    return 1;
}
+131 −0
Original line number Diff line number Diff line
// Fountain test script

#pragma version(1)
#pragma stateVertex(PV)
#pragma stateFragment(default)
#pragma stateFragmentStore(default)

/*
typedef struct FilmScriptUserEnvRec {
    RsAllocation tex[13];
    int32_t triangleOffsets[64];
    float triangleOffsetsTex[64];
    int32_t triangleOffsetsCount;
} FilmScriptUserEnv; 
*/ 

// The script enviroment has 3 env allocations.
// bank0: (r) The enviroment structure
// bank1: (r) The position information
// bank2: (rw) The temporary texture state

int main(void* con, int ft, int index) 
{
    int f1;
    int f2;
    int f3;
    int f4;
    int f5;
    int f6;
    int f7;
    int f8;
    int f9;
    int f10;
    int f11;
    int f12;
    int f13;
    int f14;
    int f15;
    int f16;

    int trans;  // float
    int rot;   // float


    //trans = loadEnvF(con, 1, 0);
    //rot = loadEnvF(con, 1, 1);

    //matrixLoadTranslate(con, &f1, 0, 0, trans);
    //matrixRotate(con, &f1, rot, 1, 0, 0);
    //matrixScale(con, &f1, 3.0f, 3.0f, 3.0f);
    //storeEnvMatrix(con, 3, RS_PROGRAM_VERTEX_MODELVIEW_OFFSET, &f1);

    //rsc_Matrix m;
    //int imgId = 0;

    // This should be replaced in the compiler with a 
    // smart load of a structure.
    //const FilmScriptUserEnv *env = loadEnvVp(con, 0,0);

    //materialDiffuse(con, 0.0f, 0.0f, 0.0f, 1.0f);
    //materialSpecular(con, 0.5f, 0.5f, 0.5f, 0.5f);
    //materialShininess(con, 20.0f);



    //lightPosition(con, 0.2f, -0.2f, -2.0f, 0.0f);

    //contextBindProgramFragmentStore(con, NAMED_PFSBackground);
    //contextBindProgramFragment(con, NAMED_PFBackground);
    //enable(con, GL_LIGHTING);
    renderTriangleMesh(con, NAMED_mesh);

/*
    contextBindProgramFragmentStore(con, env->fsImages);
    contextBindProgramFragment(con, env->fpImages);
    disable(con, GL_LIGHTING);

    float focusPos = loadEnvF(con, 1, 2);
    int32_t focusID = 0;
    int32_t lastFocusID = loadEnvI32(con, 2, 0);
    int32_t imgCount = 13;

    if (trans > (-.3)) {
        focusID = -1.0 - focusPos;
        if (focusID >= imgCount) {
            focusID = -1;
        }
    } else {
        focusID = -1;
    }

    if (focusID != lastFocusID) {
        if (lastFocusID >= 0) {
            uploadToTexture(con, env->tex[lastFocusID], 1);
        }
        if (focusID >= 0) {
            uploadToTexture(con, env->tex[focusID], 0);
        }
    }
    storeEnvI32(con, 2, 0, focusID);


    for (imgId=1; imgId <= imgCount; imgId++) {
        float pos = focusPos + imgId + .4f;
        int offset = (int)floor(pos*2);
        pos -= 0.75;
    
        offset += env->triangleOffsetsCount / 2;
    
        if ((offset < 0) || (offset >= env->triangleOffsetsCount)) {
            continue;
        }
    
        int start = offset -2;
        int end = offset + 2;
    
        if (start < 0) {
            start = 0;
        }
        if (end > env->triangleOffsetsCount) {
            end = env->triangleOffsetsCount;
        }
    
        programFragmentBindTexture(con, env->fpImages, 0, env->tex[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]);
    } 
*/
}
Loading