From 9b3030f45f69a376603ad57d8b5acb4b0ba57c1b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Wed, 14 Jul 2021 22:04:08 +0200 Subject: [PATCH] emit draw before operator switching, status for invalid rect, wait flush_fence on vkvg_flush() --- include/vkvg.h | 3 ++- src/vkvg_context.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/vkvg.h b/include/vkvg.h index 1846c17..46798ec 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -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 * diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 76cb7de..bca1164 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -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); } -- 2.47.3