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
--- 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();