From 7c25aab491707f7324f9941b8cfa9bd2b4b97e76 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Thu, 18 Oct 2012 15:05:02 -0700 Subject: Defer layer rendering to avoid stalls Bug #7326824 When a layer is taken out of the cache and initialized it gets cleared to prepare it for future rendering. This triggers the following sequence of operations: glBindFramebuffer(layer.fbo) attach texture storage to FBO glClear() glBindFramebuffer(defaultFbo) The clear forces a resolve on tilers which stalls the CPU for a little while, thus producing jank during animations. This change moves the clear to the next frame when we know we will have to execute a resolve anyway. Change-Id: Ic1939c25df20ed65a4c48dc81ee549b2cd8b6ec3 --- libs/hwui/OpenGLRenderer.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'libs/hwui/OpenGLRenderer.cpp') diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index b6be5b3d61ca..914516c593b0 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -165,11 +165,12 @@ void OpenGLRenderer::initViewport(int width, int height) { mFirstSnapshot->viewport.set(0, 0, width, height); } -int OpenGLRenderer::prepare(bool opaque) { +status_t OpenGLRenderer::prepare(bool opaque) { return prepareDirty(0.0f, 0.0f, mWidth, mHeight, opaque); } -int OpenGLRenderer::prepareDirty(float left, float top, float right, float bottom, bool opaque) { +status_t OpenGLRenderer::prepareDirty(float left, float top, float right, float bottom, + bool opaque) { mCaches.clearGarbage(); mSnapshot = new Snapshot(mFirstSnapshot, @@ -203,15 +204,18 @@ int OpenGLRenderer::prepareDirty(float left, float top, float right, float botto debugOverdraw(true, true); + return clear(left, top, right, bottom, opaque); +} + +status_t OpenGLRenderer::clear(float left, float top, float right, float bottom, bool opaque) { if (!opaque) { mCaches.enableScissor(); mCaches.setScissor(left, mSnapshot->height - bottom, right - left, bottom - top); glClear(GL_COLOR_BUFFER_BIT); return DrawGlInfo::kStatusDrew; - } else { - mCaches.resetScissor(); } + mCaches.resetScissor(); return DrawGlInfo::kStatusDone; } @@ -743,6 +747,7 @@ bool OpenGLRenderer::createLayer(float left, float top, float right, float botto bounds.getWidth() / float(layer->getWidth()), 0.0f); layer->setColorFilter(mColorFilter); layer->setBlend(true); + layer->setDirty(false); // Save the layer in the snapshot mSnapshot->flags |= Snapshot::kFlagIsLayer; -- cgit v1.2.3-59-g8ed1b