diff --git a/inc/thorvg.h b/inc/thorvg.h index a3d757a3..f4b847f6 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -982,7 +982,7 @@ public: * * @param[in] width The width of the stroke. The default value is 0. * - * @retval Result::Success when succeed, Result::FailedAllocation otherwise. + * @retval Result::Success when succeed. */ Result stroke(float width) noexcept; @@ -994,7 +994,7 @@ public: * @param[in] b The blue color channel value in the range [0 ~ 255]. The default value is 0. * @param[in] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque. The default value is 0. * - * @retval Result::Success when succeed, Result::FailedAllocation otherwise. + * @retval Result::Success when succeed. */ Result stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept; @@ -1004,8 +1004,7 @@ public: * @param[in] f The gradient fill. * * @retval Result::Success When succeed. - * @retval Result::FailedAllocation An internal error with a memory allocation for an object to be filled. - * @retval Result::MemoryCorruption In case a @c nullptr is passed as the argument. + * @retval Result::MemoryCorruption In case a @c nullptr is passed as the argument or an error with accessing it. */ Result stroke(std::unique_ptr f) noexcept; @@ -1029,7 +1028,7 @@ public: * * @param[in] cap The cap style value. The default value is @c StrokeCap::Square. * - * @retval Result::Success when succeed, Result::FailedAllocation otherwise. + * @retval Result::Success when succeed. */ Result stroke(StrokeCap cap) noexcept; @@ -1040,7 +1039,7 @@ public: * * @param[in] join The join style value. The default value is @c StrokeJoin::Bevel. * - * @retval Result::Success when succeed, Result::FailedAllocation otherwise. + * @retval Result::Success when succeed. */ Result stroke(StrokeJoin join) noexcept; @@ -1049,7 +1048,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, Result::NonSupport unsupported value, Result::FailedAllocation otherwise. + * @retval Result::Success when succeed or Result::NonSupport for @p miterlimit values less than zero. * * @since 0.11 */ @@ -1115,7 +1114,7 @@ public: * * @param[in] strokeFirst If @c true the stroke is rendered before the fill, otherwise the stroke is rendered as the second one (the default option). * - * @retval Result::Success when succeed, Result::FailedAllocation otherwise. + * @retval Result::Success when succeed. * * @since 0.10 */ diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index 97233862..acbb006c 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -1305,7 +1305,6 @@ TVG_API Tvg_Result tvg_shape_get_path_commands(const Tvg_Paint* paint, const Tvg * \return Tvg_Result enumeration. * \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. -* \retval TVG_RESULT_FAILED_ALLOCATION An internal error with a memory allocation. */ TVG_API Tvg_Result tvg_shape_set_stroke_width(Tvg_Paint* paint, float width); @@ -1335,7 +1334,6 @@ TVG_API Tvg_Result tvg_shape_get_stroke_width(const Tvg_Paint* paint, float* wid * \return Tvg_Result enumeration. * \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. -* \retval TVG_RESULT_FAILED_ALLOCATION An internal error with a memory allocation. * * \note Either a solid color or a gradient fill is applied, depending on what was set as last. */ @@ -1368,8 +1366,7 @@ TVG_API Tvg_Result tvg_shape_get_stroke_color(const Tvg_Paint* paint, uint8_t* r * \return Tvg_Result enumeration. * \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. -* \retval TVG_RESULT_FAILED_ALLOCATION An internal error with a memory allocation. -* \retval TVG_RESULT_MEMORY_CORRUPTION An invalid Tvg_Gradient pointer. +* \retval TVG_RESULT_MEMORY_CORRUPTION An invalid Tvg_Gradient pointer or an error with accessing it. * * \note Either a solid color or a gradient fill is applied, depending on what was set as last. */ @@ -1385,8 +1382,7 @@ TVG_API Tvg_Result tvg_shape_set_stroke_linear_gradient(Tvg_Paint* paint, Tvg_Gr * \return Tvg_Result enumeration. * \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. -* \retval TVG_RESULT_FAILED_ALLOCATION An internal error with a memory allocation. -* \retval TVG_RESULT_MEMORY_CORRUPTION An invalid Tvg_Gradient pointer. +* \retval TVG_RESULT_MEMORY_CORRUPTION An invalid Tvg_Gradient pointer or an error with accessing it. * * \note Either a solid color or a gradient fill is applied, depending on what was set as last. */ @@ -1459,7 +1455,6 @@ TVG_API Tvg_Result tvg_shape_get_stroke_dash(const Tvg_Paint* paint, const float * \return Tvg_Result enumeration. * \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. -* \retval TVG_RESULT_FAILED_ALLOCATION An internal error with a memory allocation. */ TVG_API Tvg_Result tvg_shape_set_stroke_cap(Tvg_Paint* paint, Tvg_Stroke_Cap cap); @@ -1486,7 +1481,6 @@ TVG_API Tvg_Result tvg_shape_get_stroke_cap(const Tvg_Paint* paint, Tvg_Stroke_C * \return Tvg_Result enumeration. * \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. -* \retval TVG_RESULT_FAILED_ALLOCATION An internal error with a memory allocation. */ TVG_API Tvg_Result tvg_shape_set_stroke_join(Tvg_Paint* paint, Tvg_Stroke_Join join); @@ -1513,8 +1507,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 value. -* \retval TVG_RESULT_FAILED_ALLOCATION An internal error with a memory allocation. +* \retval TVG_RESULT_NOT_SUPPORTED Unsupported @p miterlimit values (less than zero). * * \since 0.11 */ @@ -1639,7 +1632,6 @@ TVG_API Tvg_Result tvg_shape_get_fill_rule(const Tvg_Paint* paint, Tvg_Fill_Rule * \return Tvg_Result enumeration. * \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. -* \retval TVG_RESULT_FAILED_ALLOCATION An internal error with a memory allocation. * * \since 0.10 */ diff --git a/src/renderer/tvgShape.cpp b/src/renderer/tvgShape.cpp index 8305d066..0835b217 100644 --- a/src/renderer/tvgShape.cpp +++ b/src/renderer/tvgShape.cpp @@ -287,16 +287,14 @@ const Fill* Shape::fill() const noexcept Result Shape::order(bool strokeFirst) noexcept { - if (!pImpl->strokeFirst(strokeFirst)) return Result::FailedAllocation; - + pImpl->strokeFirst(strokeFirst); return Result::Success; } Result Shape::stroke(float width) noexcept { - if (!pImpl->strokeWidth(width)) return Result::FailedAllocation; - + pImpl->strokeWidth(width); return Result::Success; } @@ -309,8 +307,7 @@ float Shape::strokeWidth() const noexcept Result Shape::stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept { - if (!pImpl->strokeColor(r, g, b, a)) return Result::FailedAllocation; - + pImpl->strokeColor(r, g, b, a); return Result::Success; } @@ -349,16 +346,14 @@ uint32_t Shape::strokeDash(const float** dashPattern) const noexcept Result Shape::stroke(StrokeCap cap) noexcept { - if (!pImpl->strokeCap(cap)) return Result::FailedAllocation; - + pImpl->strokeCap(cap); return Result::Success; } Result Shape::stroke(StrokeJoin join) noexcept { - if (!pImpl->strokeJoin(join)) return Result::FailedAllocation; - + pImpl->strokeJoin(join); return Result::Success; } @@ -369,8 +364,7 @@ Result Shape::strokeMiterlimit(float miterlimit) noexcept // - A negative value for stroke-miterlimit must be treated as an illegal value. if (miterlimit < 0.0f) return Result::NonSupport; // TODO Find out a reasonable max value. - if (!pImpl->strokeMiterlimit(miterlimit)) return Result::FailedAllocation; - + pImpl->strokeMiterlimit(miterlimit); return Result::Success; } diff --git a/src/renderer/tvgShape.h b/src/renderer/tvgShape.h index c57550f2..4e85db37 100644 --- a/src/renderer/tvgShape.h +++ b/src/renderer/tvgShape.h @@ -207,13 +207,11 @@ struct Shape::Impl flag |= RenderUpdateFlag::Path; } - bool strokeWidth(float width) + void strokeWidth(float width) { if (!rs.stroke) rs.stroke = new RenderStroke(); rs.stroke->width = width; flag |= RenderUpdateFlag::Stroke; - - return true; } void strokeTrim(float begin, float end, bool simultaneous) @@ -262,34 +260,28 @@ struct Shape::Impl } } - bool strokeCap(StrokeCap cap) + void strokeCap(StrokeCap cap) { if (!rs.stroke) rs.stroke = new RenderStroke(); rs.stroke->cap = cap; flag |= RenderUpdateFlag::Stroke; - - return true; } - bool strokeJoin(StrokeJoin join) + void strokeJoin(StrokeJoin join) { if (!rs.stroke) rs.stroke = new RenderStroke(); rs.stroke->join = join; flag |= RenderUpdateFlag::Stroke; - - return true; } - bool strokeMiterlimit(float miterlimit) + void strokeMiterlimit(float miterlimit) { if (!rs.stroke) rs.stroke = new RenderStroke(); rs.stroke->miterlimit = miterlimit; flag |= RenderUpdateFlag::Stroke; - - return true; } - bool strokeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) + void strokeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { if (!rs.stroke) rs.stroke = new RenderStroke(); if (rs.stroke->fill) { @@ -304,8 +296,6 @@ struct Shape::Impl rs.stroke->color[3] = a; flag |= RenderUpdateFlag::Stroke; - - return true; } Result strokeFill(unique_ptr f) @@ -364,13 +354,11 @@ struct Shape::Impl return rs.stroke->strokeFirst; } - bool strokeFirst(bool strokeFirst) + void strokeFirst(bool strokeFirst) { if (!rs.stroke) rs.stroke = new RenderStroke(); rs.stroke->strokeFirst = strokeFirst; flag |= RenderUpdateFlag::Stroke; - - return true; } void update(RenderUpdateFlag flag)