From: Jean-Philippe Bruyère Date: Wed, 9 Sep 2020 04:44:45 +0000 (+0200) Subject: tests improvments, print test config header, cmd args parsing X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=c11ded434f436baa057a6538632aa2667b5ba427;p=jp%2Fvkvg.git tests improvments, print test config header, cmd args parsing --- diff --git a/scripts/batchTests.sh b/scripts/batchTests.sh index b880572..b7c8d02 100755 --- a/scripts/batchTests.sh +++ b/scripts/batchTests.sh @@ -52,14 +52,20 @@ logfile="$logdir/log-$today.txt" git log -n 1 --pretty=format:'%h %d %s%n%n' > $logfile -echo "_____________________________________________________________________________________________________" >> $logfile -echo "| Test File Name | Sub Test | Iter | SIZE | FPS | Average | Median | Sigma |" >> $logfile -echo "|-----------------|---------------------------|------|------|---------|---------|---------|---------|" >> $logfile +files=( test_* ) +./"${files[0]}" -p >> $logfile + +echo "__________________________________________________________________________________________________________" >> $logfile +echo "| N° | Test File Name | Sub Test | Iter | Size | FPS | Average | Median | Sigma |" >> $logfile +echo "|----|-----------------|---------------------------|------|------|---------|---------|---------|---------|" >> $logfile for file in test_* do if [[ -x "$file" ]] then - ./"$file" $ITERATIONS $SIZE >> $logfile + printf "." + ./"$file" -i $ITERATIONS -s $SIZE -q >> $logfile fi done -echo "_____________________________________________________________________________________________________" >> $logfile +echo "__________________________________________________________________________________________________________" >> $logfile +echo +echo "results writen in $logfile" diff --git a/src/vkvg_context.c b/src/vkvg_context.c index e9bdf88..d305109 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -633,10 +633,9 @@ float _draw_dashed_segment (VkvgContext ctx, float hw, vec2 pL, vec2 p, vec2 pR, _draw_stoke_cap (ctx, hw, p0, normal, dashOn); dashOn ^= true; - - curDashOffset += ctx->dashes[curDash++]; - if (curDash == ctx->dashCount) + if (++curDash == ctx->dashCount) curDash = 0; + curDashOffset += ctx->dashes[curDash]; } curDashOffset -= segmentLength; return segmentLength; @@ -727,7 +726,7 @@ bool _process_stroke (VkvgContext ctx) { if (!dashOn){ //finishing last dash that is already started, draw end caps but not too close to start //the default gap is the next void - uint32_t prevDash = curDash-1; + int32_t prevDash = (int32_t)curDash-1; if (prevDash < 0) curDash = ctx->dashCount-1; float m = fminf (ctx->dashes[prevDash] - curDashOffset, ctx->dashes[curDash]); diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index 4793d7a..dceba19 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -306,7 +306,7 @@ void _add_triangle_indices(VkvgContext ctx, VKVG_IBO_INDEX_TYPE i0, VKVG_IBO_IND ctx->indCount+=3; _check_index_cache_size(ctx); - LOG(VKVG_LOG_INFO, "Triangle IDX: %d %d %d (count=%d)\n", i0,i1,i2,ctx->indCount); + LOG(VKVG_LOG_INFO, "Triangle IDX: %d %d %d (indCount=%d)\n", i0,i1,i2,ctx->indCount); } void _vao_add_rectangle (VkvgContext ctx, float x, float y, float width, float height){ Vertex v[4] = diff --git a/template.c b/template.c index a222a84..333fcdf 100644 --- a/template.c +++ b/template.c @@ -4,15 +4,13 @@ #include "test.h" -void test(){ +void test_name(){ VkvgContext ctx = vkvg_create(surf); vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - - perform_test (test, "custom test", 800, 600); - + PERFORM_TEST (test_name, argc, argv); return 0; } diff --git a/tests/arcs.c b/tests/arcs.c index daeb48c..d3e1109 100644 --- a/tests/arcs.c +++ b/tests/arcs.c @@ -84,8 +84,9 @@ void test(){ } int main(int argc, char *argv[]) { + no_test_size = true; PERFORM_TEST (sizes, argc, argv); PERFORM_TEST (scaled_up, argc, argv); - PERFORM_TEST (test, argc, argv); + PERFORM_TEST (test, argc, argv); return 0; } diff --git a/tests/circles.c b/tests/circles.c index dbc86f9..3a34d81 100644 --- a/tests/circles.c +++ b/tests/circles.c @@ -55,6 +55,7 @@ void sizes() { } int main(int argc, char *argv[]) { + no_test_size = true; PERFORM_TEST (fill_and_stroke, argc, argv); PERFORM_TEST (sizes, argc, argv); PERFORM_TEST (scaled_up, argc, argv); diff --git a/tests/clip.c b/tests/clip.c index 3eb6fbe..0322295 100644 --- a/tests/clip.c +++ b/tests/clip.c @@ -159,6 +159,7 @@ void test_clip2(){ vkvg_destroy(ctx); } int main(int argc, char *argv[]) { + no_test_size = true; PERFORM_TEST (clipped_paint_ec, argc, argv); PERFORM_TEST (clipped_paint_eo, argc, argv); PERFORM_TEST (clipped_transformed_ec, argc, argv); diff --git a/tests/colinear.c b/tests/colinear.c index 68bf3ad..595ff21 100644 --- a/tests/colinear.c +++ b/tests/colinear.c @@ -18,7 +18,7 @@ void test(){ } int main(int argc, char *argv[]) { - + no_test_size = true; PERFORM_TEST (test, argc, argv); return 0; diff --git a/tests/common/test.c b/tests/common/test.c index bd28316..ef7d207 100644 --- a/tests/common/test.c +++ b/tests/common/test.c @@ -33,15 +33,21 @@ bool mouseDown = false; VkvgDevice device = NULL; VkvgSurface surf = NULL; -uint32_t test_size = 100; // items drawn in one run, or complexity -uint32_t iterations = 1000;// repeat test n times -uint32_t test_width = 1024; -uint32_t test_height= 768; -bool test_vsync = false; +uint32_t test_size = 10; // items drawn in one run, or complexity +uint32_t iterations = 100;// repeat test n times +uint32_t test_width = 512; +uint32_t test_height= 512; +bool test_vsync = false; +bool quiet = false;//if true, don't print details and head row +bool first_test = true;//if multiple tests, dont print header row. +bool no_test_size= false;//several test consist of a single draw sequence without looping 'size' times + //those test must be preceded by setting no_test_size to 'true' +int test_index = 0; +int single_test = -1; //if not < 0, contains the index of the single test to run static bool paused = false; -static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; +static VkSampleCountFlags samples = VK_SAMPLE_COUNT_1_BIT; static vk_engine_t* e; static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { @@ -162,6 +168,98 @@ void clear_test () { #ifdef VKVG_TEST_DIRECT_DRAW VkvgSurface* surfaces; #endif +_print_usage_and_exit () { + printf("\nUsage: test [options]\n\n"); + printf("\t-i iterations:\tSpecify the repeat count for the test.\n"); + printf("\t-s size:\tWhen applicable, specify the size of the test.\n"); + printf("\t-w width:\tOutput surface width.\n"); + printf("\t-h height:\tOutput surface height.\n"); + printf("\t-n index:\tRun only a single test, zero based index.\n"); + printf("\t-q:\t\tQuiet, don't print measures table head row, usefull for batch tests\n"); + printf("\t-p:\t\tPrint test details and exit without performing test, usefull to print details in logs\n"); + printf("\t-vsync:\t\tEnable VSync, disabled by default\n"); + printf("\t-h:\t\tthis help message.\n"); + printf("\n"); + exit(-1); +} +void _parse_args (int argc, char* argv[]) { + for (int i = 1; i < argc; i++) { + if (strcmp (argv[i], "-help\0") == 0) + _print_usage_and_exit (); + if (strcmp (argv[i], "-p\0") == 0) { + #ifdef DEBUG + printf("Debug build\n"); + #else + printf("Release build\n"); + #endif + #ifdef VKVG_USE_RENDERDOC + printf("Render doc enabled\n"); + #endif + #ifdef VKVG_USE_VALIDATION + printf("Validation enabled\n"); + #endif + printf("surf dims:\t%d x %d\n", test_width, test_height); + printf("Samples:\t%d\n", samples); + #ifdef VKVG_TEST_OFFSCREEN + printf("Offscreen:\ttrue\n"); + #else + printf("Offscreen:\ttrue\n"); + #endif + printf("\n"); + exit(0); + } + if (strcmp (argv[i], "-vsync\0") == 0) + test_vsync = true; + else if (strcmp (argv[i], "-q\0") == 0) + quiet = true; + else if (strcmp (argv[i], "-i\0") == 0) { + if (argc -1 < ++i) + _print_usage_and_exit(); + iterations = atoi (argv[i]); + }else if (strcmp (argv[i], "-w\0") == 0) { + if (argc -1 < ++i) + _print_usage_and_exit(); + test_width = atoi (argv[i]); + }else if (strcmp (argv[i], "-h\0") == 0) { + if (argc -1 < ++i) + _print_usage_and_exit(); + test_height = atoi (argv[i]); + }else if (strcmp (argv[i], "-n\0") == 0) { + if (argc -1 < ++i) + _print_usage_and_exit(); + single_test = atoi (argv[i]); + }else if (strcmp (argv[i], "-s\0") == 0) { + if (argc -1 < ++i) + _print_usage_and_exit(); + test_size = atoi (argv[i]); + } + } +} + +void _print_results (const char *testName, int argc, char* argv[], uint32_t i, double run_total, double* run_time_values) { + char* whoami; + (whoami = strrchr(argv[0], '/')) ? ++whoami : (whoami = argv[0]); + + double avg_run_time = run_total / (double)i; + double med_run_time = median_run_time (run_time_values, i); + double standard_dev = standard_deviation (run_time_values, i, avg_run_time); + double avg_frames_per_second = (1.0 / avg_run_time); + avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999; + + if (!quiet && (test_index == 0 || test_index == single_test)) { + printf ("______________________________________________________________________________________________________\n"); + printf ("| N° | Test File Name | Sub Test | Iter | Size | FPS | Average | Median | Sigma |\n"); + printf ("|----|-----------------|---------------------------|------|------|---------|---------|---------|---------|\n"); + } + printf ("| %2d | %-15s | %-25s | ", test_index, whoami + 5, testName); + if (no_test_size) + printf ("%4d | %4d | %7.2f | %6.5f | %6.5f | %6.5f |\n", + i, 1, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); + else + printf ("%4d | %4d | %7.2f | %6.5f | %6.5f | %6.5f |\n", + i, test_size, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); + +} void perform_test_offscreen (void(*testfunc)(void), const char *testName, int argc, char* argv[]) { //init random gen @@ -170,18 +268,14 @@ void perform_test_offscreen (void(*testfunc)(void), const char *testName, int ar srand((unsigned) currentTime.tv_usec); //dumpLayerExts(); - if (argc > 1) - iterations = atoi (argv[1]); - if (argc > 2) - test_size = atoi (argv[2]); - if (iterations == 0 || test_size == 0) { - printf("usage: test [iterations] [size]\n"); + + _parse_args (argc, argv); + + if (single_test >= 0 && test_index != single_test){ + test_index++; return; } - - char* whoami; - (whoami = strrchr(argv[0], '/')) ? ++whoami : (whoami = argv[0]); - + uint32_t enabledExtsCount = 0, phyCount = 0; const char* enabledExts [10]; #ifdef VKVG_USE_RENDERDOC @@ -269,20 +363,9 @@ void perform_test_offscreen (void(*testfunc)(void), const char *testName, int ar i++; } - double avg_run_time = run_total / (double)i; - double med_run_time = median_run_time (run_time_values, i); - double standard_dev = standard_deviation (run_time_values, i, avg_run_time); - double avg_frames_per_second = (1.0 / avg_run_time); - avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999; - - free (run_time_values); - - //printf ("size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); - printf ("| %-15s | %-25s | ",whoami + 5, testName); - printf ("%4d | %4d | %7.2f | %6.5f | %6.5f | %6.5f |\n", - test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); + _print_results (testName, argc, argv, i, run_total, run_time_values); - //printf ("%s size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", whoami+5, test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); + free (run_time_values); vkDeviceWaitIdle(dev->dev); @@ -291,6 +374,8 @@ void perform_test_offscreen (void(*testfunc)(void), const char *testName, int ar vkh_device_destroy (dev); vkh_app_destroy (app); + + test_index++; } void perform_test (void(*testfunc)(void), const char *testName, int argc, char* argv[]) { @@ -300,18 +385,13 @@ void perform_test (void(*testfunc)(void), const char *testName, int argc, char* srand((unsigned) currentTime.tv_usec); //dumpLayerExts(); - if (argc > 1) - iterations = atoi (argv[1]); - if (argc > 2) - test_size = atoi (argv[2]); - if (iterations == 0 || test_size == 0) { - printf("usage: test [iterations] [size]\n"); + _parse_args (argc, argv); + + if (single_test >= 0 && test_index != single_test){ + test_index++; return; } - char* whoami; - (whoami = strrchr(argv[0], '/')) ? ++whoami : (whoami = argv[0]); - if (test_vsync) e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); else @@ -338,7 +418,6 @@ void perform_test (void(*testfunc)(void), const char *testName, int argc, char* vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); #endif - double start_time = 0.0, stop_time = 0.0, run_time = 0.0, run_total = 0.0, min_run_time = -1, max_run_time = 0.0; double* run_time_values = (double*)malloc(iterations*sizeof(double)); @@ -408,22 +487,10 @@ void perform_test (void(*testfunc)(void), const char *testName, int argc, char* i++; } - double avg_run_time = run_total / (double)i; - double med_run_time = median_run_time (run_time_values, i); - double standard_dev = standard_deviation (run_time_values, i, avg_run_time); - double avg_frames_per_second = (1.0 / avg_run_time); - avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999; + _print_results (testName, argc, argv, i, run_total, run_time_values); free (run_time_values); - - //printf ("size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); - printf ("| %-15s | %-25s | ",whoami + 5, testName); - printf ("%4d | %4d | %7.2f | %6.5f | %6.5f | %6.5f |\n", - test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); - - //printf ("%s size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", whoami+5, test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); - vkDeviceWaitIdle(e->dev->dev); #ifdef VKVG_TEST_DIRECT_DRAW @@ -438,8 +505,35 @@ void perform_test (void(*testfunc)(void), const char *testName, int argc, char* vkvg_device_destroy (device); vkengine_destroy (e); + + test_index++; +} + + +/* common context init for several tests */ +vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_NON_ZERO; +vkvg_line_cap_t line_cap = VKVG_LINE_CAP_BUTT; +vkvg_line_join_t line_join = VKVG_LINE_JOIN_MITER; +float dashes[] = {20.0f, 10.0f}; +uint32_t dashes_count= 0; +float dash_offset = 0; +float line_width = 1.f; + +VkvgContext _initCtx() { + VkvgContext ctx = vkvg_create(surf); + + vkvg_set_line_width (ctx,line_width); + vkvg_set_line_join (ctx, line_join); + vkvg_set_line_cap (ctx, line_cap); + vkvg_set_dash (ctx, dashes, dashes_count, dash_offset); + vkvg_set_fill_rule (ctx, fill_rule); + + vkvg_clear (ctx); + return ctx; } + + const int star_points[11][2] = { { 0, 85 }, { 75, 75 }, @@ -455,10 +549,10 @@ const int star_points[11][2] = { }; void randomize_color(VkvgContext ctx) { vkvg_set_source_rgba(ctx, - (float)rand() / RAND_MAX, - (float)rand() / RAND_MAX, - (float)rand() / RAND_MAX, - (float)rand() / RAND_MAX + rndf(), + rndf(), + rndf(), + rndf() ); } void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact) { @@ -471,29 +565,29 @@ void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact) { switch (shape) { case SHAPE_LINE: - x = (float)rand()/RAND_MAX * w; - y = (float)rand()/RAND_MAX * h; - z = (float)rand()/RAND_MAX * w; - v = (float)rand()/RAND_MAX * h; + x = rndf() * w; + y = rndf() * h; + z = rndf() * w; + v = rndf() * h; vkvg_move_to(ctx, x, y); vkvg_line_to(ctx, z, v); vkvg_stroke(ctx); break; case SHAPE_RECTANGLE: - z = truncf((sizeFact*w*rand()/RAND_MAX)+1.f); - v = truncf((sizeFact*h*rand()/RAND_MAX)+1.f); - x = truncf((w-z)*rand()/RAND_MAX); - y = truncf((h-v)*rand()/RAND_MAX); + z = truncf((sizeFact*w*rndf())+1.f); + v = truncf((sizeFact*h*rndf())+1.f); + x = truncf((w-z)*rndf()); + y = truncf((h-v)*rndf()); vkvg_rectangle(ctx, x+1, y+1, z, v); break; case SHAPE_ROUNDED_RECTANGLE: - z = truncf((sizeFact*w*rand()/RAND_MAX)+1.f); - v = truncf((sizeFact*h*rand()/RAND_MAX)+1.f); - x = truncf((w-z)*rand()/RAND_MAX); - y = truncf((h-v)*rand()/RAND_MAX); - r = truncf((0.2f*z*rand()/RAND_MAX)+1.f); + z = truncf((sizeFact*w*rndf())+1.f); + v = truncf((sizeFact*h*rndf())+1.f); + x = truncf((w-z)*rndf()); + y = truncf((h-v)*rndf()); + r = truncf((0.2f*z*rndf())+1.f); if ((r > v / 2) || (r > z / 2)) r = MIN(v / 2, z / 2); @@ -513,10 +607,10 @@ void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact) { /*x = truncf((float)w * rnd()/RAND_MAX); y = truncf((float)h * rnd()/RAND_MAX); v = truncf((float)w * rnd()/RAND_MAX * 0.2f);*/ - x = (float)rand()/RAND_MAX * w; - y = (float)rand()/RAND_MAX * h; + x = rndf() * w; + y = rndf() * h; - r = truncf((sizeFact*MIN(w,h)*rand()/RAND_MAX)+1.f); + r = truncf((sizeFact*MIN(w,h)*rndf())+1.f); /*float r = 0.5f*w*rand()/RAND_MAX; float x = truncf(0.5f * w*rand()/RAND_MAX + r); @@ -526,9 +620,9 @@ void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact) { break; case SHAPE_TRIANGLE: case SHAPE_STAR: - x = (float)rand()/RAND_MAX * w; - y = (float)rand()/RAND_MAX * h; - z = (float)rand()/RAND_MAX * sizeFact + 0.15f; //scale + x = rndf() * w; + y = rndf() * h; + z = rndf() * sizeFact + 0.15f; //scale vkvg_move_to (ctx, x+star_points[0][0]*z, y+star_points[0][1]*z); for (int s=1; s<11; s++) @@ -536,10 +630,23 @@ void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact) { vkvg_close_path (ctx); break; case SHAPE_RANDOM: - draw_random_shape(ctx, 1 + rand()%4, sizeFact); + draw_random_shape(ctx, 1 + (rndf() * 4), sizeFact); break; } } +void draw_random_curve (VkvgContext ctx) { + float w = (float)test_width; + float h = (float)test_height; + + float x2 = w*rndf(); + float y2 = h*rndf(); + float cp_x1 = w*rndf(); + float cp_y1 = h*rndf(); + float cp_x2 = w*rndf(); + float cp_y2 = h*rndf(); + + vkvg_curve_to(ctx, cp_x1, cp_y1, cp_x2, cp_y2, x2, y2); +} /*void draw_random_shape (VkvgContext ctx, shape_t shape) { float w = (float)test_width; float h = (float)test_height; @@ -549,4 +656,4 @@ void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact) { float x = truncf((w-z)*rand()/RAND_MAX); float y = truncf((h-v)*rand()/RAND_MAX); vkvg_rectangle(ctx, x, y, z, v); -}*/ +}*/ \ No newline at end of file diff --git a/tests/common/test.h b/tests/common/test.h index 3716c2e..58fe95f 100644 --- a/tests/common/test.h +++ b/tests/common/test.h @@ -79,6 +79,7 @@ extern uint32_t test_size; extern uint32_t iterations; extern uint32_t test_width; extern uint32_t test_height; +extern bool no_test_size; extern float panX; extern float panY; @@ -90,12 +91,25 @@ extern bool mouseDown; extern VkvgDevice device; extern VkvgSurface surf; +/* common context init for several tests */ +extern float dash_offset; +extern float line_width; +extern vkvg_fill_rule_t fill_rule; +extern vkvg_line_cap_t line_cap; +extern vkvg_line_join_t line_join; +extern float dashes[]; +extern uint32_t dashes_count; + +VkvgContext _initCtx(); +/*******************************/ + //run test in one step void perform_test (void(*testfunc)(), const char* testName, int argc, char *argv[]); void perform_test_offscreen (void(*testfunc)(void), const char *testName, int argc, char* argv[]); void randomize_color (VkvgContext ctx); void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact); +void draw_random_curve (VkvgContext ctx); //run test in 3 step: init, run, clear. void init_test (uint32_t width, uint32_t height); diff --git a/tests/compositing.c b/tests/compositing.c index 288c3d6..e144973 100644 --- a/tests/compositing.c +++ b/tests/compositing.c @@ -16,6 +16,7 @@ void compositing(){ } int main(int argc, char *argv[]) { + no_test_size = true; PERFORM_TEST (compositing, argc, argv); return 0; } diff --git a/tests/context.c b/tests/context.c new file mode 100644 index 0000000..641a357 --- /dev/null +++ b/tests/context.c @@ -0,0 +1,21 @@ +#include "test.h" + +void create_destroy_multi(){ + VkvgContext ctxs[test_size]; + for (uint32_t i = 0; i < test_size; i++) + ctxs[i] = vkvg_create(surf); + for (uint32_t i = 0; i < test_size; i++) + vkvg_destroy(ctxs[i]); +} + +void create_destroy_single(){ + VkvgContext ctx = vkvg_create(surf); + vkvg_destroy(ctx); +} + +int main(int argc, char *argv[]) { + PERFORM_TEST (create_destroy_multi, argc, argv); + no_test_size = true; + PERFORM_TEST (create_destroy_single, argc, argv); + return 0; +} diff --git a/tests/curve.c b/tests/curve.c index 1367b60..b944c71 100644 --- a/tests/curve.c +++ b/tests/curve.c @@ -108,37 +108,9 @@ void test2() { vkvg_destroy(ctx); } -static float line_width = 1.f; -static vkvg_line_cap_t line_cap = VKVG_LINE_CAP_ROUND; -static vkvg_fill_rule_t fill_rule = VKVG_FILL_RULE_NON_ZERO; -static float dashes[] = {30.0f, 10.0f}; -static uint32_t dashes_count = 0; static bool fillAndStroke = true; -void _rnd_curve (VkvgContext ctx) { - float w = (float)test_width; - float h = (float)test_height; - - float x2 = w*rand()/RAND_MAX; - float y2 = h*rand()/RAND_MAX; - float cp_x1 = w*rand()/RAND_MAX; - float cp_y1 = h*rand()/RAND_MAX; - float cp_x2 = w*rand()/RAND_MAX; - float cp_y2 = h*rand()/RAND_MAX; - - vkvg_curve_to(ctx, cp_x1, cp_y1, cp_x2, cp_y2, x2, y2); -} - -VkvgContext _initCtx() { - VkvgContext ctx = vkvg_create(surf); - vkvg_clear(ctx); - vkvg_set_line_width (ctx,line_width); - vkvg_set_line_cap(ctx, line_cap); - vkvg_set_dash (ctx, dashes, dashes_count, 0); - return ctx; -} - -void random_curves () { +void random_curves_stroke () { float w = (float)test_width; float h = (float)test_height; @@ -150,13 +122,14 @@ void random_curves () { float y1 = h*rand()/RAND_MAX; vkvg_move_to (ctx, x1, y1); - _rnd_curve(ctx); + draw_random_curve(ctx); vkvg_stroke (ctx); } vkvg_destroy(ctx); } -void single_long_line_curved () { + +void _long_curv () { float w = (float)test_width; float h = (float)test_height; @@ -169,7 +142,7 @@ void single_long_line_curved () { vkvg_move_to (ctx, x1, y1); for (uint32_t i=0; i