Don't copy over regions that will be painted in this frame (bug 1399692 part 8, r=bas) draft
authorRyan Hunt <rhunt@eqrion.net>
Sat, 04 Nov 2017 14:52:31 -0400
changeset 695949 3e2d7d0481465fd2ed588f7b36fe49a7ec2c7a9f
parent 695948 10a55540d515c4654071d35388a9b681425e9c6e
child 695950 e46827626f63ba84547fc191cde05d40a23e5249
push id88593
push userbmo:rhunt@eqrion.net
push dateFri, 10 Nov 2017 01:41:10 +0000
reviewersbas
bugs1399692
milestone58.0a1
Don't copy over regions that will be painted in this frame (bug 1399692 part 8, r=bas) We do the same in FinalizeFrame, so we should do it here. MozReview-Commit-ID: JTKDj8yrtI2
gfx/layers/client/ContentClient.cpp
--- a/gfx/layers/client/ContentClient.cpp
+++ b/gfx/layers/client/ContentClient.cpp
@@ -248,33 +248,38 @@ ContentClient::BeginPaint(PaintedLayer* 
 
     if (!newBuffer->Lock(lockMode)) {
       gfxCriticalNote << "Failed to lock new back buffer.";
       return result;
     }
 
     // If we have an existing front buffer, copy it into the new back buffer
     if (RefPtr<RotatedBuffer> frontBuffer = GetFrontBuffer()) {
-      RefPtr<CapturedBufferState> bufferState = new CapturedBufferState();
+      nsIntRegion updateRegion = newBuffer->BufferRect();
+      updateRegion.Sub(updateRegion, result.mRegionToDraw);
 
-      bufferState->mBufferCopy = Some(CapturedBufferState::Copy {
-        frontBuffer->ShallowCopy(),
-        newBuffer->ShallowCopy(),
-        newBuffer->BufferRect(),
-      });
+      if (!updateRegion.IsEmpty()) {
+        RefPtr<CapturedBufferState> bufferState = new CapturedBufferState();
 
-      // If we're async painting then return the buffer state to
-      // be dispatched to the paint thread, otherwise do it now
-      if (asyncPaint) {
-        MOZ_ASSERT(!result.mBufferState);
-        result.mBufferState = bufferState;
-      } else {
-        if (!bufferState->PrepareBuffer()) {
-          gfxCriticalNote << "Failed to copy front buffer to back buffer.";
-          return result;
+        bufferState->mBufferCopy = Some(CapturedBufferState::Copy {
+          frontBuffer->ShallowCopy(),
+          newBuffer->ShallowCopy(),
+          updateRegion.GetBounds(),
+        });
+
+        // If we're async painting then return the buffer state to
+        // be dispatched to the paint thread, otherwise do it now
+        if (asyncPaint) {
+          MOZ_ASSERT(!result.mBufferState);
+          result.mBufferState = bufferState;
+        } else {
+          if (!bufferState->PrepareBuffer()) {
+            gfxCriticalNote << "Failed to copy front buffer to back buffer.";
+            return result;
+          }
         }
       }
 
       if (dest.mMustRemoveFrontBuffer) {
         Clear();
       }
     }