Skip to content

Commit 0585744

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Discard framebuffer commands when we redraw the entire buffer" into jb-mr1-dev
2 parents 709c542 + 45e4c3d commit 0585744

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

libs/hwui/DisplayListRenderer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,8 +1412,12 @@ int DisplayListRenderer::prepareDirty(float left, float top,
14121412
mSnapshot = new Snapshot(mFirstSnapshot,
14131413
SkCanvas::kMatrix_SaveFlag | SkCanvas::kClip_SaveFlag);
14141414
mSaveCount = 1;
1415+
14151416
mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
1417+
mDirtyClip = opaque;
1418+
14161419
mRestoreSaveCount = -1;
1420+
14171421
return DrawGlInfo::kStatusDone; // No invalidate needed at record-time
14181422
}
14191423

libs/hwui/LayerRenderer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ void LayerRenderer::flushLayer(Layer* layer) {
332332
if (Caches::getInstance().extensions.hasDiscardFramebuffer()) {
333333
GLuint previousFbo;
334334
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &previousFbo);
335-
336-
GLenum attachments = GL_COLOR_ATTACHMENT0;
337335
if (fbo != previousFbo) glBindFramebuffer(GL_FRAMEBUFFER, fbo);
338-
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, &attachments);
336+
337+
const GLenum attachments[] = { GL_COLOR_ATTACHMENT0 };
338+
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, attachments);
339339

340340
if (fbo != previousFbo) glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
341341
}

libs/hwui/OpenGLRenderer.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ int OpenGLRenderer::prepareDirty(float left, float top, float right, float botto
173173
mSnapshot->setClip(left, top, right, bottom);
174174
mDirtyClip = opaque;
175175

176+
// If we know that we are going to redraw the entire framebuffer,
177+
// perform a discard to let the driver know we don't need to preserve
178+
// the back buffer for this frame.
179+
if (mCaches.extensions.hasDiscardFramebuffer() &&
180+
left <= 0.0f && top <= 0.0f && right >= mWidth && bottom >= mHeight) {
181+
const GLenum attachments[] = { getTargetFbo() == 0 ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0 };
182+
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, attachments);
183+
}
184+
176185
syncState();
177186

178187
if (!opaque) {

0 commit comments

Comments
 (0)