From: Jean-Philippe Bruyère Date: Thu, 2 May 2019 00:38:36 +0000 (+0200) Subject: add subPath parameter, but nsvg doesn't handle g elements X-Git-Tag: v0.1-alpha~80 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=c0f5ad2b424de831b41ba10d779197d7f11320d7;p=jp%2Fvkvg.git add subPath parameter, but nsvg doesn't handle g elements --- diff --git a/include/vkvg.h b/include/vkvg.h index 4c84195..78f0202 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -199,7 +199,7 @@ NSVGimage* nsvg_load_file (VkvgDevice dev, const char* filePath); NSVGimage* nsvg_load (VkvgDevice dev, char* fragment); void nsvg_destroy (NSVGimage* svg); void nsvg_get_size (NSVGimage* svg, int* width, int* height); -void vkvg_render_svg (VkvgContext ctx, NSVGimage* svg); +void vkvg_render_svg (VkvgContext ctx, NSVGimage* svg, char* subId); //mimic from cairo, to facilitate usage of vkvg as cairo vulkan backend diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 5f06996..09da706 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -871,7 +871,7 @@ void vkvg_get_matrix (VkvgContext ctx, const vkvg_matrix_t* matrix){ memcpy (matrix, &ctx->pushConsts.mat, sizeof(vkvg_matrix_t)); } -void vkvg_render_svg (VkvgContext ctx, NSVGimage* svg){ +void vkvg_render_svg (VkvgContext ctx, NSVGimage* svg, char *subId){ NSVGshape* shape; NSVGpath* path; @@ -880,6 +880,10 @@ void vkvg_render_svg (VkvgContext ctx, NSVGimage* svg){ vkvg_set_source_rgba(ctx,0.0,0.0,0.0,1); for (shape = svg->shapes; shape != NULL; shape = shape->next) { + /*if (subId != NULL) { + if (strcmp(shape->id, subId)!=0) + continue; + }*/ vkvg_new_path(ctx); diff --git a/src/vkvg_surface.c b/src/vkvg_surface.c index d0d0b94..149fe0a 100644 --- a/src/vkvg_surface.c +++ b/src/vkvg_surface.c @@ -343,7 +343,7 @@ VkvgSurface _svg_load (VkvgDevice dev, NSVGimage* svg) { _init_surface (surf); VkvgContext ctx = vkvg_create(surf); - vkvg_render_svg(ctx, svg); + vkvg_render_svg(ctx, svg, NULL); vkvg_destroy(ctx); nsvgDelete(svg); diff --git a/tests/svg.c b/tests/svg.c index 5e1881e..348bde4 100644 --- a/tests/svg.c +++ b/tests/svg.c @@ -13,7 +13,7 @@ void _svg_set_color (VkvgContext ctx, uint32_t c, float alpha) { } static float rotation = 0.f; -//static const char* path = "/mnt/devel/crow-drm/Images/Icons/minimize.svg"; +//static const char* path = "/mnt/devel/crow-drm/Images/Icons/expandable.svg"; static const char* path = "data/tiger.svg"; void test_svg_surface() { @@ -34,8 +34,9 @@ void test_svg_surface() { void test_nsvg() { NSVGimage* svg = nsvg_load_file(device, path); VkvgContext ctx = vkvg_create(surf); - vkvg_scale(ctx,0.04f,0.04f); - vkvg_render_svg(ctx, svg); + vkvg_scale(ctx,0.4f,0.4f); + vkvg_translate(ctx,100,100); + vkvg_render_svg(ctx, svg, NULL); vkvg_destroy(ctx); nsvg_destroy(svg); }