From fbf8e8dfce3c41db3a01cd6a565e0cb77576eb71 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 6 Jun 2023 10:50:58 +0900 Subject: [PATCH] Revert "api: remove deprecated apis" This reverts commit aa000f7c569113309c4f4e8c4094da7bbffcee97. TVG will move forward to v0.10, so we still need to keep the deprecated APIs. --- inc/thorvg.h | 33 +++++++++++++++++++++++++++++++++ src/lib/tvgPaint.cpp | 6 ++++++ src/lib/tvgPicture.cpp | 6 ++++++ 3 files changed, 45 insertions(+) diff --git a/inc/thorvg.h b/inc/thorvg.h index a8f1f829..56101a4b 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -343,6 +343,21 @@ public: */ Result composite(std::unique_ptr target, CompositeMethod method) noexcept; + /** + * @brief Gets the bounding box of the paint object before any transformation. + * + * @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. + * + * @return Result::Success when succeed, Result::InsufficientCondition otherwise. + * + * @note The bounding box doesn't indicate the final rendered region. It's the smallest rectangle that encloses the object. + * @see Paint::bounds(float* x, float* y, float* w, float* h, bool transformed); + */ + TVG_DEPRECATED Result bounds(float* x, float* y, float* w, float* h) const noexcept; + /** * @brief Gets the axis-aligned bounding box of the paint object. * @@ -1153,6 +1168,24 @@ public: */ Result load(const std::string& path) noexcept; + /** + * @brief Loads a picture data from a memory block of a given size. + * + * @param[in] data A pointer to a memory location where the content of the picture file is stored. + * @param[in] size The size in bytes of the memory occupied by the @p data. + * @param[in] copy Decides whether the data should be copied into the engine local buffer. + * + * @retval Result::Success When succeed. + * @retval Result::InvalidArguments In case no data are provided or the @p size is zero or less. + * @retval Result::NonSupport When trying to load a file with an unknown extension. + * @retval Result::Unknown If an error occurs at a later stage. + * + * @warning: you have responsibility to release the @p data memory if the @p copy is true + * @deprecated Use load(const char* data, uint32_t size, const std::string& mimeType, bool copy) instead. + * @see Result load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false) noexcept + */ + TVG_DEPRECATED Result load(const char* data, uint32_t size, bool copy = false) noexcept; + /** * @brief Loads a picture data from a memory block of a given size. * diff --git a/src/lib/tvgPaint.cpp b/src/lib/tvgPaint.cpp index 450a221d..a2685b33 100644 --- a/src/lib/tvgPaint.cpp +++ b/src/lib/tvgPaint.cpp @@ -356,6 +356,12 @@ Matrix Paint::transform() noexcept } +TVG_DEPRECATED Result Paint::bounds(float* x, float* y, float* w, float* h) const noexcept +{ + return this->bounds(x, y, w, h, false); +} + + Result Paint::bounds(float* x, float* y, float* w, float* h, bool transform) const noexcept { if (pImpl->bounds(x, y, w, h, transform)) return Result::Success; diff --git a/src/lib/tvgPicture.cpp b/src/lib/tvgPicture.cpp index 7de38b2c..fd324a94 100644 --- a/src/lib/tvgPicture.cpp +++ b/src/lib/tvgPicture.cpp @@ -67,6 +67,12 @@ Result Picture::load(const char* data, uint32_t size, const string& mimeType, bo } +TVG_DEPRECATED Result Picture::load(const char* data, uint32_t size, bool copy) noexcept +{ + return load(data, size, "", copy); +} + + Result Picture::load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept { if (!data || w <= 0 || h <= 0) return Result::InvalidArguments;