Bug 1394695 - Don't push scrolling clips in layers-free WR if APZ is disabled. r?mstange draft
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 12 Sep 2017 10:33:45 -0400
changeset 663023 b8b545cb7fbb004528700e9bcc6d5dd74f71307e
parent 662290 f9a5e9ed62103c84e4cde915f4d08f1ce71be83e
child 731069 51f33d54b5774a59c164f3f49ada4c580e5e66e6
push id79293
push userkgupta@mozilla.com
push dateTue, 12 Sep 2017 14:34:18 +0000
reviewersmstange
bugs1394695
milestone57.0a1
Bug 1394695 - Don't push scrolling clips in layers-free WR if APZ is disabled. r?mstange MozReview-Commit-ID: AesXui61mB2
gfx/layers/wr/ScrollingLayersHelper.cpp
gfx/layers/wr/ScrollingLayersHelper.h
gfx/layers/wr/WebRenderLayerManager.cpp
--- a/gfx/layers/wr/ScrollingLayersHelper.cpp
+++ b/gfx/layers/wr/ScrollingLayersHelper.cpp
@@ -84,24 +84,33 @@ ScrollingLayersHelper::ScrollingLayersHe
   } else {
     PushLayerLocalClip(aStackingContext);
   }
 }
 
 ScrollingLayersHelper::ScrollingLayersHelper(nsDisplayItem* aItem,
                                              wr::DisplayListBuilder& aBuilder,
                                              const StackingContextHelper& aStackingContext,
-                                             WebRenderLayerManager::ClipIdMap& aCache)
+                                             WebRenderLayerManager::ClipIdMap& aCache,
+                                             bool aApzEnabled)
   : mLayer(nullptr)
   , mBuilder(&aBuilder)
   , mPushedLayerLocalClip(false)
   , mPushedClipAndScroll(false)
 {
   int32_t auPerDevPixel = aItem->Frame()->PresContext()->AppUnitsPerDevPixel();
 
+  if (!aApzEnabled) {
+    // If APZ is not enabled, we can ignore all the stuff with ASRs; we just
+    // need to define the clip chain on the item and that's it.
+    DefineAndPushChain(aItem->GetClipChain(), aBuilder, aStackingContext,
+        auPerDevPixel, aCache);
+    return;
+  }
+
   // There are two ASR chains here that we need to be fully defined. One is the
   // ASR chain pointed to by aItem->GetActiveScrolledRoot(). The other is the
   // ASR chain pointed to by aItem->GetClipChain()->mASR. We pick the leafmost
   // of these two chains because that one will include the other. And then we
   // call DefineAndPushScrollLayers with it, which will recursively push all
   // the necessary clips and scroll layer items for that ASR chain.
   const ActiveScrolledRoot* leafmostASR = aItem->GetActiveScrolledRoot();
   if (aItem->GetClipChain()) {
--- a/gfx/layers/wr/ScrollingLayersHelper.h
+++ b/gfx/layers/wr/ScrollingLayersHelper.h
@@ -28,17 +28,18 @@ class MOZ_RAII ScrollingLayersHelper
 {
 public:
   ScrollingLayersHelper(WebRenderLayer* aLayer,
                         wr::DisplayListBuilder& aBuilder,
                         const StackingContextHelper& aSc);
   ScrollingLayersHelper(nsDisplayItem* aItem,
                         wr::DisplayListBuilder& aBuilder,
                         const StackingContextHelper& aStackingContext,
-                        WebRenderLayerManager::ClipIdMap& aCache);
+                        WebRenderLayerManager::ClipIdMap& aCache,
+                        bool aApzEnabled);
   ~ScrollingLayersHelper();
 
 private:
   void DefineAndPushScrollLayers(nsDisplayItem* aItem,
                                  const ActiveScrolledRoot* aAsr,
                                  const DisplayItemClipChain* aChain,
                                  wr::DisplayListBuilder& aBuilder,
                                  int32_t aAppUnitsPerDevPixel,
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -323,17 +323,17 @@ WebRenderLayerManager::CreateWebRenderCo
     if (!mShouldNotifyInvalidation) {
       nsRect invalid;
       if (item->IsInvalid(invalid)) {
         mShouldNotifyInvalidation = true;
       }
     }
 
     { // scope the ScrollingLayersHelper
-      ScrollingLayersHelper clip(item, aBuilder, aSc, mClipIdCache);
+      ScrollingLayersHelper clip(item, aBuilder, aSc, mClipIdCache, AsyncPanZoomEnabled());
 
       // Note: this call to CreateWebRenderCommands can recurse back into
       // this function if the |item| is a wrapper for a sublist.
       if (!item->CreateWebRenderCommands(aBuilder, aSc, mParentCommands, this,
                                          aDisplayListBuilder)) {
         PushItemAsImage(item, aBuilder, aSc, aDisplayListBuilder);
       }
     }