diff options
| author | Owen Lin <owenlin@google.com> | 2012-04-04 12:22:59 +0800 |
|---|---|---|
| committer | Owen Lin <owenlin@google.com> | 2012-04-05 17:54:28 +0800 |
| commit | fc7efade75629450c0c160329fb42b3dbd5361f4 (patch) | |
| tree | 5bfb3932d62571726bee26f88e080469e81ab5d9 /src | |
| parent | 31cac30e46a293f6d0901e22c6ab0d083cae7021 (diff) | |
| download | android_packages_apps_Gallery2-fc7efade75629450c0c160329fb42b3dbd5361f4.tar.gz android_packages_apps_Gallery2-fc7efade75629450c0c160329fb42b3dbd5361f4.tar.bz2 android_packages_apps_Gallery2-fc7efade75629450c0c160329fb42b3dbd5361f4.zip | |
Fix flashing in "Make available offline".
Change-Id: I84f0896c6038eb21d32e0d5fe0cafec5d339e6ec
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/android/gallery3d/ui/FadeInTexture.java | 1 | ||||
| -rw-r--r-- | src/com/android/gallery3d/ui/GLCanvasImpl.java | 30 |
2 files changed, 14 insertions, 17 deletions
diff --git a/src/com/android/gallery3d/ui/FadeInTexture.java b/src/com/android/gallery3d/ui/FadeInTexture.java index c88fb47a2..17ab7157f 100644 --- a/src/com/android/gallery3d/ui/FadeInTexture.java +++ b/src/com/android/gallery3d/ui/FadeInTexture.java @@ -21,6 +21,7 @@ import com.android.gallery3d.common.Utils; // FadeInTexture is a texture which begins with a color, then gradually animates // into a given texture. public class FadeInTexture implements Texture { + @SuppressWarnings("unused") private static final String TAG = "FadeInTexture"; // The duration of the animation in milliseconds diff --git a/src/com/android/gallery3d/ui/GLCanvasImpl.java b/src/com/android/gallery3d/ui/GLCanvasImpl.java index 6411a3165..f822951c7 100644 --- a/src/com/android/gallery3d/ui/GLCanvasImpl.java +++ b/src/com/android/gallery3d/ui/GLCanvasImpl.java @@ -441,8 +441,8 @@ public class GLCanvasImpl implements GLCanvas { private void drawMixed(BasicTexture from, int toColor, float ratio, int x, int y, int width, int height, float alpha) { - - if (ratio <= 0) { + // change from 0 to 0.01f to prevent getting divided by zero below + if (ratio <= 0.01f) { drawTexture(from, x, y, width, height, alpha); return; } else if (ratio >= 1) { @@ -459,30 +459,26 @@ public class GLCanvasImpl implements GLCanvas { // // The formula we want: // alpha * ((1 - ratio) * from + ratio * to) + // // The formula that GL supports is in the form of: - // combo * (modulate * from) + (1 - combo) * to + // combo * from + (1 - combo) * to * scale // - // So, we have combo = 1 - alpha * ratio - // and modulate = alpha * (1f - ratio) / combo + // So, we have combo = alpha * (1 - ratio) + // and scale = alpha * ratio / (1 - combo) // - float comboRatio = 1 - alpha * ratio; - - // handle the case that (1 - comboRatio) == 0 - if (alpha < OPAQUE_ALPHA) { - mGLState.setTextureAlpha(alpha * (1f - ratio) / comboRatio); - } else { - mGLState.setTextureAlpha(1f); - } + float combo = alpha * (1 - ratio); + float scale = alpha * ratio / (1 - combo); // Interpolate the RGB and alpha values between both textures. mGLState.setTexEnvMode(GL11.GL_COMBINE); + // Specify the interpolation factor via the alpha component of // GL_TEXTURE_ENV_COLORs. // RGB component are get from toColor and will used as SRC1 - float colorAlpha = (float) (toColor >>> 24) / (0xff * 0xff); - setTextureColor(((toColor >>> 16) & 0xff) * colorAlpha, - ((toColor >>> 8) & 0xff) * colorAlpha, - (toColor & 0xff) * colorAlpha, comboRatio); + float colorScale = scale * (toColor >>> 24) / (0xff * 0xff); + setTextureColor(((toColor >>> 16) & 0xff) * colorScale, + ((toColor >>> 8) & 0xff) * colorScale, + (toColor & 0xff) * colorScale, combo); gl.glTexEnvfv(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, mTextureColor, 0); gl.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_COMBINE_RGB, GL11.GL_INTERPOLATE); |
