From: Jason Sams Date: Thu, 15 Oct 2009 22:40:54 +0000 (-0700) Subject: Implement workaround for GL driver which is slow to render the first frame with new... X-Git-Tag: android-x86-6.0-r1~2865^2~146 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=41b61c824c60996fe31d1331aadeea3a3a485ef6;p=android-x86%2Fpackages-apps-Launcher3.git Implement workaround for GL driver which is slow to render the first frame with new state. This change will render a transparent frame when receiving new state to warm the driver. --- diff --git a/res/raw/rollo.c b/res/raw/rollo.c index 87fdd2207..2dd17aa42 100644 --- a/res/raw/rollo.c +++ b/res/raw/rollo.c @@ -82,6 +82,9 @@ void init() { g_Zoom = 0; } +void resetHWWar() { +} + void move() { if (g_LastTouchDown) { float dx = -(state->newPositionX - g_LastPositionX); diff --git a/res/raw/rollo2.c b/res/raw/rollo2.c index cc273b1ab..ad7b18f9d 100644 --- a/res/raw/rollo2.c +++ b/res/raw/rollo2.c @@ -81,6 +81,9 @@ void init() { g_Zoom = 0; } +void resetHWWar() { +} + void move() { if (g_LastTouchDown) { float dx = -(state->newPositionX - g_LastPositionX); diff --git a/res/raw/rollo3.c b/res/raw/rollo3.c index 5eec22a91..2aefa291a 100644 --- a/res/raw/rollo3.c +++ b/res/raw/rollo3.c @@ -5,6 +5,7 @@ #define PI 3.14159f +int g_SpecialHWWar; // Attraction to center values from page edge to page center. float g_AttractionTable[9]; @@ -52,6 +53,13 @@ void updateReadback() { } } +void setColor(float r, float g, float b, float a) { + if (g_SpecialHWWar) { + color(0, 0, 0, 0.001f); + } else { + color(r, g, b, a); + } +} void init() { g_AttractionTable[0] = 6.5f; @@ -70,6 +78,11 @@ void init() { g_LastTouchDown = 0; g_LastPositionX = 0; g_Zoom = 0; + g_SpecialHWWar = 1; +} + +void resetHWWar() { + g_SpecialHWWar = 1; } void move() { @@ -219,7 +232,7 @@ int positionStrip(float row, float column, int isTop) void draw_home_button() { - color(1.0f, 1.0f, 1.0f, 1.0f); + setColor(1.0f, 1.0f, 1.0f, 1.0f); bindTexture(NAMED_PFTexLinear, 0, params->homeButtonId); float scale = 2.0f / SCREEN_WIDTH_PX; @@ -263,7 +276,7 @@ void drawFrontGrid(float rowOffset) float x = colWidth * col - ((128 - colWidth) / 2); if ((y >= ymin) && (y <= ymax)) { - color(1.f, 1.f, 1.f, 1.f); + setColor(1.f, 1.f, 1.f, 1.f); bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_ICON_IDS, iconNum)); drawSpriteScreenspace(x, y, 0, 128, 128); } @@ -278,7 +291,7 @@ void drawFrontGrid(float rowOffset) } a = clampf(a, 0, 1); - color(1, 1, 1, a); + setColor(1, 1, 1, a); bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_LABEL_IDS, iconNum)); drawSpriteScreenspace(x, y - 44, 0, params->bubbleBitmapWidth, params->bubbleBitmapHeight); @@ -369,15 +382,13 @@ main(int launchID) } // Set clear value to dim the background based on the zoom position. - if ((g_Zoom < 0.001f) && (state->zoomTarget < 0.001f)) { + if ((g_Zoom < 0.001f) && (state->zoomTarget < 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) { 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); } @@ -414,6 +425,16 @@ main(int launchID) } draw_home_button(); + + // This is a WAR to do a rendering pass without drawing during init to + // force the driver to preload and compile its shaders. + // Without this the first animation does not appear due to the time it + // takes to init the driver state. + if (g_SpecialHWWar) { + g_SpecialHWWar = 0; + return 1; + } + if (0) { float h = getHeight(); @@ -434,10 +455,6 @@ main(int launchID) drawLine(0, y, 0, 480, y, 0); } - - // Draw the home button ======================================== - //draw_home_button(); - // 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); diff --git a/res/raw/rollo4.c b/res/raw/rollo4.c index ac158de4e..b0ea5b016 100644 --- a/res/raw/rollo4.c +++ b/res/raw/rollo4.c @@ -82,6 +82,9 @@ void init() { g_Zoom = 0; } +void resetHWWar() { +} + void move() { if (g_LastTouchDown) { float dx = -(state->newPositionX - g_LastPositionX); diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java index 27afaf4fa..fdbc84159 100644 --- a/src/com/android/launcher2/AllAppsView.java +++ b/src/com/android/launcher2/AllAppsView.java @@ -507,6 +507,7 @@ public class AllAppsView extends RSSurfaceView 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 ProgramStore mPSIcons; private ProgramStore mPSText; @@ -827,6 +828,7 @@ public class AllAppsView extends RSSurfaceView 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); @@ -970,6 +972,10 @@ public class AllAppsView extends RSSurfaceView // 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(); + } mRS.contextBindRootScript(mScript[mViewMode]); }