1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40: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:
Emil Ernerfeldt
2025-11-25 08:52:16 +01:00
committed by GitHub
parent 8d3539b6da
commit a624f37e2d
4 changed files with 66 additions and 31 deletions

View File

@@ -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);
})
});
});