diff options
author | Chih-Chung Chang <chihchung@google.com> | 2012-05-29 15:28:36 -0700 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2012-05-29 21:14:38 -0700 |
commit | 860b7463c16f44a7b8fce01a79161ce3e8d47214 (patch) | |
tree | 05762a4a51727b31f77b841e2d7a29426140b366 /src/com/android/gallery3d/ui/PositionController.java | |
parent | b603e674b9e0bc7372fd535f7f3ac0b9b4e3a689 (diff) | |
download | android_packages_apps_Snap-860b7463c16f44a7b8fce01a79161ce3e8d47214.tar.gz android_packages_apps_Snap-860b7463c16f44a7b8fce01a79161ce3e8d47214.tar.bz2 android_packages_apps_Snap-860b7463c16f44a7b8fce01a79161ce3e8d47214.zip |
Improve image size change handling.
- When the camera relative frame is set, we delay the change for camera
rectange until the next setImageSize call. This avoids the unwanted
intermediate state if we change them separately.
- Don't draw other screennails when the camera is in full screen. This
avoids showing other screennails when the image size changes.
- When the aspect ratio of the image changes, we assume the view angle
of the longer side doesn't change (so the aspect ratio change is because
the view angle of the shorter side changes). This matches what camera
preview does.
Bug: 6566612
Change-Id: I7603416f31c96ba77c96cdc2a3d0b79f8921c491
Diffstat (limited to 'src/com/android/gallery3d/ui/PositionController.java')
-rw-r--r-- | src/com/android/gallery3d/ui/PositionController.java | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java index db77b99ba..cf41d3a30 100644 --- a/src/com/android/gallery3d/ui/PositionController.java +++ b/src/com/android/gallery3d/ui/PositionController.java @@ -218,28 +218,34 @@ class PositionController { } } - public void setConstrainedFrame(Rect f) { - if (mConstrainedFrame.equals(f)) return; - mConstrainedFrame.set(f); + public void setConstrainedFrame(Rect cFrame) { + if (mConstrainedFrame.equals(cFrame)) return; + mConstrainedFrame.set(cFrame); mPlatform.updateDefaultXY(); updateScaleAndGapLimit(); snapAndRedraw(); } - public void setImageSize(int index, int width, int height, boolean force) { - if (force) { - Box b = mBoxes.get(index); - b.mImageW = width; - b.mImageH = height; - return; - } + public void forceImageSize(int index, int width, int height) { + if (width == 0 || height == 0) return; + Box b = mBoxes.get(index); + b.mImageW = width; + b.mImageH = height; + return; + } + + public void setImageSize(int index, int width, int height, Rect cFrame) { + if (width == 0 || height == 0) return; - if (width == 0 || height == 0) { - initBox(index); - } else if (!setBoxSize(index, width, height, false)) { - return; + boolean needUpdate = false; + if (cFrame != null && !mConstrainedFrame.equals(cFrame)) { + mConstrainedFrame.set(cFrame); + mPlatform.updateDefaultXY(); + needUpdate = true; } + needUpdate |= setBoxSize(index, width, height, false); + if (!needUpdate) return; updateScaleAndGapLimit(); snapAndRedraw(); } @@ -259,8 +265,15 @@ class PositionController { } // The ratio of the old size and the new size. - float ratio = Math.min( - (float) b.mImageW / width, (float) b.mImageH / height); + // + // If the aspect ratio changes, we don't know if it is because one side + // grows or the other side shrinks. Currently we just assume the view + // angle of the longer side doesn't change (so the aspect ratio change + // is because the view angle of the shorter side changes). This matches + // what camera preview does. + float ratio = (width > height) + ? (float) b.mImageW / width + : (float) b.mImageH / height; b.mImageW = width; b.mImageH = height; |