Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
fix: add enabledMemoryCache option to SVGAParser, disable memory cach…
Browse files Browse the repository at this point in the history
…e to default.

fix: use SSZipArchiver 2.1.4
  • Loading branch information
PonyCui committed Dec 18, 2018
1 parent 165b4ca commit 116a91f
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ platform :ios, '8.0'

target 'SVGAPlayer' do

pod 'SSZipArchive', '~> 1.8.1'
pod 'SSZipArchive', '~> 2.1.4'
pod 'Protobuf', '~> 3.4'

end

target 'SVGAPlayer React' do

pod 'SSZipArchive', '~> 1.8.1'
pod 'SSZipArchive', '~> 2.1.4'
pod 'React', :podspec => 'https://raw.githubusercontent.com/yyued/react-native-runtime-ios/0.45.1/React.podspec', :subspecs => [
'Core',
'ART',
Expand Down
10 changes: 5 additions & 5 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ PODS:
- React/Core
- React/RCTWebSocket (0.45.1):
- React/Core
- SSZipArchive (1.8.1)
- SSZipArchive (2.1.4)
- Yoga (1.9.0)

DEPENDENCIES:
Expand All @@ -43,7 +43,7 @@ DEPENDENCIES:
- React/RCTText (from `https://raw.githubusercontent.com/yyued/react-native-runtime-ios/0.45.1/React.podspec`)
- React/RCTVibration (from `https://raw.githubusercontent.com/yyued/react-native-runtime-ios/0.45.1/React.podspec`)
- React/RCTWebSocket (from `https://raw.githubusercontent.com/yyued/react-native-runtime-ios/0.45.1/React.podspec`)
- SSZipArchive (~> 1.8.1)
- SSZipArchive (~> 2.1.4)
- Yoga

SPEC REPOS:
Expand All @@ -59,9 +59,9 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Protobuf: 1eb9700044745f00181c136ef21b8ff3ad5a0fd5
React: 505e0132cd9aaba1a56e47ef509220dd794ec9be
SSZipArchive: 04547dfa448be5ed7ecbaf7eaf8a6e9eb9b42997
SSZipArchive: 41455d4b8d2b6ab93990820b50dc697c2554a322
Yoga: aaae8abea68951f60bee05f6277d3eed90bb91bb

PODFILE CHECKSUM: b7d71960f4fe0b08fd7d4651b412bb8bec6c19f2
PODFILE CHECKSUM: 7f6714245d47e69d2933463289e4c4d6de65b831

COCOAPODS: 1.5.3
COCOAPODS: 1.6.0.beta.2
4 changes: 2 additions & 2 deletions SVGAPlayer-React.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "SVGAPlayer"
s.version = "2.3.0"
s.version = "2.3.1"
s.summary = "SVGAPlayer 是一个高性能的动画播放器"
s.description = <<-DESC
SVGA 是一个私有的动画格式,由 YY UED 主导开发。
Expand All @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.subspec 'Core' do |ss|
ss.source_files = "Source/*.{h,m}", "React/*.{h,m}"
ss.requires_arc = true
ss.dependency 'SSZipArchive', '1.8.1'
ss.dependency 'SSZipArchive', '2.1.4'
ss.library = "z"
ss.dependency 'SVGAPlayer/ProtoFiles'
end
Expand Down
4 changes: 2 additions & 2 deletions SVGAPlayer.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "SVGAPlayer"
s.version = "2.3.0"
s.version = "2.3.1"
s.summary = "SVGAPlayer 是一个高性能的动画播放器"
s.description = <<-DESC
SVGA 是一个私有的动画格式,由 YY UED 主导开发。
Expand All @@ -17,7 +17,7 @@ Pod::Spec.new do |s|
s.subspec 'Core' do |ss|
ss.source_files = "Source/*.{h,m}"
ss.requires_arc = true
ss.dependency 'SSZipArchive', '1.8.1'
ss.dependency 'SSZipArchive', '2.1.4'
ss.library = "z"
ss.framework = "AVFoundation"
ss.dependency 'SVGAPlayer/ProtoFiles'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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>SchemeUserState</key>
<dict>
<key>SVGAPlayer React.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>7</integer>
</dict>
<key>SVGAPlayer.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>6</integer>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
2 changes: 2 additions & 0 deletions Source/SVGAParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

@interface SVGAParser : NSObject

@property (nonatomic, assign) BOOL enabledMemoryCache;

- (void)parseWithURL:(nonnull NSURL *)URL
completionBlock:(void ( ^ _Nonnull )(SVGAVideoEntity * _Nullable videoItem))completionBlock
failureBlock:(void ( ^ _Nullable)(NSError * _Nullable error))failureBlock;
Expand Down
20 changes: 15 additions & 5 deletions Source/SVGAParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ - (void)parseWithCacheKey:(nonnull NSString *)cacheKey
[videoItem resetImagesWithProtoObject:protoObject];
[videoItem resetSpritesWithProtoObject:protoObject];
[videoItem resetAudiosWithProtoObject:protoObject];
[videoItem saveCache:cacheKey];
if (self.enabledMemoryCache) {
[videoItem saveCache:cacheKey];
}
if (completionBlock) {
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
completionBlock(videoItem);
Expand All @@ -148,7 +150,9 @@ - (void)parseWithCacheKey:(nonnull NSString *)cacheKey
SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithJSONObject:JSONObject cacheDir:cacheDir];
[videoItem resetImagesWithJSONObject:JSONObject];
[videoItem resetSpritesWithJSONObject:JSONObject];
[videoItem saveCache:cacheKey];
if (self.enabledMemoryCache) {
[videoItem saveCache:cacheKey];
}
if (completionBlock) {
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
completionBlock(videoItem);
Expand Down Expand Up @@ -200,7 +204,9 @@ - (void)parseWithData:(nonnull NSData *)data
[videoItem resetImagesWithProtoObject:protoObject];
[videoItem resetSpritesWithProtoObject:protoObject];
[videoItem resetAudiosWithProtoObject:protoObject];
[videoItem saveCache:cacheKey];
if (self.enabledMemoryCache) {
[videoItem saveCache:cacheKey];
}
if (completionBlock) {
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
completionBlock(videoItem);
Expand Down Expand Up @@ -253,7 +259,9 @@ - (void)parseWithData:(nonnull NSData *)data
SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithProtoObject:protoObject cacheDir:cacheDir];
[videoItem resetImagesWithProtoObject:protoObject];
[videoItem resetSpritesWithProtoObject:protoObject];
[videoItem saveCache:cacheKey];
if (self.enabledMemoryCache) {
[videoItem saveCache:cacheKey];
}
if (completionBlock) {
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
completionBlock(videoItem);
Expand All @@ -277,7 +285,9 @@ - (void)parseWithData:(nonnull NSData *)data
SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithJSONObject:JSONObject cacheDir:cacheDir];
[videoItem resetImagesWithJSONObject:JSONObject];
[videoItem resetSpritesWithJSONObject:JSONObject];
[videoItem saveCache:cacheKey];
if (self.enabledMemoryCache) {
[videoItem saveCache:cacheKey];
}
if (completionBlock) {
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
completionBlock(videoItem);
Expand Down
5 changes: 4 additions & 1 deletion Source/SVGAVectorLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ - (void)stepToFrame:(NSInteger)frame {
}

- (BOOL)isKeepFrame:(SVGAVideoSpriteFrameEntity *)frameItem {
if ([frameItem.shapes.firstObject isKindOfClass:[NSDictionary class]]) {
if (frameItem.shapes.count == 0) {
return NO;
}
else if ([frameItem.shapes.firstObject isKindOfClass:[NSDictionary class]]) {
return [frameItem.shapes.firstObject[@"type"] isKindOfClass:[NSString class]] &&
[frameItem.shapes.firstObject[@"type"] isEqualToString:@"keep"];
}
Expand Down

0 comments on commit 116a91f

Please sign in to comment.