ThorVG v1.0
Loading...
Searching...
No Matches
SwCanvasfinal

A class for the rendering graphical elements with a software raster engine. More...

#include <thorvg.h>

Inheritance diagram for SwCanvas:
Collaboration diagram for SwCanvas:

Public Member Functions

Result target (uint32_t *buffer, uint32_t stride, uint32_t w, uint32_t h, ColorSpace cs) 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 push (Paint *target, Paint *at=nullptr) noexcept
 Adds a paint object to the 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 SwCanvasgen (EngineOption op=EngineOption::Default) noexcept
 Creates a new SwCanvas object with optional rendering engine settings.
 

Detailed Description

A class for the rendering graphical elements with a software raster engine.

Member Function Documentation

◆ gen()

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

Creates a new SwCanvas object with optional rendering engine settings.

This method generates a software 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 SwCanvas object.
See also
enum EngineOption

◆ target()

Result target ( uint32_t *  buffer,
uint32_t  stride,
uint32_t  w,
uint32_t  h,
ColorSpace  cs 
)
noexcept

Sets the drawing target for the rasterization.

The buffer of a desirable size should be allocated and owned by the caller.

Parameters
[in]bufferA pointer to a memory block of the size stride x h, where the raster data are stored.
[in]strideThe stride of the raster image - greater than or equal to w.
[in]wThe width of the raster image.
[in]hThe height of the raster image.
[in]csThe value specifying the way the 32-bits colors should be read/written.
Return values
Result::InvalidArgumentsIn case no valid pointer is provided or the width, or the height or the stride is zero.
Result::InsufficientConditionif the canvas is performing rendering. Please ensure the canvas is synced.
Result::NonSupportIn case the software engine is not supported.
Warning
Do not access buffer during Canvas::push() - Canvas::sync(). It should not be accessed while the engine is writing on it.
See also
Canvas::viewport()
Canvas::sync()