ThorVG v1.1
Loading...
Searching...
No Matches
WgCanvasfinal

A class for the rendering graphic elements with a WebGPU raster engine. More...

#include <thorvg.h>

Inheritance diagram for WgCanvas:
Collaboration diagram for WgCanvas:

Classes

struct  Context
 Encapsulates the WebGPU context required for rendering. More...
 

Public Member Functions

Result target (void *device, void *instance, void *target, uint32_t w, uint32_t h, ColorSpace cs, int type=0) noexcept
 Sets the drawing target for the rasterization.
 
Result target (const Context &context, void *target, uint32_t w, uint32_t h, ColorSpace cs, int type=0) noexcept
 Sets the drawing target for the rasterization.
 
- Public Member Functions inherited from Canvas
const std::list< Paint * > & paints () const noexcept
 Returns the list of paints currently held by the Canvas.
 
Result add (Paint *target, Paint *at=nullptr) noexcept
 Adds a paint object to the canvas root scene.
 
Result remove (Paint *paint=nullptr) noexcept
 Removes a paint object or all paint objects from the root scene.
 
Result update () noexcept
 Requests the canvas to update modified paint objects in preparation for rendering.
 
Result draw (bool clear=false) noexcept
 Requests the canvas to render the Paint objects.
 
Result viewport (int32_t x, int32_t y, int32_t w, int32_t h) noexcept
 Sets the drawing region of the canvas.
 
Result sync () noexcept
 Guarantees that drawing task is finished.
 

Static Public Member Functions

static WgCanvasgen (EngineOption op=EngineOption::Default) noexcept
 Creates a new WebGPU Canvas object with optional rendering engine settings.
 

Detailed Description

A class for the rendering graphic elements with a WebGPU raster engine.

Warning
Please do not use it. This class is not fully supported yet.
Since
0.15

Member Function Documentation

◆ gen()

static WgCanvas * gen ( EngineOption  op = EngineOption::Default)
staticnoexcept

Creates a new WebGPU Canvas object with optional rendering engine settings.

This method generates a WebGPU canvas instance that can be used for drawing vector graphics. It accepts an optional parameter op to choose between different rendering engine behaviors.

Parameters
[in]opThe rendering engine option. Default is EngineOption::Default.
Returns
A new WgCanvas object.
Note
Currently, it does not support EngineOption::SmartRender. The request will be ignored.
See also
enum EngineOption
Since
1.0

◆ target() [1/2]

Result target ( const Context context,
void *  target,
uint32_t  w,
uint32_t  h,
ColorSpace  cs,
int  type = 0 
)
noexcept

Sets the drawing target for the rasterization.

Parameters
[in]contextWebGPU context.
[in]targetEither WGPUSurface or WGPUTexture, serving as handles to a presentable surface or texture.
[in]wThe width of the target.
[in]hThe height of the target.
[in]csSpecifies how the pixel values should be interpreted. Currently, it allows ColorSpace::ABGR8888 and ColorSpace::ABGR8888S.
[in]type0: surface, 1: texture are used as pesentable target.
Return values
Result::InsufficientConditionif the canvas is performing rendering. Please ensure the canvas is synced.
Result::NonSupportIn case the wg engine is not supported.
See also
Canvas::viewport()
Canvas::sync()
Note
Experimental API

◆ target() [2/2]

Result target ( void *  device,
void *  instance,
void *  target,
uint32_t  w,
uint32_t  h,
ColorSpace  cs,
int  type = 0 
)
noexcept

Sets the drawing target for the rasterization.

Parameters
[in]deviceWGPUDevice, a desired handle for the wgpu device.
[in]instanceWGPUInstance, context for all other wgpu objects.
[in]targetEither WGPUSurface or WGPUTexture, serving as handles to a presentable surface or texture.
[in]wThe width of the target.
[in]hThe height of the target.
[in]csSpecifies how the pixel values should be interpreted. Currently, it allows ColorSpace::ABGR8888 and ColorSpace::ABGR8888S.
[in]type0: surface, 1: texture are used as pesentable target.
Return values
Result::InsufficientConditionif the canvas is performing rendering. Please ensure the canvas is synced.
Result::NonSupportIn case the wg engine is not supported.
Warning
Regardless of the value of cs, this target API uses the default alpha mode.
See also
WgCanvas::target(const Context&, void*, uint32_t, uint32_t, ColorSpace, int)
Canvas::viewport()
Canvas::sync()
Since
1.0