]> O.S.I.I.S - jp/vkvg.git/commitdiff
add perf tests
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 2 Sep 2019 03:18:18 +0000 (05:18 +0200)
committerj-p <jp_bruyere@hotmail.com>
Tue, 3 Sep 2019 18:36:09 +0000 (20:36 +0200)
tests/hlines.c [new file with mode: 0644]
tests/lines.c [new file with mode: 0644]
tests/multilines.c [new file with mode: 0644]
tests/random_rects.c
tests/rect_fill.c
tests/svg.c
tests/vlines.c [new file with mode: 0644]

diff --git a/tests/hlines.c b/tests/hlines.c
new file mode 100644 (file)
index 0000000..3246793
--- /dev/null
@@ -0,0 +1,35 @@
+#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,20);
+    //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
+
+    for (int i=0; i<250; i++) {
+        randomize_color(ctx);
+        float x1 = trunc( ((float)w*rand())/RAND_MAX );
+        float y1 = trunc( ((float)h*rand())/RAND_MAX );
+        float v = trunc( ((float)500*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, 1024, 768);
+
+    return 0;
+}
diff --git a/tests/lines.c b/tests/lines.c
new file mode 100644 (file)
index 0000000..0e86481
--- /dev/null
@@ -0,0 +1,37 @@
+#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,2);
+    //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
+    vkvg_set_source_rgba(ctx,1.0,0.0,0.0,0.1);
+
+    for (int i=0; i<250; i++) {
+        randomize_color(ctx);
+        float x1 = trunc( ((float)w*rand())/RAND_MAX );
+        float y1 = trunc( ((float)h*rand())/RAND_MAX );
+        float x2 = trunc( ((float)w*rand())/RAND_MAX ) + 1;
+        float y2 = trunc( ((float)h*rand())/RAND_MAX ) + 1;
+
+        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, 1024, 768);
+
+    return 0;
+}
diff --git a/tests/multilines.c b/tests/multilines.c
new file mode 100644 (file)
index 0000000..0e86481
--- /dev/null
@@ -0,0 +1,37 @@
+#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,2);
+    //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
+    vkvg_set_source_rgba(ctx,1.0,0.0,0.0,0.1);
+
+    for (int i=0; i<250; i++) {
+        randomize_color(ctx);
+        float x1 = trunc( ((float)w*rand())/RAND_MAX );
+        float y1 = trunc( ((float)h*rand())/RAND_MAX );
+        float x2 = trunc( ((float)w*rand())/RAND_MAX ) + 1;
+        float y2 = trunc( ((float)h*rand())/RAND_MAX ) + 1;
+
+        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, 1024, 768);
+
+    return 0;
+}
index fc69207181b171bc6fa49dbf3547ccb06beec003..4a3b5ac9435c2515c3cd3dcf2a45c8aa13f5d08e 100644 (file)
@@ -1,7 +1,7 @@
 #include "test.h"
 
 void test(){
-    //vkvg_surface_clear(surf);
+    vkvg_surface_clear(surf);
     struct timeval currentTime;
     gettimeofday(&currentTime, NULL);
 
@@ -9,10 +9,11 @@ void test(){
     const float w = 1024.f;
 
     VkvgContext ctx = vkvg_create(surf);
-    vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO);
+    vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
     vkvg_set_line_width(ctx,2);
+    //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
     vkvg_set_source_rgba(ctx,1.0,0.0,0.0,0.1);
-    for (int i=0; i<500; i++) {
+    for (int i=0; i<250; i++) {
         randomize_color(ctx);
         float x = trunc( (0.5*(float)w*rand())/RAND_MAX );
         float y = trunc( (0.5*(float)w*rand())/RAND_MAX );
@@ -20,8 +21,9 @@ void test(){
         float v = trunc( (0.5*(float)w*rand())/RAND_MAX ) + 1;
 
         vkvg_rectangle(ctx, x+1, y+1, z, v);
-        vkvg_fill_preserve(ctx);
-        randomize_color(ctx);
+        /*vkvg_fill_preserve(ctx);
+        randomize_color(ctx);*/
+        vkvg_fill(ctx);
         vkvg_stroke(ctx);
     }
     vkvg_destroy(ctx);
index 0e9d0c1bd9d77e7057f8c3dca0190a13a089211b..9fe71f7d76577e3c7f740f9de95982320416f8bb 100644 (file)
@@ -1,15 +1,26 @@
 #include "test.h"
 
 void test(){
+    vkvg_matrix_t mat;
+    vkvg_matrix_init_identity(&mat);
+    vkvg_matrix_scale(&mat,zoom,zoom);
+    vkvg_matrix_translate(&mat, panX, panY);
+
     vkvg_surface_clear(surf);
+
     VkvgContext ctx = vkvg_create(surf);
+    vkvg_set_source_rgba(ctx,1.0f,1.0f,1.0f,1);
+    vkvg_paint(ctx);
+
+    vkvg_set_matrix(ctx,&mat);
+
     vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
     vkvg_set_line_width(ctx,10);
-    vkvg_set_source_rgba(ctx,0,0,1,0.5);
+    vkvg_set_source_rgba(ctx,0,0,1,1);
     vkvg_rectangle(ctx,100,100,200,200);
-    vkvg_fill(ctx);
+    /*vkvg_fill(ctx);
     vkvg_rectangle(ctx,200,200,200,200);
-    vkvg_set_source_rgba(ctx,1,0,0,0.5);
+    vkvg_set_source_rgba(ctx,1,0,0,0.5);*/
     vkvg_fill(ctx);
 
     vkvg_destroy(ctx);
index 3fb5c23102524a1f4269c0210d85f758ede6334a..adda1673d3014abd664de0cd632b8542aacef40d 100644 (file)
@@ -13,9 +13,9 @@
 }*/
 
 static float rotation = 0.f;
-static const char* path = "data/tiger.svg";
+//static const char* path = "data/tiger.svg";
 //static const char* path = "data/vkvg.svg";
-//static const char* path = "data/testPiece.svg";
+static const char* path = "data/testPiece.svg";
 
 void test_svg_surface() {
     VkvgSurface svgSurf = vkvg_surface_create_from_svg(device, path);
@@ -40,7 +40,7 @@ void test_nsvg() {
     vkvg_paint(ctx);
 
     vkvg_scale(ctx,1.0f,1.0f);
-    //vkvg_render_svg(ctx, svg, "br0");
+    //vkvg_render_svg(ctx, svg, "wq");
     vkvg_render_svg(ctx, svg, NULL);
 
     vkvg_destroy(ctx);
diff --git a/tests/vlines.c b/tests/vlines.c
new file mode 100644 (file)
index 0000000..525f3d2
--- /dev/null
@@ -0,0 +1,36 @@
+#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 (int i=0; i<250; i++) {
+        randomize_color(ctx);
+        float x1 = trunc( ((float)w*rand())/RAND_MAX );
+        float y1 = trunc( ((float)h*rand())/RAND_MAX );
+        float v = trunc( ((float)500*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, 1024, 768);
+
+    return 0;
+}