Retain opt-in layout performance diagnostics
This commit is contained in:
1 parent
84f589e364
commit
480f0bc99f
8 files changed
+613
-22
No files matched your search
@@ -1,3 +1,5 @@
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
use crate::layout_diagnostics::{self as diag, Counter, TimerKind};
|
||||
use crate::{
|
||||
Align, GlyphAtlas, GlyphEntry, GlyphKey, PlacedGlyph, RegionAlign, UiColor, util::Vec2,
|
||||
};
|
||||
@@ -138,8 +140,14 @@ impl TextBuffer {
|
||||
max_width: width,
|
||||
};
|
||||
if self.layout_key.as_ref() == Some(&layout_key) {
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
diag::bump(Counter::TextShapeHits);
|
||||
return;
|
||||
}
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
diag::bump(Counter::TextShapes);
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
let _shape = diag::timer(TimerKind::TextShape);
|
||||
let mut builder = data
|
||||
.layout_ctx
|
||||
.ranged_builder(&mut data.font_ctx, &self.text, 1.0, true);
|
||||
@@ -271,8 +279,16 @@ impl TextData {
|
||||
attrs: &TextAttrs,
|
||||
width: Option<f32>,
|
||||
) -> RenderedText {
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
diag::bump(Counter::TextRenders);
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
let _render = diag::timer(TimerKind::TextRender);
|
||||
buffer.shape(self, attrs, width);
|
||||
let glyphs = self.place(buffer);
|
||||
let glyphs = {
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
let _place = diag::timer(TimerKind::GlyphPlacement);
|
||||
self.place(buffer)
|
||||
};
|
||||
RenderedText {
|
||||
glyphs,
|
||||
size: buffer.size(),
|
||||
|
||||
Reference in new issue
Block a user