]> O.S.I.I.S - jp/vkvg.git/commitdiff
add subPath parameter, but nsvg doesn't handle g elements
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 2 May 2019 00:38:36 +0000 (02:38 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 2 May 2019 00:38:36 +0000 (02:38 +0200)
include/vkvg.h
src/vkvg_context.c
src/vkvg_surface.c
tests/svg.c

index 4c841952d0b5558a6c736b012bcd81b8ce268381..78f02028cf9babef75ae545c1fea322d1c437212 100644 (file)
@@ -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
index 5f06996a233fac793e9769ea1a2165d33f90e720..09da7066713cf938cabb9535c1c1ede6edd57a7d 100644 (file)
@@ -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);
 
index d0d0b94714d81038d961841284b08d3a92f304a4..149fe0a7fb3d6f74bc0dd38a887286256713da09 100644 (file)
@@ -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);
index 5e1881ea016d3265da53733498ca5fe177571bae..348bde4e9f1342cc89762b02e48770772c2b5e56 100644 (file)
@@ -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);
 }