Merge branch '5.4.x' of https://github.com/dreampiggy/SDWebImage
This commit is contained in:
commit
eb6c89ed89
|
@ -1,3 +1,9 @@
|
|||
## [5.4.2 - 5.4 Patch, on Jan 7th, 2020](https://github.com/rs/SDWebImage/releases/tag/5.4.2)
|
||||
See [all tickets marked for the 5.4.2 release](https://github.com/SDWebImage/SDWebImage/milestone/58)
|
||||
|
||||
### Fixes
|
||||
- SDAnimatedImage now only keep the animated coder when frame count >=1 , else we will behave like UIImage to save RAM usage #2924
|
||||
|
||||
## [5.4.1 - 5.4 Patch, on Dec 27th, 2019](https://github.com/rs/SDWebImage/releases/tag/5.4.1)
|
||||
See [all tickets marked for the 5.4.1 release](https://github.com/SDWebImage/SDWebImage/milestone/56)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'SDWebImage'
|
||||
s.version = '5.4.1'
|
||||
s.version = '5.4.2'
|
||||
|
||||
s.osx.deployment_target = '10.10'
|
||||
s.ios.deployment_target = '8.0'
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
|
||||
// This class override these methods from UIImage(NSImage), and it supports NSSecureCoding.
|
||||
// You should use these methods to create a new animated image. Use other methods just call super instead.
|
||||
// Pay attention, when the animated image frame count <= 1, all the `SDAnimatedImage` protocol methods will return nil or 0 value, you'd better check the frame count before usage and keep fallback.
|
||||
+ (nullable instancetype)imageNamed:(nonnull NSString *)name; // Cache in memory, no Asset Catalog support
|
||||
#if __has_include(<UIKit/UITraitCollection.h>)
|
||||
+ (nullable instancetype)imageNamed:(nonnull NSString *)name inBundle:(nullable NSBundle *)bundle compatibleWithTraitCollection:(nullable UITraitCollection *)traitCollection; // Cache in memory, no Asset Catalog support
|
||||
|
|
|
@ -156,7 +156,10 @@ static CGFloat SDImageScaleFromPath(NSString *string) {
|
|||
self = [super initWithCGImage:image.CGImage scale:MAX(scale, 1) orientation:image.imageOrientation];
|
||||
#endif
|
||||
if (self) {
|
||||
_animatedCoder = animatedCoder;
|
||||
// Only keep the animated coder if frame count > 1, save RAM usage for non-animated image format (APNG/WebP)
|
||||
if (animatedCoder.animatedImageFrameCount > 1) {
|
||||
_animatedCoder = animatedCoder;
|
||||
}
|
||||
NSData *data = [animatedCoder animatedImageData];
|
||||
SDImageFormat format = [NSData sd_imageFormatForImageData:data];
|
||||
_animatedImageFormat = format;
|
||||
|
@ -166,6 +169,9 @@ static CGFloat SDImageScaleFromPath(NSString *string) {
|
|||
|
||||
#pragma mark - Preload
|
||||
- (void)preloadAllFrames {
|
||||
if (!_animatedCoder) {
|
||||
return;
|
||||
}
|
||||
if (!self.isAllFramesLoaded) {
|
||||
NSMutableArray<SDImageFrame *> *frames = [NSMutableArray arrayWithCapacity:self.animatedImageFrameCount];
|
||||
for (size_t i = 0; i < self.animatedImageFrameCount; i++) {
|
||||
|
@ -180,6 +186,9 @@ static CGFloat SDImageScaleFromPath(NSString *string) {
|
|||
}
|
||||
|
||||
- (void)unloadAllFrames {
|
||||
if (!_animatedCoder) {
|
||||
return;
|
||||
}
|
||||
if (self.isAllFramesLoaded) {
|
||||
self.loadedAnimatedImageFrames = nil;
|
||||
self.allFramesLoaded = NO;
|
||||
|
@ -190,11 +199,12 @@ static CGFloat SDImageScaleFromPath(NSString *string) {
|
|||
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
self = [super initWithCoder:aDecoder];
|
||||
if (self) {
|
||||
_animatedImageFormat = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(animatedImageFormat))];
|
||||
NSData *animatedImageData = [aDecoder decodeObjectOfClass:[NSData class] forKey:NSStringFromSelector(@selector(animatedImageData))];
|
||||
CGFloat scale = self.scale;
|
||||
if (!animatedImageData) {
|
||||
return self;
|
||||
}
|
||||
CGFloat scale = self.scale;
|
||||
id<SDAnimatedImageCoder> animatedCoder = nil;
|
||||
for (id<SDImageCoder>coder in [SDImageCodersManager sharedManager].coders) {
|
||||
if ([coder conformsToProtocol:@protocol(SDAnimatedImageCoder)]) {
|
||||
|
@ -207,15 +217,16 @@ static CGFloat SDImageScaleFromPath(NSString *string) {
|
|||
if (!animatedCoder) {
|
||||
return self;
|
||||
}
|
||||
_animatedCoder = animatedCoder;
|
||||
SDImageFormat format = [NSData sd_imageFormatForImageData:animatedImageData];
|
||||
_animatedImageFormat = format;
|
||||
if (animatedCoder.animatedImageFrameCount > 1) {
|
||||
_animatedCoder = animatedCoder;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder {
|
||||
[super encodeWithCoder:aCoder];
|
||||
[aCoder encodeInteger:self.animatedImageFormat forKey:NSStringFromSelector(@selector(animatedImageFormat))];
|
||||
NSData *animatedImageData = self.animatedImageData;
|
||||
if (animatedImageData) {
|
||||
[aCoder encodeObject:animatedImageData forKey:NSStringFromSelector(@selector(animatedImageData))];
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>5.4.1</string>
|
||||
<string>5.4.2</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>5.4.1</string>
|
||||
<string>5.4.2</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
|
|
Loading…
Reference in New Issue