]> O.S.I.I.S - jp/vkvg.git/commitdiff
adjust round mitter stepping, add waitIdle at end of renderloop
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 22 Mar 2019 16:11:58 +0000 (17:11 +0100)
committerj-p <jp_bruyere@hotmail.com>
Sat, 6 Apr 2019 12:40:34 +0000 (14:40 +0200)
src/vkvg_context.c
tests/common/test.c
tests/fill.c
tests/img_surf.c
tests/line_caps.c
tests/text.c

index 4245307996bd140848c6a20b0547a10be5f9af33..aa2b5f4c16af429b720949e587a299933f00e26b 100644 (file)
@@ -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;
index 19acddcbc46ddeb2440d22382acbca6023846746..b23c39a2dd8059de1456b4b7c89e60815e084bff 100644 (file)
@@ -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);
index 0986a45aec2835dd8e7d463fe3396cdae05d07e0..612afc5ef0b6bef441b8daec72e55c81973efa70 100644 (file)
@@ -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);
index be9bb053390e1fa51623eb0ce63531b9fe400f01..81241abe67e76eccd06e96917d63edd7976839af 100644 (file)
@@ -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);
 
index c348d4a04c7f4682cd55c4332e4a89db72f19913..674ebb3fde7d094c1216f64be745dea0ccfdd4f9 100644 (file)
@@ -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);
index 67ebbb48faa60ee2162e1871496a22cb56908e75..a7b46e53925ddc7add2b1a27c9e3abbfced6e6bc 100644 (file)
@@ -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;
 }