ThorVG  v0.1
Functions

A module for rendering the graphical elements using the software engine. More...

Collaboration diagram for SwCanvas:

Functions

TVG_EXPORT Tvg_Canvastvg_swcanvas_create ()
 Creates a Canvas object. More...
 
TVG_EXPORT Tvg_Result tvg_swcanvas_set_target (Tvg_Canvas *canvas, uint32_t *buffer, uint32_t stride, uint32_t w, uint32_t h, uint32_t cs)
 Sets the buffer used in the rasterization process and defines the used colorspace. More...
 

Detailed Description

A module for rendering the graphical elements using the software engine.

Function Documentation

◆ tvg_swcanvas_create()

TVG_EXPORT Tvg_Canvas* tvg_swcanvas_create ( )

Creates a Canvas object.

Tvg_Canvas *canvas = NULL;
//set up the canvas buffer
uint32_t *buffer = NULL;
buffer = (uint32_t*) malloc(sizeof(uint32_t) * 100 * 100);
if (!buffer) return;
tvg_swcanvas_set_target(canvas, buffer, 100, 100, 100, TVG_COLORSPACE_ARGB8888);
//set up paints and add them into the canvas before drawing it
Returns
A new Tvg_Canvas object.

◆ tvg_swcanvas_set_target()

TVG_EXPORT Tvg_Result tvg_swcanvas_set_target ( Tvg_Canvas canvas,
uint32_t *  buffer,
uint32_t  stride,
uint32_t  w,
uint32_t  h,
uint32_t  cs 
)

Sets the buffer used in the rasterization process and defines the used colorspace.

For optimisation reasons TVG does not allocate memory for the output buffer on its own. The buffer of a desirable size should be allocated and owned by the caller.

Parameters
[in]canvasThe Tvg_Canvas object managing the buffer.
[in]bufferA pointer to the allocated memory block of the size stride x h.
[in]strideThe stride of the raster image - in most cases same value as w.
[in]wThe width of the raster image.
[in]hThe height of the raster image.
[in]csThe colorspace value defining the way the 32-bits colors should be read/written.
  • TVG_COLORSPACE_ABGR8888
  • TVG_COLORSPACE_ARGB8888
Returns
Tvg_Result enumeration.
Return values
TVG_RESULT_SUCCESSSucceed.
TVG_RESULT_MEMORY_CORRUPTIONCasting in the internal function implementation failed.
TVG_RESULT_INVALID_ARGUMENTSAn invalid buffer pointer passed or one of the stride, w or h being zero.
TVG_RESULT_NOT_SUPPORTEDThe software engine is not supported.
See also
TVG_COLORSPACE_ARGB8888, TVG_COLORSPACE_ABGR8888