diff options
| author | John Reck <jreck@google.com> | 2015-01-21 07:46:37 -0800 |
|---|---|---|
| committer | John Reck <jreck@google.com> | 2015-01-30 12:46:09 -0800 |
| commit | 5515637540bedd8fc9a1a6e46a4b512dd45520a5 (patch) | |
| tree | c19b93e74fd9597bb2bd038fa303cb2695e609d3 /libs/hwui/renderthread | |
| parent | 50d23adfe26bf0cf9a34138efc299eaec04127e9 (diff) | |
| download | frameworks_base-5515637540bedd8fc9a1a6e46a4b512dd45520a5.zip frameworks_base-5515637540bedd8fc9a1a6e46a4b512dd45520a5.tar.gz frameworks_base-5515637540bedd8fc9a1a6e46a4b512dd45520a5.tar.bz2 | |
Add a WAIT_FOR_GPU_COMPLETION option
Change-Id: I18d526120651676109200bfd5da87cafcd7e3d13
Diffstat (limited to 'libs/hwui/renderthread')
| -rw-r--r-- | libs/hwui/renderthread/EglManager.cpp | 18 | ||||
| -rw-r--r-- | libs/hwui/renderthread/EglManager.h | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp index c4feb41..28aa938 100644 --- a/libs/hwui/renderthread/EglManager.cpp +++ b/libs/hwui/renderthread/EglManager.cpp @@ -22,10 +22,13 @@ #include <cutils/log.h> #include <cutils/properties.h> +#include <EGL/eglext.h> #define PROPERTY_RENDER_DIRTY_REGIONS "debug.hwui.render_dirty_regions" #define GLES_VERSION 2 +#define WAIT_FOR_GPU_COMPLETION 0 + // Android-specific addition that is used to show when frames began in systrace EGLAPI void EGLAPIENTRY eglBeginFrame(EGLDisplay dpy, EGLSurface surface); @@ -263,6 +266,14 @@ void EglManager::beginFrame(EGLSurface surface, EGLint* width, EGLint* height) { bool EglManager::swapBuffers(EGLSurface surface) { mInFrame = false; + +#if WAIT_FOR_GPU_COMPLETION + { + ATRACE_NAME("Finishing GPU work"); + fence(); + } +#endif + eglSwapBuffers(mEglDisplay, surface); EGLint err = eglGetError(); if (CC_LIKELY(err == EGL_SUCCESS)) { @@ -281,6 +292,13 @@ bool EglManager::swapBuffers(EGLSurface surface) { return false; } +void EglManager::fence() { + EGLSyncKHR fence = eglCreateSyncKHR(mEglDisplay, EGL_SYNC_FENCE_KHR, NULL); + eglClientWaitSyncKHR(mEglDisplay, fence, + EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR); + eglDestroySyncKHR(mEglDisplay, fence); +} + void EglManager::cancelFrame() { mInFrame = false; } diff --git a/libs/hwui/renderthread/EglManager.h b/libs/hwui/renderthread/EglManager.h index e12db3a..b1a18a9 100644 --- a/libs/hwui/renderthread/EglManager.h +++ b/libs/hwui/renderthread/EglManager.h @@ -55,6 +55,8 @@ public: void setTextureAtlas(const sp<GraphicBuffer>& buffer, int64_t* map, size_t mapSize); + void fence(); + private: friend class RenderThread; |
