diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-09 17:51:23 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-09 17:51:23 -0800 |
commit | b798689749c64baba81f02e10cf2157c747d6b46 (patch) | |
tree | da394a395ddb1a6cf69193314846b03fe47a397e /libs/ui | |
parent | f013e1afd1e68af5e3b868c26a653bbfb39538f8 (diff) | |
download | frameworks_base-b798689749c64baba81f02e10cf2157c747d6b46.zip frameworks_base-b798689749c64baba81f02e10cf2157c747d6b46.tar.gz frameworks_base-b798689749c64baba81f02e10cf2157c747d6b46.tar.bz2 |
auto import from //branches/cupcake/...@125939
Diffstat (limited to 'libs/ui')
-rw-r--r-- | libs/ui/Camera.cpp | 19 | ||||
-rw-r--r-- | libs/ui/ICamera.cpp | 45 | ||||
-rw-r--r-- | libs/ui/IOverlay.cpp | 15 | ||||
-rw-r--r-- | libs/ui/ISurface.cpp | 8 | ||||
-rw-r--r-- | libs/ui/Overlay.cpp | 122 | ||||
-rw-r--r-- | libs/ui/Region.cpp | 2 |
6 files changed, 145 insertions, 66 deletions
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp index 9527009..4a325ac 100644 --- a/libs/ui/Camera.cpp +++ b/libs/ui/Camera.cpp @@ -136,6 +136,18 @@ sp<ICamera> Camera::remote() return mCamera; } +status_t Camera::lock() +{ + if (mCamera != 0) return mCamera->lock(); + return NO_INIT; +} + +status_t Camera::unlock() +{ + if (mCamera != 0) return mCamera->unlock(); + return NO_INIT; +} + // pass the buffered ISurface to the camera service status_t Camera::setPreviewDisplay(const sp<Surface>& surface) { @@ -172,6 +184,13 @@ void Camera::stopPreview() mCamera->stopPreview(); } +// get preview state +bool Camera::previewEnabled() +{ + LOGV("previewEnabled"); + return mCamera->previewEnabled(); +} + status_t Camera::autoFocus() { LOGV("autoFocus"); diff --git a/libs/ui/ICamera.cpp b/libs/ui/ICamera.cpp index 6a2dc6b..7b0922e 100644 --- a/libs/ui/ICamera.cpp +++ b/libs/ui/ICamera.cpp @@ -35,7 +35,10 @@ enum { TAKE_PICTURE, SET_PARAMETERS, GET_PARAMETERS, - CONNECT + CONNECT, + LOCK, + UNLOCK, + PREVIEW_ENABLED }; class BpCamera: public BpInterface<ICamera> @@ -96,6 +99,16 @@ public: remote()->transact(STOP_PREVIEW, data, &reply); } + // check preview state + bool previewEnabled() + { + LOGV("previewEnabled"); + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + remote()->transact(PREVIEW_ENABLED, data, &reply); + return reply.readInt32(); + } + // auto focus status_t autoFocus() { @@ -146,6 +159,20 @@ public: remote()->transact(CONNECT, data, &reply); return reply.readInt32(); } + virtual status_t lock() + { + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + remote()->transact(LOCK, data, &reply); + return reply.readInt32(); + } + virtual status_t unlock() + { + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + remote()->transact(UNLOCK, data, &reply); + return reply.readInt32(); + } }; IMPLEMENT_META_INTERFACE(Camera, "android.hardware.ICamera"); @@ -194,6 +221,12 @@ status_t BnCamera::onTransact( stopPreview(); return NO_ERROR; } break; + case PREVIEW_ENABLED: { + LOGV("PREVIEW_ENABLED"); + CHECK_INTERFACE(ICamera, data, reply); + reply->writeInt32(previewEnabled()); + return NO_ERROR; + } break; case AUTO_FOCUS: { LOGV("AUTO_FOCUS"); CHECK_INTERFACE(ICamera, data, reply); @@ -225,6 +258,16 @@ status_t BnCamera::onTransact( reply->writeInt32(connect(cameraClient)); return NO_ERROR; } break; + case LOCK: { + CHECK_INTERFACE(ICamera, data, reply); + reply->writeInt32(lock()); + return NO_ERROR; + } break; + case UNLOCK: { + CHECK_INTERFACE(ICamera, data, reply); + reply->writeInt32(unlock()); + return NO_ERROR; + } break; default: return BBinder::onTransact(code, data, reply, flags); } diff --git a/libs/ui/IOverlay.cpp b/libs/ui/IOverlay.cpp index 59d1ea0..fed47c2 100644 --- a/libs/ui/IOverlay.cpp +++ b/libs/ui/IOverlay.cpp @@ -27,7 +27,6 @@ namespace android { enum { DESTROY = IBinder::FIRST_CALL_TRANSACTION, // one-way transaction - SWAP_BUFFERS, }; class BpOverlay : public BpInterface<IOverlay> @@ -44,14 +43,6 @@ public: data.writeInterfaceToken(IOverlay::getInterfaceDescriptor()); remote()->transact(DESTROY, data, &reply, IBinder::FLAG_ONEWAY); } - - virtual ssize_t swapBuffers() - { - Parcel data, reply; - data.writeInterfaceToken(IOverlay::getInterfaceDescriptor()); - remote()->transact(SWAP_BUFFERS, data, &reply); - return reply.readInt32(); - } }; IMPLEMENT_META_INTERFACE(Overlay, "android.ui.IOverlay"); @@ -73,12 +64,6 @@ status_t BnOverlay::onTransact( destroy(); return NO_ERROR; } break; - case SWAP_BUFFERS: { - CHECK_INTERFACE(IOverlay, data, reply); - ssize_t offset = swapBuffers(); - reply->writeInt32(offset); - return NO_ERROR; - } break; default: return BBinder::onTransact(code, data, reply, flags); } diff --git a/libs/ui/ISurface.cpp b/libs/ui/ISurface.cpp index c1c9596..54f78fe 100644 --- a/libs/ui/ISurface.cpp +++ b/libs/ui/ISurface.cpp @@ -73,7 +73,7 @@ public: remote()->transact(UNREGISTER_BUFFERS, data, &reply); } - virtual sp<Overlay> createOverlay( + virtual sp<OverlayRef> createOverlay( uint32_t w, uint32_t h, int32_t format) { Parcel data, reply; @@ -82,7 +82,7 @@ public: data.writeInt32(h); data.writeInt32(format); remote()->transact(CREATE_OVERLAY, data, &reply); - return Overlay::readFromParcel(reply); + return OverlayRef::readFromParcel(reply); } }; @@ -128,8 +128,8 @@ status_t BnSurface::onTransact( int w = data.readInt32(); int h = data.readInt32(); int f = data.readInt32(); - sp<Overlay> o = createOverlay(w, h, w); - return Overlay::writeToParcel(reply, o); + sp<OverlayRef> o = createOverlay(w, h, w); + return OverlayRef::writeToParcel(reply, o); } break; default: return BBinder::onTransact(code, data, reply, flags); diff --git a/libs/ui/Overlay.cpp b/libs/ui/Overlay.cpp index 2267c3e..a79950c 100644 --- a/libs/ui/Overlay.cpp +++ b/libs/ui/Overlay.cpp @@ -16,86 +16,114 @@ #include <utils/IMemory.h> #include <utils/Parcel.h> +#include <utils/Errors.h> +#include <utils/MemoryHeapBase.h> #include <ui/IOverlay.h> #include <ui/Overlay.h> +#include <hardware/overlay.h> + namespace android { -Overlay::Overlay(overlay_handle_t* handle, - const sp<IOverlay>& o, const sp<IMemoryHeap>& heap, - uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs) - : mOverlay(o), mHeap(heap), mCurrentBufferOffset(0), mOverlayHandle(handle), - mWidth(w), mHeight(h), mFormat(f), mWidthStride(ws), mHeightStride(hs) +Overlay::Overlay(const sp<OverlayRef>& overlayRef) + : mOverlayRef(overlayRef), mOverlayData(0), mStatus(NO_INIT) { + mOverlayData = NULL; + hw_module_t const* module; + if (hw_get_module(OVERLAY_HARDWARE_MODULE_ID, &module) == 0) { + if (overlay_data_open(module, &mOverlayData) == NO_ERROR) { + mStatus = mOverlayData->initialize(mOverlayData, + overlayRef->mOverlayHandle); + } + } } -Overlay::Overlay(overlay_t* overlay, - const sp<IOverlay>& o, const sp<IMemoryHeap>& heap) - : mOverlay(o), mHeap(heap) -{ - mCurrentBufferOffset = 0; - mOverlayHandle = overlay->getHandleRef(overlay); - mWidth = overlay->w; - mHeight = overlay->h; - mFormat = overlay->format; - mWidthStride = overlay->w_stride; - mHeightStride = overlay->h_stride; +Overlay::~Overlay() { + if (mOverlayData) { + overlay_data_close(mOverlayData); + } } - -Overlay::~Overlay() { +overlay_buffer_t Overlay::dequeueBuffer() +{ + return mOverlayData->dequeueBuffer(mOverlayData); } -void Overlay::destroy() { - mOverlay->destroy(); +int Overlay::queueBuffer(overlay_buffer_t buffer) +{ + return mOverlayData->queueBuffer(mOverlayData, buffer); } -status_t Overlay::swapBuffers() { - ssize_t result = mOverlay->swapBuffers(); - if (result < 0) - return status_t(result); - mCurrentBufferOffset = result; - return NO_ERROR; +void* Overlay::getBufferAddress(overlay_buffer_t buffer) +{ + return mOverlayData->getBufferAddress(mOverlayData, buffer); } -overlay_handle_t const* Overlay::getHandleRef() const { - return mOverlayHandle; +void Overlay::destroy() { + mOverlayRef->mOverlayChanel->destroy(); } -size_t Overlay::getBufferOffset() const { - return mCurrentBufferOffset; +status_t Overlay::getStatus() const { + return mStatus; } -sp<IMemoryHeap> Overlay::getHeap() const { - return mHeap; +overlay_handle_t const* Overlay::getHandleRef() const { + return mOverlayRef->mOverlayHandle; } uint32_t Overlay::getWidth() const { - return mWidth; + return mOverlayRef->mWidth; } uint32_t Overlay::getHeight() const { - return mHeight; + return mOverlayRef->mHeight; } int32_t Overlay::getFormat() const { - return mFormat; + return mOverlayRef->mFormat; } int32_t Overlay::getWidthStride() const { - return mWidthStride; + return mOverlayRef->mWidthStride; } int32_t Overlay::getHeightStride() const { - return mHeightStride; + return mOverlayRef->mHeightStride; +} +// ---------------------------------------------------------------------------- + +OverlayRef::OverlayRef() + : mOverlayHandle(0), + mWidth(0), mHeight(0), mFormat(0), mWidthStride(0), mHeightStride(0), + mOwnHandle(true) +{ +} + +OverlayRef::OverlayRef(overlay_handle_t const* handle, const sp<IOverlay>& chanel, + uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs) + : mOverlayHandle(handle), mOverlayChanel(chanel), + mWidth(w), mHeight(h), mFormat(f), mWidthStride(ws), mHeightStride(hs), + mOwnHandle(false) +{ +} + +OverlayRef::~OverlayRef() +{ + if (mOwnHandle) { + /* FIXME: handles should be promoted to "real" API and be handled by + * the framework */ + for (int i=0 ; i<mOverlayHandle->numFds ; i++) { + close(mOverlayHandle->fds[i]); + } + free((void*)mOverlayHandle); + } } -sp<Overlay> Overlay::readFromParcel(const Parcel& data) { - sp<Overlay> result; +sp<OverlayRef> OverlayRef::readFromParcel(const Parcel& data) { + sp<OverlayRef> result; sp<IOverlay> overlay = IOverlay::asInterface(data.readStrongBinder()); if (overlay != NULL) { - sp<IMemoryHeap> heap = IMemoryHeap::asInterface(data.readStrongBinder()); uint32_t w = data.readInt32(); uint32_t h = data.readInt32(); uint32_t f = data.readInt32(); @@ -111,15 +139,21 @@ sp<Overlay> Overlay::readFromParcel(const Parcel& data) { handle->fds[i] = data.readFileDescriptor(); for (int i=0 ; i<numint ; i++) handle->data[i] = data.readInt32(); - result = new Overlay(handle, overlay, heap, w, h, f, ws, hs); + result = new OverlayRef(); + result->mOverlayHandle = handle; + result->mOverlayChanel = overlay; + result->mWidth = w; + result->mHeight = h; + result->mFormat = f; + result->mWidthStride = ws; + result->mHeightStride = hs; } return result; } -status_t Overlay::writeToParcel(Parcel* reply, const sp<Overlay>& o) { +status_t OverlayRef::writeToParcel(Parcel* reply, const sp<OverlayRef>& o) { if (o != NULL) { - reply->writeStrongBinder(o->mOverlay->asBinder()); - reply->writeStrongBinder(o->mHeap->asBinder()); + reply->writeStrongBinder(o->mOverlayChanel->asBinder()); reply->writeInt32(o->mWidth); reply->writeInt32(o->mHeight); reply->writeInt32(o->mFormat); diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp index 3e07f2b..26e694a 100644 --- a/libs/ui/Region.cpp +++ b/libs/ui/Region.cpp @@ -21,8 +21,6 @@ #include <utils/Debug.h> #include <utils/String8.h> #include <ui/Region.h> -#include <corecg/SkRegion.h> -#include <corecg/SkRect.h> namespace android { |