summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wu-cheng Li <wuchengli@google.com> 2010-10-12 01:41:59 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2010-10-12 01:41:59 -0700
commit7b76bed1ee4c938ec5ad24ea5d804236731da475 (patch)
treea6e9631242520c9e05200b48c9d45adbadd7b589
parent5994359f3009a3ebfbd37d82bb9a665e9b947851 (diff)
parentb0f7d95bf84ca7b315391a0a28a287319d3f3af2 (diff)
Merge "Fix camera display orientation."
-rw-r--r--services/camera/libcameraservice/CameraService.cpp12
-rw-r--r--services/camera/libcameraservice/CameraService.h2
2 files changed, 13 insertions, 1 deletions
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 808c6791c1d5..d09dfff77ec7 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -320,6 +320,7 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
// Callback is disabled by default
mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
mOrientation = 0;
+ mPreviewWindowFlag = 0;
mOrientationChanged = false;
mPlayShutterSound = true;
cameraService->setCameraBusy(cameraId);
@@ -508,6 +509,8 @@ status_t CameraService::Client::setPreviewDisplay(const sp<Surface>& surface) {
if (mUseOverlay) {
result = setOverlay();
} else if (mPreviewWindow != 0) {
+ native_window_set_buffers_transform(mPreviewWindow.get(),
+ mPreviewWindowFlag);
result = mHardware->setPreviewWindow(mPreviewWindow);
}
}
@@ -633,7 +636,10 @@ status_t CameraService::Client::startPreviewMode() {
if (result != NO_ERROR) return result;
result = mHardware->startPreview();
} else {
- // XXX: Set the orientation of the ANativeWindow.
+ if (mPreviewWindow != 0) {
+ native_window_set_buffers_transform(mPreviewWindow.get(),
+ mPreviewWindowFlag);
+ }
mHardware->setPreviewWindow(mPreviewWindow);
result = mHardware->startPreview();
}
@@ -818,15 +824,19 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a
switch (arg1) {
case 0:
orientation = ISurface::BufferHeap::ROT_0;
+ mPreviewWindowFlag = 0;
break;
case 90:
orientation = ISurface::BufferHeap::ROT_90;
+ mPreviewWindowFlag = NATIVE_WINDOW_TRANSFORM_ROT_90;
break;
case 180:
orientation = ISurface::BufferHeap::ROT_180;
+ mPreviewWindowFlag = NATIVE_WINDOW_TRANSFORM_ROT_180;
break;
case 270:
orientation = ISurface::BufferHeap::ROT_270;
+ mPreviewWindowFlag = NATIVE_WINDOW_TRANSFORM_ROT_270;
break;
default:
return BAD_VALUE;
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index d57364a8795d..c8e0c886579e 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -166,6 +166,7 @@ private:
sp<CameraService> mCameraService; // immutable after constructor
sp<ICameraClient> mCameraClient;
int mCameraId; // immutable after constructor
+ int mCameraFacing; // immutable after constructor
pid_t mClientPid;
sp<CameraHardwareInterface> mHardware; // cleared after disconnect()
bool mUseOverlay; // immutable after constructor
@@ -176,6 +177,7 @@ private:
int mOrientation; // Current display orientation
// True if display orientation has been changed. This is only used in overlay.
int mOrientationChanged;
+ int mPreviewWindowFlag;
bool mPlayShutterSound;
// Ensures atomicity among the public methods