summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-07-29 20:55:44 -0700
committerJason Sams <rjsams@android.com>2009-07-29 20:55:44 -0700
commitfaf1520be77aa01903f9ad87990377f44e185224 (patch)
treeb19baaf038a4543185644735b8bc38405e7c4686 /libs
parent31b532ee9e1aaebbe383b13422cc59df43de4725 (diff)
downloadframeworks_base-faf1520be77aa01903f9ad87990377f44e185224.zip
frameworks_base-faf1520be77aa01903f9ad87990377f44e185224.tar.gz
frameworks_base-faf1520be77aa01903f9ad87990377f44e185224.tar.bz2
Filmstrip work and boxed bitmap load bugfixes.
Diffstat (limited to 'libs')
-rw-r--r--libs/rs/java/Film/res/raw/filmstrip.c23
-rw-r--r--libs/rs/java/Film/src/com/android/film/FilmRS.java56
-rw-r--r--libs/rs/java/Film/src/com/android/film/FilmView.java2
-rw-r--r--libs/rs/java/Rollo/res/raw/rollo.c10
-rw-r--r--libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java7
-rw-r--r--libs/rs/rsAllocation.cpp4
-rw-r--r--libs/rs/rsScriptC_Lib.cpp4
7 files changed, 64 insertions, 42 deletions
diff --git a/libs/rs/java/Film/res/raw/filmstrip.c b/libs/rs/java/Film/res/raw/filmstrip.c
index 495fe55..ac694ab 100644
--- a/libs/rs/java/Film/res/raw/filmstrip.c
+++ b/libs/rs/java/Film/res/raw/filmstrip.c
@@ -47,8 +47,8 @@ int main(int index)
// Start of images.
- bindProgramFragmentStore(NAMED_PFImages);
- bindProgramFragment(NAMED_PFSImages);
+ bindProgramFragmentStore(NAMED_PFSImages);
+ bindProgramFragment(NAMED_PFImages);
bindProgramVertex(NAMED_PVImages);
float focusPos = loadF(1, POS_FOCUS);
@@ -87,7 +87,16 @@ int main(int index)
offset = offset + triangleOffsetsCount / 2;
- if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
+ int drawit = 1;
+ if (offset < 0) {
+ drawit = 0;
+ }
+ if (offset >= triangleOffsetsCount) {
+ drawit = 0;
+ }
+
+ //if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
+ if (drawit) {
int start = offset -2;
int end = offset + 2;
@@ -99,11 +108,9 @@ int main(int index)
}
bindTexture(NAMED_PFImages, 0, loadI32(0, 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]);
- */
+ matrixLoadTranslate(&f16, -pos - loadF(5, triangleOffsetsCount / 2), 0, 0);
+ vpLoadTextureMatrix(&f16);
+ drawTriangleMeshRange(NAMED_mesh, loadI32(4, start), loadI32(4, end) - loadI32(4, start));
}
}
return 0;
diff --git a/libs/rs/java/Film/src/com/android/film/FilmRS.java b/libs/rs/java/Film/src/com/android/film/FilmRS.java
index 395bd35..1de44a7 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmRS.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java
@@ -67,7 +67,7 @@ public class FilmRS {
float anim = ((float)x-50) / 270.f;
mBufferPos[POS_TRANSLATE] = 2f * anim + 0.5f; // translation
mBufferPos[POS_ROTATE] = (anim * 40); // rotation
- mBufferPos[POS_FOCUS] = ((float)y) / 16.f - 8; // focusPos
+ mBufferPos[POS_FOCUS] = ((float)y) / 16.f - 10.f; // focusPos
mAllocPos.data(mBufferPos);
}
@@ -92,6 +92,9 @@ public class FilmRS {
private RenderScript.Allocation mAllocPos;
private RenderScript.Allocation mAllocState;
private RenderScript.Allocation mAllocPV;
+ private RenderScript.Allocation mAllocOffsetsTex;
+ private RenderScript.Allocation mAllocOffsets;
+
private RenderScript.TriangleMesh mMesh;
private RenderScript.Light mLight;
@@ -101,21 +104,11 @@ public class FilmRS {
private float[] mBufferPos = new float[3];
private int[] mBufferState;
- private void initSamplers() {
- mRS.samplerBegin();
- mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN,
- RenderScript.SamplerValue.LINEAR_MIP_LINEAR);
- mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_S,
- RenderScript.SamplerValue.CLAMP);
- mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_T,
- RenderScript.SamplerValue.CLAMP);
- mSampler = mRS.samplerCreate();
- }
-
private void initPFS() {
mRS.programFragmentStoreBegin(null, null);
mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.LESS);
mRS.programFragmentStoreDitherEnable(true);
+ mRS.programFragmentStoreDepthMask(true);
mPFSBackground = mRS.programFragmentStoreCreate();
mPFSBackground.setName("PFSBackground");
@@ -130,15 +123,27 @@ public class FilmRS {
}
private void initPF() {
+ mRS.samplerBegin();
+ mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN,
+ RenderScript.SamplerValue.LINEAR);//_MIP_LINEAR);
+ mRS.samplerSet(RenderScript.SamplerParam.FILTER_MAG,
+ RenderScript.SamplerValue.LINEAR);
+ mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_S,
+ RenderScript.SamplerValue.CLAMP);
+ mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_T,
+ RenderScript.SamplerValue.WRAP);
+ mSampler = mRS.samplerCreate();
+
+
mRS.programFragmentBegin(null, null);
mPFBackground = mRS.programFragmentCreate();
mPFBackground.setName("PFBackground");
mRS.programFragmentBegin(null, null);
mRS.programFragmentSetTexEnable(0, true);
- //mRS.programFragmentSetEnvMode(0, RS_TEX_ENV_MODE_REPLACE);
- //rsProgramFragmentSetType(0, gEnv.tex[0]->getType());
+ mRS.programFragmentSetTexEnvMode(0, RenderScript.EnvMode.REPLACE);
mPFImages = mRS.programFragmentCreate();
+ mPFImages.bindSampler(mSampler, 0);
mPFImages.setName("PFImages");
}
@@ -148,12 +153,12 @@ public class FilmRS {
mLight.setPosition(0, -0.5f, -1.0f);
mRS.programVertexBegin(null, null);
- mRS.programVertexSetTextureMatrixEnable(true);
mRS.programVertexAddLight(mLight);
mPVBackground = mRS.programVertexCreate();
mPVBackground.setName("PVBackground");
mRS.programVertexBegin(null, null);
+ mRS.programVertexSetTextureMatrixEnable(true);
mPVImages = mRS.programVertexCreate();
mPVImages.setName("PVImages");
}
@@ -179,8 +184,8 @@ public class FilmRS {
b = BitmapFactory.decodeResource(mRes, R.drawable.p03, opts);
mImages[2] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
- b = BitmapFactory.decodeResource(mRes, R.drawable.p04, opts);
- mImages[3] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+ b = BitmapFactory.decodeResource(mRes, R.drawable.path1927, opts);
+ mImages[3] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
b = BitmapFactory.decodeResource(mRes, R.drawable.p05, opts);
mImages[4] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
@@ -242,10 +247,8 @@ public class FilmRS {
mMesh.setName("mesh");
initPFS();
- initSamplers();
initPF();
initPV();
- mPFImages.bindSampler(mSampler, 0);
Log.e("rs", "Done loading named");
@@ -274,6 +277,21 @@ public class FilmRS {
mScriptStrip.bindAllocation(mPVA.mAlloc, 3);
+ mAllocOffsets = mRS.allocationCreatePredefSized(
+ RenderScript.ElementPredefined.USER_I32,
+ mFSM.mTriangleOffsets.length);
+ mAllocOffsets.data(mFSM.mTriangleOffsets);
+ mScriptStrip.bindAllocation(mAllocOffsets, 4);
+
+ mAllocOffsetsTex = mRS.allocationCreatePredefSized(
+ RenderScript.ElementPredefined.USER_FLOAT,
+ mFSM.mTriangleOffsetsTex.length);
+ mAllocOffsetsTex.data(mFSM.mTriangleOffsetsTex);
+ mScriptStrip.bindAllocation(mAllocOffsetsTex, 5);
+
+
+
+
/*
{
Resources res = getResources();
diff --git a/libs/rs/java/Film/src/com/android/film/FilmView.java b/libs/rs/java/Film/src/com/android/film/FilmView.java
index a743b1b..73b7414 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmView.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmView.java
@@ -74,7 +74,7 @@ public class FilmView extends RSSurfaceView {
if (act == ev.ACTION_UP) {
ret = false;
}
- mRender.setFilmStripPosition((int)ev.getX(), (int)ev.getY());
+ mRender.setFilmStripPosition((int)ev.getX(), (int)ev.getY() / 5);
return ret;
}
}
diff --git a/libs/rs/java/Rollo/res/raw/rollo.c b/libs/rs/java/Rollo/res/raw/rollo.c
index 9e03a44..8763a34 100644
--- a/libs/rs/java/Rollo/res/raw/rollo.c
+++ b/libs/rs/java/Rollo/res/raw/rollo.c
@@ -80,15 +80,15 @@ int main(void* con, int ft, int launchID)
float tmpCos = cosf(rot);
//debugF("rot", rot);
- float tx1 = tmpSin * diam - (tmpCos * scale);
- float tx2 = tx1 + (tmpCos * scale * 2.f);
- float tz1 = tmpCos * diam + (tmpSin * scale);
- float tz2 = tz1 - (tmpSin * scale * 2.f);
+ float tx1 = tmpSin * diam - (tmpCos * scale * 0.9f);
+ float tx2 = tx1 + (tmpCos * scale * 1.8f);
+ float tz1 = tmpCos * diam + (tmpSin * scale * 0.9f);
+ float tz2 = tz1 - (tmpSin * scale * 1.8f);
int y;
for (y = rowCount -1; (y >= 0) && iconCount; y--) {
float ty1 = ((y * 3.1f) - 5.f) * scale;
- float ty2 = ty1 + scale * 2.f;
+ float ty2 = ty1 + scale * 1.8f;
bindTexture(NAMED_PF, 0, loadI32(1, index));
//if (done && (index != selectedID)) {
//color(0.4f, 0.4f, 0.4f, 1.0f);
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 556ecee..c080176 100644
--- a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
+++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
@@ -200,9 +200,6 @@ public class RolloRS {
mRS.contextBindProgramVertex(mPV);
mAllocScratchBuf = new int[32];
- for(int ct=0; ct < mAllocScratchBuf.length; ct++) {
- mAllocScratchBuf[ct] = 0;
- }
mAllocScratch = mRS.allocationCreatePredefSized(
RenderScript.ElementPredefined.USER_I32, mAllocScratchBuf.length);
mAllocScratch.data(mAllocScratchBuf);
@@ -417,9 +414,9 @@ public class RolloRS {
Canvas c = new Canvas(b);
Paint p = new Paint();
p.setTypeface(Typeface.DEFAULT_BOLD);
- p.setTextSize(16);
+ p.setTextSize(20);
p.setColor(0xffffffff);
- c.drawText(t, 2, 20, p);
+ c.drawText(t, 2, 26, p);
return mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
}
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index c6a9149..ca277ef 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -377,9 +377,9 @@ RsAllocation rsi_AllocationCreateFromBitmapBoxed(Context *rsc, uint32_t w, uint3
const uint8_t * src = static_cast<const uint8_t *>(data);
for (uint32_t y = 0; y < h; y++) {
- uint8_t * ydst = &tmp[y + ((h2 - h) >> 1)];
+ uint8_t * ydst = &tmp[(y + ((h2 - h) >> 1)) * w2 * bpp];
memcpy(&ydst[(w2 - w) >> 1], src, w * bpp);
- src += h * bpp;
+ src += w * bpp;
}
RsAllocation ret = rsi_AllocationCreateFromBitmap(rsc, w2, h2, dstFmt, srcFmt, genMips, tmp);
diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp
index 4121906..7db3619 100644
--- a/libs/rs/rsScriptC_Lib.cpp
+++ b/libs/rs/rsScriptC_Lib.cpp
@@ -497,9 +497,9 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = {
"void", "(int, int, int)" },
// vp
- { "vpLoadModelMatrix", (void *)&SC_bindProgramFragment,
+ { "vpLoadModelMatrix", (void *)&SC_vpLoadModelMatrix,
"void", "(void *)" },
- { "vpLoadTextureMatrix", (void *)&SC_bindProgramFragmentStore,
+ { "vpLoadTextureMatrix", (void *)&SC_vpLoadTextureMatrix,
"void", "(void *)" },