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 GitHub
parent 669b5badf4
commit 91187cd963
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 49 deletions

View file

@ -956,7 +956,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 strokeWidth(float width) noexcept;
@ -968,7 +968,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 strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
@ -978,8 +978,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 strokeFill(std::unique_ptr<Fill> f) noexcept;
@ -1006,7 +1005,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 strokeCap(StrokeCap cap) noexcept;
@ -1017,7 +1016,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 strokeJoin(StrokeJoin join) noexcept;
@ -1026,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, 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
*/
@ -1092,7 +1091,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
*/

View file

@ -1304,7 +1304,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);
@ -1334,7 +1333,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.
*/
@ -1367,8 +1365,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.
*/
@ -1384,8 +1381,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.
*/
@ -1455,7 +1451,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);
@ -1482,7 +1477,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);
@ -1509,8 +1503,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
*/
@ -1635,7 +1628,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
*/

View file

@ -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::strokeWidth(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::strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept
{
if (!pImpl->strokeFill(r, g, b, a)) return Result::FailedAllocation;
pImpl->strokeFill(r, g, b, a);
return Result::Success;
}
@ -349,16 +346,14 @@ uint32_t Shape::strokeDash(const float** dashPattern, float* offset) const noexc
Result Shape::strokeCap(StrokeCap cap) noexcept
{
if (!pImpl->strokeCap(cap)) return Result::FailedAllocation;
pImpl->strokeCap(cap);
return Result::Success;
}
Result Shape::strokeJoin(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;
}

View file

@ -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 strokeFill(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
void strokeFill(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<Fill> 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)