From c96955d9bb997b51be5fa929b5a67349d0459c3a Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 26 Feb 2016 14:56:44 -0800 Subject: Always swap buffers if using partial update extension Bug: 27379093 Change-Id: Ifda18287248e4ae07d4bf2ae9642a9d23039e81f --- libs/hwui/renderthread/CanvasContext.cpp | 2 +- libs/hwui/renderthread/EglManager.cpp | 4 ++++ libs/hwui/renderthread/EglManager.h | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 4f528b1a3cd1..249d83f50627 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -476,7 +476,7 @@ void CanvasContext::draw() { // metrics the frame was swapped at this point mCurrentFrameInfo->markSwapBuffers(); - if (drew) { + if (drew || mEglManager.damageRequiresSwap()) { if (CC_UNLIKELY(!mEglManager.swapBuffers(frame, screenDirty))) { setSurface(nullptr); } diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp index 364d4dda1e7f..ac6a28fe6289 100644 --- a/libs/hwui/renderthread/EglManager.cpp +++ b/libs/hwui/renderthread/EglManager.cpp @@ -324,6 +324,10 @@ void EglManager::damageFrame(const Frame& frame, const SkRect& dirty) { #endif } +bool EglManager::damageRequiresSwap() { + return EglExtensions.setDamage && mSwapBehavior == SwapBehavior::BufferAge; +} + bool EglManager::swapBuffers(const Frame& frame, const SkRect& screenDirty) { if (CC_UNLIKELY(Properties::waitForGpuCompletion)) { diff --git a/libs/hwui/renderthread/EglManager.h b/libs/hwui/renderthread/EglManager.h index 62b5b99a6e30..459baed70e40 100644 --- a/libs/hwui/renderthread/EglManager.h +++ b/libs/hwui/renderthread/EglManager.h @@ -70,6 +70,10 @@ public: bool makeCurrent(EGLSurface surface, EGLint* errOut = nullptr); Frame beginFrame(EGLSurface surface); void damageFrame(const Frame& frame, const SkRect& dirty); + // If this returns true it is mandatory that swapBuffers is called + // if damageFrame is called without subsequent calls to damageFrame(). + // See EGL_KHR_partial_update for more information + bool damageRequiresSwap(); bool swapBuffers(const Frame& frame, const SkRect& screenDirty); // Returns true iff the surface is now preserving buffers. -- cgit v1.2.3-59-g8ed1b