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
This commit is contained in:
Riley Andrews 2014-10-23 16:17:04 -07:00
parent afe2b1fadd
commit 9707f4df64
3 changed files with 7 additions and 0 deletions

View File

@ -219,6 +219,10 @@ void RenderEngine::fillRegionWithColor(const Region& region, uint32_t height,
drawMesh(mesh); drawMesh(mesh);
} }
void RenderEngine::flush() {
glFlush();
}
void RenderEngine::clearWithColor(float red, float green, float blue, float alpha) { void RenderEngine::clearWithColor(float red, float green, float blue, float alpha) {
glClearColor(red, green, blue, alpha); glClearColor(red, green, blue, alpha);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);

View File

@ -67,6 +67,7 @@ public:
virtual void dump(String8& result); virtual void dump(String8& result);
// helpers // helpers
void flush();
void clearWithColor(float red, float green, float blue, float alpha); void clearWithColor(float red, float green, float blue, float alpha);
void fillRegionWithColor(const Region& region, uint32_t height, void fillRegionWithColor(const Region& region, uint32_t height,
float red, float green, float blue, float alpha); float red, float green, float blue, float alpha);

View File

@ -3201,6 +3201,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(
EGLSyncKHR sync; EGLSyncKHR sync;
if (!DEBUG_SCREENSHOTS) { if (!DEBUG_SCREENSHOTS) {
sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
// native fence fd will not be populated until flush() is done.
getRenderEngine().flush();
} else { } else {
sync = EGL_NO_SYNC_KHR; sync = EGL_NO_SYNC_KHR;
} }