mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Use explicit Arc::clone to clarify when clones are cheap (#7784)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use egui::{TexturesDelta, UserData, ViewportCommand};
|
||||
|
||||
use crate::{App, epi, web::web_painter::WebPainter};
|
||||
@@ -12,7 +14,7 @@ pub struct AppRunner {
|
||||
painter: Box<dyn WebPainter>,
|
||||
pub(crate) input: super::WebInput,
|
||||
app: Box<dyn epi::App>,
|
||||
pub(crate) needs_repaint: std::sync::Arc<NeedRepaint>,
|
||||
pub(crate) needs_repaint: Arc<NeedRepaint>,
|
||||
last_save_time: f64,
|
||||
pub(crate) text_agent: TextAgent,
|
||||
|
||||
@@ -63,7 +65,7 @@ impl AppRunner {
|
||||
canvas,
|
||||
&web_options,
|
||||
)?;
|
||||
gl = Some(painter.gl().clone());
|
||||
gl = Some(Arc::clone(painter.gl()));
|
||||
Box::new(painter) as Box<dyn WebPainter>
|
||||
}
|
||||
|
||||
@@ -138,10 +140,9 @@ impl AppRunner {
|
||||
wgpu_render_state,
|
||||
};
|
||||
|
||||
let needs_repaint: std::sync::Arc<NeedRepaint> =
|
||||
std::sync::Arc::new(NeedRepaint::new(web_options.max_fps));
|
||||
let needs_repaint: Arc<NeedRepaint> = Arc::new(NeedRepaint::new(web_options.max_fps));
|
||||
{
|
||||
let needs_repaint = needs_repaint.clone();
|
||||
let needs_repaint = Arc::clone(&needs_repaint);
|
||||
egui_ctx.set_request_repaint_callback(move |info| {
|
||||
needs_repaint.repaint_after(info.delay.as_secs_f64());
|
||||
});
|
||||
|
||||
@@ -91,7 +91,7 @@ impl WebPainter for WebPainterGlow {
|
||||
for data in data {
|
||||
events.push(Event::Screenshot {
|
||||
viewport_id: ViewportId::default(),
|
||||
image: image.clone(),
|
||||
image: Arc::clone(&image),
|
||||
user_data: data,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ impl WebPainterWgpu {
|
||||
surface_configuration,
|
||||
depth_stencil_format,
|
||||
depth_texture_view: None,
|
||||
on_surface_error: options.wgpu_options.on_surface_error.clone(),
|
||||
on_surface_error: Arc::clone(&options.wgpu_options.on_surface_error) as _,
|
||||
screen_capture_state: None,
|
||||
capture_tx,
|
||||
capture_rx,
|
||||
@@ -336,7 +336,7 @@ impl WebPainter for WebPainterWgpu {
|
||||
events.push(Event::Screenshot {
|
||||
viewport_id,
|
||||
user_data: data,
|
||||
image: screenshot.clone(),
|
||||
image: Arc::clone(&screenshot),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user