common: clarification of returned types

The functions setting stroke's features always
returned a true. Returnig a boolen was a remnant
from a previous implementation. Since now they
never return false, they can be void functions.
The APIs description has been corrected.
This commit is contained in:
Mira Grudzinska 2024-06-05 05:36:37 +02:00 committed by Hermet Park
parent 20a0d1379e
commit 61de65e10b
4 changed files with 22 additions and 49 deletions

View file

@ -982,7 +982,7 @@ public:
* *
* @param[in] width The width of the stroke. The default value is 0. * @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; 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] 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. * @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; 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. * @param[in] f The gradient fill.
* *
* @retval Result::Success When succeed. * @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 or an error with accessing it.
* @retval Result::MemoryCorruption In case a @c nullptr is passed as the argument.
*/ */
Result stroke(std::unique_ptr<Fill> f) noexcept; Result stroke(std::unique_ptr<Fill> f) noexcept;
@ -1029,7 +1028,7 @@ public:
* *
* @param[in] cap The cap style value. The default value is @c StrokeCap::Square. * @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; Result stroke(StrokeCap cap) noexcept;
@ -1040,7 +1039,7 @@ public:
* *
* @param[in] join The join style value. The default value is @c StrokeJoin::Bevel. * @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; 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. * @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 * @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). * @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 * @since 0.10
*/ */

View file

@ -1305,7 +1305,6 @@ TVG_API Tvg_Result tvg_shape_get_path_commands(const Tvg_Paint* paint, const Tvg
* \return Tvg_Result enumeration. * \return Tvg_Result enumeration.
* \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_SUCCESS Succeed.
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. * \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); 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. * \return Tvg_Result enumeration.
* \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_SUCCESS Succeed.
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. * \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. * \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. * \return Tvg_Result enumeration.
* \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_SUCCESS Succeed.
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. * \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 or an error with accessing it.
* \retval TVG_RESULT_MEMORY_CORRUPTION An invalid Tvg_Gradient pointer.
* *
* \note Either a solid color or a gradient fill is applied, depending on what was set as last. * \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. * \return Tvg_Result enumeration.
* \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_SUCCESS Succeed.
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. * \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 or an error with accessing it.
* \retval TVG_RESULT_MEMORY_CORRUPTION An invalid Tvg_Gradient pointer.
* *
* \note Either a solid color or a gradient fill is applied, depending on what was set as last. * \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. * \return Tvg_Result enumeration.
* \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_SUCCESS Succeed.
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. * \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); 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. * \return Tvg_Result enumeration.
* \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_SUCCESS Succeed.
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. * \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); 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. * \return Tvg_Result enumeration.
* \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_SUCCESS Succeed.
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. * \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer.
* \retval TVG_RESULT_NOT_SUPPORTED Unsupported value. * \retval TVG_RESULT_NOT_SUPPORTED Unsupported @p miterlimit values (less than zero).
* \retval TVG_RESULT_FAILED_ALLOCATION An internal error with a memory allocation.
* *
* \since 0.11 * \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. * \return Tvg_Result enumeration.
* \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_SUCCESS Succeed.
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. * \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 * \since 0.10
*/ */

View file

@ -287,16 +287,14 @@ const Fill* Shape::fill() const noexcept
Result Shape::order(bool strokeFirst) noexcept Result Shape::order(bool strokeFirst) noexcept
{ {
if (!pImpl->strokeFirst(strokeFirst)) return Result::FailedAllocation; pImpl->strokeFirst(strokeFirst);
return Result::Success; return Result::Success;
} }
Result Shape::stroke(float width) noexcept Result Shape::stroke(float width) noexcept
{ {
if (!pImpl->strokeWidth(width)) return Result::FailedAllocation; pImpl->strokeWidth(width);
return Result::Success; 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 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; return Result::Success;
} }
@ -349,16 +346,14 @@ uint32_t Shape::strokeDash(const float** dashPattern) const noexcept
Result Shape::stroke(StrokeCap cap) noexcept Result Shape::stroke(StrokeCap cap) noexcept
{ {
if (!pImpl->strokeCap(cap)) return Result::FailedAllocation; pImpl->strokeCap(cap);
return Result::Success; return Result::Success;
} }
Result Shape::stroke(StrokeJoin join) noexcept Result Shape::stroke(StrokeJoin join) noexcept
{ {
if (!pImpl->strokeJoin(join)) return Result::FailedAllocation; pImpl->strokeJoin(join);
return Result::Success; 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. // - 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::NonSupport;
// TODO Find out a reasonable max value. // TODO Find out a reasonable max value.
if (!pImpl->strokeMiterlimit(miterlimit)) return Result::FailedAllocation; pImpl->strokeMiterlimit(miterlimit);
return Result::Success; return Result::Success;
} }

View file

@ -207,13 +207,11 @@ struct Shape::Impl
flag |= RenderUpdateFlag::Path; flag |= RenderUpdateFlag::Path;
} }
bool strokeWidth(float width) void strokeWidth(float width)
{ {
if (!rs.stroke) rs.stroke = new RenderStroke(); if (!rs.stroke) rs.stroke = new RenderStroke();
rs.stroke->width = width; rs.stroke->width = width;
flag |= RenderUpdateFlag::Stroke; flag |= RenderUpdateFlag::Stroke;
return true;
} }
void strokeTrim(float begin, float end, bool simultaneous) 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(); if (!rs.stroke) rs.stroke = new RenderStroke();
rs.stroke->cap = cap; rs.stroke->cap = cap;
flag |= RenderUpdateFlag::Stroke; flag |= RenderUpdateFlag::Stroke;
return true;
} }
bool strokeJoin(StrokeJoin join) void strokeJoin(StrokeJoin join)
{ {
if (!rs.stroke) rs.stroke = new RenderStroke(); if (!rs.stroke) rs.stroke = new RenderStroke();
rs.stroke->join = join; rs.stroke->join = join;
flag |= RenderUpdateFlag::Stroke; flag |= RenderUpdateFlag::Stroke;
return true;
} }
bool strokeMiterlimit(float miterlimit) void strokeMiterlimit(float miterlimit)
{ {
if (!rs.stroke) rs.stroke = new RenderStroke(); if (!rs.stroke) rs.stroke = new RenderStroke();
rs.stroke->miterlimit = miterlimit; rs.stroke->miterlimit = miterlimit;
flag |= RenderUpdateFlag::Stroke; 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) rs.stroke = new RenderStroke();
if (rs.stroke->fill) { if (rs.stroke->fill) {
@ -304,8 +296,6 @@ struct Shape::Impl
rs.stroke->color[3] = a; rs.stroke->color[3] = a;
flag |= RenderUpdateFlag::Stroke; flag |= RenderUpdateFlag::Stroke;
return true;
} }
Result strokeFill(unique_ptr<Fill> f) Result strokeFill(unique_ptr<Fill> f)
@ -364,13 +354,11 @@ struct Shape::Impl
return rs.stroke->strokeFirst; return rs.stroke->strokeFirst;
} }
bool strokeFirst(bool strokeFirst) void strokeFirst(bool strokeFirst)
{ {
if (!rs.stroke) rs.stroke = new RenderStroke(); if (!rs.stroke) rs.stroke = new RenderStroke();
rs.stroke->strokeFirst = strokeFirst; rs.stroke->strokeFirst = strokeFirst;
flag |= RenderUpdateFlag::Stroke; flag |= RenderUpdateFlag::Stroke;
return true;
} }
void update(RenderUpdateFlag flag) void update(RenderUpdateFlag flag)