![]() |
ThorVG
v0.9
|
A module for managing and drawing graphical elements. More...
Modules | |
SwCanvas | |
A module for rendering the graphical elements using the software engine. | |
Functions | |
TVG_API Tvg_Result | tvg_canvas_destroy (Tvg_Canvas *canvas) |
Clears the canvas internal data, releases all paints stored by the canvas and destroys the canvas object itself. More... | |
TVG_API Tvg_Result | tvg_canvas_push (Tvg_Canvas *canvas, Tvg_Paint *paint) |
Inserts a drawing element into the canvas using a Tvg_Paint object. More... | |
TVG_API Tvg_Result | tvg_canvas_reserve (Tvg_Canvas *canvas, uint32_t n) |
Reserves a memory block where the objects pushed into a canvas are stored. More... | |
TVG_API Tvg_Result | tvg_canvas_clear (Tvg_Canvas *canvas, bool free) |
Sets the total number of the paints pushed into the canvas to be zero. Tvg_Paint objects stored in the canvas are released if free is set to true , otherwise the memory is not deallocated and all paints should be released manually in order to avoid memory leaks. More... | |
TVG_API Tvg_Result | tvg_canvas_update (Tvg_Canvas *canvas) |
Updates all paints in a canvas. More... | |
TVG_API Tvg_Result | tvg_canvas_update_paint (Tvg_Canvas *canvas, Tvg_Paint *paint) |
Updates the given Tvg_Paint object from the canvas before the rendering. More... | |
TVG_API Tvg_Result | tvg_canvas_draw (Tvg_Canvas *canvas) |
Requests the canvas to draw the Tvg_Paint objects. More... | |
TVG_API Tvg_Result | tvg_canvas_sync (Tvg_Canvas *canvas) |
Guarantees that the drawing process is finished. More... | |
A module for managing and drawing graphical elements.
A canvas is an entity responsible for drawing the target. It sets up the drawing engine and the buffer, which can be drawn on the screen. It also manages given Paint objects.
TVG_API Tvg_Result tvg_canvas_clear | ( | Tvg_Canvas * | canvas, |
bool | free | ||
) |
Sets the total number of the paints pushed into the canvas to be zero. Tvg_Paint objects stored in the canvas are released if free
is set to true
, otherwise the memory is not deallocated and all paints should be released manually in order to avoid memory leaks.
[in] | canvas | The Tvg_Canvas object to be cleared. |
[in] | free | If true the memory occupied by paints is deallocated, otherwise it is not. |
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | An invalid Tvg_Canvas pointer. |
TVG_RESULT_INSUFFICIENT_CONDITION | An internal error. |
free
argument only when you know how it works, otherwise it's not recommended.TVG_API Tvg_Result tvg_canvas_destroy | ( | Tvg_Canvas * | canvas | ) |
Clears the canvas internal data, releases all paints stored by the canvas and destroys the canvas object itself.
[in] | canvas | The Tvg_Canvas object to be destroyed. |
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | An invalid pointer to the Tvg_Canvas object is passed. |
free
argument value set to false
should be called. Please be aware that in such a case TVG is not responsible for the paints release anymore and it has to be done manually in order to avoid memory leaks.TVG_API Tvg_Result tvg_canvas_draw | ( | Tvg_Canvas * | canvas | ) |
Requests the canvas to draw the Tvg_Paint objects.
All paints from the given canvas will be rasterized to the buffer.
[in] | canvas | The Tvg_Canvas object containing elements to be drawn. |
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | An invalid Tvg_Canvas pointer. |
TVG_RESULT_INSUFFICIENT_CONDITION | An internal error. |
TVG_API Tvg_Result tvg_canvas_push | ( | Tvg_Canvas * | canvas, |
Tvg_Paint * | paint | ||
) |
Inserts a drawing element into the canvas using a Tvg_Paint object.
[in] | canvas | The Tvg_Canvas object managing the paint . |
[in] | paint | The Tvg_Paint object to be drawn. |
Only the paints pushed into the canvas will be drawing targets. They are retained by the canvas until you call tvg_canvas_clear(). If you know the number of the pushed objects in advance, please call tvg_canvas_reserve().
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | In case a nullptr is passed as the argument. |
TVG_RESULT_INSUFFICIENT_CONDITION | An internal error. |
TVG_API Tvg_Result tvg_canvas_reserve | ( | Tvg_Canvas * | canvas, |
uint32_t | n | ||
) |
Reserves a memory block where the objects pushed into a canvas are stored.
If the number of Tvg_Paints to be stored in a canvas is known in advance, calling this function reduces the multiple memory allocations thus improves the performance.
[in] | canvas | The Tvg_Canvas object managing the reserved memory. |
[in] | n | The number of objects for which the memory is to be reserved. |
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | An invalid Tvg_Canvas pointer. |
TVG_RESULT_FAILED_ALLOCATION | An internal error with memory allocation. |
TVG_API Tvg_Result tvg_canvas_sync | ( | Tvg_Canvas * | canvas | ) |
Guarantees that the drawing process is finished.
Since the canvas rendering can be performed asynchronously, it should be called after the tvg_canvas_draw().
[in] | canvas | The Tvg_Canvas object containing elements which were drawn. |
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | An invalid Tvg_Canvas pointer. |
TVG_RESULT_INSUFFICIENT_CONDITION | An internal error. |
TVG_API Tvg_Result tvg_canvas_update | ( | Tvg_Canvas * | canvas | ) |
Updates all paints in a canvas.
Should be called before drawing in order to prepare paints for the rendering.
[in] | canvas | The Tvg_Canvas object to be updated. |
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | An invalid Tvg_Canvas pointer. |
TVG_RESULT_INSUFFICIENT_CONDITION | An internal error. |
TVG_API Tvg_Result tvg_canvas_update_paint | ( | Tvg_Canvas * | canvas, |
Tvg_Paint * | paint | ||
) |
Updates the given Tvg_Paint object from the canvas before the rendering.
If a client application using the TVG library does not update the entire canvas with tvg_canvas_update() in the frame rendering process, Tvg_Paint objects previously added to the canvas should be updated manually with this function.
[in] | canvas | The Tvg_Canvas object to which the paint belongs. |
[in] | paint | The Tvg_Paint object to be updated. |
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | In case a nullptr is passed as the argument. |