Reduce amount of data being cloned in begin_frame
This commit is contained in:
parent
44869a6718
commit
d702e3078a
1 changed files with 9 additions and 4 deletions
|
@ -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<Arc<Fonts>>,
|
||||
memory: Arc<Mutex<Memory>>,
|
||||
|
@ -315,13 +320,13 @@ pub struct Context {
|
|||
input: InputState,
|
||||
|
||||
/// State that is collected during a frame and then cleared
|
||||
frame_state: Mutex<FrameState>,
|
||||
frame_state: Arc<Mutex<FrameState>>,
|
||||
|
||||
// The output of a frame:
|
||||
graphics: Mutex<GraphicLayers>,
|
||||
output: Mutex<Output>,
|
||||
graphics: Arc<Mutex<GraphicLayers>>,
|
||||
output: Arc<Mutex<Output>>,
|
||||
|
||||
paint_stats: Mutex<PaintStats>,
|
||||
paint_stats: Arc<Mutex<PaintStats>>,
|
||||
|
||||
/// While positive, keep requesting repaints. Decrement at the end of each frame.
|
||||
repaint_requests: AtomicU32,
|
||||
|
|
Loading…
Reference in a new issue