diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index 982eb54814d..5748d4875ca 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -64,7 +64,7 @@ pub struct CreationContext<'s> { /// /// Only available when compiling with the `glow` feature and using [`Renderer::Glow`]. #[cfg(feature = "glow")] - pub gl: Option>, + pub gl: Option>, /// The underlying WGPU render state. /// @@ -584,7 +584,7 @@ pub struct Frame { /// A reference to the underlying [`glow`] (OpenGL) context. #[cfg(feature = "glow")] - pub(crate) gl: Option>, + pub(crate) gl: Option>, /// Can be used to manage GPU resources for custom rendering with WGPU using [`egui::PaintCallback`]s. #[cfg(feature = "wgpu")] @@ -656,7 +656,7 @@ impl Frame { /// To get a [`glow`] context you need to compile with the `glow` feature flag, /// and run eframe using [`Renderer::Glow`]. #[cfg(feature = "glow")] - pub fn gl(&self) -> Option<&std::rc::Rc> { + pub fn gl(&self) -> Option<&std::sync::Arc> { self.gl.as_ref() } diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index efd8135cce5..7b3d12f110f 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -152,7 +152,7 @@ impl EpiIntegration { app_name: &str, native_options: &crate::NativeOptions, storage: Option>, - #[cfg(feature = "glow")] gl: Option>, + #[cfg(feature = "glow")] gl: Option>, #[cfg(feature = "wgpu")] wgpu_render_state: Option, ) -> Self { let frame = epi::Frame { diff --git a/crates/eframe/src/native/glow_integration.rs b/crates/eframe/src/native/glow_integration.rs index 6bf7336af85..4dff0c86fe7 100644 --- a/crates/eframe/src/native/glow_integration.rs +++ b/crates/eframe/src/native/glow_integration.rs @@ -170,7 +170,7 @@ impl GlowWinitApp { let gl = unsafe { crate::profile_scope!("glow::Context::from_loader_function"); - Rc::new(glow::Context::from_loader_function(|s| { + Arc::new(glow::Context::from_loader_function(|s| { let s = std::ffi::CString::new(s) .expect("failed to construct C string from string for gl proc address"); diff --git a/crates/eframe/src/web/web_painter_glow.rs b/crates/eframe/src/web/web_painter_glow.rs index e02c6dd973a..cd62758688f 100644 --- a/crates/eframe/src/web/web_painter_glow.rs +++ b/crates/eframe/src/web/web_painter_glow.rs @@ -15,7 +15,7 @@ pub(crate) struct WebPainterGlow { } impl WebPainterGlow { - pub fn gl(&self) -> &std::rc::Rc { + pub fn gl(&self) -> &std::sync::Arc { self.painter.gl() } @@ -24,7 +24,8 @@ impl WebPainterGlow { let (gl, shader_prefix) = init_glow_context_from_canvas(&canvas, options.webgl_context_option)?; - let gl = std::rc::Rc::new(gl); + #[allow(clippy::arc_with_non_send_sync)] + let gl = std::sync::Arc::new(gl); let painter = egui_glow::Painter::new(gl, shader_prefix, None) .map_err(|err| format!("Error starting glow painter: {err}"))?; diff --git a/crates/egui_glow/examples/pure_glow.rs b/crates/egui_glow/examples/pure_glow.rs index 5709a4d03e6..5df4d23ecdf 100644 --- a/crates/egui_glow/examples/pure_glow.rs +++ b/crates/egui_glow/examples/pure_glow.rs @@ -152,7 +152,7 @@ fn main() { let event_loop = winit::event_loop::EventLoopBuilder::::with_user_event().build(); let (gl_window, gl) = create_display(&event_loop); - let gl = std::rc::Rc::new(gl); + let gl = std::sync::Arc::new(gl); let mut egui_glow = egui_glow::EguiGlow::new(&event_loop, gl.clone(), None, None); diff --git a/crates/egui_glow/src/painter.rs b/crates/egui_glow/src/painter.rs index e37de40cbc3..2df12298c46 100644 --- a/crates/egui_glow/src/painter.rs +++ b/crates/egui_glow/src/painter.rs @@ -1,7 +1,7 @@ #![allow(clippy::collapsible_else_if)] #![allow(unsafe_code)] -use std::{collections::HashMap, rc::Rc}; +use std::{collections::HashMap, sync::Arc}; use egui::{ emath::Rect, @@ -62,7 +62,7 @@ impl From for PainterError { /// /// NOTE: all egui viewports share the same painter. pub struct Painter { - gl: Rc, + gl: Arc, max_texture_side: usize, @@ -120,7 +120,7 @@ impl Painter { /// * failed to create postprocess on webgl with `sRGB` support /// * failed to create buffer pub fn new( - gl: Rc, + gl: Arc, shader_prefix: &str, shader_version: Option, ) -> Result { @@ -250,7 +250,7 @@ impl Painter { } /// Access the shared glow context. - pub fn gl(&self) -> &Rc { + pub fn gl(&self) -> &Arc { &self.gl } diff --git a/crates/egui_glow/src/winit.rs b/crates/egui_glow/src/winit.rs index 653aef07a96..7a154b27d2b 100644 --- a/crates/egui_glow/src/winit.rs +++ b/crates/egui_glow/src/winit.rs @@ -24,7 +24,7 @@ impl EguiGlow { /// For automatic shader version detection set `shader_version` to `None`. pub fn new( event_loop: &winit::event_loop::EventLoopWindowTarget, - gl: std::rc::Rc, + gl: std::sync::Arc, shader_version: Option, native_pixels_per_point: Option, ) -> Self {