From 9707f4df640c3369f873a934bb05ffa5a68a5640 Mon Sep 17 00:00:00 2001 From: Riley Andrews Date: Thu, 23 Oct 2014 16:17:04 -0700 Subject: [PATCH] Add glFlush in surfaceflinger screenshot code. After creating a syncKHR object with type EGL_SYNC_NATIVE_FENCE_ANDROID, glFlush must be called before the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute is populated with a sync fd. We currently call eglDupNativeFenceFDANDROID before issuing the flush. Bug 18052459 Taken verbatim from matthew.k.gumbel@intel.com. Change-Id: I3781d14f92862076e2bca7d27341a6dc6e7e3775 --- services/surfaceflinger/RenderEngine/RenderEngine.cpp | 4 ++++ services/surfaceflinger/RenderEngine/RenderEngine.h | 1 + services/surfaceflinger/SurfaceFlinger.cpp | 2 ++ 3 files changed, 7 insertions(+) diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.cpp b/services/surfaceflinger/RenderEngine/RenderEngine.cpp index d5d5da8fc..a77e0e9d2 100644 --- a/services/surfaceflinger/RenderEngine/RenderEngine.cpp +++ b/services/surfaceflinger/RenderEngine/RenderEngine.cpp @@ -219,6 +219,10 @@ void RenderEngine::fillRegionWithColor(const Region& region, uint32_t height, drawMesh(mesh); } +void RenderEngine::flush() { + glFlush(); +} + void RenderEngine::clearWithColor(float red, float green, float blue, float alpha) { glClearColor(red, green, blue, alpha); glClear(GL_COLOR_BUFFER_BIT); diff --git a/services/surfaceflinger/RenderEngine/RenderEngine.h b/services/surfaceflinger/RenderEngine/RenderEngine.h index acbff9b5a..8d7529cb3 100644 --- a/services/surfaceflinger/RenderEngine/RenderEngine.h +++ b/services/surfaceflinger/RenderEngine/RenderEngine.h @@ -67,6 +67,7 @@ public: virtual void dump(String8& result); // helpers + void flush(); void clearWithColor(float red, float green, float blue, float alpha); void fillRegionWithColor(const Region& region, uint32_t height, float red, float green, float blue, float alpha); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 96a8adbaf..50968e793 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3201,6 +3201,8 @@ status_t SurfaceFlinger::captureScreenImplLocked( EGLSyncKHR sync; if (!DEBUG_SCREENSHOTS) { sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); + // native fence fd will not be populated until flush() is done. + getRenderEngine().flush(); } else { sync = EGL_NO_SYNC_KHR; }