summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-10-26 22:32:54 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-26 22:32:54 -0700
commit8069c9ee96a8cd5a374b9dca01f6c2919388d085 (patch)
tree1c7024a0e643766cc4775be5c5ecfffe53be0687 /src/com
parent86bace6c94d86cd662f7bff7a58e90dd43577bb4 (diff)
parentd32aa042a7d7fdb52cd8cec571e7c648f837eaff (diff)
downloadpackages_apps_LegacyCamera-8069c9ee96a8cd5a374b9dca01f6c2919388d085.zip
packages_apps_LegacyCamera-8069c9ee96a8cd5a374b9dca01f6c2919388d085.tar.gz
packages_apps_LegacyCamera-8069c9ee96a8cd5a374b9dca01f6c2919388d085.tar.bz2
Merge "Make Panorama work in portrait layout." into ics-mr1
Diffstat (limited to 'src/com')
-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);