Merge branch 'master' of https://github.com/rs/SDWebImage into 5.x
# Conflicts: # SDWebImage/SDImageCache.h # SDWebImage/SDImageCache.m # SDWebImage/SDWebImageManager.m
This commit is contained in:
commit
f7af36f3bd
|
@ -35,24 +35,29 @@ typedef NS_OPTIONS(NSUInteger, SDImageCacheOptions) {
|
||||||
* By default, we query the memory cache synchronously, disk cache asynchronously. This mask can force to query disk cache synchronously.
|
* By default, we query the memory cache synchronously, disk cache asynchronously. This mask can force to query disk cache synchronously.
|
||||||
*/
|
*/
|
||||||
SDImageCacheQueryDiskSync = 1 << 1,
|
SDImageCacheQueryDiskSync = 1 << 1,
|
||||||
|
/**
|
||||||
|
* By default, images are decoded respecting their original size. On iOS, this flag will scale down the
|
||||||
|
* images to a size compatible with the constrained memory of devices.
|
||||||
|
*/
|
||||||
|
SDImageCacheScaleDownLargeImages = 1 << 2,
|
||||||
/**
|
/**
|
||||||
* We usually don't apply transform on animated images as most transformers could not manage animated images.
|
* We usually don't apply transform on animated images as most transformers could not manage animated images.
|
||||||
* Use this flag to transform them anyway.
|
* Use this flag to transform them anyway.
|
||||||
*/
|
*/
|
||||||
SDImageCacheTransformAnimatedImage = 1 << 2,
|
SDImageCacheTransformAnimatedImage = 1 << 3,
|
||||||
/**
|
/**
|
||||||
* 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.
|
* 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 a issue due to excessive memory consumption, This flag can prevent decode the image.
|
||||||
*/
|
*/
|
||||||
SDImageCacheAvoidDecodeImage = 1 << 3,
|
SDImageCacheAvoidDecodeImage = 1 << 4,
|
||||||
/**
|
/**
|
||||||
* By default, we decode the animated image. This flag can force decode the first frame only and produece the static image.
|
* By default, we decode the animated image. This flag can force decode the first frame only and produece the static image.
|
||||||
*/
|
*/
|
||||||
SDImageCacheDecodeFirstFrameOnly = 1 << 4,
|
SDImageCacheDecodeFirstFrameOnly = 1 << 5,
|
||||||
/**
|
/**
|
||||||
* By default, for `SDAnimatedImage`, we decode the animated image frame during rendering to reduce memory usage. This flag actually trigger `preloadAllAnimatedImageFrames = YES` after image load from disk cache
|
* By default, for `SDAnimatedImage`, we decode the animated image frame during rendering to reduce memory usage. This flag actually trigger `preloadAllAnimatedImageFrames = YES` after image load from disk cache
|
||||||
*/
|
*/
|
||||||
SDImageCachePreloadAllFrames = 1 << 5
|
SDImageCachePreloadAllFrames = 1 << 6
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void(^SDCacheQueryCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType);
|
typedef void(^SDCacheQueryCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType);
|
||||||
|
|
|
@ -328,8 +328,13 @@
|
||||||
shouldDecode = NO;
|
shouldDecode = NO;
|
||||||
}
|
}
|
||||||
if (shouldDecode) {
|
if (shouldDecode) {
|
||||||
|
BOOL shouldScaleDown = options & SDImageCacheScaleDownLargeImages;
|
||||||
|
if (shouldScaleDown) {
|
||||||
|
image = [SDWebImageCoderHelper decodedAndScaledDownImageWithImage:image limitBytes:0];
|
||||||
|
} else {
|
||||||
image = [SDWebImageCoderHelper decodedImageWithImage:image];
|
image = [SDWebImageCoderHelper decodedImageWithImage:image];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return image;
|
return image;
|
||||||
} else {
|
} else {
|
||||||
return nil;
|
return nil;
|
||||||
|
|
|
@ -157,6 +157,7 @@
|
||||||
SDImageCacheOptions cacheOptions = 0;
|
SDImageCacheOptions cacheOptions = 0;
|
||||||
if (options & SDWebImageQueryDataWhenInMemory) cacheOptions |= SDImageCacheQueryDataWhenInMemory;
|
if (options & SDWebImageQueryDataWhenInMemory) cacheOptions |= SDImageCacheQueryDataWhenInMemory;
|
||||||
if (options & SDWebImageQueryDiskSync) cacheOptions |= SDImageCacheQueryDiskSync;
|
if (options & SDWebImageQueryDiskSync) cacheOptions |= SDImageCacheQueryDiskSync;
|
||||||
|
if (options & SDWebImageScaleDownLargeImages) cacheOptions |= SDImageCacheScaleDownLargeImages;
|
||||||
if (options & SDWebImageTransformAnimatedImage) cacheOptions |= SDImageCacheTransformAnimatedImage;
|
if (options & SDWebImageTransformAnimatedImage) cacheOptions |= SDImageCacheTransformAnimatedImage;
|
||||||
if (options & SDWebImageDecodeFirstFrameOnly) cacheOptions |= SDImageCacheDecodeFirstFrameOnly;
|
if (options & SDWebImageDecodeFirstFrameOnly) cacheOptions |= SDImageCacheDecodeFirstFrameOnly;
|
||||||
if (options & SDWebImagePreloadAllFrames) cacheOptions |= SDImageCachePreloadAllFrames;
|
if (options & SDWebImagePreloadAllFrames) cacheOptions |= SDImageCachePreloadAllFrames;
|
||||||
|
|
Loading…
Reference in New Issue