VKVG  
Vulkan Vector Graphics
vkvg.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy of
5  * this software and associated documentation files (the "Software"), to deal in
6  * the Software without restriction, including without limitation the rights to use,
7  * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8  * Software, and to permit persons to whom the Software is furnished to do so, subject
9  * to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all
12  * copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 #ifndef VKVG_H
23 #define VKVG_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
65 #include <vulkan/vulkan.h>
66 #include <math.h>
67 #include <stdbool.h>
68 
69 #ifndef vkvg_public
70  #ifdef VKVG_SHARED_BUILD
71  #if (defined(_WIN32) || defined(_WIN64))
72  #define vkvg_public __declspec(dllimport)
73  #else
74  #define vkvg_public __attribute__((visibility("default")))
75  #endif
76  #else
77  #define vkvg_public
78  #endif
79 #endif
80 
81 
82 #define VKVG_LOG_ERR 0x00000001
83 #define VKVG_LOG_DEBUG 0x00000002
84 
85 #define VKVG_LOG_INFO_PTS 0x00000004
86 #define VKVG_LOG_INFO_PATH 0x00000008
87 #define VKVG_LOG_INFO_CMD 0x00000010
88 #define VKVG_LOG_INFO_VBO 0x00000020
89 #define VKVG_LOG_INFO_IBO 0x00000040
90 #define VKVG_LOG_INFO_VAO (VKVG_LOG_INFO_VBO|VKVG_LOG_INFO_IBO)
91 #define VKVG_LOG_DBG_ARRAYS 0x00001000
92 #define VKVG_LOG_STROKE 0x00010000
93 #define VKVG_LOG_FULL 0xffffffff
94 
95 #define VKVG_LOG_INFO 0x00008000//(VKVG_LOG_INFO_PTS|VKVG_LOG_INFO_PATH|VKVG_LOG_INFO_CMD|VKVG_LOG_INFO_VAO)
96 #ifdef DEBUG
97  extern uint32_t vkvg_log_level;
98  #ifdef VKVG_WIRED_DEBUG
99  typedef enum {
100  vkvg_wired_debug_mode_normal = 0x01,
101  vkvg_wired_debug_mode_points = 0x02,
102  vkvg_wired_debug_mode_lines = 0x04,
103  vkvg_wired_debug_mode_both = vkvg_wired_debug_mode_points|vkvg_wired_debug_mode_lines,
104  vkvg_wired_debug_mode_all = 0xFFFFFFFF
105  }vkvg_wired_debug_mode;
106  extern vkvg_wired_debug_mode vkvg_wired_debug;
107  #endif
108 #endif
109 
119 typedef enum {
141 
142 typedef enum {
144  VKVG_VERTICAL = 1
146 
147 typedef enum {
159 typedef enum {
165 
166 
167 typedef enum {
174 } vkvg_filter_t;
175 
181 typedef enum {
189 
196 typedef enum {
207 typedef enum {
212 
221 typedef enum {
225 
226 typedef struct {
227  float r;
228  float g;
229  float b;
230  float a;
231 } vkvg_color_t;
232 
239 typedef struct {
240  float ascent;
241  float descent;
242  float height;
252 typedef struct {
253  float x_bearing;
254  float y_bearing;
255  float width;
256  float height;
257  float x_advance;
258  float y_advance;
260 
267 typedef struct _glyph_info_t {
268  int32_t x_advance;
269  int32_t y_advance;
270  int32_t x_offset;
271  int32_t y_offset;
272  /* private */
273  uint32_t codepoint;//should be named glyphIndex, but for harfbuzz compatibility...
275 
288 typedef struct _vkvg_text_run_t* VkvgText;
289 
296 typedef struct _vkvg_context_t* VkvgContext;
308 typedef struct _vkvg_surface_t* VkvgSurface;
315 typedef struct _vkvg_device_t* VkvgDevice;
323 typedef struct _vkvg_pattern_t* VkvgPattern;
324 
325 #if VKVG_DBG_STATS
331 typedef struct {
332  uint32_t sizePoints;
333  uint32_t sizePathes;
334  uint32_t sizeVertices;
335  uint32_t sizeIndices;
336  uint32_t sizeVBO;
337  uint32_t sizeIBO;
338 } vkvg_debug_stats_t;
339 
340 vkvg_debug_stats_t vkvg_device_get_stats (VkvgDevice dev);
341 vkvg_debug_stats_t vkvg_device_reset_stats (VkvgDevice dev);
342 #endif
343 
344 
352 #define VKVG_IDENTITY_MATRIX (vkvg_matrix_t){1,0,0,1,0,0}
370 typedef struct {
371  float xx; float yx;
372  float xy; float yy;
373  float x0; float y0;
374 } vkvg_matrix_t;
381 vkvg_public
396 vkvg_public
398  float xx, float yx,
399  float xy, float yy,
400  float x0, float y0);
409 vkvg_public
410 void vkvg_matrix_init_translate (vkvg_matrix_t *matrix, float tx, float ty);
419 vkvg_public
420 void vkvg_matrix_init_scale (vkvg_matrix_t *matrix, float sx, float sy);
432 vkvg_public
433 void vkvg_matrix_init_rotate (vkvg_matrix_t *matrix, float radians);
444 vkvg_public
445 void vkvg_matrix_translate (vkvg_matrix_t *matrix, float tx, float ty);
456 vkvg_public
457 void vkvg_matrix_scale (vkvg_matrix_t *matrix, float sx, float sy);
469 vkvg_public
470 void vkvg_matrix_rotate (vkvg_matrix_t *matrix, float radians);
479 vkvg_public
496 vkvg_public
497 void vkvg_matrix_transform_distance (const vkvg_matrix_t *matrix, float *dx, float *dy);
506 vkvg_public
507 void vkvg_matrix_transform_point (const vkvg_matrix_t *matrix, float *x, float *y);
517 vkvg_public
519 vkvg_public
520 void vkvg_matrix_get_scale (const vkvg_matrix_t *matrix, float *sx, float *sy);
549 vkvg_public
550 void vkvg_device_set_thread_aware (VkvgDevice dev, uint32_t thread_awayre);
551 
567 vkvg_public
568 VkvgDevice vkvg_device_create (VkSampleCountFlags samples, bool deferredResolve);
588 vkvg_public
589 VkvgDevice vkvg_device_create_from_vk (VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex);
608 vkvg_public
609 VkvgDevice vkvg_device_create_from_vk_multisample (VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex, VkSampleCountFlags samples, bool deferredResolve);
619 vkvg_public
628 vkvg_public
637 vkvg_public
646 vkvg_public
656 vkvg_public
657 void vkvg_device_set_dpy (VkvgDevice dev, int hdpy, int vdpy);
667 vkvg_public
668 void vkvg_device_get_dpy (VkvgDevice dev, int* hdpy, int* vdpy);
669 
677 vkvg_public
678 void vkvg_get_required_instance_extensions (const char** pExtensions, uint32_t* pExtCount);
686 vkvg_public
687 void vkvg_get_required_device_extensions (VkPhysicalDevice phy, const char** pExtensions, uint32_t* pExtCount);
695 vkvg_public
696 const void* vkvg_get_device_requirements (VkPhysicalDeviceFeatures* pEnabledFeatures);
708 vkvg_public
709 VkvgSurface vkvg_surface_create (VkvgDevice dev, uint32_t width, uint32_t height);
718 vkvg_public
726 vkvg_public
728 // VkvgSurface vkvg_surface_create_from_bitmap (VkvgDevice dev, unsigned char* img, uint32_t width, uint32_t height);
734 vkvg_public
741 vkvg_public
747 vkvg_public
754 vkvg_public
766 vkvg_public
773 vkvg_public
780 vkvg_public
787 vkvg_public
794 vkvg_public
802 vkvg_public
810 vkvg_public
811 vkvg_status_t vkvg_surface_write_to_memory (VkvgSurface surf, unsigned char* const bitmap);
823 vkvg_public
827 //mimic from cairo, to facilitate usage of vkvg as cairo vulkan backend
828 
834 typedef enum _vkvg_operator {
836 
839 /* VKVG_OPERATOR_IN,
840  VKVG_OPERATOR_OUT,
841  VKVG_OPERATOR_ATOP,
842 
843  VKVG_OPERATOR_DEST,
844  VKVG_OPERATOR_DEST_OVER,
845  VKVG_OPERATOR_DEST_IN,
846  VKVG_OPERATOR_DEST_OUT,
847  VKVG_OPERATOR_DEST_ATOP,
848 
849  VKVG_OPERATOR_XOR,
850  VKVG_OPERATOR_ADD,
851  VKVG_OPERATOR_SATURATE,
852 
853  VKVG_OPERATOR_MULTIPLY,
854  VKVG_OPERATOR_SCREEN,
855  VKVG_OPERATOR_OVERLAY,
856  VKVG_OPERATOR_DARKEN,
857  VKVG_OPERATOR_LIGHTEN,
858  VKVG_OPERATOR_COLOR_DODGE,
859  VKVG_OPERATOR_COLOR_BURN,
860  VKVG_OPERATOR_HARD_LIGHT,
861  VKVG_OPERATOR_SOFT_LIGHT,
863  VKVG_OPERATOR_EXCLUSION,
864  VKVG_OPERATOR_HSL_HUE,
865  VKVG_OPERATOR_HSL_SATURATION,
866  VKVG_OPERATOR_HSL_COLOR,
867  VKVG_OPERATOR_HSL_LUMINOSITY,*/
870 
882 vkvg_public
890 vkvg_public
899 vkvg_public
909 vkvg_public
916 vkvg_public
923 vkvg_public
934 vkvg_public
944 vkvg_public
954 vkvg_public
965 vkvg_public
975 vkvg_public
976 void vkvg_path_extents (VkvgContext ctx, float *x1, float *y1, float *x2, float *y2);
985 vkvg_public
986 void vkvg_get_current_point (VkvgContext ctx, float* x, float* y);
997 vkvg_public
998 void vkvg_line_to (VkvgContext ctx, float x, float y);
1009 vkvg_public
1010 void vkvg_rel_line_to (VkvgContext ctx, float dx, float dy);
1023 vkvg_public
1024 void vkvg_move_to (VkvgContext ctx, float x, float y);
1036 vkvg_public
1037 void vkvg_rel_move_to (VkvgContext ctx, float x, float y);
1061 vkvg_public
1062 void vkvg_arc (VkvgContext ctx, float xc, float yc, float radius, float a1, float a2);
1080 vkvg_public
1081 void vkvg_arc_negative (VkvgContext ctx, float xc, float yc, float radius, float a1, float a2);
1097 vkvg_public
1098 void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3);
1115 vkvg_public
1116 void vkvg_rel_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3);
1127 vkvg_public
1128 void vkvg_quadratic_to (VkvgContext ctx, float x1, float y1, float x2, float y2);
1138 vkvg_public
1139 void vkvg_rel_quadratic_to (VkvgContext ctx, float x1, float y1, float x2, float y2);
1151 vkvg_public
1152 vkvg_status_t vkvg_rectangle(VkvgContext ctx, float x, float y, float w, float h);
1165 vkvg_public
1166 vkvg_status_t vkvg_rounded_rectangle (VkvgContext ctx, float x, float y, float w, float h, float radius);
1180 vkvg_public
1181 void vkvg_rounded_rectangle2 (VkvgContext ctx, float x, float y, float w, float h, float rx, float ry);
1182 
1195 vkvg_public
1196 void vkvg_ellipse (VkvgContext ctx, float radiusX, float radiusY, float x, float y, float rotationAngle);
1217 vkvg_public
1218 void vkvg_elliptic_arc_to (VkvgContext ctx, float x, float y, bool large_arc_flag, bool sweep_flag, float rx, float ry, float phi);
1232 vkvg_public
1233 void vkvg_rel_elliptic_arc_to (VkvgContext ctx, float x, float y, bool large_arc_flag, bool sweep_flag, float rx, float ry, float phi);
1243 vkvg_public
1252 vkvg_public
1262 vkvg_public
1271 vkvg_public
1281 vkvg_public
1293 vkvg_public
1294 void vkvg_clear (VkvgContext ctx);//use vkClearAttachment to speed up clearing surf
1302 vkvg_public
1319 vkvg_public
1328 vkvg_public
1338 vkvg_public
1339 void vkvg_set_opacity (VkvgContext ctx, float opacity);
1340 vkvg_public
1354 vkvg_public
1355 void vkvg_set_source_color (VkvgContext ctx, uint32_t c);
1366 vkvg_public
1367 void vkvg_set_source_rgba (VkvgContext ctx, float r, float g, float b, float a);
1382 vkvg_public
1383 void vkvg_set_source_rgb (VkvgContext ctx, float r, float g, float b);
1393 vkvg_public
1394 void vkvg_set_line_width (VkvgContext ctx, float width);
1409 vkvg_public
1410 void vkvg_set_miter_limit (VkvgContext ctx, float limit);
1419 vkvg_public
1428 vkvg_public
1437 vkvg_public
1448 vkvg_public
1449 void vkvg_set_source_surface (VkvgContext ctx, VkvgSurface surf, float x, float y);
1457 vkvg_public
1465 vkvg_public
1473 vkvg_public
1487 vkvg_public
1488 void vkvg_set_dash (VkvgContext ctx, const float* dashes, uint32_t num_dashes, float offset);
1500 vkvg_public
1501 void vkvg_get_dash (VkvgContext ctx, const float *dashes, uint32_t* num_dashes, float* offset);
1502 
1510 vkvg_public
1518 vkvg_public
1526 vkvg_public
1534 vkvg_public
1547 vkvg_public
1557 vkvg_public
1559 
1567 vkvg_public
1578 vkvg_public
1580 
1589 vkvg_public
1599 vkvg_public
1609 vkvg_public
1610 void vkvg_translate (VkvgContext ctx, float dx, float dy);
1619 vkvg_public
1620 void vkvg_scale (VkvgContext ctx, float sx, float sy);
1628 vkvg_public
1629 void vkvg_rotate (VkvgContext ctx, float radians);
1638 vkvg_public
1639 void vkvg_transform (VkvgContext ctx, const vkvg_matrix_t* matrix);
1648 vkvg_public
1649 void vkvg_set_matrix (VkvgContext ctx, const vkvg_matrix_t* matrix);
1658 vkvg_public
1659 void vkvg_get_matrix (VkvgContext ctx, const vkvg_matrix_t* matrix);
1667 vkvg_public
1669 
1676 vkvg_public
1677 void vkvg_select_font_face (VkvgContext ctx, const char* name);
1685 vkvg_public
1686 void vkvg_load_font_from_path (VkvgContext ctx, const char* path, const char *name);
1695 vkvg_public
1696 void vkvg_load_font_from_memory (VkvgContext ctx, unsigned char* fontBuffer, long fontBufferByteSize, const char* name);
1703 vkvg_public
1704 void vkvg_set_font_size (VkvgContext ctx, uint32_t size);
1714 vkvg_public
1715 void vkvg_show_text (VkvgContext ctx, const char* utf8);
1723 vkvg_public
1724 void vkvg_text_extents (VkvgContext ctx, const char* utf8, vkvg_text_extents_t* extents);
1731 vkvg_public
1733 
1734 //text run holds harfbuz datas, and prevent recreating them multiple times for the same line of text.
1742 vkvg_public
1752 vkvg_public
1753 VkvgText vkvg_text_run_create_with_length (VkvgContext ctx, const char* text, uint32_t length);
1759 vkvg_public
1767 vkvg_public
1775 vkvg_public
1782 vkvg_public
1788 vkvg_public
1790  uint32_t index,
1791  vkvg_glyph_info_t* pGlyphInfo);
1810 vkvg_public
1819 vkvg_public
1831 vkvg_public
1845 vkvg_public
1846 VkvgPattern vkvg_pattern_create_linear (float x0, float y0, float x1, float y1);
1858 vkvg_public
1859 vkvg_status_t vkvg_pattern_edit_linear(VkvgPattern pat, float x0, float y0, float x1, float y1);
1871 vkvg_public
1872 vkvg_status_t vkvg_pattern_get_linear_points(VkvgPattern pat, float* x0, float* y0, float* x1, float* y1);
1887 vkvg_public
1888 VkvgPattern vkvg_pattern_create_radial (float cx0, float cy0, float radius0,
1889  float cx1, float cy1, float radius1);
1904 vkvg_public
1906  float cx0, float cy0, float radius0,
1907  float cx1, float cy1, float radius1);
1917 vkvg_public
1934 vkvg_public
1936  float* offset, float* r, float* g, float* b, float* a);
1937 
1945 vkvg_public
1960 vkvg_public
1961 vkvg_status_t vkvg_pattern_add_color_stop(VkvgPattern pat, float offset, float r, float g, float b, float a);
1971 vkvg_public
1979 vkvg_public
1987 vkvg_public
1995 vkvg_public
2005 vkvg_public
2007 vkvg_public
2009 vkvg_public
2011 
2014 /********* EXPERIMENTAL **************/
2015 vkvg_public
2016 void vkvg_set_source_color_name (VkvgContext ctx, const char* color);
2017 
2018 #ifdef VKVG_RECORDING
2019 typedef struct _vkvg_recording_t* VkvgRecording;
2020 
2021 vkvg_public
2022 void vkvg_start_recording (VkvgContext ctx);
2023 vkvg_public
2024 VkvgRecording vkvg_stop_recording (VkvgContext ctx);
2025 vkvg_public
2026 void vkvg_replay (VkvgContext ctx, VkvgRecording rec);
2027 vkvg_public
2028 void vkvg_replay_command (VkvgContext ctx, VkvgRecording rec, uint32_t cmdIndex);
2029 vkvg_public
2030 void vkvg_recording_get_command (VkvgRecording rec, uint32_t cmdIndex, uint32_t* cmd, void** dataOffset);
2031 vkvg_public
2032 uint32_t vkvg_recording_get_count(VkvgRecording rec);
2033 vkvg_public
2034 void* vkvg_recording_get_data (VkvgRecording rec);
2035 vkvg_public
2036 void vkvg_recording_destroy (VkvgRecording rec);
2037 /*************************************/
2038 #endif
2039 
2040 #ifdef __cplusplus
2041 }
2042 #endif
2043 
2044 #endif
void vkvg_get_dash(VkvgContext ctx, const float *dashes, uint32_t *num_dashes, float *offset)
get current dash settings.
void vkvg_identity_matrix(VkvgContext ctx)
Set the current matrix to identity.
uint32_t vkvg_get_reference_count(VkvgContext ctx)
Get the current reference count of this context.
void vkvg_set_dash(VkvgContext ctx, const float *dashes, uint32_t num_dashes, float offset)
set the dash configuration for strokes
void vkvg_destroy(VkvgContext ctx)
Destroy vkvg context.
struct _vkvg_context_t * VkvgContext
The Vkvg drawing Context.
Definition: vkvg.h:296
void vkvg_clip(VkvgContext ctx)
Establishes a new clip region.
vkvg_line_join_t vkvg_get_line_join(VkvgContext ctx)
const char * vkvg_status_to_string(vkvg_status_t status)
void vkvg_show_text_run(VkvgContext ctx, VkvgText textRun)
void vkvg_restore(VkvgContext ctx)
Restore context's graphic states.
void vkvg_text_run_destroy(VkvgText textRun)
Release ressources holded by the text run.
void vkvg_transform(VkvgContext ctx, const vkvg_matrix_t *matrix)
Add an additional transformation to the current matrix.
void vkvg_set_fill_rule(VkvgContext ctx, vkvg_fill_rule_t fr)
void vkvg_set_miter_limit(VkvgContext ctx, float limit)
set line join miter size limit.
void vkvg_elliptic_arc_to(VkvgContext ctx, float x, float y, bool large_arc_flag, bool sweep_flag, float rx, float ry, float phi)
Add an elliptical arc to the current path.
VkvgText vkvg_text_run_create_with_length(VkvgContext ctx, const char *text, uint32_t length)
Create a new text run for a non null terminated string.
void vkvg_text_run_get_glyph_position(VkvgText textRun, uint32_t index, vkvg_glyph_info_t *pGlyphInfo)
retrieve glyph positions.
void vkvg_set_source(VkvgContext ctx, VkvgPattern pat)
set supplied pattern as current source.
float vkvg_get_miter_limit(VkvgContext ctx)
Gets the current miter limit.
float vkvg_get_line_width(VkvgContext ctx)
get current line width
uint32_t vkvg_text_run_get_glyph_count(VkvgText textRun)
Get glyph count of text run.
void vkvg_set_source_surface(VkvgContext ctx, VkvgSurface surf, float x, float y)
use supplied surface as current pattern.
void vkvg_text_extents(VkvgContext ctx, const char *utf8, vkvg_text_extents_t *extents)
Gets the extents for a string of text.
float vkvg_get_opacity(VkvgContext ctx)
Get current opacity.
void vkvg_fill(VkvgContext ctx)
Fill command.
void vkvg_path_extents(VkvgContext ctx, float *x1, float *y1, float *x2, float *y2)
vkvg_path_extents
vkvg_status_t vkvg_rounded_rectangle(VkvgContext ctx, float x, float y, float w, float h, float radius)
Add an axis aligned rectangle with rounded corners to the current path.
VkvgText vkvg_text_run_create(VkvgContext ctx, const char *text)
Create a new text run.
void vkvg_set_line_join(VkvgContext ctx, vkvg_line_join_t join)
set line joins for the next draw command.
vkvg_status_t vkvg_rectangle(VkvgContext ctx, float x, float y, float w, float h)
Add an axis aligned rectangle subpath to the current path.
void vkvg_get_matrix(VkvgContext ctx, const vkvg_matrix_t *matrix)
Get the current matrix.
void vkvg_translate(VkvgContext ctx, float dx, float dy)
Add a translation to the current transformation matrix.
void vkvg_set_source_rgba(VkvgContext ctx, float r, float g, float b, float a)
set color with alpha.
void vkvg_set_source_rgb(VkvgContext ctx, float r, float g, float b)
set opaque color as new source.
void vkvg_stroke(VkvgContext ctx)
Stroke command.
void vkvg_show_text(VkvgContext ctx, const char *utf8)
Show a string of text.
void vkvg_set_operator(VkvgContext ctx, vkvg_operator_t op)
void vkvg_line_to(VkvgContext ctx, float x, float y)
Add a line to the current path from the current point to the coordinate given in arguments.
void vkvg_arc_negative(VkvgContext ctx, float xc, float yc, float radius, float a1, float a2)
Add a circular arc in counter clockwise order to the current path.
VkvgSurface vkvg_get_target(VkvgContext ctx)
Get the current target of the context.
void vkvg_quadratic_to(VkvgContext ctx, float x1, float y1, float x2, float y2)
Add a quadratic Bezizer curve to the current path.
void vkvg_paint(VkvgContext ctx)
Paint command.
void vkvg_scale(VkvgContext ctx, float sx, float sy)
Add a scaling transform to the current transformation matrix.
void vkvg_new_path(VkvgContext ctx)
Start a new empty path.
void vkvg_load_font_from_memory(VkvgContext ctx, unsigned char *fontBuffer, long fontBufferByteSize, const char *name)
Select a new font by providing a pointer on the font file loaded in memory and its size in byte.
void vkvg_ellipse(VkvgContext ctx, float radiusX, float radiusY, float x, float y, float rotationAngle)
Add a closed ellipse to the current path.
vkvg_line_cap_t vkvg_get_line_cap(VkvgContext ctx)
void vkvg_stroke_preserve(VkvgContext ctx)
Stroke command that preserve current path.
void vkvg_move_to(VkvgContext ctx, float x, float y)
Move the context pen to the position given in argument.
void vkvg_curve_to(VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3)
Adds a cubic Bézier spline to the current path.
bool vkvg_has_current_point(VkvgContext ctx)
Check if context has a current point defined.
void vkvg_fill_preserve(VkvgContext ctx)
Fill command that preserve current path.
VkvgContext vkvg_create(VkvgSurface surf)
Create a new vkvg context used for drawing on surfaces.
void vkvg_set_opacity(VkvgContext ctx, float opacity)
Set global opacity for drawing operations.
void vkvg_set_matrix(VkvgContext ctx, const vkvg_matrix_t *matrix)
Set the current matrix.
void vkvg_get_current_point(VkvgContext ctx, float *x, float *y)
Get the current point.
void vkvg_font_extents(VkvgContext ctx, vkvg_font_extents_t *extents)
Gets the font extents for the currently selected font.
void vkvg_set_source_color(VkvgContext ctx, uint32_t c)
Set current source for drawing to the solid color defined by the supplied 32bit integer.
void vkvg_save(VkvgContext ctx)
Save context's graphic states.
void vkvg_arc(VkvgContext ctx, float xc, float yc, float radius, float a1, float a2)
Adds a circular arc of the given radius to the current path.
void vkvg_set_line_width(VkvgContext ctx, float width)
set line width for the next draw command.
vkvg_operator_t vkvg_get_operator(VkvgContext ctx)
void vkvg_rel_move_to(VkvgContext ctx, float x, float y)
Move the context pen relative to the current point.
void vkvg_flush(VkvgContext ctx)
Perform all the pending drawing operations on a context.
void vkvg_set_line_cap(VkvgContext ctx, vkvg_line_cap_t cap)
set line terminations for the next draw command.
void vkvg_reset_clip(VkvgContext ctx)
Reset the current clip region.
void vkvg_rounded_rectangle2(VkvgContext ctx, float x, float y, float w, float h, float rx, float ry)
Add an axis aligned rectangle with rounded corners defined in both axis to the current path.
void vkvg_rel_quadratic_to(VkvgContext ctx, float x1, float y1, float x2, float y2)
Add a quadratic Bezizer curve to the current path relative to the current point.
void vkvg_rel_curve_to(VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3)
Adds a cubic Bézier spline to the current path relative to the current point.
void vkvg_new_sub_path(VkvgContext ctx)
Start a new sub path.
void vkvg_rel_elliptic_arc_to(VkvgContext ctx, float x, float y, bool large_arc_flag, bool sweep_flag, float rx, float ry, float phi)
Add an elliptical arc to the current path.
vkvg_fill_rule_t vkvg_get_fill_rule(VkvgContext ctx)
Get current fill rule.
void vkvg_load_font_from_path(VkvgContext ctx, const char *path, const char *name)
Select a new font by providing its file path.
void vkvg_select_font_face(VkvgContext ctx, const char *name)
Try find font with the specified name using the FontConfig library.
void vkvg_set_font_size(VkvgContext ctx, uint32_t size)
void vkvg_text_run_get_extents(VkvgText textRun, vkvg_text_extents_t *extents)
VkvgContext vkvg_reference(VkvgContext ctx)
Increment by one the reference count on this context.
void vkvg_rotate(VkvgContext ctx, float radians)
Add a rotation to the current transformation matrix.
void vkvg_rel_line_to(VkvgContext ctx, float dx, float dy)
Add a line to the current path from the current point to the coordinate relative to it.
void vkvg_clip_preserve(VkvgContext ctx)
Establishes a new clip region preserving the current path.
vkvg_status_t vkvg_status(VkvgContext ctx)
Get context status.
void vkvg_close_path(VkvgContext ctx)
Close the current path.
VkvgPattern vkvg_get_source(VkvgContext ctx)
Get the current source of the context.
void vkvg_clear(VkvgContext ctx)
Clear surface.
void vkvg_device_set_thread_aware(VkvgDevice dev, uint32_t thread_awayre)
vkvg_device_set_thread_aware
VkvgDevice vkvg_device_create_from_vk_multisample(VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex, VkSampleCountFlags samples, bool deferredResolve)
Create a new multisampled vkvg device.
void vkvg_device_destroy(VkvgDevice dev)
Decrement the reference count of the device by 1. Release all it's ressources if count reach 0.
VkvgDevice vkvg_device_reference(VkvgDevice dev)
Increment the reference count on this device.
struct _vkvg_device_t * VkvgDevice
Opaque pointer on a Vkvg device structure.
Definition: vkvg.h:315
void vkvg_device_get_dpy(VkvgDevice dev, int *hdpy, int *vdpy)
Get the current dpy values.
void vkvg_device_set_dpy(VkvgDevice dev, int hdpy, int vdpy)
Set the screen dot per inch for this device.
VkvgDevice vkvg_device_create(VkSampleCountFlags samples, bool deferredResolve)
Create a new vkvg device.
VkvgDevice vkvg_device_create_from_vk(VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex)
Create a new vkvg device from an existing vulkan logical device.
vkvg_status_t vkvg_device_status(VkvgDevice dev)
Get the current status of the device.
void vkvg_get_required_device_extensions(VkPhysicalDevice phy, const char **pExtensions, uint32_t *pExtCount)
query required device extensions for vkvg.
void vkvg_get_required_instance_extensions(const char **pExtensions, uint32_t *pExtCount)
query required instance extensions for vkvg.
const void * vkvg_get_device_requirements(VkPhysicalDeviceFeatures *pEnabledFeatures)
get vulkan device creation requirement to fit vkvg needs.
uint32_t vkvg_device_get_reference_count(VkvgDevice dev)
Query the reference count of the device.
void vkvg_matrix_rotate(vkvg_matrix_t *matrix, float radians)
apply rotation on matrix
void vkvg_matrix_scale(vkvg_matrix_t *matrix, float sx, float sy)
apply scale on matrix
void vkvg_matrix_init_translate(vkvg_matrix_t *matrix, float tx, float ty)
Rotation matrix initialization.
void vkvg_matrix_init_identity(vkvg_matrix_t *matrix)
Set matrix to identity.
void vkvg_matrix_multiply(vkvg_matrix_t *result, const vkvg_matrix_t *a, const vkvg_matrix_t *b)
matrices multiplication
void vkvg_matrix_init_rotate(vkvg_matrix_t *matrix, float radians)
rotation matrix initialization
void vkvg_matrix_init_scale(vkvg_matrix_t *matrix, float sx, float sy)
scaling matrix initialization
vkvg_status_t vkvg_matrix_invert(vkvg_matrix_t *matrix)
invert matrix
void vkvg_matrix_transform_point(const vkvg_matrix_t *matrix, float *x, float *y)
transform point
void vkvg_matrix_translate(vkvg_matrix_t *matrix, float tx, float ty)
apply translation on matrix
void vkvg_matrix_get_scale(const vkvg_matrix_t *matrix, float *sx, float *sy)
void vkvg_matrix_init(vkvg_matrix_t *matrix, float xx, float yx, float xy, float yy, float x0, float y0)
Matrix initialization.
void vkvg_matrix_transform_distance(const vkvg_matrix_t *matrix, float *dx, float *dy)
transform distances
VkvgPattern vkvg_pattern_create_radial(float cx0, float cy0, float radius0, float cx1, float cy1, float radius1)
create a new radial gradient.
void vkvg_pattern_set_matrix(VkvgPattern pat, const vkvg_matrix_t *matrix)
void vkvg_pattern_set_extend(VkvgPattern pat, vkvg_extend_t extend)
control the extend of the pattern
vkvg_status_t vkvg_pattern_edit_radial(VkvgPattern pat, float cx0, float cy0, float radius0, float cx1, float cy1, float radius1)
edit an existing radial gradient.
VkvgPattern vkvg_pattern_reference(VkvgPattern pat)
add reference
void vkvg_pattern_get_matrix(VkvgPattern pat, vkvg_matrix_t *matrix)
struct _vkvg_pattern_t * VkvgPattern
Opaque pointer on a Vkvg pattern structure.
Definition: vkvg.h:323
uint32_t vkvg_pattern_get_reference_count(VkvgPattern pat)
get reference count
vkvg_pattern_type_t vkvg_pattern_get_type(VkvgPattern pat)
get pattern type
vkvg_status_t vkvg_pattern_get_linear_points(VkvgPattern pat, float *x0, float *y0, float *x1, float *y1)
get the gradient end points for a linear gradient
vkvg_status_t vkvg_pattern_edit_linear(VkvgPattern pat, float x0, float y0, float x1, float y1)
edit an existing linear gradient.
vkvg_status_t vkvg_pattern_add_color_stop(VkvgPattern pat, float offset, float r, float g, float b, float a)
add colors to gradients
vkvg_status_t vkvg_pattern_get_color_stop_count(VkvgPattern pat, uint32_t *count)
get color stop count.
VkvgPattern vkvg_pattern_create_linear(float x0, float y0, float x1, float y1)
create a new linear gradient.
void vkvg_pattern_set_filter(VkvgPattern pat, vkvg_filter_t filter)
control the filtering when using this pattern on a surface.
VkvgPattern vkvg_pattern_create_for_surface(VkvgSurface surf)
create a surface pattern
vkvg_filter_t vkvg_pattern_get_filter(VkvgPattern pat)
void vkvg_pattern_destroy(VkvgPattern pat)
dispose pattern.
vkvg_extend_t vkvg_pattern_get_extend(VkvgPattern pat)
query the current extend value for a pa
vkvg_status_t vkvg_pattern_get_color_stop_rgba(VkvgPattern pat, uint32_t index, float *offset, float *r, float *g, float *b, float *a)
get color stop.
vkvg_status_t vkvg_surface_status(VkvgSurface surf)
Query the current status of the surface.
VkvgSurface vkvg_surface_reference(VkvgSurface surf)
Increment reference count on the surface by one.
vkvg_status_t vkvg_surface_write_to_memory(VkvgSurface surf, unsigned char *const bitmap)
Save surface to memory.
void vkvg_surface_destroy(VkvgSurface surf)
Decrement the reference count on the surface by one. Destroy it if count reach 0.
VkFormat vkvg_surface_get_vk_format(VkvgSurface surf)
Get the vulkan format of the vulkan texture used as backend for this surface.
uint32_t vkvg_surface_get_height(VkvgSurface surf)
Get the actual surface height.
VkImage vkvg_surface_get_vk_image(VkvgSurface surf)
Get the final single sampled vulkan image of this surface.
vkvg_status_t vkvg_surface_write_to_png(VkvgSurface surf, const char *path)
Write surface content to a png file on disk.
VkvgSurface vkvg_surface_create_from_image(VkvgDevice dev, const char *filePath)
Create a new vkvg surface by loading an image file. The resulting surface will have the same dimensio...
uint32_t vkvg_surface_get_width(VkvgSurface surf)
Get the actual surface width.
VkvgSurface vkvg_surface_create(VkvgDevice dev, uint32_t width, uint32_t height)
Create a new vkvg surface.
void vkvg_surface_resolve(VkvgSurface surf)
Explicitly resolve a multisampled surface.
void vkvg_surface_clear(VkvgSurface surf)
Clear surface's content.
VkvgSurface vkvg_surface_create_for_VkhImage(VkvgDevice dev, void *vkhImg)
Create a new vkvg surface using an existing vulkan texture as backend.
struct _vkvg_surface_t * VkvgSurface
Opaque pointer on a Vkvg Surface structure.
Definition: vkvg.h:308
uint32_t vkvg_surface_get_reference_count(VkvgSurface surf)
Get the current reference count on this surface.
float r
Definition: vkvg.h:227
float a
Definition: vkvg.h:230
float b
Definition: vkvg.h:229
float g
Definition: vkvg.h:228
float max_y_advance
Definition: vkvg.h:244
float max_x_advance
Definition: vkvg.h:243
font metrics
Definition: vkvg.h:239
int32_t x_offset
Definition: vkvg.h:270
int32_t y_offset
Definition: vkvg.h:271
uint32_t codepoint
Definition: vkvg.h:273
int32_t y_advance
Definition: vkvg.h:269
int32_t x_advance
Definition: vkvg.h:268
glyphs position in a VkvgText
Definition: vkvg.h:267
float x0
Definition: vkvg.h:373
float xy
Definition: vkvg.h:372
float xx
Definition: vkvg.h:371
vkvg matrix structure
Definition: vkvg.h:370
float y_advance
Definition: vkvg.h:258
float x_bearing
Definition: vkvg.h:253
float y_bearing
Definition: vkvg.h:254
float x_advance
Definition: vkvg.h:257
text metrics
Definition: vkvg.h:252
vkvg_status_t
vkvg operation status.
Definition: vkvg.h:119
@ VKVG_STATUS_PATTERN_INVALID_GRADIENT
Definition: vkvg.h:130
@ VKVG_STATUS_INVALID_RECT
Definition: vkvg.h:134
@ VKVG_STATUS_PATTERN_TYPE_MISMATCH
Definition: vkvg.h:129
@ VKVG_STATUS_INVALID_INDEX
Definition: vkvg.h:126
@ VKVG_STATUS_NULL_POINTER
Definition: vkvg.h:127
@ VKVG_STATUS_DEVICE_ERROR
Definition: vkvg.h:136
@ VKVG_STATUS_INVALID_SURFACE
Definition: vkvg.h:138
@ VKVG_STATUS_TIMEOUT
Definition: vkvg.h:135
@ VKVG_STATUS_INVALID_MATRIX
Definition: vkvg.h:124
@ VKVG_STATUS_INVALID_IMAGE
Definition: vkvg.h:137
@ VKVG_STATUS_INVALID_FORMAT
Definition: vkvg.h:131
@ VKVG_STATUS_INVALID_FONT
Definition: vkvg.h:139
@ VKVG_STATUS_WRITE_ERROR
Definition: vkvg.h:128
@ VKVG_STATUS_INVALID_DASH
Definition: vkvg.h:133
@ VKVG_STATUS_INVALID_RESTORE
Definition: vkvg.h:122
@ VKVG_STATUS_NO_MEMORY
Definition: vkvg.h:121
@ VKVG_STATUS_SUCCESS
Definition: vkvg.h:120
@ VKVG_STATUS_FILE_NOT_FOUND
Definition: vkvg.h:132
@ VKVG_STATUS_NO_CURRENT_POINT
Definition: vkvg.h:123
@ VKVG_STATUS_INVALID_STATUS
Definition: vkvg.h:125
vkvg_pattern_type_t
pattern types
Definition: vkvg.h:181
@ VKVG_PATTERN_TYPE_LINEAR
Definition: vkvg.h:184
@ VKVG_PATTERN_TYPE_SURFACE
Definition: vkvg.h:183
@ VKVG_PATTERN_TYPE_MESH
Definition: vkvg.h:186
@ VKVG_PATTERN_TYPE_RADIAL
Definition: vkvg.h:185
@ VKVG_PATTERN_TYPE_RASTER_SOURCE
Definition: vkvg.h:187
@ VKVG_PATTERN_TYPE_SOLID
Definition: vkvg.h:182
vkvg_direction_t
Definition: vkvg.h:142
@ VKVG_VERTICAL
Definition: vkvg.h:144
@ VKVG_HORIZONTAL
Definition: vkvg.h:143
vkvg_operator_t
compositing operators
Definition: vkvg.h:834
@ VKVG_OPERATOR_OVER
Definition: vkvg.h:838
@ VKVG_OPERATOR_MAX
Definition: vkvg.h:868
@ VKVG_OPERATOR_CLEAR
Definition: vkvg.h:835
@ VKVG_OPERATOR_DIFFERENCE
Definition: vkvg.h:862
@ VKVG_OPERATOR_SOURCE
Definition: vkvg.h:837
struct _vkvg_text_run_t * VkvgText
Opaque pointer on a vkvg text run.
Definition: vkvg.h:288
vkvg_line_join_t
lines articulations
Definition: vkvg.h:207
@ VKVG_LINE_JOIN_ROUND
Definition: vkvg.h:209
@ VKVG_LINE_JOIN_BEVEL
Definition: vkvg.h:210
@ VKVG_LINE_JOIN_MITER
Definition: vkvg.h:208
vkvg_fill_rule_t
path fill method.
Definition: vkvg.h:221
@ VKVG_FILL_RULE_NON_ZERO
Definition: vkvg.h:223
@ VKVG_FILL_RULE_EVEN_ODD
Definition: vkvg.h:222
vkvg_extend_t
pattern border policy
Definition: vkvg.h:159
@ VKVG_EXTEND_NONE
Definition: vkvg.h:160
@ VKVG_EXTEND_PAD
Definition: vkvg.h:163
@ VKVG_EXTEND_REPEAT
Definition: vkvg.h:161
@ VKVG_EXTEND_REFLECT
Definition: vkvg.h:162
vkvg_format_t
Definition: vkvg.h:147
@ VKVG_FORMAT_A8
Definition: vkvg.h:150
@ VKVG_FORMAT_A1
Definition: vkvg.h:151
@ VKVG_FORMAT_ARGB32
Definition: vkvg.h:148
@ VKVG_FORMAT_RGB24
Definition: vkvg.h:149
vkvg_filter_t
Definition: vkvg.h:167
@ VKVG_FILTER_BEST
Definition: vkvg.h:170
@ VKVG_FILTER_FAST
Definition: vkvg.h:168
@ VKVG_FILTER_GAUSSIAN
Definition: vkvg.h:173
@ VKVG_FILTER_NEAREST
Definition: vkvg.h:171
@ VKVG_FILTER_GOOD
Definition: vkvg.h:169
@ VKVG_FILTER_BILINEAR
Definition: vkvg.h:172
vkvg_line_cap_t
line caps
Definition: vkvg.h:196
@ VKVG_LINE_CAP_SQUARE
Definition: vkvg.h:199
@ VKVG_LINE_CAP_ROUND
Definition: vkvg.h:198
@ VKVG_LINE_CAP_BUTT
Definition: vkvg.h:197
void vkvg_set_source_color_name(VkvgContext ctx, const char *color)