summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2010-01-21 17:31:06 -0800
committerChih-Chung Chang <chihchung@google.com>2010-01-21 20:20:08 -0800
commite1ceec234c618729cc7bd35fecb11744b52c1cc8 (patch)
treed478c2160bfb90b429f13089a92d182ddf0b62e0 /camera
parent177b580f56e91bc5519b8772e696b14f8b5757e2 (diff)
downloadframeworks_base-e1ceec234c618729cc7bd35fecb11744b52c1cc8.zip
frameworks_base-e1ceec234c618729cc7bd35fecb11744b52c1cc8.tar.gz
frameworks_base-e1ceec234c618729cc7bd35fecb11744b52c1cc8.tar.bz2
Add an orientation parameter for overlay, so we can do camera preview in portrait mode.
Diffstat (limited to 'camera')
-rw-r--r--camera/libcameraservice/CameraService.cpp29
-rw-r--r--camera/libcameraservice/CameraService.h1
-rw-r--r--camera/tests/CameraServiceTest/CameraServiceTest.cpp5
3 files changed, 18 insertions, 17 deletions
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index fae1f26..a8e217e 100644
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -235,6 +235,7 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
// Callback is disabled by default
mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
+ mOrientation = 0;
cameraService->incUsers();
LOGV("Client::Client X (pid %d)", callingPid);
}
@@ -570,7 +571,8 @@ status_t CameraService::Client::setOverlay()
// wait in the createOverlay call if the previous overlay is in the
// process of being destroyed.
for (int retry = 0; retry < 50; ++retry) {
- mOverlayRef = mSurface->createOverlay(w, h, OVERLAY_FORMAT_DEFAULT);
+ mOverlayRef = mSurface->createOverlay(w, h, OVERLAY_FORMAT_DEFAULT,
+ mOrientation);
if (mOverlayRef != NULL) break;
LOGW("Overlay create failed - retrying");
usleep(20000);
@@ -601,15 +603,9 @@ status_t CameraService::Client::registerPreviewBuffers()
CameraParameters params(mHardware->getParameters());
params.getPreviewSize(&w, &h);
- uint32_t transform = 0;
- if (params.getOrientation() ==
- CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
- LOGV("portrait mode");
- transform = ISurface::BufferHeap::ROT_90;
- }
ISurface::BufferHeap buffers(w, h, w, h,
PIXEL_FORMAT_YCbCr_420_SP,
- transform,
+ mOrientation,
0,
mHardware->getPreviewHeap());
@@ -919,12 +915,6 @@ void CameraService::Client::handleShutter(
if (mSurface != 0 && !mUseOverlay) {
int w, h;
CameraParameters params(mHardware->getParameters());
- uint32_t transform = 0;
- if (params.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
- LOGV("portrait mode");
- transform = ISurface::BufferHeap::ROT_90;
- }
-
if (size == NULL) {
params.getPictureSize(&w, &h);
} else {
@@ -935,7 +925,7 @@ void CameraService::Client::handleShutter(
LOGV("Snapshot image width=%d, height=%d", w, h);
}
ISurface::BufferHeap buffers(w, h, w, h,
- PIXEL_FORMAT_YCbCr_420_SP, transform, 0, mHardware->getRawHeap());
+ PIXEL_FORMAT_YCbCr_420_SP, mOrientation, 0, mHardware->getRawHeap());
mSurface->registerBuffers(buffers);
}
@@ -1200,6 +1190,15 @@ status_t CameraService::Client::setParameters(const String8& params)
}
CameraParameters p(params);
+
+ // The orientation parameter is actually for CameraService, not for the camera driver.
+ if (p.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
+ LOGV("portrait mode");
+ mOrientation = ISurface::BufferHeap::ROT_90;
+ } else {
+ mOrientation = 0;
+ }
+
return mHardware->setParameters(p);
}
diff --git a/camera/libcameraservice/CameraService.h b/camera/libcameraservice/CameraService.h
index 3e3e54f..b3d20f6 100644
--- a/camera/libcameraservice/CameraService.h
+++ b/camera/libcameraservice/CameraService.h
@@ -182,6 +182,7 @@ private:
sp<CameraService> mCameraService;
sp<ISurface> mSurface;
int mPreviewCallbackFlag;
+ int mOrientation;
sp<MediaPlayer> mMediaPlayerClick;
sp<MediaPlayer> mMediaPlayerBeep;
diff --git a/camera/tests/CameraServiceTest/CameraServiceTest.cpp b/camera/tests/CameraServiceTest/CameraServiceTest.cpp
index 29320e0..f89d9d3 100644
--- a/camera/tests/CameraServiceTest/CameraServiceTest.cpp
+++ b/camera/tests/CameraServiceTest/CameraServiceTest.cpp
@@ -283,7 +283,7 @@ public:
virtual void postBuffer(ssize_t offset);
virtual void unregisterBuffers();
virtual sp<OverlayRef> createOverlay(
- uint32_t w, uint32_t h, int32_t format);
+ uint32_t w, uint32_t h, int32_t format, int32_t orientation);
virtual sp<GraphicBuffer> requestBuffer(int bufferIdx, int usage);
// new functions
@@ -346,7 +346,8 @@ void MSurface::waitUntil(int c0, int c1, int c2) {
}
}
-sp<OverlayRef> MSurface::createOverlay(uint32_t w, uint32_t h, int32_t format) {
+sp<OverlayRef> MSurface::createOverlay(uint32_t w, uint32_t h, int32_t format,
+ int32_t orientation) {
// We don't expect this to be called in current hardware.
ASSERT(0);
sp<OverlayRef> dummy;