# ThorVG: WgCanvas

WgCanvasfinal
ThorVG

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

Inheritance diagram for WgCanvas:
[legend]
Collaboration diagram for WgCanvas:
[legend]

## Public Member Functions

Result | target (void *instance, void *surface, uint32_t w, uint32_t h, void *device=nullptr) noexcept
| Sets the drawing target for the rasterization. More...
Public Member Functions inherited from Canvas
std::list< Paint * > & | paints () noexcept
| Returns the list of the paints that currently held by the Canvas. More...
virtual Result | push (std::unique_ptr< Paint > paint) noexcept
| Passes drawing elements to the Canvas using Paint objects. More...
virtual Result | clear (bool free=true) noexcept
| Clear the internal canvas resources that used for the drawing. More...
virtual Result | update (Paint *paint=nullptr) noexcept
| Request the canvas to update the paint objects. More...
virtual Result | draw () noexcept
| Requests the canvas to draw the Paint objects. More...
virtual Result | viewport (int32_t x, int32_t y, int32_t w, int32_t h) noexcept
| Sets the drawing region in the canvas. More...
virtual Result | sync () noexcept
| Guarantees that drawing task is finished. More...

## Static Public Member Functions

static std::unique_ptr< WgCanvas > | gen () noexcept
| Creates a new WgCanvas object. More...

## 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 std::unique_ptr<WgCanvas> gen | ( |  | ) |

staticnoexcept

Creates a new WgCanvas object.

Returns
  A new WgCanvas object.

Since
  0.15

## target()

Result target | ( | void * | instance,
|  | void * | surface,
|  | uint32_t | w,
|  | uint32_t | h,
|  | void * | device = `nullptr`
| ) |  |

noexcept

Sets the drawing target for the rasterization.

Parameters

  [in] | instance | WGPUInstance, context for all other wgpu objects.
  [in] | surface | WGPUSurface, handle to a presentable surface.
  [in] | w | The width of the surface.
  [in] | h | The height of the surface.
  [in] | device | WGPUDevice, a desired handle for the wgpu device. If it is `nullptr`, ThorVG will assign an appropriate device internally.

Return values

  Result::InsufficientCondition | if the canvas is performing rendering. Please ensure the canvas is synced.
  Result::NonSupport | In case the wg engine is not supported.

Note
  Experimental API

See also
  Canvas::viewport()
  Canvas::sync()