diff options
| author | Alex Sakhartchouk <alexst@google.com> | 2010-05-11 16:06:00 -0700 |
|---|---|---|
| committer | Alex Sakhartchouk <alexst@google.com> | 2010-05-11 16:06:00 -0700 |
| commit | 4754f87b228e0c2f9d4723e927dfc04a2b2401a1 (patch) | |
| tree | afa7801cd0c308bb2fb4872f5f4e77d33732343e /res | |
| parent | 8aeb9839d8b2ed85ab5a580d1b10554866add28a (diff) | |
| download | android_packages_wallpapers_Basic-4754f87b228e0c2f9d4723e927dfc04a2b2401a1.tar.gz android_packages_wallpapers_Basic-4754f87b228e0c2f9d4723e927dfc04a2b2401a1.tar.bz2 android_packages_wallpapers_Basic-4754f87b228e0c2f9d4723e927dfc04a2b2401a1.zip | |
Ported fall to llvm
Change-Id: I9f737b8cc7a601718c989989cdbc816e544f764c
Conflicts:
src/com/android/wallpaper/fall/FallRS.java
Diffstat (limited to 'res')
| -rw-r--r-- | res/raw/fall.rs | 233 | ||||
| -rw-r--r-- | res/raw/fall_bc.bc | bin | 0 -> 8852 bytes |
2 files changed, 156 insertions, 77 deletions
diff --git a/res/raw/fall.rs b/res/raw/fall.rs index 22f5a1b..7ae8a6a 100644 --- a/res/raw/fall.rs +++ b/res/raw/fall.rs @@ -13,30 +13,72 @@ // limitations under the License. #pragma version(1) -#pragma stateVertex(PVSky) -#pragma stateFragment(PFBackground) -#pragma stateStore(PFSBackground) + +#include "../../../../../frameworks/base/libs/rs/scriptc/rs_types.rsh" +#include "../../../../../frameworks/base/libs/rs/scriptc/rs_math.rsh" +#include "../../../../../frameworks/base/libs/rs/scriptc/rs_graphics.rsh" #define LEAVES_TEXTURES_COUNT 8 #define LEAF_SIZE 0.55f #define LEAVES_COUNT 14 -float skyOffsetX; -float skyOffsetY; +// Things we need to set from the application +float g_glWidth; +float g_glHeight; +float g_meshWidth; +float g_meshHeight; +float g_xOffset; +float g_rotate; +// Drops generated by java +int g_newDropX; +int g_newDropY; + +rs_program_vertex g_PVWater; +rs_program_vertex g_PVSky; + +rs_program_fragment g_PFSky; +rs_program_store g_PFSLeaf; +rs_program_fragment g_PFBackground; + +rs_allocation g_TLeaves; +rs_allocation g_TRiverbed; + +rs_mesh g_WaterMesh; + +typedef struct Constants_s { + float4 Drop01; + float4 Drop02; + float4 Drop03; + float4 Drop04; + float4 Drop05; + float4 Drop06; + float4 Drop07; + float4 Drop08; + float4 Drop09; + float4 Drop10; + float4 Offset; + float Rotate; +} Constants_t; + +Constants_t *g_Constants; +rs_program_store g_PFSBackground; + +//float skyOffsetX; +//float skyOffsetY; float g_DT; -int g_LastTime; +float g_LastTime; -struct drop_s { +typedef struct Drop_s { float ampS; float ampE; float spread; float x; float y; -}; -struct drop_s gDrops[10]; +} Drop_t; +static Drop_t gDrops[10]; int gMaxDrops; -struct Leaves_s { +typedef struct Leaves_s { float x; float y; float scale; @@ -49,46 +91,78 @@ struct Leaves_s { float deltaX; float deltaY; int newLeaf; -}; - -struct Leaves_s gLeavesStore[LEAVES_COUNT]; -struct Leaves_s* gLeaves[LEAVES_COUNT]; -struct Leaves_s* gNextLeaves[LEAVES_COUNT]; +} Leaves_t; + +static Leaves_t gLeavesStore[LEAVES_COUNT]; +static Leaves_t* gLeaves[LEAVES_COUNT]; +static Leaves_t* gNextLeaves[LEAVES_COUNT]; + +#pragma rs export_var(g_glWidth, g_glHeight, g_meshWidth, g_meshHeight, g_xOffset, g_rotate, g_newDropX, g_newDropY, g_PVWater, g_PVSky, g_PFSky, g_PFSLeaf, g_PFBackground, g_TLeaves, g_TRiverbed, g_WaterMesh, g_Constants, g_PFSBackground) + +void debugAll() +{ + debugPf(100, g_glWidth); + debugPf(101, g_glHeight); + debugPf(102, g_meshWidth); + debugPf(103, g_meshHeight); + debugPf(104, g_xOffset); + debugPf(105, g_rotate); + debugP(106, (void *)g_newDropX); + debugP(107, (void *)g_newDropY); + + debugP(201, (void *)g_PVWater); + debugP(202, (void *)g_PVSky); + debugP(203, (void *)g_PFSky); + debugP(204, (void *)g_PFSLeaf); + debugP(205, (void *)g_PFBackground); + debugP(206, (void *)g_TLeaves); + debugP(207, (void *)g_TRiverbed); + debugP(208, (void *)g_WaterMesh); + debugP(209, (void *)g_Constants); -void init() { - int ct; - gMaxDrops = 10; - for (ct=0; ct<gMaxDrops; ct++) { - gDrops[ct].ampS = 0; - gDrops[ct].ampE = 0; - gDrops[ct].spread = 1; - } } void initLeaves() { struct Leaves_s *leaf = gLeavesStore; - float width = State->glWidth * 2; - float height = State->glHeight; + // globals haven't been set at this point yet. We need to find the correct + // function index to call this, we can wait until reflection works + float width = 2; //g_glWidth; + float height = 3.333; //g_glHeight; int i; for (i = 0; i < LEAVES_COUNT; i ++) { gLeaves[i] = leaf; int sprite = randf(LEAVES_TEXTURES_COUNT); - leaf->x = randf2(-width * 0.5f, width * 0.5f); + leaf->x = randf2(-width, width); leaf->y = randf2(-height * 0.5f, height * 0.5f); leaf->scale = randf2(0.4f, 0.5f); leaf->angle = randf2(0.0f, 360.0f); - leaf->spin = degf(randf2(-0.02f, 0.02f)) * 0.25f; - leaf->u1 = sprite / (float) LEAVES_TEXTURES_COUNT; - leaf->u2 = (sprite + 1) / (float) LEAVES_TEXTURES_COUNT; + leaf->spin = degrees(randf2(-0.02f, 0.02f)) * 0.25f; + leaf->u1 = (float)sprite / (float) LEAVES_TEXTURES_COUNT; + leaf->u2 = (float)(sprite + 1) / (float) LEAVES_TEXTURES_COUNT; leaf->altitude = -1.0f; leaf->rippled = 1.0f; - leaf->deltaX = randf2(-0.02f, 0.02f) / 2.0f; - leaf->deltaY = -0.08f * randf2(0.9f, 1.1f) / 2.0f; + leaf->deltaX = randf2(-0.01f, 0.01f); + leaf->deltaY = -randf2(0.036f, 0.044f); + leaf++; } } +void init() { + int ct; + gMaxDrops = 10; + for (ct=0; ct<gMaxDrops; ct++) { + gDrops[ct].ampS = 0; + gDrops[ct].ampE = 0; + gDrops[ct].spread = 1; + } + + initLeaves(); + g_LastTime = uptimeMillis(); + g_DT = 0.1f; +} + void updateDrop(int ct) { gDrops[ct].spread += 30.f * g_DT; gDrops[ct].ampE = gDrops[ct].ampS / gDrops[ct].spread; @@ -107,22 +181,22 @@ void drop(int x, int y, float s) { gDrops[iMin].ampS = s; gDrops[iMin].spread = 0; gDrops[iMin].x = x; - gDrops[iMin].y = State->meshHeight - y - 1; + gDrops[iMin].y = g_meshHeight - y - 1; updateDrop(iMin); } void generateRipples() { int ct; for (ct = 0; ct < gMaxDrops; ct++) { - struct drop_s * d = &gDrops[ct]; - vecF32_4_t *v = &Constants->Drop01; - v += ct; - v->x = d->x; - v->y = d->y; - v->z = d->ampE * 0.12f; - v->w = d->spread; + struct Drop_s * d = &gDrops[ct]; + float *v = (float*)&g_Constants->Drop01; + v += ct*4; + *(v++) = d->x; + *(v++) = d->y; + *(v++) = d->ampE * 0.12f; + *(v++) = d->spread; } - Constants->Offset.x = State->xOffset; + g_Constants->Offset.x = g_xOffset; for (ct = 0; ct < gMaxDrops; ct++) { updateDrop(ct); @@ -130,9 +204,9 @@ void generateRipples() { } void genLeafDrop(struct Leaves_s *leaf, float amp) { - float nx = (leaf->x + State->glWidth * 0.5f) / State->glWidth; - float ny = (leaf->y + State->glHeight * 0.5f) / State->glHeight; - drop(nx * State->meshWidth, State->meshHeight - ny * State->meshHeight, amp); + float nx = (leaf->x + g_glWidth * 0.5f) / g_glWidth; + float ny = (leaf->y + g_glHeight * 0.5f) / g_glHeight; + drop(nx * g_meshWidth, g_meshHeight - ny * g_meshHeight, amp); } int drawLeaf(struct Leaves_s *leaf) { @@ -161,14 +235,14 @@ int drawLeaf(struct Leaves_s *leaf) { color(0.0f, 0.0f, 0.0f, alpha * 0.15f); matrixLoadIdentity(matrix); - if (!State->rotate) { - matrixTranslate(matrix, x - State->xOffset * 2, y, tz); + if (!g_rotate) { + matrixTranslate(matrix, x - g_xOffset * 2, y, 0); } else { - matrixTranslate(matrix, x, y, tz); + matrixTranslate(matrix, x, y, 0); matrixRotate(matrix, 90.0f, 0.0f, 0.0f, 1.0f); } - float shadowOffet = a / 5; + float shadowOffet = a * 0.2f; matrixScale(matrix, s, s, 1.0f); matrixRotate(matrix, r, 0.0f, 0.0f, 1.0f); @@ -185,8 +259,8 @@ int drawLeaf(struct Leaves_s *leaf) { } matrixLoadIdentity(matrix); - if (!State->rotate) { - matrixTranslate(matrix, x - State->xOffset * 2, y, tz); + if (!g_rotate) { + matrixTranslate(matrix, x - g_xOffset * 2, y, tz); } else { matrixTranslate(matrix, x, y, tz); matrixRotate(matrix, 90.0f, 0.0f, 0.0f, 1.0f); @@ -205,9 +279,9 @@ int drawLeaf(struct Leaves_s *leaf) { float rippled = leaf->rippled; if (rippled < 0.0f) { genLeafDrop(leaf, 1.5f); - //drop(((x + State->glWidth * 0.5f) / State->glWidth) * meshWidth, - // meshHeight - ((y + State->glHeight * 0.5f) / State->glHeight) * meshHeight, 1); - spin /= 4.0f; + //drop(((x + g_glWidth * 0.5f) / g_glWidth) * meshWidth, + // meshHeight - ((y + g_glHeight * 0.5f) / g_glHeight) * meshHeight, 1); + spin *= 0.25f; leaf->spin = spin; leaf->rippled = 1.0f; } @@ -223,21 +297,22 @@ int drawLeaf(struct Leaves_s *leaf) { } int newLeaf = 0; - if (-LEAF_SIZE * s + x > State->glWidth || LEAF_SIZE * s + x < -State->glWidth || - LEAF_SIZE * s + y < -State->glHeight / 2.0f) { + if (-LEAF_SIZE * s + x > g_glWidth || LEAF_SIZE * s + x < -g_glWidth || + LEAF_SIZE * s + y < -g_glHeight * 0.5f) { int sprite = randf(LEAVES_TEXTURES_COUNT); - leaf->x = randf2(-State->glWidth, State->glWidth); - leaf->y = randf2(-State->glHeight * 0.5f, State->glHeight * 0.5f); + + leaf->x = randf2(-g_glWidth, g_glWidth); + leaf->y = randf2(-g_glHeight * 0.5f, g_glHeight * 0.5f); leaf->scale = randf2(0.4f, 0.5f); - leaf->spin = degf(randf2(-0.02f, 0.02f)) * 0.35f; + leaf->spin = degrees(randf2(-0.02f, 0.02f)) * 0.35f; leaf->u1 = sprite / (float) LEAVES_TEXTURES_COUNT; leaf->u2 = (sprite + 1) / (float) LEAVES_TEXTURES_COUNT; leaf->altitude = 0.7f; leaf->rippled = -1.0f; - leaf->deltaX = randf2(-0.02f, 0.02f) / 2.0f; - leaf->deltaY = -0.08f * randf2(0.9f, 1.1f) / 2.0f; + leaf->deltaX = randf2(-0.01f, 0.01f); + leaf->deltaY = -randf2(0.036f, 0.044f); leaf->newLeaf = 1; newLeaf = 1; } @@ -245,10 +320,10 @@ int drawLeaf(struct Leaves_s *leaf) { } void drawLeaves() { - bindProgramFragment(NAMED_PFSky); - bindProgramFragmentStore(NAMED_PFSLeaf); - bindProgramVertex(NAMED_PVSky); - bindTexture(NAMED_PFSky, 0, NAMED_TLeaves); + bindProgramFragment(g_PFSky); + bindProgramFragmentStore(g_PFSLeaf); + bindProgramVertex(g_PVSky); + bindTexture(g_PFSky, 0, g_TLeaves); color(1.0f, 1.0f, 1.0f, 1.0f); @@ -293,23 +368,28 @@ void drawLeaves() { } void drawRiverbed() { - bindTexture(NAMED_PFBackground, 0, NAMED_TRiverbed); - drawSimpleMesh(NAMED_WaterMesh); + bindProgramFragment(g_PFBackground); + bindProgramFragmentStore(g_PFSBackground); + bindTexture(g_PFBackground, 0, g_TRiverbed); + drawSimpleMesh(g_WaterMesh); } -int main(int index) { +int root(int launchID) { + //debugAll(); // Compute dt in seconds. - int newTime = uptimeMillis(); - g_DT = (newTime - g_LastTime) / 1000.f; + float newTime = uptimeMillis(); + float timeScale = 0.001f; + g_DT = newTime - g_LastTime; + g_DT = g_DT * timeScale; g_LastTime = newTime; - g_DT = minf(g_DT, 0.2f); + g_DT = min(g_DT, 0.2f); - Constants->Rotate = (float) State->rotate; + g_Constants->Rotate = (float) g_rotate; - if (Drop->dropX != -1) { - drop(Drop->dropX, Drop->dropY, 2); - Drop->dropX = -1; - Drop->dropY = -1; + if (g_newDropX != -1) { + drop(g_newDropX, g_newDropY, 2); + g_newDropX = -1; + g_newDropY = -1; } int ct; @@ -325,12 +405,11 @@ int main(int index) { genLeafDrop(gLeaves[i], randf(0.3f) + 0.1f); } - bindProgramVertex(NAMED_PVWater); + bindProgramVertex(g_PVWater); generateRipples(); drawRiverbed(); - bindProgramVertex(NAMED_PVSky); drawLeaves(); - return 30; + return 50; } diff --git a/res/raw/fall_bc.bc b/res/raw/fall_bc.bc Binary files differnew file mode 100644 index 0000000..c8207ab --- /dev/null +++ b/res/raw/fall_bc.bc |
