Loading include/gui/ISurfaceComposer.h +13 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,16 @@ public: uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ, bool isCpuConsumer) = 0; #ifdef USE_MHEAP_SCREENSHOT /* Capture the specified screen. requires READ_FRAME_BUFFER permission * This function will fail if there is a secure window on screen. */ virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap, uint32_t* width, uint32_t* height, uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ) = 0; #endif }; // ---------------------------------------------------------------------------- Loading @@ -140,6 +150,9 @@ public: GET_BUILT_IN_DISPLAY, SET_TRANSACTION_STATE, AUTHENTICATE_SURFACE, #ifdef USE_MHEAP_SCREENSHOT CAPTURE_SCREEN_DEPRECATED, #endif BLANK, UNBLANK, GET_DISPLAY_INFO, Loading include/gui/SurfaceComposerClient.h +6 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,9 @@ namespace android { class DisplayInfo; class Composer; #ifdef USE_MHEAP_SCREENSHOT class IMemoryHeap; #endif class ISurfaceComposerClient; class IGraphicBufferProducer; class Region; Loading Loading @@ -179,6 +182,9 @@ public: uint32_t minLayerZ, uint32_t maxLayerZ); private: #ifdef USE_MHEAP_SCREENSHOT sp<IMemoryHeap> mHeap; #endif mutable sp<CpuConsumer> mCpuConsumer; mutable sp<BufferQueue> mBufferQueue; CpuConsumer::LockedBuffer mBuffer; Loading libs/gui/Android.mk +4 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,10 @@ ifeq ($(BOARD_EGL_SKIP_FIRST_DEQUEUE),true) LOCAL_CFLAGS += -DSURFACE_SKIP_FIRST_DEQUEUE endif ifeq ($(BOARD_USE_MHEAP_SCREENSHOT),true) LOCAL_CFLAGS += -DUSE_MHEAP_SCREENSHOT endif LOCAL_MODULE:= libgui ifeq ($(TARGET_BOARD_PLATFORM), tegra) Loading libs/gui/ISurfaceComposer.cpp +41 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,28 @@ public: remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); } #ifdef USE_MHEAP_SCREENSHOT virtual status_t captureScreen( const sp<IBinder>& display, sp<IMemoryHeap>* heap, uint32_t* width, uint32_t* height, uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeStrongBinder(display); data.writeInt32(reqWidth); data.writeInt32(reqHeight); data.writeInt32(minLayerZ); data.writeInt32(maxLayerZ); remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN_DEPRECATED, data, &reply); *heap = interface_cast<IMemoryHeap>(reply.readStrongBinder()); *width = reply.readInt32(); *height = reply.readInt32(); return reply.readInt32(); } #endif virtual status_t captureScreen(const sp<IBinder>& display, const sp<IGraphicBufferProducer>& producer, uint32_t reqWidth, uint32_t reqHeight, Loading Loading @@ -278,6 +300,25 @@ status_t BnSurfaceComposer::onTransact( bootFinished(); return NO_ERROR; } #ifdef USE_MHEAP_SCREENSHOT case CAPTURE_SCREEN_DEPRECATED: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> display = data.readStrongBinder(); uint32_t reqWidth = data.readInt32(); uint32_t reqHeight = data.readInt32(); uint32_t minLayerZ = data.readInt32(); uint32_t maxLayerZ = data.readInt32(); sp<IMemoryHeap> heap; uint32_t w, h; status_t res = captureScreen(display, &heap, &w, &h, reqWidth, reqHeight, minLayerZ, maxLayerZ); reply->writeStrongBinder(heap->asBinder()); reply->writeInt32(w); reply->writeInt32(h); reply->writeInt32(res); return NO_ERROR; } #endif case CAPTURE_SCREEN: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> display = data.readStrongBinder(); Loading libs/gui/SurfaceComposerClient.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -699,6 +699,14 @@ status_t ScreenshotClient::capture( uint32_t minLayerZ, uint32_t maxLayerZ) { sp<ISurfaceComposer> s(ComposerService::getComposerService()); if (s == NULL) return NO_INIT; #ifdef USE_MHEAP_SCREENSHOT int format = 0; producer->query(NATIVE_WINDOW_FORMAT,&format); if (format == PIXEL_FORMAT_RGBA_8888) { /* For some reason, this format fails badly */ return BAD_VALUE; } #endif return s->captureScreen(display, producer, reqWidth, reqHeight, minLayerZ, maxLayerZ, SS_CPU_CONSUMER); Loading Loading @@ -734,6 +742,19 @@ status_t ScreenshotClient::update(const sp<IBinder>& display, uint32_t minLayerZ, uint32_t maxLayerZ) { sp<ISurfaceComposer> s(ComposerService::getComposerService()); if (s == NULL) return NO_INIT; #ifdef USE_MHEAP_SCREENSHOT int ret = -1; mHeap = 0; ret = s->captureScreen(display, &mHeap, &mBuffer.width, &mBuffer.height, reqWidth, reqHeight, minLayerZ, maxLayerZ); if (ret == NO_ERROR) { mBuffer.format = PIXEL_FORMAT_RGBA_8888; mBuffer.stride = mBuffer.width; mBuffer.data = (uint8_t *)mHeap->getBase(); } return ret; #else sp<CpuConsumer> cpuConsumer = getCpuConsumer(); if (mHaveBuffer) { Loading @@ -752,6 +773,7 @@ status_t ScreenshotClient::update(const sp<IBinder>& display, } } return err; #endif } status_t ScreenshotClient::update(const sp<IBinder>& display) { Loading @@ -764,12 +786,16 @@ status_t ScreenshotClient::update(const sp<IBinder>& display, } void ScreenshotClient::release() { #ifdef USE_MHEAP_SCREENSHOT mHeap = 0; #else if (mHaveBuffer) { mCpuConsumer->unlockBuffer(mBuffer); memset(&mBuffer, 0, sizeof(mBuffer)); mHaveBuffer = false; } mCpuConsumer.clear(); #endif } void const* ScreenshotClient::getPixels() const { Loading Loading
include/gui/ISurfaceComposer.h +13 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,16 @@ public: uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ, bool isCpuConsumer) = 0; #ifdef USE_MHEAP_SCREENSHOT /* Capture the specified screen. requires READ_FRAME_BUFFER permission * This function will fail if there is a secure window on screen. */ virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap, uint32_t* width, uint32_t* height, uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ) = 0; #endif }; // ---------------------------------------------------------------------------- Loading @@ -140,6 +150,9 @@ public: GET_BUILT_IN_DISPLAY, SET_TRANSACTION_STATE, AUTHENTICATE_SURFACE, #ifdef USE_MHEAP_SCREENSHOT CAPTURE_SCREEN_DEPRECATED, #endif BLANK, UNBLANK, GET_DISPLAY_INFO, Loading
include/gui/SurfaceComposerClient.h +6 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,9 @@ namespace android { class DisplayInfo; class Composer; #ifdef USE_MHEAP_SCREENSHOT class IMemoryHeap; #endif class ISurfaceComposerClient; class IGraphicBufferProducer; class Region; Loading Loading @@ -179,6 +182,9 @@ public: uint32_t minLayerZ, uint32_t maxLayerZ); private: #ifdef USE_MHEAP_SCREENSHOT sp<IMemoryHeap> mHeap; #endif mutable sp<CpuConsumer> mCpuConsumer; mutable sp<BufferQueue> mBufferQueue; CpuConsumer::LockedBuffer mBuffer; Loading
libs/gui/Android.mk +4 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,10 @@ ifeq ($(BOARD_EGL_SKIP_FIRST_DEQUEUE),true) LOCAL_CFLAGS += -DSURFACE_SKIP_FIRST_DEQUEUE endif ifeq ($(BOARD_USE_MHEAP_SCREENSHOT),true) LOCAL_CFLAGS += -DUSE_MHEAP_SCREENSHOT endif LOCAL_MODULE:= libgui ifeq ($(TARGET_BOARD_PLATFORM), tegra) Loading
libs/gui/ISurfaceComposer.cpp +41 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,28 @@ public: remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); } #ifdef USE_MHEAP_SCREENSHOT virtual status_t captureScreen( const sp<IBinder>& display, sp<IMemoryHeap>* heap, uint32_t* width, uint32_t* height, uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeStrongBinder(display); data.writeInt32(reqWidth); data.writeInt32(reqHeight); data.writeInt32(minLayerZ); data.writeInt32(maxLayerZ); remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN_DEPRECATED, data, &reply); *heap = interface_cast<IMemoryHeap>(reply.readStrongBinder()); *width = reply.readInt32(); *height = reply.readInt32(); return reply.readInt32(); } #endif virtual status_t captureScreen(const sp<IBinder>& display, const sp<IGraphicBufferProducer>& producer, uint32_t reqWidth, uint32_t reqHeight, Loading Loading @@ -278,6 +300,25 @@ status_t BnSurfaceComposer::onTransact( bootFinished(); return NO_ERROR; } #ifdef USE_MHEAP_SCREENSHOT case CAPTURE_SCREEN_DEPRECATED: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> display = data.readStrongBinder(); uint32_t reqWidth = data.readInt32(); uint32_t reqHeight = data.readInt32(); uint32_t minLayerZ = data.readInt32(); uint32_t maxLayerZ = data.readInt32(); sp<IMemoryHeap> heap; uint32_t w, h; status_t res = captureScreen(display, &heap, &w, &h, reqWidth, reqHeight, minLayerZ, maxLayerZ); reply->writeStrongBinder(heap->asBinder()); reply->writeInt32(w); reply->writeInt32(h); reply->writeInt32(res); return NO_ERROR; } #endif case CAPTURE_SCREEN: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> display = data.readStrongBinder(); Loading
libs/gui/SurfaceComposerClient.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -699,6 +699,14 @@ status_t ScreenshotClient::capture( uint32_t minLayerZ, uint32_t maxLayerZ) { sp<ISurfaceComposer> s(ComposerService::getComposerService()); if (s == NULL) return NO_INIT; #ifdef USE_MHEAP_SCREENSHOT int format = 0; producer->query(NATIVE_WINDOW_FORMAT,&format); if (format == PIXEL_FORMAT_RGBA_8888) { /* For some reason, this format fails badly */ return BAD_VALUE; } #endif return s->captureScreen(display, producer, reqWidth, reqHeight, minLayerZ, maxLayerZ, SS_CPU_CONSUMER); Loading Loading @@ -734,6 +742,19 @@ status_t ScreenshotClient::update(const sp<IBinder>& display, uint32_t minLayerZ, uint32_t maxLayerZ) { sp<ISurfaceComposer> s(ComposerService::getComposerService()); if (s == NULL) return NO_INIT; #ifdef USE_MHEAP_SCREENSHOT int ret = -1; mHeap = 0; ret = s->captureScreen(display, &mHeap, &mBuffer.width, &mBuffer.height, reqWidth, reqHeight, minLayerZ, maxLayerZ); if (ret == NO_ERROR) { mBuffer.format = PIXEL_FORMAT_RGBA_8888; mBuffer.stride = mBuffer.width; mBuffer.data = (uint8_t *)mHeap->getBase(); } return ret; #else sp<CpuConsumer> cpuConsumer = getCpuConsumer(); if (mHaveBuffer) { Loading @@ -752,6 +773,7 @@ status_t ScreenshotClient::update(const sp<IBinder>& display, } } return err; #endif } status_t ScreenshotClient::update(const sp<IBinder>& display) { Loading @@ -764,12 +786,16 @@ status_t ScreenshotClient::update(const sp<IBinder>& display, } void ScreenshotClient::release() { #ifdef USE_MHEAP_SCREENSHOT mHeap = 0; #else if (mHaveBuffer) { mCpuConsumer->unlockBuffer(mBuffer); memset(&mBuffer, 0, sizeof(mBuffer)); mHaveBuffer = false; } mCpuConsumer.clear(); #endif } void const* ScreenshotClient::getPixels() const { Loading