summaryrefslogtreecommitdiffstats
path: root/libs/rs/java/Fountain
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-06-01 17:45:53 -0700
committerJason Sams <rjsams@android.com>2009-06-01 17:45:53 -0700
commitffe9f48890dde7173a0845d32887fdf94a49b0a7 (patch)
tree35230173bcdd2e5c012a97ddb99a9715729d08c0 /libs/rs/java/Fountain
parentd9758d809fe82f4f3ba3af5486fd34d78a63367f (diff)
downloadframeworks_base-ffe9f48890dde7173a0845d32887fdf94a49b0a7.zip
frameworks_base-ffe9f48890dde7173a0845d32887fdf94a49b0a7.tar.gz
frameworks_base-ffe9f48890dde7173a0845d32887fdf94a49b0a7.tar.bz2
Improve bitmap support and do conversion in native rather than java code to reduce conversion time.
Diffstat (limited to 'libs/rs/java/Fountain')
-rw-r--r--libs/rs/java/Fountain/res/raw/fountain.c8
-rw-r--r--libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java67
2 files changed, 19 insertions, 56 deletions
diff --git a/libs/rs/java/Fountain/res/raw/fountain.c b/libs/rs/java/Fountain/res/raw/fountain.c
index 76f8dcf..cee6e22 100644
--- a/libs/rs/java/Fountain/res/raw/fountain.c
+++ b/libs/rs/java/Fountain/res/raw/fountain.c
@@ -15,7 +15,7 @@ main(con, ft, launchID) {
count = loadI32(con, 0, 1);
touch = loadI32(con, 0, 2);
x = loadI32(con, 0, 3);
- y = 480 - loadI32(con, 0, 4);
+ y = loadI32(con, 0, 4);
rate = 4;
maxLife = (count / rate) - 1;
@@ -69,7 +69,7 @@ main(con, ft, launchID) {
posy = * (int* )(partPtr + 16); //loadEnvI32(con, 2, srcIdx + 4);
if (life) {
- if (posy > 0) {
+ if (posy < (480 << 16)) {
c = 0xffafcf | ((life >> lifeShift) << 24);
* (int* )(vertPtr) = c; //storeEnvU32(con, 1, dstIdx, c);
@@ -87,14 +87,14 @@ main(con, ft, launchID) {
vertPtr = vertPtr + 36;
drawCount ++;
} else {
- if (dy < 0) {
+ if (dy > 0) {
dy = (-dy) >> 1;
}
}
posx = posx + dx;
posy = posy + dy;
- dy = dy - 0x400;
+ dy = dy + 0x400;
life --;
* (int* )(partPtr + 0) = dx; //storeEnvI32(con, 2, srcIdx, dx);
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java b/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java
index cf16cec..796fe35 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java
@@ -83,9 +83,8 @@ public class RenderScript {
native private int nAllocationCreateTyped(int type);
native private int nAllocationCreatePredefSized(int predef, int count);
native private int nAllocationCreateSized(int elem, int count);
- native private int nAllocationCreateFromBitmap(int w, int h, int dstFmt, int srcFmt, boolean genMips, int[] data);
+ native private int nAllocationCreateFromBitmap(int dstFmt, boolean genMips, Bitmap bmp);
- //native private int nAllocationCreateFromBitmap(type.mID);
native private void nAllocationUploadToTexture(int alloc, int baseMioLevel);
native private void nAllocationDestroy(int alloc);
native private void nAllocationData(int id, int[] d);
@@ -190,21 +189,19 @@ public class RenderScript {
USER_I32 (5),
USER_FLOAT (6),
- A_8 (7),
- RGB_565 (8),
- RGBA_5551 (9),
- RGBA_4444 (10),
- RGB_888 (11),
- RGBA_8888 (12),
-
- INDEX_16 (13),
- INDEX_32 (14),
- XY_F32 (15),
- XYZ_F32 (16),
- ST_XY_F32 (17),
- ST_XYZ_F32 (18),
- NORM_XYZ_F32 (19),
- NORM_ST_XYZ_F32 (20);
+ A_8 (7),
+ RGB_565 (8),
+ RGB_888 (12),
+ RGBA_5551 (9),
+ RGBA_4444 (10),
+ RGBA_8888 (13),
+
+ INDEX_16 (16),
+ INDEX_32 (17),
+ XY_F32 (18),
+ XYZ_F32 (19),
+ ST_XY_F32 (20),
+ ST_XYZ_F32 (21);
int mID;
ElementPredefined(int id) {
@@ -475,41 +472,7 @@ public class RenderScript {
}
public Allocation allocationCreateFromBitmap(Bitmap b, ElementPredefined dstFmt, boolean genMips) {
- int w = b.getWidth();
- int h = b.getHeight();
- int[] data = new int[w * h];
-
- int outPtr = 0;
- for(int y=0; y < h; y++) {
- for(int x=0; x < w; x++) {
- data[outPtr] = b.getPixel(x, y);
- outPtr++;
- }
- }
-
- int srcFmt = 0;
- /*
- switch(b.getConfig()) {
- case ALPHA_8:
- srcFmt = ElementPredefined.A_8.mID;
- break;
- case ARGB_4444:
- srcFmt = ElementPredefined.RGBA_4444.mID;
- break;
- case ARGB_8888:
- srcFmt = ElementPredefined.RGBA_8888.mID;
- break;
- case RGB_565:
- srcFmt = ElementPredefined.RGB_565.mID;
- break;
- default:
- Log.e(LOG_TAG, "allocationCreateFromBitmap, unknown bitmap format");
- }
- */
-
- srcFmt = ElementPredefined.RGBA_8888.mID;
-
- int id = nAllocationCreateFromBitmap(w, h, dstFmt.mID, srcFmt, genMips, data);
+ int id = nAllocationCreateFromBitmap(dstFmt.mID, genMips, b);
return new Allocation(id);
}