Don't reuse a back buffer after a swap if the content or surface changed (bug 1399692 part 9, r=bas) draft
authorRyan Hunt <rhunt@eqrion.net>
Sun, 05 Nov 2017 10:38:47 -0500
changeset 695950 e46827626f63ba84547fc191cde05d40a23e5249
parent 695949 3e2d7d0481465fd2ed588f7b36fe49a7ec2c7a9f
child 695951 cf0b0687a3c1ec690fffe1e81bd84447db38fe4f
push id88593
push userbmo:rhunt@eqrion.net
push dateFri, 10 Nov 2017 01:41:10 +0000
reviewersbas
bugs1399692
milestone58.0a1
Don't reuse a back buffer after a swap if the content or surface changed (bug 1399692 part 9, r=bas) MozReview-Commit-ID: HGAxkeyESbc
gfx/layers/client/ContentClient.cpp
--- a/gfx/layers/client/ContentClient.cpp
+++ b/gfx/layers/client/ContentClient.cpp
@@ -497,20 +497,29 @@ ContentClient::CalculateBufferForPaint(P
       // We need to validate the entire buffer, to make sure that only valid
       // pixels are sampled.
       neededRegion = destBufferRect;
     }
 
     // If we have an existing buffer, but the content type has changed or we
     // have transitioned into/out of component alpha, then we need to recreate it.
     bool needsComponentAlpha = (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA);
-    bool changedSurfaceOrContent = frontBuffer &&
-                                   (contentType != frontBuffer->GetContentType() ||
-                                    needsComponentAlpha != frontBuffer->HaveBufferOnWhite());
-    if (canKeepBufferContents && changedSurfaceOrContent) {
+    bool backBufferChangedSurface = mBuffer &&
+                                    (contentType != mBuffer->GetContentType() ||
+                                     needsComponentAlpha != mBuffer->HaveBufferOnWhite());
+    if (canKeepBufferContents && backBufferChangedSurface) {
+      // We cannot reuse the back buffer if the surface type or content type
+      // changed. We may have to also invalidate, but only if the front buffer
+      // also changed.
+      canReuseBuffer = false;
+    }
+    bool frontBufferChangedSurface = frontBuffer &&
+                                     (contentType != frontBuffer->GetContentType() ||
+                                      needsComponentAlpha != frontBuffer->HaveBufferOnWhite());
+    if (canKeepBufferContents && frontBufferChangedSurface) {
       // Restart the decision process; we won't re-enter since we guard on
       // being able to keep the buffer contents.
       canReuseBuffer = false;
       canKeepBufferContents = false;
       validRegion.SetEmpty();
       continue;
     }