sketch_2d/
context.rs

1/*
2 * Created on Mon Jul 03 2023
3 *
4 * Copyright (c) storycraft. Licensed under the MIT Licence.
5 */
6
7use wgpu::CommandEncoder;
8
9use crate::{
10    buffer::stream::{BufferStream, StreamBuffer},
11    queue::RenderNodeQueue,
12    screen::ScreenRect,
13    store::RenderFnStore,
14};
15
16/// [DrawContext] contains reference to backend, resources store, and stream for component data preparing
17pub struct DrawContext<'a, 'encoder> {
18    pub store: RenderFnStore<'a>,
19
20    pub encoder: &'encoder mut CommandEncoder,
21    pub queue: &'encoder mut RenderNodeQueue,
22
23    pub screen: ScreenRect,
24
25    pub vertex_stream: &'a mut BufferStream<'static>,
26    pub index_stream: &'a mut BufferStream<'static>,
27}
28
29/// [RenderContext] contains gpu device and stream for component rendering
30pub struct RenderContext<'a> {
31    pub store: RenderFnStore<'a>,
32
33    pub vertex_stream: StreamBuffer<'a>,
34    pub index_stream: StreamBuffer<'a>,
35}