Bug 1954798 - Add debug markers in WR's display list. r=emilio

And use DebugMarker(1) to signify that the next item is a view-transition snapshot.
This specific marker is not meant to stay forever (although the infrastructure is), but it is useful right now.

Differential Revision: https://phabricator.services.mozilla.com/D242023
This commit is contained in:
Nicolas Silva
2025-03-19 08:45:10 +00:00
parent 8abc58c71f
commit 46eae23cc9
7 changed files with 24 additions and 0 deletions

View File

@@ -1783,6 +1783,10 @@ void DisplayListBuilder::PushBoxShadow(
aBorderRadius, aClipMode);
}
void DisplayListBuilder::PushDebug(uint32_t aVal) {
wr_dp_push_debug(mWrState, aVal);
}
void DisplayListBuilder::StartGroup(nsPaintedDisplayItem* aItem) {
if (!mDisplayItemCache || mDisplayItemCache->IsFull()) {
return;

View File

@@ -793,6 +793,8 @@ class DisplayListBuilder final {
const wr::BorderRadius& aBorderRadius,
const wr::BoxShadowClipMode& aClipMode);
void PushDebug(uint32_t aVal);
/**
* Notifies the DisplayListBuilder that it can group together WR display items
* that are pushed until |CancelGroup()| or |FinishGroup()| call.

View File

@@ -3039,6 +3039,11 @@ pub extern "C" fn wr_dp_push_stacking_context(
result
}
#[no_mangle]
pub extern "C" fn wr_dp_push_debug(state: &mut WrState, val: u32) {
state.frame_builder.dl_builder.push_debug(val);
}
#[no_mangle]
pub extern "C" fn wr_dp_pop_stacking_context(state: &mut WrState, is_reference_frame: bool) {
debug_assert!(unsafe { !is_in_render_thread() });

View File

@@ -1949,6 +1949,7 @@ impl<'a> SceneBuilder<'a> {
self.pop_all_shadows();
}
DisplayItem::DebugMarker(..) => {}
}
}

View File

@@ -205,6 +205,9 @@ pub enum DisplayItem {
ReuseItems(ItemKey),
RetainedItems(ItemKey),
// For debugging purposes.
DebugMarker(u32),
}
/// This is a "complete" version of the DisplayItem, with all implicit trailing
@@ -247,6 +250,8 @@ pub enum DebugDisplayItem {
PopReferenceFrame,
PopStackingContext,
PopAllShadows,
DebugMarker(u32)
}
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
@@ -2294,6 +2299,7 @@ impl DisplayItem {
DisplayItem::Text(..) => "text",
DisplayItem::YuvImage(..) => "yuv_image",
DisplayItem::BackdropFilter(..) => "backdrop_filter",
DisplayItem::DebugMarker(..) => "debug",
}
}
}

View File

@@ -709,6 +709,7 @@ impl BuiltDisplayList {
Real::PopAllShadows => Debug::PopAllShadows,
Real::ReuseItems(_) |
Real::RetainedItems(_) => unreachable!("Unexpected item"),
Real::DebugMarker(val) => Debug::DebugMarker(val),
};
debug_items.push(serial_di);
}
@@ -1921,6 +1922,10 @@ impl DisplayListBuilder {
}
}
pub fn push_debug(&mut self, val: u32) {
self.push_item(&di::DisplayItem::DebugMarker(val));
}
fn generate_clip_index(&mut self) -> di::ClipId {
self.next_clip_index += 1;
di::ClipId(self.next_clip_index - 1, self.pipeline_id)

View File

@@ -2374,6 +2374,7 @@ void nsDisplayImage::MaybeCreateWebRenderCommandsForViewTransition(
const auto destRect =
wr::ToLayoutRect(LayoutDeviceRect::FromAppUnits(destAppUnits, factor));
auto rendering = wr::ToImageRendering(frame->UsedImageRendering());
aBuilder.PushDebug(1);
aBuilder.PushImage(destRect, destRect, !BackfaceIsHidden(),
/* aForceAntiAliasing = */ false, rendering, key);
}