am 41b61c82: 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.

Merge commit '41b61c824c60996fe31d1331aadeea3a3a485ef6' into eclair-mr2

* commit '41b61c824c60996fe31d1331aadeea3a3a485ef6':
  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.
This commit is contained in:
Jason Sams 2009-10-15 15:51:51 -07:00 committed by Android Git Automerger
commit 21386b0e12
5 changed files with 42 additions and 10 deletions

View File

@ -82,6 +82,9 @@ void init() {
g_Zoom = 0;
}
void resetHWWar() {
}
void move() {
if (g_LastTouchDown) {
float dx = -(state->newPositionX - g_LastPositionX);

View File

@ -81,6 +81,9 @@ void init() {
g_Zoom = 0;
}
void resetHWWar() {
}
void move() {
if (g_LastTouchDown) {
float dx = -(state->newPositionX - g_LastPositionX);

View File

@ -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);

View File

@ -82,6 +82,9 @@ void init() {
g_Zoom = 0;
}
void resetHWWar() {
}
void move() {
if (g_LastTouchDown) {
float dx = -(state->newPositionX - g_LastPositionX);

View File

@ -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]);
}