Bug 1775188 - Remove direct use of ClipId on stacking contexts r=gfx-reviewers,lsalzman

In future, stacking contexts, hit-tests and prims will all use
clip-chains rather than the old-style ClipId references.

Differential Revision: https://phabricator.services.mozilla.com/D149844
This commit is contained in:
Glenn Watson 2022-06-21 20:23:59 +00:00
Родитель fdd6afc666
Коммит d784bfaee9
2 изменённых файлов: 16 добавлений и 12 удалений

Просмотреть файл

@ -134,7 +134,6 @@ impl WrSpaceAndClipChain {
#[repr(C)] #[repr(C)]
pub enum WrStackingContextClip { pub enum WrStackingContextClip {
None, None,
ClipId(WrClipId),
ClipChain(u64), ClipChain(u64),
} }
@ -143,7 +142,6 @@ impl WrStackingContextClip {
match *self { match *self {
WrStackingContextClip::None => None, WrStackingContextClip::None => None,
WrStackingContextClip::ClipChain(id) => Some(clip_chain_id_to_webrender(id, pipeline_id)), WrStackingContextClip::ClipChain(id) => Some(clip_chain_id_to_webrender(id, pipeline_id)),
WrStackingContextClip::ClipId(id) => Some(id.to_webrender(pipeline_id)),
} }
} }
} }

Просмотреть файл

@ -8015,7 +8015,7 @@ void nsDisplayMasksAndClipPaths::Paint(nsDisplayListBuilder* aBuilder,
}); });
} }
static Maybe<wr::WrClipId> CreateSimpleClipRegion( static Maybe<wr::WrClipChainId> CreateSimpleClipRegion(
const nsDisplayMasksAndClipPaths& aDisplayItem, const nsDisplayMasksAndClipPaths& aDisplayItem,
wr::DisplayListBuilder& aBuilder) { wr::DisplayListBuilder& aBuilder) {
nsIFrame* frame = aDisplayItem.Frame(); nsIFrame* frame = aDisplayItem.Frame();
@ -8091,7 +8091,9 @@ static Maybe<wr::WrClipId> CreateSimpleClipRegion(
return Nothing(); return Nothing();
} }
return Some(clipId); wr::WrClipChainId clipChainId = aBuilder.DefineClipChain({clipId}, true);
return Some(clipChainId);
} }
static void FillPolygonDataForDisplayItem( static void FillPolygonDataForDisplayItem(
@ -8131,7 +8133,7 @@ static void FillPolygonDataForDisplayItem(
: wr::FillRule::Evenodd; : wr::FillRule::Evenodd;
} }
static Maybe<wr::WrClipId> CreateWRClipPathAndMasks( static Maybe<wr::WrClipChainId> CreateWRClipPathAndMasks(
nsDisplayMasksAndClipPaths* aDisplayItem, const LayoutDeviceRect& aBounds, nsDisplayMasksAndClipPaths* aDisplayItem, const LayoutDeviceRect& aBounds,
wr::IpcResourceUpdateQueue& aResources, wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, wr::DisplayListBuilder& aBuilder,
const StackingContextHelper& aSc, RenderRootStateManager* aManager, const StackingContextHelper& aSc, RenderRootStateManager* aManager,
@ -8155,7 +8157,9 @@ static Maybe<wr::WrClipId> CreateWRClipPathAndMasks(
wr::WrClipId clipId = wr::WrClipId clipId =
aBuilder.DefineImageMaskClip(mask.ref(), points, fillRule); aBuilder.DefineImageMaskClip(mask.ref(), points, fillRule);
return Some(clipId); wr::WrClipChainId clipChainId = aBuilder.DefineClipChain({clipId}, true);
return Some(clipChainId);
} }
bool nsDisplayMasksAndClipPaths::CreateWebRenderCommands( bool nsDisplayMasksAndClipPaths::CreateWebRenderCommands(
@ -8168,7 +8172,7 @@ bool nsDisplayMasksAndClipPaths::CreateWebRenderCommands(
LayoutDeviceRect bounds = LayoutDeviceRect bounds =
LayoutDeviceRect::FromAppUnits(displayBounds, appUnitsPerDevPixel); LayoutDeviceRect::FromAppUnits(displayBounds, appUnitsPerDevPixel);
Maybe<wr::WrClipId> clip = CreateWRClipPathAndMasks( Maybe<wr::WrClipChainId> clip = CreateWRClipPathAndMasks(
this, bounds, aResources, aBuilder, aSc, aManager, aDisplayListBuilder); this, bounds, aResources, aBuilder, aSc, aManager, aDisplayListBuilder);
float oldOpacity = aBuilder.GetInheritedOpacity(); float oldOpacity = aBuilder.GetInheritedOpacity();
@ -8189,7 +8193,7 @@ bool nsDisplayMasksAndClipPaths::CreateWebRenderCommands(
: Nothing(); : Nothing();
wr::StackingContextParams params; wr::StackingContextParams params;
params.clip = wr::WrStackingContextClip::ClipId(*clip); params.clip = wr::WrStackingContextClip::ClipChain(clip->id);
params.opacity = opacity.ptrOr(nullptr); params.opacity = opacity.ptrOr(nullptr);
if (mWrapsBackdropFilter) { if (mWrapsBackdropFilter) {
params.flags |= wr::StackingContextFlags::WRAPS_BACKDROP_FILTER; params.flags |= wr::StackingContextFlags::WRAPS_BACKDROP_FILTER;
@ -8428,16 +8432,18 @@ bool nsDisplayFilters::CreateWebRenderCommands(
return true; return true;
} }
wr::WrStackingContextClip clip{}; uint64_t clipChainId;
if (filterClip) { if (filterClip) {
auto devPxRect = LayoutDeviceRect::FromAppUnits( auto devPxRect = LayoutDeviceRect::FromAppUnits(
filterClip.value() + ToReferenceFrame(), auPerDevPixel); filterClip.value() + ToReferenceFrame(), auPerDevPixel);
wr::WrClipId clipId = auto clipId =
aBuilder.DefineRectClip(Nothing(), wr::ToLayoutRect(devPxRect)); aBuilder.DefineRectClip(Nothing(), wr::ToLayoutRect(devPxRect));
clip = wr::WrStackingContextClip::ClipId(clipId); clipChainId = aBuilder.DefineClipChain({clipId}, true).id;
} else { } else {
clip = wr::WrStackingContextClip::ClipChain(aBuilder.CurrentClipChainId()); clipChainId = aBuilder.CurrentClipChainId();
} }
wr::WrStackingContextClip clip =
wr::WrStackingContextClip::ClipChain(clipChainId);
float opacity = aBuilder.GetInheritedOpacity(); float opacity = aBuilder.GetInheritedOpacity();
aBuilder.SetInheritedOpacity(1.0f); aBuilder.SetInheritedOpacity(1.0f);