Fix that some option mask check with local BOOL variable, will result error result on 32 bit device. Use a macro help to solve this issue
This commit is contained in:
parent
2350dcf77d
commit
dfa871b20e
|
@ -11,10 +11,11 @@
|
|||
#import "SDImageCoderHelper.h"
|
||||
#import "SDAnimatedImage.h"
|
||||
#import "UIImage+Metadata.h"
|
||||
#import "SDInternalMacros.h"
|
||||
|
||||
UIImage * _Nullable SDImageCacheDecodeImageData(NSData * _Nonnull imageData, NSString * _Nonnull cacheKey, SDWebImageOptions options, SDWebImageContext * _Nullable context) {
|
||||
UIImage *image;
|
||||
BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
||||
BOOL decodeFirstFrame = SD_OPTIONS_CONTAINS(options, SDWebImageDecodeFirstFrameOnly);
|
||||
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
||||
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
||||
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)};
|
||||
|
@ -46,7 +47,7 @@ UIImage * _Nullable SDImageCacheDecodeImageData(NSData * _Nonnull imageData, NSS
|
|||
image = [[SDImageCodersManager sharedManager] decodedImageWithData:imageData options:coderOptions];
|
||||
}
|
||||
if (image) {
|
||||
BOOL shouldDecode = (options & SDWebImageAvoidDecodeImage) == 0;
|
||||
BOOL shouldDecode = !SD_OPTIONS_CONTAINS(options, SDWebImageAvoidDecodeImage);
|
||||
if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
||||
// `SDAnimatedImage` do not decode
|
||||
shouldDecode = NO;
|
||||
|
@ -55,7 +56,7 @@ UIImage * _Nullable SDImageCacheDecodeImageData(NSData * _Nonnull imageData, NSS
|
|||
shouldDecode = NO;
|
||||
}
|
||||
if (shouldDecode) {
|
||||
BOOL shouldScaleDown = options & SDWebImageScaleDownLargeImages;
|
||||
BOOL shouldScaleDown = SD_OPTIONS_CONTAINS(options, SDWebImageScaleDownLargeImages);
|
||||
if (shouldScaleDown) {
|
||||
image = [SDImageCoderHelper decodedAndScaledDownImageWithImage:image limitBytes:0];
|
||||
} else {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#import "SDImageCoderHelper.h"
|
||||
#import "SDAnimatedImage.h"
|
||||
#import "UIImage+Metadata.h"
|
||||
#import "SDInternalMacros.h"
|
||||
#import "objc/runtime.h"
|
||||
|
||||
static void * SDImageLoaderProgressiveCoderKey = &SDImageLoaderProgressiveCoderKey;
|
||||
|
@ -28,7 +29,7 @@ UIImage * _Nullable SDImageLoaderDecodeImageData(NSData * _Nonnull imageData, NS
|
|||
} else {
|
||||
cacheKey = imageURL.absoluteString;
|
||||
}
|
||||
BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
||||
BOOL decodeFirstFrame = SD_OPTIONS_CONTAINS(options, SDWebImageDecodeFirstFrameOnly);
|
||||
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
||||
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
||||
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)};
|
||||
|
@ -60,7 +61,7 @@ UIImage * _Nullable SDImageLoaderDecodeImageData(NSData * _Nonnull imageData, NS
|
|||
image = [[SDImageCodersManager sharedManager] decodedImageWithData:imageData options:coderOptions];
|
||||
}
|
||||
if (image) {
|
||||
BOOL shouldDecode = (options & SDWebImageAvoidDecodeImage) == 0;
|
||||
BOOL shouldDecode = !SD_OPTIONS_CONTAINS(options, SDWebImageAvoidDecodeImage);
|
||||
if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
||||
// `SDAnimatedImage` do not decode
|
||||
shouldDecode = NO;
|
||||
|
@ -70,7 +71,7 @@ UIImage * _Nullable SDImageLoaderDecodeImageData(NSData * _Nonnull imageData, NS
|
|||
}
|
||||
|
||||
if (shouldDecode) {
|
||||
BOOL shouldScaleDown = options & SDWebImageScaleDownLargeImages;
|
||||
BOOL shouldScaleDown = SD_OPTIONS_CONTAINS(options, SDWebImageScaleDownLargeImages);
|
||||
if (shouldScaleDown) {
|
||||
image = [SDImageCoderHelper decodedAndScaledDownImageWithImage:image limitBytes:0];
|
||||
} else {
|
||||
|
@ -95,7 +96,7 @@ UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NSData * _Nonnull im
|
|||
} else {
|
||||
cacheKey = imageURL.absoluteString;
|
||||
}
|
||||
BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly;
|
||||
BOOL decodeFirstFrame = SD_OPTIONS_CONTAINS(options, SDWebImageDecodeFirstFrameOnly);
|
||||
NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor];
|
||||
CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey);
|
||||
SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)};
|
||||
|
@ -142,7 +143,7 @@ UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NSData * _Nonnull im
|
|||
image = [progressiveCoder incrementalDecodedImageWithOptions:coderOptions];
|
||||
}
|
||||
if (image) {
|
||||
BOOL shouldDecode = (options & SDWebImageAvoidDecodeImage) == 0;
|
||||
BOOL shouldDecode = !SD_OPTIONS_CONTAINS(options, SDWebImageAvoidDecodeImage);
|
||||
if ([image.class conformsToProtocol:@protocol(SDAnimatedImage)]) {
|
||||
// `SDAnimatedImage` do not decode
|
||||
shouldDecode = NO;
|
||||
|
|
|
@ -270,7 +270,7 @@ static void * SDWebImageDownloaderContext = &SDWebImageDownloaderContext;
|
|||
// In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise
|
||||
NSURLRequestCachePolicy cachePolicy = options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData;
|
||||
NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:cachePolicy timeoutInterval:timeoutInterval];
|
||||
mutableRequest.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies);
|
||||
mutableRequest.HTTPShouldHandleCookies = SD_OPTIONS_CONTAINS(options, SDWebImageDownloaderHandleCookies);
|
||||
mutableRequest.HTTPShouldUsePipelining = YES;
|
||||
SD_LOCK(self.HTTPHeadersLock);
|
||||
mutableRequest.allHTTPHeaderFields = self.HTTPHeaders;
|
||||
|
|
|
@ -498,7 +498,7 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
}
|
||||
|
||||
- (BOOL)shouldContinueWhenAppEntersBackground {
|
||||
return self.options & SDWebImageDownloaderContinueInBackground;
|
||||
return SD_OPTIONS_CONTAINS(self.options, SDWebImageDownloaderContinueInBackground);
|
||||
}
|
||||
|
||||
- (void)callCompletionBlocksWithError:(nullable NSError *)error {
|
||||
|
|
|
@ -185,7 +185,7 @@ static id<SDImageLoader> _defaultImageLoader;
|
|||
progress:(nullable SDImageLoaderProgressBlock)progressBlock
|
||||
completed:(nullable SDInternalCompletionBlock)completedBlock {
|
||||
// Check whether we should query cache
|
||||
BOOL shouldQueryCache = (options & SDWebImageFromLoaderOnly) == 0;
|
||||
BOOL shouldQueryCache = !SD_OPTIONS_CONTAINS(options, SDWebImageFromLoaderOnly);
|
||||
if (shouldQueryCache) {
|
||||
id<SDWebImageCacheKeyFilter> cacheKeyFilter = context[SDWebImageContextCacheKeyFilter];
|
||||
NSString *key = [self cacheKeyForURL:url cacheKeyFilter:cacheKeyFilter];
|
||||
|
@ -218,7 +218,7 @@ static id<SDImageLoader> _defaultImageLoader;
|
|||
progress:(nullable SDImageLoaderProgressBlock)progressBlock
|
||||
completed:(nullable SDInternalCompletionBlock)completedBlock {
|
||||
// Check whether we should download image from network
|
||||
BOOL shouldDownload = (options & SDWebImageFromCacheOnly) == 0;
|
||||
BOOL shouldDownload = !SD_OPTIONS_CONTAINS(options, SDWebImageFromCacheOnly);
|
||||
shouldDownload &= (!cachedImage || options & SDWebImageRefreshCached);
|
||||
shouldDownload &= (![self.delegate respondsToSelector:@selector(imageManager:shouldDownloadImageForURL:)] || [self.delegate imageManager:self shouldDownloadImageForURL:url]);
|
||||
shouldDownload &= [self.imageLoader canRequestImageForURL:url];
|
||||
|
|
|
@ -262,7 +262,7 @@ const int64_t SDWebImageProgressUnitCountUnknown = 1LL;
|
|||
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
|
||||
context.duration = transition.duration;
|
||||
context.timingFunction = transition.timingFunction;
|
||||
context.allowsImplicitAnimation = (transition.animationOptions & SDWebImageAnimationOptionAllowsImplicitAnimation);
|
||||
context.allowsImplicitAnimation = SD_OPTIONS_CONTAINS(transition.animationOptions, SDWebImageAnimationOptionAllowsImplicitAnimation);
|
||||
if (finalSetImageBlock && !transition.avoidAutoSetImage) {
|
||||
finalSetImageBlock(image, imageData, cacheType, imageURL);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
#define SD_UNLOCK(lock) dispatch_semaphore_signal(lock);
|
||||
#endif
|
||||
|
||||
#ifndef SD_OPTIONS_CONTAINS
|
||||
#define SD_OPTIONS_CONTAINS(options, value) (((options) & (value)) == (value))
|
||||
#endif
|
||||
|
||||
#ifndef weakify
|
||||
#define weakify(...) \
|
||||
sd_keywordify \
|
||||
|
|
Loading…
Reference in New Issue