X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;ds=sidebyside;f=src%2Fcom%2Fcooliris%2Fmedia%2FCanvasTexture.java;h=a881eef0367ff32ec27d1a2d2a02f0198f018ceb;hb=db87908d640e17ef0946824be158d86c6e2d6836;hp=27baaa4b951ce5c0adf3e101381153e66bb0e65a;hpb=1451a83c8d4e494117e69540c13de0b97a9dc0ef;p=android-x86%2Fpackages-apps-Gallery2.git diff --git a/src/com/cooliris/media/CanvasTexture.java b/src/com/cooliris/media/CanvasTexture.java index 27baaa4b9..a881eef03 100644 --- a/src/com/cooliris/media/CanvasTexture.java +++ b/src/com/cooliris/media/CanvasTexture.java @@ -21,6 +21,7 @@ public abstract class CanvasTexture { private Bitmap mBitmap = null; private boolean mNeedsDraw = false; private boolean mNeedsResize = false; + private GL11 mCachedGL = null; public CanvasTexture(Bitmap.Config bitmapConfig) { mBitmapConfig = bitmapConfig; @@ -63,6 +64,10 @@ public abstract class CanvasTexture { // This code seems largely a dup of CanvasLayer. public boolean bind(GL11 gl) { + if (mCachedGL != gl) { + mCachedGL = gl; + resetTexture(); + } int width = (int) mWidth; int height = (int) mHeight; int textureId = mTextureId; @@ -110,9 +115,11 @@ public abstract class CanvasTexture { // Recycle the existing bitmap and create a new one. if (bitmap != null) bitmap.recycle(); - bitmap = Bitmap.createBitmap(textureWidth, textureHeight, mBitmapConfig); - canvas.setBitmap(bitmap); - mBitmap = bitmap; + if (textureWidth > 0 && textureHeight > 0) { + bitmap = Bitmap.createBitmap(textureWidth, textureHeight, mBitmapConfig); + canvas.setBitmap(bitmap); + mBitmap = bitmap; + } } } @@ -147,7 +154,7 @@ public abstract class CanvasTexture { float height = mHeight; // Apply scale transform if not identity. - if (scale != 1) { // CR: 1.0f + if (scale != 1) { // CR: 1.0f float originX = x + anchorX * width; float originY = y + anchorY * height; width *= scale; @@ -157,7 +164,7 @@ public abstract class CanvasTexture { } // Set alpha if needed. - if (alpha != 1f) { // CR: 1.0f + if (alpha != 1f) { // CR: 1.0f view.setAlpha(alpha); } view.draw2D(x, y, 0, width, height);