From 01559a45c0466db8eaff48f27d57edd94f7a55bc Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 7 Oct 2024 20:34:11 +0900 Subject: [PATCH] api: remove deprecations issue: https://github.com/thorvg/thorvg/issues/1372 --- inc/thorvg.h | 54 ---------------------- src/bindings/capi/thorvg_capi.h | 81 --------------------------------- src/bindings/capi/tvgCapi.cpp | 29 ------------ src/renderer/tvgAccessor.cpp | 14 ------ src/renderer/tvgFill.cpp | 18 -------- src/renderer/tvgPaint.cpp | 6 --- src/renderer/tvgPicture.cpp | 6 --- src/renderer/tvgScene.cpp | 6 --- src/renderer/tvgShape.cpp | 68 --------------------------- 9 files changed, 282 deletions(-) diff --git a/inc/thorvg.h b/inc/thorvg.h index d82e60b4..502ac5de 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -457,11 +457,6 @@ public: */ uint32_t id = 0; - /** - * @see Paint::type() - */ - TVG_DEPRECATED uint32_t identifier() const noexcept; - _TVG_DECLARE_PRIVATE(Paint); }; @@ -563,11 +558,6 @@ public: */ virtual Type type() const noexcept = 0; - /** - * @see Fill::type() - */ - TVG_DEPRECATED uint32_t identifier() const noexcept; - _TVG_DECLARE_PRIVATE(Fill); }; @@ -751,11 +741,6 @@ public: */ Type type() const noexcept override; - /** - * @see LinearGradient::type() - */ - TVG_DEPRECATED static uint32_t identifier() noexcept; - _TVG_DECLARE_PRIVATE(LinearGradient); }; @@ -816,11 +801,6 @@ public: */ Type type() const noexcept override; - /** - * @see RadialGradient::type() - */ - TVG_DEPRECATED static uint32_t identifier() noexcept; - _TVG_DECLARE_PRIVATE(RadialGradient); }; @@ -940,23 +920,6 @@ public: */ Result appendCircle(float cx, float cy, float rx, float ry) noexcept; - /** - * @brief Appends a circular arc to the path. - * - * The arc is treated as a new sub-path - it is not connected with the previous sub-path. - * The current point value is set to the end-point of the arc in case @p pie is @c false, and to the center of the arc otherwise. - * - * @param[in] cx The horizontal coordinate of the center of the arc. - * @param[in] cy The vertical coordinate of the center of the arc. - * @param[in] radius The radius of the arc. - * @param[in] startAngle The start angle of the arc given in degrees, measured counter-clockwise from the horizontal line. - * @param[in] sweep The central angle of the arc given in degrees, measured counter-clockwise from @p startAngle. - * @param[in] pie Specifies whether to draw radii from the arc's center to both of its end-point - drawn if @c true. - * - * @note Setting @p sweep value greater than 360 degrees, is equivalent to calling appendCircle(cx, cy, radius, radius). - */ - TVG_DEPRECATED Result appendArc(float cx, float cy, float radius, float startAngle, float sweep, bool pie) noexcept; - /** * @brief Appends a given sub-path to the path. * @@ -1222,11 +1185,6 @@ public: */ Type type() const noexcept override; - /** - * @see Shape::type() - */ - TVG_DEPRECATED static uint32_t identifier() noexcept; - _TVG_DECLARE_PRIVATE(Shape); }; @@ -1356,11 +1314,6 @@ public: */ Type type() const noexcept override; - /** - * @see Picture::type() - */ - TVG_DEPRECATED static uint32_t identifier() noexcept; - _TVG_DECLARE_ACCESSOR(Animation); _TVG_DECLARE_PRIVATE(Picture); }; @@ -1454,11 +1407,6 @@ public: */ Type type() const noexcept override; - /** - * @see Scene::type() - */ - TVG_DEPRECATED static uint32_t identifier() noexcept; - _TVG_DECLARE_PRIVATE(Scene); }; @@ -2098,8 +2046,6 @@ class TVG_API Accessor final public: ~Accessor(); - TVG_DEPRECATED std::unique_ptr set(std::unique_ptr picture, std::function func) noexcept; - /** * @brief Set the access function for traversing the Picture scene tree nodes. * diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index d676f102..4920009d 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -611,37 +611,6 @@ TVG_API Tvg_Result tvg_canvas_destroy(Tvg_Canvas* canvas); TVG_API Tvg_Result tvg_canvas_push(Tvg_Canvas* canvas, Tvg_Paint* paint); -/*! -* \brief Reserves a memory block where the objects pushed into a canvas are stored. -* -* If the number of Tvg_Paints to be stored in a canvas is known in advance, calling this function reduces the multiple -* memory allocations thus improves the performance. -* -* \code -* Tvg_Canvas *canvas = NULL; -* -* tvg_engine_init(TVG_ENGINE_SW, 4); -* canvas = tvg_swcanvas_create(); -* -* uint32_t *buffer = NULL; -* buffer = (uint32_t*) malloc(sizeof(uint32_t) * 100 * 100); -* if (!buffer) return; -* -* tvg_swcanvas_set_target(canvas, buffer, 100, 100, 100, TVG_COLORSPACE_ARGB8888); -* -* tvg_canvas_destroy(canvas); -* tvg_engine_term(TVG_ENGINE_SW) -* \endcode -* -* \param[in] canvas The Tvg_Canvas object managing the reserved memory. -* \param[in] n The number of objects for which the memory is to be reserved. -* -* \return Tvg_Result enumeration. -* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Canvas pointer. -*/ -TVG_DEPRECATED TVG_API Tvg_Result tvg_canvas_reserve(Tvg_Canvas* canvas, uint32_t n); - - /*! * \brief Sets the total number of the paints pushed into the canvas to be zero. * Tvg_Paint objects stored in the canvas are released if @p paints is set to @c true, otherwise the memory is not deallocated and @@ -1029,12 +998,6 @@ TVG_API Tvg_Result tvg_paint_set_clip(Tvg_Paint* paint, Tvg_Paint* clipper); TVG_API Tvg_Result tvg_paint_get_type(const Tvg_Paint* paint, Tvg_Type* type); -/** -* \see tvg_paint_get_type() -*/ -TVG_DEPRECATED TVG_API Tvg_Result tvg_paint_get_identifier(const Tvg_Paint* paint, Tvg_Identifier* identifier); - - /** * @brief Sets the blending method for the paint object. * @@ -1215,28 +1178,6 @@ TVG_API Tvg_Result tvg_shape_append_rect(Tvg_Paint* paint, float x, float y, flo TVG_API Tvg_Result tvg_shape_append_circle(Tvg_Paint* paint, float cx, float cy, float rx, float ry); -/*! -* \brief Appends a circular arc to the path. -* -* The arc is treated as a new sub-path - it is not connected with the previous sub-path. -* The current point value is set to the end-point of the arc in case @p pie is @c false, and to the center of the arc otherwise. -* -* \param[in] paint A Tvg_Paint pointer to the shape object. -* \param[in] cx The horizontal coordinate of the center of the arc. -* \param[in] cy The vertical coordinate of the center of the arc. -* \param[in] radius The radius of the arc. -* \param[in] startAngle The start angle of the arc given in degrees, measured counter-clockwise from the horizontal line. -* \param[in] sweep The central angle of the arc given in degrees, measured counter-clockwise from @p startAngle. -* \param[in] pie Specifies whether to draw radii from the arc's center to both of its end-point - drawn if @c true. -* -* \return Tvg_Result enumeration. -* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. -* -* \note Setting @p sweep value greater than 360 degrees, is equivalent to calling tvg_shape_append_circle(paint, cx, cy, radius, radius). -*/ -TVG_DEPRECATED TVG_API Tvg_Result tvg_shape_append_arc(Tvg_Paint* paint, float cx, float cy, float radius, float startAngle, float sweep, uint8_t pie); - - /*! * \brief Appends a given sub-path to the path. * @@ -1917,12 +1858,6 @@ TVG_API Tvg_Result tvg_gradient_get_transform(const Tvg_Gradient* grad, Tvg_Matr TVG_API Tvg_Result tvg_gradient_get_type(const Tvg_Gradient* grad, Tvg_Type* type); -/** -* \see tvg_gradient_get_type() -*/ -TVG_DEPRECATED TVG_API Tvg_Result tvg_gradient_get_identifier(const Tvg_Gradient* grad, Tvg_Identifier* identifier); - - /*! * \brief Duplicates the given Tvg_Gradient object. * @@ -2103,22 +2038,6 @@ TVG_API const Tvg_Paint* tvg_picture_get_paint(Tvg_Paint* paint, uint32_t id); TVG_API Tvg_Paint* tvg_scene_new(void); -/*! -* \brief Sets the size of the container, where all the paints pushed into the scene are stored. -* -* If the number of objects pushed into the scene is known in advance, calling the function -* prevents multiple memory reallocation, thus improving the performance. -* -* \param[in] scene A Tvg_Paint pointer to the scene object. -* \param[in] size The number of objects for which the memory is to be reserved. -* -* \return Tvg_Result enumeration. -* \retval TVG_RESULT_FAILED_ALLOCATION An internal error with a memory allocation. -* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. -*/ -TVG_DEPRECATED TVG_API Tvg_Result tvg_scene_reserve(Tvg_Paint* scene, uint32_t size); - - /*! * \brief Passes drawing elements to the scene using Tvg_Paint objects. * diff --git a/src/bindings/capi/tvgCapi.cpp b/src/bindings/capi/tvgCapi.cpp index 10191ba4..ab36ea9a 100644 --- a/src/bindings/capi/tvgCapi.cpp +++ b/src/bindings/capi/tvgCapi.cpp @@ -97,12 +97,6 @@ TVG_API Tvg_Result tvg_canvas_push(Tvg_Canvas* canvas, Tvg_Paint* paint) } -TVG_API Tvg_Result tvg_canvas_reserve(Tvg_Canvas* canvas, uint32_t n) -{ - return TVG_RESULT_NOT_SUPPORTED; -} - - TVG_API Tvg_Result tvg_canvas_clear(Tvg_Canvas* canvas, bool paints, bool buffer) { if (!canvas) return TVG_RESULT_INVALID_ARGUMENT; @@ -259,11 +253,6 @@ TVG_API Tvg_Result tvg_paint_set_clip(Tvg_Paint* paint, Tvg_Paint* clipper) } -TVG_DEPRECATED TVG_API Tvg_Result tvg_paint_get_identifier(const Tvg_Paint* paint, Tvg_Identifier* identifier) -{ - return tvg_paint_get_type(paint, (Tvg_Type*) identifier); -} - /************************************************************************/ /* Shape API */ /************************************************************************/ @@ -316,13 +305,6 @@ TVG_API Tvg_Result tvg_shape_append_rect(Tvg_Paint* paint, float x, float y, flo } -TVG_DEPRECATED TVG_API Tvg_Result tvg_shape_append_arc(Tvg_Paint* paint, float cx, float cy, float radius, float startAngle, float sweep, uint8_t pie) -{ - if (!paint) return TVG_RESULT_INVALID_ARGUMENT; - return (Tvg_Result) reinterpret_cast(paint)->appendArc(cx, cy, radius, startAngle, sweep, pie); -} - - TVG_API Tvg_Result tvg_shape_append_circle(Tvg_Paint* paint, float cx, float cy, float rx, float ry) { if (!paint) return TVG_RESULT_INVALID_ARGUMENT; @@ -692,11 +674,6 @@ TVG_API Tvg_Result tvg_gradient_get_type(const Tvg_Gradient* grad, Tvg_Type* typ } -TVG_DEPRECATED TVG_API Tvg_Result tvg_gradient_get_identifier(const Tvg_Gradient* grad, Tvg_Identifier* identifier) -{ - return tvg_gradient_get_type(grad, (Tvg_Type*) identifier); -} - /************************************************************************/ /* Scene API */ /************************************************************************/ @@ -707,12 +684,6 @@ TVG_API Tvg_Paint* tvg_scene_new() } -TVG_API Tvg_Result tvg_scene_reserve(Tvg_Paint* scene, uint32_t size) -{ - return TVG_RESULT_NOT_SUPPORTED; -} - - TVG_API Tvg_Result tvg_scene_push(Tvg_Paint* scene, Tvg_Paint* paint) { if (!scene || !paint) return TVG_RESULT_INVALID_ARGUMENT; diff --git a/src/renderer/tvgAccessor.cpp b/src/renderer/tvgAccessor.cpp index a1447268..076ffab3 100644 --- a/src/renderer/tvgAccessor.cpp +++ b/src/renderer/tvgAccessor.cpp @@ -50,20 +50,6 @@ static bool accessChildren(Iterator* it, function Accessor::set(unique_ptr picture, function func) noexcept -{ - auto backward = [](const tvg::Paint* paint, void* data) -> bool - { - auto func = reinterpret_cast*>(data); - if (!(*func)(paint)) return false; - return true; - }; - - set(picture.get(), backward, reinterpret_cast(&func)); - return picture; -} - - Result Accessor::set(const Picture* picture, function func, void* data) noexcept { if (!picture || !func) return Result::InvalidArguments; diff --git a/src/renderer/tvgFill.cpp b/src/renderer/tvgFill.cpp index 19edff5a..98b9a737 100644 --- a/src/renderer/tvgFill.cpp +++ b/src/renderer/tvgFill.cpp @@ -155,12 +155,6 @@ Fill* Fill::duplicate() const noexcept } -TVG_DEPRECATED uint32_t Fill::identifier() const noexcept -{ - return (uint32_t) type(); -} - - RadialGradient::RadialGradient():pImpl(new Impl()) { Fill::pImpl->method(new FillDup(pImpl)); @@ -195,12 +189,6 @@ unique_ptr RadialGradient::gen() noexcept } -TVG_DEPRECATED uint32_t RadialGradient::identifier() noexcept -{ - return (uint32_t) Type::RadialGradient; -} - - Type RadialGradient::type() const noexcept { return Type::RadialGradient; @@ -247,12 +235,6 @@ unique_ptr LinearGradient::gen() noexcept } -TVG_DEPRECATED uint32_t LinearGradient::identifier() noexcept -{ - return (uint32_t) Type::LinearGradient; -} - - Type LinearGradient::type() const noexcept { return Type::LinearGradient; diff --git a/src/renderer/tvgPaint.cpp b/src/renderer/tvgPaint.cpp index 8984204f..74515478 100644 --- a/src/renderer/tvgPaint.cpp +++ b/src/renderer/tvgPaint.cpp @@ -502,12 +502,6 @@ uint8_t Paint::opacity() const noexcept } -TVG_DEPRECATED uint32_t Paint::identifier() const noexcept -{ - return (uint32_t) type(); -} - - Result Paint::blend(BlendMethod method) noexcept { //TODO: Remove later diff --git a/src/renderer/tvgPicture.cpp b/src/renderer/tvgPicture.cpp index ac67b3fd..d6a8b571 100644 --- a/src/renderer/tvgPicture.cpp +++ b/src/renderer/tvgPicture.cpp @@ -150,12 +150,6 @@ unique_ptr Picture::gen() noexcept } -TVG_DEPRECATED uint32_t Picture::identifier() noexcept -{ - return (uint32_t) Type::Picture; -} - - Type Picture::type() const noexcept { return Type::Picture; diff --git a/src/renderer/tvgScene.cpp b/src/renderer/tvgScene.cpp index 1e2b11fc..d73425fd 100644 --- a/src/renderer/tvgScene.cpp +++ b/src/renderer/tvgScene.cpp @@ -61,12 +61,6 @@ unique_ptr Scene::gen() noexcept } -TVG_DEPRECATED uint32_t Scene::identifier() noexcept -{ - return (uint32_t) Type::Scene; -} - - Type Scene::type() const noexcept { return Type::Scene; diff --git a/src/renderer/tvgShape.cpp b/src/renderer/tvgShape.cpp index ab245f86..ada7323b 100644 --- a/src/renderer/tvgShape.cpp +++ b/src/renderer/tvgShape.cpp @@ -49,12 +49,6 @@ unique_ptr Shape::gen() noexcept } -uint32_t Shape::identifier() noexcept -{ - return (uint32_t) Type::Shape; -} - - Type Shape::type() const noexcept { return Type::Shape; @@ -156,68 +150,6 @@ Result Shape::appendCircle(float cx, float cy, float rx, float ry) noexcept } -TVG_DEPRECATED Result Shape::appendArc(float cx, float cy, float radius, float startAngle, float sweep, bool pie) noexcept -{ - //just circle - if (sweep >= 360.0f || sweep <= -360.0f) return appendCircle(cx, cy, radius, radius); - - const float arcPrecision = 1e-5f; - startAngle = deg2rad(startAngle); - sweep = deg2rad(sweep); - - auto nCurves = static_cast(fabsf(sweep / MATH_PI2)); - if (fabsf(sweep / MATH_PI2) - nCurves > arcPrecision) ++nCurves; - auto sweepSign = (sweep < 0 ? -1 : 1); - auto fract = fmodf(sweep, MATH_PI2); - fract = (fabsf(fract) < arcPrecision) ? MATH_PI2 * sweepSign : fract; - - //Start from here - Point start = {radius * cosf(startAngle), radius * sinf(startAngle)}; - - if (pie) { - pImpl->moveTo(cx, cy); - pImpl->lineTo(start.x + cx, start.y + cy); - } else { - pImpl->moveTo(start.x + cx, start.y + cy); - } - - for (int i = 0; i < nCurves; ++i) { - auto endAngle = startAngle + ((i != nCurves - 1) ? MATH_PI2 * sweepSign : fract); - Point end = {radius * cosf(endAngle), radius * sinf(endAngle)}; - - //variables needed to calculate bezier control points - - //get bezier control points using article: - //(http://itc.ktu.lt/index.php/ITC/article/view/11812/6479) - auto ax = start.x; - auto ay = start.y; - auto bx = end.x; - auto by = end.y; - auto q1 = ax * ax + ay * ay; - auto q2 = ax * bx + ay * by + q1; - auto k2 = (4.0f/3.0f) * ((sqrtf(2 * q1 * q2) - q2) / (ax * by - ay * bx)); - - start = end; //Next start point is the current end point - - end.x += cx; - end.y += cy; - - Point ctrl1 = {ax - k2 * ay + cx, ay + k2 * ax + cy}; - Point ctrl2 = {bx + k2 * by + cx, by - k2 * bx + cy}; - - pImpl->cubicTo(ctrl1.x, ctrl1.y, ctrl2.x, ctrl2.y, end.x, end.y); - - startAngle = endAngle; - } - - if (pie) pImpl->close(); - - pImpl->flag |= RenderUpdateFlag::Path; - - return Result::Success; -} - - Result Shape::appendRect(float x, float y, float w, float h, float rx, float ry) noexcept { auto halfW = w * 0.5f;