From 860b7463c16f44a7b8fce01a79161ce3e8d47214 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Tue, 29 May 2012 15:28:36 -0700 Subject: 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 --- .../android/gallery3d/ui/PositionController.java | 45 ++++++++++++++-------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'src/com/android/gallery3d/ui/PositionController.java') 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; -- cgit v1.2.3