From 14f67edd3fd39137df072d66a6fb33a148786545 Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Tue, 11 May 2010 14:02:43 -0700 Subject: [PATCH] Update Launcher2 to work with LLVM. Change-Id: I992b812ec58d182e5df7ddad3ab8e7d9e7b88551 --- res/raw/allapps.rs | 326 +++++++++++------- res/raw/allapps_bc.bc | Bin 0 -> 11052 bytes src/com/android/launcher2/AllApps3D.java | 308 ++++++----------- .../android/launcher2/ScriptC_allapps.java | 197 +++++++++++ .../launcher2/ScriptField_VpConsts.java | 73 ++++ 5 files changed, 583 insertions(+), 321 deletions(-) create mode 100644 res/raw/allapps_bc.bc create mode 100644 src/com/android/launcher2/ScriptC_allapps.java create mode 100644 src/com/android/launcher2/ScriptField_VpConsts.java diff --git a/res/raw/allapps.rs b/res/raw/allapps.rs index af5abd3118..0e278d9e13 100644 --- a/res/raw/allapps.rs +++ b/res/raw/allapps.rs @@ -1,41 +1,115 @@ #pragma version(1) -#pragma stateVertex(PV) -#pragma stateFragment(PFTexNearest) -#pragma stateStore(PSIcons) + +#include "../../../../../frameworks/base/libs/rs/scriptc/rs_types.rsh" +#include "../../../../../frameworks/base/libs/rs/scriptc/rs_math.rsh" +#include "../../../../../frameworks/base/libs/rs/scriptc/rs_graphics.rsh" +//#pragma stateVertex(PV) +//#pragma stateFragment(PFTexNearest) +//#pragma stateStore(PSIcons) #define PI 3.14159f -int g_SpecialHWWar; +static int g_SpecialHWWar; + + +// Constants from Java +int COLUMNS_PER_PAGE_PORTRAIT; +int ROWS_PER_PAGE_PORTRAIT; +int COLUMNS_PER_PAGE_LANDSCAPE; +int ROWS_PER_PAGE_LANDSCAPE; + +float gNewPositionX; +int gNewTouchDown; +float gFlingVelocity; +int gIconCount; +int gSelectedIconIndex; +rs_allocation gSelectedIconTexture; +float gZoomTarget; +rs_allocation gHomeButton; +float gTargetPos; + +rs_program_fragment gPFTexNearest; +rs_program_fragment gPFTexMip; +rs_program_fragment gPFTexMipAlpha; +rs_program_vertex gPVCurve; +rs_program_store gPS; +rs_mesh gSMCell; + +rs_allocation *gIconIDs; +rs_allocation *gLabelIDs; + +typedef struct VpConsts_s { + float4 Position; + float4 ScaleOffset; + float2 BendPos; + float2 ImgSize; +} VpConsts_t; +VpConsts_t *vpConstants; + + +#pragma rs export_var(COLUMNS_PER_PAGE_PORTRAIT, ROWS_PER_PAGE_PORTRAIT, COLUMNS_PER_PAGE_LANDSCAPE, ROWS_PER_PAGE_LANDSCAPE, gNewPositionX, gNewTouchDown, gFlingVelocity, gIconCount, gSelectedIconIndex, gSelectedIconTexture, gZoomTarget, gHomeButton, gTargetPos, gPFTexNearest, gPFTexMip, gPFTexMipAlpha, gPVCurve, gPS, gSMCell, gIconIDs, gLabelIDs, vpConstants) +#pragma rs export_func(resetHWWar, move, moveTo, setZoom, fling) + + +void debugAll() +{ + debugPi(1000, COLUMNS_PER_PAGE_PORTRAIT); + debugPi(1001, ROWS_PER_PAGE_PORTRAIT); + debugPi(1002, COLUMNS_PER_PAGE_LANDSCAPE); + debugPi(1003, ROWS_PER_PAGE_LANDSCAPE); + + debugPf(1018, gNewPositionX); + debugPi(1019, gNewTouchDown); + debugPf(1020, gFlingVelocity); + debugPi(1021, gIconCount); + debugPi(1022, gSelectedIconIndex); + debugPi(1023, gSelectedIconTexture); + debugPf(1024, gZoomTarget); + debugPi(1025, gHomeButton); + debugPf(1026, gTargetPos); + + debugPi(1027, gPFTexNearest); + debugPi(1028, gPFTexMip); + debugPi(1029, gPFTexMipAlpha); + debugPi(1030, gPVCurve); + debugPi(1031, gSMCell); + + debugP(1032, gIconIDs); + debugP(1033, gLabelIDs); + debugP(1034, vpConstants); +} + // Attraction to center values from page edge to page center. -float g_AttractionTable[9]; -float g_FrictionTable[9]; -float g_PhysicsTableSize; +static float g_AttractionTable[9]; +static float g_FrictionTable[9]; +static float g_PhysicsTableSize; -float g_PosPage; -float g_PosVelocity; -float g_LastPositionX; -int g_LastTouchDown; -float g_DT; -int g_LastTime; -int g_PosMax; -float g_Zoom; -float g_Animation; -float g_OldPosPage; -float g_OldPosVelocity; -float g_OldZoom; -float g_MoveToTotalTime; -float g_MoveToTime; -float g_MoveToOldPos; +static float g_PosPage; +static float g_PosVelocity; +static float g_LastPositionX; +static int g_LastTouchDown; +static float g_DT; +static int g_LastTime; +static int g_PosMax; +static float g_Zoom; +static float g_Animation; +static float g_OldPosPage; +static float g_OldPosVelocity; +static float g_OldZoom; +static float g_MoveToTotalTime; +static float g_MoveToTime; +static float g_MoveToOldPos; -int g_Cols; -int g_Rows; +static int g_Cols; +static int g_Rows; // Drawing constants, should be parameters ====== #define VIEW_ANGLE 1.28700222f -int g_DrawLastFrame; -int lastFrame(int draw) { +static int g_DrawLastFrame; +static int lastFrame(int draw) { + //debugPi(99, 13); // We draw one extra frame to work around the last frame post bug. // We also need to track if we drew the last frame to deal with large DT // in the physics. @@ -44,11 +118,15 @@ int lastFrame(int draw) { return ret; // should return draw instead. } -void updateReadback() { - if ((g_OldPosPage != g_PosPage) || - (g_OldPosVelocity != g_PosVelocity) || - (g_OldZoom != g_Zoom)) { +static void updateReadback() { + //debugPi(99, 12); + //if ((g_OldPosPage != g_PosPage) || + //(g_OldPosVelocity != g_PosVelocity) || + //(g_OldZoom != g_Zoom)) { + //debugPf(40, g_PosPage); + //debugPf(41, g_PosVelocity); + //debugPf(42, g_Zoom); g_OldPosPage = g_PosPage; g_OldPosVelocity = g_PosVelocity; g_OldZoom = g_Zoom; @@ -58,10 +136,11 @@ void updateReadback() { i[1] = g_PosVelocity * (1 << 16); i[2] = g_OldZoom * (1 << 16); sendToClient(&i[0], 1, 12, 1); - } + //} } -void setColor(float r, float g, float b, float a) { +static void setColor(float r, float g, float b, float a) { + //debugPi(99, 11); if (g_SpecialHWWar) { color(0, 0, 0, 0.001f); } else { @@ -70,6 +149,7 @@ void setColor(float r, float g, float b, float a) { } void init() { + //debugPi(99, 10); g_AttractionTable[0] = 20.0f; g_AttractionTable[1] = 20.0f; g_AttractionTable[2] = 20.0f; @@ -103,26 +183,29 @@ void init() { } void resetHWWar() { + //debugPi(99, 9); g_SpecialHWWar = 1; } void move() { + //debugPi(99, 8); if (g_LastTouchDown) { - float dx = -(state->newPositionX - g_LastPositionX); + float dx = -(gNewPositionX - g_LastPositionX); g_PosVelocity = 0; g_PosPage += dx * 5.2f; float pmin = -0.49f; float pmax = g_PosMax + 0.49f; - g_PosPage = clampf(g_PosPage, pmin, pmax); + g_PosPage = clamp(g_PosPage, pmin, pmax); } - g_LastTouchDown = state->newTouchDown; - g_LastPositionX = state->newPositionX; + g_LastTouchDown = gNewTouchDown; + g_LastPositionX = gNewPositionX; g_MoveToTime = 0; //debugF("Move P", g_PosPage); } void moveTo() { + //debugPi(99, 7); g_MoveToTime = g_MoveToTotalTime; g_PosVelocity = 0; g_MoveToOldPos = g_PosPage; @@ -131,18 +214,20 @@ void moveTo() { } void setZoom() { - g_Zoom = state->zoomTarget; + //debugPi(99, 6); + g_Zoom = gZoomTarget; g_DrawLastFrame = 1; updateReadback(); } void fling() { + //debugPi(99, 5); g_LastTouchDown = 0; - g_PosVelocity = -state->flingVelocity * 4; - float av = fabsf(g_PosVelocity); + g_PosVelocity = -gFlingVelocity * 4; + float av = fabs(g_PosVelocity); float minVel = 3.5f; - minVel *= 1.f - (fabsf(fracf(g_PosPage + 0.5f) - 0.5f) * 0.45f); + minVel *= 1.f - (fabs(frac(g_PosPage + 0.5f) - 0.5f) * 0.45f); if (av < minVel && av > 0.2f) { if (g_PosVelocity > 0) { @@ -153,59 +238,51 @@ void fling() { } if (g_PosPage <= 0) { - g_PosVelocity = maxf(0, g_PosVelocity); + g_PosVelocity = max(0.f, g_PosVelocity); } if (g_PosPage > g_PosMax) { - g_PosVelocity = minf(0, g_PosVelocity); + g_PosVelocity = min(0.f, g_PosVelocity); } } -float -modf(float x, float y) -{ - return x-(y*floorf(x/y)); +// Interpolates values in the range 0..1 to a curve that eases in +// and out. +static float getInterpolation(float input) { + //debugPi(99, 4); + return (cos((input + 1) * PI) * 0.5f) + 0.5f; } -/* - * Interpolates values in the range 0..1 to a curve that eases in - * and out. - */ -float -getInterpolation(float input) { - return (cosf((input + 1) * PI) / 2.0f) + 0.5f; -} - - -void updatePos() { +static void updatePos() { + //debugPi(99, 3); if (g_LastTouchDown) { return; } - float tablePosNorm = fracf(g_PosPage + 0.5f); + float tablePosNorm = frac(g_PosPage + 0.5f); float tablePosF = tablePosNorm * g_PhysicsTableSize; int tablePosI = tablePosF; float tablePosFrac = tablePosF - tablePosI; - float accel = lerpf(g_AttractionTable[tablePosI], + float accel = mix(g_AttractionTable[tablePosI], g_AttractionTable[tablePosI + 1], tablePosFrac) * g_DT; - float friction = lerpf(g_FrictionTable[tablePosI], + float friction = mix(g_FrictionTable[tablePosI], g_FrictionTable[tablePosI + 1], tablePosFrac) * g_DT; if (g_MoveToTime) { // New position is old posiition + (total distance) * (interpolated time) - g_PosPage = g_MoveToOldPos + (state->targetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime); + g_PosPage = g_MoveToOldPos + (gTargetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime); g_MoveToTime -= g_DT; if (g_MoveToTime <= 0) { g_MoveToTime = 0; - g_PosPage = state->targetPos; + g_PosPage = gTargetPos; } return; } // If our velocity is low OR acceleration is opposing it, apply it. - if (fabsf(g_PosVelocity) < 4.0f || (g_PosVelocity * accel) < 0) { + if (fabs(g_PosVelocity) < 4.0f || (g_PosVelocity * accel) < 0) { g_PosVelocity += accel; } //debugF("g_PosPage", g_PosPage); @@ -216,18 +293,18 @@ void updatePos() { // Normal physics if (g_PosVelocity > 0) { g_PosVelocity -= friction; - g_PosVelocity = maxf(g_PosVelocity, 0); + g_PosVelocity = max(g_PosVelocity, 0.f); } else { g_PosVelocity += friction; - g_PosVelocity = minf(g_PosVelocity, 0); + g_PosVelocity = min(g_PosVelocity, 0.f); } - if ((friction > fabsf(g_PosVelocity)) && (friction > fabsf(accel))) { + if ((friction > fabs(g_PosVelocity)) && (friction > fabs(accel))) { // Special get back to center and overcome friction physics. float t = tablePosNorm - 0.5f; - if (fabsf(t) < (friction * g_DT)) { + if (fabs(t) < (friction * g_DT)) { // really close, just snap - g_PosPage = roundf(g_PosPage); + g_PosPage = round(g_PosPage); g_PosVelocity = 0; } else { if (t > 0) { @@ -240,46 +317,51 @@ void updatePos() { // Check for out of boundry conditions. if (g_PosPage < 0 && g_PosVelocity < 0) { - float damp = 1.0 + (g_PosPage * 4); - damp = clampf(damp, 0.f, 0.9f); + float damp = 1.0f + (g_PosPage * 4); + damp = clamp(damp, 0.f, 0.9f); g_PosVelocity *= damp; } if (g_PosPage > g_PosMax && g_PosVelocity > 0) { - float damp = 1.0 - ((g_PosPage - g_PosMax) * 4); - damp = clampf(damp, 0.f, 0.9f); + float damp = 1.0f - ((g_PosPage - g_PosMax) * 4); + damp = clamp(damp, 0.f, 0.9f); g_PosVelocity *= damp; } g_PosPage += g_PosVelocity * g_DT; - g_PosPage = clampf(g_PosPage, -0.49, g_PosMax + 0.49); + g_PosPage = clamp(g_PosPage, -0.49f, g_PosMax + 0.49f); + + //debugPf(300, g_PosPage); } - -void +static void draw_home_button() { + //debugPi(99, 2); setColor(1.0f, 1.0f, 1.0f, 1.0f); - bindTexture(NAMED_PFTexNearest, 0, state->homeButtonId); + bindTexture(gPFTexNearest, 0, gHomeButton); float w = getWidth(); float h = getHeight(); + float tw = allocGetDimX(gHomeButton); + float th = allocGetDimY(gHomeButton); float x; float y; if (getWidth() > getHeight()) { - x = w - (params->homeButtonTextureWidth * (1 - g_Animation)) + 20; - y = (h - params->homeButtonTextureHeight) * 0.5f; + x = w - (tw * (1 - g_Animation)) + 20; + y = (h - th) * 0.5f; } else { - x = (w - params->homeButtonTextureWidth) / 2; - y = -g_Animation * params->homeButtonTextureHeight; + x = (w - tw) / 2; + y = -g_Animation * th; y -= 30; // move the house to the edge of the screen as it doesn't fill the texture. } - drawSpriteScreenspace(x, y, 0, params->homeButtonTextureWidth, params->homeButtonTextureHeight); + drawSpriteScreenspace(x, y, 0, tw, th); } -void drawFrontGrid(float rowOffset, float p) +static void drawFrontGrid(float rowOffset, float p) { + //debugPi(99, 1); float h = getHeight(); float w = getWidth(); @@ -289,6 +371,8 @@ void drawFrontGrid(float rowOffset, float p) float rowHeight = colWidth + 25.f; float yoff = 0.5f * h + 1.5f * rowHeight; + //debugPi(199, 1); + int row, col; int colCount = 4; if (w > h) { @@ -299,8 +383,7 @@ void drawFrontGrid(float rowOffset, float p) int iconNum = (intRowOffset - 5) * colCount; - - bindProgramVertex(NAMED_PVCurve); + bindProgramVertex(gPVCurve); vpConstants->Position.z = p; @@ -309,7 +392,7 @@ void drawFrontGrid(float rowOffset, float p) float y = yoff - ((-rowFrac + row) * rowHeight); for (col=0; col < colCount; col++) { - if (iconNum >= state->iconCount) { + if (iconNum >= gIconCount) { return; } @@ -317,28 +400,35 @@ void drawFrontGrid(float rowOffset, float p) float x = colWidth * col + (colWidth / 2); vpConstants->Position.x = x + 0.2f; - if (state->selectedIconIndex == iconNum && !p) { - bindProgramFragment(NAMED_PFTexNearest); - bindTexture(NAMED_PFTexNearest, 0, state->selectedIconTexture); - vpConstants->ImgSize.x = SELECTION_TEXTURE_WIDTH_PX; - vpConstants->ImgSize.y = SELECTION_TEXTURE_HEIGHT_PX; - vpConstants->Position.y = y - (SELECTION_TEXTURE_HEIGHT_PX - ICON_TEXTURE_HEIGHT_PX) * 0.5f; - drawSimpleMesh(NAMED_SMCell); + if (gSelectedIconIndex == iconNum && !p && gSelectedIconTexture) { + bindProgramFragment(gPFTexNearest); + bindTexture(gPFTexNearest, 0, gSelectedIconTexture); + vpConstants->ImgSize.x = allocGetDimX(gSelectedIconTexture); + vpConstants->ImgSize.y = allocGetDimY(gSelectedIconTexture); + vpConstants->Position.y = y - (allocGetDimY(gSelectedIconTexture) - allocGetDimY(gIconIDs[iconNum])) * 0.5f; + drawSimpleMesh(gSMCell); } - bindProgramFragment(NAMED_PFTexMip); - vpConstants->ImgSize.x = ICON_TEXTURE_WIDTH_PX; - vpConstants->ImgSize.y = ICON_TEXTURE_HEIGHT_PX; + bindProgramFragment(gPFTexMip); + vpConstants->ImgSize.x = allocGetDimX(gIconIDs[iconNum]); + vpConstants->ImgSize.y = allocGetDimY(gIconIDs[iconNum]); vpConstants->Position.y = y - 0.2f; - bindTexture(NAMED_PFTexMip, 0, loadI32(ALLOC_ICON_IDS, iconNum)); - drawSimpleMesh(NAMED_SMCell); + bindTexture(gPFTexMip, 0, gIconIDs[iconNum]); + drawSimpleMesh(gSMCell); - bindProgramFragment(NAMED_PFTexMipAlpha); - vpConstants->ImgSize.x = 120.f; - vpConstants->ImgSize.y = 64.f; + //debugPf(202, vpConstants->ImgSize.x); + //debugPf(203, vpConstants->ImgSize.y); + //debugPf(204, vpConstants->Position.y); + //debugPi(205, gIconIDs[iconNum]); + //debugPi(206, gLabelIDs[iconNum]); + + + bindProgramFragment(gPFTexMipAlpha); + vpConstants->ImgSize.x = allocGetDimX(gLabelIDs[iconNum]); + vpConstants->ImgSize.y = allocGetDimY(gLabelIDs[iconNum]); vpConstants->Position.y = y - 64.f - 0.2f; - bindTexture(NAMED_PFTexMipAlpha, 0, loadI32(ALLOC_LABEL_IDS, iconNum)); - drawSimpleMesh(NAMED_SMCell); + bindTexture(gPFTexMipAlpha, 0, gLabelIDs[iconNum]); + drawSimpleMesh(gSMCell); } iconNum++; } @@ -346,12 +436,14 @@ void drawFrontGrid(float rowOffset, float p) } -int -main(int launchID) +int root() { + //debugAll(); + bindProgramStore(gPS); + // Compute dt in seconds. int newTime = uptimeMillis(); - g_DT = (newTime - g_LastTime) / 1000.f; + g_DT = (newTime - g_LastTime) * 0.001f; g_LastTime = newTime; if (!g_DrawLastFrame) { @@ -360,24 +452,25 @@ main(int launchID) g_DT = 0.033f; } // physics may break if DT is large. - g_DT = minf(g_DT, 0.2f); + g_DT = min(g_DT, 0.2f); - if (g_Zoom != state->zoomTarget) { + if (g_Zoom != gZoomTarget) { float dz = g_DT * 1.7f; - if (state->zoomTarget < 0.5f) { + if (gZoomTarget < 0.5f) { dz = -dz; } - if (fabsf(g_Zoom - state->zoomTarget) < fabsf(dz)) { - g_Zoom = state->zoomTarget; + if (fabs(g_Zoom - gZoomTarget) < fabs(dz)) { + g_Zoom = gZoomTarget; } else { g_Zoom += dz; } updateReadback(); } - g_Animation = powf(1-g_Zoom, 3); + g_Animation = pow(1.f - g_Zoom, 3.f); + //debugPf(100, g_Zoom); // Set clear value to dim the background based on the zoom position. - if ((g_Zoom < 0.001f) && (state->zoomTarget < 0.001f) && !g_SpecialHWWar) { + if ((g_Zoom < 0.001f) && (gZoomTarget < 0.001f) && !g_SpecialHWWar) { pfClearColor(0.0f, 0.0f, 0.0f, 0.0f); // When we're zoomed out and not tracking motion events, reset the pos to 0. if (!g_LastTouchDown) { @@ -385,11 +478,11 @@ main(int launchID) } return lastFrame(0); } else { + //debugPf(101, g_Zoom); pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom); } // icons & labels - int iconCount = state->iconCount; if (getWidth() > getHeight()) { g_Cols = 6; g_Rows = 3; @@ -397,7 +490,7 @@ main(int launchID) g_Cols = 4; g_Rows = 4; } - g_PosMax = ((iconCount + (g_Cols-1)) / g_Cols) - g_Rows; + g_PosMax = ((gIconCount + (g_Cols-1)) / g_Cols) - g_Rows; if (g_PosMax < 0) g_PosMax = 0; updatePos(); @@ -408,7 +501,7 @@ main(int launchID) // Draw the icons ======================================== drawFrontGrid(g_PosPage, g_Animation); - bindProgramFragment(NAMED_PFTexNearest); + bindProgramFragment(gPFTexNearest); draw_home_button(); // This is a WAR to do a rendering pass without drawing during init to @@ -422,6 +515,7 @@ main(int launchID) // Bug workaround where the last frame is not always displayed // So we keep rendering until the bug is fixed. - return lastFrame((g_PosVelocity != 0) || fracf(g_PosPage) || g_Zoom != state->zoomTarget || (g_MoveToTime != 0)); + return lastFrame((g_PosVelocity != 0) || frac(g_PosPage) || g_Zoom != gZoomTarget || (g_MoveToTime != 0)); } + diff --git a/res/raw/allapps_bc.bc b/res/raw/allapps_bc.bc new file mode 100644 index 0000000000000000000000000000000000000000..85d680557df9d9876fbaf5c9a74f998c40926fa9 GIT binary patch literal 11052 zcmaKSd0bOR*YIQyB!mP41PPERV$`Ss0fUML5-7HaL9GSRngF8J27q8q4F=-klAEhGzjD2?eGK;4vP5X6#Wwy5G!*dCD#|Mq^*toOGev+91t81v4?KZ3sG=khLPG(D4lZyJ z%{N(4a9ljiB{;60={e*cSsda?T`r@@-a+)bL=snF7e>ptvO*DBwnbj3K-;dwGf$~J z5?EE8NzpEcEL)<-Y*%fKe8w+NK#*JBT_znNrSPtnf`s;U0hup;%-HMMy?g zo64Ds)#h^kNQ4wTQ#pGi;-}MKz`HzkG}oa($g@&koWG(nf5Jk_%2kY&lKcow{xW_3 z8e4vZoUyVZe+iS36QA$)M9tA5_cb!cl5)mU5d&A6>A!IqYYh0OE9R^!XW$>vxT2hq zqhYM!GFHIr|Cyp;EGuWMP%zd&rJ3IKzr9`m+xznWymA>!V7a$S9hajoXTT2->Kq&( zY`pt{c+n7*3V9zh94n*kJ}-4hGfBguS@KOOwkgfzOKINv{x0gMx4Kdq-|o6P%JFR$ z>8tlya<9~~Lv1w)Chts-pDt;pHZugTRW_v= z&*~CS8S9GhiLj@XCouscP5jZK7+gWhEm?drt_Ze-?FUIj$X0y7mxl1Lyr3otQb0u( zWRDXAM25Fe?My-jXwt-ADI_B*)RZ2X1E^&C@p6EwbC4BR0M&H~9s{U&aU=vQ8pJ<` zxnf}jsy-i}YRLdq9=ZWks{M#fP}S)>fa;e4R3vi}$^#6V_|SogTQd0uOe(RR|2y&W zz{CyzZbwkq&xil6m@q(m#=pb^AC!RfEk3x6b+tKJS~fs@%>b(Z(y-QvO5x2!E-*hd zpiJn?ODHaM34W)Zstk=o5&=o1p&GXEkjFcyLI4|G4R`ks80%RuL~fzokenrtY>gRN zT_b%%mToiQ(o!>gTg@0-&BzAwsD>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6G zabgSE9wYF~;BIY8Q1!}L(2_oMBj!LAQz`gabKu)OLG_=Gt_7M$4F!fbywA6~jUruP z6WnNHKl^1Bi8@^?E^!|HqXgTP!E9~fPm}MMhIqx*p^JB!qLAfG&r}{ox@m}^u2o$4 z@x-6WPDuzTetOJZEV6mj$hfbKzViB$qN1nHQ=k>)c+7gFuDKjJE1f(jzx2D+NBf0& zfFU($7LM{`EJ9I{tz(hr5fAvMH&a?z!{mFhRHk*fwEnR?fu*8{_)h1Gnu_B#^GJ>F zsXTLh`9pY3&Es#HK!%a;+nD>W$%MukdKO8w8}jgngcP1SZnhvgeYa)%c#lwVqUSDV Q+M7c|cG!qyHQc-Z2ThLT$N&HU literal 0 HcmV?d00001 diff --git a/src/com/android/launcher2/AllApps3D.java b/src/com/android/launcher2/AllApps3D.java index 9c3b3e4c72..8644a43e60 100644 --- a/src/com/android/launcher2/AllApps3D.java +++ b/src/com/android/launcher2/AllApps3D.java @@ -131,27 +131,16 @@ public class AllApps3D extends RSSurfaceView private boolean mSurrendered; private int mRestoreFocusIndex = -1; - + @SuppressWarnings({"UnusedDeclaration"}) static class Defines { - public static final int ALLOC_PARAMS = 0; - public static final int ALLOC_STATE = 1; - public static final int ALLOC_ICON_IDS = 3; - public static final int ALLOC_LABEL_IDS = 4; - public static final int ALLOC_VP_CONSTANTS = 5; - public static final int COLUMNS_PER_PAGE_PORTRAIT = 4; public static final int ROWS_PER_PAGE_PORTRAIT = 4; public static final int COLUMNS_PER_PAGE_LANDSCAPE = 6; public static final int ROWS_PER_PAGE_LANDSCAPE = 3; - public static final int ICON_WIDTH_PX = 64; - public static final int ICON_TEXTURE_WIDTH_PX = 74; public static final int SELECTION_TEXTURE_WIDTH_PX = 74 + 20; - - public static final int ICON_HEIGHT_PX = 64; - public static final int ICON_TEXTURE_HEIGHT_PX = 74; public static final int SELECTION_TEXTURE_HEIGHT_PX = 74 + 20; } @@ -274,15 +263,16 @@ public class AllApps3D extends RSSurfaceView sRollo.dirtyCheck(); sRollo.resize(w, h); + Log.d(TAG, "sc " + sRS); if (sRS != null) { sRS.mMessageCallback = mMessageProc = new AAMessage(); } if (sRollo.mUniformAlloc != null) { - float tf[] = new float[] {72.f, 72.f, - 120.f, 120.f, 0.f, 0.f, + 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, - (2.f / 480.f), 0, -((float)w / 2) - 0.25f, -380.25f}; + 72.f, 72.f,}; if (w > h) { tf[6] = 40.f; tf[7] = h - 40.f; @@ -291,7 +281,7 @@ public class AllApps3D extends RSSurfaceView tf[11] = -((float)h / 2) - 0.25f; } - sRollo.mUniformAlloc.data(tf); + sRollo.mUniformAlloc.getAllocation().data(tf); } //long endTime = SystemClock.uptimeMillis(); @@ -307,18 +297,17 @@ public class AllApps3D extends RSSurfaceView if (mArrowNavigation) { if (!hasWindowFocus) { // Clear selection when we lose window focus - mLastSelectedIcon = sRollo.mState.selectedIconIndex; + mLastSelectedIcon = sRollo.mScript.get_gSelectedIconIndex(); sRollo.setHomeSelected(SELECTED_NONE); sRollo.clearSelectedIcon(); - sRollo.mState.save(); } else { - if (sRollo.mState.iconCount > 0) { + if (sRollo.mScript.get_gIconCount() > 0) { if (mLastSelection == SELECTION_ICONS) { int selection = mLastSelectedIcon; final int firstIcon = Math.round(sRollo.mScrollPos) * mColumnsPerPage; if (selection < 0 || // No selection selection < firstIcon || // off the top of the screen - selection >= sRollo.mState.iconCount || // past last icon + selection >= sRollo.mScript.get_gIconCount() || // past last icon selection >= firstIcon + // past last icon on screen (mColumnsPerPage * mRowsPerPage)) { selection = firstIcon; @@ -326,10 +315,8 @@ public class AllApps3D extends RSSurfaceView // Select the first icon when we gain window focus sRollo.selectIcon(selection, SELECTED_FOCUSED); - sRollo.mState.save(); } else if (mLastSelection == SELECTION_HOME) { sRollo.setHomeSelected(SELECTED_FOCUSED); - sRollo.mState.save(); } } } @@ -356,7 +343,6 @@ public class AllApps3D extends RSSurfaceView // Clear selection when we lose focus sRollo.clearSelectedIcon(); sRollo.setHomeSelected(SELECTED_NONE); - sRollo.mState.save(); mArrowNavigation = false; } } else { @@ -366,11 +352,10 @@ public class AllApps3D extends RSSurfaceView } private void gainFocus() { - if (!mArrowNavigation && sRollo.mState.iconCount > 0) { + if (!mArrowNavigation && sRollo.mScript.get_gIconCount() > 0) { // Select the first icon when we gain keyboard focus mArrowNavigation = true; sRollo.selectIcon(Math.round(sRollo.mScrollPos) * mColumnsPerPage, SELECTED_FOCUSED); - sRollo.mState.save(); } } @@ -382,7 +367,7 @@ public class AllApps3D extends RSSurfaceView if (!isVisible()) { return false; } - final int iconCount = sRollo.mState.iconCount; + final int iconCount = sRollo.mScript.get_gIconCount(); if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) { if (mArrowNavigation) { @@ -390,7 +375,7 @@ public class AllApps3D extends RSSurfaceView reallyPlaySoundEffect(SoundEffectConstants.CLICK); mLauncher.closeAllApps(true); } else { - int whichApp = sRollo.mState.selectedIconIndex; + int whichApp = sRollo.mScript.get_gSelectedIconIndex(); if (whichApp >= 0) { ApplicationInfo app = mAllAppsList.get(whichApp); mLauncher.startActivitySafely(app.intent, app); @@ -402,10 +387,10 @@ public class AllApps3D extends RSSurfaceView if (iconCount > 0) { final boolean isPortrait = getWidth() < getHeight(); - + mArrowNavigation = true; - int currentSelection = sRollo.mState.selectedIconIndex; + int currentSelection = sRollo.mScript.get_gSelectedIconIndex(); int currentTopRow = Math.round(sRollo.mScrollPos); // The column of the current selection, in the range 0..COLUMNS_PER_PAGE_PORTRAIT-1 @@ -511,7 +496,6 @@ public class AllApps3D extends RSSurfaceView } if (newSelection != currentSelection) { sRollo.selectIcon(newSelection, SELECTED_FOCUSED); - sRollo.mState.save(); } } return handled; @@ -611,7 +595,6 @@ public class AllApps3D extends RSSurfaceView (!isPortrait && x > mTouchXBorders[mTouchXBorders.length-1])) { mTouchTracking = TRACKING_HOME; sRollo.setHomeSelected(SELECTED_PRESSED); - sRollo.mState.save(); mCurrentIconIndex = -1; } else { mTouchTracking = TRACKING_FLING; @@ -619,8 +602,8 @@ public class AllApps3D extends RSSurfaceView mMotionDownRawX = (int)ev.getRawX(); mMotionDownRawY = (int)ev.getRawY(); - sRollo.mState.newPositionX = ev.getRawY() / getHeight(); - sRollo.mState.newTouchDown = 1; + sRollo.mScript.set_gNewPositionX(ev.getRawY() / getHeight()); + sRollo.mScript.set_gNewTouchDown(1); if (!sRollo.checkClickOK()) { sRollo.clearSelectedIcon(); @@ -632,7 +615,6 @@ public class AllApps3D extends RSSurfaceView cancelLongPress(); } } - sRollo.mState.save(); sRollo.move(); mVelocityTracker = VelocityTracker.obtain(); mVelocityTracker.addMovement(ev); @@ -646,7 +628,6 @@ public class AllApps3D extends RSSurfaceView y > mTouchYBorders[mTouchYBorders.length-1]) || (!isPortrait && x > mTouchXBorders[mTouchXBorders.length-1]) ? SELECTED_PRESSED : SELECTED_NONE); - sRollo.mState.save(); } else if (mTouchTracking == TRACKING_FLING) { int rawY = (int)ev.getRawY(); int slop; @@ -667,14 +648,13 @@ public class AllApps3D extends RSSurfaceView cancelLongPress(); mCurrentIconIndex = -1; } - sRollo.mState.newPositionX = ev.getRawY() / getHeight(); - sRollo.mState.newTouchDown = 1; + sRollo.mScript.set_gNewPositionX(ev.getRawY() / getHeight()); + sRollo.mScript.set_gNewTouchDown(1); sRollo.move(); mStartedScrolling = true; sRollo.clearSelectedIcon(); mVelocityTracker.addMovement(ev); - sRollo.mState.save(); } } break; @@ -688,17 +668,16 @@ public class AllApps3D extends RSSurfaceView mLauncher.closeAllApps(true); } sRollo.setHomeSelected(SELECTED_NONE); - sRollo.mState.save(); } mCurrentIconIndex = -1; } else if (mTouchTracking == TRACKING_FLING) { - sRollo.mState.newTouchDown = 0; - sRollo.mState.newPositionX = ev.getRawY() / getHeight(); + sRollo.mScript.set_gNewTouchDown(0); + sRollo.mScript.set_gNewPositionX(ev.getRawY() / getHeight()); mVelocityTracker.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity); - sRollo.mState.flingVelocity = mVelocityTracker.getYVelocity() / getHeight(); + sRollo.mScript.set_gFlingVelocity(mVelocityTracker.getYVelocity() / getHeight()); sRollo.clearSelectedIcon(); - sRollo.mState.save(); + sRollo.move(); sRollo.fling(); if (mVelocityTracker != null) { @@ -761,7 +740,7 @@ public class AllApps3D extends RSSurfaceView int pos = -1; switch (mLastSelection) { case SELECTION_ICONS: - index = sRollo.mState.selectedIconIndex; + index = sRollo.mScript.get_gSelectedIconIndex(); if (index >= 0) { ApplicationInfo info = mAllAppsList.get(index); if (info.title != null) { @@ -853,13 +832,12 @@ public class AllApps3D extends RSSurfaceView if (sRollo != null && reload) { sRollo.setApps(list); } - + if (hasFocus() && mRestoreFocusIndex != -1) { sRollo.selectIcon(mRestoreFocusIndex, SELECTED_FOCUSED); - sRollo.mState.save(); mRestoreFocusIndex = -1; } - + mLocks &= ~LOCK_ICONS_PENDING; } @@ -876,7 +854,7 @@ public class AllApps3D extends RSSurfaceView final int N = list.size(); if (sRollo != null) { sRollo.pause(); - sRollo.reallocAppsList(sRollo.mState.iconCount + N); + sRollo.reallocAppsList(sRollo.mScript.get_gIconCount() + N); } for (int i=0; i 0.001f) { - sRollo.mState.zoomTarget = zoom; + sRollo.mScript.set_gZoomTarget(zoom); } else { - sRollo.mState.zoomTarget = 0; + sRollo.mScript.set_gZoomTarget(0); } - sRollo.mState.save(); if (!animate) { - sRollo.mInvokeSetZoom.execute(); + sRollo.mScript.invokable_SetZoom(); } } @@ -1390,7 +1303,7 @@ public class AllApps3D extends RSSurfaceView int[] labelIds = new int[count]; mAllocLabelIds = Allocation.createSized(sRS, Element.USER_I32(sRS), count); - final int oldCount = sRollo.mState.iconCount; + final int oldCount = sRollo.mScript.get_gIconCount(); System.arraycopy(mIcons, 0, icons, 0, oldCount); System.arraycopy(mIconIds, 0, iconIds, 0, oldCount); @@ -1407,7 +1320,7 @@ public class AllApps3D extends RSSurfaceView * Handle the allocations for the new app. Make sure you call saveAppsList when done. */ private void addApp(int index, ApplicationInfo item) { - final int count = mState.iconCount - index; + final int count = mScript.get_gIconCount() - index; final int dest = index + 1; System.arraycopy(mIcons, index, mIcons, dest, count); @@ -1417,14 +1330,15 @@ public class AllApps3D extends RSSurfaceView createAppIconAllocations(index, item); uploadAppIcon(index, item); - sRollo.mState.iconCount++; + + mScript.set_gIconCount(mScript.get_gIconCount() + 1); } /** * Handle the allocations for the removed app. Make sure you call saveAppsList when done. */ private void removeApp(int index) { - final int count = mState.iconCount - index - 1; + final int count = mScript.get_gIconCount() - index - 1; final int src = index + 1; System.arraycopy(mIcons, src, mIcons, index, count); @@ -1432,8 +1346,8 @@ public class AllApps3D extends RSSurfaceView System.arraycopy(mLabels, src, mLabels, index, count); System.arraycopy(mLabelIds, src, mLabelIds, index, count); - sRollo.mState.iconCount--; - final int last = mState.iconCount; + mScript.set_gIconCount(mScript.get_gIconCount() - 1); + final int last = mScript.get_gIconCount(); mIcons[last] = null; mIconIds[last] = 0; @@ -1450,31 +1364,23 @@ public class AllApps3D extends RSSurfaceView mAllocIconIds.data(mIconIds); mAllocLabelIds.data(mLabelIds); - mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS); - mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS); - - mState.save(); - - // Note: mScript may be null if we haven't initialized it yet. - // In that case, this is a no-op. - if (mInvokeResetWAR != null) { - mInvokeResetWAR.execute(); - } + mScript.bind_gIconIDs(mAllocIconIds); + mScript.bind_gLabelIDs(mAllocLabelIds); + mScript.invokable_ResetWAR(); } } void fling() { - mInvokeFling.execute(); + mScript.invokable_Fling(); } void move() { - mInvokeMove.execute(); + mScript.invokable_Move(); } void moveTo(float row) { - mState.targetPos = row; - mState.save(); - mInvokeMoveTo.execute(); + mScript.set_gTargetPos(row); + mScript.invokable_MoveTo(); } /** @@ -1504,7 +1410,7 @@ public class AllApps3D extends RSSurfaceView if (mAllApps != null) { mAllApps.mRestoreFocusIndex = index; } - mState.selectedIconIndex = -1; + mScript.set_gSelectedIconIndex(-1); if (mAllApps.mLastSelection == SELECTION_ICONS) { mAllApps.mLastSelection = SELECTION_NONE; } @@ -1513,8 +1419,8 @@ public class AllApps3D extends RSSurfaceView mAllApps.mLastSelection = SELECTION_ICONS; } - int prev = mState.selectedIconIndex; - mState.selectedIconIndex = index; + int prev = mScript.get_gSelectedIconIndex(); + mScript.set_gSelectedIconIndex(index); ApplicationInfo info = appsList.get(index); Bitmap selectionBitmap = mSelectionBitmap; @@ -1526,7 +1432,7 @@ public class AllApps3D extends RSSurfaceView mSelectedIcon = Allocation.createFromBitmap(sRS, selectionBitmap, Element.RGBA_8888(sRS), false); mSelectedIcon.uploadToTexture(0); - mState.selectedIconTexture = mSelectedIcon.getID(); + mScript.set_gSelectedIconTexture(mSelectedIcon); if (prev != index) { if (info.title != null && info.title.length() > 0) { @@ -1541,24 +1447,24 @@ public class AllApps3D extends RSSurfaceView * You need to call save() on mState on your own after calling this. */ void clearSelectedIcon() { - mState.selectedIconIndex = -1; + mScript.set_gSelectedIconIndex(-1); } void setHomeSelected(int mode) { final int prev = mAllApps.mLastSelection; switch (mode) { case SELECTED_NONE: - mState.homeButtonId = mHomeButtonNormal.getID(); + mScript.set_gHomeButton(mHomeButtonNormal); break; case SELECTED_FOCUSED: mAllApps.mLastSelection = SELECTION_HOME; - mState.homeButtonId = mHomeButtonFocused.getID(); + mScript.set_gHomeButton(mHomeButtonFocused); if (prev != SELECTION_HOME) { mAllApps.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); } break; case SELECTED_PRESSED: - mState.homeButtonId = mHomeButtonPressed.getID(); + mScript.set_gHomeButton(mHomeButtonPressed); break; } } @@ -1578,23 +1484,15 @@ public class AllApps3D extends RSSurfaceView Log.d(TAG, "sRollo.mLabelIds.length=" + mLabelIds.length); } Log.d(TAG, "sRollo.mLabelIds=" + Arrays.toString(mLabelIds)); - Log.d(TAG, "sRollo.mState.newPositionX=" + mState.newPositionX); - Log.d(TAG, "sRollo.mState.newTouchDown=" + mState.newTouchDown); - Log.d(TAG, "sRollo.mState.flingVelocity=" + mState.flingVelocity); - Log.d(TAG, "sRollo.mState.iconCount=" + mState.iconCount); - Log.d(TAG, "sRollo.mState.selectedIconIndex=" + mState.selectedIconIndex); - Log.d(TAG, "sRollo.mState.selectedIconTexture=" + mState.selectedIconTexture); - Log.d(TAG, "sRollo.mState.zoomTarget=" + mState.zoomTarget); - Log.d(TAG, "sRollo.mState.homeButtonId=" + mState.homeButtonId); - Log.d(TAG, "sRollo.mState.targetPos=" + mState.targetPos); - Log.d(TAG, "sRollo.mParams.bubbleWidth=" + mParams.bubbleWidth); - Log.d(TAG, "sRollo.mParams.bubbleHeight=" + mParams.bubbleHeight); - Log.d(TAG, "sRollo.mParams.bubbleBitmapWidth=" + mParams.bubbleBitmapWidth); - Log.d(TAG, "sRollo.mParams.bubbleBitmapHeight=" + mParams.bubbleBitmapHeight); - Log.d(TAG, "sRollo.mParams.homeButtonWidth=" + mParams.homeButtonWidth); - Log.d(TAG, "sRollo.mParams.homeButtonHeight=" + mParams.homeButtonHeight); - Log.d(TAG, "sRollo.mParams.homeButtonTextureWidth=" + mParams.homeButtonTextureWidth); - Log.d(TAG, "sRollo.mParams.homeButtonTextureHeight=" + mParams.homeButtonTextureHeight); + //Log.d(TAG, "sRollo.mState.newPositionX=" + mState.newPositionX); + //Log.d(TAG, "sRollo.mState.newTouchDown=" + mState.newTouchDown); + //Log.d(TAG, "sRollo.mState.flingVelocity=" + mState.flingVelocity); + //Log.d(TAG, "sRollo.mState.iconCount=" + mState.iconCount); + //Log.d(TAG, "sRollo.mState.selectedIconIndex=" + mState.selectedIconIndex); + //Log.d(TAG, "sRollo.mState.selectedIconTexture=" + mState.selectedIconTexture); + //Log.d(TAG, "sRollo.mState.zoomTarget=" + mState.zoomTarget); + //Log.d(TAG, "sRollo.mState.homeButtonId=" + mState.homeButtonId); + //Log.d(TAG, "sRollo.mState.targetPos=" + mState.targetPos); } } diff --git a/src/com/android/launcher2/ScriptC_allapps.java b/src/com/android/launcher2/ScriptC_allapps.java new file mode 100644 index 0000000000..7e6152b5ce --- /dev/null +++ b/src/com/android/launcher2/ScriptC_allapps.java @@ -0,0 +1,197 @@ + +package com.android.launcher2; + +import android.content.res.Resources; +import android.renderscript.*; +import android.util.Log; + +public class ScriptC_allapps + extends android.renderscript.ScriptC +{ + public ScriptC_allapps(RenderScript rs, Resources resources, int id, boolean isRoot) { + super(rs, resources, id, isRoot); + } + + private int mField_COLUMNS_PER_PAGE_PORTRAIT; + public void set_COLUMNS_PER_PAGE_PORTRAIT(int v) { + mField_COLUMNS_PER_PAGE_PORTRAIT = v; + setVar(0, v); + } + + private int mField_ROWS_PER_PAGE_PORTRAIT; + public void set_ROWS_PER_PAGE_PORTRAIT(int v) { + mField_ROWS_PER_PAGE_PORTRAIT = v; + setVar(1, v); + } + + private int mField_COLUMNS_PER_PAGE_LANDSCAPE; + public void set_COLUMNS_PER_PAGE_LANDSCAPE(int v) { + mField_COLUMNS_PER_PAGE_LANDSCAPE = v; + setVar(2, v); + } + + private int mField_ROWS_PER_PAGE_LANDSCAPE; + public void set_ROWS_PER_PAGE_LANDSCAPE(int v) { + mField_ROWS_PER_PAGE_LANDSCAPE = v; + setVar(3, v); + } + + + private float mField_gNewPositionX; + public void set_gNewPositionX(float v) { + mField_gNewPositionX = v; + setVar(4, v); + } + + private int mField_gNewTouchDown; + public void set_gNewTouchDown(int v) { + mField_gNewTouchDown = v; + setVar(5, v); + } + + private float mField_gFlingVelocity; + public void set_gFlingVelocity(float v) { + mField_gFlingVelocity = v; + setVar(6, v); + } + + private int mField_gIconCount; + public void set_gIconCount(int v) { + mField_gIconCount = v; + setVar(7, v); + } + public int get_gIconCount() { + return mField_gIconCount; + } + + private int mField_gSelectedIconIndex; + public void set_gSelectedIconIndex(int v) { + mField_gSelectedIconIndex = v; + setVar(8, v); + } + public int get_gSelectedIconIndex() { + return mField_gSelectedIconIndex; + } + + private Allocation mField_gSelectedIconTexture; + public void set_gSelectedIconTexture(Allocation v) { + mField_gSelectedIconTexture = v; + setVar(9, v.getID()); + } + + private float mField_gZoomTarget; + public void set_gZoomTarget(float v) { + mField_gZoomTarget = v; + setVar(10, v); + } + + private Allocation mField_gHomeButton; + public void set_gHomeButton(Allocation v) { + mField_gHomeButton = v; + setVar(11, v.getID()); + } + + private float mField_gTargetPos; + public void set_gTargetPos(float v) { + mField_gTargetPos = v; + setVar(12, v); + } + + + private ProgramFragment mField_gPFTexNearest; + public void set_gPFTexNearest(ProgramFragment v) { + mField_gPFTexNearest = v; + setVar(13, v.getID()); + } + + private ProgramFragment mField_gPFTexMip; + public void set_gPFTexMip(ProgramFragment v) { + mField_gPFTexMip = v; + setVar(14, v.getID()); + } + + private ProgramFragment mField_gPFTexMipAlpha; + public void set_gPFTexMipAlpha(ProgramFragment v) { + mField_gPFTexMipAlpha = v; + setVar(15, v.getID()); + } + + private ProgramVertex mField_gPVCurve; + public void set_gPVCurve(ProgramVertex v) { + mField_gPVCurve = v; + setVar(16, v.getID()); + } + + private ProgramStore mField_gPS; + public void set_gPS(ProgramStore v) { + mField_gPS = v; + setVar(17, v.getID()); + } + + private SimpleMesh mField_gSMCell; + public void set_gSMCell(SimpleMesh v) { + mField_gSMCell = v; + setVar(18, v.getID()); + } + + + // binds + private Allocation mField_gIconIDs; + public void bind_gIconIDs(Allocation f) { + mField_gIconIDs = f; + bindAllocation(f, 19); + } + public Allocation get_gIconIDs() { + return mField_gIconIDs; + } + + private Allocation mField_gLabelIDs; + public void bind_gLabelIDs(Allocation f) { + mField_gLabelIDs = f; + bindAllocation(f, 20); + } + public Allocation get_gLabelIDs() { + return mField_gLabelIDs; + } + + private ScriptField_VpConsts mField_vpConstants; + public void bind_vpConstants(ScriptField_VpConsts f) { + android.util.Log.e("rs", "bind_vpConstants " + f); + mField_vpConstants = f; + if (f == null) { + bindAllocation(null, 21); + } else { + bindAllocation(f.getAllocation(), 21); + } + } + public ScriptField_VpConsts get_vpConstants() { + return mField_vpConstants; + } + + + +//#pragma rs export_func(resetHWWar, move, moveTo, setZoom, fling) + + public void invokable_Move() { + //android.util.Log.e("rs", "invokable_Move"); + invoke(7); // verified + } + public void invokable_MoveTo() { + //android.util.Log.e("rs", "invokable_MoveTo"); + invoke(8); // verified + } + public void invokable_Fling() { + //android.util.Log.e("rs", "invokable_Fling"); + invoke(2); + } + public void invokable_ResetWAR() { + //android.util.Log.e("rs", "invokable_WAR"); + invoke(9); // verified + } + public void invokable_SetZoom() { + //android.util.Log.e("rs", "invokable_SetZoom"); + invoke(12); + } +} + + diff --git a/src/com/android/launcher2/ScriptField_VpConsts.java b/src/com/android/launcher2/ScriptField_VpConsts.java new file mode 100644 index 0000000000..1df75f862f --- /dev/null +++ b/src/com/android/launcher2/ScriptField_VpConsts.java @@ -0,0 +1,73 @@ + +package com.android.launcher2; + +import android.content.res.Resources; +import android.renderscript.*; +import android.util.Log; + +public class ScriptField_VpConsts + extends android.renderscript.Script.FieldBase +{ + + static public class Item { + Item() { + Position = new Float4(); + ScaleOffset = new Float4(); + BendPos = new Float2(); + ImgSize = new Float2(); + } + + public static final int sizeof = (12*4); + + Float4 Position; + Float4 ScaleOffset; + Float2 BendPos; + Float2 ImgSize; + } + private Item mItemArray[]; + + + public ScriptField_VpConsts(RenderScript rs, int count) { + // Allocate a pack/unpack buffer + mIOBuffer = new FieldPacker(Item.sizeof * count); + mItemArray = new Item[count]; + + Element.Builder eb = new Element.Builder(rs); + eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 4), "Position"); + eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 4), "ScaleOffset"); + eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "BendPos"); + eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "ImgSize"); + mElement = eb.create(); + + init(rs, count); + } + + private void copyToArray(Item i, int index) { + mIOBuffer.reset(index * Item.sizeof); + mIOBuffer.addF32(i.Position); + mIOBuffer.addF32(i.ScaleOffset); + mIOBuffer.addF32(i.BendPos); + mIOBuffer.addF32(i.ImgSize); + } + + public void set(Item i, int index, boolean copyNow) { + mItemArray[index] = i; + if (copyNow) { + copyToArray(i, index); + mAllocation.subData1D(index * Item.sizeof, Item.sizeof, mIOBuffer.getData()); + } + } + + public void copyAll() { + for (int ct=0; ct < mItemArray.length; ct++) { + copyToArray(mItemArray[ct], ct); + } + mAllocation.data(mIOBuffer.getData()); + } + + + private FieldPacker mIOBuffer; + + +} +