]> O.S.I.I.S - jp/vkvg.git/commitdiff
emit draw before operator switching, status for invalid rect, wait flush_fence on...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 14 Jul 2021 20:04:08 +0000 (22:04 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 14 Jul 2021 20:04:08 +0000 (22:04 +0200)
include/vkvg.h
src/vkvg_context.c

index 1846c17ca0daa43f3d9f2a941350ddfef2071e8b..46798ec180a68f8b226f8d540b3d44f4109ee767 100644 (file)
@@ -112,6 +112,7 @@ typedef enum {
        VKVG_STATUS_INVALID_VISUAL,                     /*!< */
        VKVG_STATUS_FILE_NOT_FOUND,                     /*!< */
        VKVG_STATUS_INVALID_DASH,                       /*!< invalid value for a dash setting */
+       VKVG_STATUS_INVALID_RECT,                       /*!< invalid value for a dash setting */
 }vkvg_status_t;
 
 typedef enum {
@@ -926,7 +927,7 @@ void vkvg_curve_to (VkvgContext ctx, float x1, float y1, float x2, float y2, flo
  * @param h The height in pixel of the rectangle to draw.
  */
 vkvg_public
-void vkvg_rectangle (VkvgContext ctx, float x, float y, float w, float h);
+void vkvg_rectangle(VkvgContext ctx, float x, float y, float w, float h);
 /**
  * @brief
  *
index 76cb7de1eca87f78aea2c4fbcc07d59709b2b88c..bca11643d4d1a15a807fa538164defec84b9aab0 100644 (file)
@@ -160,7 +160,7 @@ VkvgContext vkvg_create(VkvgSurface surf)
 }
 void vkvg_flush (VkvgContext ctx){
        _flush_cmd_buff(ctx);
-       //_wait_flush_fence(ctx);
+       _wait_flush_fence(ctx);
 /*
 #ifdef DEBUG
 
@@ -457,6 +457,11 @@ void vkvg_fill_rectangle (VkvgContext ctx, float x, float y, float w, float h){
 void vkvg_rectangle (VkvgContext ctx, float x, float y, float w, float h){
        _finish_path (ctx);
 
+       if (w <= 0 || h <= 0) {
+               ctx->status = VKVG_STATUS_INVALID_RECT;
+               return;
+       }
+
        _add_point (ctx, x, y);
        _add_point (ctx, x + w, y);
        _add_point (ctx, x + w, y + h);
@@ -842,7 +847,13 @@ void vkvg_set_line_join (VkvgContext ctx, vkvg_line_join_t join){
        ctx->lineJoin = join;
 }
 void vkvg_set_operator (VkvgContext ctx, vkvg_operator_t op){
+       if (op == ctx->curOperator)
+               return;
+
+       _emit_draw_cmd_undrawn_vertices(ctx);//draw call with different ops cant be combined, so emit draw cmd for previous vertices.
+
        ctx->curOperator = op;
+
        if (ctx->cmdStarted)
                _bind_draw_pipeline (ctx);
 }