Add extra check when user provide SDImageCoderDecodeUseLazyDecoding
This commit is contained in:
parent
3000dd5098
commit
136d05fce8
|
@ -116,7 +116,11 @@ UIImage * _Nullable SDImageCacheDecodeImageData(NSData * _Nonnull imageData, NSS
|
|||
}
|
||||
if (image) {
|
||||
BOOL shouldDecode = !SD_OPTIONS_CONTAINS(options, SDWebImageAvoidDecodeImage);
|
||||
if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
||||
BOOL lazyDecode = [coderOptions[SDImageCoderDecodeUseLazyDecoding] boolValue];
|
||||
if (lazyDecode) {
|
||||
// lazyDecode = NO means we should not forceDecode, highest priority
|
||||
shouldDecode = NO;
|
||||
} else if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
||||
// `SDAnimatedImage` do not decode
|
||||
shouldDecode = NO;
|
||||
} else if (image.sd_isAnimated) {
|
||||
|
|
|
@ -77,14 +77,17 @@ UIImage * _Nullable SDImageLoaderDecodeImageData(NSData * _Nonnull imageData, NS
|
|||
}
|
||||
if (image) {
|
||||
BOOL shouldDecode = !SD_OPTIONS_CONTAINS(options, SDWebImageAvoidDecodeImage);
|
||||
if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
||||
BOOL lazyDecode = [coderOptions[SDImageCoderDecodeUseLazyDecoding] boolValue];
|
||||
if (lazyDecode) {
|
||||
// lazyDecode = NO means we should not forceDecode, highest priority
|
||||
shouldDecode = NO;
|
||||
} else if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
||||
// `SDAnimatedImage` do not decode
|
||||
shouldDecode = NO;
|
||||
} else if (image.sd_isAnimated) {
|
||||
// animated image do not decode
|
||||
shouldDecode = NO;
|
||||
}
|
||||
|
||||
if (shouldDecode) {
|
||||
image = [SDImageCoderHelper decodedImageWithImage:image];
|
||||
}
|
||||
|
@ -157,7 +160,11 @@ UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NSData * _Nonnull im
|
|||
}
|
||||
if (image) {
|
||||
BOOL shouldDecode = !SD_OPTIONS_CONTAINS(options, SDWebImageAvoidDecodeImage);
|
||||
if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
||||
BOOL lazyDecode = [coderOptions[SDImageCoderDecodeUseLazyDecoding] boolValue];
|
||||
if (lazyDecode) {
|
||||
// lazyDecode = NO means we should not forceDecode, highest priority
|
||||
shouldDecode = NO;
|
||||
} else if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
||||
// `SDAnimatedImage` do not decode
|
||||
shouldDecode = NO;
|
||||
} else if (image.sd_isAnimated) {
|
||||
|
@ -167,10 +174,10 @@ UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NSData * _Nonnull im
|
|||
if (shouldDecode) {
|
||||
image = [SDImageCoderHelper decodedImageWithImage:image];
|
||||
}
|
||||
// mark the image as progressive (completed one are not mark as progressive)
|
||||
image.sd_isIncremental = !finished;
|
||||
// assign the decode options, to let manager check whether to re-decode if needed
|
||||
image.sd_decodeOptions = coderOptions;
|
||||
// mark the image as progressive (completed one are not mark as progressive)
|
||||
image.sd_isIncremental = !finished;
|
||||
}
|
||||
|
||||
return image;
|
||||
|
|
|
@ -169,7 +169,8 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
|
|||
|
||||
/**
|
||||
* By default, we will decode the image in the background during cache query and download from the network. This can help to improve performance because when rendering image on the screen, it need to be firstly decoded. But this happen on the main queue by Core Animation.
|
||||
* However, this process may increase the memory usage as well. If you are experiencing a issue due to excessive memory consumption, This flag can prevent decode the image.
|
||||
* However, this process may increase the memory usage as well. If you are experiencing an issue due to excessive memory consumption, This flag can prevent decode the image.
|
||||
* @note 5.14.0 introduce `SDImageCoderDecodeUseLazyDecoding`, use that for better control from codec, instead of post-processing. Which acts the similar like this option but works for SDAnimatedImage as well (this one does not)
|
||||
*/
|
||||
SDWebImageAvoidDecodeImage = 1 << 18,
|
||||
|
||||
|
|
Loading…
Reference in New Issue