From c80dac96f4efcee742db60eb27be70568106ce7b Mon Sep 17 00:00:00 2001 From: Ethan Lin Date: Thu, 3 Aug 2017 17:41:41 +0800 Subject: [PATCH] Bug 1386188 - Support filter for layers-free mode. r=kats MozReview-Commit-ID: LuPnaSjhjgk --HG-- extra : rebase_source : 2cf28919048683cdb446c5456a933651d2689fa1 --- layout/painting/nsDisplayList.cpp | 37 +++++++++++++++++++++++++++++++ layout/painting/nsDisplayList.h | 6 +++++ 2 files changed, 43 insertions(+) diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 60f7e605e5de..90a84b97d0cd 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -9132,6 +9132,43 @@ nsDisplayFilter::PaintAsLayer(nsDisplayListBuilder* aBuilder, nsDisplayFilterGeometry::UpdateDrawResult(this, imgParams.result); } +bool +nsDisplayFilter::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder, + const StackingContextHelper& aSc, + nsTArray& aParentCommands, + mozilla::layers::WebRenderLayerManager* aManager, + nsDisplayListBuilder* aDisplayListBuilder) +{ + if (aManager->IsLayersFreeTransaction()) { + ContainerLayerParameters parameter; + if (GetLayerState(aDisplayListBuilder, aManager, parameter) != LAYER_ACTIVE) { + // TODO: should have a fallback path to paint the child list + return false; + } + } + + nsTArray wrFilters; + const nsTArray& filters = mFrame->StyleEffects()->mFilters; + nsTArray cssFilters = nsTArray(filters.Length()); + for (const nsStyleFilter& filter : filters) { + wrFilters.AppendElement(wr::ToWrFilterOp(ToCSSFilter(filter))); + } + + StackingContextHelper sc(aSc, + aBuilder, + aDisplayListBuilder, + this, + &mList, + nullptr, + 0, + nullptr, + nullptr, + wrFilters); + + nsDisplaySVGEffects::CreateWebRenderCommands(aBuilder, sc, aParentCommands, aManager, aDisplayListBuilder); + return true; +} + #ifdef MOZ_DUMP_PAINTING void nsDisplayFilter::PrintEffects(nsACString& aTo) diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index 20e61e0ffb3d..f467dc31b27e 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -4586,6 +4586,12 @@ public: void PaintAsLayer(nsDisplayListBuilder* aBuilder, gfxContext* aCtx, LayerManager* aManager); + + virtual bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder, + const StackingContextHelper& aSc, + nsTArray& aParentCommands, + mozilla::layers::WebRenderLayerManager* aManager, + nsDisplayListBuilder* aDisplayListBuilder) override; }; /* A display item that applies a transformation to all of its descendant