28#include <vulkan/vulkan.h>
77#ifdef VKVG_SHARED_BUILD
78#if (defined(_WIN32) || defined(__CYGWIN__))
79#define vkvg_public __declspec(dllexport)
81#define vkvg_public __attribute__((visibility("default")))
83#elif (defined(VKVG_SHARED_LINKING) && (defined(_WIN32) || defined(__CYGWIN__)))
84#define vkvg_public __declspec(dllimport)
90#define VKVG_LOG_ERR 0x00000001
91#define VKVG_LOG_DEBUG 0x00000002
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
104#define VKVG_LOG_INFO 0x00008000
107vkvg_public
extern uint32_t vkvg_log_level;
108#ifdef VKVG_WIRED_DEBUG
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;
277typedef struct _glyph_info_t {
341#define VKVG_HAS_DBG_STATS
345 uint32_t sizeVertices;
346 uint32_t sizeIndices;
351vkvg_debug_stats_t vkvg_device_get_stats(
VkvgDevice dev);
362#define VKVG_IDENTITY_MATRIX (vkvg_matrix_t){1, 0, 0, 1, 0, 0}
705 uint32_t* pExtCount);
858typedef enum _vkvg_operator {
1223 float ry,
float phi);
1239 float rx,
float ry,
float phi);
1862 float cy1,
float radius1);
1890 float* g,
float* b,
float* a);
1963#ifdef VKVG_RECORDING
1964typedef struct _vkvg_recording_t* VkvgRecording;
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);
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.
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.
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.
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.
uint32_t vkvg_surface_get_reference_count(VkvgSurface surf)
Get the current reference count on this surface.
VkSampleCountFlags samples
vkvg device creation structure
glyphs position in a VkvgText
vkvg_status_t
vkvg operation status.
@ VKVG_STATUS_PATTERN_INVALID_GRADIENT
@ VKVG_STATUS_INVALID_RECT
@ VKVG_STATUS_INVALID_DEVICE_CREATE_INFO
@ VKVG_STATUS_PATTERN_TYPE_MISMATCH
@ VKVG_STATUS_INVALID_INDEX
@ VKVG_STATUS_NULL_POINTER
@ VKVG_STATUS_DEVICE_ERROR
@ VKVG_STATUS_INVALID_SURFACE
@ VKVG_STATUS_INVALID_MATRIX
@ VKVG_STATUS_INVALID_IMAGE
@ VKVG_STATUS_INVALID_FORMAT
@ VKVG_STATUS_INVALID_FONT
@ VKVG_STATUS_WRITE_ERROR
@ VKVG_STATUS_INVALID_DASH
@ VKVG_STATUS_INVALID_RESTORE
@ VKVG_STATUS_FILE_NOT_FOUND
@ VKVG_STATUS_NO_CURRENT_POINT
@ VKVG_STATUS_INVALID_STATUS
vkvg_pattern_type_t
pattern types
@ VKVG_PATTERN_TYPE_LINEAR
@ VKVG_PATTERN_TYPE_SURFACE
@ VKVG_PATTERN_TYPE_RADIAL
@ VKVG_PATTERN_TYPE_RASTER_SOURCE
@ VKVG_PATTERN_TYPE_SOLID
vkvg_operator_t
compositing operators
@ VKVG_OPERATOR_DIFFERENCE
struct _vkvg_text_run_t * VkvgText
Opaque pointer on a vkvg text run.
vkvg_line_join_t
lines articulations
vkvg_fill_rule_t
path fill method.
@ VKVG_FILL_RULE_NON_ZERO
@ VKVG_FILL_RULE_EVEN_ODD
vkvg_extend_t
pattern border policy
void vkvg_set_source_color_name(VkvgContext ctx, const char *color)