diff --git a/egui/src/context.rs b/egui/src/context.rs index 17d5d71d..229dd1ac 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -307,6 +307,11 @@ impl CtxRef { /// but you are likely the first person to try it. #[derive(Default)] pub struct Context { + // We clone the Context each frame so we can set a new `input`. + // This is so we can avoid a mutex lock to access the `InputState`. + // This means everything else needs to be behind an Arc. + // We can probably come up with a nicer design. + // /// None until first call to `begin_frame`. fonts: Option>, memory: Arc>, @@ -315,13 +320,13 @@ pub struct Context { input: InputState, /// State that is collected during a frame and then cleared - frame_state: Mutex, + frame_state: Arc>, // The output of a frame: - graphics: Mutex, - output: Mutex, + graphics: Arc>, + output: Arc>, - paint_stats: Mutex, + paint_stats: Arc>, /// While positive, keep requesting repaints. Decrement at the end of each frame. repaint_requests: AtomicU32,