You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, you pass the draw state as argument to every draw method on the backend implementing the Graphics trait. The benefit of this design is that the API is state-less: The draw state object keeps track of the state of the backend.
However, in practice there are some downsides to this approach:
Most code never changes the default draw state. It is mostly used for stencil clipping and scissoring, which changes infrequently.
Passing in draw state leads to typing more code.
The backend code, to perform efficiently, needs a state for the draw state and detecting when to pack the vertices into buffers anyway. Checking the draw state for equality against previously set draw state leads to unnecessary overhead. When changing the draw state through the Graphics trait, the backend can do this directly and detect whether flushing of buffers is required.
Instead of manipulating the draw state for clipping, one could use a separate object with a method taking a closure that changes the draw state and sets it back end to previous state when done.
Plan:
Add two new method to Graphics:
fn set_draw_state(&mut self, &DrawState)
fn get_draw_state(&self) -> DrawState
Remove Context::draw_state
Remove draw state parameters on draw methods
The text was updated successfully, but these errors were encountered:
Currently, you pass the draw state as argument to every draw method on the backend implementing the
Graphics
trait. The benefit of this design is that the API is state-less: The draw state object keeps track of the state of the backend.However, in practice there are some downsides to this approach:
Graphics
trait, the backend can do this directly and detect whether flushing of buffers is required.Plan:
Graphics
:fn set_draw_state(&mut self, &DrawState)
fn get_draw_state(&self) -> DrawState
Context::draw_state
The text was updated successfully, but these errors were encountered: