diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-10 15:44:00 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-10 15:44:00 -0800 |
commit | d24b8183b93e781080b2c16c487e60d51c12da31 (patch) | |
tree | fbb89154858984eb8e41556da7e9433040d55cd4 /libs/ui | |
parent | f1e484acb594a726fb57ad0ae4cfe902c7f35858 (diff) | |
download | frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.zip frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.gz frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.bz2 |
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'libs/ui')
-rw-r--r-- | libs/ui/Camera.cpp | 76 | ||||
-rw-r--r-- | libs/ui/CameraParameters.cpp | 20 | ||||
-rw-r--r-- | libs/ui/EGLDisplaySurface.cpp | 75 | ||||
-rw-r--r-- | libs/ui/EGLNativeWindowSurface.cpp | 27 | ||||
-rw-r--r-- | libs/ui/EventHub.cpp | 43 | ||||
-rw-r--r-- | libs/ui/ICamera.cpp | 91 | ||||
-rw-r--r-- | libs/ui/ICameraClient.cpp | 36 | ||||
-rw-r--r-- | libs/ui/ISurface.cpp | 67 | ||||
-rw-r--r-- | libs/ui/Overlay.cpp | 6 | ||||
-rw-r--r-- | libs/ui/PixelFormat.cpp | 33 |
10 files changed, 372 insertions, 102 deletions
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp index 50c6008..6c60b85 100644 --- a/libs/ui/Camera.cpp +++ b/libs/ui/Camera.cpp @@ -84,8 +84,10 @@ void Camera::init() mRawCallbackCookie = 0; mJpegCallback = 0; mJpegCallbackCookie = 0; - mFrameCallback = 0; - mFrameCallbackCookie = 0; + mPreviewCallback = 0; + mPreviewCallbackCookie = 0; + mRecordingCallback = 0; + mRecordingCallbackCookie = 0; mErrorCallback = 0; mErrorCallbackCookie = 0; mAutoFocusCallback = 0; @@ -184,6 +186,15 @@ status_t Camera::startPreview() return c->startPreview(); } +// start recording mode, must call setPreviewDisplay first +status_t Camera::startRecording() +{ + LOGV("startRecording"); + sp <ICamera> c = mCamera; + if (c == 0) return NO_INIT; + return c->startRecording(); +} + // stop preview mode void Camera::stopPreview() { @@ -193,6 +204,24 @@ void Camera::stopPreview() c->stopPreview(); } +// stop recording mode +void Camera::stopRecording() +{ + LOGV("stopRecording"); + sp <ICamera> c = mCamera; + if (c == 0) return; + c->stopRecording(); +} + +// release a recording frame +void Camera::releaseRecordingFrame(const sp<IMemory>& mem) +{ + LOGV("releaseRecordingFrame"); + sp <ICamera> c = mCamera; + if (c == 0) return; + c->releaseRecordingFrame(mem); +} + // get preview state bool Camera::previewEnabled() { @@ -202,6 +231,15 @@ bool Camera::previewEnabled() return c->previewEnabled(); } +// get recording state +bool Camera::recordingEnabled() +{ + LOGV("recordingEnabled"); + sp <ICamera> c = mCamera; + if (c == 0) return false; + return c->recordingEnabled(); +} + status_t Camera::autoFocus() { LOGV("autoFocus"); @@ -266,14 +304,21 @@ void Camera::setJpegCallback(frame_callback cb, void *cookie) mJpegCallbackCookie = cookie; } -void Camera::setFrameCallback(frame_callback cb, void *cookie, int frame_callback_flag) +void Camera::setPreviewCallback(frame_callback cb, void *cookie, int flag) { - LOGV("setFrameCallback"); - mFrameCallback = cb; - mFrameCallbackCookie = cookie; + LOGV("setPreviewCallback"); + mPreviewCallback = cb; + mPreviewCallbackCookie = cookie; sp <ICamera> c = mCamera; if (c == 0) return; - mCamera->setFrameCallbackFlag(frame_callback_flag); + mCamera->setPreviewCallbackFlag(flag); +} + +void Camera::setRecordingCallback(frame_callback cb, void *cookie) +{ + LOGV("setRecordingCallback"); + mRecordingCallback = cb; + mRecordingCallbackCookie = cookie; } void Camera::setErrorCallback(error_callback cb, void *cookie) @@ -316,12 +361,21 @@ void Camera::jpegCallback(const sp<IMemory>& picture) } } -// callback from camera service when video frame is ready -void Camera::frameCallback(const sp<IMemory>& frame) +// callback from camera service when preview frame is ready +void Camera::previewCallback(const sp<IMemory>& frame) { LOGV("frameCallback"); - if (mFrameCallback) { - mFrameCallback(frame, mFrameCallbackCookie); + if (mPreviewCallback) { + mPreviewCallback(frame, mPreviewCallbackCookie); + } +} + +// callback from camera service when a recording frame is ready +void Camera::recordingCallback(const sp<IMemory>& frame) +{ + LOGV("recordingCallback"); + if (mRecordingCallback) { + mRecordingCallback(frame, mRecordingCallbackCookie); } } diff --git a/libs/ui/CameraParameters.cpp b/libs/ui/CameraParameters.cpp index 7ca77bb..6c25836 100644 --- a/libs/ui/CameraParameters.cpp +++ b/libs/ui/CameraParameters.cpp @@ -24,6 +24,9 @@ namespace android { +static const char* portrait = "portrait"; +static const char* landscape = "landscape"; + CameraParameters::CameraParameters() : mMap() { @@ -182,6 +185,23 @@ void CameraParameters::setPreviewFormat(const char *format) set("preview-format", format); } +int CameraParameters::getOrientation() const +{ + const char* orientation = get("orientation"); + if (orientation && !strcmp(orientation, portrait)) + return CAMERA_ORIENTATION_PORTRAIT; + return CAMERA_ORIENTATION_LANDSCAPE; +} + +void CameraParameters::setOrientation(int orientation) +{ + if (orientation == CAMERA_ORIENTATION_PORTRAIT) { + set("preview-format", portrait); + } else { + set("preview-format", landscape); + } +} + const char *CameraParameters::getPreviewFormat() const { return get("preview-format"); diff --git a/libs/ui/EGLDisplaySurface.cpp b/libs/ui/EGLDisplaySurface.cpp index 44258a8..d06c98b 100644 --- a/libs/ui/EGLDisplaySurface.cpp +++ b/libs/ui/EGLDisplaySurface.cpp @@ -42,7 +42,7 @@ #include <linux/msm_mdp.h> #endif -#include <GLES/egl.h> +#include <EGL/egl.h> #include <pixelflinger/format.h> @@ -71,8 +71,6 @@ EGLDisplaySurface::EGLDisplaySurface() egl_native_window_t::incRef = &EGLDisplaySurface::hook_incRef; egl_native_window_t::decRef = &EGLDisplaySurface::hook_decRef; egl_native_window_t::swapBuffers = &EGLDisplaySurface::hook_swapBuffers; - egl_native_window_t::setSwapRectangle = &EGLDisplaySurface::hook_setSwapRectangle; - egl_native_window_t::nextBuffer = &EGLDisplaySurface::hook_nextBuffer; egl_native_window_t::connect = 0; egl_native_window_t::disconnect = 0; @@ -136,15 +134,6 @@ uint32_t EGLDisplaySurface::hook_swapBuffers(NativeWindowType window) { EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window); return that->swapBuffers(); } -uint32_t EGLDisplaySurface::hook_nextBuffer(NativeWindowType window) { - EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window); - return that->nextBuffer(); -} -void EGLDisplaySurface::hook_setSwapRectangle(NativeWindowType window, - int l, int t, int w, int h) { - EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window); - that->setSwapRectangle(l, t, w, h); -} void EGLDisplaySurface::setSwapRectangle(int l, int t, int w, int h) { @@ -249,15 +238,6 @@ int32_t EGLDisplaySurface::getPageFlipCount() const return mPageFlipCount; } -uint32_t EGLDisplaySurface::nextBuffer() -{ - // update the address of the buffer to draw to next - const GGLSurface& buffer = mFb[mIndex]; - egl_native_window_t::offset = - intptr_t(buffer.data) - egl_native_window_t::base; - return 0; -} - void EGLDisplaySurface::copyFrontToBack(const Region& copyback) { #if HAVE_ANDROID_OS @@ -318,6 +298,59 @@ void EGLDisplaySurface::copyFrontToBack(const Region& copyback) } } +void EGLDisplaySurface::copyFrontToImage(const copybit_image_t& dst) +{ +#if HAVE_ANDROID_OS + if (mBlitEngine) { + copybit_image_t src = { + w: egl_native_window_t::stride, + h: egl_native_window_t::height, + format: egl_native_window_t::format, + offset: mFb[mIndex].data - mFb[0].data, + base: (void*)egl_native_window_t::base, + fd: egl_native_window_t::fd + }; + region_iterator it(Region(Rect( + egl_native_window_t::width, egl_native_window_t::height))); + mBlitEngine->blit(mBlitEngine, &dst, &src, &it); + } else +#endif + { + uint8_t* const screen_src = mFb[ mIndex].data; + const size_t bpp = bytesPerPixel(egl_native_window_t::format); + const size_t bpr = egl_native_window_t::stride * bpp; + memcpy((char*)dst.base + dst.offset, screen_src, + bpr*egl_native_window_t::height); + } +} + +void EGLDisplaySurface::copyBackToImage(const copybit_image_t& dst) +{ +#if HAVE_ANDROID_OS + if (mBlitEngine) { + copybit_image_t src = { + w: egl_native_window_t::stride, + h: egl_native_window_t::height, + format: egl_native_window_t::format, + offset: mFb[1-mIndex].data - mFb[0].data, + base: (void*)egl_native_window_t::base, + fd: egl_native_window_t::fd + }; + region_iterator it(Region(Rect( + egl_native_window_t::width, egl_native_window_t::height))); + mBlitEngine->blit(mBlitEngine, &dst, &src, &it); + } else +#endif + { + uint8_t* const screen_src = mFb[1-mIndex].data; + const size_t bpp = bytesPerPixel(egl_native_window_t::format); + const size_t bpr = egl_native_window_t::stride * bpp; + memcpy((char*)dst.base + dst.offset, screen_src, + bpr*egl_native_window_t::height); + } +} + + status_t EGLDisplaySurface::mapFrameBuffer() { char const * const device_template[] = { diff --git a/libs/ui/EGLNativeWindowSurface.cpp b/libs/ui/EGLNativeWindowSurface.cpp index d55fb70..f1071cf 100644 --- a/libs/ui/EGLNativeWindowSurface.cpp +++ b/libs/ui/EGLNativeWindowSurface.cpp @@ -28,7 +28,7 @@ #include <ui/DisplayInfo.h> #include <ui/Rect.h> -#include <GLES/egl.h> +#include <EGL/egl.h> #include <pixelflinger/format.h> @@ -48,8 +48,6 @@ EGLNativeWindowSurface::EGLNativeWindowSurface(const sp<Surface>& surface) egl_native_window_t::incRef = &EGLNativeWindowSurface::hook_incRef; egl_native_window_t::decRef = &EGLNativeWindowSurface::hook_decRef; egl_native_window_t::swapBuffers = &EGLNativeWindowSurface::hook_swapBuffers; - egl_native_window_t::nextBuffer = &EGLNativeWindowSurface::hook_nextBuffer; - egl_native_window_t::setSwapRectangle = &EGLNativeWindowSurface::hook_setSwapRectangle; egl_native_window_t::connect = &EGLNativeWindowSurface::hook_connect; egl_native_window_t::disconnect = &EGLNativeWindowSurface::hook_disconnect; @@ -98,18 +96,6 @@ uint32_t EGLNativeWindowSurface::hook_swapBuffers(NativeWindowType window) return that->swapBuffers(); } -uint32_t EGLNativeWindowSurface::hook_nextBuffer(NativeWindowType window) -{ - EGLNativeWindowSurface* that = static_cast<EGLNativeWindowSurface*>(window); - return that->nextBuffer(); -} - -void EGLNativeWindowSurface::hook_setSwapRectangle(NativeWindowType window, int l, int t, int w, int h) -{ - EGLNativeWindowSurface* that = static_cast<EGLNativeWindowSurface*>(window); - that->setSwapRectangle(l, t, w, h); -} - void EGLNativeWindowSurface::setSwapRectangle(int l, int t, int w, int h) { mSurface->setSwapRectangle(Rect(l, t, l+w, t+h)); @@ -138,17 +124,6 @@ uint32_t EGLNativeWindowSurface::swapBuffers() return 0; } -uint32_t EGLNativeWindowSurface::nextBuffer() -{ - const sp<Surface>& surface(mSurface); - Surface::SurfaceInfo info; - surface->nextBuffer(&info); - // update the address of the buffer to draw to next - egl_native_window_t::base = intptr_t(info.base); - egl_native_window_t::offset = intptr_t(info.bits) - intptr_t(info.base); - return 0; -} - void EGLNativeWindowSurface::connect() { if (!mConnected) { diff --git a/libs/ui/EventHub.cpp b/libs/ui/EventHub.cpp index 700aa3a..3b29b09 100644 --- a/libs/ui/EventHub.cpp +++ b/libs/ui/EventHub.cpp @@ -71,10 +71,11 @@ static inline int max(int v1, int v2) EventHub::device_t::device_t(int32_t _id, const char* _path) : id(_id), path(_path), classes(0) - , layoutMap(new KeyLayoutMap()), next(NULL) { + , keyBitmask(NULL), layoutMap(new KeyLayoutMap()), next(NULL) { } EventHub::device_t::~device_t() { + delete [] keyBitmask; delete layoutMap; } @@ -403,6 +404,36 @@ bool EventHub::openPlatformInput(void) return true; } +/* + * Inspect the known devices to determine whether physical keys exist for the given + * framework-domain key codes. + */ +bool EventHub::hasKeys(size_t numCodes, int32_t* keyCodes, uint8_t* outFlags) { + for (size_t codeIndex = 0; codeIndex < numCodes; codeIndex++) { + outFlags[codeIndex] = 0; + + // check each available hardware device for support for this keycode + Vector<int32_t> scanCodes; + for (int n = 0; (n < mFDCount) && (outFlags[codeIndex] == 0); n++) { + if (mDevices[n]) { + status_t err = mDevices[n]->layoutMap->findScancodes(keyCodes[codeIndex], &scanCodes); + if (!err) { + // check the possible scan codes identified by the layout map against the + // map of codes actually emitted by the driver + for (size_t sc = 0; sc < scanCodes.size(); sc++) { + if (test_bit(scanCodes[sc], mDevices[n]->keyBitmask)) { + outFlags[codeIndex] = 1; + break; + } + } + } + } + } + } + + return true; +} + // ---------------------------------------------------------------------------- int EventHub::open_device(const char *deviceName) @@ -527,6 +558,16 @@ int EventHub::open_device(const char *deviceName) break; } } + if ((device->classes & CLASS_KEYBOARD) != 0) { + device->keyBitmask = new uint8_t[(KEY_MAX+1)/8]; + if (device->keyBitmask != NULL) { + memcpy(device->keyBitmask, key_bitmask, sizeof(key_bitmask)); + } else { + delete device; + LOGE("out of memory allocating key bitmask"); + return -1; + } + } } if (test_bit(BTN_MOUSE, key_bitmask)) { uint8_t rel_bitmask[(REL_MAX+1)/8]; diff --git a/libs/ui/ICamera.cpp b/libs/ui/ICamera.cpp index 7b0922e..ab0fef1 100644 --- a/libs/ui/ICamera.cpp +++ b/libs/ui/ICamera.cpp @@ -28,7 +28,7 @@ namespace android { enum { DISCONNECT = IBinder::FIRST_CALL_TRANSACTION, SET_PREVIEW_DISPLAY, - SET_FRAME_CALLBACK_FLAG, + SET_PREVIEW_CALLBACK_FLAG, START_PREVIEW, STOP_PREVIEW, AUTO_FOCUS, @@ -38,7 +38,11 @@ enum { CONNECT, LOCK, UNLOCK, - PREVIEW_ENABLED + PREVIEW_ENABLED, + START_RECORDING, + STOP_RECORDING, + RECORDING_ENABLED, + RELEASE_RECORDING_FRAME, }; class BpCamera: public BpInterface<ICamera> @@ -69,15 +73,15 @@ public: return reply.readInt32(); } - // set the frame callback flag to affect how the received frames from - // preview are handled. - void setFrameCallbackFlag(int frame_callback_flag) + // set the preview callback flag to affect how the received frames from + // preview are handled. See Camera.h for details. + void setPreviewCallbackFlag(int flag) { - LOGV("setFrameCallbackFlag(%d)", frame_callback_flag); + LOGV("setPreviewCallbackFlag(%d)", flag); Parcel data, reply; data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); - data.writeInt32(frame_callback_flag); - remote()->transact(SET_FRAME_CALLBACK_FLAG, data, &reply); + data.writeInt32(flag); + remote()->transact(SET_PREVIEW_CALLBACK_FLAG, data, &reply); } // start preview mode, must call setPreviewDisplay first @@ -90,6 +94,16 @@ public: return reply.readInt32(); } + // start recording mode, must call setPreviewDisplay first + status_t startRecording() + { + LOGV("startRecording"); + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + remote()->transact(START_RECORDING, data, &reply); + return reply.readInt32(); + } + // stop preview mode void stopPreview() { @@ -99,6 +113,24 @@ public: remote()->transact(STOP_PREVIEW, data, &reply); } + // stop recording mode + void stopRecording() + { + LOGV("stopRecording"); + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + remote()->transact(STOP_RECORDING, data, &reply); + } + + void releaseRecordingFrame(const sp<IMemory>& mem) + { + LOGV("releaseRecordingFrame"); + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + data.writeStrongBinder(mem->asBinder()); + remote()->transact(RELEASE_RECORDING_FRAME, data, &reply); + } + // check preview state bool previewEnabled() { @@ -109,6 +141,16 @@ public: return reply.readInt32(); } + // check recording state + bool recordingEnabled() + { + LOGV("recordingEnabled"); + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + remote()->transact(RECORDING_ENABLED, data, &reply); + return reply.readInt32(); + } + // auto focus status_t autoFocus() { @@ -202,11 +244,11 @@ status_t BnCamera::onTransact( reply->writeInt32(setPreviewDisplay(surface)); return NO_ERROR; } break; - case SET_FRAME_CALLBACK_FLAG: { - LOGV("SET_FRAME_CALLBACK_TYPE"); + case SET_PREVIEW_CALLBACK_FLAG: { + LOGV("SET_PREVIEW_CALLBACK_TYPE"); CHECK_INTERFACE(ICamera, data, reply); - int frame_callback_flag = data.readInt32(); - setFrameCallbackFlag(frame_callback_flag); + int callback_flag = data.readInt32(); + setPreviewCallbackFlag(callback_flag); return NO_ERROR; } break; case START_PREVIEW: { @@ -215,18 +257,43 @@ status_t BnCamera::onTransact( reply->writeInt32(startPreview()); return NO_ERROR; } break; + case START_RECORDING: { + LOGV("START_RECORDING"); + CHECK_INTERFACE(ICamera, data, reply); + reply->writeInt32(startRecording()); + return NO_ERROR; + } break; case STOP_PREVIEW: { LOGV("STOP_PREVIEW"); CHECK_INTERFACE(ICamera, data, reply); stopPreview(); return NO_ERROR; } break; + case STOP_RECORDING: { + LOGV("STOP_RECORDING"); + CHECK_INTERFACE(ICamera, data, reply); + stopRecording(); + return NO_ERROR; + } break; + case RELEASE_RECORDING_FRAME: { + LOGV("RELEASE_RECORDING_FRAME"); + CHECK_INTERFACE(ICamera, data, reply); + sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder()); + releaseRecordingFrame(mem); + return NO_ERROR; + } break; case PREVIEW_ENABLED: { LOGV("PREVIEW_ENABLED"); CHECK_INTERFACE(ICamera, data, reply); reply->writeInt32(previewEnabled()); return NO_ERROR; } break; + case RECORDING_ENABLED: { + LOGV("RECORDING_ENABLED"); + CHECK_INTERFACE(ICamera, data, reply); + reply->writeInt32(recordingEnabled()); + return NO_ERROR; + } break; case AUTO_FOCUS: { LOGV("AUTO_FOCUS"); CHECK_INTERFACE(ICamera, data, reply); diff --git a/libs/ui/ICameraClient.cpp b/libs/ui/ICameraClient.cpp index c5d6d52..4bec9d2 100644 --- a/libs/ui/ICameraClient.cpp +++ b/libs/ui/ICameraClient.cpp @@ -28,9 +28,10 @@ enum { SHUTTER_CALLBACK = IBinder::FIRST_CALL_TRANSACTION, RAW_CALLBACK, JPEG_CALLBACK, - FRAME_CALLBACK, + PREVIEW_CALLBACK, ERROR_CALLBACK, - AUTOFOCUS_CALLBACK + AUTOFOCUS_CALLBACK, + RECORDING_CALLBACK, }; class BpCameraClient: public BpInterface<ICameraClient> @@ -70,14 +71,24 @@ public: remote()->transact(JPEG_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY); } - // callback from camera service to app with video frame data - void frameCallback(const sp<IMemory>& frame) + // callback from camera service to app with preview frame data + void previewCallback(const sp<IMemory>& frame) { - LOGV("frameCallback"); + LOGV("previewCallback"); Parcel data, reply; data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor()); data.writeStrongBinder(frame->asBinder()); - remote()->transact(FRAME_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY); + remote()->transact(PREVIEW_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY); + } + + // callback from camera service to app with recording frame data + void recordingCallback(const sp<IMemory>& frame) + { + LOGV("recordingCallback"); + Parcel data, reply; + data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor()); + data.writeStrongBinder(frame->asBinder()); + remote()->transact(RECORDING_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY); } // callback from camera service to app to report error @@ -135,11 +146,18 @@ status_t BnCameraClient::onTransact( jpegCallback(picture); return NO_ERROR; } break; - case FRAME_CALLBACK: { - LOGV("FRAME_CALLBACK"); + case PREVIEW_CALLBACK: { + LOGV("PREVIEW_CALLBACK"); + CHECK_INTERFACE(ICameraClient, data, reply); + sp<IMemory> frame = interface_cast<IMemory>(data.readStrongBinder()); + previewCallback(frame); + return NO_ERROR; + } break; + case RECORDING_CALLBACK: { + LOGV("RECORDING_CALLBACK"); CHECK_INTERFACE(ICameraClient, data, reply); sp<IMemory> frame = interface_cast<IMemory>(data.readStrongBinder()); - frameCallback(frame); + recordingCallback(frame); return NO_ERROR; } break; case ERROR_CALLBACK: { diff --git a/libs/ui/ISurface.cpp b/libs/ui/ISurface.cpp index 6f3cd47..abd3634 100644 --- a/libs/ui/ISurface.cpp +++ b/libs/ui/ISurface.cpp @@ -27,12 +27,33 @@ namespace android { -enum { - REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION, - UNREGISTER_BUFFERS, - POST_BUFFER, // one-way transaction - CREATE_OVERLAY, -}; +ISurface::BufferHeap::BufferHeap() + : w(0), h(0), hor_stride(0), ver_stride(0), format(0), + transform(0), flags(0) +{ +} + +ISurface::BufferHeap::BufferHeap(uint32_t w, uint32_t h, + int32_t hor_stride, int32_t ver_stride, + PixelFormat format, const sp<IMemoryHeap>& heap) + : w(w), h(h), hor_stride(hor_stride), ver_stride(ver_stride), + format(format), heap(heap) +{ +} + +ISurface::BufferHeap::BufferHeap(uint32_t w, uint32_t h, + int32_t hor_stride, int32_t ver_stride, + PixelFormat format, uint32_t transform, uint32_t flags, + const sp<IMemoryHeap>& heap) + : w(w), h(h), hor_stride(hor_stride), ver_stride(ver_stride), + format(format), transform(transform), flags(flags), heap(heap) +{ +} + + +ISurface::BufferHeap::~BufferHeap() +{ +} class BpSurface : public BpInterface<ISurface> { @@ -42,17 +63,18 @@ public: { } - virtual status_t registerBuffers(int w, int h, int hstride, int vstride, - PixelFormat format, const sp<IMemoryHeap>& heap) + virtual status_t registerBuffers(const BufferHeap& buffers) { Parcel data, reply; data.writeInterfaceToken(ISurface::getInterfaceDescriptor()); - data.writeInt32(w); - data.writeInt32(h); - data.writeInt32(hstride); - data.writeInt32(vstride); - data.writeInt32(format); - data.writeStrongBinder(heap->asBinder()); + data.writeInt32(buffers.w); + data.writeInt32(buffers.h); + data.writeInt32(buffers.hor_stride); + data.writeInt32(buffers.ver_stride); + data.writeInt32(buffers.format); + data.writeInt32(buffers.transform); + data.writeInt32(buffers.flags); + data.writeStrongBinder(buffers.heap->asBinder()); remote()->transact(REGISTER_BUFFERS, data, &reply); status_t result = reply.readInt32(); return result; @@ -102,13 +124,16 @@ status_t BnSurface::onTransact( switch(code) { case REGISTER_BUFFERS: { CHECK_INTERFACE(ISurface, data, reply); - int w = data.readInt32(); - int h = data.readInt32(); - int hs= data.readInt32(); - int vs= data.readInt32(); - PixelFormat f = data.readInt32(); - sp<IMemoryHeap> heap(interface_cast<IMemoryHeap>(data.readStrongBinder())); - status_t err = registerBuffers(w,h,hs,vs,f,heap); + BufferHeap buffer; + buffer.w = data.readInt32(); + buffer.h = data.readInt32(); + buffer.hor_stride = data.readInt32(); + buffer.ver_stride= data.readInt32(); + buffer.format = data.readInt32(); + buffer.transform = data.readInt32(); + buffer.flags = data.readInt32(); + buffer.heap = interface_cast<IMemoryHeap>(data.readStrongBinder()); + status_t err = registerBuffers(buffer); reply->writeInt32(err); return NO_ERROR; } break; diff --git a/libs/ui/Overlay.cpp b/libs/ui/Overlay.cpp index c8e6168..b236edc 100644 --- a/libs/ui/Overlay.cpp +++ b/libs/ui/Overlay.cpp @@ -59,6 +59,12 @@ status_t Overlay::queueBuffer(overlay_buffer_t buffer) return mOverlayData->queueBuffer(mOverlayData, buffer); } +int32_t Overlay::getBufferCount() const +{ + if (mStatus != NO_ERROR) return mStatus; + return mOverlayData->getBufferCount(mOverlayData); +} + void* Overlay::getBufferAddress(overlay_buffer_t buffer) { if (mStatus != NO_ERROR) return NULL; diff --git a/libs/ui/PixelFormat.cpp b/libs/ui/PixelFormat.cpp index 605c8ae..b65ed97 100644 --- a/libs/ui/PixelFormat.cpp +++ b/libs/ui/PixelFormat.cpp @@ -19,6 +19,18 @@ namespace android { +size_t PixelFormatInfo::getScanlineSize(unsigned int width) const +{ + size_t size; + if ((components >= 6) && (components <= 8)) { + // YCbCr formats are differents. + size = (width * bitsPerPixel)>>3; + } else { + size = width * bytesPerPixel; + } + return size; +} + ssize_t bytesPerPixel(PixelFormat format) { PixelFormatInfo info; @@ -47,7 +59,25 @@ status_t getPixelFormatInfo(PixelFormat format, PixelFormatInfo* info) if (!valid) { return BAD_INDEX; } - + + #define COMPONENT(name) \ + case GGL_##name: info->components = PixelFormatInfo::name; break; + + switch (i->components) { + COMPONENT(ALPHA) + COMPONENT(RGB) + COMPONENT(RGBA) + COMPONENT(LUMINANCE) + COMPONENT(LUMINANCE_ALPHA) + COMPONENT(Y_CB_CR_SP) + COMPONENT(Y_CB_CR_P) + COMPONENT(Y_CB_CR_I) + default: + return BAD_INDEX; + } + + #undef COMPONENT + info->format = format; info->bytesPerPixel = i->size; info->bitsPerPixel = i->bitsPerPixel; @@ -59,6 +89,7 @@ status_t getPixelFormatInfo(PixelFormat format, PixelFormatInfo* info) info->l_green = i->gl; info->h_blue = i->bh; info->l_blue = i->bl; + return NO_ERROR; } |