summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2014-12-26 18:10:22 -0800
committerByunghun Jeon <bjeon@codeaurora.org>2015-02-09 20:00:21 -0800
commit30b2309e7c40a46ea9506344c25b58c9e8ce8dde (patch)
treefde7703eb9feb2d676b522dfb2bf8c3d0b78b144 /src/com/android
parent5e266938aac08975bbe198915adda22cc59ffebe (diff)
downloadandroid_packages_apps_Snap-30b2309e7c40a46ea9506344c25b58c9e8ce8dde.tar.gz
android_packages_apps_Snap-30b2309e7c40a46ea9506344c25b58c9e8ce8dde.tar.bz2
android_packages_apps_Snap-30b2309e7c40a46ea9506344c25b58c9e8ce8dde.zip
SnapdragonCamera: Add FullScreen Preview when in Panoramic shoot
Changed the Panoramic preview to full screen Resized the warped preview image to smaller Size and render on top of the full screen preview image Warped preview image can be turned on/off Change-Id: I859839542ce94c5f70d7fe7983e93b5e9534b415
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/camera/MosaicPreviewRenderer.java40
-rw-r--r--src/com/android/camera/MosaicRenderer.java16
-rw-r--r--src/com/android/camera/PanoProgressBar.java3
-rw-r--r--src/com/android/camera/PhotoUI.java2
-rw-r--r--src/com/android/camera/VideoUI.java2
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java18
-rw-r--r--src/com/android/camera/WideAnglePanoramaUI.java54
-rw-r--r--src/com/android/camera/ui/CameraControls.java18
8 files changed, 113 insertions, 40 deletions
diff --git a/src/com/android/camera/MosaicPreviewRenderer.java b/src/com/android/camera/MosaicPreviewRenderer.java
index 42da4d9e7..ba35b6f5a 100644
--- a/src/com/android/camera/MosaicPreviewRenderer.java
+++ b/src/com/android/camera/MosaicPreviewRenderer.java
@@ -34,6 +34,7 @@ public class MosaicPreviewRenderer {
private int mHeight; // height of the view in UI
private boolean mIsLandscape = true;
+ private int mOrientation = 0;
private final float[] mTransformMatrix = new float[16];
private ConditionVariable mEglThreadBlockVar = new ConditionVariable();
@@ -43,13 +44,15 @@ public class MosaicPreviewRenderer {
private SurfaceTexture mInputSurfaceTexture;
+ private boolean mEnableWarpedPanoPreview = false;
+
private class MyHandler extends Handler {
public static final int MSG_INIT_SYNC = 0;
public static final int MSG_SHOW_PREVIEW_FRAME_SYNC = 1;
public static final int MSG_SHOW_PREVIEW_FRAME = 2;
public static final int MSG_ALIGN_FRAME_SYNC = 3;
public static final int MSG_RELEASE = 4;
-
+ public static final int MSG_DO_PREVIEW_RESET = 5;
public MyHandler(Looper looper) {
super(looper);
}
@@ -65,6 +68,9 @@ public class MosaicPreviewRenderer {
doShowPreviewFrame();
mEglThreadBlockVar.open();
break;
+ case MSG_DO_PREVIEW_RESET:
+ doPreviewReset();
+ break;
case MSG_SHOW_PREVIEW_FRAME:
doShowPreviewFrame();
break;
@@ -83,10 +89,13 @@ public class MosaicPreviewRenderer {
mInputSurfaceTexture.updateTexImage();
mInputSurfaceTexture.getTransformMatrix(mTransformMatrix);
- MosaicRenderer.setWarping(true);
- // Call preprocess to render it to low-res and high-res RGB textures.
+ // Call setPreviewBackground to render high-res RGB textures to full screen.
+ MosaicRenderer.setPreviewBackground(true);
MosaicRenderer.preprocess(mTransformMatrix);
- // Now, transfer the textures from GPU to CPU memory for processing
+ MosaicRenderer.step();
+ MosaicRenderer.setPreviewBackground(false);
+
+ MosaicRenderer.setWarping(true);
MosaicRenderer.transferGPUtoCPU();
MosaicRenderer.updateMatrix();
MosaicRenderer.step();
@@ -104,8 +113,12 @@ public class MosaicPreviewRenderer {
}
private void doInit() {
- mInputSurfaceTexture = new SurfaceTexture(MosaicRenderer.init());
- MosaicRenderer.reset(mWidth, mHeight, mIsLandscape);
+ mInputSurfaceTexture = new SurfaceTexture(MosaicRenderer.init(mEnableWarpedPanoPreview));
+ MosaicRenderer.reset(mWidth, mHeight, mIsLandscape, mOrientation);
+ }
+
+ private void doPreviewReset() {
+ MosaicRenderer.reset(mWidth, mHeight, mIsLandscape, mOrientation);
}
private void doRelease() {
@@ -134,9 +147,11 @@ public class MosaicPreviewRenderer {
* @param isLandscape The UI orientation. {@code true} if in landscape,
* false if in portrait.
*/
- public MosaicPreviewRenderer(SurfaceTexture tex, int w, int h, boolean isLandscape) {
+ public MosaicPreviewRenderer(SurfaceTexture tex, int w, int h, boolean isLandscape,
+ int orientation, boolean enableWarpedPanoPreview) {
mIsLandscape = isLandscape;
-
+ mOrientation = orientation;
+ mEnableWarpedPanoPreview = enableWarpedPanoPreview;
mEglThread = new HandlerThread("PanoramaRealtimeRenderer");
mEglThread.start();
mHandler = new MyHandler(mEglThread.getLooper());
@@ -157,6 +172,15 @@ public class MosaicPreviewRenderer {
mHandler.sendMessageSync(MyHandler.MSG_INIT_SYNC);
}
+ public void previewReset(int w, int h, boolean isLandscape, int orientation) {
+ mWidth = w;
+ mHeight = h;
+ mIsLandscape = isLandscape;
+ mOrientation = orientation;
+ mHandler.sendEmptyMessage(MyHandler.MSG_DO_PREVIEW_RESET);
+ mSTRenderer.draw(false);
+ }
+
public void release() {
mSTRenderer.release();
mHandler.sendMessageSync(MyHandler.MSG_RELEASE);
diff --git a/src/com/android/camera/MosaicRenderer.java b/src/com/android/camera/MosaicRenderer.java
index 92d9cb7b6..5006b364d 100644
--- a/src/com/android/camera/MosaicRenderer.java
+++ b/src/com/android/camera/MosaicRenderer.java
@@ -35,7 +35,7 @@ public class MosaicRenderer
* @return textureID the texture ID of the newly generated texture to
* be assigned to the SurfaceTexture object.
*/
- public static native int init();
+ public static native int init(boolean mEnableWarpedPanoPreview);
/**
* Pass the drawing surface's width and height to initialize the
@@ -44,8 +44,10 @@ public class MosaicRenderer
* @param width width of the drawing surface in pixels.
* @param height height of the drawing surface in pixels.
* @param isLandscapeOrientation is the orientation of the activity layout in landscape.
+ * @param oientation is the orientation value in integer.
*/
- public static native void reset(int width, int height, boolean isLandscapeOrientation);
+ public static native void reset(int width, int height,
+ boolean isLandscapeOrientation, int orientation);
/**
* Calling this function will render the SurfaceTexture to a new 2D texture
@@ -86,4 +88,14 @@ public class MosaicRenderer
* @param flag boolean flag to set the warping to true or false.
*/
public static native void setWarping(boolean flag);
+ /**
+ * This function allows toggling between drawing the background full
+ * screen preview image data to screen and drawing the warped smaller
+ * preview on top of it. To render the full screen background preview,
+ * we set the falsg to true and to render the warped image on top of this
+ * we set the flag to false and flag in setWarping to true.
+ *
+ * @param flag boolean flag to set the warping to true or false.
+ */
+ public static native void setPreviewBackground(boolean flag);
}
diff --git a/src/com/android/camera/PanoProgressBar.java b/src/com/android/camera/PanoProgressBar.java
index 8dfb3660b..2a0589066 100644
--- a/src/com/android/camera/PanoProgressBar.java
+++ b/src/com/android/camera/PanoProgressBar.java
@@ -181,8 +181,5 @@ class PanoProgressBar extends ImageView {
}
canvas.drawRect(l, mDrawBounds.top, r, mDrawBounds.bottom, mIndicatorPaint);
}
-
- // draw the mask image on the top for shaping.
- super.onDraw(canvas);
}
}
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index bad7073a9..eb66c8395 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -350,7 +350,7 @@ public class PhotoUI implements PieListener,
mAspectRatioResize = true;
mAspectRatio = ratio;
}
- mCameraControls.setPreviewRatio(mAspectRatio);
+ mCameraControls.setPreviewRatio(mAspectRatio, false);
layoutPreview(ratio);
}
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 13db502c5..b70027a80 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -369,7 +369,7 @@ public class VideoUI implements PieRenderer.PieListener,
mHandler.sendEmptyMessage(UPDATE_TRANSFORM_MATRIX);
}
// ensure a semi-transparent background for now
- mCameraControls.setPreviewRatio(1.0f);
+ mCameraControls.setPreviewRatio(1.0f, false);
}
public int getPreviewWidth() {
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index 900951d96..e5ba57eb2 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -151,6 +151,7 @@ public class WideAnglePanoramaModule
private ComboPreferences mPreferences;
private boolean mMosaicPreviewConfigured;
private boolean mPreviewFocused = true;
+ private boolean mPreviewLayoutChanged = false;
@Override
public void onPreviewUIReady() {
@@ -205,6 +206,7 @@ public class WideAnglePanoramaModule
}
if (oldOrientation != mDeviceOrientation
&& oldOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
+ mPreviewLayoutChanged = true;
if (!mOrientationLocked)
mUI.setOrientation(mDeviceOrientation, true);
}
@@ -250,6 +252,12 @@ public class WideAnglePanoramaModule
mRootView.setVisibility(View.VISIBLE);
} else {
if (mCaptureState == CAPTURE_STATE_VIEWFINDER) {
+ if (mPreviewLayoutChanged) {
+ boolean isLandscape = (mDeviceOrientation / 90) % 2 == 1;
+ renderer.previewReset(mPreviewUIWidth, mPreviewUIHeight,
+ isLandscape, mDeviceOrientation);
+ mPreviewLayoutChanged = false;
+ }
renderer.showPreviewFrame();
} else {
renderer.alignFrameSync();
@@ -467,13 +475,13 @@ public class WideAnglePanoramaModule
}
mMosaicPreviewRenderer = null;
}
- final boolean isLandscape =
- (mActivity.getResources().getConfiguration().orientation ==
- Configuration.ORIENTATION_LANDSCAPE);
+ final boolean isLandscape = (mDeviceOrientation / 90) % 2 == 1;
+ final boolean enableWarpedPanoPreview =
+ mActivity.getResources().getBoolean(R.bool.enable_warped_pano_preview);
mUI.flipPreviewIfNeeded();
MosaicPreviewRenderer renderer = new MosaicPreviewRenderer(
- mUI.getSurfaceTexture(),
- mPreviewUIWidth, mPreviewUIHeight, isLandscape);
+ mUI.getSurfaceTexture(), mPreviewUIWidth, mPreviewUIHeight,
+ isLandscape, mDeviceOrientation, enableWarpedPanoPreview);
synchronized (mRendererLock) {
mMosaicPreviewRenderer = renderer;
mCameraTexture = mMosaicPreviewRenderer.getInputSurfaceTexture();
diff --git a/src/com/android/camera/WideAnglePanoramaUI.java b/src/com/android/camera/WideAnglePanoramaUI.java
index 53b1630b1..7941ea88c 100644
--- a/src/com/android/camera/WideAnglePanoramaUI.java
+++ b/src/com/android/camera/WideAnglePanoramaUI.java
@@ -35,6 +35,7 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.Log;
import android.view.Gravity;
+import android.view.Display;
import android.view.LayoutInflater;
import android.view.TextureView;
import android.view.View;
@@ -100,6 +101,7 @@ public class WideAnglePanoramaUI implements
private View mPreviewCover;
private int mOrientation;
+ private int mPreviewYOffset;
/** Constructor. */
public WideAnglePanoramaUI(
@@ -353,6 +355,39 @@ public class WideAnglePanoramaUI implements
}
}
+ private void setPanoramaPreviewView() {
+ int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
+ Display display = mActivity.getWindowManager().getDefaultDisplay();
+ Point size = new Point();
+ display.getSize(size);
+
+ int width = size.x;
+ int height = size.y;
+ int xOffset = 0;
+ int yOffset = 0;
+ int w = width;
+ int h = height;
+
+ h = w * 4 / 3;
+ yOffset = (height - h) / 2;
+
+ FrameLayout.LayoutParams param = new FrameLayout.LayoutParams(w, h);
+ mTextureView.setLayoutParams(param);
+ mTextureView.setX(xOffset);
+ mTextureView.setY(yOffset);
+ mPreviewBorder.setLayoutParams(param);
+ mPreviewBorder.setX(xOffset);
+ mPreviewBorder.setY(yOffset);
+ mPreviewYOffset = yOffset;
+
+ int t = mPreviewYOffset;
+ int b1 = mTextureView.getBottom() - mPreviewYOffset;
+ int r = mTextureView.getRight();
+ int b2 = mTextureView.getBottom();
+
+ mCameraControls.setPreviewRatio(1.0f, true);
+ }
+
public void resetSavingProgress() {
mSavingProgressBar.reset();
mSavingProgressBar.setRightIncreasing(true);
@@ -441,6 +476,7 @@ public class WideAnglePanoramaUI implements
mTextureView.setSurfaceTextureListener(this);
mTextureView.addOnLayoutChangeListener(this);
mCameraControls = (CameraControls) mRootView.findViewById(R.id.camera_controls);
+ setPanoramaPreviewView();
mDialogHelper = new DialogHelper();
setViews(appRes);
@@ -449,14 +485,6 @@ public class WideAnglePanoramaUI implements
private void setViews(Resources appRes) {
int weight = appRes.getInteger(R.integer.SRI_pano_layout_weight);
- LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mPreviewLayout.getLayoutParams();
- lp.weight = weight;
- mPreviewLayout.setLayoutParams(lp);
-
- lp = (LinearLayout.LayoutParams) mReview.getLayoutParams();
- lp.weight = weight;
- mPreviewLayout.setLayoutParams(lp);
-
mSavingProgressBar = (PanoProgressBar) mRootView.findViewById(R.id.pano_saving_progress_bar);
mSavingProgressBar.setIndicatorWidth(0);
mSavingProgressBar.setMaxProgress(100);
@@ -603,11 +631,11 @@ public class WideAnglePanoramaUI implements
// | 3 |
// `---------' =b2
// =r
- int t = mPreviewLayout.getTop();
- int b1 = mPreviewLayout.getBottom();
- int r = mPreviewLayout.getRight();
- int b2 = mCaptureLayout.getBottom();
-
+ final View dummy = mRootView.findViewById(R.id.pano_dummy_layout);
+ int t = dummy.getTop();
+ int b1 = dummy.getBottom();
+ int r = dummy.getRight();
+ int b2 = dummy.getBottom();
final FrameLayout progressLayout = (FrameLayout)
mRootView.findViewById(R.id.pano_progress_layout);
int pivotY = ((ViewGroup) progressLayout).getPaddingTop()
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index dedf3d583..59222b929 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -20,8 +20,8 @@ import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
-import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Paint;
@@ -803,13 +803,17 @@ public class CameraControls extends RotatableLayout {
mBottomMargin = bottom;
}
- public void setPreviewRatio(float ratio) {
- int r = CameraUtil.determineRatio(ratio);
- mPreviewRatio = r;
- if (mPreviewRatio == CameraUtil.RATIO_4_3 && mTopMargin != 0) {
- mPaint.setColor(getResources().getColor(R.color.camera_control_bg_opaque));
+ public void setPreviewRatio(float ratio, boolean panorama) {
+ if (panorama) {
+ mPaint.setColor(Color.TRANSPARENT);
} else {
- mPaint.setColor(getResources().getColor(R.color.camera_control_bg_transparent));
+ int r = CameraUtil.determineRatio(ratio);
+ mPreviewRatio = r;
+ if (mPreviewRatio == CameraUtil.RATIO_4_3 && mTopMargin != 0) {
+ mPaint.setColor(getResources().getColor(R.color.camera_control_bg_opaque));
+ } else {
+ mPaint.setColor(getResources().getColor(R.color.camera_control_bg_transparent));
+ }
}
invalidate();
}