diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.cpp b/services/surfaceflinger/RenderEngine/RenderEngine.cpp index c36fcde3f..ba82cadb0 100644 --- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp +++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp @@ -201,6 +201,10 @@ void RenderEngine::deleteTextures(size_t count, uint32_t const* names) { glDeleteTextures(count, names); } +void RenderEngine::readPixels(size_t l, size_t b, size_t w, size_t h, uint32_t* pixels) { + glReadPixels(l, b, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); +} + void RenderEngine::dump(String8& result) { const GLExtensions& extensions(GLExtensions::getInstance()); result.appendFormat("GLES: %s, %s, %s\n", diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.h b/services/surfaceflinger/RenderEngine/RenderEngine.h index 5f331d4a4..3c7f9ab09 100644 --- a/services/surfaceflinger/RenderEngine/RenderEngine.h +++ b/services/surfaceflinger/RenderEngine/RenderEngine.h @@ -70,6 +70,7 @@ public: void disableScissor(); void genTextures(size_t count, uint32_t* names); void deleteTextures(size_t count, uint32_t const* names); + void readPixels(size_t l, size_t b, size_t w, size_t h, uint32_t* pixels); class BindImageAsFramebuffer { RenderEngine& mEngine; @@ -106,8 +107,6 @@ public: virtual size_t getMaxTextureSize() const = 0; virtual size_t getMaxViewportDims() const = 0; - - EGLContext getEGLContext() const; }; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 02aef2b27..879c91187 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2832,6 +2832,15 @@ status_t SurfaceFlinger::captureScreenImplLocked( // dependent on the context's EGLConfig. renderScreenImplLocked(hw, reqWidth, reqHeight, minLayerZ, maxLayerZ, true); + + if (DEBUG_SCREENSHOTS) { + uint32_t* pixels = new uint32_t[reqWidth*reqHeight]; + getRenderEngine().readPixels(0, 0, reqWidth, reqHeight, pixels); + checkScreenshot(reqWidth, reqHeight, reqWidth, pixels, + hw, minLayerZ, maxLayerZ); + delete [] pixels; + } + } else { ALOGE("got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot"); result = INVALID_OPERATION; @@ -2852,13 +2861,12 @@ status_t SurfaceFlinger::captureScreenImplLocked( return result; } -void SurfaceFlinger::checkScreenshot(const sp& buf, void const* vaddr, - const sp& hw, - uint32_t minLayerZ, uint32_t maxLayerZ) { +void SurfaceFlinger::checkScreenshot(size_t w, size_t s, size_t h, void const* vaddr, + const sp& hw, uint32_t minLayerZ, uint32_t maxLayerZ) { if (DEBUG_SCREENSHOTS) { - for (ssize_t y=0 ; yheight ; y++) { - uint32_t const * p = (uint32_t const *)vaddr + y*buf->stride; - for (ssize_t x=0 ; xwidth ; x++) { + for (size_t y=0 ; y& args, size_t& index, String8& result) const; bool startDdmConnection(); static void appendSfConfigString(String8& result); - void checkScreenshot(const sp& buf, void const* vaddr, + void checkScreenshot(size_t w, size_t s, size_t h, void const* vaddr, const sp& hw, uint32_t minLayerZ, uint32_t maxLayerZ);