Bug 1357065 - Add a PushClip/PopClip API to WebRenderAPI to more easily distinguish between scrolling clips and non-scrolling clips. r?jrmuizel draft
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 18 Apr 2017 09:54:14 -0400
changeset 564391 347f58227138629971944547c583906e21ff9151
parent 564390 55f79645ece66080fd3b1cee46450a0413d1a383
child 564392 10965ecbe9c7d4695d49c4d1e61f340c5f79f8d7
push id54578
push userkgupta@mozilla.com
push dateTue, 18 Apr 2017 13:55:26 +0000
reviewersjrmuizel
bugs1357065
milestone55.0a1
Bug 1357065 - Add a PushClip/PopClip API to WebRenderAPI to more easily distinguish between scrolling clips and non-scrolling clips. r?jrmuizel Note that in upstream WR the push_scroll_layer API has already been renamed to push_clip_node, so conceptually the same API covers both "scrolling clips" (aka scroll layers) and non-scrolling clips. So using the same underlying API for two different WebRenderAPI.h functions makes sense. MozReview-Commit-ID: HvmwWlXRoj0
gfx/layers/wr/WebRenderContainerLayer.cpp
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
--- a/gfx/layers/wr/WebRenderContainerLayer.cpp
+++ b/gfx/layers/wr/WebRenderContainerLayer.cpp
@@ -17,27 +17,27 @@ namespace layers {
 void
 WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
 {
   nsTArray<LayerPolygon> children = SortChildrenBy3DZOrder(SortMode::WITHOUT_GEOMETRY);
 
   gfx::Matrix4x4 transform = GetTransform();
   float opacity = GetLocalOpacity();
   gfx::Rect relBounds = GetWrRelBounds();
-  gfx::Rect overflow(0, 0, relBounds.width, relBounds.height);
+  gfx::Rect clip(0, 0, relBounds.width, relBounds.height);
 
   Maybe<WrImageMask> mask = BuildWrMaskLayer(true);
 
   wr::MixBlendMode mixBlendMode = wr::ToWrMixBlendMode(GetMixBlendMode());
 
   if (gfxPrefs::LayersDump()) {
-    printf_stderr("ContainerLayer %p using bounds=%s, overflow=%s, transform=%s, mix-blend-mode=%s\n",
+    printf_stderr("ContainerLayer %p using bounds=%s, clip=%s, transform=%s, mix-blend-mode=%s\n",
                   this->GetLayer(),
                   Stringify(relBounds).c_str(),
-                  Stringify(overflow).c_str(),
+                  Stringify(clip).c_str(),
                   Stringify(transform).c_str(),
                   Stringify(mixBlendMode).c_str());
   }
 
   if (gfxPrefs::WebRenderOMTAEnabled() &&
       GetAnimations().Length()) {
     MOZ_ASSERT(GetCompositorAnimationsId());
 
@@ -55,27 +55,26 @@ WebRenderContainerLayer::RenderLayer(wr:
                                  mixBlendMode);
   } else {
     aBuilder.PushStackingContext(wr::ToWrRect(relBounds),
                                  opacity,
                                  transform,
                                  mixBlendMode);
   }
 
-  aBuilder.PushScrollLayer(wr::ToWrRect(overflow),
-                           wr::ToWrRect(overflow),
-                           mask.ptrOr(nullptr));
+  aBuilder.PushClip(wr::ToWrRect(clip),
+                    mask.ptrOr(nullptr));
 
   for (LayerPolygon& child : children) {
     if (child.layer->IsBackfaceHidden()) {
       continue;
     }
     ToWebRenderLayer(child.layer)->RenderLayer(aBuilder);
   }
-  aBuilder.PopScrollLayer();
+  aBuilder.PopClip();
   aBuilder.PopStackingContext();
 }
 
 void
 WebRenderRefLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
 {
   gfx::Matrix4x4 transform;// = GetTransform();
   gfx::Rect relBounds = TransformedVisibleBoundsRelativeToParent();
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -565,16 +565,29 @@ DisplayListBuilder::PushStackingContext(
 
 void
 DisplayListBuilder::PopStackingContext()
 {
   wr_dp_pop_stacking_context(mWrState);
 }
 
 void
+DisplayListBuilder::PushClip(const WrRect& aClipRect,
+                             const WrImageMask* aMask)
+{
+  wr_dp_push_scroll_layer(mWrState, aClipRect, aClipRect, aMask);
+}
+
+void
+DisplayListBuilder::PopClip()
+{
+  wr_dp_pop_scroll_layer(mWrState);
+}
+
+void
 DisplayListBuilder::PushBuiltDisplayList(BuiltDisplayList dl)
 {
   wr_dp_push_built_display_list(mWrState,
                                 dl.dl_desc,
                                 dl.dl.Extract(),
                                 dl.aux_desc,
                                 dl.aux.Extract());
 }
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -146,16 +146,20 @@ public:
 
   void PushStackingContext(const WrRect& aBounds, // TODO: We should work with strongly typed rects
                            const uint64_t& aAnimationId,
                            const float* aOpacity,
                            const gfx::Matrix4x4* aTransform,
                            const WrMixBlendMode& aMixBlendMode);
   void PopStackingContext();
 
+  void PushClip(const WrRect& aClipRect,
+                const WrImageMask* aMask);
+  void PopClip();
+
   void PushBuiltDisplayList(wr::BuiltDisplayList dl);
 
   void PushScrollLayer(const WrRect& aContentRect, // TODO: We should work with strongly typed rects
                        const WrRect& aClipRect,
                        const WrImageMask* aMask); // TODO: needs a wrapper.
   void PopScrollLayer();