Bug 635035, part 2: Ensure that the buffer rect only grows in the presence of scaling. r=roc
authorChris Jones <jones.chris.g@gmail.com>
Wed, 09 Mar 2011 11:27:37 -0600
changeset 63367 5a3f1c4e63c198dfe1fef41ebb5bfb503ef4f66c
parent 63366 439f8db100d7d77257c5edbe3436e95e5e347002
child 63368 173971a4af7efeaeead7a8b38a1c3abb9e879eee
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs635035
milestone2.0b13pre
Bug 635035, part 2: Ensure that the buffer rect only grows in the presence of scaling. r=roc
gfx/layers/ThebesLayerBuffer.cpp
--- a/gfx/layers/ThebesLayerBuffer.cpp
+++ b/gfx/layers/ThebesLayerBuffer.cpp
@@ -201,20 +201,22 @@ ThebesLayerBuffer::BeginPaint(ThebesLaye
     destBufferDims = ScaledSize(neededRegion.GetBounds().Size(),
                                 aXResolution, aYResolution);
     canReuseBuffer = BufferSizeOkFor(destBufferDims);
 
     if (canReuseBuffer) {
       if (mBufferRect.Contains(neededRegion.GetBounds())) {
         // We don't need to adjust mBufferRect.
         destBufferRect = mBufferRect;
-      } else {
+      } else if (neededRegion.GetBounds().Size() <= mBufferRect.Size()) {
         // The buffer's big enough but doesn't contain everything that's
         // going to be visible. We'll move it.
         destBufferRect = nsIntRect(neededRegion.GetBounds().TopLeft(), mBufferRect.Size());
+      } else {
+        destBufferRect = neededRegion.GetBounds();
       }
     } else {
       destBufferRect = neededRegion.GetBounds();
     }
 
     if ((aFlags & PAINT_WILL_RESAMPLE) &&
         (neededRegion.GetBounds() != destBufferRect ||
          neededRegion.GetNumRects() > 1)) {
@@ -246,16 +248,19 @@ ThebesLayerBuffer::BeginPaint(ThebesLaye
       // Restart decision process with the cleared buffer. We can only go
       // around the loop one more iteration, since mBuffer is null now.
       continue;
     }
 
     break;
   }
 
+  NS_ASSERTION(destBufferRect.Contains(neededRegion.GetBounds()),
+               "Destination rect doesn't contain what we need to paint");
+
   result.mRegionToDraw.Sub(neededRegion, validRegion);
   if (result.mRegionToDraw.IsEmpty())
     return result;
 
   // If we have non-identity resolution then mBufferRotation might not fall
   // on a buffer pixel boundary, in which case that row of pixels will contain
   // a mix of two completely different rows of the layer, which would be
   // a catastrophe. So disable rotation in that case.