From ea7ac1e833787fdba2e4849c35aeb8ded9577a9d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Mon, 7 Sep 2020 15:52:10 +0000 Subject: [PATCH] code clean, add optional dashes config for lines, curves, and rnd rect tests --- src/vkvg_device.c | 35 +---------------------------------- tests/curve.c | 20 ++++++++++++-------- tests/lines.c | 36 ++++++++++++++++++------------------ tests/random_rects.c | 18 +++++++++++++++--- 4 files changed, 46 insertions(+), 63 deletions(-) diff --git a/src/vkvg_device.c b/src/vkvg_device.c index 6f94cf5..e17b81b 100644 --- a/src/vkvg_device.c +++ b/src/vkvg_device.c @@ -24,32 +24,11 @@ #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); @@ -198,24 +177,12 @@ VkvgDevice vkvg_device_reference (VkvgDevice dev) { 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; diff --git a/tests/curve.c b/tests/curve.c index 2a76693..1367b60 100644 --- a/tests/curve.c +++ b/tests/curve.c @@ -111,6 +111,8 @@ void test2() { 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) { @@ -127,15 +129,20 @@ 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