From b4b1730abb7824dc084468c4942f010d94a7e039 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 20 Mar 2013 18:36:41 -0700 Subject: [PATCH] only use glReadPixels() when needed when taking screenshots some drivers don't support this yet, so we use a system property to enable the glReadPixels "workaround" for them: ro.bq.gpu_to_cpu_unsupported=1 Change-Id: I74d6a3a8f0cee8d5a507b72c760cf247e39195e0 --- services/surfaceflinger/SurfaceFlinger.cpp | 12 ++++++++---- services/surfaceflinger/SurfaceFlinger.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 854692056..2d84c54cf 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -109,6 +109,9 @@ SurfaceFlinger::SurfaceFlinger() // debugging stuff... char value[PROPERTY_VALUE_MAX]; + property_get("ro.bq.gpu_to_cpu_unsupported", value, "0"); + mGpuToCpuSupported = !!atoi(value); + property_get("debug.sf.showupdates", value, "0"); mDebugRegion = atoi(value); @@ -2546,15 +2549,16 @@ status_t SurfaceFlinger::captureScreen(const sp& display, virtual bool handler() { Mutex::Autolock _l(flinger->mStateLock); sp hw(flinger->getDisplayDevice(display)); - // TODO: if we know the GL->CPU path works, we can call + // When we know the GL->CPU path works, we can call // captureScreenImplLocked() directly, instead of using the // "CpuConsumer" version, which is much less efficient -- it is // however needed by some older drivers. - if (isCpuConsumer) { - result = flinger->captureScreenImplCpuConsumerLocked(hw, + + if (flinger->mGpuToCpuSupported || !isCpuConsumer) { + result = flinger->captureScreenImplLocked(hw, producer, reqWidth, reqHeight, minLayerZ, maxLayerZ); } else { - result = flinger->captureScreenImplLocked(hw, + result = flinger->captureScreenImplCpuConsumerLocked(hw, producer, reqWidth, reqHeight, minLayerZ, maxLayerZ); } return true; diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 2aacfe753..ef88437bf 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -412,6 +412,7 @@ private: HWComposer* mHwc; GLuint mProtectedTexName; nsecs_t mBootTime; + bool mGpuToCpuSupported; sp mEventThread; GLint mMaxViewportDims[2]; GLint mMaxTextureSize;