]> O.S.I.I.S - jp/vkvg.git/commitdiff
tests wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 15 Nov 2021 15:08:08 +0000 (16:08 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 15 Nov 2021 15:08:08 +0000 (16:08 +0100)
tests/common/test.c
tests/random_rects.c
tests/randoms.c [new file with mode: 0644]

index 24ddad9ff3fe0eeb57b69d0713abc92729fbe1c9..6152a9eca758b37aeffa297068ebac9cb86a96a3 100644 (file)
@@ -176,7 +176,7 @@ void _print_usage_and_exit () {
        printf("\t-x width:\tOutput surface width.\n");
        printf("\t-y height:\tOutput surface height.\n");
        printf("\t-S num samples:\tOutput surface filter, default is 1.\n");
-       printf("\t-G gpu_type:\tSet prefered GPU type:\n");
+    printf("\t-g gpu_type:\tSet prefered GPU type:\n");
        printf("\t\t\t\t- 0: Other\n");
        printf("\t\t\t\t- 1: Integrated\n");
        printf("\t\t\t\t- 2: Discrete\n");
index f192206493e1610f79cfe0544dc8d688c7cf87de..fc26077f4eed551bcd169b3c96d1b68ded6fb964 100644 (file)
 #include "test.h"
 
-/*void drawRandomRect (VkvgContext ctx) {
+void drawRandomRect (VkvgContext ctx, float s) {
        float w = (float)test_width;
        float h = (float)test_height;
        randomize_color(ctx);
 
-       float z = truncf((0.5f*w*rand()/RAND_MAX)+1.f);
-       float v = truncf((0.5f*w*rand()/RAND_MAX)+1.f);
-       float x = truncf((w-z)*rand()/RAND_MAX);
-       float y = truncf((h-v)*rand()/RAND_MAX);
+    float x = truncf(w*rndf());
+    float y = truncf(h*rndf());
 
-       vkvg_rectangle(ctx, x, y, z, v);
-}*/
-static float shape_size = 0.2f;
-
-void _shape_fill(shape_t shape){
-       VkvgContext ctx = _initCtx ();
-       for (uint32_t i=0; i<test_size; i++) {
-               draw_random_shape(ctx, shape, shape_size);
-               vkvg_fill(ctx);
-       }
-       vkvg_destroy(ctx);
+    vkvg_rectangle(ctx, x, y, s, s);
 }
-void _shape_stroke(shape_t shape){
+void fixedSizeRects(){
        VkvgContext ctx = _initCtx ();
        for (uint32_t i=0; i<test_size; i++) {
-               draw_random_shape(ctx, shape, shape_size);
-               vkvg_stroke (ctx);
-       }
-       vkvg_destroy(ctx);
-}
-void _shape_fill_stroke(shape_t shape){
-       VkvgContext ctx = _initCtx ();
-
-       for (uint32_t i=0; i<test_size; i++) {
-               draw_random_shape(ctx, shape, shape_size);
-               vkvg_fill_preserve(ctx);
-               vkvg_stroke(ctx);
-       }
-       vkvg_destroy(ctx);
-}
-
-void rectangles_fill () {
-       _shape_fill(SHAPE_RECTANGLE);
-}
-void rectangles_stroke () {
-       _shape_stroke(SHAPE_RECTANGLE);
-}
-void rectangles_fill_stroke () {
-       _shape_fill_stroke(SHAPE_RECTANGLE);
-}
-void rounded_rects_fill () {
-       _shape_fill(SHAPE_ROUNDED_RECTANGLE);
-}
-void rounded_rects_stroke () {
-       _shape_stroke(SHAPE_ROUNDED_RECTANGLE);
-}
-void rounded_rects_fill_stroke () {
-       _shape_fill_stroke(SHAPE_ROUNDED_RECTANGLE);
-}
-void circles_fill () {
-       _shape_fill(SHAPE_CIRCLE);
-}
-void circles_stroke () {
-       _shape_stroke(SHAPE_CIRCLE);
-}
-void circles_fill_stroke () {
-       _shape_fill_stroke(SHAPE_CIRCLE);
-}
-void stars_fill () {
-       _shape_fill(SHAPE_STAR);
-}
-void stars_stroke () {
-       _shape_stroke(SHAPE_STAR);
-}
-void stars_fill_stroke () {
-       _shape_fill_stroke(SHAPE_STAR);
-}
-void random_fill () {
-       _shape_fill(SHAPE_RANDOM);
-}
-void random_stroke () {
-       _shape_stroke(SHAPE_RANDOM);
-}
-void random_fill_stroke () {
-       _shape_fill_stroke(SHAPE_RANDOM);
+        drawRandomRect(ctx, 50.0f);
+        vkvg_fill (ctx);
+    }
+    vkvg_destroy(ctx);
 }
 
 int main(int argc, char *argv[]) {
        //vkvg_log_level = VKVG_LOG_ERR|VKVG_LOG_DEBUG|VKVG_LOG_INFO|VKVG_LOG_INFO_PATH|VKVG_LOG_DBG_ARRAYS|VKVG_LOG_FULL;
 
-       PERFORM_TEST (rectangles_fill, argc, argv);
-       PERFORM_TEST (rectangles_stroke, argc, argv);
-       PERFORM_TEST (rectangles_fill_stroke, argc, argv);
-
-       PERFORM_TEST (rounded_rects_fill, argc, argv);
-       PERFORM_TEST (rounded_rects_stroke, argc, argv);
-       PERFORM_TEST (rounded_rects_fill_stroke, argc, argv);
-
-       PERFORM_TEST (circles_fill, argc, argv);
-       PERFORM_TEST (circles_stroke, argc, argv);
-       PERFORM_TEST (circles_fill_stroke, argc, argv);
-
-       PERFORM_TEST (stars_fill, argc, argv);
-       PERFORM_TEST (stars_stroke, argc, argv);
-       PERFORM_TEST (stars_fill_stroke, argc, argv);
-
-       PERFORM_TEST (random_fill, argc, argv);
-       PERFORM_TEST (random_stroke, argc, argv);
-       PERFORM_TEST (random_fill_stroke, argc, argv);
-
+    PERFORM_TEST (fixedSizeRects, argc, argv);
        return 0;
 }
diff --git a/tests/randoms.c b/tests/randoms.c
new file mode 100644 (file)
index 0000000..f192206
--- /dev/null
@@ -0,0 +1,114 @@
+#include "test.h"
+
+/*void drawRandomRect (VkvgContext ctx) {
+       float w = (float)test_width;
+       float h = (float)test_height;
+       randomize_color(ctx);
+
+       float z = truncf((0.5f*w*rand()/RAND_MAX)+1.f);
+       float v = truncf((0.5f*w*rand()/RAND_MAX)+1.f);
+       float x = truncf((w-z)*rand()/RAND_MAX);
+       float y = truncf((h-v)*rand()/RAND_MAX);
+
+       vkvg_rectangle(ctx, x, y, z, v);
+}*/
+static float shape_size = 0.2f;
+
+void _shape_fill(shape_t shape){
+       VkvgContext ctx = _initCtx ();
+       for (uint32_t i=0; i<test_size; i++) {
+               draw_random_shape(ctx, shape, shape_size);
+               vkvg_fill(ctx);
+       }
+       vkvg_destroy(ctx);
+}
+void _shape_stroke(shape_t shape){
+       VkvgContext ctx = _initCtx ();
+       for (uint32_t i=0; i<test_size; i++) {
+               draw_random_shape(ctx, shape, shape_size);
+               vkvg_stroke (ctx);
+       }
+       vkvg_destroy(ctx);
+}
+void _shape_fill_stroke(shape_t shape){
+       VkvgContext ctx = _initCtx ();
+
+       for (uint32_t i=0; i<test_size; i++) {
+               draw_random_shape(ctx, shape, shape_size);
+               vkvg_fill_preserve(ctx);
+               vkvg_stroke(ctx);
+       }
+       vkvg_destroy(ctx);
+}
+
+void rectangles_fill () {
+       _shape_fill(SHAPE_RECTANGLE);
+}
+void rectangles_stroke () {
+       _shape_stroke(SHAPE_RECTANGLE);
+}
+void rectangles_fill_stroke () {
+       _shape_fill_stroke(SHAPE_RECTANGLE);
+}
+void rounded_rects_fill () {
+       _shape_fill(SHAPE_ROUNDED_RECTANGLE);
+}
+void rounded_rects_stroke () {
+       _shape_stroke(SHAPE_ROUNDED_RECTANGLE);
+}
+void rounded_rects_fill_stroke () {
+       _shape_fill_stroke(SHAPE_ROUNDED_RECTANGLE);
+}
+void circles_fill () {
+       _shape_fill(SHAPE_CIRCLE);
+}
+void circles_stroke () {
+       _shape_stroke(SHAPE_CIRCLE);
+}
+void circles_fill_stroke () {
+       _shape_fill_stroke(SHAPE_CIRCLE);
+}
+void stars_fill () {
+       _shape_fill(SHAPE_STAR);
+}
+void stars_stroke () {
+       _shape_stroke(SHAPE_STAR);
+}
+void stars_fill_stroke () {
+       _shape_fill_stroke(SHAPE_STAR);
+}
+void random_fill () {
+       _shape_fill(SHAPE_RANDOM);
+}
+void random_stroke () {
+       _shape_stroke(SHAPE_RANDOM);
+}
+void random_fill_stroke () {
+       _shape_fill_stroke(SHAPE_RANDOM);
+}
+
+int main(int argc, char *argv[]) {
+       //vkvg_log_level = VKVG_LOG_ERR|VKVG_LOG_DEBUG|VKVG_LOG_INFO|VKVG_LOG_INFO_PATH|VKVG_LOG_DBG_ARRAYS|VKVG_LOG_FULL;
+
+       PERFORM_TEST (rectangles_fill, argc, argv);
+       PERFORM_TEST (rectangles_stroke, argc, argv);
+       PERFORM_TEST (rectangles_fill_stroke, argc, argv);
+
+       PERFORM_TEST (rounded_rects_fill, argc, argv);
+       PERFORM_TEST (rounded_rects_stroke, argc, argv);
+       PERFORM_TEST (rounded_rects_fill_stroke, argc, argv);
+
+       PERFORM_TEST (circles_fill, argc, argv);
+       PERFORM_TEST (circles_stroke, argc, argv);
+       PERFORM_TEST (circles_fill_stroke, argc, argv);
+
+       PERFORM_TEST (stars_fill, argc, argv);
+       PERFORM_TEST (stars_stroke, argc, argv);
+       PERFORM_TEST (stars_fill_stroke, argc, argv);
+
+       PERFORM_TEST (random_fill, argc, argv);
+       PERFORM_TEST (random_stroke, argc, argv);
+       PERFORM_TEST (random_fill_stroke, argc, argv);
+
+       return 0;
+}