From f9444e597d039c73af542334dfabb68a760822cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Mon, 4 May 2020 13:40:57 +0200 Subject: [PATCH] Fontconfig init check, sample startup simplified, code docs and clean --- src/vkvg_context.c | 31 +++++++++++++--- src/vkvg_context_internal.c | 6 +-- src/vkvg_context_internal.h | 2 - src/vkvg_fonts.c | 5 +++ src/vkvg_fonts.h | 2 +- template.c | 6 ++- tests/arcs.c | 74 +++++++++++++++++++++++++++++++++++-- tests/circles.c | 47 +++++++++++++++-------- tests/clip.c | 5 +-- tests/colinear.c | 2 +- tests/common/test.c | 4 +- tests/common/test.h | 5 ++- tests/common/vkengine.c | 4 +- tests/common/vkengine.h | 1 + tests/compositing.c | 6 +-- tests/curve.c | 4 +- tests/curve2.c | 4 +- tests/curved_rect.c | 4 +- tests/dashes.c | 4 +- tests/dashes2.c | 4 +- tests/fill.c | 4 +- tests/fill_and_stroke.c | 4 +- tests/gradient.c | 40 ++++++++++++++++---- tests/gradient_transform.c | 4 +- tests/hlines.c | 2 +- tests/img_surf.c | 60 +++++++++++++++++++++++++++++- tests/line_caps.c | 4 +- tests/line_join.c | 4 +- tests/line_join_2.c | 4 +- tests/line_join_3.c | 4 +- tests/lines.c | 4 +- tests/multilines.c | 4 +- tests/random_cirles.c | 4 +- tests/random_rects.c | 2 +- tests/rect_fill.c | 22 +++++++++-- tests/save_restore.c | 2 +- tests/simple_paint.c | 48 ++++++++++++++++++++++-- tests/stroke.c | 2 +- tests/svg.c | 3 +- tests/test1.c | 3 +- tests/text.c | 6 +-- tests/vlines.c | 4 +- vkh | 2 +- 43 files changed, 336 insertions(+), 120 deletions(-) diff --git a/src/vkvg_context.c b/src/vkvg_context.c index b6a4052..4a985a3 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -41,7 +41,7 @@ static VkClearValue clearValues[3] = { /** * @brief create new context for surface - * @param drawing operation output surface + * @param drawing operations output surface * @return newly created context pointer */ VkvgContext vkvg_create(VkvgSurface surf) @@ -229,6 +229,7 @@ void vkvg_destroy (VkvgContext ctx) free(ctx->vertexCache); free(ctx->indexCache); + //TODO:check this for source counter //vkh_image_destroy (ctx->source); free(ctx->selectedFont.fontFile); @@ -301,10 +302,6 @@ void vkvg_new_sub_path (VkvgContext ctx){ void vkvg_new_path (VkvgContext ctx){ _clear_path(ctx); } -//path closing is done by setting the endpoint of the path to the same index -//as the start point. -//I'll test if closing by adding a new point with the same x,y as the start point -//would not make more sense. /** * @brief Close current path if at least 3 points are present * @param context pointer @@ -356,7 +353,7 @@ void vkvg_line_to (VkvgContext ctx, float x, float y) _add_point(ctx,x,y); } /** - * @brief Draw arc + * @brief Draw arc in clockwise order following angles of the trigonometric circle. * @param context pointer * @param center x coordinate * @param center y coordinate @@ -408,6 +405,15 @@ void vkvg_arc (VkvgContext ctx, float xc, float yc, float radius, float a1, floa _add_point (ctx, v.x, v.y); _set_curve_end(ctx); } +/** + * @brief Draw arc in counter clockwise order following angles of the trigonometric circle. + * @param context pointer + * @param center x coordinate + * @param center y coordinate + * @param radius + * @param start angle of arc + * @param end angle of arc + */ void vkvg_arc_negative (VkvgContext ctx, float xc, float yc, float radius, float a1, float a2) { while (a2 > a1) a2 -= 2.f*M_PIF; @@ -450,6 +456,12 @@ void vkvg_arc_negative (VkvgContext ctx, float xc, float yc, float radius, float _add_point (ctx, v.x, v.y); _set_curve_end(ctx); } +/** + * @brief move pen relative to the current point. + * @param ctx + * @param delta in the horizontal direction + * @param delta in the vertical direction + */ void vkvg_rel_move_to (VkvgContext ctx, float x, float y) { if (_current_path_is_empty(ctx)){ @@ -459,11 +471,18 @@ void vkvg_rel_move_to (VkvgContext ctx, float x, float y) vec2 cp = _get_current_position(ctx); vkvg_move_to(ctx, cp.x + x, cp.y + y); } +/** + * @brief move pen to the position given in argument + * @param ctx + * @param new x position of the pen + * @param new y position of the pen + */ void vkvg_move_to (VkvgContext ctx, float x, float y) { _finish_path(ctx); _start_sub_path(ctx, x, y); } + void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, float x3, float y3) { if (_current_path_is_empty(ctx)) vkvg_move_to(ctx, x1, y1); diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index 423ba05..e8ff1dd 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -99,7 +99,7 @@ void _set_curve_start (VkvgContext ctx) { ctx->pathes[ctx->pathPtr+ctx->curvePtr+1] = (ctx->pointCount - 1); ctx->pathes[ctx->pathPtr-1] |= PATH_HAS_CURVES_BIT; } -//set curve end point and set path has curve bit +//set curve end point and set path is curve bit void _set_curve_end (VkvgContext ctx) { ctx->pathes[ctx->pathPtr+ctx->curvePtr+2] = (ctx->pointCount - 1)|PATH_IS_CURVE_BIT; ctx->curvePtr+=2; @@ -1017,10 +1017,10 @@ void _poly_fill (VkvgContext ctx){ continue; } //close path - ctx->pathes[ptrPath] |= PATH_CLOSED_BIT;// ctx->pathes[ptrPath];//close path by setting start and end equal + ctx->pathes[ptrPath] |= PATH_CLOSED_BIT; uint32_t firstPtIdx = ctx->pathes [ptrPath] & PATH_ELT_MASK; - uint32_t lastPtIdx = ctx->pathes [ptrPath+1] & PATH_ELT_MASK;//_get_last_point_of_closed_path (ctx, ptrPath); + uint32_t lastPtIdx = ctx->pathes [ptrPath+1] & PATH_ELT_MASK; uint32_t pathPointCount = lastPtIdx - firstPtIdx + 1; VKVG_IBO_INDEX_TYPE firstVertIdx = ctx->vertCount; diff --git a/src/vkvg_context_internal.h b/src/vkvg_context_internal.h index 052813b..3e34722 100644 --- a/src/vkvg_context_internal.h +++ b/src/vkvg_context_internal.h @@ -123,8 +123,6 @@ typedef struct _vkvg_context_t { //pathes array is a list of couple (start,end) point idx refering to point array //it split points list in subpathes and tell if path is closed. - //if path is closed, end index is the same as start. - //(TODO: I should use a boolean or smthg else instead to keep last point in array) uint32_t pathPtr; //pointer in the path array, even=start point;odd=end point uint32_t* pathes; size_t sizePathes; diff --git a/src/vkvg_fonts.c b/src/vkvg_fonts.c index 6fa7af1..c38c303 100644 --- a/src/vkvg_fonts.c +++ b/src/vkvg_fonts.c @@ -33,6 +33,11 @@ void _init_fonts_cache (VkvgDevice dev){ _font_cache_t* cache = (_font_cache_t*)calloc(1, sizeof(_font_cache_t)); cache->config = FcInitLoadConfigAndFonts(); + if (!cache->config) { + fprintf(stderr, "Font config initialisation failed, consider using 'FONTCONFIG_PATH' and 'FONTCONFIG_FILE' environmane\ + variables to point to 'fonts.conf' needed for FontConfig startup"); + assert(cache->config); + } FT_CHECK_RESULT(FT_Init_FreeType(&cache->library)); diff --git a/src/vkvg_fonts.h b/src/vkvg_fonts.h index 02c1c14..d925545 100644 --- a/src/vkvg_fonts.h +++ b/src/vkvg_fonts.h @@ -43,7 +43,7 @@ FT_Error res = (f); \ if (res != 0) \ { \ - printf("Fatal : FreeType error is %d in %s at line %d\n", res, __FILE__, __LINE__); \ + fprintf(stderr,"Fatal : FreeType error is %d in %s at line %d\n", res, __FILE__, __LINE__); \ assert(res == 0); \ } \ } diff --git a/template.c b/template.c index 3cb99af..a222a84 100644 --- a/template.c +++ b/template.c @@ -1,3 +1,7 @@ +/* + * test template + */ + #include "test.h" void test(){ @@ -8,7 +12,7 @@ void test(){ int main(int argc, char *argv[]) { - perform_test (test, 600, 800); + perform_test (test, "custom test", 800, 600); return 0; } diff --git a/tests/arcs.c b/tests/arcs.c index 88a6066..6a3c56c 100644 --- a/tests/arcs.c +++ b/tests/arcs.c @@ -1,13 +1,79 @@ #include "test.h" +void draw_growing_circles (VkvgContext ctx, float y, int count) { + float x = 2; + for (int i=1; i (b)) ? (a) : (b)) #endif +#define PERFORM_TEST(testName) perform_test(testName, #testName, 1024, 768); #if defined(_WIN32) || defined(_WIN64) #define WIN32_LEAN_AND_MEAN #define NOMINMAX @@ -73,10 +74,10 @@ extern VkvgDevice device; extern VkvgSurface surf; //run test in one step -void perform_test (void(*testfunc)(void),uint32_t width, uint32_t height); +void perform_test (void(*testfunc)(void), const char* testName, uint32_t width, uint32_t height); void randomize_color (VkvgContext ctx); //run test in 3 step: init, run, clear. void init_test (uint32_t width, uint32_t height); -void run_test_func (void(*testfunc)(void),uint32_t width, uint32_t height); +void run_test_func (void(*testfunc)(void), uint32_t width, uint32_t height); void clear_test (); diff --git a/tests/common/vkengine.c b/tests/common/vkengine.c index a090177..c9cf9f3 100644 --- a/tests/common/vkengine.c +++ b/tests/common/vkengine.c @@ -258,7 +258,9 @@ void vkengine_blitter_run (VkEngine e, VkImage img, uint32_t width, uint32_t hei inline bool vkengine_should_close (VkEngine e) { return glfwWindowShouldClose (e->window); } - +void vkengine_set_title (VkEngine e, const char* title) { + glfwSetWindowTitle(e->window, title); +} VkDevice vkengine_get_device (VkEngine e){ return e->dev->dev; } diff --git a/tests/common/vkengine.h b/tests/common/vkengine.h index 056be08..9a83aba 100644 --- a/tests/common/vkengine.h +++ b/tests/common/vkengine.h @@ -51,6 +51,7 @@ void vkengine_destroy (VkEngine e); bool vkengine_should_close (VkEngine e); void vkengine_close (VkEngine e); void vkengine_dump_Infos (VkEngine e); +void vkengine_set_title (VkEngine e, const char* title); VkDevice vkengine_get_device (VkEngine e); VkPhysicalDevice vkengine_get_physical_device(VkEngine e); VkQueue vkengine_get_queue (VkEngine e); diff --git a/tests/compositing.c b/tests/compositing.c index 56e3d45..f485f92 100644 --- a/tests/compositing.c +++ b/tests/compositing.c @@ -1,6 +1,6 @@ #include "test.h" -void test(){ +void compositing(){ vkvg_surface_clear(surf); VkvgContext ctx = vkvg_create(surf); @@ -17,8 +17,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 600, 800); - + PERFORM_TEST (compositing); return 0; } diff --git a/tests/curve.c b/tests/curve.c index 38c4620..d6e3520 100644 --- a/tests/curve.c +++ b/tests/curve.c @@ -56,8 +56,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/curve2.c b/tests/curve2.c index 683c29b..dd8e1d9 100644 --- a/tests/curve2.c +++ b/tests/curve2.c @@ -20,8 +20,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/curved_rect.c b/tests/curved_rect.c index 34e739f..ceebfb0 100644 --- a/tests/curved_rect.c +++ b/tests/curved_rect.c @@ -33,8 +33,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/dashes.c b/tests/dashes.c index a0acdb1..f0fb73a 100644 --- a/tests/dashes.c +++ b/tests/dashes.c @@ -41,8 +41,6 @@ void test(){ } int main() { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/dashes2.c b/tests/dashes2.c index 8c1b26a..fe14a76 100644 --- a/tests/dashes2.c +++ b/tests/dashes2.c @@ -24,8 +24,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/fill.c b/tests/fill.c index 8813e26..eb3ed28 100644 --- a/tests/fill.c +++ b/tests/fill.c @@ -21,8 +21,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/fill_and_stroke.c b/tests/fill_and_stroke.c index 791d391..a9dd8d4 100644 --- a/tests/fill_and_stroke.c +++ b/tests/fill_and_stroke.c @@ -24,8 +24,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/gradient.c b/tests/gradient.c index c11a6dc..a474ae8 100644 --- a/tests/gradient.c +++ b/tests/gradient.c @@ -1,15 +1,40 @@ #include "test.h" -void test(){ - VkvgContext ctx = vkvg_create(surf); - - VkvgPattern pat = vkvg_pattern_create_linear(0,0,300,300); - vkvg_set_line_width(ctx, 20); +VkvgPattern create_grad (VkvgContext ctx) { + VkvgPattern pat = vkvg_pattern_create_linear(0,0,300,0); vkvg_pattern_add_color_stop(pat, 0, 1, 0, 0, 1); vkvg_pattern_add_color_stop(pat, 0.5, 0, 1, 0, 1); vkvg_pattern_add_color_stop(pat, 1, 0, 0, 1, 1); + return pat; +} + +void paint(){ + VkvgContext ctx = vkvg_create(surf); + VkvgPattern pat = create_grad(ctx); + vkvg_pattern_set_extend(pat,VKVG_EXTEND_NONE); + vkvg_set_source (ctx, pat); + vkvg_paint(ctx); + + vkvg_pattern_destroy (pat); + vkvg_destroy(ctx); +} +void paint_repeat(){ + VkvgContext ctx = vkvg_create(surf); + VkvgPattern pat = create_grad(ctx); + vkvg_pattern_set_extend(pat,VKVG_EXTEND_REPEAT); + vkvg_set_source (ctx, pat); + vkvg_paint(ctx); + + vkvg_pattern_destroy (pat); + vkvg_destroy(ctx); +} + +void test(){ + VkvgContext ctx = vkvg_create(surf); + VkvgPattern pat = create_grad(ctx); vkvg_set_source (ctx, pat); vkvg_rectangle(ctx,100,100,200,200); + vkvg_set_line_width(ctx, 20); //vkvg_fill (ctx); //vkvg_paint(ctx); vkvg_stroke (ctx); @@ -36,8 +61,7 @@ void test2(){ vkvg_destroy(ctx); } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST(paint); + PERFORM_TEST(paint_repeat); return 0; } diff --git a/tests/gradient_transform.c b/tests/gradient_transform.c index 6012648..ad7dadd 100644 --- a/tests/gradient_transform.c +++ b/tests/gradient_transform.c @@ -26,8 +26,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/hlines.c b/tests/hlines.c index 5c2e3f5..73837b6 100644 --- a/tests/hlines.c +++ b/tests/hlines.c @@ -29,7 +29,7 @@ void test(){ int main(int argc, char *argv[]) { - perform_test (test, 1024, 768); + PERFORM_TEST (test); return 0; } diff --git a/tests/img_surf.c b/tests/img_surf.c index 42c4797..a915f2c 100644 --- a/tests/img_surf.c +++ b/tests/img_surf.c @@ -1,4 +1,56 @@ #include "test.h" +void paint () { + VkvgContext ctx = vkvg_create(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg"); + + vkvg_set_source_surface(ctx, imgSurf, 00, 00); + vkvg_paint(ctx); + + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); +} +void paint_offset () { + VkvgContext ctx = vkvg_create(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg"); + + vkvg_set_source_surface(ctx, imgSurf, 100, 100); + vkvg_paint(ctx); + + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); +} +void paint_pattern () { + VkvgContext ctx = vkvg_create(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg"); + VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); + vkvg_set_source(ctx, pat); + vkvg_paint(ctx); + vkvg_pattern_destroy(pat); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); +} +void paint_pattern_repeat () { + VkvgContext ctx = vkvg_create(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg"); + VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); + vkvg_pattern_set_extend(pat,VKVG_EXTEND_REPEAT); + vkvg_set_source(ctx, pat); + vkvg_paint(ctx); + vkvg_pattern_destroy(pat); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); +} +void paint_pattern_pad () { + VkvgContext ctx = vkvg_create(surf); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg"); + VkvgPattern pat = vkvg_pattern_create_for_surface(imgSurf); + vkvg_pattern_set_extend(pat,VKVG_EXTEND_PAD); + vkvg_set_source(ctx, pat); + vkvg_paint(ctx); + vkvg_pattern_destroy(pat); + vkvg_surface_destroy(imgSurf); + vkvg_destroy(ctx); +} void test(){ VkvgContext ctx = vkvg_create(surf); @@ -26,8 +78,12 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); + PERFORM_TEST (paint); + PERFORM_TEST (paint_offset); + PERFORM_TEST (paint_pattern); + PERFORM_TEST (paint_pattern_repeat); + PERFORM_TEST (paint_pattern_pad); + PERFORM_TEST (test); return 0; } diff --git a/tests/line_caps.c b/tests/line_caps.c index 674ebb3..5629be1 100644 --- a/tests/line_caps.c +++ b/tests/line_caps.c @@ -52,8 +52,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/line_join.c b/tests/line_join.c index 5dd2149..1ef3f51 100644 --- a/tests/line_join.c +++ b/tests/line_join.c @@ -72,8 +72,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/line_join_2.c b/tests/line_join_2.c index a6e0ea7..9cf011c 100644 --- a/tests/line_join_2.c +++ b/tests/line_join_2.c @@ -51,8 +51,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/line_join_3.c b/tests/line_join_3.c index 5e0e48b..9c41714 100644 --- a/tests/line_join_3.c +++ b/tests/line_join_3.c @@ -51,8 +51,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST(test); return 0; } diff --git a/tests/lines.c b/tests/lines.c index 28927e2..66d493f 100644 --- a/tests/lines.c +++ b/tests/lines.c @@ -34,8 +34,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST(test); return 0; } diff --git a/tests/multilines.c b/tests/multilines.c index b4616c3..cecd24b 100644 --- a/tests/multilines.c +++ b/tests/multilines.c @@ -34,8 +34,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/tests/random_cirles.c b/tests/random_cirles.c index c98cb02..f52dc23 100644 --- a/tests/random_cirles.c +++ b/tests/random_cirles.c @@ -28,8 +28,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST(test); return 0; } diff --git a/tests/random_rects.c b/tests/random_rects.c index c6d2402..0befc38 100644 --- a/tests/random_rects.c +++ b/tests/random_rects.c @@ -28,7 +28,7 @@ void test(){ int main(int argc, char *argv[]) { - perform_test (test, 800, 600); + PERFORM_TEST (test); return 0; } diff --git a/tests/rect_fill.c b/tests/rect_fill.c index 98ba1c3..8b14c3d 100644 --- a/tests/rect_fill.c +++ b/tests/rect_fill.c @@ -5,7 +5,7 @@ void test(){ VkvgContext ctx = vkvg_create(surf); - //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD); + vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_NON_ZERO); vkvg_set_source_rgba(ctx,0,0,1,0.5); vkvg_rectangle(ctx,100,100,200,200); @@ -17,10 +17,26 @@ void test(){ vkvg_destroy(ctx); } +void test_evenodd(){ + vkvg_surface_clear(surf); -int main(int argc, char *argv[]) { + VkvgContext ctx = vkvg_create(surf); + + 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); - perform_test (test, 1024, 768); + vkvg_rectangle(ctx,200,200,200,200); + vkvg_set_source_rgba(ctx,1,0,0,0.5); + vkvg_fill(ctx); + + vkvg_destroy(ctx); +} +int main(int argc, char *argv[]) { + PERFORM_TEST (test); + PERFORM_TEST (test_evenodd); return 0; } diff --git a/tests/save_restore.c b/tests/save_restore.c index 2024fef..01afe48 100644 --- a/tests/save_restore.c +++ b/tests/save_restore.c @@ -29,7 +29,7 @@ void test(){ int main(int argc, char *argv[]) { - perform_test (test, 600, 800); + PERFORM_TEST (test); return 0; } diff --git a/tests/simple_paint.c b/tests/simple_paint.c index 9ea7aae..78c27c9 100644 --- a/tests/simple_paint.c +++ b/tests/simple_paint.c @@ -1,17 +1,59 @@ #include "test.h" -void test(){ +void paint(){ VkvgContext ctx = vkvg_create(surf); vkvg_set_source_rgba(ctx,1,0,0,1); vkvg_paint(ctx); vkvg_destroy(ctx); } - +void paint_with_rotation(){ + VkvgContext ctx = vkvg_create(surf); + vkvg_rotate(ctx, 45); + vkvg_set_source_rgba(ctx,1,0,0,1); + vkvg_paint(ctx); + vkvg_destroy(ctx); +} +void paint_with_scale(){ + VkvgContext ctx = vkvg_create(surf); + vkvg_scale (ctx, 0.2,0.2); + vkvg_set_source_rgba(ctx,1,0,0,1); + vkvg_paint(ctx); + vkvg_destroy(ctx); +} +void paint_rect(){ + VkvgContext ctx = vkvg_create(surf); + vkvg_set_source_rgba(ctx,1,0,0,1); + vkvg_rectangle(ctx,100,100,300,200); + vkvg_paint(ctx); + vkvg_destroy(ctx); +} +//TODO:test failed: full screen paint instead of rotated rect +void paint_rect_with_rotation(){ + VkvgContext ctx = vkvg_create(surf); + vkvg_rotate(ctx, 45); + vkvg_set_source_rgba(ctx,1,0,0,1); + vkvg_rectangle(ctx,100,100,300,200); + vkvg_paint(ctx); + vkvg_destroy(ctx); +} +void paint_rect_with_scale(){ + VkvgContext ctx = vkvg_create(surf); + vkvg_scale (ctx, 0.2,0.2); + vkvg_set_source_rgba(ctx,1,0,0,1); + vkvg_rectangle(ctx,100,100,300,200); + vkvg_paint(ctx); + vkvg_destroy(ctx); +} int main(int argc, char *argv[]) { vkengine_dump_available_layers(); - perform_test (test, 1024, 768); + PERFORM_TEST (paint); + PERFORM_TEST (paint_with_rotation); + PERFORM_TEST (paint_with_scale); + PERFORM_TEST (paint_rect); + PERFORM_TEST (paint_rect_with_rotation); + PERFORM_TEST (paint_rect_with_scale); return 0; } diff --git a/tests/stroke.c b/tests/stroke.c index 028e9bc..a26dce7 100644 --- a/tests/stroke.c +++ b/tests/stroke.c @@ -55,7 +55,7 @@ void test(){ int main(int argc, char *argv[]) { - perform_test (test, 1024, 768); + PERFORM_TEST (test); return 0; } diff --git a/tests/svg.c b/tests/svg.c index 7d14817..24235ae 100644 --- a/tests/svg.c +++ b/tests/svg.c @@ -43,7 +43,6 @@ void test_nsvg() { } int main(int argc, char *argv[]) { - - perform_test (test_nsvg, 1024, 800); + PERFORM_TEST (test_nsvg); return 0; } diff --git a/tests/test1.c b/tests/test1.c index 07ca3b0..faf278c 100644 --- a/tests/test1.c +++ b/tests/test1.c @@ -372,7 +372,6 @@ void cairo_tests () { int main(int argc, char *argv[]) { - - perform_test (cairo_tests, 1024, 768); + PERFORM_TEST (cairo_tests); return 0; } diff --git a/tests/text.c b/tests/text.c index a7b46e5..7db0a26 100644 --- a/tests/text.c +++ b/tests/text.c @@ -154,9 +154,9 @@ void test(){ int main(int argc, char *argv[]) { - perform_test (test2, 1024, 768); - perform_test (test1, 1024, 768); - perform_test (test, 1024, 768); + PERFORM_TEST (test); + PERFORM_TEST (test1); + PERFORM_TEST (test2); return 0; } diff --git a/tests/vlines.c b/tests/vlines.c index 5ae3be4..5c128c7 100644 --- a/tests/vlines.c +++ b/tests/vlines.c @@ -29,8 +29,6 @@ void test(){ } int main(int argc, char *argv[]) { - - perform_test (test, 1024, 768); - + PERFORM_TEST (test); return 0; } diff --git a/vkh b/vkh index d13ee19..97cd46b 160000 --- a/vkh +++ b/vkh @@ -1 +1 @@ -Subproject commit d13ee198a63102ae2ec6feb3397a65a503dcc25e +Subproject commit 97cd46b439c22abca509fd971cbe4405f8801524 -- 2.47.3