mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 23:13:13 -04:00
Remove viewport_id from tessellate and added tessellate_for
This commit is contained in:
@@ -1204,7 +1204,7 @@ mod glow_integration {
|
||||
|
||||
let screen_size_in_pixels: [u32; 2] = win.inner_size().into();
|
||||
|
||||
let clipped_primitives = egui_ctx.tessellate(output.shapes, id_pair.this);
|
||||
let clipped_primitives = egui_ctx.tessellate(output.shapes);
|
||||
|
||||
let mut glutin = glutin.borrow_mut();
|
||||
let mut painter = painter.borrow_mut();
|
||||
@@ -1517,10 +1517,7 @@ mod glow_integration {
|
||||
|
||||
let clipped_primitives = {
|
||||
crate::profile_scope!("tessellate");
|
||||
integration
|
||||
.borrow()
|
||||
.egui_ctx
|
||||
.tessellate(shapes, viewport_id)
|
||||
integration.borrow().egui_ctx.tessellate(shapes)
|
||||
};
|
||||
{
|
||||
let mut glutin = glutin.borrow_mut();
|
||||
@@ -2339,7 +2336,7 @@ mod wgpu_integration {
|
||||
}
|
||||
|
||||
let pixels_per_point = egui_ctx.input_for(id_pair.this, |i| i.pixels_per_point());
|
||||
let clipped_primitives = egui_ctx.tessellate(output.shapes, id_pair.this);
|
||||
let clipped_primitives = egui_ctx.tessellate(output.shapes);
|
||||
painter.paint_and_update_textures(
|
||||
id_pair.this,
|
||||
pixels_per_point,
|
||||
@@ -2508,10 +2505,7 @@ mod wgpu_integration {
|
||||
|
||||
let clipped_primitives = {
|
||||
crate::profile_scope!("tessellate");
|
||||
integration
|
||||
.borrow()
|
||||
.egui_ctx
|
||||
.tessellate(shapes, viewport_id)
|
||||
integration.borrow().egui_ctx.tessellate(shapes)
|
||||
};
|
||||
|
||||
let integration = &mut *integration.borrow_mut();
|
||||
|
||||
@@ -162,6 +162,9 @@ struct ContextImpl {
|
||||
/// How deeply nested are we?
|
||||
viewport_stack: Vec<ViewportIdPair>,
|
||||
|
||||
/// What is the last viewport rendered?
|
||||
last: ViewportId,
|
||||
|
||||
// The output of a frame:
|
||||
graphics: ViewportIdMap<GraphicLayers>,
|
||||
output: ViewportIdMap<PlatformOutput>,
|
||||
@@ -1540,6 +1543,8 @@ impl Context {
|
||||
|
||||
let mut viewports = Vec::new();
|
||||
self.write(|ctx| {
|
||||
ctx.last = viewport_id;
|
||||
|
||||
ctx.viewports.retain(|_, viewport| {
|
||||
let was_used = viewport.used;
|
||||
|
||||
@@ -1622,10 +1627,18 @@ impl Context {
|
||||
})
|
||||
}
|
||||
|
||||
/// Tessellate the given shapes into triangle meshes.
|
||||
///
|
||||
/// Will use the last viewport id
|
||||
pub fn tessellate(&self, shapes: Vec<ClippedShape>) -> Vec<ClippedPrimitive> {
|
||||
let last = self.read(|ctx| ctx.last);
|
||||
self.tessellate_for(shapes, last)
|
||||
}
|
||||
|
||||
/// Tessellate the given shapes into triangle meshes.
|
||||
///
|
||||
/// The `viewport_id` is used to get the correct `pixels_per_point`.
|
||||
pub fn tessellate(
|
||||
pub fn tessellate_for(
|
||||
&self,
|
||||
shapes: Vec<ClippedShape>,
|
||||
viewport_id: ViewportId,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
|
||||
use egui::{epaint::TextShape, ViewportId};
|
||||
use egui::epaint::TextShape;
|
||||
use egui_demo_lib::LOREM_IPSUM_LONG;
|
||||
|
||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
@@ -16,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, ViewportId::ROOT)
|
||||
ctx.tessellate(full_output.shapes)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,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(), ViewportId::ROOT));
|
||||
b.iter(|| ctx.tessellate(full_output.shapes.clone()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ pub mod easy_mark;
|
||||
|
||||
pub use color_test::ColorTest;
|
||||
pub use demo::DemoWindows;
|
||||
#[cfg(test)]
|
||||
use egui::ViewportId;
|
||||
|
||||
/// View some Rust code with syntax highlighting and selection.
|
||||
pub(crate) fn rust_view_ui(ui: &mut egui::Ui, code: &str) {
|
||||
@@ -79,7 +77,7 @@ fn test_egui_e2e() {
|
||||
let full_output = ctx.run(raw_input.clone(), |ctx| {
|
||||
demo_windows.ui(ctx);
|
||||
});
|
||||
let clipped_primitives = ctx.tessellate(full_output.shapes, ViewportId::ROOT);
|
||||
let clipped_primitives = ctx.tessellate(full_output.shapes);
|
||||
assert!(!clipped_primitives.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -98,7 +96,7 @@ fn test_egui_zero_window_size() {
|
||||
let full_output = ctx.run(raw_input.clone(), |ctx| {
|
||||
demo_windows.ui(ctx);
|
||||
});
|
||||
let clipped_primitives = ctx.tessellate(full_output.shapes, ViewportId::ROOT);
|
||||
let clipped_primitives = ctx.tessellate(full_output.shapes);
|
||||
assert!(
|
||||
clipped_primitives.is_empty(),
|
||||
"There should be nothing to show, has at least one primitive with clip_rect: {:?}",
|
||||
|
||||
@@ -77,7 +77,7 @@ impl EguiGlow {
|
||||
self.painter.set_texture(id, &image_delta);
|
||||
}
|
||||
|
||||
let clipped_primitives = self.egui_ctx.tessellate(shapes, ViewportId::ROOT);
|
||||
let clipped_primitives = self.egui_ctx.tessellate(shapes);
|
||||
let dimensions: [u32; 2] = window.inner_size().into();
|
||||
self.painter.paint_primitives(
|
||||
dimensions,
|
||||
|
||||
Reference in New Issue
Block a user