summaryrefslogtreecommitdiffstats
path: root/libs/rs/java
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-07-28 17:20:11 -0700
committerJason Sams <rjsams@android.com>2009-07-28 17:20:11 -0700
commit6f5c61c8df70273e3bbc7fd07412cc69b6ce1e76 (patch)
treeb429479c913cfdd0f91a7386d99295e10638ce56 /libs/rs/java
parent37d7fc70dd92a29662b9e170f91ee6b35ae950ab (diff)
downloadframeworks_base-6f5c61c8df70273e3bbc7fd07412cc69b6ce1e76.zip
frameworks_base-6f5c61c8df70273e3bbc7fd07412cc69b6ce1e76.tar.gz
frameworks_base-6f5c61c8df70273e3bbc7fd07412cc69b6ce1e76.tar.bz2
Add new icons and implement text. Fix bug with uploading 8888 bitmaps of non-square size.
Diffstat (limited to 'libs/rs/java')
-rw-r--r--libs/rs/java/Rollo/res/raw/calendar.pngbin0 -> 4551 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/g1155.pngbin0 -> 5094 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/g2140.pngbin0 -> 3982 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/path1920.pngbin0 -> 3812 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/path1927.pngbin0 -> 4034 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/path3099.pngbin0 -> 4981 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/path3950.pngbin0 -> 4873 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/path431.pngbin0 -> 3995 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/path4481.pngbin0 -> 4113 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/path5168.pngbin0 -> 5328 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/path676.pngbin0 -> 4351 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/path754.pngbin0 -> 3205 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/path815.pngbin0 -> 5536 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/polygon2408.pngbin0 -> 3873 bytes
-rw-r--r--libs/rs/java/Rollo/res/raw/rollo.c53
-rw-r--r--libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java158
-rw-r--r--libs/rs/java/Rollo/src/com/android/rollo/RolloView.java7
17 files changed, 173 insertions, 45 deletions
diff --git a/libs/rs/java/Rollo/res/raw/calendar.png b/libs/rs/java/Rollo/res/raw/calendar.png
new file mode 100644
index 0000000..030ae73
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/calendar.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/g1155.png b/libs/rs/java/Rollo/res/raw/g1155.png
new file mode 100644
index 0000000..68e1843
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/g1155.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/g2140.png b/libs/rs/java/Rollo/res/raw/g2140.png
new file mode 100644
index 0000000..8c4e853
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/g2140.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/path1920.png b/libs/rs/java/Rollo/res/raw/path1920.png
new file mode 100644
index 0000000..3510665
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/path1920.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/path1927.png b/libs/rs/java/Rollo/res/raw/path1927.png
new file mode 100644
index 0000000..fccc846
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/path1927.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/path3099.png b/libs/rs/java/Rollo/res/raw/path3099.png
new file mode 100644
index 0000000..527ebf6
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/path3099.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/path3950.png b/libs/rs/java/Rollo/res/raw/path3950.png
new file mode 100644
index 0000000..59a646a
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/path3950.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/path431.png b/libs/rs/java/Rollo/res/raw/path431.png
new file mode 100644
index 0000000..5d2ed75
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/path431.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/path4481.png b/libs/rs/java/Rollo/res/raw/path4481.png
new file mode 100644
index 0000000..78be0fc
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/path4481.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/path5168.png b/libs/rs/java/Rollo/res/raw/path5168.png
new file mode 100644
index 0000000..a7c3a19
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/path5168.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/path676.png b/libs/rs/java/Rollo/res/raw/path676.png
new file mode 100644
index 0000000..2099690
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/path676.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/path754.png b/libs/rs/java/Rollo/res/raw/path754.png
new file mode 100644
index 0000000..88aed5b
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/path754.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/path815.png b/libs/rs/java/Rollo/res/raw/path815.png
new file mode 100644
index 0000000..407570f
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/path815.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/polygon2408.png b/libs/rs/java/Rollo/res/raw/polygon2408.png
new file mode 100644
index 0000000..4413954
--- /dev/null
+++ b/libs/rs/java/Rollo/res/raw/polygon2408.png
Binary files differ
diff --git a/libs/rs/java/Rollo/res/raw/rollo.c b/libs/rs/java/Rollo/res/raw/rollo.c
index 960fdf0..9e03a44 100644
--- a/libs/rs/java/Rollo/res/raw/rollo.c
+++ b/libs/rs/java/Rollo/res/raw/rollo.c
@@ -19,6 +19,7 @@
#define STATE_COUNT 8
#define STATE_TOUCH 9
+
float filter(float val, float target, float str)
{
float delta = (target - val);
@@ -63,7 +64,7 @@ int main(void* con, int ft, int launchID)
float drawRot = filter(loadF(2, SCRATCH_ROT), targetRot, 0.1f * touchCut);
storeF(2, SCRATCH_ROT, drawRot);
- float diam = 10.f;
+ float diam = 8.f;
float scale = 1.0f / zoom;
// Bug makes 1.0f alpha fail.
@@ -77,6 +78,7 @@ int main(void* con, int ft, int launchID)
while (iconCount) {
float tmpSin = sinf(rot);
float tmpCos = cosf(rot);
+ //debugF("rot", rot);
float tx1 = tmpSin * diam - (tmpCos * scale);
float tx2 = tx1 + (tmpCos * scale * 2.f);
@@ -85,7 +87,7 @@ int main(void* con, int ft, int launchID)
int y;
for (y = rowCount -1; (y >= 0) && iconCount; y--) {
- float ty1 = ((y * 3.5f) - 6.f) * scale;
+ float ty1 = ((y * 3.1f) - 5.f) * scale;
float ty2 = ty1 + scale * 2.f;
bindTexture(NAMED_PF, 0, loadI32(1, index));
//if (done && (index != selectedID)) {
@@ -102,6 +104,51 @@ int main(void* con, int ft, int launchID)
rot = rot + rotStep;
}
+ if ((zoom < 1.1f) && (zoom > 0.9f)) {
+ bindProgramVertex(NAMED_PVOrtho);
+ bindProgramFragment(NAMED_PFText);
+ bindProgramFragmentStore(NAMED_PFSText);
+
+ rot = drawRot * scale;
+ index = 0;
+ iconCount = loadI32(0, STATE_COUNT);
+ while (iconCount) {
+ int y;
+
+ float tx = 240.f + floorf(sinf(rot) * 430.f) - 64.f + 16.f;
+
+ float alpha = 2.4f - (fabsf(tx - 240.f + 48.f) / 76.f);
+ if (alpha > 0.99f) {
+ alpha = 0.99f;
+ }
+ alpha = alpha * (1.f - (fabsf(zoom - 1.f) * 10.f));
+
+ tx = tx + 0.25f;
+
+ for (y = rowCount -1; (y >= 0) && iconCount; y--) {
+
+ if (alpha > 0) {
+ color(1.0f, 1.0f, 1.0f, alpha);
+
+ float ty = 605.f - y * 150.f;
+
+ ty = ty + 0.25f;
+
+ bindTexture(NAMED_PFText, 0, loadI32(3, index));
+ drawRect(tx, ty, tx + 128.f, ty + 32.f, 0.5f);
+ }
+ iconCount--;
+ index++;
+ }
+ rot = rot + rotStep;
+ }
+
+
+ bindProgramVertex(NAMED_PV);
+ bindProgramFragment(NAMED_PF);
+ bindProgramFragmentStore(NAMED_PFS);
+ }
+
// Draw the selected icon
color(1.0f, 1.0f, 1.0f, 0.9f);
rot = drawRot * scale;
@@ -119,7 +166,7 @@ int main(void* con, int ft, int launchID)
float tz1 = tmpCos * diam * 0.9f + tmpSin * 2.f;
float tz2 = tz1 - (tmpSin * 4.f);
- float ty1 = ((y * 3.5f) - 5.f) * scale;
+ float ty1 = ((y * 3.1f) - 4.5f) * scale;
float ty2 = ty1 + scale * 4.f;
bindTexture(NAMED_PF, 0, loadI32(1, index));
drawQuad(tx1, ty1, tz1,
diff --git a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
index 46933f3..520e3e4 100644
--- a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
+++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
@@ -26,8 +26,11 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
+import android.graphics.Typeface;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
@@ -57,6 +60,8 @@ public class RolloRS {
public void init(RenderScript rs, Resources res, int width, int height) {
mRS = rs;
mRes = res;
+ mWidth = width;
+ mHeight = height;
initNamed();
initRS();
}
@@ -79,26 +84,32 @@ public class RolloRS {
}
public void setSelected(int index) {
- Log.e("rs", "setSelected " + Integer.toString(index));
+ //Log.e("rs", "setSelected " + Integer.toString(index));
mAllocStateBuf[STATE_SELECTION] = index;
mAllocStateBuf[STATE_DONE] = 1;
mAllocState.data(mAllocStateBuf);
}
+ private int mWidth;
+ private int mHeight;
private Resources mRes;
private RenderScript mRS;
private RenderScript.Script mScript;
private RenderScript.Sampler mSampler;
+ private RenderScript.Sampler mSamplerText;
private RenderScript.ProgramFragmentStore mPFSBackground;
+ private RenderScript.ProgramFragmentStore mPFSText;
private RenderScript.ProgramFragment mPFBackground;
private RenderScript.ProgramFragment mPFImages;
+ private RenderScript.ProgramFragment mPFText;
private RenderScript.ProgramVertex mPV;
private ProgramVertexAlloc mPVAlloc;
private RenderScript.ProgramVertex mPVOrtho;
private ProgramVertexAlloc mPVOrthoAlloc;
private RenderScript.Allocation[] mIcons;
+ private RenderScript.Allocation[] mLabels;
private RenderScript.Allocation mIconPlate;
private RenderScript.Allocation mBackground;
@@ -108,6 +119,9 @@ public class RolloRS {
private int[] mAllocIconIDBuf;
private RenderScript.Allocation mAllocIconID;
+ private int[] mAllocLabelIDBuf;
+ private RenderScript.Allocation mAllocLabelID;
+
private int[] mAllocScratchBuf;
private RenderScript.Allocation mAllocScratch;
@@ -123,6 +137,17 @@ public class RolloRS {
RenderScript.SamplerValue.CLAMP);
mSampler = mRS.samplerCreate();
+ mRS.samplerBegin();
+ mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN,
+ RenderScript.SamplerValue.NEAREST);
+ mRS.samplerSet(RenderScript.SamplerParam.FILTER_MAG,
+ RenderScript.SamplerValue.NEAREST);
+ mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_S,
+ RenderScript.SamplerValue.CLAMP);
+ mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_T,
+ RenderScript.SamplerValue.CLAMP);
+ mSamplerText = mRS.samplerCreate();
+
mRS.programFragmentBegin(null, null);
mRS.programFragmentSetTexEnable(0, true);
@@ -131,6 +156,13 @@ public class RolloRS {
mPFImages.setName("PF");
mPFImages.bindSampler(mSampler, 0);
+ mRS.programFragmentBegin(null, null);
+ mRS.programFragmentSetTexEnable(0, true);
+ mRS.programFragmentSetTexEnvMode(0, RenderScript.EnvMode.MODULATE);
+ mPFText = mRS.programFragmentCreate();
+ mPFText.setName("PFText");
+ mPFText.bindSampler(mSamplerText, 0);
+
mRS.programFragmentStoreBegin(null, null);
mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.LESS);
mRS.programFragmentStoreDitherEnable(false);
@@ -140,13 +172,22 @@ public class RolloRS {
mPFSBackground = mRS.programFragmentStoreCreate();
mPFSBackground.setName("PFS");
+ mRS.programFragmentStoreBegin(null, null);
+ mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS);
+ mRS.programFragmentStoreDitherEnable(false);
+ mRS.programFragmentStoreDepthMask(false);
+ mRS.programFragmentStoreBlendFunc(RenderScript.BlendSrcFunc.SRC_ALPHA,
+ RenderScript.BlendDstFunc.ONE_MINUS_SRC_ALPHA);
+ mPFSText = mRS.programFragmentStoreCreate();
+ mPFSText.setName("PFSText");
+
mPVAlloc = new ProgramVertexAlloc(mRS);
mRS.programVertexBegin(null, null);
mRS.programVertexSetTextureMatrixEnable(false);
mPV = mRS.programVertexCreate();
mPV.setName("PV");
mPV.bindAllocation(0, mPVAlloc.mAlloc);
- mPVAlloc.setupProjectionNormalized(320, 480);
+ mPVAlloc.setupProjectionNormalized(mWidth, mHeight);
mPVOrthoAlloc = new ProgramVertexAlloc(mRS);
mRS.programVertexBegin(null, null);
@@ -154,7 +195,7 @@ public class RolloRS {
mPVOrtho = mRS.programVertexCreate();
mPVOrtho.setName("PVOrtho");
mPVOrtho.bindAllocation(0, mPVOrthoAlloc.mAlloc);
- mPVOrthoAlloc.setupOrthoWindow(320, 480);
+ mPVOrthoAlloc.setupOrthoWindow(mWidth, mHeight);
mRS.contextBindProgramVertex(mPV);
@@ -176,6 +217,11 @@ public class RolloRS {
mAllocIconID = mRS.allocationCreatePredefSized(
RenderScript.ElementPredefined.USER_I32, mAllocIconIDBuf.length);
+ mLabels = new RenderScript.Allocation[29];
+ mAllocLabelIDBuf = new int[mLabels.length];
+ mAllocLabelID = mRS.allocationCreatePredefSized(
+ RenderScript.ElementPredefined.USER_I32, mLabels.length);
+
Bitmap b;
BitmapFactory.Options opts = new BitmapFactory.Options();
@@ -188,109 +234,122 @@ public class RolloRS {
b = BitmapFactory.decodeResource(mRes, R.raw.browser, opts);
mIcons[0] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
+ mLabels[0] = makeTextBitmap("browser");
b = BitmapFactory.decodeResource(mRes, R.raw.market, opts);
mIcons[1] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
+ mLabels[1] = makeTextBitmap("market");
b = BitmapFactory.decodeResource(mRes, R.raw.photos, opts);
mIcons[2] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
+ mLabels[2] = makeTextBitmap("photos");
b = BitmapFactory.decodeResource(mRes, R.raw.settings, opts);
mIcons[3] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
+ mLabels[3] = makeTextBitmap("settings");
-/*
- b = BitmapFactory.decodeResource(mRes, R.raw.assasins_creed, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.calendar, opts);
mIcons[4] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[4] = makeTextBitmap("creed");
- b = BitmapFactory.decodeResource(mRes, R.raw.bankofamerica, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.g1155, opts);
mIcons[5] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[5] = makeTextBitmap("BOA");
- b = BitmapFactory.decodeResource(mRes, R.raw.chess, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.g2140, opts);
mIcons[6] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[6] = makeTextBitmap("chess");
- b = BitmapFactory.decodeResource(mRes, R.raw.dictionary, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.maps, opts);
mIcons[7] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[7] = makeTextBitmap("Dictionary");
- b = BitmapFactory.decodeResource(mRes, R.raw.facebook, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.path431, opts);
mIcons[8] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[8] = makeTextBitmap("facebook");
- b = BitmapFactory.decodeResource(mRes, R.raw.flashlight, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.path676, opts);
mIcons[9] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[9] = makeTextBitmap("Flash Light");
- b = BitmapFactory.decodeResource(mRes, R.raw.flight_control, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.path754, opts);
mIcons[10] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[10] = makeTextBitmap("Flight Control");
- b = BitmapFactory.decodeResource(mRes, R.raw.google_earth, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.path815, opts);
mIcons[11] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[11] = makeTextBitmap("google earth");
- b = BitmapFactory.decodeResource(mRes, R.raw.harry_potter, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.path1920, opts);
mIcons[12] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[12] = makeTextBitmap("Harry Potter");
- b = BitmapFactory.decodeResource(mRes, R.raw.movies, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.path1927, opts);
mIcons[13] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[13] = makeTextBitmap("Movies");
- b = BitmapFactory.decodeResource(mRes, R.raw.nytimes, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.path3099, opts);
mIcons[14] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[14] = makeTextBitmap("NY Times");
- b = BitmapFactory.decodeResource(mRes, R.raw.pandora, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.path3950, opts);
mIcons[15] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[15] = makeTextBitmap("Pandora");
-
-
- b = BitmapFactory.decodeResource(mRes, R.raw.public_radio, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.path4481, opts);
mIcons[16] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[16] = makeTextBitmap("Public Radio");
- b = BitmapFactory.decodeResource(mRes, R.raw.shazam, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.path5168, opts);
mIcons[17] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[17] = makeTextBitmap("Public Radio");
- b = BitmapFactory.decodeResource(mRes, R.raw.skype, opts);
+ b = BitmapFactory.decodeResource(mRes, R.raw.polygon2408, opts);
mIcons[18] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[18] = makeTextBitmap("Public Radio");
+ /*
b = BitmapFactory.decodeResource(mRes, R.raw.solitaire, opts);
mIcons[19] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[19] = makeTextBitmap("Public Radio");
b = BitmapFactory.decodeResource(mRes, R.raw.sudoku, opts);
mIcons[20] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[20] = makeTextBitmap("Public Radio");
b = BitmapFactory.decodeResource(mRes, R.raw.taptaprevenge, opts);
mIcons[21] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[21] = makeTextBitmap("Public Radio");
b = BitmapFactory.decodeResource(mRes, R.raw.tetris, opts);
mIcons[22] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[22] = makeTextBitmap("Public Radio");
b = BitmapFactory.decodeResource(mRes, R.raw.tictactoe, opts);
mIcons[23] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[23] = makeTextBitmap("Public Radio");
b = BitmapFactory.decodeResource(mRes, R.raw.tweetie, opts);
mIcons[24] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[24] = makeTextBitmap("Public Radio");
b = BitmapFactory.decodeResource(mRes, R.raw.urbanspoon, opts);
mIcons[25] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[25] = makeTextBitmap("Public Radio");
b = BitmapFactory.decodeResource(mRes, R.raw.waterslide_extreme, opts);
mIcons[26] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[26] = makeTextBitmap("Public Radio");
b = BitmapFactory.decodeResource(mRes, R.raw.weather_channel, opts);
mIcons[27] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[27] = makeTextBitmap("Public Radio");
b = BitmapFactory.decodeResource(mRes, R.raw.zippo, opts);
mIcons[28] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+ mLabels[28] = makeTextBitmap("Public Radio");
*/
- mIcons[4] = mIcons[3];
- mIcons[5] = mIcons[2];
- mIcons[6] = mIcons[1];
- mIcons[7] = mIcons[0];
- mIcons[8] = mIcons[1];
- mIcons[9] = mIcons[2];
- mIcons[10] = mIcons[3];
- mIcons[11] = mIcons[2];
- mIcons[12] = mIcons[1];
- mIcons[13] = mIcons[0];
- mIcons[14] = mIcons[1];
- mIcons[15] = mIcons[2];
- mIcons[16] = mIcons[3];
- mIcons[17] = mIcons[2];
- mIcons[18] = mIcons[1];
+
mIcons[19] = mIcons[0];
mIcons[20] = mIcons[1];
mIcons[21] = mIcons[2];
@@ -302,13 +361,26 @@ public class RolloRS {
mIcons[27] = mIcons[2];
mIcons[28] = mIcons[3];
+ mLabels[19] = mLabels[0];
+ mLabels[20] = mLabels[1];
+ mLabels[21] = mLabels[2];
+ mLabels[22] = mLabels[3];
+ mLabels[23] = mLabels[2];
+ mLabels[24] = mLabels[1];
+ mLabels[25] = mLabels[0];
+ mLabels[26] = mLabels[1];
+ mLabels[27] = mLabels[2];
+ mLabels[28] = mLabels[3];
for(int ct=0; ct < mIcons.length; ct++) {
mIcons[ct].uploadToTexture(0);
+ mLabels[ct].uploadToTexture(0);
mAllocIconIDBuf[ct] = mIcons[ct].getID();
+ mAllocLabelIDBuf[ct] = mLabels[ct].getID();
}
mAllocIconID.data(mAllocIconIDBuf);
+ mAllocLabelID.data(mAllocLabelIDBuf);
RenderScript.Element e = mRS.elementGetPredefined(RenderScript.ElementPredefined.RGB_565);
mRS.typeBegin(e);
@@ -341,10 +413,15 @@ public class RolloRS {
}
- private void makeTextBitmap() {
- //Bitmap b = Bitmap.createBitmap(128, 64, Bitmap.Config);
- //Canvas c = new Canvas(b);
- //canvas.drawText();
+ RenderScript.Allocation makeTextBitmap(String t) {
+ Bitmap b = Bitmap.createBitmap(128, 32, Bitmap.Config.ARGB_8888);
+ Canvas c = new Canvas(b);
+ Paint p = new Paint();
+ p.setTypeface(Typeface.DEFAULT_BOLD);
+ p.setTextSize(16);
+ p.setColor(0xffffffff);
+ c.drawText(t, 2, 20, p);
+ return mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
}
@@ -363,6 +440,7 @@ public class RolloRS {
mScript.bindAllocation(mAllocState, 0);
mScript.bindAllocation(mAllocIconID, 1);
mScript.bindAllocation(mAllocScratch, 2);
+ mScript.bindAllocation(mAllocLabelID, 3);
setPosition(0);
setZoom(1);
diff --git a/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java b/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java
index c67644b..71d6c7e 100644
--- a/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java
+++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java
@@ -90,8 +90,8 @@ public class RolloView extends RSSurfaceView {
if(c > (mColumns -2)) {
c = (mColumns -2);
}
- if(c < 1) {
- c = 1;
+ if(c < 0) {
+ c = 0;
}
mRender.setPosition(c);
if(clamp) {
@@ -122,6 +122,9 @@ public class RolloView extends RSSurfaceView {
float nx = ev.getX() / getWidth();
float ny = ev.getY() / getHeight();
+ //Log.e("rs", "width=" + Float.toString(getWidth()));
+ //Log.e("rs", "height=" + Float.toString(getHeight()));
+
mRender.setTouch(ret);
if((ny > 0.85f) || mControlMode) {