Introduce presentation metrics and send them to comet

This commit is contained in:
Héctor Ramón Jiménez 2025-04-09 21:50:21 +02:00
parent 6508ad67c1
commit 015f5283a8
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
8 changed files with 210 additions and 42 deletions

View file

@ -19,6 +19,7 @@ svg = ["iced_graphics/svg", "resvg"]
geometry = ["iced_graphics/geometry"]
[dependencies]
iced_debug.workspace = true
iced_graphics.workspace = true
bytemuck.workspace = true

View file

@ -17,6 +17,7 @@ mod vector;
#[cfg(feature = "geometry")]
pub mod geometry;
use iced_debug as debug;
pub use iced_graphics as graphics;
pub use iced_graphics::core;
@ -112,62 +113,84 @@ impl Renderer {
engine::adjust_clip_mask(clip_mask, clip_bounds);
for (quad, background) in &layer.quads {
self.engine.draw_quad(
quad,
background,
Transformation::scale(scale_factor),
pixels,
clip_mask,
clip_bounds,
);
if !layer.quads.is_empty() {
let render_span = debug::render(debug::Primitive::Quad);
for (quad, background) in &layer.quads {
self.engine.draw_quad(
quad,
background,
Transformation::scale(scale_factor),
pixels,
clip_mask,
clip_bounds,
);
}
render_span.finish();
}
for group in &layer.primitives {
let Some(new_clip_bounds) = (group.clip_bounds()
* scale_factor)
.intersection(&clip_bounds)
else {
continue;
};
if !layer.primitives.is_empty() {
let render_span = debug::render(debug::Primitive::Triangle);
engine::adjust_clip_mask(clip_mask, new_clip_bounds);
for group in &layer.primitives {
let Some(new_clip_bounds) = (group.clip_bounds()
* scale_factor)
.intersection(&clip_bounds)
else {
continue;
};
for primitive in group.as_slice() {
self.engine.draw_primitive(
primitive,
group.transformation()
* Transformation::scale(scale_factor),
engine::adjust_clip_mask(clip_mask, new_clip_bounds);
for primitive in group.as_slice() {
self.engine.draw_primitive(
primitive,
group.transformation()
* Transformation::scale(scale_factor),
pixels,
clip_mask,
clip_bounds,
);
}
engine::adjust_clip_mask(clip_mask, clip_bounds);
}
render_span.finish();
}
if !layer.images.is_empty() {
let render_span = debug::render(debug::Primitive::Image);
for image in &layer.images {
self.engine.draw_image(
image,
Transformation::scale(scale_factor),
pixels,
clip_mask,
clip_bounds,
);
}
engine::adjust_clip_mask(clip_mask, clip_bounds);
render_span.finish();
}
for image in &layer.images {
self.engine.draw_image(
image,
Transformation::scale(scale_factor),
pixels,
clip_mask,
clip_bounds,
);
}
if !layer.text.is_empty() {
let render_span = debug::render(debug::Primitive::Image);
for group in &layer.text {
for text in group.as_slice() {
self.engine.draw_text(
text,
group.transformation()
* Transformation::scale(scale_factor),
pixels,
clip_mask,
clip_bounds,
);
for group in &layer.text {
for text in group.as_slice() {
self.engine.draw_text(
text,
group.transformation()
* Transformation::scale(scale_factor),
pixels,
clip_mask,
clip_bounds,
);
}
}
render_span.finish();
}
}
}