diff options
author | Angus Kong <shkong@google.com> | 2013-04-26 11:17:58 -0700 |
---|---|---|
committer | Angus Kong <shkong@google.com> | 2013-04-26 15:02:36 -0700 |
commit | 8f4ca941f3b79fa1836037405191049a95cba40c (patch) | |
tree | 7928a83849adf63f01bd0f8fcd543b6fb71d0859 | |
parent | 729fdb6c279e458849f0ae62c2467cc516ed0e02 (diff) | |
download | android_packages_apps_Snap-8f4ca941f3b79fa1836037405191049a95cba40c.tar.gz android_packages_apps_Snap-8f4ca941f3b79fa1836037405191049a95cba40c.tar.bz2 android_packages_apps_Snap-8f4ca941f3b79fa1836037405191049a95cba40c.zip |
Delegate the texture copy to DrawClient.
bug:8109314
Change-Id: Ib70b9d4fa4edbf094bc0d4644b3994a5e8303013
-rw-r--r-- | src/com/android/camera/CameraScreenNail.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/com/android/camera/CameraScreenNail.java b/src/com/android/camera/CameraScreenNail.java index c5bee2e8e..afa46290d 100644 --- a/src/com/android/camera/CameraScreenNail.java +++ b/src/com/android/camera/CameraScreenNail.java @@ -89,6 +89,12 @@ public class CameraScreenNail extends SurfaceTextureScreenNail { public boolean requiresSurfaceTexture() { return true; } + + @Override + public RawTexture copyToTexture(GLCanvas c, RawTexture texture, int w, int h) { + // We shouldn't be here since requireSurfaceTexture() returns true. + return null; + } }; private DrawClient mDraw = mDefaultDraw; private float mAlpha = 1f; @@ -110,6 +116,8 @@ public class CameraScreenNail extends SurfaceTextureScreenNail { void onDraw(GLCanvas canvas, int x, int y, int width, int height); boolean requiresSurfaceTexture(); + // The client should implement this if requiresSurfaceTexture() is false; + RawTexture copyToTexture(GLCanvas c, RawTexture texture, int width, int height); } public CameraScreenNail(Listener listener, Resources res) { @@ -410,16 +418,13 @@ public class CameraScreenNail extends SurfaceTextureScreenNail { } private void copyPreviewTexture(GLCanvas canvas) { - if (!mDraw.requiresSurfaceTexture() && mAnimTexture == null) { - mAnimTexture = new RawTexture(getTextureWidth(), getTextureHeight(), true); - mAnimTexture.setIsFlippedVertically(true); - } - int width = mAnimTexture.getWidth(); - int height = mAnimTexture.getHeight(); - canvas.beginRenderTarget(mAnimTexture); if (!mDraw.requiresSurfaceTexture()) { - mDraw.onDraw(canvas, 0, 0, width, height); + mAnimTexture = mDraw.copyToTexture( + canvas, mAnimTexture, getTextureWidth(), getTextureHeight()); } else { + int width = mAnimTexture.getWidth(); + int height = mAnimTexture.getHeight(); + canvas.beginRenderTarget(mAnimTexture); // Flip preview texture vertically. OpenGL uses bottom left point // as the origin (0, 0). canvas.translate(0, height); @@ -427,8 +432,8 @@ public class CameraScreenNail extends SurfaceTextureScreenNail { getSurfaceTexture().getTransformMatrix(mTextureTransformMatrix); updateTransformMatrix(mTextureTransformMatrix); canvas.drawTexture(mExtTexture, mTextureTransformMatrix, 0, 0, width, height); + canvas.endRenderTarget(); } - canvas.endRenderTarget(); } @Override |