diff options
author | Yuli Huang <yuli@google.com> | 2011-10-20 18:29:05 +0800 |
---|---|---|
committer | Yuli Huang <yuli@google.com> | 2011-10-20 22:13:07 +0800 |
commit | 960647247705f2c3e375061d234424b71c286e4d (patch) | |
tree | 04e72e17d3020501488249aede683aef68b6bb44 /src/com/android/gallery3d/photoeditor/PhotoView.java | |
parent | c1965fc2a109cf9d267b161800356c0dc4326cf0 (diff) | |
download | android_packages_apps_Snap-960647247705f2c3e375061d234424b71c286e4d.tar.gz android_packages_apps_Snap-960647247705f2c3e375061d234424b71c286e4d.tar.bz2 android_packages_apps_Snap-960647247705f2c3e375061d234424b71c286e4d.zip |
Fix b/5401109.
1. Add FlipView similar to existing RotateView.
2. Add flipPhoto() similar to existing rotatePhoto() in PhotoView, and
add setRenderToFlip() in RendererUtils.
3. Make FlipAction use FlipView/PhotoView similar to how RotateAction
uses RotateView/PhotoView.
Change-Id: I5642266adbc248c0b8eda48ddc29558ae9cbd21e
Diffstat (limited to 'src/com/android/gallery3d/photoeditor/PhotoView.java')
-rw-r--r-- | src/com/android/gallery3d/photoeditor/PhotoView.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/photoeditor/PhotoView.java b/src/com/android/gallery3d/photoeditor/PhotoView.java index edb36242e..0d4caa862 100644 --- a/src/com/android/gallery3d/photoeditor/PhotoView.java +++ b/src/com/android/gallery3d/photoeditor/PhotoView.java @@ -88,6 +88,13 @@ public class PhotoView extends GLSurfaceView { } /** + * Flips displayed photo; this method must be queued for GL thread. + */ + public void flipPhoto(float horizontalDegrees, float verticalDegrees) { + renderer.flipPhoto(horizontalDegrees, verticalDegrees); + } + + /** * Renderer that renders the GL surface-view and only be called from the GL thread. */ private class PhotoRenderer implements GLSurfaceView.Renderer { @@ -99,6 +106,8 @@ public class PhotoView extends GLSurfaceView { int viewWidth; int viewHeight; float rotatedDegrees; + float flippedHorizontalDegrees; + float flippedVerticalDegrees; void setPhoto(Photo photo, boolean clearTransform) { int width = (photo != null) ? photo.width() : 0; @@ -115,18 +124,23 @@ public class PhotoView extends GLSurfaceView { } void updateSurface(boolean clearTransform, boolean sizeChanged) { - boolean transformed = (rotatedDegrees != 0); + boolean flipped = (flippedHorizontalDegrees != 0) || (flippedVerticalDegrees != 0); + boolean transformed = (rotatedDegrees != 0) || flipped; if ((clearTransform && transformed) || (sizeChanged && !transformed)) { // Fit photo when clearing existing transforms or changing surface/photo sizes. if (photo != null) { RendererUtils.setRenderToFit(renderContext, photo.width(), photo.height(), viewWidth, viewHeight); rotatedDegrees = 0; + flippedHorizontalDegrees = 0; + flippedVerticalDegrees = 0; } } else { // Restore existing transformations for orientation changes or awaking from sleep. if (rotatedDegrees != 0) { rotatePhoto(rotatedDegrees); + } else if (flipped) { + flipPhoto(flippedHorizontalDegrees, flippedVerticalDegrees); } } } @@ -139,6 +153,15 @@ public class PhotoView extends GLSurfaceView { } } + void flipPhoto(float horizontalDegrees, float verticalDegrees) { + if (photo != null) { + RendererUtils.setRenderToFlip(renderContext, photo.width(), photo.height(), + viewWidth, viewHeight, horizontalDegrees, verticalDegrees); + flippedHorizontalDegrees = horizontalDegrees; + flippedVerticalDegrees = verticalDegrees; + } + } + @Override public void onDrawFrame(GL10 gl) { Runnable r = null; |