From ac7018f74fea41a9fc1cbec1325d20acab9d991f Mon Sep 17 00:00:00 2001 From: John Date: Sun, 27 Dec 2020 14:21:22 +0100 Subject: [PATCH] rlottie: update to 0.2. --- srcpkgs/rlottie/patches/252.patch | 210 ------------------------------ srcpkgs/rlottie/template | 17 +-- 2 files changed, 9 insertions(+), 218 deletions(-) delete mode 100644 srcpkgs/rlottie/patches/252.patch diff --git a/srcpkgs/rlottie/patches/252.patch b/srcpkgs/rlottie/patches/252.patch deleted file mode 100644 index c5926bfde10..00000000000 --- a/srcpkgs/rlottie/patches/252.patch +++ /dev/null @@ -1,210 +0,0 @@ -From fe6f0d8ea6adf907e9bf58d95b3a5336d01e0c76 Mon Sep 17 00:00:00 2001 -From: John Preston -Date: Sat, 18 Jan 2020 16:19:58 +0100 -Subject: [PATCH] Allow passing a color replacement map. - ---- - inc/rlottie.h | 4 ++- - src/lottie/lottieanimation.cpp | 7 ++++-- - src/lottie/lottieloader.cpp | 9 ++++--- - src/lottie/lottieloader.h | 5 +++- - src/lottie/lottieparser.cpp | 45 ++++++++++++++++++++++++++++------ - src/lottie/lottieparser.h | 4 ++- - 6 files changed, 59 insertions(+), 15 deletions(-) - -diff --git inc/rlottie.h inc/rlottie.h -index b37f67a..961e25f 100644 ---- inc/rlottie.h -+++ inc/rlottie.h -@@ -299,7 +299,9 @@ public: - */ - static std::unique_ptr - loadFromData(std::string jsonData, const std::string &key, -- const std::string &resourcePath="", bool cachePolicy=true); -+ const std::string &resourcePath="", bool cachePolicy=true, -+ const std::vector> -+ &colorReplacements = {}); - - /** - * @brief Returns default framerate of the Lottie resource. -diff --git src/lottie/lottieanimation.cpp src/lottie/lottieanimation.cpp -index ef93930..dd45f2c 100644 ---- src/lottie/lottieanimation.cpp -+++ src/lottie/lottieanimation.cpp -@@ -248,7 +248,9 @@ std::future AnimationImpl::renderAsync(size_t frameNo, - */ - std::unique_ptr Animation::loadFromData( - std::string jsonData, const std::string &key, -- const std::string &resourcePath, bool cachePolicy) -+ const std::string &resourcePath, bool cachePolicy, -+ const std::vector> -+ &colorReplacements) - { - if (jsonData.empty()) { - vWarning << "jason data is empty"; -@@ -257,7 +259,8 @@ std::unique_ptr Animation::loadFromData( - - LottieLoader loader; - if (loader.loadFromData(std::move(jsonData), key, -- (resourcePath.empty() ? " " : resourcePath), cachePolicy)) { -+ (resourcePath.empty() ? " " : resourcePath), -+ cachePolicy, colorReplacements)) { - auto animation = std::unique_ptr(new Animation); - animation->d->init(loader.model()); - return animation; -diff --git src/lottie/lottieloader.cpp src/lottie/lottieloader.cpp -index 82e21e3..8c06780 100644 ---- src/lottie/lottieloader.cpp -+++ src/lottie/lottieloader.cpp -@@ -140,8 +140,11 @@ bool LottieLoader::load(const std::string &path, bool cachePolicy) - return true; - } - --bool LottieLoader::loadFromData(std::string &&jsonData, const std::string &key, -- const std::string &resourcePath, bool cachePolicy) -+bool LottieLoader::loadFromData( -+ std::string &&jsonData, const std::string &key, -+ const std::string &resourcePath, bool cachePolicy, -+ const std::vector> -+ &colorReplacements) - { - if (cachePolicy) { - mModel = LottieModelCache::instance().find(key); -@@ -149,7 +152,7 @@ bool LottieLoader::loadFromData(std::string &&jsonData, const std::string &key, - } - - LottieParser parser(const_cast(jsonData.c_str()), -- resourcePath.c_str()); -+ resourcePath.c_str(), colorReplacements); - mModel = parser.model(); - - if (!mModel) return false; -diff --git src/lottie/lottieloader.h src/lottie/lottieloader.h -index 4d4646d..711d0d6 100644 ---- src/lottie/lottieloader.h -+++ src/lottie/lottieloader.h -@@ -21,6 +21,7 @@ - - #include - #include -+#include - - class LOTModel; - class LottieLoader -@@ -29,7 +30,9 @@ public: - static void configureModelCacheSize(size_t cacheSize); - bool load(const std::string &filePath, bool cachePolicy); - bool loadFromData(std::string &&jsonData, const std::string &key, -- const std::string &resourcePath, bool cachePolicy); -+ const std::string &resourcePath, bool cachePolicy, -+ const std::vector> -+ &colorReplacements); - std::shared_ptr model(); - private: - std::shared_ptr mModel; -diff --git src/lottie/lottieparser.cpp src/lottie/lottieparser.cpp -index 945cfde..bfdf494 100644 ---- src/lottie/lottieparser.cpp -+++ src/lottie/lottieparser.cpp -@@ -169,8 +169,14 @@ protected: - - class LottieParserImpl : public LookaheadParserHandler { - public: -- LottieParserImpl(char *str, const char *dir_path) -- : LookaheadParserHandler(str), mDirPath(dir_path) {} -+ LottieParserImpl(char *str, const char *dir_path, -+ const std::vector> -+ &colorReplacements) -+ : LookaheadParserHandler(str), -+ mColorReplacements(colorReplacements), -+ mDirPath(dir_path) -+ { -+ } - bool VerifyType(); - bool ParseNext(); - public: -@@ -260,10 +266,13 @@ public: - VInterpolator* interpolator(VPointF, VPointF, std::string); - - LottieColor toColor(const char *str); -+ LottieColor applyReplacements(const LottieColor &color); - - void resolveLayerRefs(); - - protected: -+ const std::vector> -+ &mColorReplacements; - std::unordered_map - mInterpolatorCache; - std::shared_ptr mComposition; -@@ -831,6 +840,27 @@ LottieColor LottieParserImpl::toColor(const char *str) - tmp[1] = str[6]; - color.b = std::strtol(tmp, nullptr, 16) / 255.0f; - -+ return applyReplacements(color); -+} -+ -+LottieColor LottieParserImpl::applyReplacements(const LottieColor &color) -+{ -+ if (mColorReplacements.empty()) { -+ return color; -+ } -+ const auto convert = [](float value) { -+ return std::uint32_t(std::round(std::clamp(value, 0.f, 1.f) * 255.)); -+ }; -+ const auto part = [](std::uint32_t value, int shift) { -+ return float((value >> shift) & 0xFFU) / 255.f; -+ }; -+ const auto converted = -+ convert(color.b) | (convert(color.g) << 8) | (convert(color.r) << 16); -+ for (const auto [key, value] : mColorReplacements) { -+ if (key == converted) { -+ return LottieColor(part(value, 16), part(value, 8), part(value, 0)); -+ } -+ } - return color; - } - -@@ -1774,9 +1804,7 @@ void LottieParserImpl::getValue(LottieColor &color) - val[i++] = value; - } - } -- color.r = val[0]; -- color.g = val[1]; -- color.b = val[2]; -+ color = applyReplacements(LottieColor(val[0], val[1], val[2])); - } - - void LottieParserImpl::getValue(LottieGradient &grad) -@@ -2296,8 +2324,11 @@ public: - #endif - - LottieParser::~LottieParser() = default; --LottieParser::LottieParser(char *str, const char *dir_path) -- : d(std::make_unique(str, dir_path)) -+LottieParser::LottieParser( -+ char *str, const char *dir_path, -+ const std::vector> -+ &colorReplacements) -+ : d(std::make_unique(str, dir_path, colorReplacements)) - { - if (d->VerifyType()) - d->parseComposition(); -diff --git src/lottie/lottieparser.h src/lottie/lottieparser.h -index 35a8417..06165f9 100644 ---- src/lottie/lottieparser.h -+++ src/lottie/lottieparser.h -@@ -26,7 +26,9 @@ class LottieParserImpl; - class LottieParser { - public: - ~LottieParser(); -- LottieParser(char* str, const char *dir_path); -+ LottieParser(char *str, const char *dir_path, -+ const std::vector> -+ &colorReplacements = {}); - std::shared_ptr model(); - private: - std::unique_ptr d; --- -2.24.0 - diff --git a/srcpkgs/rlottie/template b/srcpkgs/rlottie/template index 8902680b215..92f4735095a 100644 --- a/srcpkgs/rlottie/template +++ b/srcpkgs/rlottie/template @@ -1,20 +1,21 @@ # Template file for 'rlottie' pkgname=rlottie -_commit=f6fc61f214945ac9961ba49fdfc9a3d3336e999b -version=0.0.20200110 -revision=2 -wrksrc="rlottie-${_commit}" +version=0.2 +revision=1 build_style=cmake -configure_args="-DLOTTIE_CACHE=OFF" +checkdepends="gtest-devel" short_desc="Platform independent standalone library that plays Lottie Animation" maintainer="John " license="LGPL-2.1-or-later, FTL, MIT, BSD-3-Clause" homepage="https://github.com/Samsung/rlottie" -distfiles="https://github.com/Samsung/rlottie/archive/${_commit}.tar.gz" -checksum=399bb06d8d2120f794eff8bc3e4cbbee13b9f22abcfd9f3f746f595d43ea0b42 +distfiles="https://github.com/Samsung/rlottie/archive/v${version}.tar.gz" +checksum=030ccbc270f144b4f3519fb3b86e20dd79fb48d5d55e57f950f12bab9b65216a + +if [ "$XBPS_CHECK_PKGS" ]; then + configure_args=" -DLOTTIE_TEST=ON" +fi post_patch() { - vsed -e 's/c++14/c++17/g' -i CMakeLists.txt # No JSON licensed source code included vsed -i licenses/COPYING.RPD \ -e 's/To avoid the problematic JSON.*//' \