VKVG  
Vulkan Vector Graphics
Loading...
Searching...
No Matches
vkvg.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2025 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#include <stdint.h>
26#include <stddef.h>
27
28#include <vulkan/vulkan.h>
29
30#ifdef __cplusplus
31extern "C" {
32#else
33#include <stdbool.h>
34#endif
35
76#ifndef vkvg_public
77#ifdef VKVG_SHARED_BUILD
78#if (defined(_WIN32) || defined(__CYGWIN__))
79#define vkvg_public __declspec(dllexport)
80#else
81#define vkvg_public __attribute__((visibility("default")))
82#endif
83#elif (defined(VKVG_SHARED_LINKING) && (defined(_WIN32) || defined(__CYGWIN__)))
84#define vkvg_public __declspec(dllimport)
85#else
86#define vkvg_public
87#endif
88#endif
89
90#define VKVG_LOG_ERR 0x00000001
91#define VKVG_LOG_DEBUG 0x00000002
92
93#define VKVG_LOG_INFO_PTS 0x00000004
94#define VKVG_LOG_INFO_PATH 0x00000008
95#define VKVG_LOG_INFO_CMD 0x00000010
96#define VKVG_LOG_INFO_VBO 0x00000020
97#define VKVG_LOG_INFO_IBO 0x00000040
98#define VKVG_LOG_INFO_VAO (VKVG_LOG_INFO_VBO | VKVG_LOG_INFO_IBO)
99#define VKVG_LOG_THREAD 0x00000080
100#define VKVG_LOG_DBG_ARRAYS 0x00001000
101#define VKVG_LOG_STROKE 0x00010000
102#define VKVG_LOG_FULL 0xffffffff
103
104#define VKVG_LOG_INFO 0x00008000 //(VKVG_LOG_INFO_PTS|VKVG_LOG_INFO_PATH|VKVG_LOG_INFO_CMD|VKVG_LOG_INFO_VAO)
105
106#ifdef DEBUG
107vkvg_public extern uint32_t vkvg_log_level;
108#ifdef VKVG_WIRED_DEBUG
109typedef enum {
110 vkvg_wired_debug_mode_normal = 0x01,
111 vkvg_wired_debug_mode_points = 0x02,
112 vkvg_wired_debug_mode_lines = 0x04,
113 vkvg_wired_debug_mode_both = vkvg_wired_debug_mode_points | vkvg_wired_debug_mode_lines,
114 vkvg_wired_debug_mode_all = 0xFFFFFFFF
115} vkvg_wired_debug_mode;
116vkvg_public extern vkvg_wired_debug_mode vkvg_wired_debug;
117#endif
118#endif
119
155
157
171
180
194
217
230
231typedef struct {
232 float r;
233 float g;
234 float b;
235 float a;
237
244typedef struct {
245 float ascent;
246 float descent;
247 float height;
259typedef struct {
260 float x_bearing;
262 float y_bearing;
264 float width;
265 float height;
266 float x_advance;
267 float y_advance;
270
277typedef struct _glyph_info_t {
278 int32_t x_advance;
279 int32_t y_advance;
280 int32_t x_offset;
281 int32_t y_offset;
282 /* private */
283 uint32_t codepoint; // should be named glyphIndex, but for harfbuzz compatibility...
285
298typedef struct _vkvg_text_run_t* VkvgText;
299
306typedef struct _vkvg_context_t* VkvgContext;
318typedef struct _vkvg_surface_t* VkvgSurface;
325typedef struct _vkvg_device_t* VkvgDevice;
333typedef struct _vkvg_pattern_t* VkvgPattern;
334
335#if VKVG_DBG_STATS
341#define VKVG_HAS_DBG_STATS
342typedef struct {
343 uint32_t sizePoints;
344 uint32_t sizePathes;
345 uint32_t sizeVertices;
346 uint32_t sizeIndices;
347 uint32_t sizeVBO;
348 uint32_t sizeIBO;
349} vkvg_debug_stats_t;
350
351vkvg_debug_stats_t vkvg_device_get_stats(VkvgDevice dev);
352void vkvg_device_reset_stats(VkvgDevice dev);
353#endif
354
362#define VKVG_IDENTITY_MATRIX (vkvg_matrix_t){1, 0, 0, 1, 0, 0}
380typedef struct {
381 float xx;
382 float yx;
383 float xy;
384 float yy;
385 float x0;
386 float y0;
394vkvg_public void vkvg_matrix_init_identity(vkvg_matrix_t* matrix);
408vkvg_public void vkvg_matrix_init(vkvg_matrix_t* matrix, float xx, float yx, float xy, float yy, float x0, float y0);
417vkvg_public void vkvg_matrix_init_translate(vkvg_matrix_t* matrix, float tx, float ty);
426vkvg_public void vkvg_matrix_init_scale(vkvg_matrix_t* matrix, float sx, float sy);
438vkvg_public void vkvg_matrix_init_rotate(vkvg_matrix_t* matrix, float radians);
449vkvg_public void vkvg_matrix_translate(vkvg_matrix_t* matrix, float tx, float ty);
460vkvg_public void vkvg_matrix_scale(vkvg_matrix_t* matrix, float sx, float sy);
472vkvg_public void vkvg_matrix_rotate(vkvg_matrix_t* matrix, float radians);
481vkvg_public void vkvg_matrix_multiply(vkvg_matrix_t* result, const vkvg_matrix_t* a, const vkvg_matrix_t* b);
497vkvg_public void vkvg_matrix_transform_distance(const vkvg_matrix_t* matrix, float* dx, float* dy);
506vkvg_public void vkvg_matrix_transform_point(const vkvg_matrix_t* matrix, float* x, float* y);
517vkvg_public void vkvg_matrix_get_scale(const vkvg_matrix_t* matrix, float* sx, float* sy);
558typedef struct {
559 VkSampleCountFlags samples;
561 VkInstance inst;
562 VkPhysicalDevice phy;
563 VkDevice vkdev;
564 uint32_t qFamIdx;
565 uint32_t qIndex;
568
569vkvg_public
579 void
643vkvg_public void vkvg_device_destroy(VkvgDevice dev);
676vkvg_public void vkvg_device_set_dpy(VkvgDevice dev, int hdpy, int vdpy);
686vkvg_public void vkvg_device_get_dpy(VkvgDevice dev, int* hdpy, int* vdpy);
687
695vkvg_public void vkvg_get_required_instance_extensions(const char** pExtensions, uint32_t* pExtCount);
704vkvg_public vkvg_status_t vkvg_get_required_device_extensions(VkPhysicalDevice phy, const char** pExtensions,
705 uint32_t* pExtCount);
713vkvg_public const void* vkvg_get_device_requirements(VkPhysicalDeviceFeatures* pEnabledFeatures);
728vkvg_public VkvgSurface vkvg_surface_create(VkvgDevice dev, uint32_t width, uint32_t height);
738vkvg_public VkvgSurface vkvg_surface_create_from_image(VkvgDevice dev, const char* filePath);
755vkvg_public VkvgSurface vkvg_surface_create_from_bitmap(VkvgDevice dev, unsigned char* img, uint32_t width,
756 uint32_t height);
781vkvg_public void vkvg_surface_destroy(VkvgSurface surf);
798vkvg_public void vkvg_surface_clear(VkvgSurface surf);
804vkvg_public VkImage vkvg_surface_get_vk_image(VkvgSurface surf);
810vkvg_public VkFormat vkvg_surface_get_vk_format(VkvgSurface surf);
816vkvg_public uint32_t vkvg_surface_get_width(VkvgSurface surf);
822vkvg_public uint32_t vkvg_surface_get_height(VkvgSurface surf);
829vkvg_public vkvg_status_t vkvg_surface_write_to_png(VkvgSurface surf, const char* path);
836vkvg_public vkvg_status_t vkvg_surface_write_to_memory(VkvgSurface surf, unsigned char* const bitmap);
848vkvg_public void vkvg_surface_resolve(VkvgSurface surf);
851// mimic from cairo, to facilitate usage of vkvg as cairo vulkan backend
852
858typedef enum _vkvg_operator {
860
863 /* VKVG_OPERATOR_IN,
864 VKVG_OPERATOR_OUT,
865 VKVG_OPERATOR_ATOP,
866
867 VKVG_OPERATOR_DEST,
868 VKVG_OPERATOR_DEST_OVER,
869 VKVG_OPERATOR_DEST_IN,
870 VKVG_OPERATOR_DEST_OUT,
871 VKVG_OPERATOR_DEST_ATOP,
872
873 VKVG_OPERATOR_XOR,
874 VKVG_OPERATOR_ADD,
875 VKVG_OPERATOR_SATURATE,
876
877 VKVG_OPERATOR_MULTIPLY,
878 VKVG_OPERATOR_SCREEN,
879 VKVG_OPERATOR_OVERLAY,
880 VKVG_OPERATOR_DARKEN,
881 VKVG_OPERATOR_LIGHTEN,
882 VKVG_OPERATOR_COLOR_DODGE,
883 VKVG_OPERATOR_COLOR_BURN,
884 VKVG_OPERATOR_HARD_LIGHT,
885 VKVG_OPERATOR_SOFT_LIGHT,
886 */
888 VKVG_OPERATOR_EXCLUSION,
889 VKVG_OPERATOR_HSL_HUE,
890 VKVG_OPERATOR_HSL_SATURATION,
891 VKVG_OPERATOR_HSL_COLOR,
892 VKVG_OPERATOR_HSL_LUMINOSITY,*/
895
916vkvg_public void vkvg_destroy(VkvgContext ctx);
933vkvg_public const char* vkvg_status_to_string(vkvg_status_t status);
945vkvg_public uint32_t vkvg_get_reference_count(VkvgContext ctx);
955vkvg_public void vkvg_flush(VkvgContext ctx);
964vkvg_public void vkvg_new_path(VkvgContext ctx);
973vkvg_public void vkvg_close_path(VkvgContext ctx);
983vkvg_public void vkvg_new_sub_path(VkvgContext ctx);
992vkvg_public void vkvg_path_extents(VkvgContext ctx, float* const x1, float* const y1, float* const x2, float* const y2);
1001vkvg_public void vkvg_get_current_point(VkvgContext ctx, float* x, float* y);
1012vkvg_public void vkvg_line_to(VkvgContext ctx, float x, float y);
1023vkvg_public void vkvg_rel_line_to(VkvgContext ctx, float dx, float dy);
1036vkvg_public void vkvg_move_to(VkvgContext ctx, float x, float y);
1048vkvg_public void vkvg_rel_move_to(VkvgContext ctx, float x, float y);
1074vkvg_public void vkvg_arc(VkvgContext ctx, float xc, float yc, float radius, float a1, float a2);
1092vkvg_public void vkvg_arc_negative(VkvgContext ctx, float xc, float yc, float radius, float a1, float a2);
1109vkvg_public void vkvg_curve_to(VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3);
1126vkvg_public void vkvg_rel_curve_to(VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3);
1138vkvg_public void vkvg_quadratic_to(VkvgContext ctx, float x1, float y1, float x2, float y2);
1148vkvg_public void vkvg_rel_quadratic_to(VkvgContext ctx, float x1, float y1, float x2, float y2);
1160vkvg_public vkvg_status_t vkvg_rectangle(VkvgContext ctx, float x, float y, float w, float h);
1173vkvg_public vkvg_status_t vkvg_rounded_rectangle(VkvgContext ctx, float x, float y, float w, float h, float radius);
1187vkvg_public void vkvg_rounded_rectangle2(VkvgContext ctx, float x, float y, float w, float h, float rx, float ry);
1188
1201vkvg_public void vkvg_ellipse(VkvgContext ctx, float radiusX, float radiusY, float x, float y, float rotationAngle);
1222vkvg_public void vkvg_elliptic_arc_to(VkvgContext ctx, float x, float y, bool large_arc_flag, bool sweep_flag, float rx,
1223 float ry, float phi);
1238vkvg_public void vkvg_rel_elliptic_arc_to(VkvgContext ctx, float x, float y, bool large_arc_flag, bool sweep_flag,
1239 float rx, float ry, float phi);
1249vkvg_public void vkvg_stroke(VkvgContext ctx);
1257vkvg_public void vkvg_stroke_preserve(VkvgContext ctx);
1266vkvg_public void vkvg_fill(VkvgContext ctx);
1274vkvg_public void vkvg_fill_preserve(VkvgContext ctx);
1283vkvg_public void vkvg_paint(VkvgContext ctx);
1294vkvg_public void vkvg_clear(VkvgContext ctx); // use vkClearAttachment to speed up clearing surf
1302vkvg_public void vkvg_reset_clip(VkvgContext ctx);
1320vkvg_public void vkvg_clip(VkvgContext ctx);
1328vkvg_public void vkvg_clip_preserve(VkvgContext ctx);
1337vkvg_public void vkvg_set_opacity(VkvgContext ctx, float opacity);
1338vkvg_public
1346 float
1353vkvg_public void vkvg_set_source_color(VkvgContext ctx, uint32_t c);
1364vkvg_public void vkvg_set_source_rgba(VkvgContext ctx, float r, float g, float b, float a);
1379vkvg_public void vkvg_set_source_rgb(VkvgContext ctx, float r, float g, float b);
1389vkvg_public void vkvg_set_source_surface(VkvgContext ctx, VkvgSurface surf, float x, float y);
1397vkvg_public void vkvg_set_source(VkvgContext ctx, VkvgPattern pat);
1407vkvg_public void vkvg_set_line_width(VkvgContext ctx, float width);
1424vkvg_public void vkvg_set_miter_limit(VkvgContext ctx, float limit);
1433vkvg_public float vkvg_get_miter_limit(VkvgContext ctx);
1476vkvg_public void vkvg_set_dash(VkvgContext ctx, const float* dashes, uint32_t num_dashes, float offset);
1488vkvg_public void vkvg_get_dash(VkvgContext ctx, const float* dashes, uint32_t* num_dashes, float* offset);
1489
1497vkvg_public float vkvg_get_line_width(VkvgContext ctx);
1540
1559
1568vkvg_public void vkvg_save(VkvgContext ctx);
1577vkvg_public void vkvg_restore(VkvgContext ctx);
1587vkvg_public void vkvg_translate(VkvgContext ctx, float dx, float dy);
1597vkvg_public void vkvg_scale(VkvgContext ctx, float sx, float sy);
1605vkvg_public void vkvg_rotate(VkvgContext ctx, float radians);
1614vkvg_public void vkvg_transform(VkvgContext ctx, const vkvg_matrix_t* matrix);
1623vkvg_public void vkvg_set_matrix(VkvgContext ctx, const vkvg_matrix_t* matrix);
1632vkvg_public void vkvg_get_matrix(VkvgContext ctx, vkvg_matrix_t* const matrix);
1640vkvg_public void vkvg_identity_matrix(VkvgContext ctx);
1641
1648vkvg_public void vkvg_select_font_face(VkvgContext ctx, const char* name);
1656vkvg_public void vkvg_load_font_from_path(VkvgContext ctx, const char* path, const char* name);
1665vkvg_public void vkvg_load_font_from_memory(VkvgContext ctx, unsigned char* fontBuffer, long fontBufferByteSize,
1666 const char* name);
1673vkvg_public void vkvg_set_font_size(VkvgContext ctx, uint32_t size);
1683vkvg_public void vkvg_show_text(VkvgContext ctx, const char* utf8);
1691vkvg_public void vkvg_text_extents(VkvgContext ctx, const char* utf8, vkvg_text_extents_t* extents);
1698vkvg_public void vkvg_font_extents(VkvgContext ctx, vkvg_font_extents_t* extents);
1699
1700// text run holds harfbuz datas, and prevent recreating them multiple times for the same line of text.
1708vkvg_public VkvgText vkvg_text_run_create(VkvgContext ctx, const char* text);
1717vkvg_public VkvgText vkvg_text_run_create_with_length(VkvgContext ctx, const char* text, uint32_t length);
1723vkvg_public void vkvg_text_run_destroy(VkvgText textRun);
1730vkvg_public void vkvg_show_text_run(VkvgContext ctx, VkvgText textRun);
1737vkvg_public void vkvg_text_run_get_extents(VkvgText textRun, vkvg_text_extents_t* extents);
1743vkvg_public uint32_t vkvg_text_run_get_glyph_count(VkvgText textRun);
1748vkvg_public void vkvg_text_run_get_glyph_position(VkvgText textRun, uint32_t index, vkvg_glyph_info_t* pGlyphInfo);
1806vkvg_public VkvgPattern vkvg_pattern_create_linear(float x0, float y0, float x1, float y1);
1818vkvg_public vkvg_status_t vkvg_pattern_edit_linear(VkvgPattern pat, float x0, float y0, float x1, float y1);
1830vkvg_public vkvg_status_t vkvg_pattern_get_linear_points(VkvgPattern pat, float* x0, float* y0, float* x1, float* y1);
1845vkvg_public VkvgPattern vkvg_pattern_create_radial(float cx0, float cy0, float radius0, float cx1, float cy1,
1846 float radius1);
1861vkvg_public vkvg_status_t vkvg_pattern_edit_radial(VkvgPattern pat, float cx0, float cy0, float radius0, float cx1,
1862 float cy1, float radius1);
1889vkvg_public vkvg_status_t vkvg_pattern_get_color_stop_rgba(VkvgPattern pat, uint32_t index, float* offset, float* r,
1890 float* g, float* b, float* a);
1891
1899vkvg_public void vkvg_pattern_destroy(VkvgPattern pat);
1913vkvg_public vkvg_status_t vkvg_pattern_add_color_stop(VkvgPattern pat, float offset, float r, float g, float b,
1914 float a);
1955vkvg_public void vkvg_pattern_set_matrix(VkvgPattern pat, const vkvg_matrix_t* matrix);
1957
1960/********* EXPERIMENTAL **************/
1961vkvg_public void vkvg_set_source_color_name(VkvgContext ctx, const char* color);
1962
1963#ifdef VKVG_RECORDING
1964typedef struct _vkvg_recording_t* VkvgRecording;
1965
1966vkvg_public void vkvg_start_recording(VkvgContext ctx);
1967vkvg_public VkvgRecording vkvg_stop_recording(VkvgContext ctx);
1968vkvg_public void vkvg_replay(VkvgContext ctx, VkvgRecording rec);
1969vkvg_public void vkvg_replay_command(VkvgContext ctx, VkvgRecording rec, uint32_t cmdIndex);
1970vkvg_public void vkvg_recording_get_command(VkvgRecording rec, uint32_t cmdIndex, uint32_t* cmd, void** dataOffset);
1971vkvg_public uint32_t vkvg_recording_get_count(VkvgRecording rec);
1972vkvg_public void* vkvg_recording_get_data(VkvgRecording rec);
1973vkvg_public void vkvg_recording_destroy(VkvgRecording rec);
1974/*************************************/
1975#endif
1976
1977#ifdef __cplusplus
1978}
1979#endif
1980
1981#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:306
void vkvg_clip(VkvgContext ctx)
Establishes a new clip region.
vkvg_line_join_t vkvg_get_line_join(VkvgContext ctx)
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 resources 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.
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_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.
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.
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_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_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_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_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:325
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.
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_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_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:333
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.
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_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:318
uint32_t vkvg_surface_get_reference_count(VkvgSurface surf)
Get the current reference count on this surface.
float r
Definition vkvg.h:232
float a
Definition vkvg.h:235
float b
Definition vkvg.h:234
float g
Definition vkvg.h:233
VkSampleCountFlags samples
Definition vkvg.h:559
VkPhysicalDevice phy
Definition vkvg.h:562
vkvg device creation structure
Definition vkvg.h:558
float max_y_advance
Definition vkvg.h:250
float max_x_advance
Definition vkvg.h:248
font metrics
Definition vkvg.h:244
int32_t x_offset
Definition vkvg.h:280
int32_t y_offset
Definition vkvg.h:281
uint32_t codepoint
Definition vkvg.h:283
int32_t y_advance
Definition vkvg.h:279
int32_t x_advance
Definition vkvg.h:278
glyphs position in a VkvgText
Definition vkvg.h:277
float yy
Definition vkvg.h:384
float x0
Definition vkvg.h:385
float xy
Definition vkvg.h:383
float yx
Definition vkvg.h:382
float xx
Definition vkvg.h:381
float y0
Definition vkvg.h:386
vkvg matrix structure
Definition vkvg.h:380
text metrics
Definition vkvg.h:259
vkvg_status_t
vkvg operation status.
Definition vkvg.h:129
@ VKVG_STATUS_PATTERN_INVALID_GRADIENT
Definition vkvg.h:140
@ VKVG_STATUS_INVALID_RECT
Definition vkvg.h:144
@ VKVG_STATUS_INVALID_DEVICE_CREATE_INFO
Definition vkvg.h:147
@ VKVG_STATUS_PATTERN_TYPE_MISMATCH
Definition vkvg.h:139
@ VKVG_STATUS_INVALID_INDEX
Definition vkvg.h:137
@ VKVG_STATUS_NULL_POINTER
Definition vkvg.h:132
@ VKVG_STATUS_DEVICE_ERROR
Definition vkvg.h:146
@ VKVG_STATUS_INVALID_SURFACE
Definition vkvg.h:149
@ VKVG_STATUS_TIMEOUT
Definition vkvg.h:145
@ VKVG_STATUS_INVALID_MATRIX
Definition vkvg.h:135
@ VKVG_STATUS_INVALID_IMAGE
Definition vkvg.h:148
@ VKVG_STATUS_ENUM_MAX
Definition vkvg.h:153
@ VKVG_STATUS_INVALID_FORMAT
Definition vkvg.h:141
@ VKVG_STATUS_INVALID_FONT
Definition vkvg.h:150
@ VKVG_STATUS_WRITE_ERROR
Definition vkvg.h:138
@ VKVG_STATUS_INVALID_DASH
Definition vkvg.h:143
@ VKVG_STATUS_IN_CACHE
Definition vkvg.h:151
@ VKVG_STATUS_INVALID_RESTORE
Definition vkvg.h:133
@ VKVG_STATUS_NO_MEMORY
Definition vkvg.h:131
@ VKVG_STATUS_SUCCESS
Definition vkvg.h:130
@ VKVG_STATUS_FILE_NOT_FOUND
Definition vkvg.h:142
@ VKVG_STATUS_NO_CURRENT_POINT
Definition vkvg.h:134
@ VKVG_STATUS_INVALID_STATUS
Definition vkvg.h:136
vkvg_pattern_type_t
pattern types
Definition vkvg.h:186
@ VKVG_PATTERN_TYPE_LINEAR
Definition vkvg.h:189
@ VKVG_PATTERN_TYPE_SURFACE
Definition vkvg.h:188
@ VKVG_PATTERN_TYPE_MESH
Definition vkvg.h:191
@ VKVG_PATTERN_TYPE_RADIAL
Definition vkvg.h:190
@ VKVG_PATTERN_TYPE_RASTER_SOURCE
Definition vkvg.h:192
@ VKVG_PATTERN_TYPE_SOLID
Definition vkvg.h:187
vkvg_direction_t
Definition vkvg.h:156
@ VKVG_VERTICAL
Definition vkvg.h:156
@ VKVG_HORIZONTAL
Definition vkvg.h:156
vkvg_operator_t
compositing operators
Definition vkvg.h:858
@ VKVG_OPERATOR_OVER
Definition vkvg.h:862
@ VKVG_OPERATOR_MAX
Definition vkvg.h:893
@ VKVG_OPERATOR_CLEAR
Definition vkvg.h:859
@ VKVG_OPERATOR_DIFFERENCE
Definition vkvg.h:887
@ VKVG_OPERATOR_SOURCE
Definition vkvg.h:861
struct _vkvg_text_run_t * VkvgText
Opaque pointer on a vkvg text run.
Definition vkvg.h:298
vkvg_line_join_t
lines articulations
Definition vkvg.h:212
@ VKVG_LINE_JOIN_ROUND
Definition vkvg.h:214
@ VKVG_LINE_JOIN_BEVEL
Definition vkvg.h:215
@ VKVG_LINE_JOIN_MITER
Definition vkvg.h:213
vkvg_fill_rule_t
path fill method.
Definition vkvg.h:226
@ VKVG_FILL_RULE_NON_ZERO
Definition vkvg.h:228
@ VKVG_FILL_RULE_EVEN_ODD
Definition vkvg.h:227
vkvg_extend_t
pattern border policy
Definition vkvg.h:165
@ VKVG_EXTEND_NONE
Definition vkvg.h:166
@ VKVG_EXTEND_PAD
Definition vkvg.h:169
@ VKVG_EXTEND_REPEAT
Definition vkvg.h:167
@ VKVG_EXTEND_REFLECT
Definition vkvg.h:168
vkvg_format_t
Definition vkvg.h:158
@ VKVG_FORMAT_A8
Definition vkvg.h:158
@ VKVG_FORMAT_A1
Definition vkvg.h:158
@ VKVG_FORMAT_ARGB32
Definition vkvg.h:158
@ VKVG_FORMAT_RGB24
Definition vkvg.h:158
vkvg_filter_t
Definition vkvg.h:172
@ VKVG_FILTER_BEST
Definition vkvg.h:175
@ VKVG_FILTER_FAST
Definition vkvg.h:173
@ VKVG_FILTER_GAUSSIAN
Definition vkvg.h:178
@ VKVG_FILTER_NEAREST
Definition vkvg.h:176
@ VKVG_FILTER_GOOD
Definition vkvg.h:174
@ VKVG_FILTER_BILINEAR
Definition vkvg.h:177
vkvg_line_cap_t
line caps
Definition vkvg.h:201
@ VKVG_LINE_CAP_SQUARE
Definition vkvg.h:204
@ VKVG_LINE_CAP_ROUND
Definition vkvg.h:203
@ VKVG_LINE_CAP_BUTT
Definition vkvg.h:202
void vkvg_set_source_color_name(VkvgContext ctx, const char *color)