summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/panorama
diff options
context:
space:
mode:
authorWei-Ta Chen <weita@google.com>2011-10-19 12:42:44 -0700
committerWei-Ta Chen <weita@google.com>2011-10-26 15:15:39 -0700
commitd32aa042a7d7fdb52cd8cec571e7c648f837eaff (patch)
treedc7149fceba6fe30ec1f52520ce8fb96461b1d18 /src/com/android/camera/panorama
parenta4bfc37a8d4567745bf2c5d9bbb3166fa0e7f302 (diff)
downloadpackages_apps_LegacyCamera-d32aa042a7d7fdb52cd8cec571e7c648f837eaff.zip
packages_apps_LegacyCamera-d32aa042a7d7fdb52cd8cec571e7c648f837eaff.tar.gz
packages_apps_LegacyCamera-d32aa042a7d7fdb52cd8cec571e7c648f837eaff.tar.bz2
Make Panorama work in portrait layout.
Add the support of both portrait and landscape layout to the panorama library. Add a step into the preview renderer that rotates the content in the offscreen buffer by 90 degrees in the case of a portrait layout. Change-Id: I879e3476daac522b0c8b27fe3ef5b17ebf0797e3
Diffstat (limited to 'src/com/android/camera/panorama')
-rw-r--r--src/com/android/camera/panorama/MosaicRenderer.java3
-rw-r--r--src/com/android/camera/panorama/MosaicRendererSurfaceView.java25
-rwxr-xr-xsrc/com/android/camera/panorama/MosaicRendererSurfaceViewRenderer.java7
-rwxr-xr-xsrc/com/android/camera/panorama/PanoramaActivity.java7
4 files changed, 31 insertions, 11 deletions
diff --git a/src/com/android/camera/panorama/MosaicRenderer.java b/src/com/android/camera/panorama/MosaicRenderer.java
index 1ff307d..f055c0e 100644
--- a/src/com/android/camera/panorama/MosaicRenderer.java
+++ b/src/com/android/camera/panorama/MosaicRenderer.java
@@ -43,8 +43,9 @@ 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.
*/
- public static native void reset(int width, int height);
+ public static native void reset(int width, int height, boolean isLandscapeOrientation);
/**
* Calling this function will render the SurfaceTexture to a new 2D texture
diff --git a/src/com/android/camera/panorama/MosaicRendererSurfaceView.java b/src/com/android/camera/panorama/MosaicRendererSurfaceView.java
index 08d4eff..b2acfde 100644
--- a/src/com/android/camera/panorama/MosaicRendererSurfaceView.java
+++ b/src/com/android/camera/panorama/MosaicRendererSurfaceView.java
@@ -16,7 +16,9 @@
package com.android.camera.panorama;
+import android.app.Activity;
import android.content.Context;
+import android.content.pm.ActivityInfo;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView;
import android.os.ConditionVariable;
@@ -33,25 +35,36 @@ public class MosaicRendererSurfaceView extends GLSurfaceView {
private static final boolean DEBUG = false;
private MosaicRendererSurfaceViewRenderer mRenderer;
private ConditionVariable mPreviewFrameReadyForProcessing;
+ private boolean mIsLandscapeOrientation = true;
public MosaicRendererSurfaceView(Context context) {
super(context);
- init(false, 0, 0);
- setZOrderMediaOverlay(true);
+ initialize(context, false, 0, 0);
}
public MosaicRendererSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
- init(false, 0, 0);
- setZOrderMediaOverlay(true);
+ initialize(context, false, 0, 0);
}
- public MosaicRendererSurfaceView(Context context, boolean translucent, int depth, int stencil) {
+ public MosaicRendererSurfaceView(Context context, boolean translucent,
+ int depth, int stencil) {
super(context);
+ initialize(context, translucent, depth, stencil);
+ }
+
+ private void initialize(Context context, boolean translucent, int depth, int stencil) {
+ getDisplayOrientation(context);
init(translucent, depth, stencil);
setZOrderMediaOverlay(true);
}
+ private void getDisplayOrientation(Context context) {
+ Activity activity = (PanoramaActivity) context;
+ mIsLandscapeOrientation = (activity.getRequestedOrientation()
+ == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE );
+ }
+
private void init(boolean translucent, int depth, int stencil) {
/* By default, GLSurfaceView() creates a RGB_565 opaque surface.
@@ -78,7 +91,7 @@ public class MosaicRendererSurfaceView extends GLSurfaceView {
new ConfigChooser(5, 6, 5, 0, depth, stencil));
/* Set the renderer responsible for frame rendering */
- mRenderer = new MosaicRendererSurfaceViewRenderer();
+ mRenderer = new MosaicRendererSurfaceViewRenderer(mIsLandscapeOrientation);
setRenderer(mRenderer);
setRenderMode(RENDERMODE_WHEN_DIRTY);
mPreviewFrameReadyForProcessing = new ConditionVariable();
diff --git a/src/com/android/camera/panorama/MosaicRendererSurfaceViewRenderer.java b/src/com/android/camera/panorama/MosaicRendererSurfaceViewRenderer.java
index b2b2f56..3089972 100755
--- a/src/com/android/camera/panorama/MosaicRendererSurfaceViewRenderer.java
+++ b/src/com/android/camera/panorama/MosaicRendererSurfaceViewRenderer.java
@@ -25,9 +25,14 @@ import javax.microedition.khronos.opengles.GL10;
public class MosaicRendererSurfaceViewRenderer implements GLSurfaceView.Renderer
{
private static final String TAG = "MosaicRendererSurfaceViewRenderer";
+ private boolean mIsLandscapeOrientation;
private MosaicSurfaceCreateListener mSurfaceCreateListener;
+ public MosaicRendererSurfaceViewRenderer(boolean isLandscapeOrientation) {
+ mIsLandscapeOrientation = isLandscapeOrientation;
+ }
+
/** A callback to be called when the surface is created */
public interface MosaicSurfaceCreateListener {
public void onMosaicSurfaceCreated(final int surface);
@@ -41,7 +46,7 @@ public class MosaicRendererSurfaceViewRenderer implements GLSurfaceView.Renderer
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
- MosaicRenderer.reset(width, height);
+ MosaicRenderer.reset(width, height, mIsLandscapeOrientation);
Log.i(TAG, "Renderer: onSurfaceChanged");
if (mSurfaceCreateListener != null) {
mSurfaceCreateListener.onMosaicSurfaceChanged();
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java
index 6fd9b1a..e63ef71 100755
--- a/src/com/android/camera/panorama/PanoramaActivity.java
+++ b/src/com/android/camera/panorama/PanoramaActivity.java
@@ -983,9 +983,10 @@ public class PanoramaActivity extends ActivityBase implements
// the screen).
if (mCameraState != PREVIEW_STOPPED) stopCameraPreview();
- int orientation = Util.getDisplayOrientation(Util.getDisplayRotation(this),
- CameraHolder.instance().getBackCameraId());
- mCameraDevice.setDisplayOrientation(orientation);
+ // Set the display orientation to 0, so that the underlying mosaic library
+ // can always get undistorted mPreviewWidth x mPreviewHeight image data
+ // from SurfaceTexture.
+ mCameraDevice.setDisplayOrientation(0);
setPreviewTexture(mSurfaceTexture);