From c1ea948ee8b16cf1afeea6f3e9e67df0811e4253 Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Thu, 16 Jul 2009 19:09:33 -0700 Subject: [PATCH] More usability tweaks including turning the icons right side up. --- libs/rs/java/Rollo/res/raw/rollo.c | 30 ++++++++----------- .../Rollo/src/com/android/rollo/RolloRS.java | 16 ++++++---- .../src/com/android/rollo/RolloView.java | 4 ++- libs/rs/rsScriptC.cpp | 15 ++-------- 4 files changed, 29 insertions(+), 36 deletions(-) diff --git a/libs/rs/java/Rollo/res/raw/rollo.c b/libs/rs/java/Rollo/res/raw/rollo.c index 91413ca06e3ca..08acc5dd551ea 100644 --- a/libs/rs/java/Rollo/res/raw/rollo.c +++ b/libs/rs/java/Rollo/res/raw/rollo.c @@ -4,14 +4,10 @@ #pragma stateFragmentStore(PFS) // Scratch buffer layout -// 0: fadeIn -// 1: zoomFade - #define SCRATCH_FADE 0 #define SCRATCH_ZOOM 1 #define SCRATCH_ROT 2 - #define STATE_POS_X 0 #define STATE_POS_Y 1 #define STATE_PRESSURE 2 @@ -21,16 +17,13 @@ #define STATE_SELECTION 6 #define STATE_FIRST_VISIBLE 7 #define STATE_COUNT 8 +#define STATE_TOUCH 9 -void pfClearColor(float, float, float, float); -float loadF(int, int); -void storeF(int, int, float); -void drawQuad(float x1, float y1, float z1, - float x2, float y2, float z2, - float x3, float y3, float z3, - float x4, float y4, float z4); -float sinf(float); -float cosf(float); +float filter(float val, float target, float str) +{ + float delta = (target - val); + return val + delta * str; +} int main(void* con, int ft, int launchID) { @@ -48,14 +41,17 @@ int main(void* con, int ft, int launchID) storeF(2, 0, f); } - float zoom = loadF(2, SCRATCH_ZOOM); + float touchCut = 1.f; + if (loadI32(0, STATE_TOUCH)) { + touchCut = 5.f; + } + float targetZoom = ((float)loadI32(0, STATE_ZOOM)) / 10.f; - zoom = zoom + (targetZoom - zoom) * 0.15f; + float zoom = filter(loadF(2, SCRATCH_ZOOM), targetZoom, 0.15 * touchCut); storeF(2, SCRATCH_ZOOM, zoom); - float rot = loadF(2, SCRATCH_ROT); float targetRot = loadI32(0, STATE_FIRST_VISIBLE) / 180.0f * 3.14f; - rot = rot + (targetRot - rot) * 0.15f; + float rot = filter(loadF(2, SCRATCH_ROT), targetRot, 0.1f * touchCut); storeF(2, SCRATCH_ROT, rot); float diam = 8.f;// + curve * 2.f; 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 daf3aa6fa9f6b..d4340174d859b 100644 --- a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java +++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java @@ -47,6 +47,7 @@ public class RolloRS { public static final int STATE_SELECTION = 6; public static final int STATE_FIRST_VISIBLE = 7; public static final int STATE_COUNT = 8; + public static final int STATE_TOUCH = 9; public RolloRS() { @@ -64,20 +65,25 @@ public class RolloRS { mAllocState.data(mAllocStateBuf); } + public void setTouch(boolean touch) { + mAllocStateBuf[STATE_TOUCH] = touch ? 1 : 0; + mAllocState.data(mAllocStateBuf); + } + public void setShadow(float x, float y, float size) { // x and y are normalized at this point. mAllocStateBuf[STATE_POS_X] = (int)(x * 1000); mAllocStateBuf[STATE_POS_Y] = (int)(y * 1000); mAllocStateBuf[STATE_PRESSURE] = (int)(size * 1000); - Log.e("rs","shadow x=" + Integer.toString(mAllocStateBuf[STATE_POS_X]) + - " y=" + Integer.toString(mAllocStateBuf[STATE_POS_X]) + - " s=" + Integer.toString(mAllocStateBuf[STATE_PRESSURE])); + //Log.e("rs","shadow x=" + Integer.toString(mAllocStateBuf[STATE_POS_X]) + + //" y=" + Integer.toString(mAllocStateBuf[STATE_POS_X]) + + //" s=" + Integer.toString(mAllocStateBuf[STATE_PRESSURE])); mAllocState.data(mAllocStateBuf); } public void setZoom(float z) { - Log.e("rs", "zoom " + Float.toString(z)); + //Log.e("rs", "zoom " + Float.toString(z)); mAllocStateBuf[STATE_ZOOM] = (int)(z * 10.f); mAllocState.data(mAllocStateBuf); @@ -253,7 +259,7 @@ public class RolloRS { //mRS.scriptCSetClearDepth(0); mScript = mRS.scriptCCreate(); - mAllocStateBuf = new int[] {0, 0, 0, 8, 0, 0, 0, 0, 38, 0}; + mAllocStateBuf = new int[] {0, 0, 0, 8, 0, 0, 0, 0, 38, 0, 0}; mAllocState = mRS.allocationCreatePredefSized( RenderScript.ElementPredefined.USER_I32, mAllocStateBuf.length); mScript.bindAllocation(mAllocState, 0); 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 6e2768ce8cc63..7df2b85c89c50 100644 --- a/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java +++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java @@ -87,6 +87,8 @@ public class RolloView extends RSSurfaceView { float nx = ev.getX() / getWidth(); float ny = ev.getY() / getHeight(); + mRender.setTouch(ret); + if((ny > 0.85f) || mControlMode) { mRender.setShadow(0, 0, 0); mFlingMode = false; @@ -99,7 +101,7 @@ public class RolloView extends RSSurfaceView { float dx = nx - mFlingX; if(ny < 0.9) { - zoom = 5.f - ((0.9f - ny) * 10.f); + zoom = 5.f - ((0.9f - ny) * 15.f); if(zoom < 1) { zoom = 1; mControlMode = false; diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index adbe3e9d07e6b..82bad7cb84868 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -326,7 +326,7 @@ static void SC_drawQuad(float x1, float y1, float z1, //LOGE("%4.2f, %4.2f, %4.2f", x4, y4, z4); float vtx[] = {x1,y1,z1, x2,y2,z2, x3,y3,z3, x4,y4,z4}; - static const float tex[] = {0,0, 0,1, 1,1, 1,0}; + static const float tex[] = {0,1, 1,1, 1,0, 0,0}; rsc->setupCheck(); @@ -353,18 +353,6 @@ static void SC_drawQuad(float x1, float y1, float z1, glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } -extern "C" float sinf(float angle) -{ - float s = (float)sin(angle); - return s; -} - -extern "C" float cosf(float angle) -{ - float s = (float)cos(angle); - return s; -} - extern "C" void pfClearColor(float r, float g, float b, float a) { //LOGE("c %f %f %f %f", r, g, b, a); @@ -522,6 +510,7 @@ ScriptCState::SymbolTable_t ScriptCState::gSyms[] = { { "drawQuad", (void *)&SC_drawQuad, "void drawQuad(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)" }, { "sinf", (void *)&sinf, "float sinf(float)" }, { "cosf", (void *)&cosf, "float cosf(float)" }, + { "fabs", (void *)&fabs, "float fabs(float)" }, { "contextBindProgramFragmentStore", (void *)&contextBindProgramFragmentStore, "void contextBindProgramFragmentStore(int)" }, { "pfClearColor", (void *)&pfClearColor, "void pfClearColor(float, float, float, float)" }, { "pfBindTexture", (void *)&pfBindTexture, "void pfBindTexture(int, int, int)" },