diff options
author | Mathias Agopian <mathias@google.com> | 2010-12-07 19:38:17 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-12-08 16:13:59 -0800 |
commit | a5529c8778c2f407f482fc12165aeb76c0f505c2 (patch) | |
tree | ffa08b15bbbaa2436d60e4d00cfae6cbcc3d8a82 | |
parent | 4eaf95afa47c8d7ce2b2928bc297572bf6a711d5 (diff) | |
download | frameworks_native-a5529c8778c2f407f482fc12165aeb76c0f505c2.zip frameworks_native-a5529c8778c2f407f482fc12165aeb76c0f505c2.tar.gz frameworks_native-a5529c8778c2f407f482fc12165aeb76c0f505c2.tar.bz2 |
remove support for PUSH_BUFFER surfaces and overlays
the same functionality is now supported through
the h/w composer HAL, and YUV support in the GPU.
Change-Id: I8146605449954b8e8fd7f78810b7d873c2d8f5bf
21 files changed, 6 insertions, 1713 deletions
diff --git a/include/surfaceflinger/ISurface.h b/include/surfaceflinger/ISurface.h index ddbe03d..cd0ee40 100644 --- a/include/surfaceflinger/ISurface.h +++ b/include/surfaceflinger/ISurface.h @@ -34,18 +34,15 @@ namespace android { typedef int32_t SurfaceID; -class IMemoryHeap; -class OverlayRef; class GraphicBuffer; class ISurface : public IInterface { protected: enum { - REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION, - UNREGISTER_BUFFERS, - POST_BUFFER, // one-way transaction - CREATE_OVERLAY, + RESERVED0 = IBinder::FIRST_CALL_TRANSACTION, + RESERVED1, + RESERVED2, REQUEST_BUFFER, SET_BUFFER_COUNT, }; @@ -66,49 +63,6 @@ public: * sets the number of buffers dequeuable for this surface. */ virtual status_t setBufferCount(int bufferCount) = 0; - - // ------------------------------------------------------------------------ - // Deprecated... - // ------------------------------------------------------------------------ - - class BufferHeap { - public: - enum { - /* rotate source image */ - ROT_0 = 0, - ROT_90 = HAL_TRANSFORM_ROT_90, - ROT_180 = HAL_TRANSFORM_ROT_180, - ROT_270 = HAL_TRANSFORM_ROT_270, - }; - BufferHeap(); - - BufferHeap(uint32_t w, uint32_t h, - int32_t hor_stride, int32_t ver_stride, - PixelFormat format, const sp<IMemoryHeap>& heap); - - 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); - - ~BufferHeap(); - - uint32_t w; - uint32_t h; - int32_t hor_stride; - int32_t ver_stride; - PixelFormat format; - uint32_t transform; - uint32_t flags; - sp<IMemoryHeap> heap; - }; - - virtual status_t registerBuffers(const BufferHeap& buffers) = 0; - virtual void postBuffer(ssize_t offset) = 0; // one-way - virtual void unregisterBuffers() = 0; - - virtual sp<OverlayRef> createOverlay( - uint32_t w, uint32_t h, int32_t format, int32_t orientation) = 0; }; // ---------------------------------------------------------------------------- diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h index db57859..382cbda 100644 --- a/include/surfaceflinger/ISurfaceComposer.h +++ b/include/surfaceflinger/ISurfaceComposer.h @@ -42,7 +42,6 @@ public: eDestroyBackbuffer = 0x00000020, eSecure = 0x00000080, eNonPremultiplied = 0x00000100, - ePushBuffers = 0x00000200, eOpaque = 0x00000400, eFXSurfaceNormal = 0x00000000, diff --git a/include/ui/IOverlay.h b/include/ui/IOverlay.h deleted file mode 100644 index af3add1..0000000 --- a/include/ui/IOverlay.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_IOVERLAY_H -#define ANDROID_IOVERLAY_H - -#include <stdint.h> -#include <sys/types.h> - -#include <utils/Errors.h> -#include <binder/IInterface.h> -#include <utils/RefBase.h> -#include <ui/PixelFormat.h> - -namespace android { - -class IOverlay : public IInterface -{ -public: - DECLARE_META_INTERFACE(Overlay); - - virtual void destroy() = 0; // one-way -}; - -// ---------------------------------------------------------------------------- - -class BnOverlay : public BnInterface<IOverlay> -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IOVERLAY_H diff --git a/include/ui/Overlay.h b/include/ui/Overlay.h deleted file mode 100644 index a9ae1c4..0000000 --- a/include/ui/Overlay.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_OVERLAY_H -#define ANDROID_OVERLAY_H - -#include <stdint.h> -#include <sys/types.h> - -#include <utils/Errors.h> -#include <binder/IInterface.h> -#include <utils/RefBase.h> -#include <utils/threads.h> - -#include <ui/PixelFormat.h> -#include <ui/IOverlay.h> - -#include <hardware/overlay.h> - -namespace android { - -class IMemory; -class IMemoryHeap; - -// ---------------------------------------------------------------------------- - -class OverlayRef : public LightRefBase<OverlayRef> -{ -public: - OverlayRef(overlay_handle_t, const sp<IOverlay>&, - uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs); - - static sp<OverlayRef> readFromParcel(const Parcel& data); - static status_t writeToParcel(Parcel* reply, const sp<OverlayRef>& o); - -private: - friend class LightRefBase<OverlayRef>; - friend class Overlay; - - OverlayRef(); - virtual ~OverlayRef(); - - overlay_handle_t mOverlayHandle; - sp<IOverlay> mOverlayChannel; - uint32_t mWidth; - uint32_t mHeight; - int32_t mFormat; - int32_t mWidthStride; - int32_t mHeightStride; - bool mOwnHandle; -}; - -// ---------------------------------------------------------------------------- - -class Overlay : public virtual RefBase -{ -public: - Overlay(const sp<OverlayRef>& overlayRef); - - /* destroys this overlay */ - void destroy(); - - /* get the HAL handle for this overlay */ - overlay_handle_t getHandleRef() const; - - /* blocks until an overlay buffer is available and return that buffer. */ - status_t dequeueBuffer(overlay_buffer_t* buffer); - - /* release the overlay buffer and post it */ - status_t queueBuffer(overlay_buffer_t buffer); - - /* change the width and height of the overlay */ - status_t resizeInput(uint32_t width, uint32_t height); - - status_t setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h) ; - - status_t getCrop(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h) ; - - /* set the buffer attributes */ - status_t setParameter(int param, int value); - - /* returns the address of a given buffer if supported, NULL otherwise. */ - void* getBufferAddress(overlay_buffer_t buffer); - - /* get physical informations about the overlay */ - uint32_t getWidth() const; - uint32_t getHeight() const; - int32_t getFormat() const; - int32_t getWidthStride() const; - int32_t getHeightStride() const; - int32_t getBufferCount() const; - status_t getStatus() const; - -private: - virtual ~Overlay(); - - sp<OverlayRef> mOverlayRef; - overlay_data_device_t *mOverlayData; - status_t mStatus; -}; - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_OVERLAY_H diff --git a/libs/surfaceflinger_client/ISurface.cpp b/libs/surfaceflinger_client/ISurface.cpp index 7049d9e..23b90af 100644 --- a/libs/surfaceflinger_client/ISurface.cpp +++ b/libs/surfaceflinger_client/ISurface.cpp @@ -21,9 +21,7 @@ #include <sys/types.h> #include <binder/Parcel.h> -#include <binder/IMemory.h> -#include <ui/Overlay.h> #include <ui/GraphicBuffer.h> #include <surfaceflinger/Surface.h> @@ -33,36 +31,6 @@ namespace android { // ---------------------------------------------------------------------- -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), transform(0), flags(0), 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> { public: @@ -96,51 +64,6 @@ public: status_t err = reply.readInt32(); return err; } - - virtual status_t registerBuffers(const BufferHeap& buffers) - { - Parcel data, reply; - data.writeInterfaceToken(ISurface::getInterfaceDescriptor()); - 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; - } - - virtual void postBuffer(ssize_t offset) - { - Parcel data, reply; - data.writeInterfaceToken(ISurface::getInterfaceDescriptor()); - data.writeInt32(offset); - remote()->transact(POST_BUFFER, data, &reply, IBinder::FLAG_ONEWAY); - } - - virtual void unregisterBuffers() - { - Parcel data, reply; - data.writeInterfaceToken(ISurface::getInterfaceDescriptor()); - remote()->transact(UNREGISTER_BUFFERS, data, &reply); - } - - virtual sp<OverlayRef> createOverlay( - uint32_t w, uint32_t h, int32_t format, int32_t orientation) - { - Parcel data, reply; - data.writeInterfaceToken(ISurface::getInterfaceDescriptor()); - data.writeInt32(w); - data.writeInt32(h); - data.writeInt32(format); - data.writeInt32(orientation); - remote()->transact(CREATE_OVERLAY, data, &reply); - return OverlayRef::readFromParcel(reply); - } }; IMPLEMENT_META_INTERFACE(Surface, "android.ui.ISurface"); @@ -170,41 +93,6 @@ status_t BnSurface::onTransact( reply->writeInt32(err); return NO_ERROR; } - case REGISTER_BUFFERS: { - CHECK_INTERFACE(ISurface, data, reply); - 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; - case UNREGISTER_BUFFERS: { - CHECK_INTERFACE(ISurface, data, reply); - unregisterBuffers(); - return NO_ERROR; - } break; - case POST_BUFFER: { - CHECK_INTERFACE(ISurface, data, reply); - ssize_t offset = data.readInt32(); - postBuffer(offset); - return NO_ERROR; - } break; - case CREATE_OVERLAY: { - CHECK_INTERFACE(ISurface, data, reply); - int w = data.readInt32(); - int h = data.readInt32(); - int f = data.readInt32(); - int orientation = data.readInt32(); - sp<OverlayRef> o = createOverlay(w, h, f, orientation); - return OverlayRef::writeToParcel(reply, o); - } break; default: return BBinder::onTransact(code, data, reply, flags); } diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk index d0e041a..4ba8b5b 100644 --- a/libs/ui/Android.mk +++ b/libs/ui/Android.mk @@ -54,8 +54,6 @@ LOCAL_SRC_FILES:= \ InputManager.cpp \ InputReader.cpp \ InputTransport.cpp \ - IOverlay.cpp \ - Overlay.cpp \ PixelFormat.cpp \ Rect.cpp \ Region.cpp @@ -64,7 +62,6 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libutils \ libEGL \ - libbinder \ libpixelflinger \ libhardware \ libhardware_legacy diff --git a/libs/ui/IOverlay.cpp b/libs/ui/IOverlay.cpp deleted file mode 100644 index 65e6b4f..0000000 --- a/libs/ui/IOverlay.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <stdio.h> -#include <stdint.h> -#include <sys/types.h> - -#include <binder/Parcel.h> -#include <binder/IInterface.h> - -#include <ui/IOverlay.h> - -namespace android { - -enum { - DESTROY = IBinder::FIRST_CALL_TRANSACTION, // one-way transaction -}; - -class BpOverlay : public BpInterface<IOverlay> -{ -public: - BpOverlay(const sp<IBinder>& impl) - : BpInterface<IOverlay>(impl) - { - } - - virtual void destroy() - { - Parcel data, reply; - data.writeInterfaceToken(IOverlay::getInterfaceDescriptor()); - remote()->transact(DESTROY, data, &reply, IBinder::FLAG_ONEWAY); - } -}; - -IMPLEMENT_META_INTERFACE(Overlay, "android.ui.IOverlay"); - -// ---------------------------------------------------------------------- - -status_t BnOverlay::onTransact( - uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) -{ - switch(code) { - case DESTROY: { - CHECK_INTERFACE(IOverlay, data, reply); - destroy(); - return NO_ERROR; - } break; - default: - return BBinder::onTransact(code, data, reply, flags); - } -} - -}; // namespace android diff --git a/libs/ui/Overlay.cpp b/libs/ui/Overlay.cpp deleted file mode 100644 index b082c53..0000000 --- a/libs/ui/Overlay.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <binder/IMemory.h> -#include <binder/Parcel.h> -#include <utils/Errors.h> -#include <binder/MemoryHeapBase.h> - -#include <ui/IOverlay.h> -#include <ui/Overlay.h> - -#include <hardware/overlay.h> - -namespace android { - -Overlay::Overlay(const sp<OverlayRef>& overlayRef) - : mOverlayRef(overlayRef), mOverlayData(0), mStatus(NO_INIT) -{ - mOverlayData = NULL; - hw_module_t const* module; - if (overlayRef != 0) { - 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() { - if (mOverlayData) { - overlay_data_close(mOverlayData); - } -} - -status_t Overlay::dequeueBuffer(overlay_buffer_t* buffer) -{ - if (mStatus != NO_ERROR) return mStatus; - return mOverlayData->dequeueBuffer(mOverlayData, buffer); -} - -status_t Overlay::queueBuffer(overlay_buffer_t buffer) -{ - if (mStatus != NO_ERROR) return mStatus; - return mOverlayData->queueBuffer(mOverlayData, buffer); -} - -status_t Overlay::resizeInput(uint32_t width, uint32_t height) -{ - if (mStatus != NO_ERROR) return mStatus; - return mOverlayData->resizeInput(mOverlayData, width, height); -} - -status_t Overlay::setParameter(int param, int value) -{ - if (mStatus != NO_ERROR) return mStatus; - return mOverlayData->setParameter(mOverlayData, param, value); -} - -status_t Overlay::setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h) -{ - if (mStatus != NO_ERROR) return mStatus; - return mOverlayData->setCrop(mOverlayData, x, y, w, h); -} - -status_t Overlay::getCrop(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h) -{ - if (mStatus != NO_ERROR) return mStatus; - return mOverlayData->getCrop(mOverlayData, x, y, w, h); -} - -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; - return mOverlayData->getBufferAddress(mOverlayData, buffer); -} - -void Overlay::destroy() { - - // Must delete the objects in reverse creation order, thus the - // data side must be closed first and then the destroy send to - // the control side. - if (mOverlayData) { - overlay_data_close(mOverlayData); - mOverlayData = NULL; - } else { - LOGD("Overlay::destroy mOverlayData is NULL"); - } - - if (mOverlayRef != 0) { - mOverlayRef->mOverlayChannel->destroy(); - } else { - LOGD("Overlay::destroy mOverlayRef is NULL"); - } -} - -status_t Overlay::getStatus() const { - return mStatus; -} - -overlay_handle_t Overlay::getHandleRef() const { - if (mStatus != NO_ERROR) return NULL; - return mOverlayRef->mOverlayHandle; -} - -uint32_t Overlay::getWidth() const { - if (mStatus != NO_ERROR) return 0; - return mOverlayRef->mWidth; -} - -uint32_t Overlay::getHeight() const { - if (mStatus != NO_ERROR) return 0; - return mOverlayRef->mHeight; -} - -int32_t Overlay::getFormat() const { - if (mStatus != NO_ERROR) return -1; - return mOverlayRef->mFormat; -} - -int32_t Overlay::getWidthStride() const { - if (mStatus != NO_ERROR) return 0; - return mOverlayRef->mWidthStride; -} - -int32_t Overlay::getHeightStride() const { - if (mStatus != NO_ERROR) return 0; - return mOverlayRef->mHeightStride; -} -// ---------------------------------------------------------------------------- - -OverlayRef::OverlayRef() - : mOverlayHandle(0), - mWidth(0), mHeight(0), mFormat(0), mWidthStride(0), mHeightStride(0), - mOwnHandle(true) -{ -} - -OverlayRef::OverlayRef(overlay_handle_t handle, const sp<IOverlay>& channel, - uint32_t w, uint32_t h, int32_t f, uint32_t ws, uint32_t hs) - : mOverlayHandle(handle), mOverlayChannel(channel), - mWidth(w), mHeight(h), mFormat(f), mWidthStride(ws), mHeightStride(hs), - mOwnHandle(false) -{ -} - -OverlayRef::~OverlayRef() -{ - if (mOwnHandle) { - native_handle_close(mOverlayHandle); - native_handle_delete(const_cast<native_handle*>(mOverlayHandle)); - } -} - -sp<OverlayRef> OverlayRef::readFromParcel(const Parcel& data) { - sp<OverlayRef> result; - sp<IOverlay> overlay = IOverlay::asInterface(data.readStrongBinder()); - if (overlay != NULL) { - uint32_t w = data.readInt32(); - uint32_t h = data.readInt32(); - uint32_t f = data.readInt32(); - uint32_t ws = data.readInt32(); - uint32_t hs = data.readInt32(); - native_handle* handle = data.readNativeHandle(); - - result = new OverlayRef(); - result->mOverlayHandle = handle; - result->mOverlayChannel = overlay; - result->mWidth = w; - result->mHeight = h; - result->mFormat = f; - result->mWidthStride = ws; - result->mHeightStride = hs; - } - return result; -} - -status_t OverlayRef::writeToParcel(Parcel* reply, const sp<OverlayRef>& o) { - if (o != NULL) { - reply->writeStrongBinder(o->mOverlayChannel->asBinder()); - reply->writeInt32(o->mWidth); - reply->writeInt32(o->mHeight); - reply->writeInt32(o->mFormat); - reply->writeInt32(o->mWidthStride); - reply->writeInt32(o->mHeightStride); - reply->writeNativeHandle(o->mOverlayHandle); - } else { - reply->writeStrongBinder(NULL); - } - return NO_ERROR; -} - -// ---------------------------------------------------------------------------- - -}; // namespace android diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 1c2a2c8..3d79e40 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -10,7 +10,6 @@ LOCAL_SRC_FILES:= \ GLExtensions.cpp \ Layer.cpp \ LayerBase.cpp \ - LayerBuffer.cpp \ LayerBlur.cpp \ LayerDim.cpp \ MessageQueue.cpp \ @@ -22,7 +21,7 @@ LOCAL_CFLAGS:= -DLOG_TAG=\"SurfaceFlinger\" LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES ifeq ($(TARGET_BOARD_PLATFORM), omap3) - LOCAL_CFLAGS += -DNO_RGBX_8888 -DHAS_PUSH_BUFFERS + LOCAL_CFLAGS += -DNO_RGBX_8888 endif ifeq ($(TARGET_BOARD_PLATFORM), s5pc110) LOCAL_CFLAGS += -DHAS_CONTEXT_PRIORITY diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp index 58751be..64cff96 100644 --- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp +++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp @@ -36,7 +36,6 @@ #include "DisplayHardware/DisplayHardware.h" -#include <hardware/overlay.h> #include <hardware/gralloc.h> #include "GLExtensions.h" @@ -104,12 +103,6 @@ void DisplayHardware::init(uint32_t dpy) mDpiY = mNativeWindow->ydpi; mRefreshRate = fbDev->fps; - mOverlayEngine = NULL; - hw_module_t const* module; - if (hw_get_module(OVERLAY_HARDWARE_MODULE_ID, &module) == 0) { - overlay_control_open(module, &mOverlayEngine); - } - EGLint w, h, dummy; EGLint numConfigs=0; EGLSurface surface; @@ -296,7 +289,6 @@ void DisplayHardware::fini() { eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglTerminate(mDisplay); - overlay_control_close(mOverlayEngine); } void DisplayHardware::releaseScreen() const diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.h b/services/surfaceflinger/DisplayHardware/DisplayHardware.h index eb71e8b..ee7a2af 100644 --- a/services/surfaceflinger/DisplayHardware/DisplayHardware.h +++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.h @@ -33,8 +33,6 @@ #include "DisplayHardware/DisplayHardwareBase.h" -struct overlay_control_device_t; - namespace android { class FramebufferNativeWindow; @@ -78,7 +76,6 @@ public: uint32_t getPageFlipCount() const; EGLDisplay getEGLDisplay() const { return mDisplay; } - overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; } void dump(String8& res) const; @@ -117,7 +114,6 @@ private: HWComposer* mHwc; sp<FramebufferNativeWindow> mNativeWindow; - overlay_control_device_t* mOverlayEngine; }; }; // namespace android diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp index 28b02c9..8a021cb 100644 --- a/services/surfaceflinger/LayerBase.cpp +++ b/services/surfaceflinger/LayerBase.cpp @@ -610,21 +610,6 @@ sp<LayerBaseClient> LayerBaseClient::Surface::getOwner() const { status_t LayerBaseClient::Surface::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { - switch (code) { - case REGISTER_BUFFERS: - case UNREGISTER_BUFFERS: - case CREATE_OVERLAY: - { - if (!mFlinger->mAccessSurfaceFlinger.checkCalling()) { - IPCThreadState* ipc = IPCThreadState::self(); - const int pid = ipc->getCallingPid(); - const int uid = ipc->getCallingUid(); - LOGE("Permission Denial: " - "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid); - return PERMISSION_DENIED; - } - } - } return BnSurface::onTransact(code, data, reply, flags); } @@ -639,26 +624,6 @@ status_t LayerBaseClient::Surface::setBufferCount(int bufferCount) return INVALID_OPERATION; } -status_t LayerBaseClient::Surface::registerBuffers( - const ISurface::BufferHeap& buffers) -{ - return INVALID_OPERATION; -} - -void LayerBaseClient::Surface::postBuffer(ssize_t offset) -{ -} - -void LayerBaseClient::Surface::unregisterBuffers() -{ -} - -sp<OverlayRef> LayerBaseClient::Surface::createOverlay( - uint32_t w, uint32_t h, int32_t format, int32_t orientation) -{ - return NULL; -}; - // --------------------------------------------------------------------------- }; // namespace android diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h index 135b3a6..f6c49fc 100644 --- a/services/surfaceflinger/LayerBase.h +++ b/services/surfaceflinger/LayerBase.h @@ -27,7 +27,6 @@ #include <utils/RefBase.h> #include <ui/Region.h> -#include <ui/Overlay.h> #include <surfaceflinger/ISurfaceComposerClient.h> #include <private/surfaceflinger/SharedBufferStack.h> @@ -314,12 +313,6 @@ public: uint32_t w, uint32_t h, uint32_t format, uint32_t usage); virtual status_t setBufferCount(int bufferCount); - virtual status_t registerBuffers(const ISurface::BufferHeap& buffers); - virtual void postBuffer(ssize_t offset); - virtual void unregisterBuffers(); - virtual sp<OverlayRef> createOverlay(uint32_t w, uint32_t h, - int32_t format, int32_t orientation); - protected: friend class LayerBaseClient; sp<SurfaceFlinger> mFlinger; diff --git a/services/surfaceflinger/LayerBuffer.cpp b/services/surfaceflinger/LayerBuffer.cpp deleted file mode 100644 index 23506cf..0000000 --- a/services/surfaceflinger/LayerBuffer.cpp +++ /dev/null @@ -1,701 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <stdlib.h> -#include <stdint.h> -#include <math.h> -#include <sys/types.h> - -#include <utils/Errors.h> -#include <utils/Log.h> -#include <utils/StopWatch.h> - -#include <ui/GraphicBuffer.h> -#include <ui/PixelFormat.h> -#include <ui/FramebufferNativeWindow.h> -#include <ui/Rect.h> -#include <ui/Region.h> - -#include <hardware/copybit.h> - -#include "LayerBuffer.h" -#include "SurfaceFlinger.h" -#include "DisplayHardware/DisplayHardware.h" - -namespace android { - -// --------------------------------------------------------------------------- - -gralloc_module_t const* LayerBuffer::sGrallocModule = 0; - -// --------------------------------------------------------------------------- - -LayerBuffer::LayerBuffer(SurfaceFlinger* flinger, DisplayID display, - const sp<Client>& client) - : LayerBaseClient(flinger, display, client), - mNeedsBlending(false), mBlitEngine(0) -{ -} - -LayerBuffer::~LayerBuffer() -{ - if (mBlitEngine) { - copybit_close(mBlitEngine); - } -} - -void LayerBuffer::onFirstRef() -{ - LayerBaseClient::onFirstRef(); - mSurface = new SurfaceLayerBuffer(mFlinger, this); - - hw_module_t const* module = (hw_module_t const*)sGrallocModule; - if (!module) { - // NOTE: technically there is a race here, but it shouldn't - // cause any problem since hw_get_module() always returns - // the same value. - if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { - sGrallocModule = (gralloc_module_t const *)module; - } - } - - if (hw_get_module(COPYBIT_HARDWARE_MODULE_ID, &module) == 0) { - copybit_open(module, &mBlitEngine); - } -} - -sp<LayerBaseClient::Surface> LayerBuffer::createSurface() const -{ - return mSurface; -} - -status_t LayerBuffer::ditch() -{ - mSurface.clear(); - return NO_ERROR; -} - -bool LayerBuffer::needsBlending() const { - return mNeedsBlending; -} - -void LayerBuffer::setNeedsBlending(bool blending) { - mNeedsBlending = blending; -} - -void LayerBuffer::postBuffer(ssize_t offset) -{ - sp<Source> source(getSource()); - if (source != 0) - source->postBuffer(offset); -} - -void LayerBuffer::unregisterBuffers() -{ - sp<Source> source(clearSource()); - if (source != 0) - source->unregisterBuffers(); -} - -uint32_t LayerBuffer::doTransaction(uint32_t flags) -{ - sp<Source> source(getSource()); - if (source != 0) - source->onTransaction(flags); - uint32_t res = LayerBase::doTransaction(flags); - // we always want filtering for these surfaces - mNeedsFiltering = !(mFlags & DisplayHardware::SLOW_CONFIG); - return res; -} - -void LayerBuffer::unlockPageFlip(const Transform& planeTransform, - Region& outDirtyRegion) -{ - // this code-path must be as tight as possible, it's called each time - // the screen is composited. - sp<Source> source(getSource()); - if (source != 0) - source->onVisibilityResolved(planeTransform); - LayerBase::unlockPageFlip(planeTransform, outDirtyRegion); -} - -void LayerBuffer::validateVisibility(const Transform& globalTransform) -{ - sp<Source> source(getSource()); - if (source != 0) - source->onvalidateVisibility(globalTransform); - LayerBase::validateVisibility(globalTransform); -} - -void LayerBuffer::drawForSreenShot() const -{ - const DisplayHardware& hw(graphicPlane(0).displayHardware()); - clearWithOpenGL( Region(hw.bounds()) ); -} - -void LayerBuffer::onDraw(const Region& clip) const -{ - sp<Source> source(getSource()); - if (LIKELY(source != 0)) { - source->onDraw(clip); - } else { - clearWithOpenGL(clip); - } -} - -void LayerBuffer::serverDestroy() -{ - sp<Source> source(clearSource()); - if (source != 0) { - source->destroy(); - } -} - -/** - * This creates a "buffer" source for this surface - */ -status_t LayerBuffer::registerBuffers(const ISurface::BufferHeap& buffers) -{ - Mutex::Autolock _l(mLock); - if (mSource != 0) - return INVALID_OPERATION; - - sp<BufferSource> source = new BufferSource(*this, buffers); - - status_t result = source->getStatus(); - if (result == NO_ERROR) { - mSource = source; - } - return result; -} - -/** - * This creates an "overlay" source for this surface - */ -sp<OverlayRef> LayerBuffer::createOverlay(uint32_t w, uint32_t h, int32_t f, - int32_t orientation) -{ - sp<OverlayRef> result; - Mutex::Autolock _l(mLock); - if (mSource != 0) - return result; - - sp<OverlaySource> source = new OverlaySource(*this, &result, w, h, f, orientation); - if (result != 0) { - mSource = source; - } - return result; -} - -sp<LayerBuffer::Source> LayerBuffer::getSource() const { - Mutex::Autolock _l(mLock); - return mSource; -} - -sp<LayerBuffer::Source> LayerBuffer::clearSource() { - sp<Source> source; - Mutex::Autolock _l(mLock); - source = mSource; - mSource.clear(); - return source; -} - -// ============================================================================ -// LayerBuffer::SurfaceLayerBuffer -// ============================================================================ - -LayerBuffer::SurfaceLayerBuffer::SurfaceLayerBuffer( - const sp<SurfaceFlinger>& flinger, const sp<LayerBuffer>& owner) - : LayerBaseClient::Surface(flinger, owner->getIdentity(), owner) -{ -} - -LayerBuffer::SurfaceLayerBuffer::~SurfaceLayerBuffer() -{ - unregisterBuffers(); -} - -status_t LayerBuffer::SurfaceLayerBuffer::registerBuffers( - const ISurface::BufferHeap& buffers) -{ - sp<LayerBuffer> owner(getOwner()); - if (owner != 0) - return owner->registerBuffers(buffers); - return NO_INIT; -} - -void LayerBuffer::SurfaceLayerBuffer::postBuffer(ssize_t offset) -{ - sp<LayerBuffer> owner(getOwner()); - if (owner != 0) - owner->postBuffer(offset); -} - -void LayerBuffer::SurfaceLayerBuffer::unregisterBuffers() -{ - sp<LayerBuffer> owner(getOwner()); - if (owner != 0) - owner->unregisterBuffers(); -} - -sp<OverlayRef> LayerBuffer::SurfaceLayerBuffer::createOverlay( - uint32_t w, uint32_t h, int32_t format, int32_t orientation) { - sp<OverlayRef> result; - sp<LayerBuffer> owner(getOwner()); - if (owner != 0) - result = owner->createOverlay(w, h, format, orientation); - return result; -} - -// ============================================================================ -// LayerBuffer::Buffer -// ============================================================================ - -LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, - ssize_t offset, size_t bufferSize) - : mBufferHeap(buffers), mSupportsCopybit(false) -{ - NativeBuffer& src(mNativeBuffer); - src.crop.l = 0; - src.crop.t = 0; - src.crop.r = buffers.w; - src.crop.b = buffers.h; - - src.img.w = buffers.hor_stride ?: buffers.w; - src.img.h = buffers.ver_stride ?: buffers.h; - src.img.format = buffers.format; - src.img.base = (void*)(intptr_t(buffers.heap->base()) + offset); - src.img.handle = 0; - - gralloc_module_t const * module = LayerBuffer::getGrallocModule(); - if (module && module->perform) { - int err = module->perform(module, - GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER, - buffers.heap->heapID(), bufferSize, - offset, buffers.heap->base(), - &src.img.handle); - - // we can fail here is the passed buffer is purely software - mSupportsCopybit = (err == NO_ERROR); - } - } - -LayerBuffer::Buffer::~Buffer() -{ - NativeBuffer& src(mNativeBuffer); - if (src.img.handle) { - native_handle_delete(src.img.handle); - } -} - -// ============================================================================ -// LayerBuffer::Source -// LayerBuffer::BufferSource -// LayerBuffer::OverlaySource -// ============================================================================ - -LayerBuffer::Source::Source(LayerBuffer& layer) - : mLayer(layer) -{ -} -LayerBuffer::Source::~Source() { -} -void LayerBuffer::Source::onDraw(const Region& clip) const { -} -void LayerBuffer::Source::onTransaction(uint32_t flags) { -} -void LayerBuffer::Source::onVisibilityResolved( - const Transform& planeTransform) { -} -void LayerBuffer::Source::postBuffer(ssize_t offset) { -} -void LayerBuffer::Source::unregisterBuffers() { -} - -// --------------------------------------------------------------------------- - -LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer, - const ISurface::BufferHeap& buffers) - : Source(layer), mStatus(NO_ERROR), mBufferSize(0) -{ - if (buffers.heap == NULL) { - // this is allowed, but in this case, it is illegal to receive - // postBuffer(). The surface just erases the framebuffer with - // fully transparent pixels. - mBufferHeap = buffers; - mLayer.setNeedsBlending(false); - return; - } - - status_t err = (buffers.heap->heapID() >= 0) ? NO_ERROR : NO_INIT; - if (err != NO_ERROR) { - LOGE("LayerBuffer::BufferSource: invalid heap (%s)", strerror(err)); - mStatus = err; - return; - } - - PixelFormatInfo info; - err = getPixelFormatInfo(buffers.format, &info); - if (err != NO_ERROR) { - LOGE("LayerBuffer::BufferSource: invalid format %d (%s)", - buffers.format, strerror(err)); - mStatus = err; - return; - } - - if (buffers.hor_stride<0 || buffers.ver_stride<0) { - LOGE("LayerBuffer::BufferSource: invalid parameters " - "(w=%d, h=%d, xs=%d, ys=%d)", - buffers.w, buffers.h, buffers.hor_stride, buffers.ver_stride); - mStatus = BAD_VALUE; - return; - } - - mBufferHeap = buffers; - mLayer.setNeedsBlending((info.h_alpha - info.l_alpha) > 0); - mBufferSize = info.getScanlineSize(buffers.hor_stride)*buffers.ver_stride; - mLayer.forceVisibilityTransaction(); -} - -LayerBuffer::BufferSource::~BufferSource() -{ - class MessageDestroyTexture : public MessageBase { - SurfaceFlinger* flinger; - GLuint name; - public: - MessageDestroyTexture( - SurfaceFlinger* flinger, GLuint name) - : flinger(flinger), name(name) { } - virtual bool handler() { - glDeleteTextures(1, &name); - return true; - } - }; - - if (mTexture.name != -1U) { - // GL textures can only be destroyed from the GL thread - getFlinger()->mEventQueue.postMessage( - new MessageDestroyTexture(getFlinger(), mTexture.name) ); - } - if (mTexture.image != EGL_NO_IMAGE_KHR) { - EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay()); - eglDestroyImageKHR(dpy, mTexture.image); - } -} - -void LayerBuffer::BufferSource::postBuffer(ssize_t offset) -{ - ISurface::BufferHeap buffers; - { // scope for the lock - Mutex::Autolock _l(mBufferSourceLock); - buffers = mBufferHeap; - if (buffers.heap != 0) { - const size_t memorySize = buffers.heap->getSize(); - if ((size_t(offset) + mBufferSize) > memorySize) { - LOGE("LayerBuffer::BufferSource::postBuffer() " - "invalid buffer (offset=%d, size=%d, heap-size=%d", - int(offset), int(mBufferSize), int(memorySize)); - return; - } - } - } - - sp<Buffer> buffer; - if (buffers.heap != 0) { - buffer = new LayerBuffer::Buffer(buffers, offset, mBufferSize); - if (buffer->getStatus() != NO_ERROR) - buffer.clear(); - setBuffer(buffer); - mLayer.invalidate(); - } -} - -void LayerBuffer::BufferSource::unregisterBuffers() -{ - Mutex::Autolock _l(mBufferSourceLock); - mBufferHeap.heap.clear(); - mBuffer.clear(); - mLayer.invalidate(); -} - -sp<LayerBuffer::Buffer> LayerBuffer::BufferSource::getBuffer() const -{ - Mutex::Autolock _l(mBufferSourceLock); - return mBuffer; -} - -void LayerBuffer::BufferSource::setBuffer(const sp<LayerBuffer::Buffer>& buffer) -{ - Mutex::Autolock _l(mBufferSourceLock); - mBuffer = buffer; -} - -void LayerBuffer::BufferSource::onDraw(const Region& clip) const -{ - sp<Buffer> ourBuffer(getBuffer()); - if (UNLIKELY(ourBuffer == 0)) { - // nothing to do, we don't have a buffer - mLayer.clearWithOpenGL(clip); - return; - } - - status_t err = NO_ERROR; - NativeBuffer src(ourBuffer->getBuffer()); - const Rect transformedBounds(mLayer.getTransformedBounds()); - -#if defined(EGL_ANDROID_image_native_buffer) - if (GLExtensions::getInstance().haveDirectTexture()) { - err = INVALID_OPERATION; - if (ourBuffer->supportsCopybit()) { - copybit_device_t* copybit = mLayer.mBlitEngine; - if (copybit && err != NO_ERROR) { - // create our EGLImageKHR the first time - err = initTempBuffer(); - if (err == NO_ERROR) { - // NOTE: Assume the buffer is allocated with the proper USAGE flags - const NativeBuffer& dst(mTempBuffer); - region_iterator clip(Region(Rect(dst.crop.r, dst.crop.b))); - copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0); - copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF); - copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE); - err = copybit->stretch(copybit, &dst.img, &src.img, - &dst.crop, &src.crop, &clip); - if (err != NO_ERROR) { - clearTempBufferImage(); - } - } - } - } - } -#endif - else { - err = INVALID_OPERATION; - } - - if (err != NO_ERROR) { - // slower fallback - GGLSurface t; - t.version = sizeof(GGLSurface); - t.width = src.crop.r; - t.height = src.crop.b; - t.stride = src.img.w; - t.vstride= src.img.h; - t.format = src.img.format; - t.data = (GGLubyte*)src.img.base; - const Region dirty(Rect(t.width, t.height)); - mTextureManager.loadTexture(&mTexture, dirty, t); - } - - mLayer.setBufferTransform(mBufferHeap.transform); - mLayer.drawWithOpenGL(clip, mTexture); -} - -status_t LayerBuffer::BufferSource::initTempBuffer() const -{ - // figure out the size we need now - const ISurface::BufferHeap& buffers(mBufferHeap); - uint32_t w = mLayer.mTransformedBounds.width(); - uint32_t h = mLayer.mTransformedBounds.height(); - if (mLayer.getOrientation() & (Transform::ROT_90 | Transform::ROT_270)) { - int t = w; w = h; h = t; - } - - // we're in the copybit case, so make sure we can handle this blit - // we don't have to keep the aspect ratio here - copybit_device_t* copybit = mLayer.mBlitEngine; - const int down = copybit->get(copybit, COPYBIT_MINIFICATION_LIMIT); - const int up = copybit->get(copybit, COPYBIT_MAGNIFICATION_LIMIT); - if (buffers.w > w*down) w = buffers.w / down; - else if (w > buffers.w*up) w = buffers.w*up; - if (buffers.h > h*down) h = buffers.h / down; - else if (h > buffers.h*up) h = buffers.h*up; - - if (mTexture.image != EGL_NO_IMAGE_KHR) { - // we have an EGLImage, make sure the needed size didn't change - if (w!=mTexture.width || h!= mTexture.height) { - // delete the EGLImage and texture - clearTempBufferImage(); - } else { - // we're good, we have an EGLImageKHR and it's (still) the - // right size - return NO_ERROR; - } - } - - // figure out if we need linear filtering - if (buffers.w * h == buffers.h * w) { - // same pixel area, don't use filtering - mLayer.mNeedsFiltering = false; - } - - // Allocate a temporary buffer and create the corresponding EGLImageKHR - // once the EGLImage has been created we don't need the - // graphic buffer reference anymore. - sp<GraphicBuffer> buffer = new GraphicBuffer( - w, h, HAL_PIXEL_FORMAT_RGB_565, - GraphicBuffer::USAGE_HW_TEXTURE | - GraphicBuffer::USAGE_HW_2D); - - status_t err = buffer->initCheck(); - if (err == NO_ERROR) { - NativeBuffer& dst(mTempBuffer); - dst.img.w = buffer->getStride(); - dst.img.h = h; - dst.img.format = buffer->getPixelFormat(); - dst.img.handle = (native_handle_t *)buffer->handle; - dst.img.base = 0; - dst.crop.l = 0; - dst.crop.t = 0; - dst.crop.r = w; - dst.crop.b = h; - - EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay()); - err = mTextureManager.initEglImage(&mTexture, dpy, buffer); - } - - return err; -} - -void LayerBuffer::BufferSource::clearTempBufferImage() const -{ - // delete the image - EGLDisplay dpy(getFlinger()->graphicPlane(0).getEGLDisplay()); - eglDestroyImageKHR(dpy, mTexture.image); - - // and the associated texture (recreate a name) - glDeleteTextures(1, &mTexture.name); - Texture defaultTexture; - mTexture = defaultTexture; -} - -// --------------------------------------------------------------------------- - -LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer, - sp<OverlayRef>* overlayRef, - uint32_t w, uint32_t h, int32_t format, int32_t orientation) - : Source(layer), mVisibilityChanged(false), - mOverlay(0), mOverlayHandle(0), mOverlayDevice(0), mOrientation(orientation) -{ - overlay_control_device_t* overlay_dev = getFlinger()->getOverlayEngine(); - if (overlay_dev == NULL) { - // overlays not supported - return; - } - - mOverlayDevice = overlay_dev; - overlay_t* overlay = overlay_dev->createOverlay(overlay_dev, w, h, format); - if (overlay == NULL) { - // couldn't create the overlay (no memory? no more overlays?) - return; - } - - // enable dithering... - overlay_dev->setParameter(overlay_dev, overlay, - OVERLAY_DITHER, OVERLAY_ENABLE); - - mOverlay = overlay; - mWidth = overlay->w; - mHeight = overlay->h; - mFormat = overlay->format; - mWidthStride = overlay->w_stride; - mHeightStride = overlay->h_stride; - mInitialized = false; - - mOverlayHandle = overlay->getHandleRef(overlay); - - sp<OverlayChannel> channel = new OverlayChannel( &layer ); - - *overlayRef = new OverlayRef(mOverlayHandle, channel, - mWidth, mHeight, mFormat, mWidthStride, mHeightStride); - getFlinger()->signalEvent(); -} - -LayerBuffer::OverlaySource::~OverlaySource() -{ - if (mOverlay && mOverlayDevice) { - overlay_control_device_t* overlay_dev = mOverlayDevice; - overlay_dev->destroyOverlay(overlay_dev, mOverlay); - } -} - -void LayerBuffer::OverlaySource::onDraw(const Region& clip) const -{ - // this would be where the color-key would be set, should we need it. - GLclampf red = 0; - GLclampf green = 0; - GLclampf blue = 0; - mLayer.clearWithOpenGL(clip, red, green, blue, 0); -} - -void LayerBuffer::OverlaySource::onTransaction(uint32_t flags) -{ - const Layer::State& front(mLayer.drawingState()); - const Layer::State& temp(mLayer.currentState()); - if (temp.sequence != front.sequence) { - mVisibilityChanged = true; - } -} - -void LayerBuffer::OverlaySource::onvalidateVisibility(const Transform&) -{ - mVisibilityChanged = true; -} - -void LayerBuffer::OverlaySource::onVisibilityResolved( - const Transform& planeTransform) -{ - // this code-path must be as tight as possible, it's called each time - // the screen is composited. - if (UNLIKELY(mOverlay != 0)) { - if (mVisibilityChanged || !mInitialized) { - mVisibilityChanged = false; - mInitialized = true; - const Rect bounds(mLayer.getTransformedBounds()); - int x = bounds.left; - int y = bounds.top; - int w = bounds.width(); - int h = bounds.height(); - - // we need a lock here to protect "destroy" - Mutex::Autolock _l(mOverlaySourceLock); - if (mOverlay) { - overlay_control_device_t* overlay_dev = mOverlayDevice; - overlay_dev->setPosition(overlay_dev, mOverlay, x,y,w,h); - // we need to combine the layer orientation and the - // user-requested orientation. - Transform finalTransform(Transform(mLayer.getOrientation()) * - Transform(mOrientation)); - overlay_dev->setParameter(overlay_dev, mOverlay, - OVERLAY_TRANSFORM, finalTransform.getOrientation()); - overlay_dev->commit(overlay_dev, mOverlay); - } - } - } -} - -void LayerBuffer::OverlaySource::destroy() -{ - // we need a lock here to protect "onVisibilityResolved" - Mutex::Autolock _l(mOverlaySourceLock); - if (mOverlay && mOverlayDevice) { - overlay_control_device_t* overlay_dev = mOverlayDevice; - overlay_dev->destroyOverlay(overlay_dev, mOverlay); - mOverlay = 0; - } -} - -// --------------------------------------------------------------------------- -}; // namespace android diff --git a/services/surfaceflinger/LayerBuffer.h b/services/surfaceflinger/LayerBuffer.h deleted file mode 100644 index a89d8fe..0000000 --- a/services/surfaceflinger/LayerBuffer.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_LAYER_BUFFER_H -#define ANDROID_LAYER_BUFFER_H - -#include <stdint.h> -#include <sys/types.h> - -#include "LayerBase.h" -#include "TextureManager.h" - -struct copybit_device_t; - -namespace android { - -// --------------------------------------------------------------------------- - -class Buffer; -class Region; -class OverlayRef; - -// --------------------------------------------------------------------------- - -class LayerBuffer : public LayerBaseClient -{ - class Source : public LightRefBase<Source> { - public: - Source(LayerBuffer& layer); - virtual ~Source(); - virtual void onDraw(const Region& clip) const; - virtual void onTransaction(uint32_t flags); - virtual void onVisibilityResolved(const Transform& planeTransform); - virtual void onvalidateVisibility(const Transform& globalTransform) { } - virtual void postBuffer(ssize_t offset); - virtual void unregisterBuffers(); - virtual void destroy() { } - SurfaceFlinger* getFlinger() const { return mLayer.mFlinger.get(); } - protected: - LayerBuffer& mLayer; - }; - -public: - LayerBuffer(SurfaceFlinger* flinger, DisplayID display, - const sp<Client>& client); - virtual ~LayerBuffer(); - - virtual void onFirstRef(); - virtual bool needsBlending() const; - virtual const char* getTypeId() const { return "LayerBuffer"; } - - virtual sp<LayerBaseClient::Surface> createSurface() const; - virtual status_t ditch(); - virtual void onDraw(const Region& clip) const; - virtual void drawForSreenShot() const; - virtual uint32_t doTransaction(uint32_t flags); - virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion); - virtual void validateVisibility(const Transform& globalTransform); - - status_t registerBuffers(const ISurface::BufferHeap& buffers); - void postBuffer(ssize_t offset); - void unregisterBuffers(); - sp<OverlayRef> createOverlay(uint32_t w, uint32_t h, int32_t format, - int32_t orientation); - - sp<Source> getSource() const; - sp<Source> clearSource(); - void setNeedsBlending(bool blending); - Rect getTransformedBounds() const { - return mTransformedBounds; - } - - void serverDestroy(); - -private: - struct NativeBuffer { - copybit_image_t img; - copybit_rect_t crop; - }; - - static gralloc_module_t const* sGrallocModule; - static gralloc_module_t const* getGrallocModule() { - return sGrallocModule; - } - - class Buffer : public LightRefBase<Buffer> { - public: - Buffer(const ISurface::BufferHeap& buffers, - ssize_t offset, size_t bufferSize); - inline bool supportsCopybit() const { - return mSupportsCopybit; - } - inline status_t getStatus() const { - return mBufferHeap.heap!=0 ? NO_ERROR : NO_INIT; - } - inline const NativeBuffer& getBuffer() const { - return mNativeBuffer; - } - protected: - friend class LightRefBase<Buffer>; - Buffer& operator = (const Buffer& rhs); - Buffer(const Buffer& rhs); - ~Buffer(); - private: - ISurface::BufferHeap mBufferHeap; - NativeBuffer mNativeBuffer; - bool mSupportsCopybit; - }; - - class BufferSource : public Source { - public: - BufferSource(LayerBuffer& layer, const ISurface::BufferHeap& buffers); - virtual ~BufferSource(); - - status_t getStatus() const { return mStatus; } - sp<Buffer> getBuffer() const; - void setBuffer(const sp<Buffer>& buffer); - - virtual void onDraw(const Region& clip) const; - virtual void postBuffer(ssize_t offset); - virtual void unregisterBuffers(); - virtual void destroy() { } - private: - status_t initTempBuffer() const; - void clearTempBufferImage() const; - mutable Mutex mBufferSourceLock; - sp<Buffer> mBuffer; - status_t mStatus; - ISurface::BufferHeap mBufferHeap; - size_t mBufferSize; - mutable Texture mTexture; - mutable NativeBuffer mTempBuffer; - mutable TextureManager mTextureManager; - }; - - class OverlaySource : public Source { - public: - OverlaySource(LayerBuffer& layer, - sp<OverlayRef>* overlayRef, - uint32_t w, uint32_t h, int32_t format, int32_t orientation); - virtual ~OverlaySource(); - virtual void onDraw(const Region& clip) const; - virtual void onTransaction(uint32_t flags); - virtual void onVisibilityResolved(const Transform& planeTransform); - virtual void onvalidateVisibility(const Transform& globalTransform); - virtual void destroy(); - private: - - class OverlayChannel : public BnOverlay { - wp<LayerBuffer> mLayer; - virtual void destroy() { - sp<LayerBuffer> layer(mLayer.promote()); - if (layer != 0) { - layer->serverDestroy(); - } - } - public: - OverlayChannel(const sp<LayerBuffer>& layer) - : mLayer(layer) { - } - }; - - friend class OverlayChannel; - bool mVisibilityChanged; - - overlay_t* mOverlay; - overlay_handle_t mOverlayHandle; - overlay_control_device_t* mOverlayDevice; - uint32_t mWidth; - uint32_t mHeight; - int32_t mFormat; - int32_t mWidthStride; - int32_t mHeightStride; - int32_t mOrientation; - mutable Mutex mOverlaySourceLock; - bool mInitialized; - }; - - - class SurfaceLayerBuffer : public LayerBaseClient::Surface - { - public: - SurfaceLayerBuffer(const sp<SurfaceFlinger>& flinger, - const sp<LayerBuffer>& owner); - virtual ~SurfaceLayerBuffer(); - - virtual status_t registerBuffers(const ISurface::BufferHeap& buffers); - virtual void postBuffer(ssize_t offset); - virtual void unregisterBuffers(); - - virtual sp<OverlayRef> createOverlay( - uint32_t w, uint32_t h, int32_t format, int32_t orientation); - private: - sp<LayerBuffer> getOwner() const { - return static_cast<LayerBuffer*>(Surface::getOwner().get()); - } - }; - - mutable Mutex mLock; - sp<Source> mSource; - sp<Surface> mSurface; - bool mInvalidate; - bool mNeedsBlending; - copybit_device_t* mBlitEngine; -}; - -// --------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_LAYER_BUFFER_H diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 49240e8..09b084e 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -48,7 +48,6 @@ #include "GLExtensions.h" #include "Layer.h" #include "LayerBlur.h" -#include "LayerBuffer.h" #include "LayerDim.h" #include "SurfaceFlinger.h" @@ -119,11 +118,6 @@ SurfaceFlinger::~SurfaceFlinger() glDeleteTextures(1, &mWormholeTexName); } -overlay_control_device_t* SurfaceFlinger::getOverlayEngine() const -{ - return graphicPlane(0).displayHardware().getOverlayEngine(); -} - sp<IMemoryHeap> SurfaceFlinger::getCblk() const { return mServerHeap; @@ -1228,15 +1222,8 @@ sp<ISurface> SurfaceFlinger::createSurface(const sp<Client>& client, int pid, sp<Layer> normalLayer; switch (flags & eFXSurfaceMask) { case eFXSurfaceNormal: -#if HAS_PUSH_BUFFERS - if (UNLIKELY(flags & ePushBuffers)) { - layer = createPushBuffersSurface(client, d, w, h, flags); - } else -#endif - { - normalLayer = createNormalSurface(client, d, w, h, flags, format); - layer = normalLayer; - } + normalLayer = createNormalSurface(client, d, w, h, flags, format); + layer = normalLayer; break; case eFXSurfaceBlur: layer = createBlurSurface(client, d, w, h, flags); @@ -1322,15 +1309,6 @@ sp<LayerDim> SurfaceFlinger::createDimSurface( return layer; } -sp<LayerBuffer> SurfaceFlinger::createPushBuffersSurface( - const sp<Client>& client, DisplayID display, - uint32_t w, uint32_t h, uint32_t flags) -{ - sp<LayerBuffer> layer = new LayerBuffer(this, display, client); - layer->initStates(w, h, flags); - return layer; -} - status_t SurfaceFlinger::removeSurface(const sp<Client>& client, SurfaceID sid) { /* diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index dda25e8..596108f 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -50,7 +50,6 @@ class FreezeLock; class Layer; class LayerBlur; class LayerDim; -class LayerBuffer; #define LIKELY( exp ) (__builtin_expect( (exp) != 0, true )) #define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false )) @@ -207,8 +206,6 @@ public: void screenReleased(DisplayID dpy); void screenAcquired(DisplayID dpy); - overlay_control_device_t* getOverlayEngine() const; - status_t removeLayer(const sp<LayerBase>& layer); status_t addLayer(const sp<LayerBase>& layer); status_t invalidateLayerVisibility(const sp<LayerBase>& layer); @@ -218,7 +215,6 @@ public: private: friend class Client; friend class LayerBase; - friend class LayerBuffer; friend class LayerBaseClient; friend class LayerBaseClient::Surface; friend class Layer; @@ -244,10 +240,6 @@ private: const sp<Client>& client, DisplayID display, uint32_t w, uint32_t h, uint32_t flags); - sp<LayerBuffer> createPushBuffersSurface( - const sp<Client>& client, DisplayID display, - uint32_t w, uint32_t h, uint32_t flags); - status_t removeSurface(const sp<Client>& client, SurfaceID sid); status_t destroySurface(const sp<LayerBaseClient>& layer); status_t setClientState(const sp<Client>& client, diff --git a/services/surfaceflinger/tests/overlays/Android.mk b/services/surfaceflinger/tests/overlays/Android.mk deleted file mode 100644 index 592b601..0000000 --- a/services/surfaceflinger/tests/overlays/Android.mk +++ /dev/null @@ -1,17 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - overlays.cpp - -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libutils \ - libui \ - libsurfaceflinger_client - -LOCAL_MODULE:= test-overlays - -LOCAL_MODULE_TAGS := tests - -include $(BUILD_EXECUTABLE) diff --git a/services/surfaceflinger/tests/overlays/overlays.cpp b/services/surfaceflinger/tests/overlays/overlays.cpp deleted file mode 100644 index c248a615..0000000 --- a/services/surfaceflinger/tests/overlays/overlays.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include <binder/IPCThreadState.h> -#include <binder/ProcessState.h> -#include <binder/IServiceManager.h> -#include <utils/Log.h> - -#include <ui/Overlay.h> - -#include <surfaceflinger/Surface.h> -#include <surfaceflinger/ISurface.h> -#include <surfaceflinger/SurfaceComposerClient.h> - -using namespace android; - -namespace android { -class Test { -public: - static const sp<ISurface>& getISurface(const sp<Surface>& s) { - return s->getISurface(); - } -}; -}; - -int main(int argc, char** argv) -{ - // set up the thread-pool - sp<ProcessState> proc(ProcessState::self()); - ProcessState::self()->startThreadPool(); - - // create a client to surfaceflinger - sp<SurfaceComposerClient> client = new SurfaceComposerClient(); - - // create pushbuffer surface - sp<Surface> surface = client->createSurface(getpid(), 0, 320, 240, - PIXEL_FORMAT_UNKNOWN, ISurfaceComposer::ePushBuffers); - - // get to the isurface - sp<ISurface> isurface = Test::getISurface(surface); - printf("isurface = %p\n", isurface.get()); - - // now request an overlay - sp<OverlayRef> ref = isurface->createOverlay(320, 240, PIXEL_FORMAT_RGB_565); - sp<Overlay> overlay = new Overlay(ref); - - - /* - * here we can use the overlay API - */ - - overlay_buffer_t buffer; - overlay->dequeueBuffer(&buffer); - printf("buffer = %p\n", buffer); - - void* address = overlay->getBufferAddress(buffer); - printf("address = %p\n", address); - - overlay->queueBuffer(buffer); - - return 0; -} diff --git a/services/surfaceflinger/tests/resize/resize.cpp b/services/surfaceflinger/tests/resize/resize.cpp index 127cca3..99f4b4f 100644 --- a/services/surfaceflinger/tests/resize/resize.cpp +++ b/services/surfaceflinger/tests/resize/resize.cpp @@ -10,8 +10,6 @@ #include <surfaceflinger/ISurface.h> #include <surfaceflinger/SurfaceComposerClient.h> -#include <ui/Overlay.h> - using namespace android; namespace android { @@ -32,7 +30,6 @@ int main(int argc, char** argv) // create a client to surfaceflinger sp<SurfaceComposerClient> client = new SurfaceComposerClient(); - // create pushbuffer surface sp<Surface> surface = client->createSurface(getpid(), 0, 160, 240, PIXEL_FORMAT_RGB_565); diff --git a/services/surfaceflinger/tests/surface/surface.cpp b/services/surfaceflinger/tests/surface/surface.cpp index b4de4b4..194fbb6 100644 --- a/services/surfaceflinger/tests/surface/surface.cpp +++ b/services/surfaceflinger/tests/surface/surface.cpp @@ -10,8 +10,6 @@ #include <surfaceflinger/ISurface.h> #include <surfaceflinger/SurfaceComposerClient.h> -#include <ui/Overlay.h> - using namespace android; int main(int argc, char** argv) @@ -23,7 +21,6 @@ int main(int argc, char** argv) // create a client to surfaceflinger sp<SurfaceComposerClient> client = new SurfaceComposerClient(); - // create pushbuffer surface sp<SurfaceControl> surfaceControl = client->createSurface( getpid(), 0, 160, 240, PIXEL_FORMAT_RGB_565); client->openTransaction(); |