From ca341cbb6329b5d6c6060588b81956553b07a0c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Fri, 22 Mar 2019 17:11:58 +0100 Subject: [PATCH] adjust round mitter stepping, add waitIdle at end of renderloop --- src/vkvg_context.c | 6 +++--- tests/common/test.c | 7 ++++++- tests/fill.c | 16 ++++++---------- tests/img_surf.c | 33 ++++++++++++++++----------------- tests/line_caps.c | 8 +++++--- tests/text.c | 10 ++++++---- 6 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 4245307..aa2b5f4 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -445,7 +445,7 @@ void _poly_fill (VkvgContext ctx){ while (ptrPath < ctx->pathPtr){ if (!_path_is_closed(ctx, ptrPath)) - ctx->pathes[ptrPath+1] = ctx->pathes[ptrPath]; + ctx->pathes[ptrPath+1] = ctx->pathes[ptrPath];//close path by setting start and end equal uint32_t firstPtIdx = ctx->pathes[ptrPath]; uint32_t lastPtIdx = _get_last_point_of_closed_path (ctx, ptrPath); @@ -548,7 +548,7 @@ void vkvg_stroke_preserve (VkvgContext ctx) vhw = vec2_perp(vhw); if (ctx->lineCap == VKVG_LINE_CAP_ROUND){ - float step = M_PI_2 / hw; + float step = M_PI / hw; float a = acos(n.x) + M_PI_2; if (n.y < 0) a = M_PI-a; @@ -598,7 +598,7 @@ void vkvg_stroke_preserve (VkvgContext ctx) if (ctx->lineCap == VKVG_LINE_CAP_ROUND){ firstIdx = ctx->vertCount; - float step = M_PI_2 / hw; + float step = M_PI / hw; float a = acos(n.x)+ M_PI_2; if (n.y < 0) a = M_PI-a; diff --git a/tests/common/test.c b/tests/common/test.c index 19acddc..b23c39a 100644 --- a/tests/common/test.c +++ b/tests/common/test.c @@ -76,7 +76,10 @@ void perform_test (void(*testfunc)(void),uint width, uint height) { bool deferredResolve = false; - device = vkvg_device_create_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, VK_SAMPLE_COUNT_4_BIT, deferredResolve); + device = vkvg_device_create_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, VK_SAMPLE_COUNT_8_BIT, deferredResolve); + + vkvg_device_set_dpy(device, 96, 96); + surf = vkvg_surface_create(device, width, height); vkvg_surface_clear(surf); @@ -98,6 +101,8 @@ void perform_test (void(*testfunc)(void),uint width, uint height) { if (!vkh_presenter_draw (r)) vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), width, height); + vkDeviceWaitIdle(e->dev->dev); + gettimeofday(&after , NULL); frameTimeAccum += time_diff(before , after); diff --git a/tests/fill.c b/tests/fill.c index 0986a45..612afc5 100644 --- a/tests/fill.c +++ b/tests/fill.c @@ -4,18 +4,14 @@ void test(){ VkvgContext ctx = vkvg_create(surf); vkvg_set_source_rgba(ctx,0.1,0.9,0.1,1.0); - vkvg_move_to(ctx,10,10); + vkvg_move_to(ctx,100,100); vkvg_rel_line_to(ctx,100,100); vkvg_rel_line_to(ctx,100,-100); - vkvg_rel_line_to(ctx,100,400); -// vkvg_line_to(ctx,400,350); -// vkvg_line_to(ctx,900,150); -// vkvg_line_to(ctx,700,450); -// vkvg_line_to(ctx,900,750); -// vkvg_line_to(ctx,500,650); -// vkvg_line_to(ctx,100,800); -// vkvg_line_to(ctx,150,400); - vkvg_close_path(ctx); + vkvg_rel_line_to(ctx,100,200); + vkvg_rel_line_to(ctx,-100,100); + vkvg_rel_line_to(ctx,-100,-100); + vkvg_rel_line_to(ctx,-100,-50); + //vkvg_close_path(ctx); vkvg_fill(ctx); vkvg_destroy(ctx); diff --git a/tests/img_surf.c b/tests/img_surf.c index be9bb05..81241ab 100644 --- a/tests/img_surf.c +++ b/tests/img_surf.c @@ -3,23 +3,22 @@ void test(){ VkvgContext ctx = vkvg_create(surf); - VkvgSurface imgSurf;// = vkvg_surface_create_from_image(device, "/mnt/data/images/blason.png"); - //VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "/mnt/data/images/2000px-Tux.svg.png"); - //VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "/mnt/data/images/path2674.png"); - //VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "/mnt/data/images/horse-black-head-shape-of-a-chess-piece_318-52446.jpg"); - /*vkvg_set_source_surface(ctx, imgSurf, 200, 200); - vkvg_paint(ctx); - vkvg_set_source_surface(ctx, imgSurf, 400, 400); - vkvg_paint(ctx); - vkvg_flush(ctx); - vkvg_surface_destroy(imgSurf);*/ - - imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg"); - fflush(stdout); - vkvg_set_source_surface(ctx, imgSurf, 0, 0); - vkvg_paint(ctx); - //vkvg_flush(ctx); - //vkvg_set_source_rgba(ctx,1,0,0,1); + VkvgSurface imgSurf = vkvg_surface_create_from_image(device, "data/miroir.jpg"); + + vkvg_translate(ctx,200,200); + //vkvg_rotate(ctx,M_PI_4); + + vkvg_set_line_width(ctx,20.f); + vkvg_set_source_rgba(ctx,1,0,0,1); + vkvg_arc(ctx,200,200,200,0,2.f*M_PI); + vkvg_new_sub_path(ctx); + vkvg_arc(ctx,200,200,100,0,2.f*M_PI); + + vkvg_set_source_surface(ctx, imgSurf, 00, 00); + vkvg_fill_preserve(ctx); + vkvg_set_source_rgba(ctx,0.2,0.3,0.8,1); + + vkvg_stroke(ctx); vkvg_surface_destroy(imgSurf); diff --git a/tests/line_caps.c b/tests/line_caps.c index c348d4a..674ebb3 100644 --- a/tests/line_caps.c +++ b/tests/line_caps.c @@ -2,12 +2,14 @@ void test(){ VkvgContext ctx = vkvg_create(surf); + vkvg_set_source_rgba(ctx,0.9,0.9,0.9,1); + vkvg_paint(ctx); - float x = 20, y = 20, dx = 30, dy = 60; + float x = 20, y = 20, dx = 40, dy = 60; //vkvg_scale(ctx,5,5); - vkvg_set_line_width(ctx,26); - vkvg_set_source_rgba(ctx,0,0,0,1); + vkvg_set_line_width(ctx,30); + vkvg_set_source_rgba(ctx,0.0,0.0,0,1); vkvg_move_to(ctx,x,y); vkvg_rel_line_to(ctx,0,dy); vkvg_stroke(ctx); diff --git a/tests/text.c b/tests/text.c index 67ebbb4..a7b46e5 100644 --- a/tests/text.c +++ b/tests/text.c @@ -11,8 +11,8 @@ void print(VkvgContext ctx, float penY, uint32_t size) { void test2() { VkvgContext ctx = vkvg_create(surf); - vkvg_color_t bg = {0.3,0.3,0.3,1}; - vkvg_color_t fg = {0.9,0.9,0.9,1}; + vkvg_color_t bg = {0.0,0.0,0.0,1}; + vkvg_color_t fg = {1.0,1.0,1.0,1}; vkvg_set_source_rgba(ctx,bg.r,bg.g,bg.b,bg.a); vkvg_paint(ctx); @@ -23,7 +23,7 @@ void test2() { float penY = 10.f; - for (uint32_t size=8;size<39;size++) { + for (uint32_t size=4;size<39;size++) { print(ctx,penY+=size,size); } @@ -67,7 +67,7 @@ void test(){ //vkvg_color_t fg = {0.2,0.2,0.2,1}; vkvg_color_t fg = {0.0,0.0,0.0,1}; - vkvg_color_t bg = {0.9,0.9,0.9,1}; + vkvg_color_t bg = {1.0,1.0,1.0,1}; vkvg_set_source_rgba(ctx,bg.r,bg.g,bg.b,bg.a); vkvg_paint(ctx); @@ -155,6 +155,8 @@ void test(){ int main(int argc, char *argv[]) { perform_test (test2, 1024, 768); + perform_test (test1, 1024, 768); + perform_test (test, 1024, 768); return 0; } -- 2.47.3