Bug 1081911 - Null pointer check (wallpaper) for destDTBufferOnWhite. r=mattwoodrow, a=sledru
authorMilan Sreckovic <milan@mozilla.com>
Mon, 02 Feb 2015 17:46:22 -0500
changeset 243682 8f52ac825ba7
parent 243681 41f8742f7c93
child 243683 b0684ad8a47c
push id4434
push userryanvm@gmail.com
push date2015-02-04 16:40 +0000
treeherdermozilla-beta@8f52ac825ba7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, sledru
bugs1081911
milestone36.0
Bug 1081911 - Null pointer check (wallpaper) for destDTBufferOnWhite. r=mattwoodrow, a=sledru
gfx/layers/RotatedBuffer.cpp
--- a/gfx/layers/RotatedBuffer.cpp
+++ b/gfx/layers/RotatedBuffer.cpp
@@ -622,20 +622,19 @@ RotatedContentBuffer::BeginPaint(Painted
             mBufferRect = destBufferRect;
             mBufferRotation = nsIntPoint(0, 0);
           }
 
           if (!result.mDidSelfCopy) {
             destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
             CreateBuffer(result.mContentType, destBufferRect, bufferFlags,
                          &destDTBuffer, &destDTBufferOnWhite);
-            MOZ_ASSERT(destDTBuffer, "Failed to allocate a texture");
-            MOZ_ASSERT(destDTBufferOnWhite || !(bufferFlags & BUFFER_COMPONENT_ALPHA),
-                       "Failed to allocate the texture on white");
-            if (!destDTBuffer) {
+            if (!destDTBuffer ||
+                (!destDTBufferOnWhite && (bufferFlags & BUFFER_COMPONENT_ALPHA))) {
+              gfxCriticalError() << "Failed 1 buffer db=" << hexa(destDTBuffer.get()) << " dw=" << hexa(destDTBufferOnWhite.get()) << " for " << destBufferRect.x << ", " << destBufferRect.y << ", " << destBufferRect.width << ", " << destBufferRect.height;
               return result;
             }
           }
         }
       } else {
         mBufferRect = destBufferRect;
         mBufferRotation = newRotation;
       }
@@ -645,20 +644,19 @@ RotatedContentBuffer::BeginPaint(Painted
       // set destBuffer.
       mBufferRect = destBufferRect;
       mBufferRotation = nsIntPoint(0,0);
     }
   } else {
     // The buffer's not big enough, so allocate a new one
     CreateBuffer(result.mContentType, destBufferRect, bufferFlags,
                  &destDTBuffer, &destDTBufferOnWhite);
-    MOZ_ASSERT(destDTBuffer, "Failed to allocate a texture");
-    MOZ_ASSERT(destDTBufferOnWhite || !(bufferFlags & BUFFER_COMPONENT_ALPHA),
-               "Failed to allocate the texture on white");
-    if (!destDTBuffer) {
+    if (!destDTBuffer ||
+        (!destDTBufferOnWhite && (bufferFlags & BUFFER_COMPONENT_ALPHA))) {
+      gfxCriticalError() << "Failed 2 buffer db=" << hexa(destDTBuffer.get()) << " dw=" << hexa(destDTBufferOnWhite.get()) << " for " << destBufferRect.x << ", " << destBufferRect.y << ", " << destBufferRect.width << ", " << destBufferRect.height;
       return result;
     }
   }
 
   NS_ASSERTION(!(aFlags & PAINT_WILL_RESAMPLE) || destBufferRect == neededRegion.GetBounds(),
                "If we're resampling, we need to validate the entire buffer");
 
   // If we have no buffered data already, then destBuffer will be a fresh buffer
@@ -674,22 +672,21 @@ RotatedContentBuffer::BeginPaint(Painted
       if (!EnsureBuffer()) {
         return result;
       }
        MOZ_ASSERT(mDTBuffer, "Have we got a Thebes buffer for some reason?");
       DrawBufferWithRotation(destDTBuffer, BUFFER_BLACK, 1.0, CompositionOp::OP_SOURCE);
       destDTBuffer->SetTransform(Matrix());
 
       if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
-        NS_ASSERTION(destDTBufferOnWhite, "Must have a white buffer!");
-        destDTBufferOnWhite->SetTransform(mat);
-        if (!EnsureBufferOnWhite()) {
+        if (!destDTBufferOnWhite || !EnsureBufferOnWhite()) {
           return result;
         }
         MOZ_ASSERT(mDTBufferOnWhite, "Have we got a Thebes buffer for some reason?");
+        destDTBufferOnWhite->SetTransform(mat);
         DrawBufferWithRotation(destDTBufferOnWhite, BUFFER_WHITE, 1.0, CompositionOp::OP_SOURCE);
         destDTBufferOnWhite->SetTransform(Matrix());
       }
     }
 
     mDTBuffer = destDTBuffer.forget();
     mDTBufferOnWhite = destDTBufferOnWhite.forget();
     mBufferRect = destBufferRect;