]> O.S.I.I.S - jp/vkvg.git/commitdiff
add missing vkvg_status()
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 30 Dec 2021 08:54:41 +0000 (09:54 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 30 Dec 2021 08:54:41 +0000 (09:54 +0100)
include/vkvg.h
src/vkvg_context.c

index 53b9433ad2a7e0b8768072e413630aac8cf48283..131c8110eefc6314244b60a61aa99bd5211370ce 100644 (file)
@@ -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
  *
index de719d4df89d95332b2b60cefd62780dfc7f5df8..c056bdfa7476b77257547e62aa87473c97a09900 100644 (file)
@@ -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}}}};