Bug 1458598 - Expose the generated reference frame id for stacking contexts. r?mstange
This is just plumbing, no functional changes yet.
MozReview-Commit-ID: FlmnMVammse
--- a/gfx/layers/wr/StackingContextHelper.cpp
+++ b/gfx/layers/wr/StackingContextHelper.cpp
@@ -55,27 +55,28 @@ StackingContextHelper::StackingContextHe
mInheritedTransform = aParentSC.mInheritedTransform;
mScale = aParentSC.mScale;
}
auto rasterSpace = mRasterizeLocally
? wr::GlyphRasterSpace::Local(std::max(mScale.width, mScale.height))
: wr::GlyphRasterSpace::Screen();
- mBuilder->PushStackingContext(wr::ToLayoutRect(aBounds),
- aClipNodeId,
- aAnimation,
- aOpacityPtr,
- aTransformPtr,
- aIsPreserve3D ? wr::TransformStyle::Preserve3D : wr::TransformStyle::Flat,
- aPerspectivePtr,
- wr::ToMixBlendMode(aMixBlendMode),
- aFilters,
- aBackfaceVisible,
- rasterSpace);
+ mReferenceFrameId = mBuilder->PushStackingContext(
+ wr::ToLayoutRect(aBounds),
+ aClipNodeId,
+ aAnimation,
+ aOpacityPtr,
+ aTransformPtr,
+ aIsPreserve3D ? wr::TransformStyle::Preserve3D : wr::TransformStyle::Flat,
+ aPerspectivePtr,
+ wr::ToMixBlendMode(aMixBlendMode),
+ aFilters,
+ aBackfaceVisible,
+ rasterSpace);
mAffectsClipPositioning =
(aTransformPtr && !aTransformPtr->IsIdentity()) ||
(aBounds.TopLeft() != LayoutDevicePoint()) ||
(aAnimation && aAnimation->effect_type == wr::WrAnimationType::Transform);
}
StackingContextHelper::~StackingContextHelper()
--- a/gfx/layers/wr/StackingContextHelper.h
+++ b/gfx/layers/wr/StackingContextHelper.h
@@ -57,22 +57,24 @@ public:
const gfx::Matrix& GetInheritedTransform() const
{
return mInheritedTransform;
}
const Maybe<gfx::Matrix4x4>& GetTransformForScrollData() const;
bool AffectsClipPositioning() const { return mAffectsClipPositioning; }
+ Maybe<wr::WrClipId> ReferenceFrameId() const { return mReferenceFrameId; }
private:
wr::DisplayListBuilder* mBuilder;
gfx::Size mScale;
gfx::Matrix mInheritedTransform;
bool mAffectsClipPositioning;
+ Maybe<wr::WrClipId> mReferenceFrameId;
Maybe<gfx::Matrix4x4> mTransformForScrollData;
bool mIsPreserve3D;
bool mRasterizeLocally;
};
} // namespace layers
} // namespace mozilla
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -758,17 +758,17 @@ DisplayListBuilder::Finalize(wr::LayoutS
BuiltDisplayList& aOutDisplayList)
{
wr_api_finalize_builder(mWrState,
&aOutContentSize,
&aOutDisplayList.dl_desc,
&aOutDisplayList.dl.inner);
}
-void
+Maybe<wr::WrClipId>
DisplayListBuilder::PushStackingContext(const wr::LayoutRect& aBounds,
const wr::WrClipId* aClipNodeId,
const WrAnimationProperty* aAnimation,
const float* aOpacity,
const gfx::Matrix4x4* aTransform,
wr::TransformStyle aTransformStyle,
const gfx::Matrix4x4* aPerspective,
const wr::MixBlendMode& aMixBlendMode,
@@ -785,21 +785,26 @@ DisplayListBuilder::PushStackingContext(
if (aPerspective) {
perspective = ToLayoutTransform(*aPerspective);
}
const wr::LayoutTransform* maybePerspective = aPerspective ? &perspective : nullptr;
const size_t* maybeClipNodeId = aClipNodeId ? &aClipNodeId->id : nullptr;
WRDL_LOG("PushStackingContext b=%s t=%s\n", mWrState, Stringify(aBounds).c_str(),
aTransform ? Stringify(*aTransform).c_str() : "none");
+
+ bool outIsReferenceFrame = false;
+ uintptr_t outReferenceFrameId = 0;
wr_dp_push_stacking_context(mWrState, aBounds, maybeClipNodeId, aAnimation,
aOpacity, maybeTransform, aTransformStyle,
maybePerspective, aMixBlendMode,
aFilters.Elements(), aFilters.Length(),
- aIsBackfaceVisible, aRasterSpace);
+ aIsBackfaceVisible, aRasterSpace,
+ &outIsReferenceFrame, &outReferenceFrameId);
+ return outIsReferenceFrame ? Some(wr::WrClipId { outReferenceFrameId }) : Nothing();
}
void
DisplayListBuilder::PopStackingContext()
{
WRDL_LOG("PopStackingContext\n", mWrState);
wr_dp_pop_stacking_context(mWrState);
}
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -274,27 +274,28 @@ public:
void Save();
void Restore();
void ClearSave();
void Dump();
void Finalize(wr::LayoutSize& aOutContentSize,
wr::BuiltDisplayList& aOutDisplayList);
- void PushStackingContext(const wr::LayoutRect& aBounds, // TODO: We should work with strongly typed rects
- const wr::WrClipId* aClipNodeId,
- const wr::WrAnimationProperty* aAnimation,
- const float* aOpacity,
- const gfx::Matrix4x4* aTransform,
- wr::TransformStyle aTransformStyle,
- const gfx::Matrix4x4* aPerspective,
- const wr::MixBlendMode& aMixBlendMode,
- const nsTArray<wr::WrFilterOp>& aFilters,
- bool aIsBackfaceVisible,
- const wr::GlyphRasterSpace& aRasterSpace);
+ Maybe<wr::WrClipId> PushStackingContext(
+ const wr::LayoutRect& aBounds, // TODO: We should work with strongly typed rects
+ const wr::WrClipId* aClipNodeId,
+ const wr::WrAnimationProperty* aAnimation,
+ const float* aOpacity,
+ const gfx::Matrix4x4* aTransform,
+ wr::TransformStyle aTransformStyle,
+ const gfx::Matrix4x4* aPerspective,
+ const wr::MixBlendMode& aMixBlendMode,
+ const nsTArray<wr::WrFilterOp>& aFilters,
+ bool aIsBackfaceVisible,
+ const wr::GlyphRasterSpace& aRasterSpace);
void PopStackingContext();
wr::WrClipChainId DefineClipChain(const Maybe<wr::WrClipChainId>& aParent,
const nsTArray<wr::WrClipId>& aClips);
wr::WrClipId DefineClip(const Maybe<wr::WrClipId>& aParentId,
const wr::LayoutRect& aClipRect,
const nsTArray<wr::ComplexClipRegion>* aComplex = nullptr,
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1573,17 +1573,19 @@ pub extern "C" fn wr_dp_push_stacking_co
opacity: *const f32,
transform: *const LayoutTransform,
transform_style: TransformStyle,
perspective: *const LayoutTransform,
mix_blend_mode: MixBlendMode,
filters: *const WrFilterOp,
filter_count: usize,
is_backface_visible: bool,
- glyph_raster_space: GlyphRasterSpace) {
+ glyph_raster_space: GlyphRasterSpace,
+ out_is_reference_frame: &mut bool,
+ out_reference_frame_id: &mut usize) {
debug_assert!(unsafe { !is_in_render_thread() });
let c_filters = make_slice(filters, filter_count);
let mut filters : Vec<FilterOp> = c_filters.iter().map(|c_filter| {
match c_filter.filter_type {
WrFilterOpType::Blur => FilterOp::Blur(c_filter.argument),
WrFilterOpType::Brightness => FilterOp::Brightness(c_filter.argument),
WrFilterOpType::Contrast => FilterOp::Contrast(c_filter.argument),
@@ -1633,27 +1635,34 @@ pub extern "C" fn wr_dp_push_stacking_co
Some(perspective) => Some(perspective.clone()),
None => None,
};
let mut prim_info = LayoutPrimitiveInfo::new(bounds);
prim_info.is_backface_visible = is_backface_visible;
prim_info.tag = state.current_tag;
- state.frame_builder
+ let ref_frame_id = state.frame_builder
.dl_builder
.push_stacking_context(&prim_info,
clip_node_id,
ScrollPolicy::Scrollable,
transform_binding,
transform_style,
perspective,
mix_blend_mode,
filters,
glyph_raster_space);
+ if let Some(ClipId::Clip(id, pipeline_id)) = ref_frame_id {
+ assert!(pipeline_id == state.pipeline_id);
+ *out_is_reference_frame = true;
+ *out_reference_frame_id = id;
+ } else {
+ *out_is_reference_frame = false;
+ }
}
#[no_mangle]
pub extern "C" fn wr_dp_pop_stacking_context(state: &mut WrState) {
debug_assert!(unsafe { !is_in_render_thread() });
state.frame_builder.dl_builder.pop_stacking_context();
}
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -1335,17 +1335,19 @@ void wr_dp_push_stacking_context(WrState
const float *aOpacity,
const LayoutTransform *aTransform,
TransformStyle aTransformStyle,
const LayoutTransform *aPerspective,
MixBlendMode aMixBlendMode,
const WrFilterOp *aFilters,
uintptr_t aFilterCount,
bool aIsBackfaceVisible,
- GlyphRasterSpace aGlyphRasterSpace)
+ GlyphRasterSpace aGlyphRasterSpace,
+ bool *aOutIsReferenceFrame,
+ uintptr_t *aOutReferenceFrameId)
WR_FUNC;
WR_INLINE
void wr_dp_push_text(WrState *aState,
LayoutRect aBounds,
LayoutRect aClip,
bool aIsBackfaceVisible,
ColorF aColor,