diff options
author | Angus Kong <shkong@google.com> | 2013-04-26 23:30:49 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-04-26 23:30:49 +0000 |
commit | beefbf5ad2ef69683f4c2f6c3d354b20c457a11c (patch) | |
tree | a1f61133395db256c4a1770f0409150aecba7070 /src/com/android/camera/CameraScreenNail.java | |
parent | ba9862f353476fcb7ab77d5b7e601adca8a6d136 (diff) | |
parent | 8f4ca941f3b79fa1836037405191049a95cba40c (diff) | |
download | android_packages_apps_Snap-beefbf5ad2ef69683f4c2f6c3d354b20c457a11c.tar.gz android_packages_apps_Snap-beefbf5ad2ef69683f4c2f6c3d354b20c457a11c.tar.bz2 android_packages_apps_Snap-beefbf5ad2ef69683f4c2f6c3d354b20c457a11c.zip |
Merge "Delegate the texture copy to DrawClient." into gb-ub-photos-bryce
Diffstat (limited to 'src/com/android/camera/CameraScreenNail.java')
-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 |