Bug 1384839 - Part3. Implement nsDisplayMask::CreateWebRenderCommands. r=kats
MozReview-Commit-ID: D6eOYP29XlN
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -8862,16 +8862,43 @@ nsDisplayMask::PaintAsLayer(nsDisplayLis
nsSVGIntegrationUtils::PaintMaskAndClipPath(params);
context->PopClip();
nsDisplayMaskGeometry::UpdateDrawResult(this, imgParams.result);
}
+bool
+nsDisplayMask::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
+ const StackingContextHelper& aSc,
+ nsTArray<WebRenderParentCommand>& aParentCommands,
+ mozilla::layers::WebRenderLayerManager* aManager,
+ nsDisplayListBuilder* aDisplayListBuilder)
+{
+ bool snap;
+ float appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
+ nsRect displayBound = GetBounds(aDisplayListBuilder, &snap);
+ LayerRect bounds = ViewAs<LayerPixel>(LayoutDeviceRect::FromAppUnits(displayBound, appUnitsPerDevPixel),
+ PixelCastJustification::WebRenderHasUnitResolution);
+
+ Maybe<wr::WrImageMask> mask = aManager->BuildWrMaskImage(this, aBuilder, aSc, aDisplayListBuilder, bounds);
+ if (mask) {
+ aBuilder.PushClip(aSc.ToRelativeLayoutRect(bounds), mask.ptr());
+ }
+
+ nsDisplaySVGEffects::CreateWebRenderCommands(aBuilder, aSc, aParentCommands, aManager, aDisplayListBuilder);
+
+ if (mask) {
+ aBuilder.PopClip();
+ }
+
+ return true;
+}
+
#ifdef MOZ_DUMP_PAINTING
void
nsDisplayMask::PrintEffects(nsACString& aTo)
{
nsIFrame* firstFrame =
nsLayoutUtils::FirstContinuationOrIBSplitSibling(mFrame);
nsSVGEffects::EffectProperties effectProperties =
nsSVGEffects::GetEffectProperties(firstFrame);
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -4515,16 +4515,22 @@ public:
* return whether the mask layer was painted successfully.
*/
bool PaintMask(nsDisplayListBuilder* aBuilder, gfxContext* aMaskContext);
const nsTArray<nsRect>& GetDestRects()
{
return mDestRects;
}
+
+ virtual bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
+ const StackingContextHelper& aSc,
+ nsTArray<WebRenderParentCommand>& aParentCommands,
+ mozilla::layers::WebRenderLayerManager* aManager,
+ nsDisplayListBuilder* aDisplayListBuilder) override;
private:
// According to mask property and the capability of aManager, determine
// whether paint mask onto a dedicate mask layer.
bool ShouldPaintOnMaskLayer(LayerManager* aManager);
nsTArray<nsRect> mDestRects;
};