Bug 725925 - ShadowableThebesLayer does useless extra composite into 1x1 fake surface. r=cjones
☠☠ backed out by 80910c61fba9 ☠ ☠
authorOleg Romashin <romaxa@gmail.com>
Fri, 10 Feb 2012 11:22:21 -0800
changeset 86639 b43f4d9f38daa89efbea5a3997ef4405f29a3371
parent 86638 6b12265a4aa090d42d4af46aac03793ce571af3e
child 86640 80910c61fba9ddede17045274ce9917b218a43c4
push idunknown
push userunknown
push dateunknown
reviewerscjones
bugs725925
milestone13.0a1
Bug 725925 - ShadowableThebesLayer does useless extra composite into 1x1 fake surface. r=cjones
gfx/layers/basic/BasicLayers.cpp
widget/xpwidgets/PuppetWidget.cpp
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -758,17 +758,19 @@ BasicThebesLayer::PaintThebes(gfxContext
       NS_ASSERTION(state.mRegionToDraw.IsEmpty(),
                    "If we need to draw, we should have a context");
     }
   }
 
   if (BasicManager()->IsTransactionIncomplete())
     return;
 
-  if (!IsHidden()) {
+  gfxRect clipExtents;
+  clipExtents = aContext->GetClipExtents();
+  if (!IsHidden() && clipExtents.IsEmpty()) {
     AutoSetOperator setOperator(aContext, GetOperator());
     mBuffer.DrawTo(this, aContext, opacity);
   }
 
   for (PRUint32 i = 0; i < readbackUpdates.Length(); ++i) {
     ReadbackProcessor::Update& update = readbackUpdates[i];
     nsIntPoint offset = update.mLayer->GetBackgroundLayerOffset();
     nsRefPtr<gfxContext> ctx =
@@ -1941,26 +1943,32 @@ BasicLayerManager::PaintLayer(gfxContext
   if (needsGroup) {
     bool blitComplete = false;
     if (is2D) {
       PopGroupToSourceWithCachedSurface(aTarget, groupTarget);
     } else {
       NS_ABORT_IF_FALSE(untransformedSurface, 
                         "We should always allocate an untransformed surface with 3d transforms!");
 
-      gfxPoint offset;
-      bool dontBlit = needsClipToVisibleRegion || mTransactionIncomplete || 
-                        aLayer->GetEffectiveOpacity() != 1.0f;
-      nsRefPtr<gfxASurface> result = 
-        Transform3D(untransformedSurface, aTarget, bounds,
-                    effectiveTransform, offset, dontBlit);
-
-      blitComplete = !result;
-      if (result) {
-        aTarget->SetSource(result, offset);
+      // Temporary fast fix for bug 725886
+      // Revert these changes when 725886 is ready
+      gfxRect clipExtents;
+      clipExtents = aTarget->GetClipExtents();
+      if (!clipExtents.IsEmpty()) {
+        gfxPoint offset;
+        bool dontBlit = needsClipToVisibleRegion || mTransactionIncomplete ||
+                          aLayer->GetEffectiveOpacity() != 1.0f;
+        nsRefPtr<gfxASurface> result =
+          Transform3D(untransformedSurface, aTarget, bounds,
+                      effectiveTransform, offset, dontBlit);
+
+        blitComplete = !result;
+        if (result) {
+          aTarget->SetSource(result, offset);
+        }
       }
     }
     // If we're doing our own double-buffering, we need to avoid drawing
     // the results of an incomplete transaction to the destination surface ---
     // that could cause flicker. Double-buffering is implemented using a
     // temporary surface for one or more container layers, so we need to stop
     // those temporary surfaces from being composited to aTarget.
     // ApplyDoubleBuffering guarantees that this container layer can't
--- a/widget/xpwidgets/PuppetWidget.cpp
+++ b/widget/xpwidgets/PuppetWidget.cpp
@@ -525,16 +525,18 @@ PuppetWidget::DispatchPaintEvent()
     debug_DumpPaintEvent(stderr, this, &event,
                          nsCAutoString("PuppetWidget"), nsnull);
 #endif
 
     if (LayerManager::LAYERS_D3D10 == mLayerManager->GetBackendType()) {
       DispatchEvent(&event, status);
     } else {
       nsRefPtr<gfxContext> ctx = new gfxContext(mSurface);
+      ctx->Rectangle(gfxRect(0,0,0,0));
+      ctx->Clip();
       AutoLayerManagerSetup setupLayerManager(this, ctx,
                                               BasicLayerManager::BUFFER_NONE);
       DispatchEvent(&event, status);  
     }
   }
 
   nsPaintEvent didPaintEvent(true, NS_DID_PAINT, this);
   DispatchEvent(&didPaintEvent, status);