VKVG  
Vulkan Vector Graphics
Loading...
Searching...
No Matches
vkvg.h
Go to the documentation of this file.
1// Copyright (c) 2018-2026 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
2//
3// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
4#ifndef VKVG_H
5#define VKVG_H
6
7#include <stdint.h>
8#include <stddef.h>
9
10#include <vulkan/vulkan.h>
11
12#ifdef __cplusplus
13extern "C" {
14#else
15#include <stdbool.h>
16#endif
17
58#ifndef vkvg_public
59#ifdef VKVG_SHARED_BUILD
60#if (defined(_WIN32) || defined(__CYGWIN__))
61#define vkvg_public __declspec(dllexport)
62#else
63#define vkvg_public __attribute__((visibility("default")))
64#endif
65#elif (defined(VKVG_SHARED_LINKING) && (defined(_WIN32) || defined(__CYGWIN__)))
66#define vkvg_public __declspec(dllimport)
67#else
68#define vkvg_public
69#endif
70#endif
71
72#define VKVG_LOG_ERR 0x00000001
73#define VKVG_LOG_WARN 0x00000002
74#define VKVG_LOG_DEBUG 0x00000004
75
76#define VKVG_LOG_INFO_PTS 0x00000008
77#define VKVG_LOG_INFO_PATH 0x00000010
78#define VKVG_LOG_INFO_CMD 0x00000020
79#define VKVG_LOG_INFO_VBO 0x00000040
80#define VKVG_LOG_INFO_IBO 0x00000080
81#define VKVG_LOG_INFO_VAO (VKVG_LOG_INFO_VBO | VKVG_LOG_INFO_IBO)
82#define VKVG_LOG_THREAD 0x00000100
83#define VKVG_LOG_DBG_ARRAYS 0x00001000
84#define VKVG_LOG_STROKE 0x00010000
85#define VKVG_LOG_FONT 0x00100000
86#define VKVG_LOG_FULL 0xffffffff
87
88#define VKVG_LOG_INFO 0x00008000 //(VKVG_LOG_INFO_PTS|VKVG_LOG_INFO_PATH|VKVG_LOG_INFO_CMD|VKVG_LOG_INFO_VAO)
89
90vkvg_public extern uint32_t vkvg_log_level;
91#ifdef DEBUG
92#ifdef VKVG_WIRED_DEBUG
93typedef enum {
94 vkvg_wired_debug_mode_normal = 0x01,
95 vkvg_wired_debug_mode_points = 0x02,
96 vkvg_wired_debug_mode_lines = 0x04,
97 vkvg_wired_debug_mode_both = vkvg_wired_debug_mode_points | vkvg_wired_debug_mode_lines,
98 vkvg_wired_debug_mode_all = 0xFFFFFFFF
99} vkvg_wired_debug_mode;
100vkvg_public extern vkvg_wired_debug_mode vkvg_wired_debug;
101#endif
102#endif
103
104#define VKVG_MAX_DASH_COUNT 5
105
141
143
157
166
180
203
216
217typedef struct {
218 float r;
219 float g;
220 float b;
221 float a;
223
230typedef struct {
231 float ascent;
232 float descent;
233 float height;
245typedef struct {
246 float x_bearing;
248 float y_bearing;
250 float width;
251 float height;
252 float x_advance;
253 float y_advance;
256
263typedef struct _glyph_info_t {
264 int32_t x_advance;
265 int32_t y_advance;
266 int32_t x_offset;
267 int32_t y_offset;
268 /* private */
269 uint32_t codepoint; // should be named glyphIndex, but for harfbuzz compatibility...
271
278typedef struct _vkvg_context_t* VkvgContext;
290typedef struct _vkvg_surface_t* VkvgSurface;
297typedef struct _vkvg_device_t* VkvgDevice;
305typedef struct _vkvg_pattern_t* VkvgPattern;
318typedef struct _vkvg_text_run_t* VkvgText;
319
329typedef struct _vkvg_font_t* VkvgFont;
341vkvg_public VkvgFont vkvg_font_create (VkvgSurface surf, const char* queryString, float pointSize);
350vkvg_public VkvgFont vkvg_font_create_from_file (VkvgSurface surf, const char* fontFilePath, int faceIndex, float pointSize);
356vkvg_public void* vkvg_font_get_face (VkvgFont font);
368vkvg_public uint32_t vkvg_font_get_reference_count (VkvgFont font);
381vkvg_public void vkvg_font_destroy (VkvgFont font);
382#if VKVG_DBG_STATS
388#define VKVG_HAS_DBG_STATS
389typedef struct {
390 uint32_t sizePoints;
391 uint32_t sizePathes;
392 uint32_t sizeVertices;
393 uint32_t sizeIndices;
394 uint32_t sizeVBO;
395 uint32_t sizeIBO;
396} vkvg_debug_stats_t;
397
398vkvg_debug_stats_t vkvg_device_get_stats(VkvgDevice dev);
399void vkvg_device_reset_stats(VkvgDevice dev);
400#endif
401
409#define VKVG_IDENTITY_MATRIX (vkvg_matrix_t){1, 0, 0, 1, 0, 0}
427typedef struct {
428 float xx;
429 float yx;
430 float xy;
431 float yy;
432 float x0;
433 float y0;
441vkvg_public void vkvg_matrix_init_identity(vkvg_matrix_t* matrix);
455vkvg_public void vkvg_matrix_init(vkvg_matrix_t* matrix, float xx, float yx, float xy, float yy, float x0, float y0);
464vkvg_public void vkvg_matrix_init_translate(vkvg_matrix_t* matrix, float tx, float ty);
473vkvg_public void vkvg_matrix_init_scale(vkvg_matrix_t* matrix, float sx, float sy);
485vkvg_public void vkvg_matrix_init_rotate(vkvg_matrix_t* matrix, float radians);
496vkvg_public void vkvg_matrix_translate(vkvg_matrix_t* matrix, float tx, float ty);
507vkvg_public void vkvg_matrix_scale(vkvg_matrix_t* matrix, float sx, float sy);
519vkvg_public void vkvg_matrix_rotate(vkvg_matrix_t* matrix, float radians);
528vkvg_public void vkvg_matrix_multiply(vkvg_matrix_t* result, const vkvg_matrix_t * const a, const vkvg_matrix_t * const b);
544vkvg_public void vkvg_matrix_transform_distance(const vkvg_matrix_t* matrix, float* dx, float* dy);
553vkvg_public void vkvg_matrix_transform_point(const vkvg_matrix_t* matrix, float* x, float* y);
564vkvg_public void vkvg_matrix_get_scale(const vkvg_matrix_t* matrix, float* sx, float* sy);
605typedef struct {
606 VkSampleCountFlags samples;
608 VkInstance inst;
609 VkPhysicalDevice phy;
610 VkDevice vkdev;
611 uint32_t qFamIdx;
612 uint32_t qIndex;
614 const char* fontsDirectories;
618
619vkvg_public
629 void
693vkvg_public void vkvg_device_destroy(VkvgDevice dev);
718
726vkvg_public void vkvg_get_required_instance_extensions(const char** pExtensions, uint32_t* pExtCount);
735vkvg_public vkvg_status_t vkvg_get_required_device_extensions(VkPhysicalDevice phy, const char** pExtensions,
736 uint32_t* pExtCount);
744vkvg_public const void* vkvg_get_device_requirements(VkPhysicalDeviceFeatures* pEnabledFeatures);
759vkvg_public VkvgSurface vkvg_surface_create(VkvgDevice dev, uint32_t width, uint32_t height);
768VkvgSurface vkvg_surface_create_ms(VkvgDevice dev, uint32_t width, uint32_t height, VkSampleCountFlags sampleCount);
778vkvg_public VkvgSurface vkvg_surface_create_from_image(VkvgDevice dev, const char* filePath);
795vkvg_public VkvgSurface vkvg_surface_create_from_bitmap(VkvgDevice dev, unsigned char* img, uint32_t width,
796 uint32_t height);
821vkvg_public void vkvg_surface_destroy(VkvgSurface surf);
838vkvg_public void vkvg_surface_clear(VkvgSurface surf);
844vkvg_public VkImage vkvg_surface_get_vk_image(VkvgSurface surf);
850vkvg_public VkFormat vkvg_surface_get_vk_format(VkvgSurface surf);
856vkvg_public uint32_t vkvg_surface_get_width(VkvgSurface surf);
862vkvg_public uint32_t vkvg_surface_get_height(VkvgSurface surf);
871vkvg_public void vkvg_surface_set_dpy(VkvgSurface surf, int hdpy, int vdpy);
881vkvg_public void vkvg_surface_get_dpy(VkvgSurface surf, int* hdpy, int* vdpy);
888vkvg_public vkvg_status_t vkvg_surface_write_to_png(VkvgSurface surf, const char* path);
895vkvg_public vkvg_status_t vkvg_surface_write_to_memory(VkvgSurface surf, unsigned char* const bitmap);
907vkvg_public void vkvg_surface_resolve(VkvgSurface surf);
910// mimic from cairo, to facilitate usage of vkvg as cairo vulkan backend
911
917typedef enum _vkvg_operator {
919
922 /* VKVG_OPERATOR_IN,
923 VKVG_OPERATOR_OUT,
924 VKVG_OPERATOR_ATOP,
925
926 VKVG_OPERATOR_DEST,
927 VKVG_OPERATOR_DEST_OVER,
928 VKVG_OPERATOR_DEST_IN,
929 VKVG_OPERATOR_DEST_OUT,
930 VKVG_OPERATOR_DEST_ATOP,
931
932 VKVG_OPERATOR_XOR,
933 VKVG_OPERATOR_ADD,
934 VKVG_OPERATOR_SATURATE,
935
936 VKVG_OPERATOR_MULTIPLY,
937 VKVG_OPERATOR_SCREEN,
938 VKVG_OPERATOR_OVERLAY,
939 VKVG_OPERATOR_DARKEN,
940 VKVG_OPERATOR_LIGHTEN,
941 VKVG_OPERATOR_COLOR_DODGE,
942 VKVG_OPERATOR_COLOR_BURN,
943 VKVG_OPERATOR_HARD_LIGHT,
944 VKVG_OPERATOR_SOFT_LIGHT,
945 */
947 VKVG_OPERATOR_EXCLUSION,
948 VKVG_OPERATOR_HSL_HUE,
949 VKVG_OPERATOR_HSL_SATURATION,
950 VKVG_OPERATOR_HSL_COLOR,
951 VKVG_OPERATOR_HSL_LUMINOSITY,*/
954
975vkvg_public void vkvg_destroy(VkvgContext ctx);
992vkvg_public const char* vkvg_status_to_string(vkvg_status_t status);
1004vkvg_public uint32_t vkvg_get_reference_count(VkvgContext ctx);
1014vkvg_public void vkvg_flush(VkvgContext ctx);
1023vkvg_public void vkvg_new_path(VkvgContext ctx);
1032vkvg_public void vkvg_close_path(VkvgContext ctx);
1042vkvg_public void vkvg_new_sub_path(VkvgContext ctx);
1051vkvg_public void vkvg_path_extents(VkvgContext ctx, float* const x1, float* const y1, float* const x2, float* const y2);
1060vkvg_public void vkvg_get_current_point(VkvgContext ctx, float* x, float* y);
1071vkvg_public void vkvg_line_to(VkvgContext ctx, float x, float y);
1082vkvg_public void vkvg_rel_line_to(VkvgContext ctx, float dx, float dy);
1095vkvg_public void vkvg_move_to(VkvgContext ctx, float x, float y);
1107vkvg_public void vkvg_rel_move_to(VkvgContext ctx, float x, float y);
1133vkvg_public void vkvg_arc(VkvgContext ctx, float xc, float yc, float radius, float a1, float a2);
1151vkvg_public void vkvg_arc_negative(VkvgContext ctx, float xc, float yc, float radius, float a1, float a2);
1168vkvg_public void vkvg_curve_to(VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3);
1185vkvg_public void vkvg_rel_curve_to(VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3);
1197vkvg_public void vkvg_quadratic_to(VkvgContext ctx, float x1, float y1, float x2, float y2);
1207vkvg_public void vkvg_rel_quadratic_to(VkvgContext ctx, float x1, float y1, float x2, float y2);
1219vkvg_public vkvg_status_t vkvg_rectangle(VkvgContext ctx, float x, float y, float w, float h);
1232vkvg_public vkvg_status_t vkvg_rounded_rectangle(VkvgContext ctx, float x, float y, float w, float h, float radius);
1246vkvg_public void vkvg_rounded_rectangle2(VkvgContext ctx, float x, float y, float w, float h, float rx, float ry);
1247
1260vkvg_public void vkvg_ellipse(VkvgContext ctx, float radiusX, float radiusY, float x, float y, float rotationAngle);
1281vkvg_public void vkvg_elliptic_arc_to(VkvgContext ctx, float x, float y, bool large_arc_flag, bool sweep_flag, float rx,
1282 float ry, float phi);
1297vkvg_public void vkvg_rel_elliptic_arc_to(VkvgContext ctx, float x, float y, bool large_arc_flag, bool sweep_flag,
1298 float rx, float ry, float phi);
1308vkvg_public void vkvg_stroke(VkvgContext ctx);
1316vkvg_public void vkvg_stroke_preserve(VkvgContext ctx);
1325vkvg_public void vkvg_fill(VkvgContext ctx);
1333vkvg_public void vkvg_fill_preserve(VkvgContext ctx);
1342vkvg_public void vkvg_paint(VkvgContext ctx);
1353vkvg_public void vkvg_clear(VkvgContext ctx); // use vkClearAttachment to speed up clearing surf
1361vkvg_public void vkvg_reset_clip(VkvgContext ctx);
1379vkvg_public void vkvg_clip(VkvgContext ctx);
1387vkvg_public void vkvg_clip_preserve(VkvgContext ctx);
1396vkvg_public void vkvg_set_opacity(VkvgContext ctx, float opacity);
1397vkvg_public
1405 float
1412vkvg_public void vkvg_set_source_color(VkvgContext ctx, uint32_t c);
1423vkvg_public void vkvg_set_source_rgba(VkvgContext ctx, float r, float g, float b, float a);
1438vkvg_public void vkvg_set_source_rgb(VkvgContext ctx, float r, float g, float b);
1448vkvg_public void vkvg_set_source_surface(VkvgContext ctx, VkvgSurface surf, float x, float y);
1456vkvg_public void vkvg_set_source(VkvgContext ctx, VkvgPattern pat);
1466vkvg_public void vkvg_set_line_width(VkvgContext ctx, float width);
1483vkvg_public void vkvg_set_miter_limit(VkvgContext ctx, float limit);
1492vkvg_public float vkvg_get_miter_limit(VkvgContext ctx);
1535vkvg_public void vkvg_set_dash(VkvgContext ctx, const float* dashes, uint32_t num_dashes, float offset);
1547vkvg_public void vkvg_get_dash(VkvgContext ctx, const float* dashes, uint32_t* num_dashes, float* offset);
1548
1556vkvg_public float vkvg_get_line_width(VkvgContext ctx);
1599
1618
1627vkvg_public void vkvg_save(VkvgContext ctx);
1636vkvg_public void vkvg_restore(VkvgContext ctx);
1646vkvg_public void vkvg_translate(VkvgContext ctx, float dx, float dy);
1656vkvg_public void vkvg_scale(VkvgContext ctx, float sx, float sy);
1664vkvg_public void vkvg_rotate(VkvgContext ctx, float radians);
1673vkvg_public void vkvg_transform(VkvgContext ctx, const vkvg_matrix_t* matrix);
1682vkvg_public void vkvg_set_matrix(VkvgContext ctx, const vkvg_matrix_t* matrix);
1691vkvg_public void vkvg_get_matrix(VkvgContext ctx, vkvg_matrix_t* const matrix);
1699vkvg_public void vkvg_identity_matrix(VkvgContext ctx);
1700
1707vkvg_public void vkvg_select_font_face(VkvgContext ctx, const char* name);
1715vkvg_public void vkvg_load_font_from_path(VkvgContext ctx, const char* path, uint32_t size);
1724vkvg_public void vkvg_load_font_from_memory(VkvgContext ctx, unsigned char* fontBuffer, long fontBufferByteSize,
1725 const char* name);
1732vkvg_public void vkvg_set_font_size(VkvgContext ctx, uint32_t size);
1745vkvg_public void vkvg_set_font (VkvgContext ctx, VkvgFont font);
1764vkvg_public void vkvg_show_text(VkvgContext ctx, const char* utf8);
1773vkvg_public void vkvg_text_extents(VkvgContext ctx, const char* utf8, vkvg_text_extents_t* extents);
1781vkvg_public void vkvg_font_extents(VkvgContext ctx, vkvg_font_extents_t* extents);
1782
1783//
1792vkvg_public VkvgText vkvg_text_create(VkvgContext ctx, const char* text);
1801vkvg_public VkvgText vkvg_text_create_with_length(VkvgContext ctx, const char* text, uint32_t length);
1807vkvg_public void vkvg_text_destroy(VkvgText textRun);
1814vkvg_public void vkvg_text_render(VkvgContext ctx, VkvgText textRun);
1821vkvg_public void vkvg_text_get_extents(VkvgText textRun, vkvg_text_extents_t* extents);
1827vkvg_public uint32_t vkvg_text_get_glyph_count(VkvgText textRun);
1834vkvg_public vkvg_glyph_info_t vkvg_text_get_glyph_position(VkvgText textRun, uint32_t index);
1892vkvg_public VkvgPattern vkvg_pattern_create_linear(float x0, float y0, float x1, float y1);
1904vkvg_public vkvg_status_t vkvg_pattern_edit_linear(VkvgPattern pat, float x0, float y0, float x1, float y1);
1916vkvg_public vkvg_status_t vkvg_pattern_get_linear_points(VkvgPattern pat, float* x0, float* y0, float* x1, float* y1);
1931vkvg_public VkvgPattern vkvg_pattern_create_radial(float cx0, float cy0, float radius0, float cx1, float cy1,
1932 float radius1);
1947vkvg_public vkvg_status_t vkvg_pattern_edit_radial(VkvgPattern pat, float cx0, float cy0, float radius0, float cx1,
1948 float cy1, float radius1);
1975vkvg_public vkvg_status_t vkvg_pattern_get_color_stop_rgba(VkvgPattern pat, uint32_t index, float* offset, float* r,
1976 float* g, float* b, float* a);
1977
1985vkvg_public void vkvg_pattern_destroy(VkvgPattern pat);
1999vkvg_public vkvg_status_t vkvg_pattern_add_color_stop(VkvgPattern pat, float offset, float r, float g, float b,
2000 float a);
2041vkvg_public void vkvg_pattern_set_matrix(VkvgPattern pat, const vkvg_matrix_t* matrix);
2043
2046/********* EXPERIMENTAL **************/
2047vkvg_public void vkvg_set_source_color_name(VkvgContext ctx, const char* color);
2048
2049#ifdef VKVG_RECORDING
2050typedef struct _vkvg_recording_t* VkvgRecording;
2051
2052vkvg_public void vkvg_start_recording(VkvgContext ctx);
2053vkvg_public VkvgRecording vkvg_stop_recording(VkvgContext ctx);
2054vkvg_public void vkvg_replay(VkvgContext ctx, VkvgRecording rec);
2055vkvg_public void vkvg_replay_command(VkvgContext ctx, VkvgRecording rec, uint32_t cmdIndex);
2056vkvg_public void vkvg_recording_get_command(VkvgRecording rec, uint32_t cmdIndex, uint32_t* cmd, void** dataOffset);
2057vkvg_public uint32_t vkvg_recording_get_count(VkvgRecording rec);
2058vkvg_public void* vkvg_recording_get_data(VkvgRecording rec);
2059vkvg_public void vkvg_recording_destroy(VkvgRecording rec);
2060/*************************************/
2061#endif
2062
2063#ifdef __cplusplus
2064}
2065#endif
2066
2067#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:278
void vkvg_clip(VkvgContext ctx)
Establishes a new clip region.
vkvg_line_join_t vkvg_get_line_join(VkvgContext ctx)
void vkvg_restore(VkvgContext ctx)
Restore context's graphic states.
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.
void vkvg_set_font(VkvgContext ctx, VkvgFont font)
set current font for context, see vkvg_font_create to create fonts.
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
void vkvg_text_render(VkvgContext ctx, VkvgText textRun)
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.
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.
void vkvg_set_line_join(VkvgContext ctx, vkvg_line_join_t join)
set line joins for the next draw command.
VkvgFont vkvg_get_font(VkvgContext ctx)
Get active font for provided context.
VkvgText vkvg_text_create_with_length(VkvgContext ctx, const char *text, uint32_t length)
Create a new text run for a non null terminated string.
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.
uint32_t vkvg_text_get_glyph_count(VkvgText textRun)
Get glyph count of text run.
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_text_get_extents(VkvgText textRun, vkvg_text_extents_t *extents)
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.
void vkvg_get_matrix(VkvgContext ctx, vkvg_matrix_t *const matrix)
Get the current matrix.
VkvgSurface vkvg_get_target(VkvgContext ctx)
Get the current target of the context.
vkvg_glyph_info_t vkvg_text_get_glyph_position(VkvgText textRun, uint32_t index)
Get glyph position at the provided index.
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.
const char * vkvg_status_to_string(vkvg_status_t status)
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_load_font_from_path(VkvgContext ctx, const char *path, uint32_t size)
Select a new font by providing its file path.
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_set_text_direction(VkvgContext ctx, vkvg_direction_t direction)
vkvg_set_text_direction
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.
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_path_extents(VkvgContext ctx, float *const x1, float *const y1, float *const x2, float *const y2)
vkvg_path_extents
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_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)
VkvgContext vkvg_reference(VkvgContext ctx)
Increment by one the reference count on this context.
VkvgText vkvg_text_create(VkvgContext ctx, const char *text)
Create a new text run.
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_text_destroy(VkvgText textRun)
Release resources holded by the text run.
void vkvg_device_destroy(VkvgDevice dev)
Create a new vkvg device from an existing vulkan logical device.
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:297
vkvg_status_t vkvg_device_status(VkvgDevice dev)
Get the current status of the device.
void vkvg_get_required_instance_extensions(const char **pExtensions, uint32_t *pExtCount)
query required instance extensions for vkvg.
void vkvg_device_set_context_cache_size(VkvgDevice dev, uint32_t maxCount)
Set maximum cached context count.
VkvgDevice vkvg_device_create(vkvg_device_create_info_t *info)
Create a new vkvg device.
const void * vkvg_get_device_requirements(VkPhysicalDeviceFeatures *pEnabledFeatures)
get vulkan device creation requirement to fit vkvg needs.
vkvg_status_t vkvg_get_required_device_extensions(VkPhysicalDevice phy, const char **pExtensions, uint32_t *pExtCount)
query required device extensions for vkvg.
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_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_multiply(vkvg_matrix_t *result, const vkvg_matrix_t *const a, const vkvg_matrix_t *const b)
matrices multiplication
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_status(VkvgPattern pat)
Get pattern current status.
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:305
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)
Get 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_set_dpy(VkvgSurface surf, int hdpy, int vdpy)
Set the screen dot per inch for this surface.
VkvgSurface vkvg_surface_create_from_bitmap(VkvgDevice dev, unsigned char *img, uint32_t width, uint32_t height)
Create a new vkvg surface from an in memory rgba bitmap.
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_ms(VkvgDevice dev, uint32_t width, uint32_t height, VkSampleCountFlags sampleCount)
create mulstisample surface
void vkvg_surface_get_dpy(VkvgSurface surf, int *hdpy, int *vdpy)
Get the current dpy values.
VkvgSurface vkvg_surface_create_for_VkhImage(VkvgDevice dev, void *vkhImg)
Create a new vkvg surface using an existing vulkan texture as backend. This method will always return...
struct _vkvg_surface_t * VkvgSurface
Opaque pointer on a Vkvg Surface structure.
Definition vkvg.h:290
uint32_t vkvg_surface_get_reference_count(VkvgSurface surf)
Get the current reference count on this surface.
float r
Definition vkvg.h:218
float a
Definition vkvg.h:221
float b
Definition vkvg.h:220
float g
Definition vkvg.h:219
const char * fontsDirectories
Definition vkvg.h:614
VkSampleCountFlags samples
Definition vkvg.h:606
VkPhysicalDevice phy
Definition vkvg.h:609
vkvg device creation structure
Definition vkvg.h:605
float max_y_advance
Definition vkvg.h:236
float max_x_advance
Definition vkvg.h:234
font metrics
Definition vkvg.h:230
int32_t x_offset
Definition vkvg.h:266
int32_t y_offset
Definition vkvg.h:267
uint32_t codepoint
Definition vkvg.h:269
int32_t y_advance
Definition vkvg.h:265
int32_t x_advance
Definition vkvg.h:264
glyphs position in a VkvgText
Definition vkvg.h:263
float yy
Definition vkvg.h:431
float x0
Definition vkvg.h:432
float xy
Definition vkvg.h:430
float yx
Definition vkvg.h:429
float xx
Definition vkvg.h:428
float y0
Definition vkvg.h:433
vkvg matrix structure
Definition vkvg.h:427
text metrics
Definition vkvg.h:245
vkvg_status_t
vkvg operation status.
Definition vkvg.h:115
@ VKVG_STATUS_PATTERN_INVALID_GRADIENT
Definition vkvg.h:126
@ VKVG_STATUS_INVALID_RECT
Definition vkvg.h:130
@ VKVG_STATUS_INVALID_DEVICE_CREATE_INFO
Definition vkvg.h:133
@ VKVG_STATUS_PATTERN_TYPE_MISMATCH
Definition vkvg.h:125
@ VKVG_STATUS_INVALID_INDEX
Definition vkvg.h:123
@ VKVG_STATUS_NULL_POINTER
Definition vkvg.h:118
@ VKVG_STATUS_DEVICE_ERROR
Definition vkvg.h:132
@ VKVG_STATUS_INVALID_SURFACE
Definition vkvg.h:135
@ VKVG_STATUS_TIMEOUT
Definition vkvg.h:131
@ VKVG_STATUS_INVALID_MATRIX
Definition vkvg.h:121
@ VKVG_STATUS_INVALID_IMAGE
Definition vkvg.h:134
@ VKVG_STATUS_ENUM_MAX
Definition vkvg.h:139
@ VKVG_STATUS_INVALID_FORMAT
Definition vkvg.h:127
@ VKVG_STATUS_INVALID_FONT
Definition vkvg.h:136
@ VKVG_STATUS_WRITE_ERROR
Definition vkvg.h:124
@ VKVG_STATUS_INVALID_DASH
Definition vkvg.h:129
@ VKVG_STATUS_IN_CACHE
Definition vkvg.h:137
@ VKVG_STATUS_INVALID_RESTORE
Definition vkvg.h:119
@ VKVG_STATUS_NO_MEMORY
Definition vkvg.h:117
@ VKVG_STATUS_SUCCESS
Definition vkvg.h:116
@ VKVG_STATUS_FILE_NOT_FOUND
Definition vkvg.h:128
@ VKVG_STATUS_NO_CURRENT_POINT
Definition vkvg.h:120
@ VKVG_STATUS_INVALID_STATUS
Definition vkvg.h:122
vkvg_pattern_type_t
pattern types
Definition vkvg.h:172
@ VKVG_PATTERN_TYPE_LINEAR
Definition vkvg.h:175
@ VKVG_PATTERN_TYPE_SURFACE
Definition vkvg.h:174
@ VKVG_PATTERN_TYPE_MESH
Definition vkvg.h:177
@ VKVG_PATTERN_TYPE_RADIAL
Definition vkvg.h:176
@ VKVG_PATTERN_TYPE_RASTER_SOURCE
Definition vkvg.h:178
@ VKVG_PATTERN_TYPE_SOLID
Definition vkvg.h:173
vkvg_direction_t
Definition vkvg.h:142
@ VKVG_VERTICAL
Definition vkvg.h:142
@ VKVG_HORIZONTAL
Definition vkvg.h:142
void vkvg_font_destroy(VkvgFont font)
Release resources associated with that font. This will release cached glyph entries,...
vkvg_operator_t
compositing operators
Definition vkvg.h:917
@ VKVG_OPERATOR_OVER
Definition vkvg.h:921
@ VKVG_OPERATOR_MAX
Definition vkvg.h:952
@ VKVG_OPERATOR_CLEAR
Definition vkvg.h:918
@ VKVG_OPERATOR_DIFFERENCE
Definition vkvg.h:946
@ VKVG_OPERATOR_SOURCE
Definition vkvg.h:920
struct _vkvg_text_run_t * VkvgText
Opaque pointer on a vkvg text run.
Definition vkvg.h:318
vkvg_line_join_t
lines articulations
Definition vkvg.h:198
@ VKVG_LINE_JOIN_ROUND
Definition vkvg.h:200
@ VKVG_LINE_JOIN_BEVEL
Definition vkvg.h:201
@ VKVG_LINE_JOIN_MITER
Definition vkvg.h:199
vkvg_status_t vkvg_font_status(VkvgFont font)
Query the current status of the font, VKVG_STATUS_SUCCESS means no error.
struct _vkvg_font_t * VkvgFont
Opaque pointer on a vkvg font.
Definition vkvg.h:329
vkvg_fill_rule_t
path fill method.
Definition vkvg.h:212
@ VKVG_FILL_RULE_NON_ZERO
Definition vkvg.h:214
@ VKVG_FILL_RULE_EVEN_ODD
Definition vkvg.h:213
VkvgFont vkvg_font_reference(VkvgFont font)
Increment reference counter of font.
vkvg_extend_t
pattern border policy
Definition vkvg.h:151
@ VKVG_EXTEND_NONE
Definition vkvg.h:152
@ VKVG_EXTEND_PAD
Definition vkvg.h:155
@ VKVG_EXTEND_REPEAT
Definition vkvg.h:153
@ VKVG_EXTEND_REFLECT
Definition vkvg.h:154
void * vkvg_font_get_face(VkvgFont font)
Get underlying font face object pointer, if freetype is enable, the FT_Face will be returned.
uint32_t vkvg_font_get_reference_count(VkvgFont font)
Query current reference count from font.
VkvgFont vkvg_font_create_from_file(VkvgSurface surf, const char *fontFilePath, int faceIndex, float pointSize)
Create a new VkvgFont from the provided font file, face index and size.
uint32_t vkvg_log_level
vkvg_format_t
Definition vkvg.h:144
@ VKVG_FORMAT_A8
Definition vkvg.h:144
@ VKVG_FORMAT_A1
Definition vkvg.h:144
@ VKVG_FORMAT_ARGB32
Definition vkvg.h:144
@ VKVG_FORMAT_RGB24
Definition vkvg.h:144
VkvgFont vkvg_font_create(VkvgSurface surf, const char *queryString, float pointSize)
Create a new VkvgFont at the specified size from the provided query string.
vkvg_filter_t
Definition vkvg.h:158
@ VKVG_FILTER_BEST
Definition vkvg.h:161
@ VKVG_FILTER_FAST
Definition vkvg.h:159
@ VKVG_FILTER_GAUSSIAN
Definition vkvg.h:164
@ VKVG_FILTER_NEAREST
Definition vkvg.h:162
@ VKVG_FILTER_GOOD
Definition vkvg.h:160
@ VKVG_FILTER_BILINEAR
Definition vkvg.h:163
vkvg_line_cap_t
line caps
Definition vkvg.h:187
@ VKVG_LINE_CAP_SQUARE
Definition vkvg.h:190
@ VKVG_LINE_CAP_ROUND
Definition vkvg.h:189
@ VKVG_LINE_CAP_BUTT
Definition vkvg.h:188
void vkvg_set_source_color_name(VkvgContext ctx, const char *color)