Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From e5b0c51fb87e3cf0b47ebf80d51382f756d462dc Mon Sep 17 00:00:00 2001
- From: Ricardo Cerqueira <cyanogenmod@cerqueira.org>
- Date: Tue, 6 Aug 2013 16:11:06 +0100
- Subject: [PATCH 1/8] libgui: Bring back support for mHeap-based screenshots
- Older graphics libraries throw a hissy fit when trying to lock
- buffers for Surface-based screenshots, on at least Tegra2/3 and
- Exynos4 hardware.
- This patch depends on the BOARD_USE_MHEAP_SCREENSHOT board flag
- and requires the ro.bq.gpu_to_cpu_unsupported property set to 1
- in order to work.
- [pawitp: port to Lollipop]
- Change-Id: I7db955e2cdd120018e349c14290e975788e70ed3
- ---
- include/gui/ISurfaceComposer.h | 15 +++
- include/gui/SurfaceComposerClient.h | 6 +
- libs/gui/Android.mk | 4 +
- libs/gui/ISurfaceComposer.cpp | 53 ++++++++
- libs/gui/SurfaceComposerClient.cpp | 27 ++++
- services/surfaceflinger/Android.mk | 4 +
- services/surfaceflinger/SurfaceFlinger.h | 16 +++
- services/surfaceflinger/SurfaceFlinger_hwc1.cpp | 161 +++++++++++++++++++++++-
- 8 files changed, 282 insertions(+), 4 deletions(-)
- diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h
- index 90c4dc3..725575a 100644
- --- a/include/gui/ISurfaceComposer.h
- +++ b/include/gui/ISurfaceComposer.h
- @@ -157,6 +157,18 @@ public:
- Rotation rotation = eRotateNone,
- bool isCpuConsumer = false) = 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,
- + Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- + uint32_t minLayerZ, uint32_t maxLayerZ,
- + bool useIdentityTransform,
- + Rotation rotation = eRotateNone) = 0;
- +#endif
- +
- /* Clears the frame statistics for animations.
- *
- * Requires the ACCESS_SURFACE_FLINGER permission.
- @@ -193,6 +205,9 @@ public:
- GET_BUILT_IN_DISPLAY,
- SET_TRANSACTION_STATE,
- AUTHENTICATE_SURFACE,
- +#ifdef USE_MHEAP_SCREENSHOT
- + CAPTURE_SCREEN_DEPRECATED,
- +#endif
- GET_DISPLAY_CONFIGS,
- GET_ACTIVE_CONFIG,
- SET_ACTIVE_CONFIG,
- diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
- index bcf4880..2f4922c 100644
- --- a/include/gui/SurfaceComposerClient.h
- +++ b/include/gui/SurfaceComposerClient.h
- @@ -41,6 +41,9 @@ namespace android {
- class DisplayInfo;
- class Composer;
- class HdrCapabilities;
- +#ifdef USE_MHEAP_SCREENSHOT
- +class IMemoryHeap;
- +#endif
- class ISurfaceComposerClient;
- class IGraphicBufferProducer;
- class Region;
- @@ -218,6 +221,9 @@ public:
- bool useIdentityTransform);
- private:
- +#ifdef USE_MHEAP_SCREENSHOT
- + sp<IMemoryHeap> mHeap;
- +#endif
- mutable sp<CpuConsumer> mCpuConsumer;
- mutable sp<IGraphicBufferProducer> mProducer;
- CpuConsumer::LockedBuffer mBuffer;
- diff --git a/libs/gui/Android.mk b/libs/gui/Android.mk
- index 0889aaf..d1b415e 100644
- --- a/libs/gui/Android.mk
- +++ b/libs/gui/Android.mk
- @@ -87,6 +87,10 @@ LOCAL_SHARED_LIBRARIES := \
- liblog
- +ifeq ($(BOARD_USE_MHEAP_SCREENSHOT),true)
- + LOCAL_CFLAGS += -DUSE_MHEAP_SCREENSHOT
- +endif
- +
- LOCAL_MODULE := libgui
- ifeq ($(TARGET_BOARD_PLATFORM), tegra)
- diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
- index 2e101b3..5c5caa5 100644
- --- a/libs/gui/ISurfaceComposer.cpp
- +++ b/libs/gui/ISurfaceComposer.cpp
- @@ -101,6 +101,33 @@ 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,
- + Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- + uint32_t minLayerZ, uint32_t maxLayerZ,
- + bool useIdentityTransform,
- + ISurfaceComposer::Rotation rotation)
- + {
- + Parcel data, reply;
- + data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
- + data.writeStrongBinder(display);
- + data.write(sourceCrop);
- + data.writeUint32(reqWidth);
- + data.writeUint32(reqHeight);
- + data.writeUint32(minLayerZ);
- + data.writeUint32(maxLayerZ);
- + data.writeInt32(static_cast<int32_t>(useIdentityTransform));
- + data.writeInt32(static_cast<int32_t>(rotation));
- + remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN_DEPRECATED, data, &reply);
- + *heap = interface_cast<IMemoryHeap>(reply.readStrongBinder());
- + *width = reply.readUint32();
- + *height = reply.readUint32();
- + return reply.readInt32();
- + }
- +#endif
- +
- virtual status_t captureScreen(const sp<IBinder>& display,
- const sp<IGraphicBufferProducer>& producer,
- Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- @@ -451,6 +478,32 @@ 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();
- + Rect sourceCrop(Rect::EMPTY_RECT);
- + data.read(sourceCrop);
- + uint32_t reqWidth = data.readUint32();
- + uint32_t reqHeight = data.readUint32();
- + uint32_t minLayerZ = data.readUint32();
- + uint32_t maxLayerZ = data.readUint32();
- + bool useIdentityTransform = static_cast<bool>(data.readInt32());
- + uint32_t rotation = data.readUint32();
- + sp<IMemoryHeap> heap;
- + uint32_t w, h;
- +
- + status_t res = captureScreen(display, &heap, &w, &h,
- + sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
- + useIdentityTransform,
- + static_cast<ISurfaceComposer::Rotation>(rotation));
- + reply->writeStrongBinder(IInterface::asBinder(heap));
- + reply->writeUint32(w);
- + reply->writeUint32(h);
- + reply->writeInt32(res);
- + return NO_ERROR;
- + }
- +#endif
- case CAPTURE_SCREEN: {
- CHECK_INTERFACE(ISurfaceComposer, data, reply);
- sp<IBinder> display = data.readStrongBinder();
- diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
- index a4bf2de..f5218f5 100644
- --- a/libs/gui/SurfaceComposerClient.cpp
- +++ b/libs/gui/SurfaceComposerClient.cpp
- @@ -922,6 +922,14 @@ status_t ScreenshotClient::capture(
- uint32_t minLayerZ, uint32_t maxLayerZ, bool useIdentityTransform) {
- 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, sourceCrop,
- reqWidth, reqHeight, minLayerZ, maxLayerZ, useIdentityTransform,
- ISurfaceComposer::eRotateNone, SS_CPU_CONSUMER);
- @@ -952,6 +960,20 @@ status_t ScreenshotClient::update(const sp<IBinder>& display,
- bool useIdentityTransform, uint32_t rotation) {
- 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, sourceCrop,
- + reqWidth, reqHeight, minLayerZ, maxLayerZ, useIdentityTransform,
- + static_cast<ISurfaceComposer::Rotation>(rotation));
- +
- + if (ret == NO_ERROR) {
- + mBuffer.format = PIXEL_FORMAT_RGBA_8888;
- + mBuffer.stride = mBuffer.width;
- + mBuffer.data = static_cast<uint8_t*>(mHeap->getBase());
- + }
- + return ret;
- +#else
- sp<CpuConsumer> cpuConsumer = getCpuConsumer();
- if (mHaveBuffer) {
- @@ -971,6 +993,7 @@ status_t ScreenshotClient::update(const sp<IBinder>& display,
- }
- }
- return err;
- +#endif
- }
- status_t ScreenshotClient::update(const sp<IBinder>& display,
- @@ -995,12 +1018,16 @@ status_t ScreenshotClient::update(const sp<IBinder>& display, Rect sourceCrop,
- }
- 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 {
- diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
- index 18cc946..2df45c3 100644
- --- a/services/surfaceflinger/Android.mk
- +++ b/services/surfaceflinger/Android.mk
- @@ -90,6 +90,10 @@ ifeq ($(TARGET_HAS_HH_VSYNC_ISSUE),true)
- LOCAL_CFLAGS += -DHH_VSYNC_ISSUE
- endif
- +ifeq ($(BOARD_USE_MHEAP_SCREENSHOT),true)
- + LOCAL_CFLAGS += -DUSE_MHEAP_SCREENSHOT
- +endif
- +
- # The following two BoardConfig variables define (respectively):
- #
- # - The phase offset between hardware vsync and when apps are woken up by the
- diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
- index 900383d..01475e1 100644
- --- a/services/surfaceflinger/SurfaceFlinger.h
- +++ b/services/surfaceflinger/SurfaceFlinger.h
- @@ -229,6 +229,13 @@ private:
- uint32_t minLayerZ, uint32_t maxLayerZ,
- bool useIdentityTransform, ISurfaceComposer::Rotation rotation,
- bool isCpuConsumer);
- +#ifdef USE_MHEAP_SCREENSHOT
- + virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
- + uint32_t* width, uint32_t* height,
- + Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- + uint32_t minLayerZ, uint32_t maxLayerZ,
- + bool useIdentityTransform, ISurfaceComposer::Rotation rotation);
- +#endif
- virtual status_t getDisplayStats(const sp<IBinder>& display,
- DisplayStatInfo* stats);
- virtual status_t getDisplayConfigs(const sp<IBinder>& display,
- @@ -407,6 +414,15 @@ private:
- bool useIdentityTransform, Transform::orientation_flags rotation,
- bool isLocalScreenshot, bool useReadPixels);
- +#ifdef USE_MHEAP_SCREENSHOT
- + status_t captureScreenImplCpuConsumerLocked(
- + const sp<const DisplayDevice>& hw,
- + sp<IMemoryHeap>* heap, uint32_t* width, uint32_t* height,
- + Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- + uint32_t minLayerZ, uint32_t maxLayerZ,
- + bool useIdentityTransform, Transform::orientation_flags rotation);
- +#endif
- +
- /* ------------------------------------------------------------------------
- * EGL
- */
- diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
- index e0b2d55..9deb50b 100644
- --- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
- +++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
- @@ -29,6 +29,9 @@
- #include <stdatomic.h>
- #include <EGL/egl.h>
- +#ifdef USE_MHEAP_SCREENSHOT
- +#include <GLES/gl.h>
- +#endif
- #include <cutils/iosched_policy.h>
- #include <cutils/log.h>
- @@ -3236,12 +3239,18 @@ status_t SurfaceFlinger::onTransact(
- break;
- }
- case CAPTURE_SCREEN:
- +#ifdef USE_MHEAP_SCREENSHOT
- + case CAPTURE_SCREEN_DEPRECATED:
- +#endif
- {
- // codes that require permission check
- IPCThreadState* ipc = IPCThreadState::self();
- const int pid = ipc->getCallingPid();
- const int uid = ipc->getCallingUid();
- if ((uid != AID_GRAPHICS) &&
- +#ifdef USE_MHEAP_SCREENSHOT
- + (uid != AID_SYSTEM) &&
- +#endif
- !PermissionCache::checkPermission(sReadFramebuffer, pid, uid)) {
- ALOGE("Permission Denial: "
- "can't read framebuffer pid=%d, uid=%d", pid, uid);
- @@ -3610,10 +3619,19 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
- Mutex::Autolock _l(flinger->mStateLock);
- sp<const DisplayDevice> hw(flinger->getDisplayDevice(display));
- bool useReadPixels = this->useReadPixels && !flinger->mGpuToCpuSupported;
- - result = flinger->captureScreenImplLocked(hw, producer,
- - sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
- - useIdentityTransform, rotation, isLocalScreenshot,
- - useReadPixels);
- +#ifdef USE_MHEAP_SCREENSHOT
- + if (!useReadPixels) {
- +#endif
- + result = flinger->captureScreenImplLocked(hw, producer,
- + sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
- + useIdentityTransform, rotation, isLocalScreenshot,
- + useReadPixels);
- +#ifdef USE_MHEAP_SCREENSHOT
- + } else {
- + // Should never get here
- + return BAD_VALUE;
- + }
- +#endif
- static_cast<GraphicProducerWrapper*>(IInterface::asBinder(producer).get())->exit(result);
- return true;
- }
- @@ -3955,6 +3973,139 @@ void SurfaceFlinger::drawWormHoleIfRequired(HWComposer::LayerListIterator& /*cur
- drawWormhole(hw, region);
- }
- +#ifdef USE_MHEAP_SCREENSHOT
- +status_t SurfaceFlinger::captureScreenImplCpuConsumerLocked(
- + const sp<const DisplayDevice>& hw,
- + sp<IMemoryHeap>* heap, uint32_t* w, uint32_t* h,
- + Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- + uint32_t minLayerZ, uint32_t maxLayerZ,
- + bool useIdentityTransform, Transform::orientation_flags rotation)
- +{
- + ATRACE_CALL();
- +
- + // get screen geometry
- + uint32_t hw_w = hw->getWidth();
- + uint32_t hw_h = hw->getHeight();
- +
- + if ((reqWidth > hw_w) || (reqHeight > hw_h)) {
- + ALOGE("size mismatch (%d, %d) > (%d, %d)",
- + reqWidth, reqHeight, hw_w, hw_h);
- + return BAD_VALUE;
- + }
- +
- + reqWidth = (!reqWidth) ? hw_w : reqWidth;
- + reqHeight = (!reqHeight) ? hw_h : reqHeight;
- +
- + status_t result = NO_ERROR;
- +
- + renderScreenImplLocked(
- + hw, sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ, true,
- + useIdentityTransform, rotation);
- +
- + size_t size = reqWidth * reqHeight * 4;
- + // allocate shared memory large enough to hold the
- + // screen capture
- + sp<MemoryHeapBase> base(
- + new MemoryHeapBase(size, 0, "screen-capture") );
- + void *vaddr = base->getBase();
- + glReadPixels(0, 0, reqWidth, reqHeight,
- + GL_RGBA, GL_UNSIGNED_BYTE, vaddr);
- + if (glGetError() == GL_NO_ERROR) {
- + *heap = base;
- + *w = reqWidth;
- + *h = reqHeight;
- + result = NO_ERROR;
- + } else {
- + result = INVALID_OPERATION;
- + }
- +
- + return result;
- +}
- +
- +status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
- + sp<IMemoryHeap>* heap, uint32_t* outWidth, uint32_t* outHeight,
- + Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- + uint32_t minLayerZ, uint32_t maxLayerZ,
- + bool useIdentityTransform, ISurfaceComposer::Rotation rotation)
- +{
- + if (CC_UNLIKELY(display == 0))
- + return BAD_VALUE;
- +
- + // Convert to surfaceflinger's internal rotation type.
- + Transform::orientation_flags rotationFlags;
- + switch (rotation) {
- + case ISurfaceComposer::eRotateNone:
- + rotationFlags = Transform::ROT_0;
- + break;
- + case ISurfaceComposer::eRotate90:
- + rotationFlags = Transform::ROT_90;
- + break;
- + case ISurfaceComposer::eRotate180:
- + rotationFlags = Transform::ROT_180;
- + break;
- + case ISurfaceComposer::eRotate270:
- + rotationFlags = Transform::ROT_270;
- + break;
- + default:
- + rotationFlags = Transform::ROT_0;
- + ALOGE("Invalid rotation passed to captureScreen(): %d\n", rotation);
- + break;
- + }
- +
- + class MessageCaptureScreen : public MessageBase {
- + SurfaceFlinger* flinger;
- + sp<IBinder> display;
- + sp<IMemoryHeap>* heap;
- + uint32_t* outWidth;
- + uint32_t* outHeight;
- + Rect sourceCrop;
- + uint32_t reqWidth, reqHeight;
- + uint32_t minLayerZ,maxLayerZ;
- + bool useIdentityTransform;
- + Transform::orientation_flags rotation;
- + status_t result;
- + public:
- + MessageCaptureScreen(SurfaceFlinger* flinger,
- + const sp<IBinder>& display, sp<IMemoryHeap>* heap,
- + uint32_t* outWidth, uint32_t* outHeight,
- + Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- + uint32_t minLayerZ, uint32_t maxLayerZ,
- + bool useIdentityTransform, Transform::orientation_flags rotation)
- + : flinger(flinger), display(display), heap(heap),
- + outWidth(outWidth), outHeight(outHeight),
- + sourceCrop(sourceCrop), reqWidth(reqWidth), reqHeight(reqHeight),
- + minLayerZ(minLayerZ), maxLayerZ(maxLayerZ),
- + useIdentityTransform(useIdentityTransform),
- + rotation(rotation),
- + result(PERMISSION_DENIED)
- + {
- + }
- + status_t getResult() const {
- + return result;
- + }
- + virtual bool handler() {
- + Mutex::Autolock _l(flinger->mStateLock);
- + sp<const DisplayDevice> hw(flinger->getDisplayDevice(display));
- + result = flinger->captureScreenImplCpuConsumerLocked(hw, heap,
- + outWidth, outHeight,
- + sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
- + useIdentityTransform, rotation);
- + return true;
- + }
- + };
- +
- + sp<MessageBase> msg = new MessageCaptureScreen(this, display, heap,
- + outWidth, outHeight,
- + sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
- + useIdentityTransform, rotationFlags);
- + status_t res = postMessageSync(msg);
- + if (res == NO_ERROR) {
- + res = static_cast<MessageCaptureScreen*>(msg.get())->getResult();
- + }
- + return res;
- +}
- +#endif
- +
- // ---------------------------------------------------------------------------
- SurfaceFlinger::LayerVector::LayerVector() {
- @@ -4012,6 +4163,7 @@ SurfaceFlinger::DisplayDeviceState::DisplayDeviceState(
- }; // namespace android
- +#ifndef USE_MHEAP_SCREENSHOT
- #if defined(__gl_h_)
- #error "don't include gl/gl.h in this file"
- #endif
- @@ -4019,3 +4171,4 @@ SurfaceFlinger::DisplayDeviceState::DisplayDeviceState(
- #if defined(__gl2_h_)
- #error "don't include gl2/gl2.h in this file"
- #endif
- +#endif
- --
- 2.7.4
- From cc6ff705bdeb06e3949673ff3f1c756b6ea02a8f Mon Sep 17 00:00:00 2001
- From: corphish <d97.avinaba@gmail.com>
- Date: Fri, 16 Sep 2016 22:21:08 +0530
- Subject: [PATCH 2/8] surfaceflinger: Use different function names for legacy
- captureScreen method
- With newer API, captureScreen parameters got changed,
- overriding it may actually conflict somewhere else in the source. Solution:
- Use a different name for our functions.
- Signed-off-by: corphish <d97.avinaba@gmail.com>
- ---
- include/gui/ISurfaceComposer.h | 2 +-
- libs/gui/ISurfaceComposer.cpp | 4 ++--
- libs/gui/SurfaceComposerClient.cpp | 2 +-
- services/surfaceflinger/SurfaceFlinger.h | 2 +-
- services/surfaceflinger/SurfaceFlinger_hwc1.cpp | 2 +-
- 5 files changed, 6 insertions(+), 6 deletions(-)
- diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h
- index 725575a..9b32836 100644
- --- a/include/gui/ISurfaceComposer.h
- +++ b/include/gui/ISurfaceComposer.h
- @@ -161,7 +161,7 @@ public:
- /* 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,
- + virtual status_t captureScreenLegacy(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
- uint32_t* width, uint32_t* height,
- Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- uint32_t minLayerZ, uint32_t maxLayerZ,
- diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
- index 5c5caa5..062573b 100644
- --- a/libs/gui/ISurfaceComposer.cpp
- +++ b/libs/gui/ISurfaceComposer.cpp
- @@ -102,7 +102,7 @@ public:
- }
- #ifdef USE_MHEAP_SCREENSHOT
- - virtual status_t captureScreen(
- + virtual status_t captureScreenLegacy(
- const sp<IBinder>& display, sp<IMemoryHeap>* heap,
- uint32_t* width, uint32_t* height,
- Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- @@ -493,7 +493,7 @@ status_t BnSurfaceComposer::onTransact(
- sp<IMemoryHeap> heap;
- uint32_t w, h;
- - status_t res = captureScreen(display, &heap, &w, &h,
- + status_t res = captureScreenLegacy(display, &heap, &w, &h,
- sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
- useIdentityTransform,
- static_cast<ISurfaceComposer::Rotation>(rotation));
- diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
- index f5218f5..9fa675c 100644
- --- a/libs/gui/SurfaceComposerClient.cpp
- +++ b/libs/gui/SurfaceComposerClient.cpp
- @@ -963,7 +963,7 @@ status_t ScreenshotClient::update(const sp<IBinder>& display,
- #ifdef USE_MHEAP_SCREENSHOT
- int ret = -1;
- mHeap = 0;
- - ret = s->captureScreen(display, &mHeap, &mBuffer.width, &mBuffer.height, sourceCrop,
- + ret = s->captureScreenLegacy(display, &mHeap, &mBuffer.width, &mBuffer.height, sourceCrop,
- reqWidth, reqHeight, minLayerZ, maxLayerZ, useIdentityTransform,
- static_cast<ISurfaceComposer::Rotation>(rotation));
- diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
- index 01475e1..059e429 100644
- --- a/services/surfaceflinger/SurfaceFlinger.h
- +++ b/services/surfaceflinger/SurfaceFlinger.h
- @@ -230,7 +230,7 @@ private:
- bool useIdentityTransform, ISurfaceComposer::Rotation rotation,
- bool isCpuConsumer);
- #ifdef USE_MHEAP_SCREENSHOT
- - virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
- + virtual status_t captureScreenLegacy(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
- uint32_t* width, uint32_t* height,
- Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- uint32_t minLayerZ, uint32_t maxLayerZ,
- diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
- index 9deb50b..7ea7f28 100644
- --- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
- +++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
- @@ -4022,7 +4022,7 @@ status_t SurfaceFlinger::captureScreenImplCpuConsumerLocked(
- return result;
- }
- -status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
- +status_t SurfaceFlinger::captureScreenLegacy(const sp<IBinder>& display,
- sp<IMemoryHeap>* heap, uint32_t* outWidth, uint32_t* outHeight,
- Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
- uint32_t minLayerZ, uint32_t maxLayerZ,
- --
- 2.7.4
- From b5af229001bdcc23f71b3dde300497b3632505c9 Mon Sep 17 00:00:00 2001
- From: ghsr <ghsr92@yandex.ru>
- Date: Sat, 18 Nov 2017 12:56:13 +0600
- Subject: [PATCH 3/8] BufferQueueProducer: CAPRI_HWC: disable
- connect/disconnect methods
- ---
- libs/gui/BufferQueueProducer.cpp | 14 ++++++++++++++
- 1 file changed, 14 insertions(+)
- diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp
- index ff85eb5..32852f2 100644
- --- a/libs/gui/BufferQueueProducer.cpp
- +++ b/libs/gui/BufferQueueProducer.cpp
- @@ -66,10 +66,12 @@ status_t BufferQueueProducer::requestBuffer(int slot, sp<GraphicBuffer>* buf) {
- return NO_INIT;
- }
- +#ifndef CAPRI_HWC
- if (mCore->mConnectedApi == BufferQueueCore::NO_CONNECTED_API) {
- BQ_LOGE("requestBuffer: BufferQueue has no connected producer");
- return NO_INIT;
- }
- +#endif
- if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
- BQ_LOGE("requestBuffer: slot index %d out of range [0, %d)",
- @@ -354,10 +356,12 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
- return NO_INIT;
- }
- +#ifndef CAPRI_HWC
- if (mCore->mConnectedApi == BufferQueueCore::NO_CONNECTED_API) {
- BQ_LOGE("dequeueBuffer: BufferQueue has no connected producer");
- return NO_INIT;
- }
- +#endif
- } // Autolock scope
- BQ_LOGV("dequeueBuffer: w=%u h=%u format=%#x, usage=%#x", width, height,
- @@ -569,10 +573,12 @@ status_t BufferQueueProducer::detachBuffer(int slot) {
- return NO_INIT;
- }
- +#ifndef CAPRI_HWC
- if (mCore->mConnectedApi == BufferQueueCore::NO_CONNECTED_API) {
- BQ_LOGE("detachBuffer: BufferQueue has no connected producer");
- return NO_INIT;
- }
- +#endif
- if (mCore->mSharedBufferMode || mCore->mSharedBufferSlot == slot) {
- BQ_LOGE("detachBuffer: cannot detach a buffer in shared buffer mode");
- @@ -628,10 +634,12 @@ status_t BufferQueueProducer::detachNextBuffer(sp<GraphicBuffer>* outBuffer,
- return NO_INIT;
- }
- +#ifndef CAPRI_HWC
- if (mCore->mConnectedApi == BufferQueueCore::NO_CONNECTED_API) {
- BQ_LOGE("detachNextBuffer: BufferQueue has no connected producer");
- return NO_INIT;
- }
- +#endif
- if (mCore->mSharedBufferMode) {
- BQ_LOGE("detachNextBuffer: cannot detach a buffer in shared buffer "
- @@ -678,10 +686,12 @@ status_t BufferQueueProducer::attachBuffer(int* outSlot,
- return NO_INIT;
- }
- +#ifndef CAPRI_HWC
- if (mCore->mConnectedApi == BufferQueueCore::NO_CONNECTED_API) {
- BQ_LOGE("attachBuffer: BufferQueue has no connected producer");
- return NO_INIT;
- }
- +#endif
- if (mCore->mSharedBufferMode) {
- BQ_LOGE("attachBuffer: cannot attach a buffer in shared buffer mode");
- @@ -772,10 +782,12 @@ status_t BufferQueueProducer::queueBuffer(int slot,
- return NO_INIT;
- }
- +#ifndef CAPRI_HWC
- if (mCore->mConnectedApi == BufferQueueCore::NO_CONNECTED_API) {
- BQ_LOGE("queueBuffer: BufferQueue has no connected producer");
- return NO_INIT;
- }
- +#endif
- if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
- BQ_LOGE("queueBuffer: slot index %d out of range [0, %d)",
- @@ -969,10 +981,12 @@ status_t BufferQueueProducer::cancelBuffer(int slot, const sp<Fence>& fence) {
- return NO_INIT;
- }
- +#ifndef CAPRI_HWC
- if (mCore->mConnectedApi == BufferQueueCore::NO_CONNECTED_API) {
- BQ_LOGE("cancelBuffer: BufferQueue has no connected producer");
- return NO_INIT;
- }
- +#endif
- if (mCore->mSharedBufferMode) {
- BQ_LOGE("cancelBuffer: cannot cancel a buffer in shared buffer mode");
- --
- 2.7.4
- From 70db9faf672259d4a0eb76e59da057b5aa46c68a Mon Sep 17 00:00:00 2001
- From: Pawit Pornkitprasan <p.pawit@gmail.com>
- Date: Thu, 14 Nov 2013 15:19:46 +0700
- Subject: [PATCH 4/8] binder: add compat symbol
- Required for older Samsung libtvout
- Change-Id: Ib18d2513570382432d49f302ab041230650372f2
- ---
- libs/binder/IPCThreadState.cpp | 4 ++++
- 1 file changed, 4 insertions(+)
- diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
- index 3efebf7..505570a 100644
- --- a/libs/binder/IPCThreadState.cpp
- +++ b/libs/binder/IPCThreadState.cpp
- @@ -353,6 +353,10 @@ status_t IPCThreadState::clearLastError()
- return err;
- }
- +extern "C" int _ZN7android14IPCThreadState13getCallingPidEv(IPCThreadState *state) {
- + return state->getCallingPid();
- +}
- +
- pid_t IPCThreadState::getCallingPid() const
- {
- return mCallingPid;
- --
- 2.7.4
- From 16e54c7c9db33748c6205c893267e134c1fa8d1d Mon Sep 17 00:00:00 2001
- From: Pawit Pornkitprasan <p.pawit@gmail.com>
- Date: Tue, 10 Dec 2013 19:38:17 +0700
- Subject: [PATCH 5/8] binder: add compat symbols
- Required for libtvservice_binder.so on I9082
- Change-Id: I059e92f19e4c5a911d38faa9c4df549c75c90761
- ---
- libs/binder/Parcel.cpp | 12 ++++++++++++
- 1 file changed, 12 insertions(+)
- diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
- index 52caa24..5de642f 100644
- --- a/libs/binder/Parcel.cpp
- +++ b/libs/binder/Parcel.cpp
- @@ -1267,6 +1267,12 @@ status_t Parcel::writeDupImmutableBlobFileDescriptor(int fd)
- return writeDupFileDescriptor(fd);
- }
- +extern "C" status_t _ZN7android6Parcel5writeERKNS0_26FlattenableHelperInterfaceE(void *parcel, void *val);
- +
- +extern "C" status_t _ZN7android6Parcel5writeERKNS_11FlattenableE(void *parcel, void *val) {
- + return _ZN7android6Parcel5writeERKNS0_26FlattenableHelperInterfaceE(parcel, val);
- +}
- +
- status_t Parcel::write(const FlattenableHelperInterface& val)
- {
- status_t err;
- @@ -2056,6 +2062,12 @@ status_t Parcel::readBlob(size_t len, ReadableBlob* outBlob) const
- return NO_ERROR;
- }
- +extern "C" status_t _ZNK7android6Parcel4readERNS0_26FlattenableHelperInterfaceE(void *parcel, void *val);
- +
- +extern "C" status_t _ZNK7android6Parcel4readERNS_11FlattenableE(void *parcel, void *val) {
- + return _ZNK7android6Parcel4readERNS0_26FlattenableHelperInterfaceE(parcel, val);
- +}
- +
- status_t Parcel::read(FlattenableHelperInterface& val) const
- {
- // size
- --
- 2.7.4
- From 8939ff3547d059ddaf183b362de785fd2cea1815 Mon Sep 17 00:00:00 2001
- From: Pawit Pornkitprasan <p.pawit@gmail.com>
- Date: Mon, 16 Dec 2013 15:45:42 +0700
- Subject: [PATCH 6/8] sf: CAPRI_HWC: fix rotation artifact
- ---
- services/surfaceflinger/SurfaceFlinger_hwc1.cpp | 5 +++++
- 1 file changed, 5 insertions(+)
- diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
- index 7ea7f28..c97bbdf 100644
- --- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
- +++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
- @@ -3747,6 +3747,11 @@ status_t SurfaceFlinger::captureScreenImplLocked(
- {
- ATRACE_CALL();
- +// Rotation artifact problems when useReadPixels is false
- +#ifdef CAPRI_HWC
- + useReadPixels = true;
- +#endif
- +
- // get screen geometry
- uint32_t hw_w = hw->getWidth();
- uint32_t hw_h = hw->getHeight();
- --
- 2.7.4
- From 7b631e848be1b3f1c37af6898a63e394d5efa80b Mon Sep 17 00:00:00 2001
- From: Pawit Pornkitprasan <p.pawit@gmail.com>
- Date: Mon, 15 Dec 2014 23:12:44 +0700
- Subject: [PATCH 7/8] SurfaceComposerClient: don't block RGBA_8888 for
- screenshot on CAPRI_HWC
- Works here and required for ColorFade animation
- Change-Id: Ie7d549bb63e11380d7efcab27b7e4d9f3eb2a1fe
- ---
- libs/gui/SurfaceComposerClient.cpp | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
- index 9fa675c..e8b5aef 100644
- --- a/libs/gui/SurfaceComposerClient.cpp
- +++ b/libs/gui/SurfaceComposerClient.cpp
- @@ -922,7 +922,7 @@ status_t ScreenshotClient::capture(
- uint32_t minLayerZ, uint32_t maxLayerZ, bool useIdentityTransform) {
- sp<ISurfaceComposer> s(ComposerService::getComposerService());
- if (s == NULL) return NO_INIT;
- -#ifdef USE_MHEAP_SCREENSHOT
- +#if defined(USE_MHEAP_SCREENSHOT) && !defined(CAPRI_HWC)
- int format = 0;
- producer->query(NATIVE_WINDOW_FORMAT,&format);
- if (format == PIXEL_FORMAT_RGBA_8888) {
- --
- 2.7.4
- From afba76166beac37b9ad222c2c62d2a65890140e6 Mon Sep 17 00:00:00 2001
- From: Pawit Pornkitprasan <p.pawit@gmail.com>
- Date: Sun, 11 Oct 2015 15:28:51 +0700
- Subject: [PATCH 8/8] binder: add compat symbol for RIL
- ---
- libs/binder/Parcel.cpp | 6 ++++++
- 1 file changed, 6 insertions(+)
- diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
- index 5de642f..eb9c566 100644
- --- a/libs/binder/Parcel.cpp
- +++ b/libs/binder/Parcel.cpp
- @@ -1082,6 +1082,12 @@ status_t Parcel::writeString16(const String16& str)
- return writeString16(str.string(), str.size());
- }
- +extern "C" status_t _ZN7android6Parcel13writeString16EPKDsj(void *parcel, const char16_t* str, size_t len);
- +
- +extern "C" status_t _ZN7android6Parcel13writeString16EPKtj(void *parcel, const char16_t* str, size_t len) {
- + return _ZN7android6Parcel13writeString16EPKDsj(parcel, str, len);
- +}
- +
- status_t Parcel::writeString16(const char16_t* str, size_t len)
- {
- if (str == NULL) return writeInt32(-1);
- --
- 2.7.4
Add Comment
Please, Sign In to add comment