Skia
2D Graphics Library
SkDrawable::GpuDrawHandler Class Reference

When using the GPU backend it is possible for a drawable to execute using the underlying 3D API rather than the SkCanvas API. More...

#include <SkDrawable.h>

Public Member Functions

virtual ~GpuDrawHandler ()
 
virtual void draw (const GrBackendDrawableInfo &)
 

Detailed Description

When using the GPU backend it is possible for a drawable to execute using the underlying 3D API rather than the SkCanvas API.

It does so by creating a GpuDrawHandler. 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 GpuDrawHandler. At this time the drawable may add commands to the stream of GPU commands for the unerlying 3D API. The draw function takes a GrBackendDrawableInfo which contains information about the current state of 3D API which the caller must respect. See GrBackendDrawableInfo for more specific details on what information is sent and the requirements for different 3D APIs.

Additionaly 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 GpuDrawHandler 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 GpuDrawHandler will be kept alive and then deleted once the commands are submitted to the GPU. The dtor of the GpuDrawHandler 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 dtor call of the GpuDrawHandler 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.

Constructor & Destructor Documentation

◆ ~GpuDrawHandler()

virtual SkDrawable::GpuDrawHandler::~GpuDrawHandler ( )
inlinevirtual

Member Function Documentation

◆ draw()

virtual void SkDrawable::GpuDrawHandler::draw ( const GrBackendDrawableInfo )
inlinevirtual

The documentation for this class was generated from the following file: