From 3f9e3c7c2c283611aa1ac0c8cf30859ef7e918d7 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 14 Mar 2022 10:01:49 +0100 Subject: [PATCH] Some cleanup --- egui_glium/src/lib.rs | 2 +- egui_glium/src/painter.rs | 6 +++--- egui_glow/src/epi_backend.rs | 2 +- egui_glow/src/painter.rs | 6 +++--- egui_glow/src/winit.rs | 2 +- egui_web/src/backend.rs | 5 +---- egui_web/src/glow_wrapping.rs | 4 ++-- egui_web/src/lib.rs | 2 +- epaint/src/shape.rs | 4 ++-- 9 files changed, 15 insertions(+), 18 deletions(-) diff --git a/egui_glium/src/lib.rs b/egui_glium/src/lib.rs index ce5b67864f5..9e6760e5392 100644 --- a/egui_glium/src/lib.rs +++ b/egui_glium/src/lib.rs @@ -164,7 +164,7 @@ impl EguiGlium { display, target, self.egui_ctx.pixels_per_point(), - clipped_primitives, + &clipped_primitives, &textures_delta, ); } diff --git a/egui_glium/src/painter.rs b/egui_glium/src/painter.rs index 0f779c5f3d3..4eaf87c8717 100644 --- a/egui_glium/src/painter.rs +++ b/egui_glium/src/painter.rs @@ -70,7 +70,7 @@ impl Painter { display: &glium::Display, target: &mut T, pixels_per_point: f32, - clipped_primitives: Vec, + clipped_primitives: &[egui::ClippedPrimitive], textures_delta: &egui::TexturesDelta, ) { for (id, image_delta) in &textures_delta.set { @@ -92,7 +92,7 @@ impl Painter { display: &glium::Display, target: &mut T, pixels_per_point: f32, - clipped_primitives: Vec, + clipped_primitives: &[egui::ClippedPrimitive], ) { for egui::ClippedPrimitive { clip_rect, @@ -116,7 +116,7 @@ impl Painter { target: &mut T, display: &glium::Display, pixels_per_point: f32, - clip_rect: Rect, + clip_rect: &Rect, mesh: &Mesh, ) { debug_assert!(mesh.is_valid()); diff --git a/egui_glow/src/epi_backend.rs b/egui_glow/src/epi_backend.rs index bbf8755066a..57c3f46ef92 100644 --- a/egui_glow/src/epi_backend.rs +++ b/egui_glow/src/epi_backend.rs @@ -108,7 +108,7 @@ pub fn run(app: Box, native_options: &epi::NativeOptions) -> ! { painter.paint_and_update_textures( gl_window.window().inner_size().into(), integration.egui_ctx.pixels_per_point(), - clipped_primitives, + &clipped_primitives, &textures_delta, ); diff --git a/egui_glow/src/painter.rs b/egui_glow/src/painter.rs index b0f307a9cb6..ef707129344 100644 --- a/egui_glow/src/painter.rs +++ b/egui_glow/src/painter.rs @@ -287,7 +287,7 @@ impl Painter { &mut self, inner_size: [u32; 2], pixels_per_point: f32, - clipped_primitives: Vec, + clipped_primitives: &[egui::ClippedPrimitive], textures_delta: &egui::TexturesDelta, ) { for (id, image_delta) in &textures_delta.set { @@ -324,7 +324,7 @@ impl Painter { &mut self, inner_size: [u32; 2], pixels_per_point: f32, - clipped_primitives: Vec, + clipped_primitives: &[egui::ClippedPrimitive], ) { self.assert_not_destroyed(); @@ -340,7 +340,7 @@ impl Painter { primitive, } in clipped_primitives { - set_clip_rect(&self.gl, size_in_pixels, pixels_per_point, clip_rect); + set_clip_rect(&self.gl, size_in_pixels, pixels_per_point, *clip_rect); match primitive { Primitive::Mesh(mesh) => { diff --git a/egui_glow/src/winit.rs b/egui_glow/src/winit.rs index b8e9c625bde..547e9065be3 100644 --- a/egui_glow/src/winit.rs +++ b/egui_glow/src/winit.rs @@ -76,7 +76,7 @@ impl EguiGlow { self.painter.paint_primitives( dimensions, self.egui_ctx.pixels_per_point(), - clipped_primitives, + &clipped_primitives, ); for id in textures_delta.free.drain(..) { diff --git a/egui_web/src/backend.rs b/egui_web/src/backend.rs index 0da078cf7e7..50313303b8b 100644 --- a/egui_web/src/backend.rs +++ b/egui_web/src/backend.rs @@ -273,10 +273,7 @@ impl AppRunner { } /// Paint the results of the last call to [`Self::logic`]. - pub fn paint( - &mut self, - clipped_primitives: Vec, - ) -> Result<(), JsValue> { + pub fn paint(&mut self, clipped_primitives: &[egui::ClippedPrimitive]) -> Result<(), JsValue> { let textures_delta = std::mem::take(&mut self.textures_delta); self.painter.clear(self.app.clear_color()); diff --git a/egui_web/src/glow_wrapping.rs b/egui_web/src/glow_wrapping.rs index c70ba6ce464..c589aad1400 100644 --- a/egui_web/src/glow_wrapping.rs +++ b/egui_web/src/glow_wrapping.rs @@ -55,7 +55,7 @@ impl WrappedGlowPainter { pub fn paint_primitives( &mut self, - clipped_primitives: Vec, + clipped_primitives: &[ClippedPrimitive], pixels_per_point: f32, ) -> Result<(), JsValue> { let canvas_dimension = [self.canvas.width(), self.canvas.height()]; @@ -66,7 +66,7 @@ impl WrappedGlowPainter { pub fn paint_and_update_textures( &mut self, - clipped_primitives: Vec, + clipped_primitives: &[egui::ClippedPrimitive], pixels_per_point: f32, textures_delta: &egui::TexturesDelta, ) -> Result<(), JsValue> { diff --git a/egui_web/src/lib.rs b/egui_web/src/lib.rs index a7c3068ab6b..062c9ac0d4f 100644 --- a/egui_web/src/lib.rs +++ b/egui_web/src/lib.rs @@ -348,7 +348,7 @@ fn paint_and_schedule(runner_ref: &AppRunnerRef, panicked: Arc) -> R let mut runner_lock = runner_ref.lock(); if runner_lock.needs_repaint.fetch_and_clear() { let (needs_repaint, clipped_primitives) = runner_lock.logic()?; - runner_lock.paint(clipped_primitives)?; + runner_lock.paint(&clipped_primitives)?; if needs_repaint { runner_lock.needs_repaint.set_true(); } diff --git a/epaint/src/shape.rs b/epaint/src/shape.rs index c8c6a306b1e..1d846fb21e8 100644 --- a/epaint/src/shape.rs +++ b/epaint/src/shape.rs @@ -672,8 +672,8 @@ impl std::fmt::Debug for PaintCallback { impl std::cmp::PartialEq for PaintCallback { fn eq(&self, other: &Self) -> bool { - // As I understand it, the problem this clippy tried to protect against can only happen - // if we do dynamic casts back and forth on the pointers, and we don't do that. + // As I understand it, the problem this clippy is trying to protect against + // can only happen if we do dynamic casts back and forth on the pointers, and we don't do that. #[allow(clippy::vtable_address_comparisons)] { self.rect.eq(&other.rect) && std::sync::Arc::ptr_eq(&self.callback, &other.callback)