Bug 1043426: Avoid doing work for empty visible regions. r=mattwoodrow
☠☠ backed out by e8c21ff47dc1 ☠ ☠
authorBas Schouten <bschouten@mozilla.com>
Mon, 04 Aug 2014 13:02:14 +0200
changeset 197576 1405060b0c96530ebef6d8997f4ac4d21dd8ac5f
parent 197575 67734057268095dc89214939177b7ed2d26ef320
child 197577 5a28657e4996df34354f2dd925515f9da130e6a6
push id47171
push userbschouten@mozilla.com
push dateMon, 04 Aug 2014 11:04:04 +0000
treeherdermozilla-inbound@1405060b0c96 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1043426
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1043426: Avoid doing work for empty visible regions. r=mattwoodrow
gfx/layers/Layers.cpp
gfx/layers/composite/ContainerLayerComposite.cpp
gfx/layers/composite/ThebesLayerComposite.cpp
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -1008,17 +1008,17 @@ ContainerLayer::DefaultComputeEffectiveT
             useIntermediateSurface = true;
             break;
           }
         }
       }
     }
   }
 
-  mUseIntermediateSurface = useIntermediateSurface;
+  mUseIntermediateSurface = useIntermediateSurface && !GetEffectiveVisibleRegion().IsEmpty();
   if (useIntermediateSurface) {
     ComputeEffectiveTransformsForChildren(Matrix4x4::From2D(residual));
   } else {
     ComputeEffectiveTransformsForChildren(idealTransform);
   }
 
   if (idealTransform.CanDraw2D()) {
     ComputeEffectiveTransformForMaskLayer(aTransformToSurface);
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -396,16 +396,17 @@ RenderLayers(ContainerT* aContainer,
             clipRect, effectChain, opacity, Matrix4x4());
       }
     }
   }
 
   for (size_t i = 0u; i < aContainer->mPrepared->mLayers.Length(); i++) {
     PreparedLayer& preparedData = aContainer->mPrepared->mLayers[i];
     LayerComposite* layerToRender = preparedData.mLayer;
+
     nsIntRect clipRect = preparedData.mClipRect;
     if (layerToRender->HasLayerBeenComposited()) {
       // Composer2D will compose this layer so skip GPU composition
       // this time & reset composition flag for next composition phase
       layerToRender->SetLayerComposited(false);
       nsIntRect clearRect = layerToRender->GetClearRect();
       if (!clearRect.IsEmpty()) {
         // Clear layer's visible rect on FrameBuffer with transparent pixels
@@ -497,31 +498,35 @@ RenderIntermediate(ContainerT* aContaine
   compositor->SetRenderTarget(previousTarget);
 }
 
 template<class ContainerT> void
 ContainerRender(ContainerT* aContainer,
                  LayerManagerComposite* aManager,
                  const nsIntRect& aClipRect)
 {
+  nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
+  if (visibleRect.IsEmpty()) {
+    return;
+  }
+
   MOZ_ASSERT(aContainer->mPrepared);
   if (aContainer->UseIntermediateSurface()) {
     RefPtr<CompositingRenderTarget> surface;
 
     if (!aContainer->mPrepared->mTmpTarget) {
       // we needed to copy the background so we waited until now to render the intermediate
       surface = CreateTemporaryTargetAndCopyFromBackground(aContainer, aManager);
       RenderIntermediate(aContainer, aManager, aClipRect, surface);
     } else {
       surface = aContainer->mPrepared->mTmpTarget;
     }
 
     float opacity = aContainer->GetEffectiveOpacity();
 
-    nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();
 #ifdef MOZ_DUMP_PAINTING
     if (gfxUtils::sDumpPainting) {
       RefPtr<gfx::DataSourceSurface> surf = surface->Dump(aManager->GetCompositor());
       if (surf) {
         WriteSnapshotToDumpFile(aContainer, surf);
       }
     }
 #endif
--- a/gfx/layers/composite/ThebesLayerComposite.cpp
+++ b/gfx/layers/composite/ThebesLayerComposite.cpp
@@ -103,16 +103,22 @@ ThebesLayerComposite::GetRenderState()
     return LayerRenderState();
   }
   return mBuffer->GetRenderState();
 }
 
 void
 ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect)
 {
+  const nsIntRegion& visibleRegion = GetEffectiveVisibleRegion();
+
+  if (visibleRegion.IsEmpty()) {
+    return;
+  }
+
   if (!mBuffer || !mBuffer->IsAttached()) {
     return;
   }
   PROFILER_LABEL("ThebesLayerComposite", "RenderLayer",
     js::ProfileEntry::Category::GRAPHICS);
 
   MOZ_ASSERT(mBuffer->GetCompositor() == mCompositeManager->GetCompositor() &&
              mBuffer->GetLayer() == this,
@@ -128,18 +134,16 @@ ThebesLayerComposite::RenderLayer(const 
     }
   }
 #endif
 
   EffectChain effectChain(this);
   LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(mMaskLayer, effectChain);
   AddBlendModeEffect(effectChain);
 
-  const nsIntRegion& visibleRegion = GetEffectiveVisibleRegion();
-
   TiledLayerProperties tiledLayerProps;
   if (mRequiresTiledProperties) {
     tiledLayerProps.mVisibleRegion = visibleRegion;
     tiledLayerProps.mEffectiveResolution = GetEffectiveResolution();
     tiledLayerProps.mValidRegion = mValidRegion;
   }
 
   mBuffer->SetPaintWillResample(MayResample());