From: Angus Kong Date: Thu, 17 May 2012 02:15:56 +0000 (-0700) Subject: Support Panorama preview. X-Git-Tag: android-x86-6.0-r3~2044^2~1257^2~31^3~14 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d5c545b45ac938dd358f0eb3af40a574a6e96a09;p=android-x86%2Fpackages-apps-Camera2.git Support Panorama preview. The panorama preview doesn't consider display rotation. bug:6305152 Change-Id: I6b87c18ed8eadf1b2bf5e64437c5b290d111cbba --- diff --git a/src/com/android/gallery3d/app/AppBridge.java b/src/com/android/gallery3d/app/AppBridge.java index 90cbd0bbb..5d6b1ec52 100644 --- a/src/com/android/gallery3d/app/AppBridge.java +++ b/src/com/android/gallery3d/app/AppBridge.java @@ -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(); diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java index d88b72ca8..c92f7ed43 100644 --- a/src/com/android/gallery3d/app/PhotoDataAdapter.java +++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java @@ -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) diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 493e4aaf4..595e35bb7 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -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); diff --git a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java index 4ee6a0144..563d55da6 100644 --- a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java +++ b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java @@ -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; } diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index 7f3bee0a3..2d543179e 100644 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -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);