From f5aa347a70cd4ab3971de033f1b2ba8cc434d3f4 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 13 Jan 2025 16:38:26 +0900 Subject: [PATCH] api: renamed api for consistency API modification: - Shape::fillColor() -> Shape::fill() issue: https://github.com/thorvg/thorvg/issues/3116 --- examples/Accessor.cpp | 2 +- inc/thorvg.h | 2 +- src/bindings/capi/tvgCapi.cpp | 2 +- src/renderer/tvgPaint.cpp | 2 +- src/renderer/tvgShape.cpp | 2 +- src/renderer/tvgShape.h | 2 +- test/testAccessor.cpp | 2 +- test/testShape.cpp | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/Accessor.cpp b/examples/Accessor.cpp index fd1c5d01..5fb16e9f 100644 --- a/examples/Accessor.cpp +++ b/examples/Accessor.cpp @@ -48,7 +48,7 @@ struct UserExample : tvgexam::Example auto shape = (tvg::Shape*) paint; //override color? uint8_t r, g, b; - shape->fillColor(&r, &g, &b); + shape->fill(&r, &g, &b); if (r == 255 && g == 180 && b == 0) shape->fill(0, 0, 255); diff --git a/inc/thorvg.h b/inc/thorvg.h index b64a11b5..cc72a9fb 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -1183,7 +1183,7 @@ public: * @param[out] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque. * */ - Result fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept; + Result fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept; /** * @brief Gets the fill rule value. diff --git a/src/bindings/capi/tvgCapi.cpp b/src/bindings/capi/tvgCapi.cpp index 51ebee52..c8bd4a6c 100644 --- a/src/bindings/capi/tvgCapi.cpp +++ b/src/bindings/capi/tvgCapi.cpp @@ -510,7 +510,7 @@ TVG_API Tvg_Result tvg_shape_set_fill_color(Tvg_Paint* paint, uint8_t r, uint8_t TVG_API Tvg_Result tvg_shape_get_fill_color(const Tvg_Paint* paint, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) { if (!paint) return TVG_RESULT_INVALID_ARGUMENT; - return (Tvg_Result) reinterpret_cast(paint)->fillColor(r, g, b, a); + return (Tvg_Result) reinterpret_cast(paint)->fill(r, g, b, a); } diff --git a/src/renderer/tvgPaint.cpp b/src/renderer/tvgPaint.cpp index d3b58ae3..460500df 100644 --- a/src/renderer/tvgPaint.cpp +++ b/src/renderer/tvgPaint.cpp @@ -224,7 +224,7 @@ RenderData Paint::Impl::update(RenderMethod* renderer, const Matrix& pm, Arraytype() == Type::Shape) { auto shape = static_cast(target); uint8_t a; - shape->fillColor(nullptr, nullptr, nullptr, &a); + shape->fill(nullptr, nullptr, nullptr, &a); //no gradient fill & no maskings of the masking target. if (!shape->fill() && !(PAINT(shape)->maskData)) { if ((method == MaskMethod::Alpha && a == 255 && PAINT(shape)->opacity == 255) || (method == MaskMethod::InvAlpha && (a == 0 || PAINT(shape)->opacity == 0))) { diff --git a/src/renderer/tvgShape.cpp b/src/renderer/tvgShape.cpp index 6f743d77..ab047f78 100644 --- a/src/renderer/tvgShape.cpp +++ b/src/renderer/tvgShape.cpp @@ -124,7 +124,7 @@ Result Shape::fill(Fill* f) noexcept } -Result Shape::fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept +Result Shape::fill(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const noexcept { SHAPE(this)->rs.fillColor(r, g, b, a); return Result::Success; diff --git a/src/renderer/tvgShape.h b/src/renderer/tvgShape.h index 2d51a28c..548b2a27 100644 --- a/src/renderer/tvgShape.h +++ b/src/renderer/tvgShape.h @@ -88,7 +88,7 @@ struct Shape::Impl : Paint::Impl auto shape = static_cast(target); if (!shape->fill()) { uint8_t r, g, b, a; - shape->fillColor(&r, &g, &b, &a); + shape->fill(&r, &g, &b, &a); if (a == 0 || a == 255) { if (method == MaskMethod::Luma || method == MaskMethod::InvLuma) { if ((r == 255 && g == 255 && b == 255) || (r == 0 && g == 0 && b == 0)) return false; diff --git a/test/testAccessor.cpp b/test/testAccessor.cpp index bdae9879..f57e7da5 100644 --- a/test/testAccessor.cpp +++ b/test/testAccessor.cpp @@ -66,7 +66,7 @@ TEST_CASE("Set", "[tvgAccessor]") if (paint->type() == Type::Shape) { auto shape = (tvg::Shape*) paint; uint8_t r, g, b; - shape->fillColor(&r, &g, &b); + shape->fill(&r, &g, &b); if (r == 37 && g == 47 && b == 53) { shape->fill(0, 0, 255); shape->id = Accessor::id("TestAccessor"); diff --git a/test/testShape.cpp b/test/testShape.cpp index f25b2dcd..45f72690 100644 --- a/test/testShape.cpp +++ b/test/testShape.cpp @@ -208,10 +208,10 @@ TEST_CASE("Shape Filling", "[tvgShape]") //Fill Color uint8_t r, g, b, a; REQUIRE(shape->fill(255, 100, 50, 5) == Result::Success); - REQUIRE(shape->fillColor(&r, nullptr, &b, nullptr) == Result::Success); + REQUIRE(shape->fill(&r, nullptr, &b, nullptr) == Result::Success); REQUIRE(r == 255); REQUIRE(b == 50); - REQUIRE(shape->fillColor(&r, &g, &b, &a) == Result::Success); + REQUIRE(shape->fill(&r, &g, &b, &a) == Result::Success); REQUIRE(g == 100); REQUIRE(a == 5);