diff --git a/SDWebImage/Core/SDAnimatedImage.h b/SDWebImage/Core/SDAnimatedImage.h index 2683984f..feb118e6 100644 --- a/SDWebImage/Core/SDAnimatedImage.h +++ b/SDWebImage/Core/SDAnimatedImage.h @@ -57,6 +57,12 @@ */ @property (nonatomic, assign, readonly, getter=isAllFramesLoaded) BOOL allFramesLoaded; +/** + Return the animated image coder if the image is created with `initWithAnimatedCoder:scale:` method. + @note We use this with animated coder which conforms to `SDProgressiveImageCoder` for progressive animation decoding. + */ +@property (nonatomic, strong, readonly, nullable) id animatedCoder; + @end /** diff --git a/SDWebImage/Core/SDAnimatedImage.m b/SDWebImage/Core/SDAnimatedImage.m index 7d9ed01a..ce86e331 100644 --- a/SDWebImage/Core/SDAnimatedImage.m +++ b/SDWebImage/Core/SDAnimatedImage.m @@ -32,7 +32,7 @@ static CGFloat SDImageScaleFromPath(NSString *string) { @interface SDAnimatedImage () -@property (nonatomic, strong) id coder; +@property (nonatomic, strong) id animatedCoder; @property (nonatomic, assign, readwrite) SDImageFormat animatedImageFormat; @property (atomic, copy) NSArray *loadedAnimatedImageFrames; // Mark as atomic to keep thread-safe @property (nonatomic, assign, getter=isAllFramesLoaded) BOOL allFramesLoaded; @@ -156,7 +156,7 @@ static CGFloat SDImageScaleFromPath(NSString *string) { self = [super initWithCGImage:image.CGImage scale:MAX(scale, 1) orientation:image.imageOrientation]; #endif if (self) { - _coder = animatedCoder; + _animatedCoder = animatedCoder; NSData *data = [animatedCoder animatedImageData]; SDImageFormat format = [NSData sd_imageFormatForImageData:data]; _animatedImageFormat = format; @@ -207,7 +207,7 @@ static CGFloat SDImageScaleFromPath(NSString *string) { if (!animatedCoder) { return self; } - _coder = animatedCoder; + _animatedCoder = animatedCoder; SDImageFormat format = [NSData sd_imageFormatForImageData:animatedImageData]; _animatedImageFormat = format; } @@ -229,15 +229,15 @@ static CGFloat SDImageScaleFromPath(NSString *string) { #pragma mark - SDAnimatedImage - (NSData *)animatedImageData { - return [self.coder animatedImageData]; + return [self.animatedCoder animatedImageData]; } - (NSUInteger)animatedImageLoopCount { - return [self.coder animatedImageLoopCount]; + return [self.animatedCoder animatedImageLoopCount]; } - (NSUInteger)animatedImageFrameCount { - return [self.coder animatedImageFrameCount]; + return [self.animatedCoder animatedImageFrameCount]; } - (UIImage *)animatedImageFrameAtIndex:(NSUInteger)index { @@ -248,7 +248,7 @@ static CGFloat SDImageScaleFromPath(NSString *string) { SDImageFrame *frame = [self.loadedAnimatedImageFrames objectAtIndex:index]; return frame.image; } - return [self.coder animatedImageFrameAtIndex:index]; + return [self.animatedCoder animatedImageFrameAtIndex:index]; } - (NSTimeInterval)animatedImageDurationAtIndex:(NSUInteger)index { @@ -259,7 +259,7 @@ static CGFloat SDImageScaleFromPath(NSString *string) { SDImageFrame *frame = [self.loadedAnimatedImageFrames objectAtIndex:index]; return frame.duration; } - return [self.coder animatedImageDurationAtIndex:index]; + return [self.animatedCoder animatedImageDurationAtIndex:index]; } @end