From 670bd2d45afae150a923a7ce87e7ca0c5e67050a Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sat, 6 Jul 2019 15:39:30 +0200 Subject: [PATCH 1/7] Various UI fixes --- NotificationContent/Info.plist | 2 +- NotificationService/Info.plist | 2 +- Share/Info.plist | 2 +- SiriIntents/Info.plist | 2 +- Telegram-iOS/Info.plist | 2 +- Watch/App/Info.plist | 2 +- Watch/Extension/Info.plist | 2 +- Widget/Info.plist | 2 +- .../TelegramCore/TelegramPeerNotificationSettings.swift | 4 ++-- .../TelegramUI/ChatMessageAvatarAccessoryItem.swift | 6 +++++- .../TelegramUI/TelegramUI/ChatTextInputAttributes.swift | 2 +- .../TelegramUI/TelegramUI/MediaInputPaneTrendingItem.swift | 3 ++- 12 files changed, 18 insertions(+), 13 deletions(-) diff --git a/NotificationContent/Info.plist b/NotificationContent/Info.plist index def5291df2..fc4fb2678a 100644 --- a/NotificationContent/Info.plist +++ b/NotificationContent/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.9 + 5.9.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/NotificationService/Info.plist b/NotificationService/Info.plist index ff3b9530b1..de5dc6bfcd 100644 --- a/NotificationService/Info.plist +++ b/NotificationService/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.9 + 5.9.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/Share/Info.plist b/Share/Info.plist index 9ca0244ac4..a28ea585bc 100644 --- a/Share/Info.plist +++ b/Share/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.9 + 5.9.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/SiriIntents/Info.plist b/SiriIntents/Info.plist index db4a9902b3..2a6a05825c 100644 --- a/SiriIntents/Info.plist +++ b/SiriIntents/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.9 + 5.9.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/Telegram-iOS/Info.plist b/Telegram-iOS/Info.plist index 1a8de0bd71..1c01c0b648 100644 --- a/Telegram-iOS/Info.plist +++ b/Telegram-iOS/Info.plist @@ -185,7 +185,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 5.9 + 5.9.1 CFBundleSignature ???? CFBundleURLTypes diff --git a/Watch/App/Info.plist b/Watch/App/Info.plist index fe81e58b75..a24eeb4c0d 100644 --- a/Watch/App/Info.plist +++ b/Watch/App/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 5.9 + 5.9.1 CFBundleVersion ${BUILD_NUMBER} UISupportedInterfaceOrientations diff --git a/Watch/Extension/Info.plist b/Watch/Extension/Info.plist index ef838bd935..7d5914d543 100644 --- a/Watch/Extension/Info.plist +++ b/Watch/Extension/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.9 + 5.9.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/Widget/Info.plist b/Widget/Info.plist index 3660ec2d30..74ebe90850 100644 --- a/Widget/Info.plist +++ b/Widget/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 5.9 + 5.9.1 CFBundleVersion ${BUILD_NUMBER} NSExtension diff --git a/submodules/TelegramCore/TelegramCore/TelegramPeerNotificationSettings.swift b/submodules/TelegramCore/TelegramCore/TelegramPeerNotificationSettings.swift index 154d1b922b..aa6e6fa00a 100644 --- a/submodules/TelegramCore/TelegramCore/TelegramPeerNotificationSettings.swift +++ b/submodules/TelegramCore/TelegramCore/TelegramPeerNotificationSettings.swift @@ -136,9 +136,9 @@ public enum PeerNotificationDisplayPreviews { case .default: encoder.encodeInt32(0, forKey: "p.v") case .show: - encoder.encodeInt32(0, forKey: "p.v") + encoder.encodeInt32(1, forKey: "p.v") case .hide: - encoder.encodeInt32(0, forKey: "p.v") + encoder.encodeInt32(2, forKey: "p.v") } } } diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageAvatarAccessoryItem.swift b/submodules/TelegramUI/TelegramUI/ChatMessageAvatarAccessoryItem.swift index 9aaed1628c..b5c777c419 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageAvatarAccessoryItem.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageAvatarAccessoryItem.swift @@ -67,6 +67,10 @@ final class ChatMessageAvatarAccessoryItemNode: ListViewAccessoryItemNode { } func setPeer(account: Account, theme: PresentationTheme, synchronousLoad:Bool, peer: Peer, authorOfMessage: MessageReference?, emptyColor: UIColor) { - self.avatarNode.setPeer(account: account, theme: theme, peer: peer, authorOfMessage: authorOfMessage, emptyColor: emptyColor, synchronousLoad: synchronousLoad) + var overrideImage: AvatarNodeImageOverride? + if peer.isDeleted { + overrideImage = .deletedIcon + } + self.avatarNode.setPeer(account: account, theme: theme, peer: peer, authorOfMessage: authorOfMessage, overrideImage: overrideImage, emptyColor: emptyColor, synchronousLoad: synchronousLoad) } } diff --git a/submodules/TelegramUI/TelegramUI/ChatTextInputAttributes.swift b/submodules/TelegramUI/TelegramUI/ChatTextInputAttributes.swift index a9166ab9e6..032306111a 100644 --- a/submodules/TelegramUI/TelegramUI/ChatTextInputAttributes.swift +++ b/submodules/TelegramUI/TelegramUI/ChatTextInputAttributes.swift @@ -666,7 +666,7 @@ func convertMarkdownToAttributes(_ text: NSAttributedString) -> NSAttributedStri while let match = regex.firstMatch(in: string as String, range: NSMakeRange(0, string.length)) { let matchIndex = stringOffset + match.range.location - result.append(text.attributedSubstring(from: NSMakeRange(0, match.range.location))) + result.append(text.attributedSubstring(from: NSMakeRange(text.length - string.length, match.range.location))) var pre = match.range(at: 3) if pre.location != NSNotFound { diff --git a/submodules/TelegramUI/TelegramUI/MediaInputPaneTrendingItem.swift b/submodules/TelegramUI/TelegramUI/MediaInputPaneTrendingItem.swift index 04cf0a09bf..571d79455c 100644 --- a/submodules/TelegramUI/TelegramUI/MediaInputPaneTrendingItem.swift +++ b/submodules/TelegramUI/TelegramUI/MediaInputPaneTrendingItem.swift @@ -114,6 +114,7 @@ final class TrendingTopItemNode: ASDisplayNode { self?.imageNode.alpha = 0.0 } animationNode.setup(account: account, resource: item.file.resource, width: 160, height: 160, mode: .cached) + self.loadDisposable.set(freeMediaFileResourceInteractiveFetched(account: account, fileReference: stickerPackFileReference(item.file), resource: item.file.resource).start()) } else { self.imageNode.setSignal(chatMessageSticker(account: account, file: item.file, small: true, synchronousLoad: synchronousLoads), attemptSynchronously: synchronousLoads) @@ -121,8 +122,8 @@ final class TrendingTopItemNode: ASDisplayNode { self.animationNode = nil currentAnimationNode.removeFromSupernode() } + self.loadDisposable.set(freeMediaFileResourceInteractiveFetched(account: account, fileReference: stickerPackFileReference(item.file), resource: chatMessageStickerResource(file: item.file, small: true)).start()) } - self.loadDisposable.set(freeMediaFileResourceInteractiveFetched(account: account, fileReference: stickerPackFileReference(item.file), resource: chatMessageStickerResource(file: item.file, small: true)).start()) } func updatePreviewing(animated: Bool, isPreviewing: Bool) { From 6e060bddedf4473fcf4d23ab795789a39f71c3bf Mon Sep 17 00:00:00 2001 From: Peter <> Date: Sat, 6 Jul 2019 20:34:08 +0300 Subject: [PATCH 2/7] Isolate rlottie drawing --- .../rlottie/src/lottie/lottieanimation.cpp | 2 +- .../Sources/rlottie/src/vector/config.h | 2 +- .../Sources/rlottie/src/vector/vraster.cpp | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/submodules/RLottie/Sources/rlottie/src/lottie/lottieanimation.cpp b/submodules/RLottie/Sources/rlottie/src/lottie/lottieanimation.cpp index 61f23ff9b8..7b11f4f8ce 100644 --- a/submodules/RLottie/Sources/rlottie/src/lottie/lottieanimation.cpp +++ b/submodules/RLottie/Sources/rlottie/src/lottie/lottieanimation.cpp @@ -113,7 +113,7 @@ void AnimationImpl::init(const std::shared_ptr &model) mRenderInProgress = false; } -#if false //def LOTTIE_THREAD_SUPPORT +#ifdef LOTTIE_THREAD_SUPPORT #include #include "vtaskqueue.h" diff --git a/submodules/RLottie/Sources/rlottie/src/vector/config.h b/submodules/RLottie/Sources/rlottie/src/vector/config.h index dde0e17724..596ad11616 100644 --- a/submodules/RLottie/Sources/rlottie/src/vector/config.h +++ b/submodules/RLottie/Sources/rlottie/src/vector/config.h @@ -2,7 +2,7 @@ #define CONFIG_H // enable threading -#define LOTTIE_THREAD_SUPPORT +//#define LOTTIE_THREAD_SUPPORT //enable logging //#define LOTTIE_LOGGING_SUPPORT diff --git a/submodules/RLottie/Sources/rlottie/src/vector/vraster.cpp b/submodules/RLottie/Sources/rlottie/src/vector/vraster.cpp index 3f24e3dd70..fec83e83b5 100644 --- a/submodules/RLottie/Sources/rlottie/src/vector/vraster.cpp +++ b/submodules/RLottie/Sources/rlottie/src/vector/vraster.cpp @@ -346,7 +346,7 @@ struct VRleTask { sw_ft_grays_raster.raster_render(nullptr, ¶ms); } - void operator()(FTOutline &outRef, SW_FT_Stroker &stroker) + void update(FTOutline &outRef, SW_FT_Stroker &stroker) { if (mGenerateStroke) { // Stroke Task outRef.convert(mPath); @@ -481,13 +481,23 @@ public: ~RleTaskScheduler() { SW_FT_Stroker_Done(stroker); } - void process(VTask task) { (*task)(outlineRef, stroker); } + void process(VTask task) { (*task).update(outlineRef, stroker); } }; #endif struct VRasterizer::VRasterizerImpl { VRleTask mTask; - + FTOutline outlineRef; + SW_FT_Stroker stroker; + + VRasterizerImpl() { + SW_FT_Stroker_New(&stroker); + } + + ~VRasterizerImpl() { + SW_FT_Stroker_Done(stroker); + } + VRle & rle() { return mTask.rle(); } VRleTask &task() { return mTask; } }; @@ -505,8 +515,7 @@ void VRasterizer::init() void VRasterizer::updateRequest() { - VTask taskObj = VTask(d, &d->task()); - RleTaskScheduler::instance().process(std::move(taskObj)); + d->task().update(d->outlineRef, d->stroker); } void VRasterizer::rasterize(VPath path, FillRule fillRule, const VRect &clip) From f57f5b663795f96c4fe56bb698e4d3e73a8a90bb Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 7 Jul 2019 00:02:23 +0200 Subject: [PATCH 3/7] Increased animated sticker file size limit --- .../TelegramUI/TelegramUI/AnimatedStickerUtils.swift | 11 ++++++++--- .../TelegramUI/TelegramUI/ChatMessageItem.swift | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift b/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift index 901a8a5d14..c836c4afe1 100644 --- a/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift +++ b/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift @@ -69,16 +69,21 @@ private func validateAnimationLayers(_ layers: [Any]?) -> Bool { } func validateAnimationComposition(json: [AnyHashable: Any]) -> Bool { + let validDimensions: [Int] = [100, 512] + let validFramerates: [Int] = [30, 60] + guard let tgs = json["tgs"] as? Int, tgs == 1 else { return false } - guard let width = json["w"] as? Int, width == 512 else { + guard let width = json["w"] as? Int, validDimensions.contains(width) else { return false } - guard let height = json["h"] as? Int, height == 512 else { + guard let height = json["h"] as? Int, validDimensions.contains(height) else { + return false + } + guard let fps = json["fr"] as? Int, validFramerates.contains(fps) else { return false } - return true } diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageItem.swift b/submodules/TelegramUI/TelegramUI/ChatMessageItem.swift index a4e3848a4d..d020ec179c 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageItem.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageItem.swift @@ -353,7 +353,7 @@ public final class ChatMessageItem: ListViewItem, CustomStringConvertible { loop: for media in self.message.media { if let telegramFile = media as? TelegramMediaFile { - if telegramFile.isAnimatedSticker, let size = telegramFile.size, size > 0 && size <= 64 * 1024 { + if telegramFile.isAnimatedSticker, let size = telegramFile.size, size > 0 && size <= 128 * 1024 { viewClassName = ChatMessageAnimatedStickerItemNode.self break loop } From 4f2f717239f5740168e6685dde9a310ad9fef157 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 7 Jul 2019 16:12:50 +0200 Subject: [PATCH 4/7] Fixed lottie file parsing --- .../rlottie/src/lottie/lottieloader.cpp | 6 +++++ .../rlottie/src/lottie/lottieparser.cpp | 26 ++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/submodules/RLottie/Sources/rlottie/src/lottie/lottieloader.cpp b/submodules/RLottie/Sources/rlottie/src/lottie/lottieloader.cpp index 28b4e4b1ce..d9383f6dd4 100644 --- a/submodules/RLottie/Sources/rlottie/src/lottie/lottieloader.cpp +++ b/submodules/RLottie/Sources/rlottie/src/lottie/lottieloader.cpp @@ -93,6 +93,9 @@ bool LottieLoader::load(const std::string &path) LottieParser parser(const_cast(buf.str().data()), dirname(path).c_str()); mModel = parser.model(); + + if (!mModel) return false; + LottieFileCache::instance().add(path, mModel); f.close(); @@ -110,6 +113,9 @@ bool LottieLoader::loadFromData(std::string &&jsonData, const std::string &key, LottieParser parser(const_cast(jsonData.c_str()), resourcePath.c_str()); mModel = parser.model(); + + if (!mModel) return false; + LottieFileCache::instance().add(key, mModel); return true; diff --git a/submodules/RLottie/Sources/rlottie/src/lottie/lottieparser.cpp b/submodules/RLottie/Sources/rlottie/src/lottie/lottieparser.cpp index 614ea335ca..a0d40122d6 100644 --- a/submodules/RLottie/Sources/rlottie/src/lottie/lottieparser.cpp +++ b/submodules/RLottie/Sources/rlottie/src/lottie/lottieparser.cpp @@ -587,6 +587,12 @@ void LottieParserImpl::parseComposition() Skip(key); } } + + if (comp->mVersion.empty()) { + // don't have a valid bodymovin header + return; + } + resolveLayerRefs(); comp->setStatic(comp->mRootLayer->isStatic()); comp->mRootLayer->mInFrame = comp->mStartFrame; @@ -699,8 +705,10 @@ std::shared_ptr LottieParserImpl::parseAsset() bool staticFlag = true; while (NextArrayValue()) { std::shared_ptr layer = parseLayer(); - staticFlag = staticFlag && layer->isStatic(); - asset->mLayers.push_back(layer); + if (layer) { + staticFlag = staticFlag && layer->isStatic(); + asset->mLayers.push_back(layer); + } } asset->setStatic(staticFlag); } else { @@ -735,8 +743,10 @@ void LottieParserImpl::parseLayers(LOTCompositionData *comp) EnterArray(); while (NextArrayValue()) { std::shared_ptr layer = parseLayer(true); - staticFlag = staticFlag && layer->isStatic(); - comp->mRootLayer->mChildren.push_back(layer); + if (layer) { + staticFlag = staticFlag && layer->isStatic(); + comp->mRootLayer->mChildren.push_back(layer); + } } comp->mRootLayer->setStatic(staticFlag); } @@ -904,6 +914,11 @@ std::shared_ptr LottieParserImpl::parseLayer(bool record) Skip(key); } } + + if (!layer->mTransform) { + // not a valid layer + return nullptr; + } layer->mCompRef = compRef; @@ -1240,6 +1255,7 @@ LOTTrimData::TrimType LottieParserImpl::getTrimType() break; default: RAPIDJSON_ASSERT(0); + return LOTTrimData::TrimType::Individually; break; } } @@ -2229,6 +2245,8 @@ LottieParser::LottieParser(char *str, const char *dir_path) std::shared_ptr LottieParser::model() { + if (!d->composition()) return nullptr; + std::shared_ptr model = std::make_shared(); model->mRoot = d->composition(); model->mRoot->processRepeaterObjects(); From 529dfcd10aed9f8876240c3f5f407c53eb7fc16f Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 7 Jul 2019 16:40:40 +0200 Subject: [PATCH 5/7] Fixed gunzip --- submodules/GZip/Sources/GZip.h | 4 ++-- submodules/GZip/Sources/GZip.m | 14 +++++++++++--- .../TelegramUI/AnimatedStickerNode.swift | 2 +- .../TelegramUI/AnimatedStickerUtils.swift | 4 ++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/submodules/GZip/Sources/GZip.h b/submodules/GZip/Sources/GZip.h index ee4c756f4d..ea1f93b9b3 100644 --- a/submodules/GZip/Sources/GZip.h +++ b/submodules/GZip/Sources/GZip.h @@ -10,8 +10,8 @@ FOUNDATION_EXPORT const unsigned char GZipVersionString[]; extern "C" { #endif -NSData *TGGZipData(NSData *data, float level); -NSData * _Nullable TGGUnzipData(NSData *data); +NSData * _Nonnull TGGZipData(NSData * _Nonnull data, float level); +NSData * _Nullable TGGUnzipData(NSData * _Nonnull data, uint sizeLimit); #ifdef __cplusplus } diff --git a/submodules/GZip/Sources/GZip.m b/submodules/GZip/Sources/GZip.m index 4d55ac33bc..9e7a828e7d 100644 --- a/submodules/GZip/Sources/GZip.m +++ b/submodules/GZip/Sources/GZip.m @@ -42,7 +42,7 @@ NSData *TGGZipData(NSData *data, float level) { return output; } -NSData * _Nullable TGGUnzipData(NSData *data) +NSData * _Nullable TGGUnzipData(NSData *data, uint sizeLimit) { if (data.length == 0 || !TGIsGzippedData(data)) { return nil; @@ -61,12 +61,20 @@ NSData * _Nullable TGGUnzipData(NSData *data) int status = Z_OK; output = [NSMutableData dataWithCapacity:data.length * 2]; while (status == Z_OK) { + if (sizeLimit > 0 && stream.total_out > sizeLimit) { + return nil; + } + if (stream.total_out >= output.length) { - output.length += data.length / 2; + NSUInteger length = output.length + data.length / 2; + if (sizeLimit > 0 && length > sizeLimit) { + return nil; + } + output.length = length; } stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out; stream.avail_out = (uInt)(output.length - stream.total_out); - status = inflate (&stream, Z_SYNC_FLUSH); + status = inflate(&stream, Z_SYNC_FLUSH); } if (inflateEnd(&stream) == Z_OK) { if (status == Z_STREAM_END) { diff --git a/submodules/TelegramUI/TelegramUI/AnimatedStickerNode.swift b/submodules/TelegramUI/TelegramUI/AnimatedStickerNode.swift index bb5986a994..a7a817af47 100644 --- a/submodules/TelegramUI/TelegramUI/AnimatedStickerNode.swift +++ b/submodules/TelegramUI/TelegramUI/AnimatedStickerNode.swift @@ -214,7 +214,7 @@ private final class AnimatedStickerDirectFrameSource: AnimatedStickerFrameSource self.width = width self.height = height self.currentFrame = 0 - guard let rawData = TGGUnzipData(data) else { + guard let rawData = TGGUnzipData(data, 1024 * 1024) else { return nil } guard let animation = LottieInstance(data: rawData, cacheKey: "") else { diff --git a/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift b/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift index c836c4afe1..c9baab8fa8 100644 --- a/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift +++ b/submodules/TelegramUI/TelegramUI/AnimatedStickerUtils.swift @@ -98,7 +98,7 @@ func fetchCompressedLottieFirstFrameAJpeg(data: Data, size: CGSize, cacheKey: St return } - let decompressedData = TGGUnzipData(data) + let decompressedData = TGGUnzipData(data, 1024 * 1024) if let decompressedData = decompressedData, let player = LottieInstance(data: decompressedData, cacheKey: cacheKey) { if cancelled.with({ $0 }) { return @@ -193,7 +193,7 @@ func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: CGSize, var deltaTime: Double = 0 var compressionTime: Double = 0 - let decompressedData = TGGUnzipData(data) + let decompressedData = TGGUnzipData(data, 1024 * 1024) if let decompressedData = decompressedData, let player = LottieInstance(data: decompressedData, cacheKey: cacheKey) { let endFrame = Int(player.frameCount) From 1aa9c3d871cf3055b731761d1a0ff6abb2740813 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 7 Jul 2019 17:01:38 +0200 Subject: [PATCH 6/7] Added some format checks --- submodules/RLottie/Sources/LottieInstance.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/submodules/RLottie/Sources/LottieInstance.mm b/submodules/RLottie/Sources/LottieInstance.mm index 849339297b..499469e2d8 100644 --- a/submodules/RLottie/Sources/LottieInstance.mm +++ b/submodules/RLottie/Sources/LottieInstance.mm @@ -20,6 +20,17 @@ _frameCount = (int32_t)_animation->totalFrame(); _frameRate = (int32_t)_animation->frameRate(); + + size_t width = 0; + size_t height = 0; + _animation->size(width, height); + + if (width != height || (width != 100 && width != 512)) { + return nil; + } + if ((_frameRate > 30 && _frameRate != 60) || _animation->duration() > 4.5) { + return nil; + } } return self; } From 7ff263736cc72c47966a430391455501f8dde111 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 7 Jul 2019 17:12:31 +0200 Subject: [PATCH 7/7] Added tgs check --- submodules/RLottie/Sources/rlottie/inc/rlottie.h | 2 ++ .../Sources/rlottie/src/lottie/lottieanimation.cpp | 8 +++++++- .../RLottie/Sources/rlottie/src/lottie/lottiemodel.h | 2 ++ .../RLottie/Sources/rlottie/src/lottie/lottieparser.cpp | 5 ++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/submodules/RLottie/Sources/rlottie/inc/rlottie.h b/submodules/RLottie/Sources/rlottie/inc/rlottie.h index 74def69ebc..ab70720b2b 100644 --- a/submodules/RLottie/Sources/rlottie/inc/rlottie.h +++ b/submodules/RLottie/Sources/rlottie/inc/rlottie.h @@ -423,6 +423,8 @@ public: * @internal */ ~Animation(); + + bool isTgs() const; private: void setValue(Color_Type, Property, const std::string &, Color); diff --git a/submodules/RLottie/Sources/rlottie/src/lottie/lottieanimation.cpp b/submodules/RLottie/Sources/rlottie/src/lottie/lottieanimation.cpp index 7b11f4f8ce..91514858e7 100644 --- a/submodules/RLottie/Sources/rlottie/src/lottie/lottieanimation.cpp +++ b/submodules/RLottie/Sources/rlottie/src/lottie/lottieanimation.cpp @@ -47,7 +47,8 @@ public: Surface render(size_t frameNo, const Surface &surface); std::future renderAsync(size_t frameNo, Surface &&surface); const LOTLayerNode * renderTree(size_t frameNo, const VSize &size); - + bool isTgs() const { return mModel->isTgs(); } + const LayerInfoList &layerInfoList() const { return mModel->layerInfoList(); @@ -266,6 +267,11 @@ std::unique_ptr Animation::loadFromFile(const std::string &path) return nullptr; } +bool Animation::isTgs() const +{ + return d->isTgs(); +} + void Animation::size(size_t &width, size_t &height) const { VSize sz = d->size(); diff --git a/submodules/RLottie/Sources/rlottie/src/lottie/lottiemodel.h b/submodules/RLottie/Sources/rlottie/src/lottie/lottiemodel.h index 6fe933593e..2353cb7a05 100644 --- a/submodules/RLottie/Sources/rlottie/src/lottie/lottiemodel.h +++ b/submodules/RLottie/Sources/rlottie/src/lottie/lottiemodel.h @@ -569,6 +569,7 @@ public: VSize size() const {return mSize;} void processRepeaterObjects(); public: + int mTgs; std::string mVersion; VSize mSize; long mStartFrame{0}; @@ -954,6 +955,7 @@ public: class LOTModel { public: + bool isTgs() const {return mRoot->mTgs == 1;} bool isStatic() const {return mRoot->isStatic();} double duration() const {return mRoot->duration();} size_t totalFrame() const {return mRoot->totalFrame();} diff --git a/submodules/RLottie/Sources/rlottie/src/lottie/lottieparser.cpp b/submodules/RLottie/Sources/rlottie/src/lottie/lottieparser.cpp index a0d40122d6..9def4aa8a0 100644 --- a/submodules/RLottie/Sources/rlottie/src/lottie/lottieparser.cpp +++ b/submodules/RLottie/Sources/rlottie/src/lottie/lottieparser.cpp @@ -558,7 +558,10 @@ void LottieParserImpl::parseComposition() LOTCompositionData *comp = sharedComposition.get(); compRef = comp; while (const char *key = NextObjectKey()) { - if (0 == strcmp(key, "v")) { + if (0 == strcmp(key, "tgs")) { + RAPIDJSON_ASSERT(PeekType() == kNumberType); + comp->mTgs = GetInt(); + }else if (0 == strcmp(key, "v")) { RAPIDJSON_ASSERT(PeekType() == kStringType); comp->mVersion = std::string(GetString()); } else if (0 == strcmp(key, "w")) {