From: Jean-Philippe Bruyère Date: Thu, 30 Dec 2021 08:54:41 +0000 (+0100) Subject: add missing vkvg_status() X-Git-Tag: v0.3.0-beta~57 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=d7d28a409b2cb3c5af019887a4cf30624f16efd9;p=jp%2Fvkvg.git add missing vkvg_status() --- diff --git a/include/vkvg.h b/include/vkvg.h index 53b9433..131c811 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -97,7 +97,7 @@ extern uint8_t vkvg_log_level; * * vkvg_status_t is used to indicates errors that can occur when using vkvg. Several vkvg function directely * return result, but when using a @ref context, the last error is stored in the context and can be accessed - * with #vkvg_status. + * with @ref vkvg_status(). * * As soon as a status is not success, further operations will be canceled. */ @@ -810,6 +810,15 @@ VkvgContext vkvg_create (VkvgSurface surf); */ vkvg_public void vkvg_destroy (VkvgContext ctx); +/** + * @brief Get context status + * + * Get the current context status. + * + * @param ctx The vkvg context to query the status for. + */ +vkvg_public +vkvg_status_t vkvg_status (VkvgContext ctx); /** * @brief Increment by one the reference count on this context. * @param ctx The context to increment the reference count for. @@ -1042,9 +1051,10 @@ void vkvg_rel_quadratic_to (VkvgContext ctx, float x1, float y1, float x2, float * @param y The y coordinate of the top left corner of the rectangle to emit. * @param w The width in pixel of the rectangle to draw. * @param h The height in pixel of the rectangle to draw. + * @return VKVG_STATUS_SUCCESS or VKVG_STATUS_INVALID_RECT if width or height is equal to 0. */ vkvg_public -void vkvg_rectangle(VkvgContext ctx, float x, float y, float w, float h); +vkvg_status_t vkvg_rectangle(VkvgContext ctx, float x, float y, float w, float h); /** * @brief Stroke command * diff --git a/src/vkvg_context.c b/src/vkvg_context.c index de719d4..c056bdf 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -286,6 +286,9 @@ void vkvg_destroy (VkvgContext ctx) free(ctx); } +vkvg_status_t vkvg_status (VkvgContext ctx) { + return ctx->status; +} VkvgContext vkvg_reference (VkvgContext ctx) { ctx->references++; return ctx; @@ -526,15 +529,13 @@ void vkvg_fill_rectangle (VkvgContext ctx, float x, float y, float w, float h){ //_record_draw_cmd(ctx); } -void vkvg_rectangle (VkvgContext ctx, float x, float y, float w, float h){ +vkvg_status_t vkvg_rectangle (VkvgContext ctx, float x, float y, float w, float h){ if (ctx->status) - return; + return ctx->status; _finish_path (ctx); - if (w <= 0 || h <= 0) { - ctx->status = VKVG_STATUS_INVALID_RECT; - return; - } + if (w <= 0 || h <= 0) + return VKVG_STATUS_INVALID_RECT; _add_point (ctx, x, y); _add_point (ctx, x + w, y); @@ -544,6 +545,7 @@ void vkvg_rectangle (VkvgContext ctx, float x, float y, float w, float h){ ctx->pathes[ctx->pathPtr] |= PATH_CLOSED_BIT; _finish_path(ctx); + return VKVG_STATUS_SUCCESS; } static const VkClearAttachment clearStencil = {VK_IMAGE_ASPECT_STENCIL_BIT, 1, {{{0}}}}; static const VkClearAttachment clearColorAttach = {VK_IMAGE_ASPECT_COLOR_BIT, 0, {{{0}}}};