summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2010-06-18 22:11:19 (GMT)
committerJason Sams <rjsams@android.com>2010-06-18 22:11:19 (GMT)
commit60a55bbf54998afe9a0b766781c1dfada0d53518 (patch)
treec733c7250c89d007ef9b4cee7f9322644f0b9719 /src
parent9180ff6a59b552845751949749b2598813cb9f52 (diff)
downloadandroid_packages_apps_Trebuchet-60a55bbf54998afe9a0b766781c1dfada0d53518.zip
android_packages_apps_Trebuchet-60a55bbf54998afe9a0b766781c1dfada0d53518.tar.gz
android_packages_apps_Trebuchet-60a55bbf54998afe9a0b766781c1dfada0d53518.tar.bz2
Code cleanup possible with new reflected classes.
Change-Id: If9e79383722c0df997526717c52ded4921b6663e
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AllApps3D.java115
-rw-r--r--src/com/android/launcher2/ScriptC_Allapps.java127
-rw-r--r--src/com/android/launcher2/ScriptField_VpConsts.java2
3 files changed, 85 insertions, 159 deletions
diff --git a/src/com/android/launcher2/AllApps3D.java b/src/com/android/launcher2/AllApps3D.java
index 85dd750..4a2dc49 100644
--- a/src/com/android/launcher2/AllApps3D.java
+++ b/src/com/android/launcher2/AllApps3D.java
@@ -268,19 +268,19 @@ public class AllApps3D extends RSSurfaceView
}
if (sRollo.mUniformAlloc != null) {
- float tf[] = new float[] {120.f, 120.f, 0.f, 0.f,
- (2.f / 480.f), 0, -((float)w / 2) - 0.25f, -380.25f,
- 120.f, 680.f,
- 72.f, 72.f,};
+ ScriptField_VpConsts.Item i = new ScriptField_VpConsts.Item();
+ i.ScaleOffset.x = (2.f / 480.f);
+ i.ScaleOffset.y = 0;
+ i.ScaleOffset.z = -((float)w / 2) - 0.25f;
+ i.ScaleOffset.w = -380.25f;
+ i.BendPos.x = 120.f;
+ i.BendPos.y = 680.f;
if (w > h) {
- tf[6] = 40.f;
- tf[7] = h - 40.f;
- tf[9] = 1.f;
- tf[10] = -((float)w / 2) - 0.25f;
- tf[11] = -((float)h / 2) - 0.25f;
+ i.ScaleOffset.z = 40.f;
+ i.ScaleOffset.w = h - 40.f;
+ i.BendPos.y = 1.f;
}
-
- sRollo.mUniformAlloc.getAllocation().data(tf);
+ sRollo.mUniformAlloc.set(i, 0, true);
}
//long endTime = SystemClock.uptimeMillis();
@@ -601,9 +601,6 @@ public class AllApps3D extends RSSurfaceView
mMotionDownRawX = (int)ev.getRawX();
mMotionDownRawY = (int)ev.getRawY();
- sRollo.mScript.set_gNewPositionX(ev.getRawY() / getHeight());
- sRollo.mScript.set_gNewTouchDown(1);
-
if (!sRollo.checkClickOK()) {
sRollo.clearSelectedIcon();
} else {
@@ -614,7 +611,7 @@ public class AllApps3D extends RSSurfaceView
cancelLongPress();
}
}
- sRollo.move();
+ sRollo.move(ev.getRawY() / getHeight());
mVelocityTracker = VelocityTracker.obtain();
mVelocityTracker.addMovement(ev);
mStartedScrolling = false;
@@ -647,9 +644,7 @@ public class AllApps3D extends RSSurfaceView
cancelLongPress();
mCurrentIconIndex = -1;
}
- sRollo.mScript.set_gNewPositionX(ev.getRawY() / getHeight());
- sRollo.mScript.set_gNewTouchDown(1);
- sRollo.move();
+ sRollo.move(ev.getRawY() / getHeight());
mStartedScrolling = true;
sRollo.clearSelectedIcon();
@@ -670,14 +665,10 @@ public class AllApps3D extends RSSurfaceView
}
mCurrentIconIndex = -1;
} else if (mTouchTracking == TRACKING_FLING) {
- sRollo.mScript.set_gNewTouchDown(0);
- sRollo.mScript.set_gNewPositionX(ev.getRawY() / getHeight());
-
mVelocityTracker.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity);
- sRollo.mScript.set_gFlingVelocity(mVelocityTracker.getYVelocity() / getHeight());
sRollo.clearSelectedIcon();
- sRollo.move();
- sRollo.fling();
+ sRollo.fling(ev.getRawY() / getHeight(),
+ mVelocityTracker.getYVelocity() / getHeight());
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
@@ -923,17 +914,6 @@ public class AllApps3D extends RSSurfaceView
return -1;
}
- /*
- private static int countPages(int iconCount) {
- int iconsPerPage = getColumnsCount() * Defines.ROWS_PER_PAGE_PORTRAIT;
- int pages = iconCount / iconsPerPage;
- if (pages*iconsPerPage != iconCount) {
- pages++;
- }
- return pages;
- }
- */
-
class AAMessage extends RenderScript.RSMessage {
public void run() {
sRollo.mScrollPos = ((float)mData[0]) / (1 << 16);
@@ -967,12 +947,6 @@ public class AllApps3D extends RSSurfaceView
private Resources mRes;
ScriptC_Allapps mScript;
- //private ProgramStore mPSIcons;
- private ProgramFragment mPFTexMip;
- private ProgramFragment mPFTexMipAlpha;
- private ProgramFragment mPFTexNearest;
- private ProgramVertex mPV;
- private ProgramVertex mPVCurve;
private SimpleMesh mMesh;
private ProgramVertex.MatrixAllocation mPVA;
@@ -989,7 +963,6 @@ public class AllApps3D extends RSSurfaceView
private Allocation[] mLabels;
private int[] mLabelIds;
private Allocation mAllocLabelIds;
- private Allocation mSelectedIcon;
private Bitmap mSelectionBitmap;
private Canvas mSelectionCanvas;
@@ -1074,8 +1047,9 @@ public class AllApps3D extends RSSurfaceView
ProgramVertex.Builder pvb = new ProgramVertex.Builder(sRS, null, null);
pvb.setTextureMatrixEnable(true);
- mPV = pvb.create();
- mPV.bindAllocation(mPVA);
+ ProgramVertex pv = pvb.create();
+ pv.bindAllocation(mPVA);
+ sRS.contextBindProgramVertex(pv);
mUniformAlloc = new ScriptField_VpConsts(sRS, 1);
mScript.bind_vpConstants(mUniformAlloc);
@@ -1141,12 +1115,11 @@ public class AllApps3D extends RSSurfaceView
sb.setShader(t);
sb.addConstant(mUniformAlloc.getType());
sb.addInput(mMesh.getVertexType(0).getElement());
- mPVCurve = sb.create();
- mPVCurve.bindAllocation(mPVA);
- mPVCurve.bindConstants(mUniformAlloc.getAllocation(), 1);
+ ProgramVertex pvc = sb.create();
+ pvc.bindAllocation(mPVA);
+ pvc.bindConstants(mUniformAlloc.getAllocation(), 1);
- sRS.contextBindProgramVertex(mPV);
- mScript.set_gPVCurve(mPVCurve);
+ mScript.set_gPVCurve(pvc);
}
private void initProgramFragment() {
@@ -1164,20 +1137,20 @@ public class AllApps3D extends RSSurfaceView
ProgramFragment.Builder bf = new ProgramFragment.Builder(sRS);
bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
ProgramFragment.Builder.Format.RGBA, 0);
- mPFTexMip = bf.create();
- mPFTexMip.bindSampler(linear, 0);
+ ProgramFragment pfTexMip = bf.create();
+ pfTexMip.bindSampler(linear, 0);
- mPFTexNearest = bf.create();
- mPFTexNearest.bindSampler(nearest, 0);
+ ProgramFragment pfTexNearest = bf.create();
+ pfTexNearest.bindSampler(nearest, 0);
bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
ProgramFragment.Builder.Format.ALPHA, 0);
- mPFTexMipAlpha = bf.create();
- mPFTexMipAlpha.bindSampler(linear, 0);
+ ProgramFragment pfTexMipAlpha = bf.create();
+ pfTexMipAlpha.bindSampler(linear, 0);
- mScript.set_gPFTexNearest(mPFTexNearest);
- mScript.set_gPFTexMip(mPFTexMip);
- mScript.set_gPFTexMipAlpha(mPFTexMipAlpha);
+ mScript.set_gPFTexNearest(pfTexNearest);
+ mScript.set_gPFTexMip(pfTexMip);
+ mScript.set_gPFTexMipAlpha(pfTexMipAlpha);
}
private void initProgramStore() {
@@ -1258,14 +1231,7 @@ public class AllApps3D extends RSSurfaceView
sRollo.clearSelectedIcon();
sRollo.setHomeSelected(SELECTED_NONE);
}
- if (zoom > 0.001f) {
- sRollo.mScript.set_gZoomTarget(zoom);
- } else {
- sRollo.mScript.set_gZoomTarget(0);
- }
- if (!animate) {
- sRollo.mScript.invoke_setZoom();
- }
+ sRollo.mScript.invoke_setZoom(zoom, animate ? 1 : 0);
}
private void createAppIconAllocations(int index, ApplicationInfo item) {
@@ -1367,17 +1333,16 @@ public class AllApps3D extends RSSurfaceView
}
}
- void fling() {
- mScript.invoke_fling();
+ void fling(float pos, float v) {
+ mScript.invoke_fling(pos, v);
}
- void move() {
- mScript.invoke_move();
+ void move(float pos) {
+ mScript.invoke_move(pos);
}
void moveTo(float row) {
- mScript.set_gTargetPos(row);
- mScript.invoke_moveTo();
+ mScript.invoke_moveTo(row);
}
/**
@@ -1426,10 +1391,10 @@ public class AllApps3D extends RSSurfaceView
selectionBitmap.getWidth(), selectionBitmap.getHeight(),
pressed == SELECTED_PRESSED, info.iconBitmap);
- mSelectedIcon = Allocation.createFromBitmap(sRS, selectionBitmap,
+ Allocation si = Allocation.createFromBitmap(sRS, selectionBitmap,
Element.RGBA_8888(sRS), false);
- mSelectedIcon.uploadToTexture(0);
- mScript.set_gSelectedIconTexture(mSelectedIcon);
+ si.uploadToTexture(0);
+ mScript.set_gSelectedIconTexture(si);
if (prev != index) {
if (info.title != null && info.title.length() > 0) {
diff --git a/src/com/android/launcher2/ScriptC_Allapps.java b/src/com/android/launcher2/ScriptC_Allapps.java
index 55e3df0..aeb1c26 100644
--- a/src/com/android/launcher2/ScriptC_Allapps.java
+++ b/src/com/android/launcher2/ScriptC_Allapps.java
@@ -70,40 +70,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_ROWS_PER_PAGE_LANDSCAPE;
}
- private final static int mExportVarIdx_gNewPositionX = 4;
- private float mExportVar_gNewPositionX;
- public void set_gNewPositionX(float v) {
- mExportVar_gNewPositionX = v;
- setVar(mExportVarIdx_gNewPositionX, v);
- }
-
- public float get_gNewPositionX() {
- return mExportVar_gNewPositionX;
- }
-
- private final static int mExportVarIdx_gNewTouchDown = 5;
- private int mExportVar_gNewTouchDown;
- public void set_gNewTouchDown(int v) {
- mExportVar_gNewTouchDown = v;
- setVar(mExportVarIdx_gNewTouchDown, v);
- }
-
- public int get_gNewTouchDown() {
- return mExportVar_gNewTouchDown;
- }
-
- private final static int mExportVarIdx_gFlingVelocity = 6;
- private float mExportVar_gFlingVelocity;
- public void set_gFlingVelocity(float v) {
- mExportVar_gFlingVelocity = v;
- setVar(mExportVarIdx_gFlingVelocity, v);
- }
-
- public float get_gFlingVelocity() {
- return mExportVar_gFlingVelocity;
- }
-
- private final static int mExportVarIdx_gIconCount = 7;
+ private final static int mExportVarIdx_gIconCount = 4;
private int mExportVar_gIconCount;
public void set_gIconCount(int v) {
mExportVar_gIconCount = v;
@@ -114,7 +81,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gIconCount;
}
- private final static int mExportVarIdx_gSelectedIconIndex = 8;
+ private final static int mExportVarIdx_gSelectedIconIndex = 5;
private int mExportVar_gSelectedIconIndex;
public void set_gSelectedIconIndex(int v) {
mExportVar_gSelectedIconIndex = v;
@@ -125,7 +92,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gSelectedIconIndex;
}
- private final static int mExportVarIdx_gSelectedIconTexture = 9;
+ private final static int mExportVarIdx_gSelectedIconTexture = 6;
private Allocation mExportVar_gSelectedIconTexture;
public void set_gSelectedIconTexture(Allocation v) {
mExportVar_gSelectedIconTexture = v;
@@ -136,18 +103,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gSelectedIconTexture;
}
- private final static int mExportVarIdx_gZoomTarget = 10;
- private float mExportVar_gZoomTarget;
- public void set_gZoomTarget(float v) {
- mExportVar_gZoomTarget = v;
- setVar(mExportVarIdx_gZoomTarget, v);
- }
-
- public float get_gZoomTarget() {
- return mExportVar_gZoomTarget;
- }
-
- private final static int mExportVarIdx_gHomeButton = 11;
+ private final static int mExportVarIdx_gHomeButton = 7;
private Allocation mExportVar_gHomeButton;
public void set_gHomeButton(Allocation v) {
mExportVar_gHomeButton = v;
@@ -158,18 +114,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gHomeButton;
}
- private final static int mExportVarIdx_gTargetPos = 12;
- private float mExportVar_gTargetPos;
- public void set_gTargetPos(float v) {
- mExportVar_gTargetPos = v;
- setVar(mExportVarIdx_gTargetPos, v);
- }
-
- public float get_gTargetPos() {
- return mExportVar_gTargetPos;
- }
-
- private final static int mExportVarIdx_gPFTexNearest = 13;
+ private final static int mExportVarIdx_gPFTexNearest = 8;
private ProgramFragment mExportVar_gPFTexNearest;
public void set_gPFTexNearest(ProgramFragment v) {
mExportVar_gPFTexNearest = v;
@@ -180,7 +125,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gPFTexNearest;
}
- private final static int mExportVarIdx_gPFTexMip = 14;
+ private final static int mExportVarIdx_gPFTexMip = 9;
private ProgramFragment mExportVar_gPFTexMip;
public void set_gPFTexMip(ProgramFragment v) {
mExportVar_gPFTexMip = v;
@@ -191,7 +136,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gPFTexMip;
}
- private final static int mExportVarIdx_gPFTexMipAlpha = 15;
+ private final static int mExportVarIdx_gPFTexMipAlpha = 10;
private ProgramFragment mExportVar_gPFTexMipAlpha;
public void set_gPFTexMipAlpha(ProgramFragment v) {
mExportVar_gPFTexMipAlpha = v;
@@ -202,7 +147,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gPFTexMipAlpha;
}
- private final static int mExportVarIdx_gPVCurve = 16;
+ private final static int mExportVarIdx_gPVCurve = 11;
private ProgramVertex mExportVar_gPVCurve;
public void set_gPVCurve(ProgramVertex v) {
mExportVar_gPVCurve = v;
@@ -213,7 +158,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gPVCurve;
}
- private final static int mExportVarIdx_gPS = 17;
+ private final static int mExportVarIdx_gPS = 12;
private ProgramStore mExportVar_gPS;
public void set_gPS(ProgramStore v) {
mExportVar_gPS = v;
@@ -224,7 +169,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gPS;
}
- private final static int mExportVarIdx_gSMCell = 18;
+ private final static int mExportVarIdx_gSMCell = 13;
private SimpleMesh mExportVar_gSMCell;
public void set_gSMCell(SimpleMesh v) {
mExportVar_gSMCell = v;
@@ -235,7 +180,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gSMCell;
}
- private final static int mExportVarIdx_gIconIDs = 19;
+ private final static int mExportVarIdx_gIconIDs = 14;
private Allocation mExportVar_gIconIDs;
public void bind_gIconIDs(Allocation v) {
mExportVar_gIconIDs = v;
@@ -247,7 +192,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gIconIDs;
}
- private final static int mExportVarIdx_gLabelIDs = 20;
+ private final static int mExportVarIdx_gLabelIDs = 15;
private Allocation mExportVar_gLabelIDs;
public void bind_gLabelIDs(Allocation v) {
mExportVar_gLabelIDs = v;
@@ -259,7 +204,7 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_gLabelIDs;
}
- private final static int mExportVarIdx_vpConstants = 21;
+ private final static int mExportVarIdx_vpConstants = 16;
private ScriptField_VpConsts mExportVar_vpConstants;
public void bind_vpConstants(ScriptField_VpConsts v) {
mExportVar_vpConstants = v;
@@ -271,29 +216,45 @@ public class ScriptC_Allapps extends ScriptC {
return mExportVar_vpConstants;
}
- private final static int mExportFuncIdx_resetHWWar = 0;
- public void invoke_resetHWWar() {
- invoke(mExportFuncIdx_resetHWWar);
+ private final static int mExportVarIdx_gTargetPos = 17;
+ private float mExportVar_gTargetPos;
+ public void set_gTargetPos(float v) {
+ mExportVar_gTargetPos = v;
+ setVar(mExportVarIdx_gTargetPos, v);
+ }
+
+ public float get_gTargetPos() {
+ return mExportVar_gTargetPos;
}
- private final static int mExportFuncIdx_move = 1;
- public void invoke_move() {
- invoke(mExportFuncIdx_move);
+ private final static int mExportFuncIdx_move = 0;
+ public void invoke_move(float newPos) {
+ FieldPacker move_fp = new FieldPacker(4);
+ move_fp.addF32(newPos);
+ invoke(mExportFuncIdx_move, move_fp);
}
- private final static int mExportFuncIdx_moveTo = 2;
- public void invoke_moveTo() {
- invoke(mExportFuncIdx_moveTo);
+ private final static int mExportFuncIdx_moveTo = 1;
+ public void invoke_moveTo(float targetPos) {
+ FieldPacker moveTo_fp = new FieldPacker(4);
+ moveTo_fp.addF32(targetPos);
+ invoke(mExportFuncIdx_moveTo, moveTo_fp);
}
- private final static int mExportFuncIdx_setZoom = 3;
- public void invoke_setZoom() {
- invoke(mExportFuncIdx_setZoom);
+ private final static int mExportFuncIdx_setZoom = 2;
+ public void invoke_setZoom(float z, int animate) {
+ FieldPacker setZoom_fp = new FieldPacker(8);
+ setZoom_fp.addF32(z);
+ setZoom_fp.addI32(animate);
+ invoke(mExportFuncIdx_setZoom, setZoom_fp);
}
- private final static int mExportFuncIdx_fling = 4;
- public void invoke_fling() {
- invoke(mExportFuncIdx_fling);
+ private final static int mExportFuncIdx_fling = 3;
+ public void invoke_fling(float newPos, float vel) {
+ FieldPacker fling_fp = new FieldPacker(8);
+ fling_fp.addF32(newPos);
+ fling_fp.addF32(vel);
+ invoke(mExportFuncIdx_fling, fling_fp);
}
}
diff --git a/src/com/android/launcher2/ScriptField_VpConsts.java b/src/com/android/launcher2/ScriptField_VpConsts.java
index f3ef684..b5e41b7 100644
--- a/src/com/android/launcher2/ScriptField_VpConsts.java
+++ b/src/com/android/launcher2/ScriptField_VpConsts.java
@@ -69,7 +69,7 @@ public class ScriptField_VpConsts extends android.renderscript.Script.FieldBase
mItemArray[index] = i;
if (copyNow) {
copyToArray(i, index);
- mAllocation.subData1D(index * Item.sizeof, Item.sizeof, mIOBuffer.getData());
+ mAllocation.subData1D(index /** Item.sizeof*/, 1/*Item.sizeof*/, mIOBuffer.getData());
}
}