mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Add Context::run_ui (#7736)
* Part of https://github.com/emilk/egui/issues/3524 Adds `Context::run_ui` as a convenience wrapper around `Context::run`. This on the path to deprecate `run` and use a top-level `Ui` as the entry-point for all of egui.
This commit is contained in:
@@ -28,10 +28,8 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
// The most end-to-end benchmark.
|
||||
c.bench_function("demo_with_tessellate__realistic", |b| {
|
||||
b.iter(|| {
|
||||
let full_output = ctx.run(RawInput::default(), |ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
demo_windows.ui(ui);
|
||||
});
|
||||
let full_output = ctx.run_ui(RawInput::default(), |ui| {
|
||||
demo_windows.ui(ui);
|
||||
});
|
||||
ctx.tessellate(full_output.shapes, full_output.pixels_per_point)
|
||||
});
|
||||
@@ -39,18 +37,14 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
|
||||
c.bench_function("demo_no_tessellate", |b| {
|
||||
b.iter(|| {
|
||||
ctx.run(RawInput::default(), |ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
demo_windows.ui(ui);
|
||||
});
|
||||
ctx.run_ui(RawInput::default(), |ui| {
|
||||
demo_windows.ui(ui);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
let full_output = ctx.run(RawInput::default(), |ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
demo_windows.ui(ui);
|
||||
});
|
||||
let full_output = ctx.run_ui(RawInput::default(), |ui| {
|
||||
demo_windows.ui(ui);
|
||||
});
|
||||
c.bench_function("demo_only_tessellate", |b| {
|
||||
b.iter(|| ctx.tessellate(full_output.shapes.clone(), full_output.pixels_per_point));
|
||||
@@ -63,10 +57,8 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
let mut demo_windows = egui_demo_lib::DemoWindows::default();
|
||||
c.bench_function("demo_full_no_tessellate", |b| {
|
||||
b.iter(|| {
|
||||
ctx.run(RawInput::default(), |ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
demo_windows.ui(ui);
|
||||
});
|
||||
ctx.run_ui(RawInput::default(), |ui| {
|
||||
demo_windows.ui(ui);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
@@ -73,10 +73,8 @@ fn test_egui_e2e() {
|
||||
|
||||
const NUM_FRAMES: usize = 5;
|
||||
for _ in 0..NUM_FRAMES {
|
||||
let full_output = ctx.run(raw_input.clone(), |ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
demo_windows.ui(ui);
|
||||
});
|
||||
let full_output = ctx.run_ui(raw_input.clone(), |ui| {
|
||||
demo_windows.ui(ui);
|
||||
});
|
||||
let clipped_primitives = ctx.tessellate(full_output.shapes, full_output.pixels_per_point);
|
||||
assert!(!clipped_primitives.is_empty());
|
||||
@@ -94,10 +92,8 @@ fn test_egui_zero_window_size() {
|
||||
|
||||
const NUM_FRAMES: usize = 5;
|
||||
for _ in 0..NUM_FRAMES {
|
||||
let full_output = ctx.run(raw_input.clone(), |ctx| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
demo_windows.ui(ui);
|
||||
});
|
||||
let full_output = ctx.run_ui(raw_input.clone(), |ui| {
|
||||
demo_windows.ui(ui);
|
||||
});
|
||||
let clipped_primitives = ctx.tessellate(full_output.shapes, full_output.pixels_per_point);
|
||||
assert!(
|
||||
|
||||
Reference in New Issue
Block a user