diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2022-04-22 21:16:47 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2022-04-22 21:16:47 +0200 |
| commit | 0405dad351c9f9358f176a4cff00fb766b72c949 (patch) | |
| tree | 4f58e503d6a2fca3a79b6880d48ffcaae66ff40a | |
| parent | d80262e20ab307357585407c102509b3776097d4 (diff) | |
| parent | 96107ef47246b9dcd38d803bd0e02b5b1dd29f7e (diff) | |
Merge branch 'master' into timelineSemaphore
| -rw-r--r-- | CMakeLists.txt | 1 | ||||
| m--------- | external/vkvg-svg | 0 | ||||
| -rw-r--r-- | src/vkvg_context.c | 13 | ||||
| -rw-r--r-- | src/vkvg_context_internal.c | 6 | ||||
| -rw-r--r-- | tests/vkvg-svg/svg-viewer.c | 17 |
5 files changed, 23 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 346cc4a..624311f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.16) SET(LANG "CXX") SET(CMAKE_C_STANDARD 11) SET(CMAKE_CXX_STANDARD 11) +SET(CMAKE_C_EXTENSIONS OFF) OPTION (VKVG_BUILD_SHARED_LIB "Build using shared libraries" ON) diff --git a/external/vkvg-svg b/external/vkvg-svg -Subproject 441009b65b2e1e18b403463e9ebba17302fbefa +Subproject d9cfafb0986819c022f47d2670e63e9cdc22541 diff --git a/src/vkvg_context.c b/src/vkvg_context.c index d3234b3..0078598 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -229,6 +229,7 @@ void vkvg_flush (VkvgContext ctx){ void _clear_context (VkvgContext ctx) { //free saved context stack elmt vkvg_context_save_t* next = ctx->pSavedCtxs; + ctx->pSavedCtxs = NULL; while (next != NULL) { vkvg_context_save_t* cur = next; next = cur->pNext; @@ -258,8 +259,10 @@ void _clear_context (VkvgContext ctx) { ctx->pPrev->pNext = ctx->pNext; ctx->pNext->pPrev = ctx->pPrev; }*/ - if (ctx->dashCount > 0) + if (ctx->dashCount > 0) { free(ctx->dashes); + ctx->dashCount = 0; + } } void vkvg_destroy (VkvgContext ctx) @@ -671,13 +674,13 @@ vkvg_status_t vkvg_rounded_rectangle (VkvgContext ctx, float x, float y, float w radius = fmin (w / 2.0f, h / 2.0f); vkvg_move_to(ctx, x, y + radius); - vkvg_arc(ctx, x + radius, y + radius, radius, (float)M_PI, (float)-M_PI_2); + vkvg_arc(ctx, x + radius, y + radius, radius, M_PIF, -M_PIF_2); vkvg_line_to(ctx, x + w - radius, y); - vkvg_arc(ctx, x + w - radius, y + radius, radius, (float)-M_PI_2, 0); + vkvg_arc(ctx, x + w - radius, y + radius, radius, -M_PIF_2, 0); vkvg_line_to(ctx, x + w, y + h - radius); - vkvg_arc(ctx, x + w - radius, y + h - radius, radius, 0, (float)M_PI_2); + vkvg_arc(ctx, x + w - radius, y + h - radius, radius, 0, M_PIF_2); vkvg_line_to(ctx, x + radius, y + h); - vkvg_arc(ctx, x + radius, y + h - radius, radius, (float)M_PI_2, (float)M_PI); + vkvg_arc(ctx, x + radius, y + h - radius, radius, M_PIF_2, M_PIF); vkvg_line_to(ctx, x, y + radius); vkvg_close_path(ctx); diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index 867c987..bf8078c 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -250,8 +250,8 @@ float _get_arc_step (VkvgContext ctx, float radius) { vkvg_matrix_get_scale (&ctx->pushConsts.mat, &sx, &sy); float r = radius * fabsf(fmaxf(sx,sy)); if (r < 30.0f) - return fminf(M_PI / 3.f, M_PI / r); - return fminf(M_PI / 3.f,M_PI / (r * 0.4f)); + return fminf(M_PIF / 3.f, M_PIF / r); + return fminf(M_PIF / 3.f,M_PIF / (r * 0.4f)); } void _create_gradient_buff (VkvgContext ctx){ vkvg_buffer_create (ctx->dev, @@ -1583,7 +1583,7 @@ void _elliptic_arc (VkvgContext ctx, float x1, float y1, float x2, float y2, boo double theta = sa; double ea = sa + delta_theta; - float step = fmaxf(0.001f, fminf(M_PI, _get_arc_step(ctx, fminf (rx, ry))*0.1f)); + float step = fmaxf(0.001f, fminf(M_PIF, _get_arc_step(ctx, fminf (rx, ry))*0.1f)); p = (vec2) { rx * cosf (theta), diff --git a/tests/vkvg-svg/svg-viewer.c b/tests/vkvg-svg/svg-viewer.c index b44415d..c39617e 100644 --- a/tests/vkvg-svg/svg-viewer.c +++ b/tests/vkvg-svg/svg-viewer.c @@ -1,3 +1,7 @@ +#include "vkvg.h" +#include "vkvg-svg.h" +#include "vkengine.h" + #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> @@ -9,10 +13,6 @@ #include <stdarg.h> #include <ctype.h> -#include "vkvg.h" -#include "vkvg-svg.h" -#include "vkengine.h" - static VkvgDevice dev; static VkvgSurface svgSurf = NULL; static double scale = 1; @@ -38,6 +38,11 @@ struct stat file_stat; static int svg_file_count; static float maxScroll; +/* not defined in c11, ok to define here only for sample */ +#ifndef DT_DIR + # define DT_DIR 4 +#endif + int _count_svg_files () { struct dirent *de; rewinddir (pCurrentDir); @@ -101,7 +106,7 @@ void readSVG (VkEngine e) { printf ("Unable to stat file: %s\n", filename); exit(EXIT_FAILURE); } - if (sb.st_mtim.tv_sec == file_stat.st_mtim.tv_sec) + if (sb.st_mtime == file_stat.st_mtime) return; file_stat = sb; newSvgSurf = vkvg_surface_create_from_svg(dev, width, height, filename); @@ -113,7 +118,7 @@ void readSVG (VkEngine e) { printf ("Unable to stat file: %s\n", tmp); exit(EXIT_FAILURE); } - if (sb.st_mtim.tv_sec == file_stat.st_mtim.tv_sec) + if (sb.st_mtime == file_stat.st_mtime) return; file_stat = sb; newSvgSurf = vkvg_surface_create_from_svg(dev, width, height, tmp); |