#include "vkh_queue.h"
#include "vkh_phyinfo.h"
#include "vk_mem_alloc.h"
-/**
- * @brief Create VkvgDevice with default multisampling configuration
- * @param Vulkan instance, usefull to retrieve function pointers
- * @param Vulkan physical device
- * @param Vulkan Device
- * @param Queue familly index
- * @param Queue index in selected familly
- * @return
- */
+
VkvgDevice vkvg_device_create(VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex)
{
return vkvg_device_create_multisample (inst,phy,vkdev,qFamIdx,qIndex, VK_SAMPLE_COUNT_1_BIT, false);
}
-/**
- * @brief Create VkvgDevice with default multisampling configuration
- * @param Vulkan instance, usefull to retrieve function pointers
- * @param Vulkan physical device
- * @param Vulkan Device
- * @param Queue familly index
- * @param Queue index in selected familly
- * @param multisample count
- * @param When set to false, surface is resolve after each renderpasses on resolve attachment of surface.
- * If set to true, multisample surface image is resolve with vkvg_multisample_surface_resolve. This function
- * is called automatically when surface's VkImage is querried with vkvg_surface_get_vk_image.
- * @return
- */
VkvgDevice vkvg_device_create_multisample(VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex, VkSampleCountFlags samples, bool deferredResolve)
{
LOG(VKVG_LOG_INFO, "CREATE Device: qFam = %d; qIdx = %d\n", qFamIdx, qIndex);
uint32_t vkvg_device_get_reference_count (VkvgDevice dev) {
return dev->references;
}
-/**
- * @brief set horizontal and vertical resolution of device in dot per inch
- * @param vkvg device pointer
- * @param horizontal device resolution in dot per inch
- * @param vertical device resolution in dot per inch
- */
void vkvg_device_set_dpy (VkvgDevice dev, int hdpy, int vdpy) {
dev->hdpi = hdpy;
dev->vdpi = vdpy;
//TODO: reset font cache
}
-/**
- * @brief get horizontal and vertical resolution of device in dot per inch
- * @param vkvg device pointer
- * @param return horizontal device resolution in dot per inch
- * @param return vertical device resolution in dot per inch
- */
void vkvg_device_get_dpy (VkvgDevice dev, int* hdpy, int* vdpy) {
*hdpy = dev->hdpi;
*vdpy = dev->vdpi;
static float line_width = 1.f;
static vkvg_line_cap_t line_cap = VKVG_LINE_CAP_ROUND;
static vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_NON_ZERO;
+static float dashes[] = {30.0f, 10.0f};
+static uint32_t dashes_count = 0;
static bool fillAndStroke = true;
void _rnd_curve (VkvgContext ctx) {
vkvg_curve_to(ctx, cp_x1, cp_y1, cp_x2, cp_y2, x2, y2);
}
+VkvgContext _initCtx() {
+ VkvgContext ctx = vkvg_create(surf);
+ vkvg_clear(ctx);
+ vkvg_set_line_width (ctx,line_width);
+ vkvg_set_line_cap(ctx, line_cap);
+ vkvg_set_dash (ctx, dashes, dashes_count, 0);
+ return ctx;
+}
void random_curves () {
float w = (float)test_width;
float h = (float)test_height;
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_line_width (ctx,line_width);
- vkvg_set_line_cap(ctx, line_cap);
+ VkvgContext ctx = _initCtx();
for (uint32_t i=0; i<test_size; i++) {
randomize_color(ctx);
float w = (float)test_width;
float h = (float)test_height;
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_line_width (ctx,line_width);
- vkvg_set_line_cap(ctx, line_cap);
+ VkvgContext ctx = _initCtx();
vkvg_set_fill_rule(ctx, fill_rule);
randomize_color(ctx);
#include "test.h"
-static float line_width = 4.f;
-static vkvg_line_cap_t line_cap = VKVG_LINE_CAP_BUTT;
-
-void horizontal() {
- float w = (float)test_width;
- float h = (float)test_height;
+static float line_width = 1.f;
+static vkvg_line_cap_t line_cap = VKVG_LINE_CAP_ROUND;
+static float dashes[] = {1.0f, 5.0f};
+static uint32_t dashes_count = 0;
+VkvgContext _initCtx() {
VkvgContext ctx = vkvg_create(surf);
vkvg_clear(ctx);
vkvg_set_line_width (ctx,line_width);
vkvg_set_line_cap(ctx, line_cap);
+ vkvg_set_dash (ctx, dashes, dashes_count, 0);
+ return ctx;
+}
+
+void horizontal() {
+ float w = (float)test_width;
+ float h = (float)test_height;
+
+ VkvgContext ctx = _initCtx();
for (uint32_t i=0; i<test_size; i++) {
randomize_color(ctx);
float w = (float)test_width;
float h = (float)test_height;
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_line_width (ctx,line_width);
+ VkvgContext ctx = _initCtx();
for (uint32_t i=0; i<test_size; i++) {
randomize_color(ctx);
float w = (float)test_width;
float h = (float)test_height;
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_line_width (ctx,line_width);
+ VkvgContext ctx = _initCtx();
for (uint32_t i=0; i<test_size; i++) {
randomize_color(ctx);
float w = (float)test_width;
float h = (float)test_height;
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_line_width (ctx,line_width);
+ VkvgContext ctx = _initCtx();
randomize_color(ctx);
float w = (float)test_width-10;
float h = (float)test_height-10;
- VkvgContext ctx = vkvg_create(surf);
- vkvg_clear(ctx);
- vkvg_set_line_width (ctx,line_width);
+ VkvgContext ctx = _initCtx();
randomize_color(ctx);
float x1 = w*rand()/RAND_MAX;
vkvg_rectangle(ctx, x, y, z, v);
}*/
-static vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_NON_ZERO;
-static float line_width = 5.f;
-static float shape_size = 0.1f;
+static vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_EVEN_ODD;
+static vkvg_line_cap_t line_cap = VKVG_LINE_CAP_BUTT;
+static vkvg_line_join_t line_join = VKVG_LINE_JOIN_MITER;
+static float line_width = 1.f;
+static float shape_size = 0.2f;
+static float dashes[] = {3.0f, 10.0f};
+static uint32_t dashes_count = 0;
+
void _shape_fill(shape_t shape){
VkvgContext ctx = vkvg_create(surf);
VkvgContext ctx = vkvg_create(surf);
vkvg_clear(ctx);
vkvg_set_line_width (ctx, line_width);
+ vkvg_set_line_cap(ctx, line_cap);
+ vkvg_set_line_join (ctx, line_join);
+ vkvg_set_dash (ctx, dashes, dashes_count, 0);
vkvg_set_fill_rule(ctx, fill_rule);
for (uint32_t i=0; i<test_size; i++) {
draw_random_shape(ctx, shape, shape_size);
VkvgContext ctx = vkvg_create(surf);
vkvg_clear(ctx);
vkvg_set_line_width (ctx, line_width);
+ vkvg_set_line_cap(ctx, line_cap);
+ vkvg_set_line_join (ctx, line_join);
+
+ vkvg_set_dash (ctx, dashes, dashes_count, 0);
vkvg_set_fill_rule(ctx, fill_rule);
for (uint32_t i=0; i<test_size; i++) {
draw_random_shape(ctx, shape, shape_size);