Type Alias GPUDrawHandler
pub type GPUDrawHandler = RefHandle<SkDrawable_GpuDrawHandler>;Expand description
When using the GPU backend it is possible for a drawable to execute using the underlying 3D
API rather than the crate::Canvas API. It does so by creating a GPU draw handler. The GPU
backend is deferred so the handler will be given access to the 3D API at the correct point
in the drawing stream as the GPU backend flushes. Since the drawable may mutate, each time it
is drawn to a GPU-backed canvas a new handler is snapped, representing the drawable’s state
at the time of the snap.
When the GPU backend flushes to the 3D API it will call the draw method on the GPU draw handler. At this time the drawable may add commands to the stream of GPU commands for the underlying 3D API. The draw function takes a backend drawable info which contains information about the current state of the 3D API which the caller must respect. See the backend drawable info for more specific details on what information is sent and the requirements for different 3D APIs.
Additionally there may be a slight delay from when the drawable adds its commands to when those commands are actually submitted to the GPU. Thus the drawable or GPU draw handler is required to keep any resources that are used by its added commands alive and valid until those commands are submitted to the GPU. The GPU draw handler will be kept alive and then deleted once the commands are submitted to the GPU. The destructor of the GPU draw handler is the signal to the drawable that the commands have all been submitted. Different 3D APIs may have additional requirements for certain resources which require waiting for the GPU to finish all work on those resources before reusing or deleting them. In this case, the drawable can use the destructor call of the GPU draw handler to add a fence to the GPU to track when the GPU work has completed.
Currently this is only supported for the GPU Vulkan backend.
Aliased Type§
pub struct GPUDrawHandler(/* private fields */);