]> O.S.I.I.S - jp/vkvg.git/commitdiff
vkvg_clear use renderpass clear when command not already started, use it in samples
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 15 Jul 2020 14:07:56 +0000 (16:07 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 15 Jul 2020 14:38:40 +0000 (16:38 +0200)
14 files changed:
.gitignore
src/shaders.h
src/vkvg_context.c
tests/circles.c
tests/clip.c
tests/compositing.c
tests/dashes.c
tests/hlines.c [deleted file]
tests/lines.c
tests/multilines.c [deleted file]
tests/random_cirles.c [deleted file]
tests/random_rects.c
tests/rect_fill.c
tests/vlines.c [deleted file]

index 197514b7ca5991bbe4b5b0793ed74f44a4640a0b..9a69b42121ea14e77744041e44874ea2710eb16e 100644 (file)
@@ -3,3 +3,4 @@ build/
 ignore
 .vs/
 *.json
+log-*.txt
index d0317082d52d6cb899b17e4bca7fca2d9ae26eb8..8c009531bff940f31bf4c3e8baecc0cea03dd23a 100644 (file)
@@ -1014,7 +1014,7 @@ unsigned char vkvg_main_vert_spv[] = {
   0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
   0x08, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00,
-  0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00,
+  0x29, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00,
   0x46, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00,
   0x02, 0x00, 0x00, 0x00, 0xc2, 0x01, 0x00, 0x00, 0x04, 0x00, 0x09, 0x00,
   0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73, 0x65, 0x70, 0x61, 0x72,
@@ -1054,7 +1054,7 @@ unsigned char vkvg_main_vert_spv[] = {
   0x69, 0x6f, 0x6e, 0x00, 0x05, 0x00, 0x03, 0x00, 0x29, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00,
   0x67, 0x6c, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x6e, 0x64,
-  0x65, 0x78, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00,
+  0x65, 0x78, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, 0x00,
   0x6f, 0x75, 0x74, 0x55, 0x56, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00,
   0x46, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x55, 0x56, 0x00, 0x00, 0x00, 0x00,
   0x05, 0x00, 0x03, 0x00, 0x49, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
@@ -1085,7 +1085,7 @@ unsigned char vkvg_main_vert_spv[] = {
   0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x47, 0x00, 0x03, 0x00, 0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
   0x47, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x2a, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x42, 0x00, 0x00, 0x00,
+  0x2a, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, 0x00,
   0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
   0x46, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
   0x47, 0x00, 0x04, 0x00, 0x51, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
@@ -1130,17 +1130,17 @@ unsigned char vkvg_main_vert_spv[] = {
   0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00,
   0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
   0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x2b, 0x00, 0x04, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf,
+  0x09, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
   0x2b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x17, 0x00, 0x04, 0x00,
-  0x40, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x40, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x41, 0x00, 0x00, 0x00,
-  0x42, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x06, 0x00,
-  0x40, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00,
-  0x3a, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
-  0x45, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x3f, 0x00, 0x00, 0x00,
+  0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x40, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
+  0x3b, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00,
+  0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x2c, 0x00, 0x06, 0x00,
+  0x3f, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00,
+  0x3a, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x45, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
   0x3b, 0x00, 0x04, 0x00, 0x45, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
   0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00,
   0x07, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
@@ -1158,7 +1158,7 @@ unsigned char vkvg_main_vert_spv[] = {
   0x70, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00,
   0x20, 0x00, 0x04, 0x00, 0x72, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
   0x0b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x76, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00,
+  0x76, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
   0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00,
   0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00,
@@ -1197,21 +1197,21 @@ unsigned char vkvg_main_vert_spv[] = {
   0x33, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
   0x36, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00,
   0x50, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
-  0x37, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00,
+  0x37, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00,
   0x0b, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00,
   0x38, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x3c, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00,
+  0x3b, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
   0x39, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00,
-  0x0a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
-  0x3d, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00,
-  0x41, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
+  0x0a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00,
+  0x3c, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00,
   0x29, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
-  0x3f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
-  0x42, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00,
+  0x3e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
+  0x41, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00,
   0xf8, 0x00, 0x02, 0x00, 0x26, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
-  0x40, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
-  0x3e, 0x00, 0x03, 0x00, 0x42, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00,
+  0x3f, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
+  0x3e, 0x00, 0x03, 0x00, 0x41, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00,
   0x41, 0x00, 0x07, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00,
   0x0f, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
   0x4c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
@@ -1276,7 +1276,7 @@ unsigned char vkvg_main_vert_spv[] = {
   0x51, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00,
   0x77, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00,
   0x0a, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
-  0x79, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00,
+  0x79, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
   0x41, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00,
   0x29, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
   0x7b, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00,
index eaf7f7f1d451cece072dbdd792c83a76400e3e6d..d696dc39c21f70e8ec9e112ceaa0ca7cd5600f93 100644 (file)
@@ -537,10 +537,20 @@ static const VkClearAttachment clearStencil        = {VK_IMAGE_ASPECT_STENCIL_BI
 static const VkClearAttachment clearColorAttach    = {VK_IMAGE_ASPECT_COLOR_BIT,   0, {{{0}}}};
 
 void vkvg_reset_clip (VkvgContext ctx){
+       if (!ctx->cmdStarted) {
+               ctx->renderPassBeginInfo.renderPass = ctx->pSurf->dev->renderPass_ClearStencil;
+               _start_cmd_for_render_pass(ctx);
+               return;
+       }
        _check_cmd_buff_state (ctx);
        vkCmdClearAttachments(ctx->cmd, 1, &clearStencil, 1, &ctx->clearRect);
 }
 void vkvg_clear (VkvgContext ctx){
+       if (!ctx->cmdStarted) {
+               ctx->renderPassBeginInfo.renderPass = ctx->pSurf->dev->renderPass_ClearAll;
+               _start_cmd_for_render_pass(ctx);
+               return;
+       }
        _check_cmd_buff_state (ctx);
        VkClearAttachment ca[2] = {clearColorAttach, clearStencil};
        vkCmdClearAttachments(ctx->cmd, 2, ca, 1, &ctx->clearRect);
index 906652f0e7d4e3f13c7ad8784fd11f2315dd1be7..9dd31cc76f388fe56bfbfaef3bb058ffebb3b54f 100644 (file)
@@ -11,10 +11,9 @@ void draw_growing_circles (VkvgContext ctx, float y, int count) {
 
 void scaled_up() {
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
 
        vkvg_set_source_rgb   (ctx, 1,1,1);
-       vkvg_paint(ctx);
-       vkvg_set_source_rgb   (ctx, 0,0,0);
 
        vkvg_scale(ctx,100,100);
        vkvg_arc(ctx, 2, 2, 0.5f, 0, M_PIF*2);
@@ -23,8 +22,8 @@ void scaled_up() {
        vkvg_destroy(ctx);
 }
 void fill_and_stroke () {
-       vkvg_surface_clear(surf);
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
        vkvg_set_source_rgba   (ctx, 0,0.1f,0.8f, 0.5f);
        vkvg_set_line_width(ctx,10);
 
@@ -36,10 +35,9 @@ void fill_and_stroke () {
 }
 void sizes() {
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
 
        vkvg_set_source_rgb   (ctx, 1,1,1);
-       vkvg_paint(ctx);
-       vkvg_set_source_rgb   (ctx, 0,0,0);
 
        draw_growing_circles (ctx, 100, 40);
        vkvg_fill (ctx);
index ac24af2b0c85c097b1a8e2bcd128f8b8a276c436..8a5efbd782b8e68e3af76c7aacf9b2f22aaec9de 100644 (file)
@@ -1,8 +1,8 @@
 #include "test.h"
 
 void test_clip(){
-       vkvg_surface_clear(surf);
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
 
        vkvg_move_to(ctx,10,10);
        vkvg_line_to(ctx,400,150);
@@ -24,8 +24,8 @@ void test_clip(){
        vkvg_destroy(ctx);
 }
 void test_clip2(){
-       vkvg_surface_clear(surf);
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
        vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO);
        vkvg_rectangle(ctx, 50,50,500,500);
        vkvg_clip(ctx);
index df193a7c4f066f06e33bb0ff3dd459f8193d3ed3..288c3d632dc06e486d97ccf18f888753bb615b24 100644 (file)
@@ -1,9 +1,8 @@
 #include "test.h"
 
 void compositing(){
-       vkvg_surface_clear(surf);
-
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
 
        vkvg_set_source_rgba(ctx, 1,0,0,0.5f);
        vkvg_rectangle(ctx,100,100,200,200);
index 6ce59dfd4255f4b70917e9d706da105d9d35af3c..e3272ac5943d986d7b9eb75b44f7476935335a41 100644 (file)
@@ -2,9 +2,9 @@
 static float offset = 0;
 void test(){
        offset += 0.1f;
-       vkvg_surface_clear(surf);
 
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
        //const float dashes[] = {160.0f, 80};
        float dashes[] = {700.0f, 30};
        //const float dashes[] = {50, 40};
diff --git a/tests/hlines.c b/tests/hlines.c
deleted file mode 100644 (file)
index 25322f5..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "test.h"
-
-void test(){
-       vkvg_surface_clear(surf);
-       struct timeval currentTime;
-       gettimeofday(&currentTime, NULL);
-
-       srand((unsigned) currentTime.tv_usec);
-       const float w = 1024.f;
-       const float h = 800.f;
-
-       VkvgContext ctx = vkvg_create(surf);
-       //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
-       vkvg_set_line_width(ctx,1);
-       //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
-
-       for (uint32_t i=0; i<test_size; i++) {
-               randomize_color(ctx);
-               float x1 = w*rand()/RAND_MAX;
-               float y1 = h*rand()/RAND_MAX;
-               float v = 500.f*rand()/RAND_MAX;
-
-               vkvg_move_to (ctx, x1, y1);
-               vkvg_line_to (ctx, x1 + v, y1);
-               vkvg_stroke (ctx);
-       }
-       vkvg_destroy(ctx);
-}
-
-int main(int argc, char *argv[]) {
-
-       PERFORM_TEST (test, argc, argv);
-
-       return 0;
-}
index 98bde9f234b43ba72b28eb4e1818e4b948c1a1a5..c796dde760a2448304b19b7cc59d245dfd742a88 100644 (file)
@@ -1,19 +1,56 @@
 #include "test.h"
 
-void test(){
-       vkvg_surface_clear(surf);
+static float line_width = 1.f;
+static vkvg_line_cap_t line_cap = VKVG_LINE_CAP_BUTT;
 
-       struct timeval currentTime;
-       gettimeofday(&currentTime, NULL);
-       srand((unsigned) currentTime.tv_usec);
+void horizontal() {
+       float w = (float)test_width;
+       float h = (float)test_height;
 
-       const float w = 1024.f;
-       const float h = 800.f;
+       VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
+       vkvg_set_line_width (ctx,line_width);
+       vkvg_set_line_cap(ctx, line_cap);
+
+       for (uint32_t i=0; i<test_size; i++) {
+               randomize_color(ctx);
+               float x1 = w*rand()/RAND_MAX;
+               float y1 = h*rand()/RAND_MAX;
+               float v = 500.f*rand()/RAND_MAX;
+
+               vkvg_move_to (ctx, x1, y1);
+               vkvg_line_to (ctx, x1 + v, y1);
+               vkvg_stroke (ctx);
+       }
+       vkvg_destroy(ctx);
+}
+void vertical() {
+       float w = (float)test_width;
+       float h = (float)test_height;
 
        VkvgContext ctx = vkvg_create(surf);
-       //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
-       vkvg_set_line_width (ctx,1);
-       //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
+       vkvg_clear(ctx);
+       vkvg_set_line_width (ctx,line_width);
+
+       for (uint32_t i=0; i<test_size; i++) {
+               randomize_color(ctx);
+               float x1 = w*rand()/RAND_MAX;
+               float y1 = h*rand()/RAND_MAX;
+               float v = 500.f*rand()/RAND_MAX;
+
+               vkvg_move_to (ctx, x1, y1);
+               vkvg_line_to (ctx, x1, y1 + v);
+               vkvg_stroke (ctx);
+       }
+       vkvg_destroy(ctx);
+}
+void horzAndVert(){
+       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);
 
        for (uint32_t i=0; i<test_size; i++) {
                randomize_color(ctx);
@@ -26,14 +63,43 @@ void test(){
                vkvg_move_to (ctx, x1, y1);
                vkvg_line_to (ctx, x2, y2);
                vkvg_stroke (ctx);
+       }
+       vkvg_destroy(ctx);
+}
+void multilines(){
+       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);
+
+       randomize_color(ctx);
+
+       for (uint32_t i=0; i<test_size; i++) {
+
+               float x1 = w*rand()/RAND_MAX;
+               float y1 = h*rand()/RAND_MAX;
+               float x2 = (w*rand()/RAND_MAX) + 1;
+               float y2 = (h*rand()/RAND_MAX) + 1;
 
-               /*if (i%100==0)
-                       vkvg_flush(ctx);*/
+               vkvg_move_to (ctx, x1, y1);
+               vkvg_line_to (ctx, x2, y2);
        }
+       vkvg_stroke (ctx);
        vkvg_destroy(ctx);
 }
 
+
 int main(int argc, char *argv[]) {
-       PERFORM_TEST(test, argc, argv);
+       struct timeval currentTime;
+       gettimeofday(&currentTime, NULL);
+
+       srand((unsigned) currentTime.tv_usec);
+
+       PERFORM_TEST(horizontal, argc, argv);
+       PERFORM_TEST(vertical, argc, argv);
+       PERFORM_TEST(horzAndVert, argc, argv);
+       PERFORM_TEST(multilines, argc, argv);
        return 0;
 }
diff --git a/tests/multilines.c b/tests/multilines.c
deleted file mode 100644 (file)
index f9d6c06..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "test.h"
-
-void test(){
-       vkvg_surface_clear(surf);
-       struct timeval currentTime;
-       gettimeofday(&currentTime, NULL);
-
-       srand((unsigned) currentTime.tv_usec);
-       const float w = 1024.f;
-       const float h = 800.f;
-
-       VkvgContext ctx = vkvg_create(surf);
-       //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
-       vkvg_set_line_width(ctx,1);
-       //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
-
-       randomize_color(ctx);
-
-       for (uint32_t i=0; i<test_size; i++) {
-
-               float x1 = w*rand()/RAND_MAX;
-               float y1 = h*rand()/RAND_MAX;
-               float x2 = (w*rand()/RAND_MAX) + 1;
-               float y2 = (h*rand()/RAND_MAX) + 1;
-
-               vkvg_move_to (ctx, x1, y1);
-               vkvg_line_to (ctx, x2, y2);
-
-               /*if (i%100==0)
-                       vkvg_flush(ctx);*/
-       }
-       vkvg_stroke (ctx);
-       vkvg_destroy(ctx);
-}
-
-int main(int argc, char *argv[]) {
-       PERFORM_TEST (test, argc, argv);
-       return 0;
-}
diff --git a/tests/random_cirles.c b/tests/random_cirles.c
deleted file mode 100644 (file)
index 9004961..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "test.h"
-
-void test(){
-       vkvg_surface_clear(surf);
-       struct timeval currentTime;
-       gettimeofday(&currentTime, NULL);
-
-       srand((unsigned) currentTime.tv_usec);
-       const float w = 800.f;
-
-       VkvgContext ctx = vkvg_create(surf);
-       vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
-
-       vkvg_set_line_width(ctx, 1.0f);
-       //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
-
-       for (uint32_t i=0; i<test_size; i++) {
-               randomize_color(ctx);
-
-               float r = 0.5f*w*rand()/RAND_MAX;
-               float x = truncf(0.5f * w*rand()/RAND_MAX + r);
-               float y = truncf(0.5f * w*rand()/RAND_MAX + r);
-
-               vkvg_arc(ctx, x, y, r, 0, M_PIF * 2.0f);
-               vkvg_fill(ctx);
-       }
-       vkvg_destroy(ctx);
-}
-
-int main(int argc, char *argv[]) {
-       PERFORM_TEST(test, argc, argv);
-       return 0;
-}
index bcfd28b519bf75d496313fd7a258a057c0156b32..05dec69e0ab1b1355306e76a1c96431729720383 100644 (file)
 
        vkvg_rectangle(ctx, x, y, z, v);
 }*/
-static vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_EVEN_ODD;
+static vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_NON_ZERO;
 static float line_width = 5.f;
 static float shape_size = 0.1f;
 
 void _shape_fill(shape_t shape){
-       vkvg_surface_clear(surf);
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
        vkvg_set_fill_rule(ctx, fill_rule);
        for (uint32_t i=0; i<test_size; i++) {
                draw_random_shape(ctx, shape, shape_size);
@@ -27,8 +27,8 @@ void _shape_fill(shape_t shape){
        vkvg_destroy(ctx);
 }
 void _shape_stroke(shape_t shape){
-       vkvg_surface_clear (surf);
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
        vkvg_set_line_width (ctx, line_width);
        vkvg_set_fill_rule(ctx, fill_rule);
        for (uint32_t i=0; i<test_size; i++) {
@@ -38,8 +38,8 @@ void _shape_stroke(shape_t shape){
        vkvg_destroy(ctx);
 }
 void _shape_fill_stroke(shape_t shape){
-       vkvg_surface_clear(surf);
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
        vkvg_set_line_width (ctx, line_width);
        vkvg_set_fill_rule(ctx, fill_rule);
        for (uint32_t i=0; i<test_size; i++) {
index ab5785a0b7ddda0e0cb444e6a44f6106b2541709..5a6d244ceacb9872d479ec5305b0665b0e6a26d5 100644 (file)
@@ -1,12 +1,6 @@
 #include "test.h"
 
-void test(){
-       vkvg_surface_clear(surf);
-
-       VkvgContext ctx = vkvg_create(surf);
-
-       vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO);
-
+void draw(VkvgContext ctx) {
        vkvg_set_source_rgba(ctx,0,0,1,0.5);
        vkvg_rectangle(ctx,100,100,200,200);
        vkvg_fill(ctx);
@@ -14,23 +8,26 @@ void test(){
        vkvg_rectangle(ctx,200,200,200,200);
        vkvg_set_source_rgba(ctx,1,0,0,0.5);
        vkvg_fill(ctx);
+}
+void test(){
+
+       VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
+
+       vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO);
+
+       draw(ctx);
 
        vkvg_destroy(ctx);
 }
 void test_evenodd(){
-       vkvg_surface_clear(surf);
 
        VkvgContext ctx = vkvg_create(surf);
+       vkvg_clear(ctx);
 
        vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
 
-       vkvg_set_source_rgba(ctx,0,0,1,0.5);
-       vkvg_rectangle(ctx,100,100,200,200);
-       vkvg_fill(ctx);
-
-       vkvg_rectangle(ctx,200,200,200,200);
-       vkvg_set_source_rgba(ctx,1,0,0,0.5);
-       vkvg_fill(ctx);
+       draw(ctx);
 
        vkvg_destroy(ctx);
 }
diff --git a/tests/vlines.c b/tests/vlines.c
deleted file mode 100644 (file)
index 302457d..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "test.h"
-
-void test(){
-       vkvg_surface_clear(surf);
-       struct timeval currentTime;
-       gettimeofday(&currentTime, NULL);
-
-       srand((unsigned) currentTime.tv_usec);
-       const float w = 1024.f;
-       const float h = 800.f;
-
-       VkvgContext ctx = vkvg_create(surf);
-       //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
-       vkvg_set_line_width(ctx,1);
-       //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
-       //vkvg_set_source_rgba(ctx,1.0,0.0,0.0,0.1);
-
-       for (uint32_t i=0; i<test_size; i++) {
-               randomize_color(ctx);
-               float x1 = w*rand()/RAND_MAX;
-               float y1 = h*rand()/RAND_MAX;
-               float v = (500.f*rand()/RAND_MAX) + 1;
-
-               vkvg_move_to (ctx, x1, y1);
-               vkvg_line_to (ctx, x1, y1 + v);
-               vkvg_stroke (ctx);
-       }
-       vkvg_destroy(ctx);
-}
-
-int main(int argc, char *argv[]) {
-       PERFORM_TEST (test, argc, argv);
-       return 0;
-}