not add protect in frameDuration method

This commit is contained in:
kinarobin 2021-01-04 13:36:10 +08:00
parent e52686b452
commit 784a29578c
2 changed files with 3 additions and 11 deletions

View File

@ -102,7 +102,6 @@
if (!data) {
return nil;
}
UIImage *image;
NSArray<id<SDImageCoder>> *coders = self.coders;
for (id<SDImageCoder> coder in coders.reverseObjectEnumerator) {
@ -119,7 +118,6 @@
if (!image) {
return nil;
}
NSArray<id<SDImageCoder>> *coders = self.coders;
for (id<SDImageCoder> coder in coders.reverseObjectEnumerator) {
if ([coder canEncodeToFormat:format]) {

View File

@ -29,8 +29,8 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
@implementation SDImageIOCoderFrame
@end
BOOL willTerminated_;
NSLock *terminatedLock_;
static BOOL willTerminated_;
static NSLock *terminatedLock_;
@implementation SDImageIOAnimatedCoder {
size_t _width, _height;
@ -186,17 +186,11 @@ NSLock *terminatedLock_;
}
+ (NSTimeInterval)frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
NSTimeInterval frameDuration = 0.1;
// Earily return when application will be terminated.
if (self.willTerminated) {
return frameDuration;
}
NSDictionary *options = @{
(__bridge NSString *)kCGImageSourceShouldCacheImmediately : @(YES),
(__bridge NSString *)kCGImageSourceShouldCache : @(YES) // Always cache to reduce CPU usage
};
NSTimeInterval frameDuration = 0.1;
CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, (__bridge CFDictionaryRef)options);
if (!cfFrameProperties) {
return frameDuration;