From ade5eb2e8d780b40fbcb979ce64f23e2d81d2e3d Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 5 Jun 2024 17:10:34 +0900 Subject: [PATCH] api: corrected return type. NonSupport indicates unsupported options due to disabled features or lack of system support. InvalidArgument indicates the case such as incorrect parameter values. --- inc/thorvg.h | 4 ++-- src/bindings/capi/thorvg_capi.h | 5 ++--- src/bindings/capi/tvgCapi.cpp | 1 - src/renderer/tvgShape.cpp | 2 +- test/capi/capiShape.cpp | 2 +- test/testShape.cpp | 2 +- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/inc/thorvg.h b/inc/thorvg.h index 401d8df5..11d6cc46 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -80,7 +80,7 @@ enum class Result InsufficientCondition, ///< The value returned in case the request cannot be processed - e.g. asking for properties of an object, which does not exist. FailedAllocation, ///< The value returned in case of unsuccessful memory allocation. MemoryCorruption, ///< The value returned in the event of bad memory handling - e.g. failing in pointer releasing or casting - NonSupport, ///< The value returned in case of choosing unsupported options. + NonSupport, ///< The value returned in case of choosing unsupported engine features(options). Unknown ///< The value returned in all other cases. }; @@ -1025,7 +1025,7 @@ public: * * @param[in] miterlimit The miterlimit imposes a limit on the extent of the stroke join, when the @c StrokeJoin::Miter join style is set. The default value is 4. * - * @retval Result::Success when succeed or Result::NonSupport for @p miterlimit values less than zero. + * @retval Result::Success when succeed or Result::InvalidArgument for @p miterlimit values less than zero. * * @since 0.11 */ diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index eb3ac565..5ef1a43d 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -122,7 +122,7 @@ typedef enum { TVG_RESULT_INSUFFICIENT_CONDITION, ///< The value returned in case the request cannot be processed - e.g. asking for properties of an object, which does not exist. TVG_RESULT_FAILED_ALLOCATION, ///< The value returned in case of unsuccessful memory allocation. TVG_RESULT_MEMORY_CORRUPTION, ///< The value returned in the event of bad memory handling - e.g. failing in pointer releasing or casting - TVG_RESULT_NOT_SUPPORTED, ///< The value returned in case of choosing unsupported options. + TVG_RESULT_NOT_SUPPORTED, ///< The value returned in case of choosing unsupported engine features(options). TVG_RESULT_UNKNOWN ///< The value returned in all other cases. } Tvg_Result; @@ -1502,8 +1502,7 @@ TVG_API Tvg_Result tvg_shape_get_stroke_join(const Tvg_Paint* paint, Tvg_Stroke_ * * \return Tvg_Result enumeration. * \retval TVG_RESULT_SUCCESS Succeed. -* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. -* \retval TVG_RESULT_NOT_SUPPORTED Unsupported @p miterlimit values (less than zero). +* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer or Unsupported @p miterlimit values (less than zero). * * \since 0.11 */ diff --git a/src/bindings/capi/tvgCapi.cpp b/src/bindings/capi/tvgCapi.cpp index aaf3b0c7..809d7931 100644 --- a/src/bindings/capi/tvgCapi.cpp +++ b/src/bindings/capi/tvgCapi.cpp @@ -447,7 +447,6 @@ TVG_API Tvg_Result tvg_shape_get_stroke_join(const Tvg_Paint* paint, Tvg_Stroke_ TVG_API Tvg_Result tvg_shape_set_stroke_miterlimit(Tvg_Paint* paint, float ml) { - if (ml < 0.0f) return TVG_RESULT_NOT_SUPPORTED; if (!paint) return TVG_RESULT_INVALID_ARGUMENT; return (Tvg_Result) reinterpret_cast(paint)->strokeMiterlimit(ml); } diff --git a/src/renderer/tvgShape.cpp b/src/renderer/tvgShape.cpp index 28af2ef8..8de343f3 100644 --- a/src/renderer/tvgShape.cpp +++ b/src/renderer/tvgShape.cpp @@ -362,7 +362,7 @@ Result Shape::strokeMiterlimit(float miterlimit) noexcept { // https://www.w3.org/TR/SVG2/painting.html#LineJoin // - A negative value for stroke-miterlimit must be treated as an illegal value. - if (miterlimit < 0.0f) return Result::NonSupport; + if (miterlimit < 0.0f) return Result::InvalidArguments; // TODO Find out a reasonable max value. pImpl->strokeMiterlimit(miterlimit); return Result::Success; diff --git a/test/capi/capiShape.cpp b/test/capi/capiShape.cpp index 66ca9504..fefc4ac5 100644 --- a/test/capi/capiShape.cpp +++ b/test/capi/capiShape.cpp @@ -242,7 +242,7 @@ TEST_CASE("Stroke join", "[capiStrokeJoin]") REQUIRE(tvg_shape_get_stroke_miterlimit(paint, &ml) == TVG_RESULT_SUCCESS); REQUIRE(ml == 1000.0f); - REQUIRE(tvg_shape_set_stroke_miterlimit(paint, -0.001f) == TVG_RESULT_NOT_SUPPORTED); + REQUIRE(tvg_shape_set_stroke_miterlimit(paint, -0.001f) == TVG_RESULT_INVALID_ARGUMENT); REQUIRE(tvg_shape_get_stroke_miterlimit(paint, &ml) == TVG_RESULT_SUCCESS); REQUIRE(ml == 1000.0f); diff --git a/test/testShape.cpp b/test/testShape.cpp index 8f2ca7e5..077296fe 100644 --- a/test/testShape.cpp +++ b/test/testShape.cpp @@ -201,7 +201,7 @@ TEST_CASE("Stroking", "[tvgShape]") REQUIRE(shape->strokeMiterlimit() == 0.00001f); REQUIRE(shape->strokeMiterlimit(1000.0f) == Result::Success); REQUIRE(shape->strokeMiterlimit() == 1000.0f); - REQUIRE(shape->strokeMiterlimit(-0.001f) == Result::NonSupport); + REQUIRE(shape->strokeMiterlimit(-0.001f) == Result::InvalidArguments); //Stroke Trim float begin, end;