Bug 1381503 - Part 2. Do not use GetWidgetLayerManager if gfxPrefs::LayersAllowTextLayers return false. r=mattwoodrow
authorcku <cku@mozilla.com>
Mon, 17 Jul 2017 23:31:36 +0800
changeset 369299 486da25b9ae013cfb8a436ed7e174ebb48b7948b
parent 369298 287b244e6087f0dd3ef04dfc028f15110a06d5fb
child 369300 8e1fe8f92ade4cd5aed82e193bbc0e385b8b7d62
push id46635
push usercku@mozilla.com
push dateTue, 18 Jul 2017 02:20:25 +0000
treeherderautoland@486da25b9ae0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1381503
milestone56.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 1381503 - Part 2. Do not use GetWidgetLayerManager if gfxPrefs::LayersAllowTextLayers return false. r=mattwoodrow Call gfxPrefs::LayersAllowTextLayers before aBuilder->GetWidgetLayerManager, which is costly. Since LayersAllowTextLayers returns false by default, we are free of using aBuilder->GetWidgetLayerManager. MozReview-Commit-ID: Jv1voPYjOad
layout/generic/nsTextFrame.cpp
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -5110,22 +5110,22 @@ GetTextCombineScaleFactor(nsTextFrame* a
 nsDisplayText::nsDisplayText(nsDisplayListBuilder* aBuilder, nsTextFrame* aFrame,
                              const Maybe<bool>& aIsSelected)
   : nsCharClipDisplayItem(aBuilder, aFrame)
   , mOpacity(1.0f)
   , mDisableSubpixelAA(false)
 {
   MOZ_COUNT_CTOR(nsDisplayText);
   mIsFrameSelected = aIsSelected;
-
   mBounds = mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
     // Bug 748228
   mBounds.Inflate(mFrame->PresContext()->AppUnitsPerDevPixel());
 
-  if (ShouldUseAdvancedLayer(aBuilder->GetWidgetLayerManager(), gfxPrefs::LayersAllowTextLayers)) {
+  if (gfxPrefs::LayersAllowTextLayers() &&
+      CanUseAdvancedLayer(aBuilder->GetWidgetLayerManager())) {
     RefPtr<DrawTargetCapture> capture =
       gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget()->CreateCaptureDT(IntSize());
     RefPtr<gfxContext> captureCtx = gfxContext::CreateOrNull(capture);
 
     // TODO: Paint() checks mDisableSubpixelAA, we should too.
     RenderToContext(captureCtx, aBuilder, true);
 
     // TODO: Ideally we'd re-use captureCtx in Paint() if we couldn't build
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -2726,24 +2726,30 @@ nsDisplayItem::FuseClipChainUpTo(nsDispl
     mClip = &mClipChain->mClip;
   } else {
     mClipChain = nullptr;
     mClip = nullptr;
   }
 }
 
 bool
-nsDisplayItem::ShouldUseAdvancedLayer(LayerManager* aManager, PrefFunc aFunc)
+nsDisplayItem::ShouldUseAdvancedLayer(LayerManager* aManager, PrefFunc aFunc) const
+{
+  return CanUseAdvancedLayer(aManager) ? aFunc() : false;
+}
+
+bool
+nsDisplayItem::CanUseAdvancedLayer(LayerManager* aManager) const
 {
   if (!gfxPrefs::LayersAdvancedBasicLayerEnabled() &&
       aManager && aManager->GetBackendType() == layers::LayersBackend::LAYERS_BASIC) {
     return false;
   }
 
-  return aFunc();
+  return true;
 }
 
 static const DisplayItemClipChain*
 FindCommonAncestorClipForIntersection(const DisplayItemClipChain* aOne,
                                       const DisplayItemClipChain* aTwo)
 {
   for (const ActiveScrolledRoot* asr =
          ActiveScrolledRoot::PickDescendant(aOne->mASR, aTwo->mASR);
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -2178,17 +2178,18 @@ public:
   }
 
 protected:
   friend class nsDisplayList;
 
   nsDisplayItem() { mAbove = nullptr; }
 
   typedef bool (*PrefFunc)(void);
-  bool ShouldUseAdvancedLayer(LayerManager* aManager, PrefFunc aFunc);
+  bool ShouldUseAdvancedLayer(LayerManager* aManager, PrefFunc aFunc) const;
+  bool CanUseAdvancedLayer(LayerManager* aManager) const;
 
   nsIFrame* mFrame;
   const DisplayItemClipChain* mClipChain;
   const DisplayItemClip* mClip;
   const ActiveScrolledRoot* mActiveScrolledRoot;
   // Result of FindReferenceFrameFor(mFrame), if mFrame is non-null
   const nsIFrame* mReferenceFrame;
   struct AnimatedGeometryRoot* mAnimatedGeometryRoot;