Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
objc_library(
name = "RLottieBinding",
module_name = "RLottieBinding",
enable_modules = True,
srcs = glob([
"rlottie/src/**/*.cpp",
"rlottie/src/**/*.h",
"rlottie/inc/**/*.h",
], exclude = [
"rlottie/src/vector/vdrawhelper_neon.cpp",
"rlottie/src/vector/stb/**/*",
"rlottie/src/lottie/rapidjson/msinttypes/**/*",
]) + [
"LottieInstance.mm",
"config.h",
],
hdrs = glob([
"PublicHeaders/**/*.h",
]),
includes = [
"PublicHeaders",
],
copts = [
"-Dpixman_region_selfcheck(x)=1",
"-DLOTTIE_DISABLE_ARM_NEON=1",
"-DLOTTIE_THREAD_SAFE=1",
"-DLOTTIE_IMAGE_MODULE_DISABLED=1",
"-I{}".format(package_name()),
"-I{}/rlottie/inc".format(package_name()),
"-I{}/rlottie/src/vector".format(package_name()),
"-I{}/rlottie/src/vector/pixman".format(package_name()),
"-I{}/rlottie/src/vector/freetype".format(package_name()),
],
deps = [
],
visibility = ["//visibility:public"],
)
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
</plist>
+81
View File
@@ -0,0 +1,81 @@
#import <RLottieBinding/LottieInstance.h>
#include "rlottie.h"
@interface LottieInstance () {
std::unique_ptr<rlottie::Animation> _animation;
}
@end
@implementation LottieInstance
- (instancetype _Nullable)initWithData:(NSData * _Nonnull)data fitzModifier:(LottieFitzModifier)fitzModifier colorReplacements:(NSDictionary * _Nullable)colorReplacements cacheKey:(NSString * _Nonnull)cacheKey {
self = [super init];
if (self != nil) {
rlottie::FitzModifier modifier;
switch(fitzModifier) {
case LottieFitzModifierNone:
modifier = rlottie::FitzModifier::None;
break;
case LottieFitzModifierType12:
modifier = rlottie::FitzModifier::Type12;
break;
case LottieFitzModifierType3:
modifier = rlottie::FitzModifier::Type3;
break;
case LottieFitzModifierType4:
modifier = rlottie::FitzModifier::Type4;
break;
case LottieFitzModifierType5:
modifier = rlottie::FitzModifier::Type5;
break;
case LottieFitzModifierType6:
modifier = rlottie::FitzModifier::Type6;
break;
}
std::vector<std::pair<std::uint32_t, std::uint32_t>> colorsVector;
if (colorReplacements != nil) {
for (NSNumber *color in colorReplacements.allKeys) {
NSNumber *replacement = colorReplacements[color];
colorsVector.push_back({ color.unsignedIntValue, replacement.unsignedIntValue });
}
}
_animation = rlottie::Animation::loadFromData(std::string(reinterpret_cast<const char *>(data.bytes), data.length), std::string([cacheKey UTF8String]), "", cacheKey.length != 0, colorsVector, modifier);
if (_animation == nullptr) {
return nil;
}
_frameCount = (int32_t)_animation->totalFrame();
_frameCount = MAX(1, _frameCount);
_frameRate = (int32_t)_animation->frameRate();
_frameRate = MAX(1, _frameRate);
size_t width = 0;
size_t height = 0;
_animation->size(width, height);
if (width > 1536 || height > 1536) {
return nil;
}
width = MAX(1, width);
height = MAX(1, height);
_dimensions = CGSizeMake(width, height);
if ((_frameRate > 360) || _animation->duration() > 9.0) {
return nil;
}
}
return self;
}
- (void)renderFrameWithIndex:(int32_t)index into:(uint8_t * _Nonnull)buffer width:(int32_t)width height:(int32_t)height bytesPerRow:(int32_t) bytesPerRow{
rlottie::Surface surface((uint32_t *)buffer, width, height, bytesPerRow);
_animation->renderSync(index, surface);
}
@end
@@ -0,0 +1,28 @@
#ifndef Lottie_h
#define Lottie_h
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
typedef NS_ENUM(int32_t, LottieFitzModifier) {
LottieFitzModifierNone,
LottieFitzModifierType12,
LottieFitzModifierType3,
LottieFitzModifierType4,
LottieFitzModifierType5,
LottieFitzModifierType6
};
@interface LottieInstance : NSObject
@property (nonatomic, readonly) int32_t frameCount;
@property (nonatomic, readonly) int32_t frameRate;
@property (nonatomic, readonly) CGSize dimensions;
- (instancetype _Nullable)initWithData:(NSData * _Nonnull)data fitzModifier:(LottieFitzModifier)fitzModifier colorReplacements:(NSDictionary * _Nullable)colorReplacements cacheKey:(NSString * _Nonnull)cacheKey;
- (void)renderFrameWithIndex:(int32_t)index into:(uint8_t * _Nonnull)buffer width:(int32_t)width height:(int32_t)height bytesPerRow:(int32_t)bytesPerRow;
@end
#endif /* Lottie_h */
+18
View File
@@ -0,0 +1,18 @@
//
// RLottie.h
// RLottie
//
// Created by Peter on 6/25/19.
// Copyright © 2019 Telegram LLP. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for RLottie.
FOUNDATION_EXPORT double RLottieBindingVersionNumber;
//! Project version string for RLottie.
FOUNDATION_EXPORT const unsigned char RLottieBindingVersionString[];
#import <RLottieBinding/LottieInstance.h>
+29
View File
@@ -0,0 +1,29 @@
#ifndef CONFIG_H
#define CONFIG_H
// enable threading
//#define LOTTIE_THREAD_SUPPORT
#ifndef LOTTIE_THREAD_SAFE
#define LOTTIE_THREAD_SAFE
#endif
//enable logging
//#define LOTTIE_LOGGING_SUPPORT
//enable module building of image loader
//#define LOTTIE_IMAGE_MODULE_SUPPORT
//enable lottie model caching
//#define LOTTIE_CACHE_SUPPORT
// disable image loader
#ifndef LOTTIE_IMAGE_MODULE_DISABLED
#define LOTTIE_IMAGE_MODULE_DISABLED
#endif
#ifndef LOTTIE_CACHE_SUPPORT
#define LOTTIE_CACHE_SUPPORT
#endif
#endif // CONFIG_H