am 37e7c2b6: Remove the competitors to the one true AppApps3D.
Merge commit '37e7c2b6e4ee280b9cad39e53d9206ca7a46c510' into eclair-mr2 * commit '37e7c2b6e4ee280b9cad39e53d9206ca7a46c510': Remove the competitors to the one true AppApps3D.
This commit is contained in:
+3
-23
@@ -102,7 +102,7 @@ void move() {
|
||||
|
||||
void fling() {
|
||||
g_LastTouchDown = 0;
|
||||
g_PosVelocity = -state->flingVelocityX * 2;
|
||||
g_PosVelocity = -state->flingVelocity * 4;
|
||||
float av = fabsf(g_PosVelocity);
|
||||
float minVel = 3.5f;
|
||||
|
||||
@@ -329,7 +329,7 @@ void drawStrip(float row, float column, int isTop, int iconNum, float p)
|
||||
bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_ICON_IDS, iconNum));
|
||||
if (offset < -20) return;
|
||||
offset = clamp(offset, 0, 199 - 20);
|
||||
drawSimpleMeshRange(NAMED_SMMesh2, offset * 6, 20 * 6);
|
||||
drawSimpleMeshRange(NAMED_SMMesh, offset * 6, 20 * 6);
|
||||
}
|
||||
|
||||
void drawTop(float rowOffset)
|
||||
@@ -433,7 +433,7 @@ main(int launchID)
|
||||
|
||||
//bindProgramFragment(NAMED_PFColor);
|
||||
//positionStrip(1, 0, 0);
|
||||
//drawSimpleMesh(NAMED_SMMesh2);
|
||||
//drawSimpleMesh(NAMED_SMMesh);
|
||||
|
||||
bindProgramFragment(NAMED_PFTexLinear);
|
||||
|
||||
@@ -460,26 +460,6 @@ main(int launchID)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0) {
|
||||
float h = getHeight();
|
||||
|
||||
color(1, 1, 1, 1);
|
||||
bindProgramFragment(NAMED_PFColor);
|
||||
bindProgramVertex(NAMED_PVOrtho);
|
||||
float dy = 145.f;
|
||||
float y = h - ((h - (dy * 4.f)) / 2);
|
||||
|
||||
drawLine(0, y, 0, 480, y, 0);
|
||||
y -= dy;
|
||||
drawLine(0, y, 0, 480, y, 0);
|
||||
y -= dy;
|
||||
drawLine(0, y, 0, 480, y, 0);
|
||||
y -= dy;
|
||||
drawLine(0, y, 0, 480, y, 0);
|
||||
y -= dy;
|
||||
drawLine(0, y, 0, 480, y, 0);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -1,432 +0,0 @@
|
||||
#pragma version(1)
|
||||
#pragma stateVertex(PV)
|
||||
#pragma stateFragment(PFTexLinear)
|
||||
#pragma stateStore(PSIcons)
|
||||
|
||||
#define PI 3.14159f
|
||||
|
||||
|
||||
// Attraction to center values from page edge to page center.
|
||||
float g_AttractionTable[9];
|
||||
float g_FrictionTable[9];
|
||||
float g_PhysicsTableSize;
|
||||
|
||||
float g_PosPage;
|
||||
float g_PosVelocity;
|
||||
float g_LastPositionX;
|
||||
int g_LastTouchDown;
|
||||
float g_DT;
|
||||
int g_LastTime;
|
||||
int g_PageCount;
|
||||
float g_Zoom;
|
||||
|
||||
// Drawing constants, should be parameters ======
|
||||
#define VIEW_ANGLE 1.28700222f
|
||||
|
||||
float g_OldPosPage;
|
||||
float g_OldPosVelocity;
|
||||
float g_OldZoom;
|
||||
|
||||
int g_DrawLastFrame;
|
||||
int lastFrame(int draw) {
|
||||
// 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.
|
||||
int ret = g_DrawLastFrame | draw;
|
||||
g_DrawLastFrame = draw;
|
||||
return ret; // should return draw instead.
|
||||
}
|
||||
|
||||
void updateReadback() {
|
||||
if ((g_OldPosPage != g_PosPage) ||
|
||||
(g_OldPosVelocity != g_PosVelocity) ||
|
||||
(g_OldZoom != g_Zoom)) {
|
||||
|
||||
g_OldPosPage = g_PosPage;
|
||||
g_OldPosVelocity = g_PosVelocity;
|
||||
g_OldZoom = g_Zoom;
|
||||
|
||||
int i[3];
|
||||
i[0] = g_PosPage * (1 << 16);
|
||||
i[1] = g_PosVelocity * (1 << 16);
|
||||
i[2] = g_OldZoom * (1 << 16);
|
||||
sendToClient(&i[0], 1, 12, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void init() {
|
||||
g_AttractionTable[0] = 6.5f;
|
||||
g_AttractionTable[1] = 6.5f;
|
||||
g_AttractionTable[2] = 7.0f;
|
||||
g_AttractionTable[3] = 6.0f;
|
||||
g_AttractionTable[4] = -6.0f;
|
||||
g_AttractionTable[5] = -7.0f;
|
||||
g_AttractionTable[6] = -6.5f;
|
||||
g_AttractionTable[7] = -6.5f;
|
||||
g_AttractionTable[8] = -6.5f; // dup 7 to avoid a clamp later
|
||||
g_FrictionTable[0] = 3.5f;
|
||||
g_FrictionTable[1] = 3.6f;
|
||||
g_FrictionTable[2] = 4.0f;
|
||||
g_FrictionTable[3] = 5.0f;
|
||||
g_FrictionTable[4] = 5.0f;
|
||||
g_FrictionTable[5] = 4.0f;
|
||||
g_FrictionTable[6] = 3.6f;
|
||||
g_FrictionTable[7] = 3.5f;
|
||||
g_FrictionTable[8] = 3.5f; // dup 7 to avoid a clamp later
|
||||
g_PhysicsTableSize = 7;
|
||||
|
||||
g_PosVelocity = 0;
|
||||
g_PosPage = 0;
|
||||
g_LastTouchDown = 0;
|
||||
g_LastPositionX = 0;
|
||||
g_Zoom = 0;
|
||||
}
|
||||
|
||||
void resetHWWar() {
|
||||
}
|
||||
|
||||
void move() {
|
||||
if (g_LastTouchDown) {
|
||||
float dx = -(state->newPositionX - g_LastPositionX);
|
||||
g_PosVelocity = 0;
|
||||
g_PosPage += dx;
|
||||
|
||||
float pmin = -0.25f;
|
||||
float pmax = (g_PageCount - 1) + 0.25f;
|
||||
g_PosPage = clampf(g_PosPage, pmin, pmax);
|
||||
}
|
||||
g_LastTouchDown = state->newTouchDown;
|
||||
g_LastPositionX = state->newPositionX;
|
||||
//debugF("Move P", g_PosPage);
|
||||
}
|
||||
|
||||
void fling() {
|
||||
g_LastTouchDown = 0;
|
||||
g_PosVelocity = -state->flingVelocityX;
|
||||
float av = fabsf(g_PosVelocity);
|
||||
float minVel = 3.5f;
|
||||
|
||||
minVel *= 1.f - (fabsf(fracf(g_PosPage + 0.5f) - 0.5f) * 0.45f);
|
||||
|
||||
if (av < minVel && av > 0.2f) {
|
||||
if (g_PosVelocity > 0) {
|
||||
g_PosVelocity = minVel;
|
||||
} else {
|
||||
g_PosVelocity = -minVel;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_PosPage <= 0) {
|
||||
g_PosVelocity = maxf(0, g_PosVelocity);
|
||||
}
|
||||
if (g_PosPage > (g_PageCount - 1)) {
|
||||
g_PosVelocity = minf(0, g_PosVelocity);
|
||||
}
|
||||
//debugF("fling v", g_PosVelocity);
|
||||
}
|
||||
|
||||
void touchUp() {
|
||||
g_LastTouchDown = 0;
|
||||
}
|
||||
|
||||
int
|
||||
count_pages(int iconCount)
|
||||
{
|
||||
int iconsPerPage = COLUMNS_PER_PAGE * ROWS_PER_PAGE;
|
||||
int pages = iconCount / iconsPerPage;
|
||||
if (pages*iconsPerPage != iconCount) {
|
||||
pages++;
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
|
||||
float
|
||||
modf(float x, float y)
|
||||
{
|
||||
return x-(y*floorf(x/y));
|
||||
}
|
||||
|
||||
void updatePos() {
|
||||
if (g_LastTouchDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
float tablePosNorm = fracf(g_PosPage + 0.5f);
|
||||
float tablePosF = tablePosNorm * g_PhysicsTableSize;
|
||||
int tablePosI = tablePosF;
|
||||
float tablePosFrac = tablePosF - tablePosI;
|
||||
float accel = lerpf(g_AttractionTable[tablePosI],
|
||||
g_AttractionTable[tablePosI + 1],
|
||||
tablePosFrac) * g_DT;
|
||||
float friction = lerpf(g_FrictionTable[tablePosI],
|
||||
g_FrictionTable[tablePosI + 1],
|
||||
tablePosFrac) * g_DT;
|
||||
//debugF(" accel", accel);
|
||||
//debugF(" friction", friction);
|
||||
|
||||
// If our velocity is low OR acceleration is opposing it, apply it.
|
||||
if (fabsf(g_PosVelocity) < 1.0f || (g_PosVelocity * accel) < 0) {
|
||||
g_PosVelocity += accel;
|
||||
}
|
||||
|
||||
if ((friction > fabsf(g_PosVelocity)) && (friction > fabsf(accel))) {
|
||||
// Special get back to center and overcome friction physics.
|
||||
float t = tablePosNorm - 0.5f;
|
||||
if (fabsf(t) < (friction * g_DT)) {
|
||||
// really close, just snap
|
||||
g_PosPage = roundf(g_PosPage);
|
||||
g_PosVelocity = 0;
|
||||
} else {
|
||||
if (t > 0) {
|
||||
g_PosVelocity = -friction;
|
||||
} else {
|
||||
g_PosVelocity = friction;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Normal physics
|
||||
if (g_PosVelocity > 0) {
|
||||
g_PosVelocity -= friction;
|
||||
g_PosVelocity = maxf(g_PosVelocity, 0);
|
||||
} else {
|
||||
g_PosVelocity += friction;
|
||||
g_PosVelocity = minf(g_PosVelocity, 0);
|
||||
}
|
||||
}
|
||||
g_PosPage += g_PosVelocity * g_DT;
|
||||
|
||||
// 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);
|
||||
g_PosVelocity *= damp;
|
||||
}
|
||||
if (g_PosPage > (g_PageCount-1) && g_PosVelocity > 0) {
|
||||
float damp = 1.0 - ((g_PosPage - g_PageCount + 1) * 4);
|
||||
damp = clampf(damp, 0.f, 0.9f);
|
||||
g_PosVelocity *= damp;
|
||||
}
|
||||
}
|
||||
|
||||
float
|
||||
far_size(float sizeAt0)
|
||||
{
|
||||
return sizeAt0 * (RADIUS+2) / 2; // -2 is the camera z=(z-camZ)/z
|
||||
}
|
||||
|
||||
void
|
||||
draw_page(int icon, int lastIcon, float centerAngle, float scale)
|
||||
{
|
||||
int row;
|
||||
int col;
|
||||
|
||||
//debugF("center angle", centerAngle);
|
||||
|
||||
float iconTextureWidth = ICON_WIDTH_PX / (float)ICON_TEXTURE_WIDTH_PX;
|
||||
float iconTextureHeight = ICON_HEIGHT_PX / (float)ICON_TEXTURE_HEIGHT_PX;
|
||||
|
||||
float iconWidthAngle = VIEW_ANGLE * ICON_WIDTH_PX / SCREEN_WIDTH_PX;
|
||||
float columnGutterAngle = iconWidthAngle * 0.9f;
|
||||
|
||||
float farIconSize = FAR_ICON_SIZE;
|
||||
float iconGutterHeight = farIconSize * 1.3f;
|
||||
|
||||
float farIconTextureSize = far_size(2 * ICON_TEXTURE_WIDTH_PX / (float)SCREEN_WIDTH_PX);
|
||||
|
||||
float normalizedLabelWidth = 2 * params->bubbleWidth / (float)SCREEN_WIDTH_PX;
|
||||
float farLabelHeight = far_size(params->bubbleHeight * (normalizedLabelWidth / params->bubbleWidth));
|
||||
|
||||
for (row=0; row<ROWS_PER_PAGE && icon<=lastIcon; row++) {
|
||||
float angle = centerAngle;
|
||||
angle -= (columnGutterAngle + iconWidthAngle) * 1.5f;
|
||||
|
||||
float iconTop = (farIconSize + iconGutterHeight) * (1.85f + ICON_TOP_OFFSET)
|
||||
- row * (farIconSize + iconGutterHeight);
|
||||
float iconBottom = iconTop - farIconSize;
|
||||
|
||||
float labelY = iconBottom - farLabelHeight;
|
||||
float iconTextureTop = iconTop + (0.5f * (farIconTextureSize - farIconSize));
|
||||
float iconTextureBottom = iconTextureTop - farIconTextureSize;
|
||||
|
||||
for (col=0; col<COLUMNS_PER_PAGE && icon<=lastIcon; col++) {
|
||||
// icon
|
||||
float sine = sinf(angle);
|
||||
float cosine = cosf(angle);
|
||||
|
||||
float centerX = sine * RADIUS;
|
||||
float centerZ = cosine * RADIUS / scale;
|
||||
|
||||
if (scale > 1.f) {
|
||||
centerX *= scale;
|
||||
}
|
||||
|
||||
float iconLeftX = centerX - (cosine * farIconTextureSize * .5);
|
||||
float iconRightX = centerX + (cosine * farIconTextureSize * .5);
|
||||
float iconLeftZ = centerZ + (sine * farIconTextureSize * .5);
|
||||
float iconRightZ = centerZ - (sine * farIconTextureSize * .5);
|
||||
|
||||
color(1.0f, 1.0f, 1.0f, 0.99f);
|
||||
if (state->selectedIconIndex == icon) {
|
||||
bindTexture(NAMED_PFTexLinear, 0, state->selectedIconTexture);
|
||||
drawQuadTexCoords(
|
||||
iconLeftX, iconTextureTop, iconLeftZ, 0.0f, 0.0f,
|
||||
iconRightX, iconTextureTop, iconRightZ, 1.0f, 0.0f,
|
||||
iconRightX, iconTextureBottom, iconRightZ, 1.0f, 1.0f,
|
||||
iconLeftX, iconTextureBottom, iconLeftZ, 0.0f, 1.0f);
|
||||
} else {
|
||||
bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_ICON_IDS, icon));
|
||||
drawQuadTexCoords(
|
||||
iconLeftX, iconTextureTop, iconLeftZ, 0.0f, 0.0f,
|
||||
iconRightX, iconTextureTop, iconRightZ, 1.0f, 0.0f,
|
||||
iconRightX, iconTextureBottom, iconRightZ, 1.0f, 1.0f,
|
||||
iconLeftX, iconTextureBottom, iconLeftZ, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
// label
|
||||
if (scale < 1.2f) {
|
||||
float a = (1.2f - maxf(scale, 1.0f)) * 5;
|
||||
color(1.0f, 1.0f, 1.0f, a);
|
||||
bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_LABEL_IDS, icon));
|
||||
drawSprite(centerX, labelY, centerZ,
|
||||
params->bubbleBitmapWidth, params->bubbleBitmapHeight);
|
||||
}
|
||||
|
||||
angle += columnGutterAngle + iconWidthAngle;
|
||||
icon++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
draw_home_button()
|
||||
{
|
||||
color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
bindTexture(NAMED_PFTexLinear, 0, state->homeButtonId);
|
||||
|
||||
float scale = 2.0f / SCREEN_WIDTH_PX;
|
||||
|
||||
float x = 0.0f;
|
||||
|
||||
float y = -(SCREEN_HEIGHT_PX / (float)SCREEN_WIDTH_PX);
|
||||
y += g_Zoom * (scale * params->homeButtonTextureHeight / 2);
|
||||
|
||||
float z = 0.0f;
|
||||
drawSprite(x, y, z, params->homeButtonTextureWidth, params->homeButtonTextureHeight);
|
||||
}
|
||||
|
||||
int
|
||||
main(int launchID)
|
||||
{
|
||||
// Compute dt in seconds.
|
||||
int newTime = uptimeMillis();
|
||||
g_DT = (newTime - g_LastTime) / 1000.f;
|
||||
g_LastTime = newTime;
|
||||
|
||||
if (!g_DrawLastFrame) {
|
||||
// If we stopped rendering we cannot use DT.
|
||||
// assume 30fps in this case.
|
||||
g_DT = 0.033f;
|
||||
}
|
||||
if (g_DT > 0.2f) {
|
||||
// physics may break if DT is large.
|
||||
g_DT = 0.2f;
|
||||
}
|
||||
|
||||
//debugF("zoom", g_Zoom);
|
||||
if (g_Zoom != state->zoomTarget) {
|
||||
float dz = (state->zoomTarget - g_Zoom) * g_DT * 5;
|
||||
if (dz && (fabsf(dz) < 0.03f)) {
|
||||
if (dz > 0) {
|
||||
dz = 0.03f;
|
||||
} else {
|
||||
dz = -0.03f;
|
||||
}
|
||||
}
|
||||
if (fabsf(g_Zoom - state->zoomTarget) < fabsf(dz)) {
|
||||
g_Zoom = state->zoomTarget;
|
||||
} else {
|
||||
g_Zoom += dz;
|
||||
}
|
||||
updateReadback();
|
||||
}
|
||||
|
||||
// Set clear value to dim the background based on the zoom position.
|
||||
if ((g_Zoom < 0.001f) && (state->zoomTarget < 0.001f)) {
|
||||
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) {
|
||||
g_PosPage = 0;
|
||||
}
|
||||
return lastFrame(0);
|
||||
} else if (g_Zoom < 0.85f) {
|
||||
pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
|
||||
} else {
|
||||
pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
|
||||
}
|
||||
|
||||
// icons & labels
|
||||
int iconCount = state->iconCount;
|
||||
g_PageCount = count_pages(iconCount);
|
||||
|
||||
updatePos(0.1f);
|
||||
updateReadback();
|
||||
|
||||
//debugF(" draw g_PosPage", g_PosPage);
|
||||
|
||||
// Draw the icons ========================================
|
||||
|
||||
// Bug makes 1.0f alpha fail.
|
||||
color(1.0f, 1.0f, 1.0f, 0.99f);
|
||||
|
||||
if (iconCount <= 0) {
|
||||
return lastFrame(0);
|
||||
}
|
||||
int lastIcon = iconCount-1;
|
||||
|
||||
int page = g_PosPage;
|
||||
float currentPagePosition = g_PosPage - page;
|
||||
|
||||
int iconsPerPage = COLUMNS_PER_PAGE * ROWS_PER_PAGE;
|
||||
int icon = clamp(iconsPerPage * page, 0, lastIcon);
|
||||
|
||||
float scale = (1 / g_Zoom);
|
||||
|
||||
float pageAngle = VIEW_ANGLE * 1.2f;
|
||||
draw_page(icon, lastIcon, -pageAngle*currentPagePosition, scale);
|
||||
draw_page(icon+iconsPerPage, lastIcon, (-pageAngle*currentPagePosition)+pageAngle, scale);
|
||||
|
||||
// Draw the border lines for debugging ========================================
|
||||
/*
|
||||
bindProgramVertex(NAMED_PVOrtho);
|
||||
bindProgramFragment(NAMED_PFOrtho);
|
||||
bindProgramFragmentStore(NAMED_PFSText);
|
||||
|
||||
color(1.0f, 1.0f, 0.0f, 0.99f);
|
||||
int i;
|
||||
for (i=0; i<ROWS_PER_PAGE+1; i++) {
|
||||
int y = loadI32(ALLOC_Y_BORDERS, i);
|
||||
drawRect(0, y, SCREEN_WIDTH_PX, y+1, 0.0f);
|
||||
}
|
||||
for (i=0; i<COLUMNS_PER_PAGE+1; i++) {
|
||||
int x = loadI32(ALLOC_X_BORDERS, i);
|
||||
drawRect(x, 0, x+1, SCREEN_HEIGHT_PX, 0.0f);
|
||||
}
|
||||
*/
|
||||
|
||||
// Draw the home button ========================================
|
||||
draw_home_button();
|
||||
|
||||
/*
|
||||
bindTexture(NAMED_PFOrtho, 0, loadI32(ALLOC_PARAMS, PARAM_SCROLL_HANDLE_ID));
|
||||
float handleLeft = 40 + (320 * (scrollXPx/(float)(maxScrollXPx)));
|
||||
float handleTop = 680;
|
||||
float handleWidth = loadI32(ALLOC_PARAMS, PARAM_SCROLL_HANDLE_TEX_WIDTH);
|
||||
float handleHeight = loadI32(ALLOC_PARAMS, PARAM_SCROLL_HANDLE_TEX_HEIGHT);
|
||||
drawRect(handleLeft, handleTop, handleLeft+handleWidth, handleTop+handleHeight, 0.0f);
|
||||
*/
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
@@ -98,43 +98,28 @@ public class AllAppsView extends RSSurfaceView
|
||||
private int mCurrentIconIndex = -1;
|
||||
private int mHomeButtonTop;
|
||||
private long mTouchTime;
|
||||
private boolean mRotateMove = true;
|
||||
|
||||
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_X_BORDERS = 5;
|
||||
public static final int ALLOC_Y_BORDERS = 6;
|
||||
|
||||
public static final int COLUMNS_PER_PAGE = 4;
|
||||
public static final int ROWS_PER_PAGE = 4;
|
||||
|
||||
public static final float RADIUS = 4.0f;
|
||||
|
||||
public static final int ICON_WIDTH_PX = 64;
|
||||
public static final int ICON_TEXTURE_WIDTH_PX = 128;
|
||||
|
||||
public static final int ICON_HEIGHT_PX = 64;
|
||||
public static final int ICON_TEXTURE_HEIGHT_PX = 128;
|
||||
public static final float ICON_TOP_OFFSET = 0.2f;
|
||||
|
||||
public static final float CAMERA_Z = -2;
|
||||
|
||||
public int SCREEN_WIDTH_PX;
|
||||
public int SCREEN_HEIGHT_PX;
|
||||
|
||||
public float FAR_ICON_SIZE;
|
||||
|
||||
public void recompute(int w, int h) {
|
||||
SCREEN_WIDTH_PX = 480;
|
||||
SCREEN_HEIGHT_PX = 800;
|
||||
FAR_ICON_SIZE = farSize(2 * ICON_WIDTH_PX / (float)w);
|
||||
}
|
||||
|
||||
private static float farSize(float sizeAt0) {
|
||||
return sizeAt0 * (Defines.RADIUS - Defines.CAMERA_Z) / -Defines.CAMERA_Z;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,10 +204,6 @@ public class AllAppsView extends RSSurfaceView
|
||||
int action = ev.getAction();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
if (x < 60 && y > 700) {
|
||||
//mRotateMove = mRollo.setView((++mRSMode) & 3);
|
||||
}
|
||||
|
||||
if (y > mRollo.mTouchYBorders[mRollo.mTouchYBorders.length-1]) {
|
||||
mTouchTracking = TRACKING_HOME;
|
||||
mRollo.setHomeSelected(true);
|
||||
@@ -233,11 +214,7 @@ public class AllAppsView extends RSSurfaceView
|
||||
mMotionDownRawX = (int)ev.getRawX();
|
||||
mMotionDownRawY = (int)ev.getRawY();
|
||||
|
||||
if (mRotateMove) {
|
||||
mRollo.mState.newPositionX = ev.getRawY() / mDefines.SCREEN_WIDTH_PX;
|
||||
} else {
|
||||
mRollo.mState.newPositionX = ev.getRawX() / mDefines.SCREEN_WIDTH_PX;
|
||||
}
|
||||
mRollo.mState.newPositionX = ev.getRawY() / getWidth();
|
||||
mRollo.mState.newTouchDown = 1;
|
||||
|
||||
if (!mRollo.checkClickOK()) {
|
||||
@@ -266,11 +243,7 @@ public class AllAppsView extends RSSurfaceView
|
||||
int rawX = (int)ev.getRawX();
|
||||
int rawY = (int)ev.getRawY();
|
||||
int slop;
|
||||
if (mRotateMove) {
|
||||
slop = Math.abs(rawY - mMotionDownRawY);
|
||||
} else {
|
||||
slop = Math.abs(rawX - mMotionDownRawX);
|
||||
}
|
||||
slop = Math.abs(rawY - mMotionDownRawY);
|
||||
|
||||
if (!mStartedScrolling && slop < mSlop) {
|
||||
// don't update anything so when we do start scrolling
|
||||
@@ -287,11 +260,7 @@ public class AllAppsView extends RSSurfaceView
|
||||
cancelLongPress();
|
||||
mCurrentIconIndex = -1;
|
||||
}
|
||||
if (mRotateMove) {
|
||||
mRollo.mState.newPositionX = ev.getRawY() / mDefines.SCREEN_WIDTH_PX;
|
||||
} else {
|
||||
mRollo.mState.newPositionX = ev.getRawX() / mDefines.SCREEN_WIDTH_PX;
|
||||
}
|
||||
mRollo.mState.newPositionX = ev.getRawY() / getWidth();
|
||||
mRollo.mState.newTouchDown = 1;
|
||||
mRollo.move();
|
||||
|
||||
@@ -314,20 +283,10 @@ public class AllAppsView extends RSSurfaceView
|
||||
}
|
||||
} else if (mTouchTracking == TRACKING_FLING) {
|
||||
mRollo.mState.newTouchDown = 0;
|
||||
if (mRotateMove) {
|
||||
mRollo.mState.newPositionX = ev.getRawY() / mDefines.SCREEN_WIDTH_PX;
|
||||
} else {
|
||||
mRollo.mState.newPositionX = ev.getRawX() / mDefines.SCREEN_WIDTH_PX;
|
||||
}
|
||||
mRollo.mState.newPositionX = ev.getRawY() / getWidth();
|
||||
|
||||
mVelocity.computeCurrentVelocity(1000 /* px/sec */, mMaxFlingVelocity);
|
||||
if (mRotateMove) {
|
||||
mRollo.mState.flingVelocityX
|
||||
= mVelocity.getYVelocity() / mDefines.SCREEN_WIDTH_PX;
|
||||
} else {
|
||||
mRollo.mState.flingVelocityX
|
||||
= mVelocity.getXVelocity() / mDefines.SCREEN_WIDTH_PX;
|
||||
}
|
||||
mRollo.mState.flingVelocity = mVelocity.getYVelocity() / getHeight();
|
||||
mRollo.clearSelectedIcon();
|
||||
mRollo.mState.save();
|
||||
mRollo.fling();
|
||||
@@ -517,23 +476,19 @@ public class AllAppsView extends RSSurfaceView
|
||||
public class RolloRS {
|
||||
|
||||
// Allocations ======
|
||||
private int mViewMode = 0;
|
||||
|
||||
private int mWidth;
|
||||
private int mHeight;
|
||||
|
||||
private Resources mRes;
|
||||
private Script[] mScript = new Script[4];
|
||||
|
||||
private Script.Invokable[] mInvokeMove = new Script.Invokable[4];
|
||||
private Script.Invokable[] mInvokeFling = new Script.Invokable[4];
|
||||
private Script.Invokable[] mInvokeResetWAR = new Script.Invokable[4];
|
||||
private Script mScript;
|
||||
private Script.Invokable mInvokeMove;
|
||||
private Script.Invokable mInvokeFling;
|
||||
private Script.Invokable mInvokeResetWAR;
|
||||
|
||||
private ProgramStore mPSIcons;
|
||||
private ProgramStore mPSText;
|
||||
private ProgramFragment mPFColor;
|
||||
private ProgramFragment mPFTexLinear;
|
||||
private ProgramFragment mPFTexNearest;
|
||||
private ProgramVertex mPV;
|
||||
private ProgramVertex mPVOrtho;
|
||||
private SimpleMesh mMesh;
|
||||
@@ -552,9 +507,7 @@ public class AllAppsView extends RSSurfaceView
|
||||
private Allocation mSelectedIcon;
|
||||
|
||||
private int[] mTouchYBorders;
|
||||
private Allocation mAllocTouchYBorders;
|
||||
private int[] mTouchXBorders;
|
||||
private Allocation mAllocTouchXBorders;
|
||||
|
||||
private Bitmap mSelectionBitmap;
|
||||
private Canvas mSelectionCanvas;
|
||||
@@ -611,7 +564,7 @@ public class AllAppsView extends RSSurfaceView
|
||||
class State extends BaseAlloc {
|
||||
public float newPositionX;
|
||||
public int newTouchDown;
|
||||
public float flingVelocityX;
|
||||
public float flingVelocity;
|
||||
public int iconCount;
|
||||
public int selectedIconIndex = -1;
|
||||
public int selectedIconTexture;
|
||||
@@ -637,7 +590,6 @@ public class AllAppsView extends RSSurfaceView
|
||||
initProgramFragment();
|
||||
initProgramStore();
|
||||
initMesh();
|
||||
initMesh2();
|
||||
initGl();
|
||||
initData();
|
||||
initTouchState();
|
||||
@@ -648,60 +600,6 @@ public class AllAppsView extends RSSurfaceView
|
||||
SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(mRS, 3,
|
||||
SimpleMesh.TriangleMeshBuilder.TEXTURE_0 | SimpleMesh.TriangleMeshBuilder.COLOR);
|
||||
|
||||
for (int ct=0; ct < 450; ct++) {
|
||||
float x = 0;
|
||||
float z = 0;
|
||||
float l = 1.f;
|
||||
|
||||
if (ct < 190) {
|
||||
z = 0.1f + 0.05f * (190 - ct);
|
||||
x = -1;
|
||||
l = 0.125f + (0.125f / 190.f) * ct;
|
||||
} else if (ct >= 190 && ct < 200) {
|
||||
float a = (3.14f * 0.5f) * (0.1f * (ct - 200));
|
||||
float s = (float)Math.sin(a);
|
||||
float c = (float)Math.cos(a);
|
||||
x = -0.9f + s * 0.1f;
|
||||
z = 0.1f - c * 0.1f;
|
||||
l = 0.25f + 0.075f * (ct - 190);
|
||||
} else if (ct >= 200 && ct < 250) {
|
||||
z = 0.f;
|
||||
x = -0.9f + (1.8f * (ct - 200) / 50.f);
|
||||
} else if (ct >= 250 && ct < 260) {
|
||||
float a = (3.14f * 0.5f) * (0.1f * (ct - 250));
|
||||
float s = (float)Math.sin(a);
|
||||
float c = (float)Math.cos(a);
|
||||
x = 0.9f + s * 0.1f;
|
||||
z = 0.1f - c * 0.1f;
|
||||
l = 0.25f + 0.075f * (260 - ct);
|
||||
} else if (ct >= 260) {
|
||||
z = 0.1f + 0.05f * (ct - 260);
|
||||
x = 1;
|
||||
l = 0.125f + (0.125f / 190.f) * (450 - ct);
|
||||
}
|
||||
//Log.e("rs", "ct " + Integer.toString(ct) + " x = " + Float.toString(x) + ", z = " + Float.toString(z));
|
||||
//Log.e("rs", "ct " + Integer.toString(ct) + " l = " + Float.toString(l));
|
||||
float s = ct * 0.1f;
|
||||
tm.setColor(l, l, l, 0.99f);
|
||||
tm.setTexture(s, 1);
|
||||
tm.addVertex(x, -0.5f, z);
|
||||
tm.setTexture(s, 0);
|
||||
tm.addVertex(x, 0.5f, z);
|
||||
}
|
||||
for (int ct=0; ct < (450*2 - 2); ct+= 2) {
|
||||
tm.addTriangle(ct, ct+1, ct+2);
|
||||
tm.addTriangle(ct+1, ct+3, ct+2);
|
||||
}
|
||||
mMesh = tm.create();
|
||||
mMesh.setName("SMMesh");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void initMesh2() {
|
||||
SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(mRS, 3,
|
||||
SimpleMesh.TriangleMeshBuilder.TEXTURE_0 | SimpleMesh.TriangleMeshBuilder.COLOR);
|
||||
|
||||
float y = 0;
|
||||
float z = 0;
|
||||
for (int ct=0; ct < 200; ct++) {
|
||||
@@ -733,7 +631,7 @@ public class AllAppsView extends RSSurfaceView
|
||||
tm.addTriangle(ct+1, ct+3, ct+2);
|
||||
}
|
||||
mMesh2 = tm.create();
|
||||
mMesh2.setName("SMMesh2");
|
||||
mMesh2.setName("SMMesh");
|
||||
}
|
||||
|
||||
private void initProgramVertex() {
|
||||
@@ -746,12 +644,12 @@ public class AllAppsView extends RSSurfaceView
|
||||
mPV.setName("PV");
|
||||
mPV.bindAllocation(pva);
|
||||
|
||||
pva = new ProgramVertex.MatrixAllocation(mRS);
|
||||
pva.setupOrthoWindow(mWidth, mHeight);
|
||||
pvb.setTextureMatrixEnable(true);
|
||||
mPVOrtho = pvb.create();
|
||||
mPVOrtho.setName("PVOrtho");
|
||||
mPVOrtho.bindAllocation(pva);
|
||||
//pva = new ProgramVertex.MatrixAllocation(mRS);
|
||||
//pva.setupOrthoWindow(mWidth, mHeight);
|
||||
//pvb.setTextureMatrixEnable(true);
|
||||
//mPVOrtho = pvb.create();
|
||||
//mPVOrtho.setName("PVOrtho");
|
||||
//mPVOrtho.bindAllocation(pva);
|
||||
|
||||
mRS.contextBindProgramVertex(mPV);
|
||||
}
|
||||
@@ -769,18 +667,14 @@ public class AllAppsView extends RSSurfaceView
|
||||
Sampler nearest = sb.create();
|
||||
|
||||
ProgramFragment.Builder bf = new ProgramFragment.Builder(mRS, null, null);
|
||||
mPFColor = bf.create();
|
||||
mPFColor.setName("PFColor");
|
||||
//mPFColor = bf.create();
|
||||
//mPFColor.setName("PFColor");
|
||||
|
||||
bf.setTexEnable(true, 0);
|
||||
bf.setTexEnvMode(ProgramFragment.EnvMode.MODULATE, 0);
|
||||
mPFTexLinear = bf.create();
|
||||
mPFTexLinear.setName("PFTexLinear");
|
||||
mPFTexLinear.bindSampler(linear, 0);
|
||||
|
||||
mPFTexNearest = bf.create();
|
||||
mPFTexNearest.setName("PFTexNearest");
|
||||
mPFTexNearest.bindSampler(nearest, 0);
|
||||
}
|
||||
|
||||
private void initProgramStore() {
|
||||
@@ -800,14 +694,7 @@ public class AllAppsView extends RSSurfaceView
|
||||
|
||||
private void initGl() {
|
||||
mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1];
|
||||
mAllocTouchXBorders = Allocation.createSized(mRS, Element.USER_I32(mRS),
|
||||
mTouchXBorders.length);
|
||||
mAllocTouchXBorders.data(mTouchXBorders);
|
||||
|
||||
mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1];
|
||||
mAllocTouchYBorders = Allocation.createSized(mRS, Element.USER_I32(mRS),
|
||||
mTouchYBorders.length);
|
||||
mAllocTouchYBorders.data(mTouchYBorders);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
@@ -844,36 +731,29 @@ public class AllAppsView extends RSSurfaceView
|
||||
setApps(null);
|
||||
}
|
||||
|
||||
private void initScript(int idx, int id) {
|
||||
private void initScript(int id) {
|
||||
}
|
||||
|
||||
private void initRs() {
|
||||
ScriptC.Builder sb = new ScriptC.Builder(mRS);
|
||||
sb.setScript(mRes, id);
|
||||
sb.setScript(mRes, R.raw.rollo3);
|
||||
sb.setRoot(true);
|
||||
sb.addDefines(mDefines);
|
||||
sb.setType(mParams.mType, "params", Defines.ALLOC_PARAMS);
|
||||
sb.setType(mState.mType, "state", Defines.ALLOC_STATE);
|
||||
mInvokeMove[idx] = sb.addInvokable("move");
|
||||
mInvokeFling[idx] = sb.addInvokable("fling");
|
||||
mInvokeResetWAR[idx] = sb.addInvokable("resetHWWar");
|
||||
mScript[idx] = sb.create();
|
||||
mScript[idx].setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
mScript[idx].bindAllocation(mParams.mAlloc, Defines.ALLOC_PARAMS);
|
||||
mScript[idx].bindAllocation(mState.mAlloc, Defines.ALLOC_STATE);
|
||||
mScript[idx].bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
|
||||
mScript[idx].bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
|
||||
mScript[idx].bindAllocation(mAllocTouchXBorders, Defines.ALLOC_X_BORDERS);
|
||||
mScript[idx].bindAllocation(mAllocTouchYBorders, Defines.ALLOC_Y_BORDERS);
|
||||
}
|
||||
|
||||
private void initRs() {
|
||||
mViewMode = 0;
|
||||
initScript(0, R.raw.rollo3);
|
||||
initScript(1, R.raw.rollo2);
|
||||
initScript(2, R.raw.rollo);
|
||||
initScript(3, R.raw.rollo4);
|
||||
mInvokeMove = sb.addInvokable("move");
|
||||
mInvokeFling = sb.addInvokable("fling");
|
||||
mInvokeResetWAR = sb.addInvokable("resetHWWar");
|
||||
mScript = sb.create();
|
||||
mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
mScript.bindAllocation(mParams.mAlloc, Defines.ALLOC_PARAMS);
|
||||
mScript.bindAllocation(mState.mAlloc, Defines.ALLOC_STATE);
|
||||
mScript.bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
|
||||
mScript.bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
|
||||
|
||||
mMessageProc = new AAMessage();
|
||||
mRS.mMessageCallback = mMessageProc;
|
||||
mRS.contextBindRootScript(mScript[mViewMode]);
|
||||
mRS.contextBindRootScript(mScript);
|
||||
}
|
||||
|
||||
private void setApps(ArrayList<ApplicationInfo> list) {
|
||||
@@ -986,62 +866,48 @@ public class AllAppsView extends RSSurfaceView
|
||||
mAllocIconIds.data(mIconIds);
|
||||
mAllocLabelIds.data(mLabelIds);
|
||||
|
||||
if (mScript[0] != null) { // this happens when we init it
|
||||
for (int ct=0; ct < 4; ct++) {
|
||||
mScript[ct].bindAllocation(mAllocIconIds, Defines.ALLOC_ICON_IDS);
|
||||
mScript[ct].bindAllocation(mAllocLabelIds, Defines.ALLOC_LABEL_IDS);
|
||||
}
|
||||
if (mScript != null) { // this happens when we init it
|
||||
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[mViewMode] != null) {
|
||||
mInvokeResetWAR[mViewMode].execute();
|
||||
if (mInvokeResetWAR != null) {
|
||||
mInvokeResetWAR.execute();
|
||||
}
|
||||
mRS.contextBindRootScript(mScript[mViewMode]);
|
||||
mRS.contextBindRootScript(mScript);
|
||||
}
|
||||
|
||||
void initTouchState() {
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
int cellHeight = 145;//iconsSize / Defines.ROWS_PER_PAGE;
|
||||
int cellWidth = width / Defines.COLUMNS_PER_PAGE;
|
||||
|
||||
int iconsSize;
|
||||
if (width < height) {
|
||||
iconsSize = width;
|
||||
} else {
|
||||
iconsSize = height;
|
||||
}
|
||||
int cellHeight = iconsSize / Defines.ROWS_PER_PAGE;
|
||||
int cellWidth = iconsSize / Defines.COLUMNS_PER_PAGE;
|
||||
|
||||
int centerY = (height / 2) - (int)(cellHeight * 0.2f);
|
||||
mTouchYBorders[0] = centerY - (int)(2.8f * cellHeight);
|
||||
mTouchYBorders[1] = centerY - (int)(1.25f * cellHeight);
|
||||
int centerY = (height / 2);
|
||||
mTouchYBorders[0] = centerY - (cellHeight * 2);
|
||||
mTouchYBorders[1] = centerY - cellHeight;
|
||||
mTouchYBorders[2] = centerY;
|
||||
mTouchYBorders[3] = centerY + (int)(1.25f * cellHeight);;
|
||||
mTouchYBorders[4] = centerY + (int)(2.6f * cellHeight);
|
||||
|
||||
mAllocTouchYBorders.data(mTouchYBorders);
|
||||
mTouchYBorders[3] = centerY + cellHeight;
|
||||
mTouchYBorders[4] = centerY + (cellHeight * 2);
|
||||
|
||||
int centerX = (width / 2);
|
||||
mTouchXBorders[0] = centerX - (2 * cellWidth);
|
||||
mTouchXBorders[1] = centerX - (int)(0.85f * cellWidth);
|
||||
mTouchXBorders[0] = 0;
|
||||
mTouchXBorders[1] = centerX - (width / 4);
|
||||
mTouchXBorders[2] = centerX;
|
||||
mTouchXBorders[3] = centerX + (int)(0.85f * cellWidth);
|
||||
mTouchXBorders[4] = centerX + (2 * cellWidth);
|
||||
|
||||
mAllocTouchXBorders.data(mTouchXBorders);
|
||||
mTouchXBorders[3] = centerX + (width / 4);
|
||||
mTouchXBorders[4] = width;
|
||||
}
|
||||
|
||||
int chooseTappedIconHorz(int x, int y, float page) {
|
||||
int currentPage = (int)page;
|
||||
int chooseTappedIcon(int x, int y, float pos) {
|
||||
// Adjust for scroll position if not zero.
|
||||
y += (pos - ((int)pos)) * (mTouchYBorders[1] - mTouchYBorders[0]);
|
||||
|
||||
int col = -1;
|
||||
int row = -1;
|
||||
|
||||
for (int i=0; i<Defines.COLUMNS_PER_PAGE; i++) {
|
||||
if (x >= mTouchXBorders[i] && x < mTouchXBorders[i+1]) {
|
||||
col = i;
|
||||
@@ -1059,50 +925,16 @@ public class AllAppsView extends RSSurfaceView
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (currentPage * Defines.ROWS_PER_PAGE * Defines.COLUMNS_PER_PAGE)
|
||||
return (((int)pos) * Defines.COLUMNS_PER_PAGE)
|
||||
+ (row * Defines.ROWS_PER_PAGE) + col;
|
||||
}
|
||||
|
||||
int chooseTappedIconVert(int x, int y, float pos) {
|
||||
int ydead = (getHeight() - 4 * 145) / 2;
|
||||
if (y < ydead || y > (getHeight() - ydead)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
y -= ydead;
|
||||
y += pos * 145;
|
||||
int row = y / 145;
|
||||
int col = x / 120;
|
||||
|
||||
return row * 4 + col;
|
||||
}
|
||||
|
||||
int chooseTappedIcon(int x, int y, float pos) {
|
||||
int index;
|
||||
if (mViewMode != 0) {
|
||||
index = chooseTappedIconHorz(x, y, pos);
|
||||
} else {
|
||||
index = chooseTappedIconVert(x, y, pos);
|
||||
}
|
||||
final int iconCount = mAllAppsList.size();
|
||||
if (index >= iconCount) {
|
||||
index = -1;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
boolean setView(int v) {
|
||||
mViewMode = v;
|
||||
mRS.contextBindRootScript(mScript[mViewMode]);
|
||||
return (v == 0);
|
||||
}
|
||||
|
||||
void fling() {
|
||||
mInvokeFling[mViewMode].execute();
|
||||
mInvokeFling.execute();
|
||||
}
|
||||
|
||||
void move() {
|
||||
mInvokeMove[mViewMode].execute();
|
||||
mInvokeMove.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user