OSDN Git Service

Support Panorama preview.
authorAngus Kong <shkong@google.com>
Thu, 17 May 2012 02:15:56 +0000 (19:15 -0700)
committerChih-Chung Chang <chihchung@google.com>
Thu, 17 May 2012 18:19:43 +0000 (11:19 -0700)
The panorama preview doesn't consider display rotation.

bug:6305152
Change-Id: I6b87c18ed8eadf1b2bf5e64437c5b290d111cbba

src/com/android/gallery3d/app/AppBridge.java
src/com/android/gallery3d/app/PhotoDataAdapter.java
src/com/android/gallery3d/app/PhotoPage.java
src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
src/com/android/gallery3d/ui/PhotoView.java

index 90cbd0b..5d6b1ec 100644 (file)
@@ -34,6 +34,7 @@ public abstract class AppBridge implements Parcelable {
     //  These are requests sent from PhotoPage to the app
     //////////////////////////////////////////////////////////////////////////
 
+    public abstract boolean isPanorama();
     public abstract ScreenNail attachScreenNail();
     public abstract void detachScreenNail();
 
index d88b72c..c92f7ed 100644 (file)
@@ -147,6 +147,7 @@ public class PhotoDataAdapter implements PhotoPage.Model {
     private int mSize = 0;
     private Path mItemPath;
     private int mCameraIndex;
+    private boolean mIsPanorama;
     private boolean mIsActive;
     private boolean mNeedFullImage;
 
@@ -164,12 +165,14 @@ public class PhotoDataAdapter implements PhotoPage.Model {
     // find the image being viewed. cameraIndex is the index of the camera
     // preview. If cameraIndex < 0, there is no camera preview.
     public PhotoDataAdapter(GalleryActivity activity, PhotoView view,
-            MediaSet mediaSet, Path itemPath, int indexHint, int cameraIndex) {
+            MediaSet mediaSet, Path itemPath, int indexHint, int cameraIndex,
+            boolean isPanorama) {
         mSource = Utils.checkNotNull(mediaSet);
         mPhotoView = Utils.checkNotNull(view);
         mItemPath = Utils.checkNotNull(itemPath);
         mCurrentIndex = indexHint;
         mCameraIndex = cameraIndex;
+        mIsPanorama = isPanorama;
         mThreadPool = activity.getThreadPool();
         mNeedFullImage = true;
 
@@ -429,6 +432,11 @@ public class PhotoDataAdapter implements PhotoPage.Model {
     }
 
     @Override
+    public boolean isPanorama(int offset) {
+        return isCamera(offset) && mIsPanorama;
+    }
+
+    @Override
     public boolean isVideo(int offset) {
         MediaItem item = getItem(mCurrentIndex + offset);
         return (item == null)
index 493e4aa..595e35b 100644 (file)
@@ -213,7 +213,8 @@ public class PhotoPage extends ActivityState implements
             }
             PhotoDataAdapter pda = new PhotoDataAdapter(
                     mActivity, mPhotoView, mMediaSet, itemPath, mCurrentIndex,
-                    mAppBridge == null ? -1 : 0);
+                    mAppBridge == null ? -1 : 0,
+                    mAppBridge == null ? false : mAppBridge.isPanorama());
             mModel = pda;
             mPhotoView.setModel(mModel);
 
index 4ee6a01..563d55d 100644 (file)
@@ -190,6 +190,11 @@ public class SinglePhotoDataAdapter extends TileImageViewAdapter
     }
 
     @Override
+    public boolean isPanorama(int offset) {
+        return false;
+    }
+
+    @Override
     public boolean isVideo(int offset) {
         return mItem.getMediaType() == MediaItem.MEDIA_TYPE_VIDEO;
     }
index 7f3bee0..2d54317 100644 (file)
@@ -69,6 +69,9 @@ public class PhotoView extends GLView {
         // Returns true if the item is the Camera preview.
         public boolean isCamera(int offset);
 
+        // Returns true if the item is the Panorama.
+        public boolean isPanorama(int offset);
+
         // Returns true if the item is a Video.
         public boolean isVideo(int offset);
     }
@@ -401,6 +404,10 @@ public class PhotoView extends GLView {
         return (mCompensation - mDisplayRotation + 360) % 360;
     }
 
+    private int getPanoramaRotation() {
+        return mCompensation;
+    }
+
     ////////////////////////////////////////////////////////////////////////////
     //  Pictures
     ////////////////////////////////////////////////////////////////////////////
@@ -416,6 +423,7 @@ public class PhotoView extends GLView {
     class FullPicture implements Picture {
         private int mRotation;
         private boolean mIsCamera;
+        private boolean mIsPanorama;
         private boolean mIsVideo;
         private boolean mWasCameraCenter;
 
@@ -429,6 +437,7 @@ public class PhotoView extends GLView {
             mTileView.notifyModelInvalidated();
 
             mIsCamera = mModel.isCamera(0);
+            mIsPanorama = mModel.isPanorama(0);
             mIsVideo = mModel.isVideo(0);
             setScreenNail(mModel.getScreenNail(0));
             updateSize(false);
@@ -437,7 +446,9 @@ public class PhotoView extends GLView {
 
         @Override
         public void updateSize(boolean force) {
-            if (mIsCamera) {
+            if (mIsPanorama) {
+                mRotation = getPanoramaRotation();
+            } else if (mIsCamera) {
                 mRotation = getCameraRotation();
             } else {
                 mRotation = mModel.getImageRotation(0);
@@ -627,6 +638,7 @@ public class PhotoView extends GLView {
         private ScreenNail mScreenNail;
         private Size mSize = new Size();
         private boolean mIsCamera;
+        private boolean mIsPanorama;
         private boolean mIsVideo;
 
         public ScreenNailPicture(int index) {
@@ -636,6 +648,7 @@ public class PhotoView extends GLView {
         @Override
         public void reload() {
             mIsCamera = mModel.isCamera(mIndex);
+            mIsPanorama = mModel.isPanorama(mIndex);
             mIsVideo = mModel.isVideo(mIndex);
             setScreenNail(mModel.getScreenNail(mIndex));
         }
@@ -701,7 +714,9 @@ public class PhotoView extends GLView {
 
         @Override
         public void updateSize(boolean force) {
-            if (mIsCamera) {
+            if (mIsPanorama) {
+                mRotation = getPanoramaRotation();
+            } else if (mIsCamera) {
                 mRotation = getCameraRotation();
             } else {
                 mRotation = mModel.getImageRotation(mIndex);