From 9737dd4a89146fde9fca7b6bb0280dae427d9ca3 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 1 Oct 2021 19:31:04 +0900 Subject: [PATCH] test capi: update tvg_paint_get_bounds() utc. The api has been changed by 060564cc938f3773467b56e66ccee0562b5192e3 update it according its change. --- src/bindings/capi/thorvg_capi.h | 6 +++--- test/capi/capiPaint.cpp | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index fbe09a82..41b49616 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -807,21 +807,21 @@ TVG_EXPORT Tvg_Paint* tvg_paint_duplicate(Tvg_Paint* paint); /*! -* \brief Gets the bounding box of the Tvg_Paint object before any transformation. (BETA_API) +* \brief Gets the axis-aligned bounding box of the Tvg_Paint object. (BETA_API) * * \param[in] paint The Tvg_Paint object of which to get the bounds. * \param[out] x The x coordinate of the upper left corner of the object. * \param[out] y The y coordinate of the upper left corner of the object. * \param[out] w The width of the object. * \param[out] h The height of the object. -* \param[in] transformed if @c true, apply the transformation of the paint. +* \param[in] transformed If @c true, the transformation of the paint is taken into account, otherwise it isn't. * * \return Tvg_Result enumeration. * \retval TVG_RESULT_SUCCESS Succeed. * \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. * \retval TVG_RESULT_INSUFFICIENT_CONDITION Other errors. * -* \note Transformation of an object changes the returned values. +* \note The bounding box doesn't indicate the actual drawing region. It's the smallest rectangle that encloses the object. */ TVG_EXPORT Tvg_Result tvg_paint_get_bounds(const Tvg_Paint* paint, float* x, float* y, float* w, float* h, bool transformed); diff --git a/test/capi/capiPaint.cpp b/test/capi/capiPaint.cpp index 0ec9c609..bb040dae 100644 --- a/test/capi/capiPaint.cpp +++ b/test/capi/capiPaint.cpp @@ -142,7 +142,7 @@ TEST_CASE("Paint Bounds", "[capiPaint]") float x, y, w, h; REQUIRE(tvg_shape_append_rect(paint, 0, 10, 20, 100, 0, 0) == TVG_RESULT_SUCCESS); - REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h) == TVG_RESULT_SUCCESS); + REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h, true) == TVG_RESULT_SUCCESS); REQUIRE(x == 0); REQUIRE(y == 10); @@ -151,15 +151,25 @@ TEST_CASE("Paint Bounds", "[capiPaint]") REQUIRE(tvg_shape_reset(paint) == TVG_RESULT_SUCCESS); + REQUIRE(tvg_paint_translate(paint, 100, 100) == TVG_RESULT_SUCCESS); + REQUIRE(tvg_paint_scale(paint, 2) == TVG_RESULT_SUCCESS); + REQUIRE(tvg_shape_move_to(paint, 0, 10) == TVG_RESULT_SUCCESS); REQUIRE(tvg_shape_line_to(paint, 20, 110) == TVG_RESULT_SUCCESS); - REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h) == TVG_RESULT_SUCCESS); + REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h, false) == TVG_RESULT_SUCCESS); REQUIRE(x == 0); REQUIRE(y == 10); REQUIRE(w == 20); REQUIRE(h == 100); + REQUIRE(tvg_paint_get_bounds(paint, &x, &y, &w, &h, true) == TVG_RESULT_SUCCESS); + + REQUIRE(x == Approx(100.0f).margin(0.000001)); + REQUIRE(y == Approx(120.0f).margin(0.000001)); + REQUIRE(w == Approx(40.0f).margin(0.000001)); + REQUIRE(h == Approx(200.0f).margin(0.000001)); + REQUIRE(tvg_paint_del(paint) == TVG_RESULT_SUCCESS); }