1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Pass out pixels_per_point in output for use in tesselation

This commit is contained in:
Emil Ernerfeldt
2023-11-15 11:14:13 +01:00
parent c18eb1987e
commit 1b1be3cd6c
7 changed files with 33 additions and 25 deletions

View File

@@ -9,7 +9,6 @@ pub fn criterion_benchmark(c: &mut Criterion) {
{
let ctx = egui::Context::default();
let mut demo_windows = egui_demo_lib::DemoWindows::default();
let pixels_per_point = 1.0;
// The most end-to-end benchmark.
c.bench_function("demo_with_tessellate__realistic", |b| {
@@ -17,7 +16,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
let full_output = ctx.run(RawInput::default(), |ctx| {
demo_windows.ui(ctx);
});
ctx.tessellate(full_output.shapes, pixels_per_point)
ctx.tessellate(full_output.shapes, full_output.pixels_per_point)
});
});
@@ -33,7 +32,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
demo_windows.ui(ctx);
});
c.bench_function("demo_only_tessellate", |b| {
b.iter(|| ctx.tessellate(full_output.shapes.clone(), pixels_per_point));
b.iter(|| ctx.tessellate(full_output.shapes.clone(), full_output.pixels_per_point));
});
}

View File

@@ -71,14 +71,13 @@ fn test_egui_e2e() {
let mut demo_windows = crate::DemoWindows::default();
let ctx = egui::Context::default();
let raw_input = egui::RawInput::default();
let pixels_per_point = 1.0;
const NUM_FRAMES: usize = 5;
for _ in 0..NUM_FRAMES {
let full_output = ctx.run(raw_input.clone(), |ctx| {
demo_windows.ui(ctx);
});
let clipped_primitives = ctx.tessellate(full_output.shapes, pixels_per_point);
let clipped_primitives = ctx.tessellate(full_output.shapes, full_output.pixels_per_point);
assert!(!clipped_primitives.is_empty());
}
}
@@ -91,14 +90,13 @@ fn test_egui_zero_window_size() {
screen_rect: Some(egui::Rect::from_min_max(egui::Pos2::ZERO, egui::Pos2::ZERO)),
..Default::default()
};
let pixels_per_point = 1.0;
const NUM_FRAMES: usize = 5;
for _ in 0..NUM_FRAMES {
let full_output = ctx.run(raw_input.clone(), |ctx| {
demo_windows.ui(ctx);
});
let clipped_primitives = ctx.tessellate(full_output.shapes, pixels_per_point);
let clipped_primitives = ctx.tessellate(full_output.shapes, full_output.pixels_per_point);
assert!(
clipped_primitives.is_empty(),
"There should be nothing to show, has at least one primitive with clip_rect: {:?}",