diff --git a/Podfile b/Podfile index 581b589e..ac1e7f32 100644 --- a/Podfile +++ b/Podfile @@ -1,6 +1,6 @@ -platform :ios, '7.0' +platform :ios, '8.0' target 'SDCycleScrollView' #use_frameworks! -pod 'SDWebImage', '>= 4.0.0' +pod 'SDWebImage', '>= 5.0.0' diff --git a/Podfile.lock b/Podfile.lock index 5138323b..a1485b6f 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,14 +1,18 @@ PODS: - - SDWebImage (4.0.0): - - SDWebImage/Core (= 4.0.0) - - SDWebImage/Core (4.0.0) + - SDWebImage (5.0.0): + - SDWebImage/Core (= 5.0.0) + - SDWebImage/Core (5.0.0) DEPENDENCIES: - - SDWebImage (~> 4.0.0) + - SDWebImage (>= 5.0.0) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - SDWebImage SPEC CHECKSUMS: - SDWebImage: 76a6348bdc74eb5a55dd08a091ef298e56b55e41 + SDWebImage: 5de80a0302de9e377e62f47d2fa1304efff0e55f -PODFILE CHECKSUM: 15dea9690d6001704f1e5d2a3d5fe6a8628a9d3f +PODFILE CHECKSUM: 36b38d6f3870a9dd8180509afda3b51d62283956 -COCOAPODS: 1.1.1 +COCOAPODS: 1.5.3 diff --git a/Pods/Headers/Private/SDWebImage/NSBezierPath+RoundedCorners.h b/Pods/Headers/Private/SDWebImage/NSBezierPath+RoundedCorners.h new file mode 120000 index 00000000..18770a2b --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/NSBezierPath+RoundedCorners.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/Private/NSBezierPath+RoundedCorners.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/NSButton+WebCache.h b/Pods/Headers/Private/SDWebImage/NSButton+WebCache.h new file mode 120000 index 00000000..487f0e35 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/NSButton+WebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/NSButton+WebCache.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/NSImage+Compatibility.h b/Pods/Headers/Private/SDWebImage/NSImage+Compatibility.h new file mode 120000 index 00000000..dde4c7e6 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/NSImage+Compatibility.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/NSImage+Compatibility.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/NSImage+WebCache.h b/Pods/Headers/Private/SDWebImage/NSImage+WebCache.h deleted file mode 120000 index b7a00e1f..00000000 --- a/Pods/Headers/Private/SDWebImage/NSImage+WebCache.h +++ /dev/null @@ -1 +0,0 @@ -../../../SDWebImage/SDWebImage/NSImage+WebCache.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDAnimatedImage.h b/Pods/Headers/Private/SDWebImage/SDAnimatedImage.h new file mode 120000 index 00000000..bcb3fd5f --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDAnimatedImage.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDAnimatedImage.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDAnimatedImageRep.h b/Pods/Headers/Private/SDWebImage/SDAnimatedImageRep.h new file mode 120000 index 00000000..fbf739fd --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDAnimatedImageRep.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDAnimatedImageRep.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDAnimatedImageView+WebCache.h b/Pods/Headers/Private/SDWebImage/SDAnimatedImageView+WebCache.h new file mode 120000 index 00000000..d89f0976 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDAnimatedImageView+WebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDAnimatedImageView+WebCache.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDAnimatedImageView.h b/Pods/Headers/Private/SDWebImage/SDAnimatedImageView.h new file mode 120000 index 00000000..6cbe3354 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDAnimatedImageView.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDAnimatedImageView.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDAsyncBlockOperation.h b/Pods/Headers/Private/SDWebImage/SDAsyncBlockOperation.h new file mode 120000 index 00000000..1fcccbe5 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDAsyncBlockOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDDiskCache.h b/Pods/Headers/Private/SDWebImage/SDDiskCache.h new file mode 120000 index 00000000..708362ad --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDDiskCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDDiskCache.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageAPNGCoder.h b/Pods/Headers/Private/SDWebImage/SDImageAPNGCoder.h new file mode 120000 index 00000000..467121d8 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageAPNGCoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageAPNGCoder.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageAPNGCoderInternal.h b/Pods/Headers/Private/SDWebImage/SDImageAPNGCoderInternal.h new file mode 120000 index 00000000..358810e6 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageAPNGCoderInternal.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/Private/SDImageAPNGCoderInternal.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageAssetManager.h b/Pods/Headers/Private/SDWebImage/SDImageAssetManager.h new file mode 120000 index 00000000..17c176c0 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageAssetManager.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/Private/SDImageAssetManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageCacheDefine.h b/Pods/Headers/Private/SDWebImage/SDImageCacheDefine.h new file mode 120000 index 00000000..a15891c2 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageCacheDefine.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCacheDefine.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageCachesManager.h b/Pods/Headers/Private/SDWebImage/SDImageCachesManager.h new file mode 120000 index 00000000..f4ee9dfb --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageCachesManager.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCachesManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageCachesManagerOperation.h b/Pods/Headers/Private/SDWebImage/SDImageCachesManagerOperation.h new file mode 120000 index 00000000..3b6f379d --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageCachesManagerOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageCoder.h b/Pods/Headers/Private/SDWebImage/SDImageCoder.h new file mode 120000 index 00000000..5afaf946 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageCoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCoder.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageCoderHelper.h b/Pods/Headers/Private/SDWebImage/SDImageCoderHelper.h new file mode 120000 index 00000000..f3222589 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageCoderHelper.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCoderHelper.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageCodersManager.h b/Pods/Headers/Private/SDWebImage/SDImageCodersManager.h new file mode 120000 index 00000000..c1ec760d --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageCodersManager.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCodersManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageFrame.h b/Pods/Headers/Private/SDWebImage/SDImageFrame.h new file mode 120000 index 00000000..46641f19 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageFrame.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageFrame.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageGIFCoder.h b/Pods/Headers/Private/SDWebImage/SDImageGIFCoder.h new file mode 120000 index 00000000..6322b52f --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageGIFCoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageGIFCoder.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageGIFCoderInternal.h b/Pods/Headers/Private/SDWebImage/SDImageGIFCoderInternal.h new file mode 120000 index 00000000..6c5ab1ad --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageGIFCoderInternal.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/Private/SDImageGIFCoderInternal.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageGraphics.h b/Pods/Headers/Private/SDWebImage/SDImageGraphics.h new file mode 120000 index 00000000..3354e529 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageGraphics.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageGraphics.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageIOCoder.h b/Pods/Headers/Private/SDWebImage/SDImageIOCoder.h new file mode 120000 index 00000000..9394c1ef --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageIOCoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageIOCoder.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageLoader.h b/Pods/Headers/Private/SDWebImage/SDImageLoader.h new file mode 120000 index 00000000..73fbf8e6 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageLoader.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageLoader.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageLoadersManager.h b/Pods/Headers/Private/SDWebImage/SDImageLoadersManager.h new file mode 120000 index 00000000..8e192dd7 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageLoadersManager.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageLoadersManager.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDImageTransformer.h b/Pods/Headers/Private/SDWebImage/SDImageTransformer.h new file mode 120000 index 00000000..e2e017ad --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDImageTransformer.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageTransformer.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDInternalMacros.h b/Pods/Headers/Private/SDWebImage/SDInternalMacros.h new file mode 120000 index 00000000..6e6ed32f --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDInternalMacros.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/Private/SDInternalMacros.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDMemoryCache.h b/Pods/Headers/Private/SDWebImage/SDMemoryCache.h new file mode 120000 index 00000000..932c6130 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDMemoryCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDMemoryCache.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWeakProxy.h b/Pods/Headers/Private/SDWebImage/SDWeakProxy.h new file mode 120000 index 00000000..c683464d --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDWeakProxy.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/Private/SDWeakProxy.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWebImage.h b/Pods/Headers/Private/SDWebImage/SDWebImage.h new file mode 120000 index 00000000..48f99e34 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDWebImage.h @@ -0,0 +1 @@ +../../../SDWebImage/WebImage/SDWebImage.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWebImageCacheKeyFilter.h b/Pods/Headers/Private/SDWebImage/SDWebImageCacheKeyFilter.h new file mode 120000 index 00000000..0e5e35f0 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDWebImageCacheKeyFilter.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageCacheKeyFilter.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWebImageCacheSerializer.h b/Pods/Headers/Private/SDWebImage/SDWebImageCacheSerializer.h new file mode 120000 index 00000000..a7207c50 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDWebImageCacheSerializer.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageCacheSerializer.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWebImageDecoder.h b/Pods/Headers/Private/SDWebImage/SDWebImageDecoder.h deleted file mode 120000 index a2f3a683..00000000 --- a/Pods/Headers/Private/SDWebImage/SDWebImageDecoder.h +++ /dev/null @@ -1 +0,0 @@ -../../../SDWebImage/SDWebImage/SDWebImageDecoder.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWebImageDefine.h b/Pods/Headers/Private/SDWebImage/SDWebImageDefine.h new file mode 120000 index 00000000..67fae79f --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDWebImageDefine.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDefine.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderConfig.h b/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderConfig.h new file mode 120000 index 00000000..65052a3c --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderConfig.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDownloaderConfig.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderRequestModifier.h b/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderRequestModifier.h new file mode 120000 index 00000000..0c4210a5 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderRequestModifier.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDownloaderRequestModifier.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWebImageError.h b/Pods/Headers/Private/SDWebImage/SDWebImageError.h new file mode 120000 index 00000000..562aedca --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDWebImageError.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageError.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWebImageIndicator.h b/Pods/Headers/Private/SDWebImage/SDWebImageIndicator.h new file mode 120000 index 00000000..617a5243 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDWebImageIndicator.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageIndicator.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDWebImageTransition.h b/Pods/Headers/Private/SDWebImage/SDWebImageTransition.h new file mode 120000 index 00000000..98ad40f6 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDWebImageTransition.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageTransition.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/SDmetamacros.h b/Pods/Headers/Private/SDWebImage/SDmetamacros.h new file mode 120000 index 00000000..e1485f5a --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/SDmetamacros.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/Private/SDmetamacros.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/UIColor+HexString.h b/Pods/Headers/Private/SDWebImage/UIColor+HexString.h new file mode 120000 index 00000000..216a7580 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/UIColor+HexString.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/Private/UIColor+HexString.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/UIImage+ForceDecode.h b/Pods/Headers/Private/SDWebImage/UIImage+ForceDecode.h new file mode 120000 index 00000000..1ec2523f --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/UIImage+ForceDecode.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+ForceDecode.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/UIImage+MemoryCacheCost.h b/Pods/Headers/Private/SDWebImage/UIImage+MemoryCacheCost.h new file mode 120000 index 00000000..a54c96f7 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/UIImage+MemoryCacheCost.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+MemoryCacheCost.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/UIImage+Metadata.h b/Pods/Headers/Private/SDWebImage/UIImage+Metadata.h new file mode 120000 index 00000000..be998a5b --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/UIImage+Metadata.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+Metadata.h \ No newline at end of file diff --git a/Pods/Headers/Private/SDWebImage/UIImage+Transform.h b/Pods/Headers/Private/SDWebImage/UIImage+Transform.h new file mode 120000 index 00000000..e5adc993 --- /dev/null +++ b/Pods/Headers/Private/SDWebImage/UIImage+Transform.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+Transform.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/NSButton+WebCache.h b/Pods/Headers/Public/SDWebImage/NSButton+WebCache.h new file mode 120000 index 00000000..487f0e35 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/NSButton+WebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/NSButton+WebCache.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/NSImage+Compatibility.h b/Pods/Headers/Public/SDWebImage/NSImage+Compatibility.h new file mode 120000 index 00000000..dde4c7e6 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/NSImage+Compatibility.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/NSImage+Compatibility.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/NSImage+WebCache.h b/Pods/Headers/Public/SDWebImage/NSImage+WebCache.h deleted file mode 120000 index b7a00e1f..00000000 --- a/Pods/Headers/Public/SDWebImage/NSImage+WebCache.h +++ /dev/null @@ -1 +0,0 @@ -../../../SDWebImage/SDWebImage/NSImage+WebCache.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDAnimatedImage.h b/Pods/Headers/Public/SDWebImage/SDAnimatedImage.h new file mode 120000 index 00000000..bcb3fd5f --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDAnimatedImage.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDAnimatedImage.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDAnimatedImageRep.h b/Pods/Headers/Public/SDWebImage/SDAnimatedImageRep.h new file mode 120000 index 00000000..fbf739fd --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDAnimatedImageRep.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDAnimatedImageRep.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDAnimatedImageView+WebCache.h b/Pods/Headers/Public/SDWebImage/SDAnimatedImageView+WebCache.h new file mode 120000 index 00000000..d89f0976 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDAnimatedImageView+WebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDAnimatedImageView+WebCache.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDAnimatedImageView.h b/Pods/Headers/Public/SDWebImage/SDAnimatedImageView.h new file mode 120000 index 00000000..6cbe3354 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDAnimatedImageView.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDAnimatedImageView.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDDiskCache.h b/Pods/Headers/Public/SDWebImage/SDDiskCache.h new file mode 120000 index 00000000..708362ad --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDDiskCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDDiskCache.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageAPNGCoder.h b/Pods/Headers/Public/SDWebImage/SDImageAPNGCoder.h new file mode 120000 index 00000000..467121d8 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageAPNGCoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageAPNGCoder.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageCacheDefine.h b/Pods/Headers/Public/SDWebImage/SDImageCacheDefine.h new file mode 120000 index 00000000..a15891c2 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageCacheDefine.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCacheDefine.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageCachesManager.h b/Pods/Headers/Public/SDWebImage/SDImageCachesManager.h new file mode 120000 index 00000000..f4ee9dfb --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageCachesManager.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCachesManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageCoder.h b/Pods/Headers/Public/SDWebImage/SDImageCoder.h new file mode 120000 index 00000000..5afaf946 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageCoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCoder.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageCoderHelper.h b/Pods/Headers/Public/SDWebImage/SDImageCoderHelper.h new file mode 120000 index 00000000..f3222589 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageCoderHelper.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCoderHelper.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageCodersManager.h b/Pods/Headers/Public/SDWebImage/SDImageCodersManager.h new file mode 120000 index 00000000..c1ec760d --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageCodersManager.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCodersManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageFrame.h b/Pods/Headers/Public/SDWebImage/SDImageFrame.h new file mode 120000 index 00000000..46641f19 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageFrame.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageFrame.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageGIFCoder.h b/Pods/Headers/Public/SDWebImage/SDImageGIFCoder.h new file mode 120000 index 00000000..6322b52f --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageGIFCoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageGIFCoder.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageGraphics.h b/Pods/Headers/Public/SDWebImage/SDImageGraphics.h new file mode 120000 index 00000000..3354e529 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageGraphics.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageGraphics.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageIOCoder.h b/Pods/Headers/Public/SDWebImage/SDImageIOCoder.h new file mode 120000 index 00000000..9394c1ef --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageIOCoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageIOCoder.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageLoader.h b/Pods/Headers/Public/SDWebImage/SDImageLoader.h new file mode 120000 index 00000000..73fbf8e6 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageLoader.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageLoader.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageLoadersManager.h b/Pods/Headers/Public/SDWebImage/SDImageLoadersManager.h new file mode 120000 index 00000000..8e192dd7 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageLoadersManager.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageLoadersManager.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDImageTransformer.h b/Pods/Headers/Public/SDWebImage/SDImageTransformer.h new file mode 120000 index 00000000..e2e017ad --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDImageTransformer.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageTransformer.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDMemoryCache.h b/Pods/Headers/Public/SDWebImage/SDMemoryCache.h new file mode 120000 index 00000000..932c6130 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDMemoryCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDMemoryCache.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDWebImage.h b/Pods/Headers/Public/SDWebImage/SDWebImage.h new file mode 120000 index 00000000..48f99e34 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDWebImage.h @@ -0,0 +1 @@ +../../../SDWebImage/WebImage/SDWebImage.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDWebImageCacheKeyFilter.h b/Pods/Headers/Public/SDWebImage/SDWebImageCacheKeyFilter.h new file mode 120000 index 00000000..0e5e35f0 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDWebImageCacheKeyFilter.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageCacheKeyFilter.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDWebImageCacheSerializer.h b/Pods/Headers/Public/SDWebImage/SDWebImageCacheSerializer.h new file mode 120000 index 00000000..a7207c50 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDWebImageCacheSerializer.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageCacheSerializer.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDWebImageDecoder.h b/Pods/Headers/Public/SDWebImage/SDWebImageDecoder.h deleted file mode 120000 index a2f3a683..00000000 --- a/Pods/Headers/Public/SDWebImage/SDWebImageDecoder.h +++ /dev/null @@ -1 +0,0 @@ -../../../SDWebImage/SDWebImage/SDWebImageDecoder.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDWebImageDefine.h b/Pods/Headers/Public/SDWebImage/SDWebImageDefine.h new file mode 120000 index 00000000..67fae79f --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDWebImageDefine.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDefine.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderConfig.h b/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderConfig.h new file mode 120000 index 00000000..65052a3c --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderConfig.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDownloaderConfig.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderRequestModifier.h b/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderRequestModifier.h new file mode 120000 index 00000000..0c4210a5 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderRequestModifier.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDownloaderRequestModifier.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDWebImageError.h b/Pods/Headers/Public/SDWebImage/SDWebImageError.h new file mode 120000 index 00000000..562aedca --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDWebImageError.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageError.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDWebImageIndicator.h b/Pods/Headers/Public/SDWebImage/SDWebImageIndicator.h new file mode 120000 index 00000000..617a5243 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDWebImageIndicator.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageIndicator.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/SDWebImageTransition.h b/Pods/Headers/Public/SDWebImage/SDWebImageTransition.h new file mode 120000 index 00000000..98ad40f6 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/SDWebImageTransition.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageTransition.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/UIImage+ForceDecode.h b/Pods/Headers/Public/SDWebImage/UIImage+ForceDecode.h new file mode 120000 index 00000000..1ec2523f --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/UIImage+ForceDecode.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+ForceDecode.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/UIImage+MemoryCacheCost.h b/Pods/Headers/Public/SDWebImage/UIImage+MemoryCacheCost.h new file mode 120000 index 00000000..a54c96f7 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/UIImage+MemoryCacheCost.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+MemoryCacheCost.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/UIImage+Metadata.h b/Pods/Headers/Public/SDWebImage/UIImage+Metadata.h new file mode 120000 index 00000000..be998a5b --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/UIImage+Metadata.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+Metadata.h \ No newline at end of file diff --git a/Pods/Headers/Public/SDWebImage/UIImage+Transform.h b/Pods/Headers/Public/SDWebImage/UIImage+Transform.h new file mode 120000 index 00000000..e5adc993 --- /dev/null +++ b/Pods/Headers/Public/SDWebImage/UIImage+Transform.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+Transform.h \ No newline at end of file diff --git a/Pods/Manifest.lock b/Pods/Manifest.lock index 5138323b..a1485b6f 100644 --- a/Pods/Manifest.lock +++ b/Pods/Manifest.lock @@ -1,14 +1,18 @@ PODS: - - SDWebImage (4.0.0): - - SDWebImage/Core (= 4.0.0) - - SDWebImage/Core (4.0.0) + - SDWebImage (5.0.0): + - SDWebImage/Core (= 5.0.0) + - SDWebImage/Core (5.0.0) DEPENDENCIES: - - SDWebImage (~> 4.0.0) + - SDWebImage (>= 5.0.0) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - SDWebImage SPEC CHECKSUMS: - SDWebImage: 76a6348bdc74eb5a55dd08a091ef298e56b55e41 + SDWebImage: 5de80a0302de9e377e62f47d2fa1304efff0e55f -PODFILE CHECKSUM: 15dea9690d6001704f1e5d2a3d5fe6a8628a9d3f +PODFILE CHECKSUM: 36b38d6f3870a9dd8180509afda3b51d62283956 -COCOAPODS: 1.1.1 +COCOAPODS: 1.5.3 diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj index 3aabee0e..e3b38720 100644 --- a/Pods/Pods.xcodeproj/project.pbxproj +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -7,126 +7,281 @@ objects = { /* Begin PBXBuildFile section */ - 0563C15039B9DB0BFE599D858E2D7AD4 /* SDWebImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 061BD245946E3501DC9722976B6AD69F /* SDWebImageDownloader.m */; }; - 0609ADFEC935AA6939774C002465E1E8 /* UIImageView+HighlightedWebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = EBB52CF8D4721A70A8DBB80842994D97 /* UIImageView+HighlightedWebCache.m */; }; - 0806B52A4FF29C2EC3EF54188853178B /* UIImageView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = F3B0E9B6DF8E857C9B0D2F99FC304F5C /* UIImageView+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 1DA182826EC8C87EB9B467553410FBC7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9757679632F4D96FB95D495ADE43F19A /* Foundation.framework */; }; - 22D7C12314E74434F6263E75A1FCFBB7 /* NSImage+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 38144E417F1BCD6B1FAEC6B8717E1E23 /* NSImage+WebCache.m */; }; - 280AA9BF6725F27F7DEFC7227D8DAFD9 /* SDWebImageDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A6E5B273CF39F8FC2FD8786F72729B7 /* SDWebImageDecoder.m */; }; - 2CB68438863541C687D381644D48A316 /* UIImage+GIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 003ABD753CAF59EF000CA534C832D14D /* UIImage+GIF.m */; }; - 2F6FDB59B5F2FC767BCBC56E20B629C1 /* UIImageView+HighlightedWebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F24A6DBFFEDC06E98C0AFD080F1D24D /* UIImageView+HighlightedWebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 31B2BBEA7904DFACC385C6B7C0840462 /* SDWebImageDownloaderOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 7175586325AADB8BA8C4ECB09907EA10 /* SDWebImageDownloaderOperation.m */; }; - 31E75759A4D48F2BAE19250501E5BFF3 /* SDWebImagePrefetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 8FF5AFAC79DED4F0C94D1BB961D2D557 /* SDWebImagePrefetcher.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 376177EBDCF60CB0FB51B86B96450C8B /* SDWebImagePrefetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = B1D5D1B92B920495205ECC5F01A79B18 /* SDWebImagePrefetcher.m */; }; - 382DC345E4CD7336DB317C977E0A99C3 /* SDWebImageOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1278B5233127A1E722D53F10E7FA5EC8 /* SDWebImageOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 3C880215CB75D9AD6B0E47B328009C33 /* UIView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F2BB2A6F6DDDD53BC079622F286FF42 /* UIView+WebCache.m */; }; - 3E46237DDFF6F217CBB0013683817AB2 /* SDWebImage-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C421E1831E29906D3404BDCA1B2C1B /* SDWebImage-dummy.m */; }; - 407E5795C1ACD9040A3450893A96EBE5 /* UIView+WebCacheOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A82F610DA462435F1AF2E40069B468A /* UIView+WebCacheOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 415FACAA36208C9635B45618EAB2AAF6 /* UIImage+MultiFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B730BABFE2264BB576806D96D5292B1 /* UIImage+MultiFormat.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 41D681DF56CF050FF356A3830D2E019A /* NSData+ImageContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 151184230168224C23550D1C654C722F /* NSData+ImageContentType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 508FC75E82E9E649B029E9A01779374B /* UIButton+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = F84F89DA463D5F013F47620258BECA2C /* UIButton+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 552E2209ED0C19F4C9ED3FD8F36D0CB1 /* UIImage+GIF.h in Headers */ = {isa = PBXBuildFile; fileRef = 0ACCB8B450CC4B80A63EE725C41C0B29 /* UIImage+GIF.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 58C3747479C9F665724E660819653FEC /* SDImageCacheConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 169F96E9B9B5F19875E606404AF824BE /* SDImageCacheConfig.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 5D692C1F585A2AB1D4FA27913EC2481A /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C97050C5BB315CF8D59A03899BAFA13 /* ImageIO.framework */; }; - 6450B80E85D93BA4F47EA53250BA24BA /* SDImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E2890C6456A666BDAAC0FA873AC628D /* SDImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 6AE7F72206A1986AA98E214EECC034C0 /* SDImageCacheConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 017851524E3ABDA65B7BF9B37C3D7034 /* SDImageCacheConfig.m */; }; - 6D53759AD23FB006DB98C343FE0B0429 /* SDImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 33187D162677C128060029C7359C0024 /* SDImageCache.m */; }; - 6FE4ED7E5C0B4D314B886640BB86D6BE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9757679632F4D96FB95D495ADE43F19A /* Foundation.framework */; }; - 77E85137B222DE725AB120FFB67A372F /* SDWebImageCompat.m in Sources */ = {isa = PBXBuildFile; fileRef = AC1B1D53218A33DDF03E78CC1D10282D /* SDWebImageCompat.m */; }; - 7E35B5C825EC79C3D9FEC0CDEA0B89C4 /* SDWebImageCompat.h in Headers */ = {isa = PBXBuildFile; fileRef = 800D2AB9BD2022E1D6C504CF6566681F /* SDWebImageCompat.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 7EF397649EE76E22EFEA1DCCACF95006 /* SDWebImageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = AC4FF8277985072AA2414C8092B0E5E8 /* SDWebImageManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 9BE39F21B6B0A15D3ED1EBEF23C7A1D6 /* NSImage+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = CC6C5BEF90DB5C23F890DDF3AE04E82D /* NSImage+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 9E469014F9101E8B45DD6CE2DD32C9C4 /* SDWebImageDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = D0AAD31650A9E6056BF51E6E7F5DC451 /* SDWebImageDownloader.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A6231D3566857EF78863E9E6F7B5C2D9 /* UIImageView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = F922701ABE8790DD84BD643BFA3F9D9E /* UIImageView+WebCache.m */; }; - A922281722FC3E4E385E883385114A75 /* SDWebImageDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = B1FC992CB7BD5112195C879B7F23ACC8 /* SDWebImageDecoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AA67E49DCA2B8EC1234B549D1CFA7161 /* UIImage+MultiFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BE46DB6FE0E8D812F73130BD83794EB /* UIImage+MultiFormat.m */; }; - AB470D17E6092FB9EB75242755C68897 /* SDWebImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B2D7436D47BF86BE7F4C22F258A0154 /* SDWebImageManager.m */; }; - B05F1D8C2665A054BBC70862DE98496E /* UIView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = FC24B0F8787681FFD86A7FF97C481764 /* UIView+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; - B5519105E2DCABE661C1FAB79F0DDA69 /* UIButton+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 123A809310FA5938787013915F3D64B4 /* UIButton+WebCache.m */; }; - C0078FEBEA8C63FBF4FE00AA498F7B05 /* NSData+ImageContentType.m in Sources */ = {isa = PBXBuildFile; fileRef = 0515B8FFDF02AC747460BF06B7147C92 /* NSData+ImageContentType.m */; }; - CF179B9B47312BA380C3B9FF301640BB /* Pods-SDCycleScrollView-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 28402603F55CD72C518801A83342CBF6 /* Pods-SDCycleScrollView-dummy.m */; }; - D99B7877B3CF8C66A8B9E37D12448D95 /* SDWebImageDownloaderOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 9FAAAA9369B44B0CACDD1C0E8FCD6F43 /* SDWebImageDownloaderOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - E6BBCB71FC3E3E2682CB33BAEC93A392 /* UIView+WebCacheOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A96738A124145BD661891641E09D321 /* UIView+WebCacheOperation.m */; }; + 008FCDE17FDC370C7F76FFF47CE1A80C /* SDWebImageDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A34D73ED123F5F748AE645379270F77 /* SDWebImageDefine.m */; }; + 015DAF5E194F4BFF92C2062E21440393 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 46CCC34935322C85370ADB095550F87F /* ImageIO.framework */; }; + 041785B6A223D7A9CCE89E9F4B0BC23D /* NSImage+Compatibility.h in Headers */ = {isa = PBXBuildFile; fileRef = E7ABEF7378149E529C46995578A29DC2 /* NSImage+Compatibility.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 06023DFC2B0F4A395515B0DC5A62A6BF /* SDImageLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 299D0541609FD621129F3323B78F0AF2 /* SDImageLoader.m */; }; + 06BE6E690AC714D69BC93AB514AF917F /* SDWeakProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 724B476FA329BB5D5EBE4D5B95FC3619 /* SDWeakProxy.m */; }; + 1079FC4C3A11D2F6EE2D0BB5E9F25D14 /* UIImageView+HighlightedWebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = B4E5E8E43B45E6679A1DDB70277160C9 /* UIImageView+HighlightedWebCache.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 12760FCD14A16F134829A383166F8455 /* SDWebImage-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = DA94C0A9E8D752E887DDA70C51FE790B /* SDWebImage-dummy.m */; }; + 14B7469739C5AFBDE9FDD52844D5D461 /* SDImageGraphics.h in Headers */ = {isa = PBXBuildFile; fileRef = 086EE0E1FA0EA4CCC7A50D97347A511A /* SDImageGraphics.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 1542BA07EC3225C2D8E27770F0E9E3E1 /* SDMemoryCache.h in Headers */ = {isa = PBXBuildFile; fileRef = CF5C37953A10E1847A179009361FA9BE /* SDMemoryCache.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 182724AF3B99093B45530C87D8A95EDE /* SDImageFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EBB1C87045EF7B9F693C3B1F5FFF8D /* SDImageFrame.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 183A26CA35C022038861C37C7087CED0 /* SDImageCacheDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 685C98EF4D7951391ECCEE3A88FED46E /* SDImageCacheDefine.m */; }; + 18FC4EE1A082E669001BB26EF41FCFC2 /* UIImageView+HighlightedWebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = B475BEF1AD73DEAD014AC2B7CFCF4861 /* UIImageView+HighlightedWebCache.m */; }; + 1AA118F5B7A4557F0C1743E4C8C5F82F /* UIImage+ForceDecode.m in Sources */ = {isa = PBXBuildFile; fileRef = 166BEB9DD6DC2E9005E2A0F26F58CB30 /* UIImage+ForceDecode.m */; }; + 1AB9619CAE94105841213942BE8FCFC4 /* SDAnimatedImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 358978FAB2C566B04FB4F81A2472669E /* SDAnimatedImage.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 1C14257D98DF6893FBEF059AA6A20817 /* SDWebImageIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = A619747494E6F4BD0FD882FE7DED8746 /* SDWebImageIndicator.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 1C993E6046FCDDF9C93BAFAC22F6B5E0 /* SDWebImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EDB45480ACEB0EC48B9141E97883C2 /* SDWebImage.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 236A672A5E4B8E00EC7C9D2A8FEDC139 /* SDAnimatedImageView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FF6A35501C5E43C95290FCBED6E43C3 /* SDAnimatedImageView+WebCache.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 2550B12A23C2C8B5FF2F0E5CBBC9F840 /* NSBezierPath+RoundedCorners.m in Sources */ = {isa = PBXBuildFile; fileRef = F25B05917B4744980F19D8172BC89A76 /* NSBezierPath+RoundedCorners.m */; }; + 2B03ABA71D7AB83DAC5FFF63BA2038CC /* NSBezierPath+RoundedCorners.h in Headers */ = {isa = PBXBuildFile; fileRef = D10F7457F3E2BF3D94A2CDF2CACBA6F3 /* NSBezierPath+RoundedCorners.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 2B6031E45FA11FE572D0E1667510B182 /* SDWebImageError.m in Sources */ = {isa = PBXBuildFile; fileRef = B32BB3A3364C2577436CB6D5395F0FC1 /* SDWebImageError.m */; }; + 2C01FA5B03600B28879E3FC413F72C0F /* SDWebImagePrefetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = ED5A8112D1C8315E467C16BAC610263D /* SDWebImagePrefetcher.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 2DCD9020DAA94C4FA194A2DACE12830B /* SDWebImageDownloaderRequestModifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F05F110D78D69A2DD2452036BC3DB2 /* SDWebImageDownloaderRequestModifier.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 2EC315732B470964D4E397459F95D1DC /* SDWebImageDownloaderOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B82716CEFAF9CAE8EE2A867A5D15499 /* SDWebImageDownloaderOperation.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 325D712321152BCDB4FB51E5F8EC90DF /* SDImageCodersManager.h in Headers */ = {isa = PBXBuildFile; fileRef = A3983DE10FE8C33B8A1C9081EA378AE2 /* SDImageCodersManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 332D280BF4D5E90DDF8AD94CBC338586 /* SDImageCacheConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CD626EAB095253442E41CD3BD7AF70D /* SDImageCacheConfig.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 3547A4FD96ED48176396D9CDD9BA59B9 /* SDWebImageError.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AA04EFE04CF822C0A17F260BA29FDA4 /* SDWebImageError.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 35B2A0B3973BA1FB65FA4CB1E76F8191 /* UIImage+Transform.m in Sources */ = {isa = PBXBuildFile; fileRef = 4838B415BD044852DDDFF8CBD2B4307F /* UIImage+Transform.m */; }; + 3AFF5E078CC8E70773662AD7148A6410 /* UIButton+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 57838CEA123FC3BD3535291808320965 /* UIButton+WebCache.m */; }; + 3E34384734A72BF450EFAE7C1FD3575F /* SDImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = CEDB7B91DE3BDBD371418213B2A1018F /* SDImageLoader.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 3F448EE6946D52AE1B9EB64A63CFFF8B /* SDInternalMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 400AFA873788C9C5294C8A9AD28AD866 /* SDInternalMacros.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 4295551A6F547D5562E4EE3D85E62927 /* SDImageTransformer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E2B30396EFEB52D1344BFAD7C08DB16 /* SDImageTransformer.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 44DD3A94A38F29766C51A8306C5B5B23 /* SDImageCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 327630E206AA37029FDA8550C2D9C1AA /* SDImageCoder.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 489561F7F78E7CDADA7D59C08C2DEF75 /* SDImageAssetManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 0924FB2B142D007EFA183C280FFC5F5A /* SDImageAssetManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 4AA3BDDFD2D461FDF26518F19388EA71 /* Pods-SDCycleScrollView-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 28402603F55CD72C518801A83342CBF6 /* Pods-SDCycleScrollView-dummy.m */; }; + 4ABEB2B0416B66969CD541D55452E545 /* UIImage+Metadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A4C07E130AB45A5536D0ACD5F198F3D /* UIImage+Metadata.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 4C761F6FB5A90D3796184C9CC2F8E28A /* SDWebImageIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B0F702B6FF89EF212A40916477C1450 /* SDWebImageIndicator.m */; }; + 4DED5FA6CA047667A0E72CF511DC7395 /* UIImage+MemoryCacheCost.h in Headers */ = {isa = PBXBuildFile; fileRef = A413688E6D527C394DB942E97A79CC7D /* UIImage+MemoryCacheCost.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 51B49695AA82F4ED962B938D312DE2CB /* SDWebImageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 817BEA41EF6F0B336EC31DDDB68AEDEA /* SDWebImageManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 5214D2AAB2E5DE5027ED02BFD052E75C /* SDWebImageDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 24FB39BF7EA1BCAAC5A3DDA1DC226554 /* SDWebImageDefine.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 52334444A5F9D3AB3B826533FA5F11B3 /* SDImageCoderHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = DF5A6ABC0D605124ADF3D45B438BA284 /* SDImageCoderHelper.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 5255772D9D225389C738332D83628EA8 /* SDWebImageOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = F3BCA0F245BD5F9E6EAE47A0DEAA1D0C /* SDWebImageOperation.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 548C07B2567191751DA2DF6CDDB4DF19 /* SDWebImageDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2FD199A40983F02B0F9842FFFFFE50AD /* SDWebImageDownloader.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 5645B7BE3160BCAD3C33DD7C94E9E8BA /* SDImageCoderHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 37642A5DE6FBA62A17E2FE3434CF1610 /* SDImageCoderHelper.m */; }; + 58D381662970FE011EED09F4DB99FF69 /* SDWebImageCacheSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = CDB85D1A66A7602880B4A7D8D7CEA31F /* SDWebImageCacheSerializer.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 5B6A9B73BF63BC1CC1B32C74FF1BC485 /* SDImageCachesManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 252EA4A4143A0298288955A98FC2F6B8 /* SDImageCachesManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 5BBB8B88BDFA79854EA0D8B1FC65D405 /* SDWebImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 912D25A660B2BC888ACEFE0556A5A680 /* SDWebImageManager.m */; }; + 604A8B694B89CB58C791BAAF0F3641BB /* SDImageLoadersManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 10ED050ECEF1C479762A41F18CA54EAC /* SDImageLoadersManager.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 6182BE7BBA533F1116E361147CF7028A /* UIImage+GIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 95B74374ADE7B3619DA5086AC7F1E954 /* UIImage+GIF.m */; }; + 6301AB41AB7192280A29DC8681DF1755 /* NSImage+Compatibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 471A4025DB4C846117183EF38EC4E31C /* NSImage+Compatibility.m */; }; + 6662C46E4CF56C6119AD9DB580C6AC52 /* SDInternalMacros.m in Sources */ = {isa = PBXBuildFile; fileRef = 27E8309474F966628D3488F60EE56B76 /* SDInternalMacros.m */; }; + 6C077C1556E56CD1BF6D90864D87967C /* SDAsyncBlockOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 965CA1E15C752616A54C495859354070 /* SDAsyncBlockOperation.m */; }; + 6C5BE74F5F658DA3F40C6382DBCAD794 /* SDImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 862AD584CCBCEAE9636F39626C29F407 /* SDImageCache.m */; }; + 6CFA1A2228794F143768674E646D599B /* SDImageCodersManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5653AE3DAFA7109C6EE90B8627D9AF5A /* SDImageCodersManager.m */; }; + 6D26BABBAB67DF7BE355D6D358A18994 /* SDAnimatedImageView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 24AED846B71430FFBE02D3AECCBF0576 /* SDAnimatedImageView+WebCache.m */; }; + 715089F4E130FBCA6DB96B0C7E0AA8FD /* SDImageCachesManagerOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C076EF50460791EDA64C176108C4BAB /* SDImageCachesManagerOperation.m */; }; + 71DC7B6657041333D23DB519DF31E116 /* UIImageView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = AD627E37D3ED047E71830F5E4E22A52F /* UIImageView+WebCache.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 785AB0D7DE13BE012AE6A69257A0A430 /* NSButton+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 95ABE62EC1EB24199357F7E9DEA8BC71 /* NSButton+WebCache.m */; }; + 79B9263193B208C09C3C609B0E1BBF1D /* SDImageTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = CFE3C8B4010B3A5D5B3D485ADFFAE31E /* SDImageTransformer.m */; }; + 79F2466272FDCBAA74CBE5AC2EE0640B /* SDImageGIFCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C7E1D5AA5E3BFCAD9D65D245B63D1FD /* SDImageGIFCoder.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7E163BB499D7E5B56605D123119B0218 /* SDmetamacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 8D18978388217BAD3C76C919917F488B /* SDmetamacros.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7E5F9D01401AF8DE4DC76DAAECA729CD /* SDWebImageDownloaderConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 79CD4B74E157C0A16CD427EBD3143B4B /* SDWebImageDownloaderConfig.m */; }; + 8146D1581848A2AF9F9F67611D4BAF38 /* SDImageCachesManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D9D40C20DADFED8D00E2814A4C15FD74 /* SDImageCachesManager.m */; }; + 82148E298BC2CAA1995F87646BFCCE28 /* UIImage+ForceDecode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD8011F1FE90BAC4E879AA60199D59DB /* UIImage+ForceDecode.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 86194C7C685FE84C0ECFDE1BDD96A331 /* SDImageCachesManagerOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8DC56CEC50021BB4FD9BFB59F5C02EE3 /* SDImageCachesManagerOperation.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 8A9A602B6A841872373C523F1B005359 /* SDImageAPNGCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 740C4363AFC46B547870C1212FD59BFB /* SDImageAPNGCoder.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 8ABAF55C03179196A43CD274CDEC3F7E /* UIImage+MultiFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = FBBED8C92E3705C3A859F86BE6698FE6 /* UIImage+MultiFormat.m */; }; + 8DE5F4DEEAB43193DF3DB984A2D67B0A /* UIImageView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 38FE5ABD708743EB87018CC13F861F01 /* UIImageView+WebCache.m */; }; + 8F27B8A212B41DBC721597F6AD1A3BED /* UIColor+HexString.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F2ADE6B35494134D339EA2C90B9276 /* UIColor+HexString.m */; }; + 90F6067598A5BEF6AA8EB9B3E36F288D /* SDAnimatedImageRep.m in Sources */ = {isa = PBXBuildFile; fileRef = FD05F5F67E683C39C452461374576EA2 /* SDAnimatedImageRep.m */; }; + 94D309811F93732EE62507CE919E0A7A /* SDAnimatedImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 242952C85954F97FAD2F21A50F4B0941 /* SDAnimatedImage.m */; }; + 95501C627C8BDA06BFAFB53DB636ABD4 /* SDWebImageDownloaderRequestModifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E2B2CD6DBA50ED73A9A4DB28DA7666E /* SDWebImageDownloaderRequestModifier.m */; }; + 99B46762BA9F8A5586086DBA63F97C70 /* UIView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C124047867A671320DB11A9688C268E /* UIView+WebCache.m */; }; + 99D2E5B21E1F05939CC30FF6BEFF9E89 /* SDWebImageDownloaderConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = BBD6BB25D89D1B42F4936564C5BA640A /* SDWebImageDownloaderConfig.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 9CD037CC4E713BE035052909CFDC7CDB /* SDWebImageCompat.h in Headers */ = {isa = PBXBuildFile; fileRef = A91974CCB58F427C1764D73D283E3734 /* SDWebImageCompat.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 9D907B0F2724776188CCB32DEA810F55 /* UIImage+MultiFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EACDCA00375B43046C959ABF2621469 /* UIImage+MultiFormat.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 9F53011B8A7AE4D4C5C8E5638AAE7F30 /* SDWebImageDownloaderOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = DD7ABEEE27609AD673AADB3A4BA78560 /* SDWebImageDownloaderOperation.m */; }; + A269D6FED8BEA14664B25C72E68FA3AD /* SDImageGIFCoderInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = DF66C7AB6B984E09C80E82DFB49A4378 /* SDImageGIFCoderInternal.h */; settings = {ATTRIBUTES = (Project, ); }; }; + A391AE3617170F12A65FB1AE37530932 /* SDWebImageTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = F9D83F02AC271A5CC560E16FAF7D6675 /* SDWebImageTransition.m */; }; + A5F3938473C62A54E55E892B069BDA2C /* SDDiskCache.m in Sources */ = {isa = PBXBuildFile; fileRef = CC50B874409F5595F554ED81B57F2E5B /* SDDiskCache.m */; }; + A7ACCA3D8FA2CDA2FBA0BA45208B9150 /* UIImage+Metadata.m in Sources */ = {isa = PBXBuildFile; fileRef = BADE89D6D30652E8F39D082602E75C7D /* UIImage+Metadata.m */; }; + AA4FBF21D640C3721B755869B5C174E3 /* SDImageCacheDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = FD6FE5D298A971DEAFFA685B4C7CF3E9 /* SDImageCacheDefine.h */; settings = {ATTRIBUTES = (Project, ); }; }; + ACDE3D13AB2FA902ECB2A99031D2BBF9 /* SDImageIOCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C204F67D0CA51F885C6A350CBF753B4 /* SDImageIOCoder.m */; }; + AD10793D43B7CE79FE2B2870875A3269 /* UIButton+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = C5D45FFA26B6D19B057AD435A58C85DA /* UIButton+WebCache.h */; settings = {ATTRIBUTES = (Project, ); }; }; + B1DE6CC693FDA77B6D2185CF91BFF625 /* SDAsyncBlockOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AECE16F143ED5A11B101E507F08B677E /* SDAsyncBlockOperation.h */; settings = {ATTRIBUTES = (Project, ); }; }; + B51DD16A2C84759D53F7B5D7DBE06FC0 /* SDImageAPNGCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 93148A2C3D455B7A4E9CE157781367B6 /* SDImageAPNGCoder.m */; }; + B72D72A40F0DEFF50115330CE9716D9B /* SDImageCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = F3DDDB05D460AEF07A2B3B6CB1D0DBEF /* SDImageCoder.m */; }; + B812A6162E3D6E4C7E3D7ABBE9A37825 /* SDWeakProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A245EB7795689D145AA8A71A79713EE7 /* SDWeakProxy.h */; settings = {ATTRIBUTES = (Project, ); }; }; + BF200366C603CA7F20B4BF6291091596 /* SDImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E728569F128BE30D0B31189F04B0594 /* SDImageCache.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C014CC3542B2C431CAE640E4B56CEC5E /* SDImageGIFCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 742CC17B1484A3E9F54F138EE4E08BB0 /* SDImageGIFCoder.m */; }; + C5078979C875E1856A9252CFC491700F /* UIView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 7DB62FCE59F7A1B1B269F90E5F954966 /* UIView+WebCache.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C5FA55898462E047EAB14D0FD0F011B9 /* SDWebImageTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = C75CCDC9340AA190F18CE7A4650EC931 /* SDWebImageTransition.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C973A839B25516A8A63291EE097EF86B /* SDWebImagePrefetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = F623865988B321F01F17496583BF5710 /* SDWebImagePrefetcher.m */; }; + C9958F80C527D2593E1DEEA903590E1B /* SDImageCacheConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 013C9CB568185DDE99962EB0D2B9E464 /* SDImageCacheConfig.m */; }; + CFB5988D4F1373EC852CF115D0E40EF4 /* UIColor+HexString.h in Headers */ = {isa = PBXBuildFile; fileRef = 7813BA26306D2FEA740D27F8E105DB99 /* UIColor+HexString.h */; settings = {ATTRIBUTES = (Project, ); }; }; + D013AD4793C4D4E36BFE990E44143AAD /* NSData+ImageContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D7A08DB6ECF1AAA5FB9C45300C5FC79 /* NSData+ImageContentType.h */; settings = {ATTRIBUTES = (Project, ); }; }; + D555A6BBADB213BF38EE94BEDB4F187A /* SDWebImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 21A200B372A442E1A1C6AB08E21F63A4 /* SDWebImageDownloader.m */; }; + D60C936D270619B9462ED070DCA3AB90 /* UIImage+GIF.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DAB48D959F5ADE26E33A5678CFC81A /* UIImage+GIF.h */; settings = {ATTRIBUTES = (Project, ); }; }; + D7FBB701B8C8B966F7BBA30E22FE94FD /* UIView+WebCacheOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CC05EFFE2466F212ADE0D1B5C4237F4 /* UIView+WebCacheOperation.m */; }; + DBAB548A7AE22D5C77A2BAEE1F156DB7 /* SDDiskCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 14CA9FC43AB44A0A1913B13BB7CEFBA8 /* SDDiskCache.h */; settings = {ATTRIBUTES = (Project, ); }; }; + DBFA9FD040FF59AAAF6683A63C3BEF7E /* NSData+ImageContentType.m in Sources */ = {isa = PBXBuildFile; fileRef = B7BF3C4337DE00F26A2D4386B32E169C /* NSData+ImageContentType.m */; }; + DC89D52A2149475F3D747413A0075C3D /* SDImageIOCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 693BBCF3EE35260C780B78694E8AB5F3 /* SDImageIOCoder.h */; settings = {ATTRIBUTES = (Project, ); }; }; + DDF906614D8A0B9D41A171BDE52212FF /* SDImageAssetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DE4C218276AC416F6D694C02EE9C5D7 /* SDImageAssetManager.m */; }; + DE5417C8589D84C89CC0B483C4C35E02 /* UIImage+MemoryCacheCost.m in Sources */ = {isa = PBXBuildFile; fileRef = E3E8964FE03D3276C0CB61948E156A14 /* UIImage+MemoryCacheCost.m */; }; + DF29BDBBAD4D6C48453470E8AB03C910 /* SDWebImageCacheKeyFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = 297A05DF2CB0F803D6CD307A1115F0AA /* SDWebImageCacheKeyFilter.m */; }; + E1399B6E7E468B68F51CB5C24FF9AB75 /* SDWebImageCompat.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FBF78986CC5EC98518BD7CC559A789E /* SDWebImageCompat.m */; }; + E288A4CE8C87E324A37BE68DBC8579FF /* NSButton+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = C8F1E878C6065520F51BE4933981384A /* NSButton+WebCache.h */; settings = {ATTRIBUTES = (Project, ); }; }; + E56C4859D765A9D52FE4D573BEAB9C83 /* SDAnimatedImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = E0322BA20062BAFB677D9BDB027A85B7 /* SDAnimatedImageView.m */; }; + E58E12550D55AD4BA229611B3F3FA835 /* SDAnimatedImageRep.h in Headers */ = {isa = PBXBuildFile; fileRef = F46D5AD4CC4784CBB63CA4BC95258748 /* SDAnimatedImageRep.h */; settings = {ATTRIBUTES = (Project, ); }; }; + E8E5C810ADB9A5AB0594FCB0412FCAFC /* SDImageGraphics.m in Sources */ = {isa = PBXBuildFile; fileRef = E1E0120381C41F901C053A675AA09774 /* SDImageGraphics.m */; }; + E9FD13262C44C904D0C7A3DD7C35B0F6 /* SDAnimatedImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = AA923309479E318B830D52F1B337EDA1 /* SDAnimatedImageView.h */; settings = {ATTRIBUTES = (Project, ); }; }; + EDBEB7AC95D35F2193C89FDEBE9C7CA6 /* SDMemoryCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 27D4432EE894DB9A19EED54491D77B31 /* SDMemoryCache.m */; }; + EF790706D931EA9C9F62FC3C6F6ADE4F /* UIView+WebCacheOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC307C36A8A6C4A6DB9F83A4CE8C536 /* UIView+WebCacheOperation.h */; settings = {ATTRIBUTES = (Project, ); }; }; + F46F6157AF4821C80F9BCD8463CE001C /* SDImageFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = EE0E926662DDC8AE9800938B7165B173 /* SDImageFrame.m */; }; + F7F7651B871AEA0A8E80C9E4ABAAEB37 /* UIImage+Transform.h in Headers */ = {isa = PBXBuildFile; fileRef = 67343103154F724CCE9016F61FA76E05 /* UIImage+Transform.h */; settings = {ATTRIBUTES = (Project, ); }; }; + F9B99B6481DB22FB77161450AFFFEBBF /* SDImageAPNGCoderInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = F480D462C4940521841D4A8F389FDAD8 /* SDImageAPNGCoderInternal.h */; settings = {ATTRIBUTES = (Project, ); }; }; + FB194BBDDDFBF397023E2C16F2237720 /* SDWebImageCacheSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = B1C24966B56D943C60B30E48343908D7 /* SDWebImageCacheSerializer.m */; }; + FC77681761F4E54D4DAB2E779D279D09 /* SDImageLoadersManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EA9B4317A11216073FFB6DBAD5F803E /* SDImageLoadersManager.m */; }; + FC93FB677AB5D7D5923FD293C1109692 /* SDWebImageCacheKeyFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = FE82B97C5E67AA40232423DF711CF3E7 /* SDWebImageCacheKeyFilter.h */; settings = {ATTRIBUTES = (Project, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - AC6BDB0356350D16E1EC65B293F4C435 /* PBXContainerItemProxy */ = { + 287F57F447A925E1D086390B7A2000A6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; proxyType = 1; - remoteGlobalIDString = 6EB15CAFDEB6B266F3F2F4538542CE37; + remoteGlobalIDString = A0C7189BE1171A7480D2D8405EA34120; remoteInfo = SDWebImage; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 003ABD753CAF59EF000CA534C832D14D /* UIImage+GIF.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+GIF.m"; path = "SDWebImage/UIImage+GIF.m"; sourceTree = ""; }; - 017851524E3ABDA65B7BF9B37C3D7034 /* SDImageCacheConfig.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCacheConfig.m; path = SDWebImage/SDImageCacheConfig.m; sourceTree = ""; }; - 0515B8FFDF02AC747460BF06B7147C92 /* NSData+ImageContentType.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSData+ImageContentType.m"; path = "SDWebImage/NSData+ImageContentType.m"; sourceTree = ""; }; - 061BD245946E3501DC9722976B6AD69F /* SDWebImageDownloader.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDownloader.m; path = SDWebImage/SDWebImageDownloader.m; sourceTree = ""; }; - 0ACCB8B450CC4B80A63EE725C41C0B29 /* UIImage+GIF.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+GIF.h"; path = "SDWebImage/UIImage+GIF.h"; sourceTree = ""; }; - 0E2890C6456A666BDAAC0FA873AC628D /* SDImageCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCache.h; path = SDWebImage/SDImageCache.h; sourceTree = ""; }; - 123A809310FA5938787013915F3D64B4 /* UIButton+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIButton+WebCache.m"; path = "SDWebImage/UIButton+WebCache.m"; sourceTree = ""; }; - 1278B5233127A1E722D53F10E7FA5EC8 /* SDWebImageOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageOperation.h; path = SDWebImage/SDWebImageOperation.h; sourceTree = ""; }; - 151184230168224C23550D1C654C722F /* NSData+ImageContentType.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSData+ImageContentType.h"; path = "SDWebImage/NSData+ImageContentType.h"; sourceTree = ""; }; - 169F96E9B9B5F19875E606404AF824BE /* SDImageCacheConfig.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCacheConfig.h; path = SDWebImage/SDImageCacheConfig.h; sourceTree = ""; }; + 013C9CB568185DDE99962EB0D2B9E464 /* SDImageCacheConfig.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCacheConfig.m; path = SDWebImage/SDImageCacheConfig.m; sourceTree = ""; }; + 04DAB48D959F5ADE26E33A5678CFC81A /* UIImage+GIF.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+GIF.h"; path = "SDWebImage/UIImage+GIF.h"; sourceTree = ""; }; + 04F05F110D78D69A2DD2452036BC3DB2 /* SDWebImageDownloaderRequestModifier.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDownloaderRequestModifier.h; path = SDWebImage/SDWebImageDownloaderRequestModifier.h; sourceTree = ""; }; + 086EE0E1FA0EA4CCC7A50D97347A511A /* SDImageGraphics.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageGraphics.h; path = SDWebImage/SDImageGraphics.h; sourceTree = ""; }; + 0924FB2B142D007EFA183C280FFC5F5A /* SDImageAssetManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageAssetManager.h; path = SDWebImage/Private/SDImageAssetManager.h; sourceTree = ""; }; + 0A4C07E130AB45A5536D0ACD5F198F3D /* UIImage+Metadata.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+Metadata.h"; path = "SDWebImage/UIImage+Metadata.h"; sourceTree = ""; }; + 0B0F702B6FF89EF212A40916477C1450 /* SDWebImageIndicator.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageIndicator.m; path = SDWebImage/SDWebImageIndicator.m; sourceTree = ""; }; + 10ED050ECEF1C479762A41F18CA54EAC /* SDImageLoadersManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageLoadersManager.h; path = SDWebImage/SDImageLoadersManager.h; sourceTree = ""; }; + 14CA9FC43AB44A0A1913B13BB7CEFBA8 /* SDDiskCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDDiskCache.h; path = SDWebImage/SDDiskCache.h; sourceTree = ""; }; + 15EDB45480ACEB0EC48B9141E97883C2 /* SDWebImage.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImage.h; path = WebImage/SDWebImage.h; sourceTree = ""; }; + 166BEB9DD6DC2E9005E2A0F26F58CB30 /* UIImage+ForceDecode.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+ForceDecode.m"; path = "SDWebImage/UIImage+ForceDecode.m"; sourceTree = ""; }; + 1B82716CEFAF9CAE8EE2A867A5D15499 /* SDWebImageDownloaderOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDownloaderOperation.h; path = SDWebImage/SDWebImageDownloaderOperation.h; sourceTree = ""; }; 1BE409094A00DAA7DDA4E314201ACAFA /* Pods-SDCycleScrollView-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-SDCycleScrollView-frameworks.sh"; sourceTree = ""; }; - 1F2BB2A6F6DDDD53BC079622F286FF42 /* UIView+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIView+WebCache.m"; path = "SDWebImage/UIView+WebCache.m"; sourceTree = ""; }; + 1D7A08DB6ECF1AAA5FB9C45300C5FC79 /* NSData+ImageContentType.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSData+ImageContentType.h"; path = "SDWebImage/NSData+ImageContentType.h"; sourceTree = ""; }; + 1E2B30396EFEB52D1344BFAD7C08DB16 /* SDImageTransformer.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageTransformer.h; path = SDWebImage/SDImageTransformer.h; sourceTree = ""; }; + 21A200B372A442E1A1C6AB08E21F63A4 /* SDWebImageDownloader.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDownloader.m; path = SDWebImage/SDWebImageDownloader.m; sourceTree = ""; }; + 242952C85954F97FAD2F21A50F4B0941 /* SDAnimatedImage.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDAnimatedImage.m; path = SDWebImage/SDAnimatedImage.m; sourceTree = ""; }; + 24AED846B71430FFBE02D3AECCBF0576 /* SDAnimatedImageView+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "SDAnimatedImageView+WebCache.m"; path = "SDWebImage/SDAnimatedImageView+WebCache.m"; sourceTree = ""; }; + 24FB39BF7EA1BCAAC5A3DDA1DC226554 /* SDWebImageDefine.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDefine.h; path = SDWebImage/SDWebImageDefine.h; sourceTree = ""; }; + 252EA4A4143A0298288955A98FC2F6B8 /* SDImageCachesManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCachesManager.h; path = SDWebImage/SDImageCachesManager.h; sourceTree = ""; }; 26F12F84948751709EF2ECE2FCCA16D1 /* libPods-SDCycleScrollView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = "libPods-SDCycleScrollView.a"; path = "libPods-SDCycleScrollView.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 27D4432EE894DB9A19EED54491D77B31 /* SDMemoryCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDMemoryCache.m; path = SDWebImage/SDMemoryCache.m; sourceTree = ""; }; + 27E8309474F966628D3488F60EE56B76 /* SDInternalMacros.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDInternalMacros.m; path = SDWebImage/Private/SDInternalMacros.m; sourceTree = ""; }; 28402603F55CD72C518801A83342CBF6 /* Pods-SDCycleScrollView-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-SDCycleScrollView-dummy.m"; sourceTree = ""; }; + 297A05DF2CB0F803D6CD307A1115F0AA /* SDWebImageCacheKeyFilter.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageCacheKeyFilter.m; path = SDWebImage/SDWebImageCacheKeyFilter.m; sourceTree = ""; }; + 299D0541609FD621129F3323B78F0AF2 /* SDImageLoader.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageLoader.m; path = SDWebImage/SDImageLoader.m; sourceTree = ""; }; 2E4656658E6F974BDC0B2644E4C0DE6F /* Pods-SDCycleScrollView.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-SDCycleScrollView.debug.xcconfig"; sourceTree = ""; }; - 33187D162677C128060029C7359C0024 /* SDImageCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCache.m; path = SDWebImage/SDImageCache.m; sourceTree = ""; }; - 38144E417F1BCD6B1FAEC6B8717E1E23 /* NSImage+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSImage+WebCache.m"; path = "SDWebImage/NSImage+WebCache.m"; sourceTree = ""; }; + 2E728569F128BE30D0B31189F04B0594 /* SDImageCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCache.h; path = SDWebImage/SDImageCache.h; sourceTree = ""; }; + 2FD199A40983F02B0F9842FFFFFE50AD /* SDWebImageDownloader.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDownloader.h; path = SDWebImage/SDWebImageDownloader.h; sourceTree = ""; }; + 327630E206AA37029FDA8550C2D9C1AA /* SDImageCoder.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCoder.h; path = SDWebImage/SDImageCoder.h; sourceTree = ""; }; + 358978FAB2C566B04FB4F81A2472669E /* SDAnimatedImage.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDAnimatedImage.h; path = SDWebImage/SDAnimatedImage.h; sourceTree = ""; }; + 37642A5DE6FBA62A17E2FE3434CF1610 /* SDImageCoderHelper.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCoderHelper.m; path = SDWebImage/SDImageCoderHelper.m; sourceTree = ""; }; + 38FE5ABD708743EB87018CC13F861F01 /* UIImageView+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+WebCache.m"; path = "SDWebImage/UIImageView+WebCache.m"; sourceTree = ""; }; 39F14F4D91BCCA09D41340CC84440373 /* Pods-SDCycleScrollView-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-SDCycleScrollView-resources.sh"; sourceTree = ""; }; 3AB34520BD883B06A167910A68BDB340 /* libSDWebImage.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = libSDWebImage.a; path = libSDWebImage.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 4BE46DB6FE0E8D812F73130BD83794EB /* UIImage+MultiFormat.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+MultiFormat.m"; path = "SDWebImage/UIImage+MultiFormat.m"; sourceTree = ""; }; + 3CC05EFFE2466F212ADE0D1B5C4237F4 /* UIView+WebCacheOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIView+WebCacheOperation.m"; path = "SDWebImage/UIView+WebCacheOperation.m"; sourceTree = ""; }; + 3FBF78986CC5EC98518BD7CC559A789E /* SDWebImageCompat.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageCompat.m; path = SDWebImage/SDWebImageCompat.m; sourceTree = ""; }; + 400AFA873788C9C5294C8A9AD28AD866 /* SDInternalMacros.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDInternalMacros.h; path = SDWebImage/Private/SDInternalMacros.h; sourceTree = ""; }; + 46CCC34935322C85370ADB095550F87F /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/ImageIO.framework; sourceTree = DEVELOPER_DIR; }; + 471A4025DB4C846117183EF38EC4E31C /* NSImage+Compatibility.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSImage+Compatibility.m"; path = "SDWebImage/NSImage+Compatibility.m"; sourceTree = ""; }; + 4838B415BD044852DDDFF8CBD2B4307F /* UIImage+Transform.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+Transform.m"; path = "SDWebImage/UIImage+Transform.m"; sourceTree = ""; }; + 4BC307C36A8A6C4A6DB9F83A4CE8C536 /* UIView+WebCacheOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIView+WebCacheOperation.h"; path = "SDWebImage/UIView+WebCacheOperation.h"; sourceTree = ""; }; + 4CD626EAB095253442E41CD3BD7AF70D /* SDImageCacheConfig.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCacheConfig.h; path = SDWebImage/SDImageCacheConfig.h; sourceTree = ""; }; 51AE4E2A5687B066AD375FBBB6E54A73 /* Pods-SDCycleScrollView.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-SDCycleScrollView.release.xcconfig"; sourceTree = ""; }; - 5437AD385EDE551AEDFF150954990560 /* SDWebImage.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SDWebImage.xcconfig; sourceTree = ""; }; - 5498F4E300BC16139F8A6203B7E099F1 /* SDWebImage-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SDWebImage-prefix.pch"; sourceTree = ""; }; - 63C421E1831E29906D3404BDCA1B2C1B /* SDWebImage-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SDWebImage-dummy.m"; sourceTree = ""; }; - 6B2D7436D47BF86BE7F4C22F258A0154 /* SDWebImageManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageManager.m; path = SDWebImage/SDWebImageManager.m; sourceTree = ""; }; - 7175586325AADB8BA8C4ECB09907EA10 /* SDWebImageDownloaderOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDownloaderOperation.m; path = SDWebImage/SDWebImageDownloaderOperation.m; sourceTree = ""; }; - 800D2AB9BD2022E1D6C504CF6566681F /* SDWebImageCompat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageCompat.h; path = SDWebImage/SDWebImageCompat.h; sourceTree = ""; }; - 8A6E5B273CF39F8FC2FD8786F72729B7 /* SDWebImageDecoder.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDecoder.m; path = SDWebImage/SDWebImageDecoder.m; sourceTree = ""; }; - 8B730BABFE2264BB576806D96D5292B1 /* UIImage+MultiFormat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+MultiFormat.h"; path = "SDWebImage/UIImage+MultiFormat.h"; sourceTree = ""; }; - 8C97050C5BB315CF8D59A03899BAFA13 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/ImageIO.framework; sourceTree = DEVELOPER_DIR; }; - 8FF5AFAC79DED4F0C94D1BB961D2D557 /* SDWebImagePrefetcher.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImagePrefetcher.h; path = SDWebImage/SDWebImagePrefetcher.h; sourceTree = ""; }; + 5653AE3DAFA7109C6EE90B8627D9AF5A /* SDImageCodersManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCodersManager.m; path = SDWebImage/SDImageCodersManager.m; sourceTree = ""; }; + 57838CEA123FC3BD3535291808320965 /* UIButton+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIButton+WebCache.m"; path = "SDWebImage/UIButton+WebCache.m"; sourceTree = ""; }; + 5C076EF50460791EDA64C176108C4BAB /* SDImageCachesManagerOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCachesManagerOperation.m; path = SDWebImage/Private/SDImageCachesManagerOperation.m; sourceTree = ""; }; + 5EA9B4317A11216073FFB6DBAD5F803E /* SDImageLoadersManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageLoadersManager.m; path = SDWebImage/SDImageLoadersManager.m; sourceTree = ""; }; + 5FF6A35501C5E43C95290FCBED6E43C3 /* SDAnimatedImageView+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "SDAnimatedImageView+WebCache.h"; path = "SDWebImage/SDAnimatedImageView+WebCache.h"; sourceTree = ""; }; + 67343103154F724CCE9016F61FA76E05 /* UIImage+Transform.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+Transform.h"; path = "SDWebImage/UIImage+Transform.h"; sourceTree = ""; }; + 685C98EF4D7951391ECCEE3A88FED46E /* SDImageCacheDefine.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCacheDefine.m; path = SDWebImage/SDImageCacheDefine.m; sourceTree = ""; }; + 693BBCF3EE35260C780B78694E8AB5F3 /* SDImageIOCoder.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageIOCoder.h; path = SDWebImage/SDImageIOCoder.h; sourceTree = ""; }; + 724B476FA329BB5D5EBE4D5B95FC3619 /* SDWeakProxy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWeakProxy.m; path = SDWebImage/Private/SDWeakProxy.m; sourceTree = ""; }; + 740C4363AFC46B547870C1212FD59BFB /* SDImageAPNGCoder.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageAPNGCoder.h; path = SDWebImage/SDImageAPNGCoder.h; sourceTree = ""; }; + 742CC17B1484A3E9F54F138EE4E08BB0 /* SDImageGIFCoder.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageGIFCoder.m; path = SDWebImage/SDImageGIFCoder.m; sourceTree = ""; }; + 7813BA26306D2FEA740D27F8E105DB99 /* UIColor+HexString.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIColor+HexString.h"; path = "SDWebImage/Private/UIColor+HexString.h"; sourceTree = ""; }; + 79CD4B74E157C0A16CD427EBD3143B4B /* SDWebImageDownloaderConfig.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDownloaderConfig.m; path = SDWebImage/SDWebImageDownloaderConfig.m; sourceTree = ""; }; + 79F2ADE6B35494134D339EA2C90B9276 /* UIColor+HexString.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIColor+HexString.m"; path = "SDWebImage/Private/UIColor+HexString.m"; sourceTree = ""; }; + 7C7E1D5AA5E3BFCAD9D65D245B63D1FD /* SDImageGIFCoder.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageGIFCoder.h; path = SDWebImage/SDImageGIFCoder.h; sourceTree = ""; }; + 7DB62FCE59F7A1B1B269F90E5F954966 /* UIView+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIView+WebCache.h"; path = "SDWebImage/UIView+WebCache.h"; sourceTree = ""; }; + 7DE4C218276AC416F6D694C02EE9C5D7 /* SDImageAssetManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageAssetManager.m; path = SDWebImage/Private/SDImageAssetManager.m; sourceTree = ""; }; + 7EACDCA00375B43046C959ABF2621469 /* UIImage+MultiFormat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+MultiFormat.h"; path = "SDWebImage/UIImage+MultiFormat.h"; sourceTree = ""; }; + 817BEA41EF6F0B336EC31DDDB68AEDEA /* SDWebImageManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageManager.h; path = SDWebImage/SDWebImageManager.h; sourceTree = ""; }; + 84D45E81A5EFD0086A70019152256830 /* SDWebImage.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SDWebImage.xcconfig; sourceTree = ""; }; + 862AD584CCBCEAE9636F39626C29F407 /* SDImageCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCache.m; path = SDWebImage/SDImageCache.m; sourceTree = ""; }; + 8AA04EFE04CF822C0A17F260BA29FDA4 /* SDWebImageError.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageError.h; path = SDWebImage/SDWebImageError.h; sourceTree = ""; }; + 8C204F67D0CA51F885C6A350CBF753B4 /* SDImageIOCoder.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageIOCoder.m; path = SDWebImage/SDImageIOCoder.m; sourceTree = ""; }; + 8D18978388217BAD3C76C919917F488B /* SDmetamacros.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDmetamacros.h; path = SDWebImage/Private/SDmetamacros.h; sourceTree = ""; }; + 8DC56CEC50021BB4FD9BFB59F5C02EE3 /* SDImageCachesManagerOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCachesManagerOperation.h; path = SDWebImage/Private/SDImageCachesManagerOperation.h; sourceTree = ""; }; + 8E2B2CD6DBA50ED73A9A4DB28DA7666E /* SDWebImageDownloaderRequestModifier.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDownloaderRequestModifier.m; path = SDWebImage/SDWebImageDownloaderRequestModifier.m; sourceTree = ""; }; + 912D25A660B2BC888ACEFE0556A5A680 /* SDWebImageManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageManager.m; path = SDWebImage/SDWebImageManager.m; sourceTree = ""; }; + 93148A2C3D455B7A4E9CE157781367B6 /* SDImageAPNGCoder.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageAPNGCoder.m; path = SDWebImage/SDImageAPNGCoder.m; sourceTree = ""; }; 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - 9757679632F4D96FB95D495ADE43F19A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - 9A82F610DA462435F1AF2E40069B468A /* UIView+WebCacheOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIView+WebCacheOperation.h"; path = "SDWebImage/UIView+WebCacheOperation.h"; sourceTree = ""; }; - 9A96738A124145BD661891641E09D321 /* UIView+WebCacheOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIView+WebCacheOperation.m"; path = "SDWebImage/UIView+WebCacheOperation.m"; sourceTree = ""; }; - 9F24A6DBFFEDC06E98C0AFD080F1D24D /* UIImageView+HighlightedWebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+HighlightedWebCache.h"; path = "SDWebImage/UIImageView+HighlightedWebCache.h"; sourceTree = ""; }; - 9FAAAA9369B44B0CACDD1C0E8FCD6F43 /* SDWebImageDownloaderOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDownloaderOperation.h; path = SDWebImage/SDWebImageDownloaderOperation.h; sourceTree = ""; }; - AC1B1D53218A33DDF03E78CC1D10282D /* SDWebImageCompat.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageCompat.m; path = SDWebImage/SDWebImageCompat.m; sourceTree = ""; }; - AC4FF8277985072AA2414C8092B0E5E8 /* SDWebImageManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageManager.h; path = SDWebImage/SDWebImageManager.h; sourceTree = ""; }; - B1D5D1B92B920495205ECC5F01A79B18 /* SDWebImagePrefetcher.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImagePrefetcher.m; path = SDWebImage/SDWebImagePrefetcher.m; sourceTree = ""; }; - B1FC992CB7BD5112195C879B7F23ACC8 /* SDWebImageDecoder.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDecoder.h; path = SDWebImage/SDWebImageDecoder.h; sourceTree = ""; }; - CC6C5BEF90DB5C23F890DDF3AE04E82D /* NSImage+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSImage+WebCache.h"; path = "SDWebImage/NSImage+WebCache.h"; sourceTree = ""; }; - D0AAD31650A9E6056BF51E6E7F5DC451 /* SDWebImageDownloader.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDownloader.h; path = SDWebImage/SDWebImageDownloader.h; sourceTree = ""; }; + 95ABE62EC1EB24199357F7E9DEA8BC71 /* NSButton+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSButton+WebCache.m"; path = "SDWebImage/NSButton+WebCache.m"; sourceTree = ""; }; + 95B74374ADE7B3619DA5086AC7F1E954 /* UIImage+GIF.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+GIF.m"; path = "SDWebImage/UIImage+GIF.m"; sourceTree = ""; }; + 965CA1E15C752616A54C495859354070 /* SDAsyncBlockOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDAsyncBlockOperation.m; path = SDWebImage/Private/SDAsyncBlockOperation.m; sourceTree = ""; }; + 9A34D73ED123F5F748AE645379270F77 /* SDWebImageDefine.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDefine.m; path = SDWebImage/SDWebImageDefine.m; sourceTree = ""; }; + 9C124047867A671320DB11A9688C268E /* UIView+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIView+WebCache.m"; path = "SDWebImage/UIView+WebCache.m"; sourceTree = ""; }; + 9FD3A5509EC5028B8A144FB6757F5C79 /* SDWebImage-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SDWebImage-prefix.pch"; sourceTree = ""; }; + A245EB7795689D145AA8A71A79713EE7 /* SDWeakProxy.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWeakProxy.h; path = SDWebImage/Private/SDWeakProxy.h; sourceTree = ""; }; + A3983DE10FE8C33B8A1C9081EA378AE2 /* SDImageCodersManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCodersManager.h; path = SDWebImage/SDImageCodersManager.h; sourceTree = ""; }; + A413688E6D527C394DB942E97A79CC7D /* UIImage+MemoryCacheCost.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+MemoryCacheCost.h"; path = "SDWebImage/UIImage+MemoryCacheCost.h"; sourceTree = ""; }; + A619747494E6F4BD0FD882FE7DED8746 /* SDWebImageIndicator.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageIndicator.h; path = SDWebImage/SDWebImageIndicator.h; sourceTree = ""; }; + A91974CCB58F427C1764D73D283E3734 /* SDWebImageCompat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageCompat.h; path = SDWebImage/SDWebImageCompat.h; sourceTree = ""; }; + AA923309479E318B830D52F1B337EDA1 /* SDAnimatedImageView.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDAnimatedImageView.h; path = SDWebImage/SDAnimatedImageView.h; sourceTree = ""; }; + AD627E37D3ED047E71830F5E4E22A52F /* UIImageView+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+WebCache.h"; path = "SDWebImage/UIImageView+WebCache.h"; sourceTree = ""; }; + AECE16F143ED5A11B101E507F08B677E /* SDAsyncBlockOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDAsyncBlockOperation.h; path = SDWebImage/Private/SDAsyncBlockOperation.h; sourceTree = ""; }; + B1C24966B56D943C60B30E48343908D7 /* SDWebImageCacheSerializer.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageCacheSerializer.m; path = SDWebImage/SDWebImageCacheSerializer.m; sourceTree = ""; }; + B32BB3A3364C2577436CB6D5395F0FC1 /* SDWebImageError.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageError.m; path = SDWebImage/SDWebImageError.m; sourceTree = ""; }; + B475BEF1AD73DEAD014AC2B7CFCF4861 /* UIImageView+HighlightedWebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+HighlightedWebCache.m"; path = "SDWebImage/UIImageView+HighlightedWebCache.m"; sourceTree = ""; }; + B4E5E8E43B45E6679A1DDB70277160C9 /* UIImageView+HighlightedWebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+HighlightedWebCache.h"; path = "SDWebImage/UIImageView+HighlightedWebCache.h"; sourceTree = ""; }; + B7BF3C4337DE00F26A2D4386B32E169C /* NSData+ImageContentType.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSData+ImageContentType.m"; path = "SDWebImage/NSData+ImageContentType.m"; sourceTree = ""; }; + BADE89D6D30652E8F39D082602E75C7D /* UIImage+Metadata.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+Metadata.m"; path = "SDWebImage/UIImage+Metadata.m"; sourceTree = ""; }; + BBD6BB25D89D1B42F4936564C5BA640A /* SDWebImageDownloaderConfig.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDownloaderConfig.h; path = SDWebImage/SDWebImageDownloaderConfig.h; sourceTree = ""; }; + C5D45FFA26B6D19B057AD435A58C85DA /* UIButton+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+WebCache.h"; path = "SDWebImage/UIButton+WebCache.h"; sourceTree = ""; }; + C75CCDC9340AA190F18CE7A4650EC931 /* SDWebImageTransition.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageTransition.h; path = SDWebImage/SDWebImageTransition.h; sourceTree = ""; }; + C8F1E878C6065520F51BE4933981384A /* NSButton+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSButton+WebCache.h"; path = "SDWebImage/NSButton+WebCache.h"; sourceTree = ""; }; + CC50B874409F5595F554ED81B57F2E5B /* SDDiskCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDDiskCache.m; path = SDWebImage/SDDiskCache.m; sourceTree = ""; }; + CDB85D1A66A7602880B4A7D8D7CEA31F /* SDWebImageCacheSerializer.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageCacheSerializer.h; path = SDWebImage/SDWebImageCacheSerializer.h; sourceTree = ""; }; + CEDB7B91DE3BDBD371418213B2A1018F /* SDImageLoader.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageLoader.h; path = SDWebImage/SDImageLoader.h; sourceTree = ""; }; + CF5C37953A10E1847A179009361FA9BE /* SDMemoryCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDMemoryCache.h; path = SDWebImage/SDMemoryCache.h; sourceTree = ""; }; + CFE3C8B4010B3A5D5B3D485ADFFAE31E /* SDImageTransformer.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageTransformer.m; path = SDWebImage/SDImageTransformer.m; sourceTree = ""; }; + D10F7457F3E2BF3D94A2CDF2CACBA6F3 /* NSBezierPath+RoundedCorners.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSBezierPath+RoundedCorners.h"; path = "SDWebImage/Private/NSBezierPath+RoundedCorners.h"; sourceTree = ""; }; + D9D40C20DADFED8D00E2814A4C15FD74 /* SDImageCachesManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCachesManager.m; path = SDWebImage/SDImageCachesManager.m; sourceTree = ""; }; + DA94C0A9E8D752E887DDA70C51FE790B /* SDWebImage-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SDWebImage-dummy.m"; sourceTree = ""; }; + DD7ABEEE27609AD673AADB3A4BA78560 /* SDWebImageDownloaderOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDownloaderOperation.m; path = SDWebImage/SDWebImageDownloaderOperation.m; sourceTree = ""; }; + DF5A6ABC0D605124ADF3D45B438BA284 /* SDImageCoderHelper.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCoderHelper.h; path = SDWebImage/SDImageCoderHelper.h; sourceTree = ""; }; + DF66C7AB6B984E09C80E82DFB49A4378 /* SDImageGIFCoderInternal.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageGIFCoderInternal.h; path = SDWebImage/Private/SDImageGIFCoderInternal.h; sourceTree = ""; }; + E0322BA20062BAFB677D9BDB027A85B7 /* SDAnimatedImageView.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDAnimatedImageView.m; path = SDWebImage/SDAnimatedImageView.m; sourceTree = ""; }; + E1E0120381C41F901C053A675AA09774 /* SDImageGraphics.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageGraphics.m; path = SDWebImage/SDImageGraphics.m; sourceTree = ""; }; + E1EBB1C87045EF7B9F693C3B1F5FFF8D /* SDImageFrame.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageFrame.h; path = SDWebImage/SDImageFrame.h; sourceTree = ""; }; + E3E8964FE03D3276C0CB61948E156A14 /* UIImage+MemoryCacheCost.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+MemoryCacheCost.m"; path = "SDWebImage/UIImage+MemoryCacheCost.m"; sourceTree = ""; }; E4E8417D73B90ECCAF12D7582A46FFCE /* Pods-SDCycleScrollView-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-SDCycleScrollView-acknowledgements.plist"; sourceTree = ""; }; - EBB52CF8D4721A70A8DBB80842994D97 /* UIImageView+HighlightedWebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+HighlightedWebCache.m"; path = "SDWebImage/UIImageView+HighlightedWebCache.m"; sourceTree = ""; }; - F3B0E9B6DF8E857C9B0D2F99FC304F5C /* UIImageView+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+WebCache.h"; path = "SDWebImage/UIImageView+WebCache.h"; sourceTree = ""; }; + E7ABEF7378149E529C46995578A29DC2 /* NSImage+Compatibility.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSImage+Compatibility.h"; path = "SDWebImage/NSImage+Compatibility.h"; sourceTree = ""; }; + ED5A8112D1C8315E467C16BAC610263D /* SDWebImagePrefetcher.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImagePrefetcher.h; path = SDWebImage/SDWebImagePrefetcher.h; sourceTree = ""; }; + EE0E926662DDC8AE9800938B7165B173 /* SDImageFrame.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageFrame.m; path = SDWebImage/SDImageFrame.m; sourceTree = ""; }; + F25B05917B4744980F19D8172BC89A76 /* NSBezierPath+RoundedCorners.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSBezierPath+RoundedCorners.m"; path = "SDWebImage/Private/NSBezierPath+RoundedCorners.m"; sourceTree = ""; }; + F3BCA0F245BD5F9E6EAE47A0DEAA1D0C /* SDWebImageOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageOperation.h; path = SDWebImage/SDWebImageOperation.h; sourceTree = ""; }; + F3DDDB05D460AEF07A2B3B6CB1D0DBEF /* SDImageCoder.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCoder.m; path = SDWebImage/SDImageCoder.m; sourceTree = ""; }; + F46D5AD4CC4784CBB63CA4BC95258748 /* SDAnimatedImageRep.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDAnimatedImageRep.h; path = SDWebImage/SDAnimatedImageRep.h; sourceTree = ""; }; + F480D462C4940521841D4A8F389FDAD8 /* SDImageAPNGCoderInternal.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageAPNGCoderInternal.h; path = SDWebImage/Private/SDImageAPNGCoderInternal.h; sourceTree = ""; }; + F623865988B321F01F17496583BF5710 /* SDWebImagePrefetcher.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImagePrefetcher.m; path = SDWebImage/SDWebImagePrefetcher.m; sourceTree = ""; }; F7D9C47C6B7A1C918340961DF8FC0F56 /* Pods-SDCycleScrollView-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-SDCycleScrollView-acknowledgements.markdown"; sourceTree = ""; }; - F84F89DA463D5F013F47620258BECA2C /* UIButton+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+WebCache.h"; path = "SDWebImage/UIButton+WebCache.h"; sourceTree = ""; }; - F922701ABE8790DD84BD643BFA3F9D9E /* UIImageView+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+WebCache.m"; path = "SDWebImage/UIImageView+WebCache.m"; sourceTree = ""; }; - FC24B0F8787681FFD86A7FF97C481764 /* UIView+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIView+WebCache.h"; path = "SDWebImage/UIView+WebCache.h"; sourceTree = ""; }; + F9D83F02AC271A5CC560E16FAF7D6675 /* SDWebImageTransition.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageTransition.m; path = SDWebImage/SDWebImageTransition.m; sourceTree = ""; }; + FBBED8C92E3705C3A859F86BE6698FE6 /* UIImage+MultiFormat.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+MultiFormat.m"; path = "SDWebImage/UIImage+MultiFormat.m"; sourceTree = ""; }; + FD05F5F67E683C39C452461374576EA2 /* SDAnimatedImageRep.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDAnimatedImageRep.m; path = SDWebImage/SDAnimatedImageRep.m; sourceTree = ""; }; + FD6FE5D298A971DEAFFA685B4C7CF3E9 /* SDImageCacheDefine.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCacheDefine.h; path = SDWebImage/SDImageCacheDefine.h; sourceTree = ""; }; + FD8011F1FE90BAC4E879AA60199D59DB /* UIImage+ForceDecode.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+ForceDecode.h"; path = "SDWebImage/UIImage+ForceDecode.h"; sourceTree = ""; }; + FE82B97C5E67AA40232423DF711CF3E7 /* SDWebImageCacheKeyFilter.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageCacheKeyFilter.h; path = SDWebImage/SDWebImageCacheKeyFilter.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 0D9AD3D4B9069066E913291417EFF1D9 /* Frameworks */ = { + AE71903F14643C0DA4FE37E71EE70777 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 1DA182826EC8C87EB9B467553410FBC7 /* Foundation.framework in Frameworks */, + 015DAF5E194F4BFF92C2062E21440393 /* ImageIO.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; - 3E58F3D4D961D5FB9EDD17EA1539091E /* Frameworks */ = { + B85B13BC2B65A16F92C3DE9859A3FFE7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 6FE4ED7E5C0B4D314B886640BB86D6BE /* Foundation.framework in Frameworks */, - 5D692C1F585A2AB1D4FA27913EC2481A /* ImageIO.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -148,22 +303,23 @@ path = "Target Support Files/Pods-SDCycleScrollView"; sourceTree = ""; }; - 0B3A2341D139ED8F608BC1E84218DBDD /* SDWebImage */ = { + 04AC3CF222DBCEF919EC9963C0E0B331 /* Support Files */ = { isa = PBXGroup; children = ( - D87149291904346236E59ACD631FBD6B /* Core */, - C07A6F66802BE499B63D9B298F0F3416 /* Support Files */, + 84D45E81A5EFD0086A70019152256830 /* SDWebImage.xcconfig */, + DA94C0A9E8D752E887DDA70C51FE790B /* SDWebImage-dummy.m */, + 9FD3A5509EC5028B8A144FB6757F5C79 /* SDWebImage-prefix.pch */, ); - name = SDWebImage; - path = SDWebImage; + name = "Support Files"; + path = "../Target Support Files/SDWebImage"; sourceTree = ""; }; - 433CD3331B6C3787F473C941B61FC68F /* Frameworks */ = { + 4D6FA5267D81D23C793FDDA02B337D76 /* iOS */ = { isa = PBXGroup; children = ( - 7D84E3C69AE5CBF48F1BFE903C509C33 /* iOS */, + 46CCC34935322C85370ADB095550F87F /* ImageIO.framework */, ); - name = Frameworks; + name = iOS; sourceTree = ""; }; 6765F70F788296904DCD38D349E1A56E /* Products */ = { @@ -175,20 +331,11 @@ name = Products; sourceTree = ""; }; - 7D84E3C69AE5CBF48F1BFE903C509C33 /* iOS */ = { - isa = PBXGroup; - children = ( - 9757679632F4D96FB95D495ADE43F19A /* Foundation.framework */, - 8C97050C5BB315CF8D59A03899BAFA13 /* ImageIO.framework */, - ); - name = iOS; - sourceTree = ""; - }; 7DB346D0F39D3F0E887471402A8071AB = { isa = PBXGroup; children = ( 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */, - 433CD3331B6C3787F473C941B61FC68F /* Frameworks */, + BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */, BF4B13718B20D23D5B220FA33C2583D8 /* Pods */, 6765F70F788296904DCD38D349E1A56E /* Products */, AA2EF140399E6251B8D8B12610F52F18 /* Targets Support Files */, @@ -203,130 +350,267 @@ name = "Targets Support Files"; sourceTree = ""; }; - BF4B13718B20D23D5B220FA33C2583D8 /* Pods */ = { + ACC4418C23F9249F3874FCC4B92FC544 /* Core */ = { isa = PBXGroup; children = ( - 0B3A2341D139ED8F608BC1E84218DBDD /* SDWebImage */, + D10F7457F3E2BF3D94A2CDF2CACBA6F3 /* NSBezierPath+RoundedCorners.h */, + F25B05917B4744980F19D8172BC89A76 /* NSBezierPath+RoundedCorners.m */, + C8F1E878C6065520F51BE4933981384A /* NSButton+WebCache.h */, + 95ABE62EC1EB24199357F7E9DEA8BC71 /* NSButton+WebCache.m */, + 1D7A08DB6ECF1AAA5FB9C45300C5FC79 /* NSData+ImageContentType.h */, + B7BF3C4337DE00F26A2D4386B32E169C /* NSData+ImageContentType.m */, + E7ABEF7378149E529C46995578A29DC2 /* NSImage+Compatibility.h */, + 471A4025DB4C846117183EF38EC4E31C /* NSImage+Compatibility.m */, + 358978FAB2C566B04FB4F81A2472669E /* SDAnimatedImage.h */, + 242952C85954F97FAD2F21A50F4B0941 /* SDAnimatedImage.m */, + F46D5AD4CC4784CBB63CA4BC95258748 /* SDAnimatedImageRep.h */, + FD05F5F67E683C39C452461374576EA2 /* SDAnimatedImageRep.m */, + AA923309479E318B830D52F1B337EDA1 /* SDAnimatedImageView.h */, + E0322BA20062BAFB677D9BDB027A85B7 /* SDAnimatedImageView.m */, + 5FF6A35501C5E43C95290FCBED6E43C3 /* SDAnimatedImageView+WebCache.h */, + 24AED846B71430FFBE02D3AECCBF0576 /* SDAnimatedImageView+WebCache.m */, + AECE16F143ED5A11B101E507F08B677E /* SDAsyncBlockOperation.h */, + 965CA1E15C752616A54C495859354070 /* SDAsyncBlockOperation.m */, + 14CA9FC43AB44A0A1913B13BB7CEFBA8 /* SDDiskCache.h */, + CC50B874409F5595F554ED81B57F2E5B /* SDDiskCache.m */, + 740C4363AFC46B547870C1212FD59BFB /* SDImageAPNGCoder.h */, + 93148A2C3D455B7A4E9CE157781367B6 /* SDImageAPNGCoder.m */, + F480D462C4940521841D4A8F389FDAD8 /* SDImageAPNGCoderInternal.h */, + 0924FB2B142D007EFA183C280FFC5F5A /* SDImageAssetManager.h */, + 7DE4C218276AC416F6D694C02EE9C5D7 /* SDImageAssetManager.m */, + 2E728569F128BE30D0B31189F04B0594 /* SDImageCache.h */, + 862AD584CCBCEAE9636F39626C29F407 /* SDImageCache.m */, + 4CD626EAB095253442E41CD3BD7AF70D /* SDImageCacheConfig.h */, + 013C9CB568185DDE99962EB0D2B9E464 /* SDImageCacheConfig.m */, + FD6FE5D298A971DEAFFA685B4C7CF3E9 /* SDImageCacheDefine.h */, + 685C98EF4D7951391ECCEE3A88FED46E /* SDImageCacheDefine.m */, + 252EA4A4143A0298288955A98FC2F6B8 /* SDImageCachesManager.h */, + D9D40C20DADFED8D00E2814A4C15FD74 /* SDImageCachesManager.m */, + 8DC56CEC50021BB4FD9BFB59F5C02EE3 /* SDImageCachesManagerOperation.h */, + 5C076EF50460791EDA64C176108C4BAB /* SDImageCachesManagerOperation.m */, + 327630E206AA37029FDA8550C2D9C1AA /* SDImageCoder.h */, + F3DDDB05D460AEF07A2B3B6CB1D0DBEF /* SDImageCoder.m */, + DF5A6ABC0D605124ADF3D45B438BA284 /* SDImageCoderHelper.h */, + 37642A5DE6FBA62A17E2FE3434CF1610 /* SDImageCoderHelper.m */, + A3983DE10FE8C33B8A1C9081EA378AE2 /* SDImageCodersManager.h */, + 5653AE3DAFA7109C6EE90B8627D9AF5A /* SDImageCodersManager.m */, + E1EBB1C87045EF7B9F693C3B1F5FFF8D /* SDImageFrame.h */, + EE0E926662DDC8AE9800938B7165B173 /* SDImageFrame.m */, + 7C7E1D5AA5E3BFCAD9D65D245B63D1FD /* SDImageGIFCoder.h */, + 742CC17B1484A3E9F54F138EE4E08BB0 /* SDImageGIFCoder.m */, + DF66C7AB6B984E09C80E82DFB49A4378 /* SDImageGIFCoderInternal.h */, + 086EE0E1FA0EA4CCC7A50D97347A511A /* SDImageGraphics.h */, + E1E0120381C41F901C053A675AA09774 /* SDImageGraphics.m */, + 693BBCF3EE35260C780B78694E8AB5F3 /* SDImageIOCoder.h */, + 8C204F67D0CA51F885C6A350CBF753B4 /* SDImageIOCoder.m */, + CEDB7B91DE3BDBD371418213B2A1018F /* SDImageLoader.h */, + 299D0541609FD621129F3323B78F0AF2 /* SDImageLoader.m */, + 10ED050ECEF1C479762A41F18CA54EAC /* SDImageLoadersManager.h */, + 5EA9B4317A11216073FFB6DBAD5F803E /* SDImageLoadersManager.m */, + 1E2B30396EFEB52D1344BFAD7C08DB16 /* SDImageTransformer.h */, + CFE3C8B4010B3A5D5B3D485ADFFAE31E /* SDImageTransformer.m */, + 400AFA873788C9C5294C8A9AD28AD866 /* SDInternalMacros.h */, + 27E8309474F966628D3488F60EE56B76 /* SDInternalMacros.m */, + CF5C37953A10E1847A179009361FA9BE /* SDMemoryCache.h */, + 27D4432EE894DB9A19EED54491D77B31 /* SDMemoryCache.m */, + 8D18978388217BAD3C76C919917F488B /* SDmetamacros.h */, + A245EB7795689D145AA8A71A79713EE7 /* SDWeakProxy.h */, + 724B476FA329BB5D5EBE4D5B95FC3619 /* SDWeakProxy.m */, + 15EDB45480ACEB0EC48B9141E97883C2 /* SDWebImage.h */, + FE82B97C5E67AA40232423DF711CF3E7 /* SDWebImageCacheKeyFilter.h */, + 297A05DF2CB0F803D6CD307A1115F0AA /* SDWebImageCacheKeyFilter.m */, + CDB85D1A66A7602880B4A7D8D7CEA31F /* SDWebImageCacheSerializer.h */, + B1C24966B56D943C60B30E48343908D7 /* SDWebImageCacheSerializer.m */, + A91974CCB58F427C1764D73D283E3734 /* SDWebImageCompat.h */, + 3FBF78986CC5EC98518BD7CC559A789E /* SDWebImageCompat.m */, + 24FB39BF7EA1BCAAC5A3DDA1DC226554 /* SDWebImageDefine.h */, + 9A34D73ED123F5F748AE645379270F77 /* SDWebImageDefine.m */, + 2FD199A40983F02B0F9842FFFFFE50AD /* SDWebImageDownloader.h */, + 21A200B372A442E1A1C6AB08E21F63A4 /* SDWebImageDownloader.m */, + BBD6BB25D89D1B42F4936564C5BA640A /* SDWebImageDownloaderConfig.h */, + 79CD4B74E157C0A16CD427EBD3143B4B /* SDWebImageDownloaderConfig.m */, + 1B82716CEFAF9CAE8EE2A867A5D15499 /* SDWebImageDownloaderOperation.h */, + DD7ABEEE27609AD673AADB3A4BA78560 /* SDWebImageDownloaderOperation.m */, + 04F05F110D78D69A2DD2452036BC3DB2 /* SDWebImageDownloaderRequestModifier.h */, + 8E2B2CD6DBA50ED73A9A4DB28DA7666E /* SDWebImageDownloaderRequestModifier.m */, + 8AA04EFE04CF822C0A17F260BA29FDA4 /* SDWebImageError.h */, + B32BB3A3364C2577436CB6D5395F0FC1 /* SDWebImageError.m */, + A619747494E6F4BD0FD882FE7DED8746 /* SDWebImageIndicator.h */, + 0B0F702B6FF89EF212A40916477C1450 /* SDWebImageIndicator.m */, + 817BEA41EF6F0B336EC31DDDB68AEDEA /* SDWebImageManager.h */, + 912D25A660B2BC888ACEFE0556A5A680 /* SDWebImageManager.m */, + F3BCA0F245BD5F9E6EAE47A0DEAA1D0C /* SDWebImageOperation.h */, + ED5A8112D1C8315E467C16BAC610263D /* SDWebImagePrefetcher.h */, + F623865988B321F01F17496583BF5710 /* SDWebImagePrefetcher.m */, + C75CCDC9340AA190F18CE7A4650EC931 /* SDWebImageTransition.h */, + F9D83F02AC271A5CC560E16FAF7D6675 /* SDWebImageTransition.m */, + C5D45FFA26B6D19B057AD435A58C85DA /* UIButton+WebCache.h */, + 57838CEA123FC3BD3535291808320965 /* UIButton+WebCache.m */, + 7813BA26306D2FEA740D27F8E105DB99 /* UIColor+HexString.h */, + 79F2ADE6B35494134D339EA2C90B9276 /* UIColor+HexString.m */, + FD8011F1FE90BAC4E879AA60199D59DB /* UIImage+ForceDecode.h */, + 166BEB9DD6DC2E9005E2A0F26F58CB30 /* UIImage+ForceDecode.m */, + 04DAB48D959F5ADE26E33A5678CFC81A /* UIImage+GIF.h */, + 95B74374ADE7B3619DA5086AC7F1E954 /* UIImage+GIF.m */, + A413688E6D527C394DB942E97A79CC7D /* UIImage+MemoryCacheCost.h */, + E3E8964FE03D3276C0CB61948E156A14 /* UIImage+MemoryCacheCost.m */, + 0A4C07E130AB45A5536D0ACD5F198F3D /* UIImage+Metadata.h */, + BADE89D6D30652E8F39D082602E75C7D /* UIImage+Metadata.m */, + 7EACDCA00375B43046C959ABF2621469 /* UIImage+MultiFormat.h */, + FBBED8C92E3705C3A859F86BE6698FE6 /* UIImage+MultiFormat.m */, + 67343103154F724CCE9016F61FA76E05 /* UIImage+Transform.h */, + 4838B415BD044852DDDFF8CBD2B4307F /* UIImage+Transform.m */, + B4E5E8E43B45E6679A1DDB70277160C9 /* UIImageView+HighlightedWebCache.h */, + B475BEF1AD73DEAD014AC2B7CFCF4861 /* UIImageView+HighlightedWebCache.m */, + AD627E37D3ED047E71830F5E4E22A52F /* UIImageView+WebCache.h */, + 38FE5ABD708743EB87018CC13F861F01 /* UIImageView+WebCache.m */, + 7DB62FCE59F7A1B1B269F90E5F954966 /* UIView+WebCache.h */, + 9C124047867A671320DB11A9688C268E /* UIView+WebCache.m */, + 4BC307C36A8A6C4A6DB9F83A4CE8C536 /* UIView+WebCacheOperation.h */, + 3CC05EFFE2466F212ADE0D1B5C4237F4 /* UIView+WebCacheOperation.m */, ); - name = Pods; + name = Core; sourceTree = ""; }; - C07A6F66802BE499B63D9B298F0F3416 /* Support Files */ = { + BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */ = { isa = PBXGroup; children = ( - 5437AD385EDE551AEDFF150954990560 /* SDWebImage.xcconfig */, - 63C421E1831E29906D3404BDCA1B2C1B /* SDWebImage-dummy.m */, - 5498F4E300BC16139F8A6203B7E099F1 /* SDWebImage-prefix.pch */, + 4D6FA5267D81D23C793FDDA02B337D76 /* iOS */, ); - name = "Support Files"; - path = "../Target Support Files/SDWebImage"; + name = Frameworks; sourceTree = ""; }; - D87149291904346236E59ACD631FBD6B /* Core */ = { + BF4B13718B20D23D5B220FA33C2583D8 /* Pods */ = { isa = PBXGroup; children = ( - 151184230168224C23550D1C654C722F /* NSData+ImageContentType.h */, - 0515B8FFDF02AC747460BF06B7147C92 /* NSData+ImageContentType.m */, - CC6C5BEF90DB5C23F890DDF3AE04E82D /* NSImage+WebCache.h */, - 38144E417F1BCD6B1FAEC6B8717E1E23 /* NSImage+WebCache.m */, - 0E2890C6456A666BDAAC0FA873AC628D /* SDImageCache.h */, - 33187D162677C128060029C7359C0024 /* SDImageCache.m */, - 169F96E9B9B5F19875E606404AF824BE /* SDImageCacheConfig.h */, - 017851524E3ABDA65B7BF9B37C3D7034 /* SDImageCacheConfig.m */, - 800D2AB9BD2022E1D6C504CF6566681F /* SDWebImageCompat.h */, - AC1B1D53218A33DDF03E78CC1D10282D /* SDWebImageCompat.m */, - B1FC992CB7BD5112195C879B7F23ACC8 /* SDWebImageDecoder.h */, - 8A6E5B273CF39F8FC2FD8786F72729B7 /* SDWebImageDecoder.m */, - D0AAD31650A9E6056BF51E6E7F5DC451 /* SDWebImageDownloader.h */, - 061BD245946E3501DC9722976B6AD69F /* SDWebImageDownloader.m */, - 9FAAAA9369B44B0CACDD1C0E8FCD6F43 /* SDWebImageDownloaderOperation.h */, - 7175586325AADB8BA8C4ECB09907EA10 /* SDWebImageDownloaderOperation.m */, - AC4FF8277985072AA2414C8092B0E5E8 /* SDWebImageManager.h */, - 6B2D7436D47BF86BE7F4C22F258A0154 /* SDWebImageManager.m */, - 1278B5233127A1E722D53F10E7FA5EC8 /* SDWebImageOperation.h */, - 8FF5AFAC79DED4F0C94D1BB961D2D557 /* SDWebImagePrefetcher.h */, - B1D5D1B92B920495205ECC5F01A79B18 /* SDWebImagePrefetcher.m */, - F84F89DA463D5F013F47620258BECA2C /* UIButton+WebCache.h */, - 123A809310FA5938787013915F3D64B4 /* UIButton+WebCache.m */, - 0ACCB8B450CC4B80A63EE725C41C0B29 /* UIImage+GIF.h */, - 003ABD753CAF59EF000CA534C832D14D /* UIImage+GIF.m */, - 8B730BABFE2264BB576806D96D5292B1 /* UIImage+MultiFormat.h */, - 4BE46DB6FE0E8D812F73130BD83794EB /* UIImage+MultiFormat.m */, - 9F24A6DBFFEDC06E98C0AFD080F1D24D /* UIImageView+HighlightedWebCache.h */, - EBB52CF8D4721A70A8DBB80842994D97 /* UIImageView+HighlightedWebCache.m */, - F3B0E9B6DF8E857C9B0D2F99FC304F5C /* UIImageView+WebCache.h */, - F922701ABE8790DD84BD643BFA3F9D9E /* UIImageView+WebCache.m */, - FC24B0F8787681FFD86A7FF97C481764 /* UIView+WebCache.h */, - 1F2BB2A6F6DDDD53BC079622F286FF42 /* UIView+WebCache.m */, - 9A82F610DA462435F1AF2E40069B468A /* UIView+WebCacheOperation.h */, - 9A96738A124145BD661891641E09D321 /* UIView+WebCacheOperation.m */, + E3E2557BE79D3BF60FBAA39B70BB117E /* SDWebImage */, ); - name = Core; + name = Pods; + sourceTree = ""; + }; + E3E2557BE79D3BF60FBAA39B70BB117E /* SDWebImage */ = { + isa = PBXGroup; + children = ( + ACC4418C23F9249F3874FCC4B92FC544 /* Core */, + 04AC3CF222DBCEF919EC9963C0E0B331 /* Support Files */, + ); + name = SDWebImage; + path = SDWebImage; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ - C9949CD275B61A994824D0C12BBA4212 /* Headers */ = { + 57A70848059A3F71907212BF23F0A5D2 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 2B03ABA71D7AB83DAC5FFF63BA2038CC /* NSBezierPath+RoundedCorners.h in Headers */, + E288A4CE8C87E324A37BE68DBC8579FF /* NSButton+WebCache.h in Headers */, + D013AD4793C4D4E36BFE990E44143AAD /* NSData+ImageContentType.h in Headers */, + 041785B6A223D7A9CCE89E9F4B0BC23D /* NSImage+Compatibility.h in Headers */, + 1AB9619CAE94105841213942BE8FCFC4 /* SDAnimatedImage.h in Headers */, + E58E12550D55AD4BA229611B3F3FA835 /* SDAnimatedImageRep.h in Headers */, + 236A672A5E4B8E00EC7C9D2A8FEDC139 /* SDAnimatedImageView+WebCache.h in Headers */, + E9FD13262C44C904D0C7A3DD7C35B0F6 /* SDAnimatedImageView.h in Headers */, + B1DE6CC693FDA77B6D2185CF91BFF625 /* SDAsyncBlockOperation.h in Headers */, + DBAB548A7AE22D5C77A2BAEE1F156DB7 /* SDDiskCache.h in Headers */, + 8A9A602B6A841872373C523F1B005359 /* SDImageAPNGCoder.h in Headers */, + F9B99B6481DB22FB77161450AFFFEBBF /* SDImageAPNGCoderInternal.h in Headers */, + 489561F7F78E7CDADA7D59C08C2DEF75 /* SDImageAssetManager.h in Headers */, + BF200366C603CA7F20B4BF6291091596 /* SDImageCache.h in Headers */, + 332D280BF4D5E90DDF8AD94CBC338586 /* SDImageCacheConfig.h in Headers */, + AA4FBF21D640C3721B755869B5C174E3 /* SDImageCacheDefine.h in Headers */, + 5B6A9B73BF63BC1CC1B32C74FF1BC485 /* SDImageCachesManager.h in Headers */, + 86194C7C685FE84C0ECFDE1BDD96A331 /* SDImageCachesManagerOperation.h in Headers */, + 44DD3A94A38F29766C51A8306C5B5B23 /* SDImageCoder.h in Headers */, + 52334444A5F9D3AB3B826533FA5F11B3 /* SDImageCoderHelper.h in Headers */, + 325D712321152BCDB4FB51E5F8EC90DF /* SDImageCodersManager.h in Headers */, + 182724AF3B99093B45530C87D8A95EDE /* SDImageFrame.h in Headers */, + 79F2466272FDCBAA74CBE5AC2EE0640B /* SDImageGIFCoder.h in Headers */, + A269D6FED8BEA14664B25C72E68FA3AD /* SDImageGIFCoderInternal.h in Headers */, + 14B7469739C5AFBDE9FDD52844D5D461 /* SDImageGraphics.h in Headers */, + DC89D52A2149475F3D747413A0075C3D /* SDImageIOCoder.h in Headers */, + 3E34384734A72BF450EFAE7C1FD3575F /* SDImageLoader.h in Headers */, + 604A8B694B89CB58C791BAAF0F3641BB /* SDImageLoadersManager.h in Headers */, + 4295551A6F547D5562E4EE3D85E62927 /* SDImageTransformer.h in Headers */, + 3F448EE6946D52AE1B9EB64A63CFFF8B /* SDInternalMacros.h in Headers */, + 1542BA07EC3225C2D8E27770F0E9E3E1 /* SDMemoryCache.h in Headers */, + 7E163BB499D7E5B56605D123119B0218 /* SDmetamacros.h in Headers */, + B812A6162E3D6E4C7E3D7ABBE9A37825 /* SDWeakProxy.h in Headers */, + 1C993E6046FCDDF9C93BAFAC22F6B5E0 /* SDWebImage.h in Headers */, + FC93FB677AB5D7D5923FD293C1109692 /* SDWebImageCacheKeyFilter.h in Headers */, + 58D381662970FE011EED09F4DB99FF69 /* SDWebImageCacheSerializer.h in Headers */, + 9CD037CC4E713BE035052909CFDC7CDB /* SDWebImageCompat.h in Headers */, + 5214D2AAB2E5DE5027ED02BFD052E75C /* SDWebImageDefine.h in Headers */, + 548C07B2567191751DA2DF6CDDB4DF19 /* SDWebImageDownloader.h in Headers */, + 99D2E5B21E1F05939CC30FF6BEFF9E89 /* SDWebImageDownloaderConfig.h in Headers */, + 2EC315732B470964D4E397459F95D1DC /* SDWebImageDownloaderOperation.h in Headers */, + 2DCD9020DAA94C4FA194A2DACE12830B /* SDWebImageDownloaderRequestModifier.h in Headers */, + 3547A4FD96ED48176396D9CDD9BA59B9 /* SDWebImageError.h in Headers */, + 1C14257D98DF6893FBEF059AA6A20817 /* SDWebImageIndicator.h in Headers */, + 51B49695AA82F4ED962B938D312DE2CB /* SDWebImageManager.h in Headers */, + 5255772D9D225389C738332D83628EA8 /* SDWebImageOperation.h in Headers */, + 2C01FA5B03600B28879E3FC413F72C0F /* SDWebImagePrefetcher.h in Headers */, + C5FA55898462E047EAB14D0FD0F011B9 /* SDWebImageTransition.h in Headers */, + AD10793D43B7CE79FE2B2870875A3269 /* UIButton+WebCache.h in Headers */, + CFB5988D4F1373EC852CF115D0E40EF4 /* UIColor+HexString.h in Headers */, + 82148E298BC2CAA1995F87646BFCCE28 /* UIImage+ForceDecode.h in Headers */, + D60C936D270619B9462ED070DCA3AB90 /* UIImage+GIF.h in Headers */, + 4DED5FA6CA047667A0E72CF511DC7395 /* UIImage+MemoryCacheCost.h in Headers */, + 4ABEB2B0416B66969CD541D55452E545 /* UIImage+Metadata.h in Headers */, + 9D907B0F2724776188CCB32DEA810F55 /* UIImage+MultiFormat.h in Headers */, + F7F7651B871AEA0A8E80C9E4ABAAEB37 /* UIImage+Transform.h in Headers */, + 1079FC4C3A11D2F6EE2D0BB5E9F25D14 /* UIImageView+HighlightedWebCache.h in Headers */, + 71DC7B6657041333D23DB519DF31E116 /* UIImageView+WebCache.h in Headers */, + C5078979C875E1856A9252CFC491700F /* UIView+WebCache.h in Headers */, + EF790706D931EA9C9F62FC3C6F6ADE4F /* UIView+WebCacheOperation.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 58CD89A7E8464654E2432BA919F0BDBC /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 41D681DF56CF050FF356A3830D2E019A /* NSData+ImageContentType.h in Headers */, - 9BE39F21B6B0A15D3ED1EBEF23C7A1D6 /* NSImage+WebCache.h in Headers */, - 6450B80E85D93BA4F47EA53250BA24BA /* SDImageCache.h in Headers */, - 58C3747479C9F665724E660819653FEC /* SDImageCacheConfig.h in Headers */, - 7E35B5C825EC79C3D9FEC0CDEA0B89C4 /* SDWebImageCompat.h in Headers */, - A922281722FC3E4E385E883385114A75 /* SDWebImageDecoder.h in Headers */, - 9E469014F9101E8B45DD6CE2DD32C9C4 /* SDWebImageDownloader.h in Headers */, - D99B7877B3CF8C66A8B9E37D12448D95 /* SDWebImageDownloaderOperation.h in Headers */, - 7EF397649EE76E22EFEA1DCCACF95006 /* SDWebImageManager.h in Headers */, - 382DC345E4CD7336DB317C977E0A99C3 /* SDWebImageOperation.h in Headers */, - 31E75759A4D48F2BAE19250501E5BFF3 /* SDWebImagePrefetcher.h in Headers */, - 508FC75E82E9E649B029E9A01779374B /* UIButton+WebCache.h in Headers */, - 552E2209ED0C19F4C9ED3FD8F36D0CB1 /* UIImage+GIF.h in Headers */, - 415FACAA36208C9635B45618EAB2AAF6 /* UIImage+MultiFormat.h in Headers */, - 2F6FDB59B5F2FC767BCBC56E20B629C1 /* UIImageView+HighlightedWebCache.h in Headers */, - 0806B52A4FF29C2EC3EF54188853178B /* UIImageView+WebCache.h in Headers */, - B05F1D8C2665A054BBC70862DE98496E /* UIView+WebCache.h in Headers */, - 407E5795C1ACD9040A3450893A96EBE5 /* UIView+WebCacheOperation.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - 3534881E151B75DB5D2040D8F663C85A /* Pods-SDCycleScrollView */ = { + A0C7189BE1171A7480D2D8405EA34120 /* SDWebImage */ = { isa = PBXNativeTarget; - buildConfigurationList = A01F9A7511AE64FF2DBA56854F79CACC /* Build configuration list for PBXNativeTarget "Pods-SDCycleScrollView" */; + buildConfigurationList = 3CF676033A51B2C14784B683C70617B9 /* Build configuration list for PBXNativeTarget "SDWebImage" */; buildPhases = ( - 5E627AF593858E7F8AB449CAEE0DC158 /* Sources */, - 0D9AD3D4B9069066E913291417EFF1D9 /* Frameworks */, + 57A70848059A3F71907212BF23F0A5D2 /* Headers */, + 3C5A22DB3F425899E54EABCA4CC22822 /* Sources */, + AE71903F14643C0DA4FE37E71EE70777 /* Frameworks */, ); buildRules = ( ); dependencies = ( - 2B17752EE84064E62CABB3EEEF0950EB /* PBXTargetDependency */, ); - name = "Pods-SDCycleScrollView"; - productName = "Pods-SDCycleScrollView"; - productReference = 26F12F84948751709EF2ECE2FCCA16D1 /* libPods-SDCycleScrollView.a */; + name = SDWebImage; + productName = SDWebImage; + productReference = 3AB34520BD883B06A167910A68BDB340 /* libSDWebImage.a */; productType = "com.apple.product-type.library.static"; }; - 6EB15CAFDEB6B266F3F2F4538542CE37 /* SDWebImage */ = { + D0D8439406877AB26FD19991C048A13C /* Pods-SDCycleScrollView */ = { isa = PBXNativeTarget; - buildConfigurationList = 21D358F74B18048B013A788C19A0C006 /* Build configuration list for PBXNativeTarget "SDWebImage" */; + buildConfigurationList = 27BE9C849AE638043EEC39807D1854EF /* Build configuration list for PBXNativeTarget "Pods-SDCycleScrollView" */; buildPhases = ( - B76493C608BC2B1E95A81C5D5AA74C2A /* Sources */, - 3E58F3D4D961D5FB9EDD17EA1539091E /* Frameworks */, - C9949CD275B61A994824D0C12BBA4212 /* Headers */, + 58CD89A7E8464654E2432BA919F0BDBC /* Headers */, + BE9EF1A6F864E132A12370B7995A2047 /* Sources */, + B85B13BC2B65A16F92C3DE9859A3FFE7 /* Frameworks */, ); buildRules = ( ); dependencies = ( + 6E456F1CDDD4ADF9B571B181DDF66C12 /* PBXTargetDependency */, ); - name = SDWebImage; - productName = SDWebImage; - productReference = 3AB34520BD883B06A167910A68BDB340 /* libSDWebImage.a */; + name = "Pods-SDCycleScrollView"; + productName = "Pods-SDCycleScrollView"; + productReference = 26F12F84948751709EF2ECE2FCCA16D1 /* libPods-SDCycleScrollView.a */; productType = "com.apple.product-type.library.static"; }; /* End PBXNativeTarget section */ @@ -335,8 +619,8 @@ D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0700; + LastSwiftUpdateCheck = 0930; + LastUpgradeCheck = 0930; }; buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; compatibilityVersion = "Xcode 3.2"; @@ -350,242 +634,322 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 3534881E151B75DB5D2040D8F663C85A /* Pods-SDCycleScrollView */, - 6EB15CAFDEB6B266F3F2F4538542CE37 /* SDWebImage */, + D0D8439406877AB26FD19991C048A13C /* Pods-SDCycleScrollView */, + A0C7189BE1171A7480D2D8405EA34120 /* SDWebImage */, ); }; /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ - 5E627AF593858E7F8AB449CAEE0DC158 /* Sources */ = { + 3C5A22DB3F425899E54EABCA4CC22822 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - CF179B9B47312BA380C3B9FF301640BB /* Pods-SDCycleScrollView-dummy.m in Sources */, + 2550B12A23C2C8B5FF2F0E5CBBC9F840 /* NSBezierPath+RoundedCorners.m in Sources */, + 785AB0D7DE13BE012AE6A69257A0A430 /* NSButton+WebCache.m in Sources */, + DBFA9FD040FF59AAAF6683A63C3BEF7E /* NSData+ImageContentType.m in Sources */, + 6301AB41AB7192280A29DC8681DF1755 /* NSImage+Compatibility.m in Sources */, + 94D309811F93732EE62507CE919E0A7A /* SDAnimatedImage.m in Sources */, + 90F6067598A5BEF6AA8EB9B3E36F288D /* SDAnimatedImageRep.m in Sources */, + 6D26BABBAB67DF7BE355D6D358A18994 /* SDAnimatedImageView+WebCache.m in Sources */, + E56C4859D765A9D52FE4D573BEAB9C83 /* SDAnimatedImageView.m in Sources */, + 6C077C1556E56CD1BF6D90864D87967C /* SDAsyncBlockOperation.m in Sources */, + A5F3938473C62A54E55E892B069BDA2C /* SDDiskCache.m in Sources */, + B51DD16A2C84759D53F7B5D7DBE06FC0 /* SDImageAPNGCoder.m in Sources */, + DDF906614D8A0B9D41A171BDE52212FF /* SDImageAssetManager.m in Sources */, + 6C5BE74F5F658DA3F40C6382DBCAD794 /* SDImageCache.m in Sources */, + C9958F80C527D2593E1DEEA903590E1B /* SDImageCacheConfig.m in Sources */, + 183A26CA35C022038861C37C7087CED0 /* SDImageCacheDefine.m in Sources */, + 8146D1581848A2AF9F9F67611D4BAF38 /* SDImageCachesManager.m in Sources */, + 715089F4E130FBCA6DB96B0C7E0AA8FD /* SDImageCachesManagerOperation.m in Sources */, + B72D72A40F0DEFF50115330CE9716D9B /* SDImageCoder.m in Sources */, + 5645B7BE3160BCAD3C33DD7C94E9E8BA /* SDImageCoderHelper.m in Sources */, + 6CFA1A2228794F143768674E646D599B /* SDImageCodersManager.m in Sources */, + F46F6157AF4821C80F9BCD8463CE001C /* SDImageFrame.m in Sources */, + C014CC3542B2C431CAE640E4B56CEC5E /* SDImageGIFCoder.m in Sources */, + E8E5C810ADB9A5AB0594FCB0412FCAFC /* SDImageGraphics.m in Sources */, + ACDE3D13AB2FA902ECB2A99031D2BBF9 /* SDImageIOCoder.m in Sources */, + 06023DFC2B0F4A395515B0DC5A62A6BF /* SDImageLoader.m in Sources */, + FC77681761F4E54D4DAB2E779D279D09 /* SDImageLoadersManager.m in Sources */, + 79B9263193B208C09C3C609B0E1BBF1D /* SDImageTransformer.m in Sources */, + 6662C46E4CF56C6119AD9DB580C6AC52 /* SDInternalMacros.m in Sources */, + EDBEB7AC95D35F2193C89FDEBE9C7CA6 /* SDMemoryCache.m in Sources */, + 06BE6E690AC714D69BC93AB514AF917F /* SDWeakProxy.m in Sources */, + 12760FCD14A16F134829A383166F8455 /* SDWebImage-dummy.m in Sources */, + DF29BDBBAD4D6C48453470E8AB03C910 /* SDWebImageCacheKeyFilter.m in Sources */, + FB194BBDDDFBF397023E2C16F2237720 /* SDWebImageCacheSerializer.m in Sources */, + E1399B6E7E468B68F51CB5C24FF9AB75 /* SDWebImageCompat.m in Sources */, + 008FCDE17FDC370C7F76FFF47CE1A80C /* SDWebImageDefine.m in Sources */, + D555A6BBADB213BF38EE94BEDB4F187A /* SDWebImageDownloader.m in Sources */, + 7E5F9D01401AF8DE4DC76DAAECA729CD /* SDWebImageDownloaderConfig.m in Sources */, + 9F53011B8A7AE4D4C5C8E5638AAE7F30 /* SDWebImageDownloaderOperation.m in Sources */, + 95501C627C8BDA06BFAFB53DB636ABD4 /* SDWebImageDownloaderRequestModifier.m in Sources */, + 2B6031E45FA11FE572D0E1667510B182 /* SDWebImageError.m in Sources */, + 4C761F6FB5A90D3796184C9CC2F8E28A /* SDWebImageIndicator.m in Sources */, + 5BBB8B88BDFA79854EA0D8B1FC65D405 /* SDWebImageManager.m in Sources */, + C973A839B25516A8A63291EE097EF86B /* SDWebImagePrefetcher.m in Sources */, + A391AE3617170F12A65FB1AE37530932 /* SDWebImageTransition.m in Sources */, + 3AFF5E078CC8E70773662AD7148A6410 /* UIButton+WebCache.m in Sources */, + 8F27B8A212B41DBC721597F6AD1A3BED /* UIColor+HexString.m in Sources */, + 1AA118F5B7A4557F0C1743E4C8C5F82F /* UIImage+ForceDecode.m in Sources */, + 6182BE7BBA533F1116E361147CF7028A /* UIImage+GIF.m in Sources */, + DE5417C8589D84C89CC0B483C4C35E02 /* UIImage+MemoryCacheCost.m in Sources */, + A7ACCA3D8FA2CDA2FBA0BA45208B9150 /* UIImage+Metadata.m in Sources */, + 8ABAF55C03179196A43CD274CDEC3F7E /* UIImage+MultiFormat.m in Sources */, + 35B2A0B3973BA1FB65FA4CB1E76F8191 /* UIImage+Transform.m in Sources */, + 18FC4EE1A082E669001BB26EF41FCFC2 /* UIImageView+HighlightedWebCache.m in Sources */, + 8DE5F4DEEAB43193DF3DB984A2D67B0A /* UIImageView+WebCache.m in Sources */, + 99B46762BA9F8A5586086DBA63F97C70 /* UIView+WebCache.m in Sources */, + D7FBB701B8C8B966F7BBA30E22FE94FD /* UIView+WebCacheOperation.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - B76493C608BC2B1E95A81C5D5AA74C2A /* Sources */ = { + BE9EF1A6F864E132A12370B7995A2047 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C0078FEBEA8C63FBF4FE00AA498F7B05 /* NSData+ImageContentType.m in Sources */, - 22D7C12314E74434F6263E75A1FCFBB7 /* NSImage+WebCache.m in Sources */, - 6D53759AD23FB006DB98C343FE0B0429 /* SDImageCache.m in Sources */, - 6AE7F72206A1986AA98E214EECC034C0 /* SDImageCacheConfig.m in Sources */, - 3E46237DDFF6F217CBB0013683817AB2 /* SDWebImage-dummy.m in Sources */, - 77E85137B222DE725AB120FFB67A372F /* SDWebImageCompat.m in Sources */, - 280AA9BF6725F27F7DEFC7227D8DAFD9 /* SDWebImageDecoder.m in Sources */, - 0563C15039B9DB0BFE599D858E2D7AD4 /* SDWebImageDownloader.m in Sources */, - 31B2BBEA7904DFACC385C6B7C0840462 /* SDWebImageDownloaderOperation.m in Sources */, - AB470D17E6092FB9EB75242755C68897 /* SDWebImageManager.m in Sources */, - 376177EBDCF60CB0FB51B86B96450C8B /* SDWebImagePrefetcher.m in Sources */, - B5519105E2DCABE661C1FAB79F0DDA69 /* UIButton+WebCache.m in Sources */, - 2CB68438863541C687D381644D48A316 /* UIImage+GIF.m in Sources */, - AA67E49DCA2B8EC1234B549D1CFA7161 /* UIImage+MultiFormat.m in Sources */, - 0609ADFEC935AA6939774C002465E1E8 /* UIImageView+HighlightedWebCache.m in Sources */, - A6231D3566857EF78863E9E6F7B5C2D9 /* UIImageView+WebCache.m in Sources */, - 3C880215CB75D9AD6B0E47B328009C33 /* UIView+WebCache.m in Sources */, - E6BBCB71FC3E3E2682CB33BAEC93A392 /* UIView+WebCacheOperation.m in Sources */, + 4AA3BDDFD2D461FDF26518F19388EA71 /* Pods-SDCycleScrollView-dummy.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 2B17752EE84064E62CABB3EEEF0950EB /* PBXTargetDependency */ = { + 6E456F1CDDD4ADF9B571B181DDF66C12 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = SDWebImage; - target = 6EB15CAFDEB6B266F3F2F4538542CE37 /* SDWebImage */; - targetProxy = AC6BDB0356350D16E1EC65B293F4C435 /* PBXContainerItemProxy */; + target = A0C7189BE1171A7480D2D8405EA34120 /* SDWebImage */; + targetProxy = 287F57F447A925E1D086390B7A2000A6 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ - 56770D81813E7C44DDA80EE19317D5A6 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 5437AD385EDE551AEDFF150954990560 /* SDWebImage.xcconfig */; - buildSettings = { - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_NO_COMMON_BLOCKS = YES; - GCC_PREFIX_HEADER = "Target Support Files/SDWebImage/SDWebImage-prefix.pch"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PRIVATE_HEADERS_FOLDER_PATH = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - PUBLIC_HEADERS_FOLDER_PATH = ""; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - }; - name = Release; - }; - 77DB2F0E06ED0864C9E7CA1ABF249E81 /* Debug */ = { + 18B37E771C0C1652C4868A8DBF6E60B3 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 2E4656658E6F974BDC0B2644E4C0DE6F /* Pods-SDCycleScrollView.debug.xcconfig */; + baseConfigurationReference = 51AE4E2A5687B066AD375FBBB6E54A73 /* Pods-SDCycleScrollView.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_NO_COMMON_BLOCKS = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACH_O_TYPE = staticlib; - MTL_ENABLE_DEBUG_INFO = YES; OTHER_LDFLAGS = ""; OTHER_LIBTOOLFLAGS = ""; PODS_ROOT = "$(SRCROOT)"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; }; - name = Debug; + name = Release; }; - 79B0C2E66EFA9917ED6EDDB8FC6A7684 /* Release */ = { + 85B95B1234E227C814CCC2C7902D0916 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_ALLOWED = NO; CODE_SIGNING_REQUIRED = NO; - COPY_PHASE_STRIP = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "POD_CONFIGURATION_RELEASE=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; - STRIP_INSTALLED_PRODUCT = NO; - SYMROOT = "${SRCROOT}/../build"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - B1EE390C3D3584FE878C5635FF65D499 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 51AE4E2A5687B066AD375FBBB6E54A73 /* Pods-SDCycleScrollView.release.xcconfig */; - buildSettings = { - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_NO_COMMON_BLOCKS = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MACH_O_TYPE = staticlib; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PODS_ROOT = "$(SRCROOT)"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + MTL_FAST_MATH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; + STRIP_INSTALLED_PRODUCT = NO; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_VERSION = 4.2; + SYMROOT = "${SRCROOT}/../build"; }; name = Release; }; - BFBE6EE6AEE2DCE7FD23DB8F552F1D50 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 5437AD385EDE551AEDFF150954990560 /* SDWebImage.xcconfig */; - buildSettings = { - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_NO_COMMON_BLOCKS = YES; - GCC_PREFIX_HEADER = "Target Support Files/SDWebImage/SDWebImage-prefix.pch"; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PRIVATE_HEADERS_FOLDER_PATH = ""; - PRODUCT_NAME = "$(TARGET_NAME)"; - PUBLIC_HEADERS_FOLDER_PATH = ""; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - CF7953F66E785E8876EB4D370D777D50 /* Debug */ = { + A73625DEBD810B78234FA1958C191C8C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_ALLOWED = NO; CODE_SIGNING_REQUIRED = NO; COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "POD_CONFIGURATION_DEBUG=1", "DEBUG=1", "$(inherited)", ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; - PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; + PRODUCT_NAME = "$(TARGET_NAME)"; STRIP_INSTALLED_PRODUCT = NO; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; SYMROOT = "${SRCROOT}/../build"; }; name = Debug; }; + A83143E426A4DF7E0392D3AFB3893A4B /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 84D45E81A5EFD0086A70019152256830 /* SDWebImage.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + GCC_PREFIX_HEADER = "Target Support Files/SDWebImage/SDWebImage-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_MODULE_NAME = SDWebImage; + PRODUCT_NAME = SDWebImage; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + ADDD04FA441FB6ECC416E39A6182010D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 2E4656658E6F974BDC0B2644E4C0DE6F /* Pods-SDCycleScrollView.debug.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MACH_O_TYPE = staticlib; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + E1E041380A26AC1C2C0942558A8B64F0 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 84D45E81A5EFD0086A70019152256830 /* SDWebImage.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + GCC_PREFIX_HEADER = "Target Support Files/SDWebImage/SDWebImage-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_MODULE_NAME = SDWebImage; + PRODUCT_NAME = SDWebImage; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 21D358F74B18048B013A788C19A0C006 /* Build configuration list for PBXNativeTarget "SDWebImage" */ = { + 27BE9C849AE638043EEC39807D1854EF /* Build configuration list for PBXNativeTarget "Pods-SDCycleScrollView" */ = { isa = XCConfigurationList; buildConfigurations = ( - BFBE6EE6AEE2DCE7FD23DB8F552F1D50 /* Debug */, - 56770D81813E7C44DDA80EE19317D5A6 /* Release */, + ADDD04FA441FB6ECC416E39A6182010D /* Debug */, + 18B37E771C0C1652C4868A8DBF6E60B3 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -593,17 +957,17 @@ 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { isa = XCConfigurationList; buildConfigurations = ( - CF7953F66E785E8876EB4D370D777D50 /* Debug */, - 79B0C2E66EFA9917ED6EDDB8FC6A7684 /* Release */, + A73625DEBD810B78234FA1958C191C8C /* Debug */, + 85B95B1234E227C814CCC2C7902D0916 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - A01F9A7511AE64FF2DBA56854F79CACC /* Build configuration list for PBXNativeTarget "Pods-SDCycleScrollView" */ = { + 3CF676033A51B2C14784B683C70617B9 /* Build configuration list for PBXNativeTarget "SDWebImage" */ = { isa = XCConfigurationList; buildConfigurations = ( - 77DB2F0E06ED0864C9E7CA1ABF249E81 /* Debug */, - B1EE390C3D3584FE878C5635FF65D499 /* Release */, + E1E041380A26AC1C2C0942558A8B64F0 /* Debug */, + A83143E426A4DF7E0392D3AFB3893A4B /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/Pods-SDCycleScrollView.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/Pods-SDCycleScrollView.xcscheme index dc4e5d8f..fb018cf7 100644 --- a/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/Pods-SDCycleScrollView.xcscheme +++ b/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/Pods-SDCycleScrollView.xcscheme @@ -1,6 +1,6 @@ + BuildableIdentifier = "primary" + BlueprintIdentifier = "D0D8439406877AB26FD19991C048A13C" + BlueprintName = "Pods-SDCycleScrollView" + ReferencedContainer = "container:Pods.xcodeproj" + BuildableName = "libPods-SDCycleScrollView.a"> diff --git a/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/SDWebImage.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/SDWebImage.xcscheme index 9999e225..e9865f29 100644 --- a/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/SDWebImage.xcscheme +++ b/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/SDWebImage.xcscheme @@ -1,6 +1,6 @@ + BuildableIdentifier = "primary" + BlueprintIdentifier = "A0C7189BE1171A7480D2D8405EA34120" + BlueprintName = "SDWebImage" + ReferencedContainer = "container:Pods.xcodeproj" + BuildableName = "libSDWebImage.a"> diff --git a/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/xcschememanagement.plist b/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/xcschememanagement.plist index af60ebcf..cfc33c37 100644 --- a/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Pods/Pods.xcodeproj/xcuserdata/gaoshaodong.xcuserdatad/xcschemes/xcschememanagement.plist @@ -16,17 +16,6 @@ SuppressBuildableAutocreation - - 3534881E151B75DB5D2040D8F663C85A - - primary - - - 6EB15CAFDEB6B266F3F2F4538542CE37 - - primary - - - + diff --git a/Pods/SDWebImage/LICENSE b/Pods/SDWebImage/LICENSE index 810cf88a..93321c73 100644 --- a/Pods/SDWebImage/LICENSE +++ b/Pods/SDWebImage/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com +Copyright (c) 2009-2018 Olivier Poitrey rs@dailymotion.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Pods/SDWebImage/README.md b/Pods/SDWebImage/README.md index e6214543..fc99e613 100644 --- a/Pods/SDWebImage/README.md +++ b/Pods/SDWebImage/README.md @@ -1,16 +1,14 @@

- +

-[![Build Status](http://img.shields.io/travis/rs/SDWebImage/master.svg?style=flat)](https://travis-ci.org/rs/SDWebImage) +[![Build Status](http://img.shields.io/travis/SDWebImage/SDWebImage/master.svg?style=flat)](https://travis-ci.org/SDWebImage/SDWebImage) [![Pod Version](http://img.shields.io/cocoapods/v/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/) [![Pod Platform](http://img.shields.io/cocoapods/p/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/) [![Pod License](http://img.shields.io/cocoapods/l/SDWebImage.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html) -[![Dependency Status](https://www.versioneye.com/objective-c/sdwebimage/badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage) -[![Reference Status](https://www.versioneye.com/objective-c/sdwebimage/reference_badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage/references) -[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/rs/SDWebImage) -[![codecov](https://codecov.io/gh/rs/SDWebImage/branch/master/graph/badge.svg)](https://codecov.io/gh/rs/SDWebImage) +[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/SDWebImage/SDWebImage) +[![codecov](https://codecov.io/gh/SDWebImage/SDWebImage/branch/master/graph/badge.svg)](https://codecov.io/gh/SDWebImage/SDWebImage) This library provides an async image downloader with cache support. For convenience, we added categories for UI elements like `UIImageView`, `UIButton`, `MKAnnotationView`. @@ -20,6 +18,11 @@ This library provides an async image downloader with cache support. For convenie - [x] An asynchronous image downloader - [x] An asynchronous memory + disk image caching with automatic cache expiration handling - [x] A background image decompression +- [x] Improved [support for animated images](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#animated-image-50) +- [x] [Customizable and composable transformations](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#transformer-50) can be applied to the images right after download +- [x] [Custom cache control](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#custom-cache-50) +- [x] Expand the image loading capabilites by adding your [own custom loaders](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#custom-loader-50) or using prebuilt loaders like [FLAnimatedImage plugin](https://github.com/SDWebImage/SDWebImageFLPlugin) or [Photos Library plugin](https://github.com/SDWebImage/SDWebImagePhotosPlugin) +- [x] [Loading indicators](https://github.com/SDWebImage/SDWebImage/wiki/How-to-use#use-view-indicator-50) - [x] A guarantee that the same URL won't be downloaded several times - [x] A guarantee that bogus URLs won't be retried again and again - [x] A guarantee that main thread will never be blocked @@ -29,33 +32,63 @@ This library provides an async image downloader with cache support. For convenie ## Supported Image Formats - Image formats supported by UIImage (JPEG, PNG, ...), including GIF -- WebP format, including animated WebP (use the `WebP` subspec) +- WebP format, including animated WebP (use the [SDWebImageWebPCoder](https://github.com/SDWebImage/SDWebImageWebPCoder) project) +- Support extendable coder plugins for new image formats. Like APNG, BPG, HFIF, SVG, etc. See all the list in [Image coder plugin List](https://github.com/SDWebImage/SDWebImage/wiki/Coder-Plugin-List) + +## Additional modules + +In order to keep SDWebImage focused and limited to the core features, but also allow extensibility and custom behaviors, during the 5.0 refactoring we focused on modularizing the library. +As such, we have moved/built new modules to [SDWebImage org](https://github.com/SDWebImage). + +#### Coders for additional image formats +- [SDWebImageWebPCoder](https://github.com/SDWebImage/SDWebImageWebPCoder) - coder for WebP image format. Based on [libwebp](https://chromium.googlesource.com/webm/libwebp) +- [SDWebImageHEIFCoder](https://github.com/SDWebImage/SDWebImageHEIFCoder) - coder to support HEIF image without Apple's `Image/IO framework`, iOS 8+/macOS 10.10+ support. +- [SDWebImageBPGCoder](https://github.com/SDWebImage/SDWebImageBPGCoder) - coder for BPG format +- [SDWebImageFLIFCoder](https://github.com/SDWebImage/SDWebImageFLIFCoder) - coder for FLIF format +- and more from community! + +#### Loaders +- [SDWebImagePhotosPlugin](https://github.com/SDWebImage/SDWebImagePhotosPlugin) - plugin to support loading images from Photos (using `Photos.framework`) + +#### Integration with 3rd party libraries +- [SDWebImageFLPlugin](https://github.com/SDWebImage/SDWebImageFLPlugin) - plugin to support [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) as the engine for animated GIFs +- [SDWebImageYYPlugin](https://github.com/SDWebImage/SDWebImageYYPlugin) - plugin to integrate [YYImage](https://github.com/ibireme/YYImage) & [YYCache](https://github.com/ibireme/YYCache) for image rendering & caching +- [SDWebImageProgressiveJPEGDemo](https://github.com/SDWebImage/SDWebImageProgressiveJPEGDemo) - demo project for using `SDWebImage` + [Concorde library](https://github.com/contentful-labs/Concorde) for Progressive JPEG decoding + +#### Make our lives easier +- [libwebp-Xcode](https://github.com/SDWebImage/libwebp-Xcode) - A wrapper for [libwebp](https://chromium.googlesource.com/webm/libwebp) + an Xcode project. + +You can use those directly, or create similar components of your own. ## Requirements -- iOS 7.0 or later +- iOS 8.0 or later - tvOS 9.0 or later - watchOS 2.0 or later -- OS X 10.8 or later -- Xcode 7.3 or later +- macOS 10.10 or later +- Xcode 9.0 or later #### Backwards compatibility -- For iOS 5 and 6, use [any 3.x version up to 3.7.6](https://github.com/rs/SDWebImage/tree/3.7.6) -- For iOS < 5.0, please use the last [2.0 version](https://github.com/rs/SDWebImage/tree/2.0-compat). +- For iOS 7, macOS 10.9 or Xcode < 8, use [any 4.x version up to 4.4.6](https://github.com/SDWebImage/SDWebImage/releases/tag/4.4.6) +- For macOS 10.8, use [any 4.x version up to 4.3.0](https://github.com/SDWebImage/SDWebImage/releases/tag/4.3.0) +- For iOS 5 and 6, use [any 3.x version up to 3.7.6](https://github.com/SDWebImage/SDWebImage/tag/3.7.6) +- For iOS < 5.0, please use the last [2.0 version](https://github.com/SDWebImage/SDWebImage/tree/2.0-compat). ## Getting Started - Read this Readme doc -- Read the [How to use section](https://github.com/rs/SDWebImage#how-to-use) -- Read the [documentation @ CocoaDocs](http://cocoadocs.org/docsets/SDWebImage/) -- Read [How is SDWebImage better than X?](https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F) +- Read the [How to use section](https://github.com/SDWebImage/SDWebImage#how-to-use) +- Read the [Documentation @ CocoaDocs](http://cocoadocs.org/docsets/SDWebImage/) - Try the example by downloading the project from Github or even easier using CocoaPods try `pod try SDWebImage` -- Get to the [installation steps](https://github.com/rs/SDWebImage#installation) -- Read the [SDWebImage 4.0 Migration Guide](Docs/SDWebImage-4.0-Migration-guide.md) to get an idea of the changes from 3.x to 4.x +- Read the [Installation Guide](https://github.com/SDWebImage/SDWebImage/wiki/Installation-Guide) +- Read the [SDWebImage 5.0 Migration Guide](https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/Docs/SDWebImage-5.0-Migration-guide.md) to get an idea of the changes from 4.x to 5.x +- Read the [SDWebImage 4.0 Migration Guide](https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/Docs/SDWebImage-4.0-Migration-guide.md) to get an idea of the changes from 3.x to 4.x +- Read the [Common Problems](https://github.com/SDWebImage/SDWebImage/wiki/Common-Problems) to find the solution for common problems +- Go to the [Wiki Page](https://github.com/SDWebImage/SDWebImage/wiki) for more information such as [Advanced Usage](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage) ## Who Uses It -- Find out [who uses SDWebImage](https://github.com/rs/SDWebImage/wiki/Who-Uses-SDWebImage) and add your app to the list. +- Find out [who uses SDWebImage](https://github.com/SDWebImage/SDWebImage/wiki/Who-Uses-SDWebImage) and add your app to the list. ## Communication @@ -63,78 +96,38 @@ This library provides an async image downloader with cache support. For convenie - If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/sdwebimage). - If you **found a bug**, open an issue. - If you **have a feature request**, open an issue. -- If you **want to contribute**, submit a pull request. - -## Installation +- If you **want to contribute**, read the [Contributing Guide](https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/.github/CONTRIBUTING.md) ## How To Use -```objective-c -Objective-C: +* Objective-C -#import +```objective-c +#import ... [imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; ``` -```swift -Swift: +* Swift -@import SDWebImage +```swift +import SDWebImage imageView.sd_setImage(with: URL(string: "http://www.domain.com/path/to/image.jpg"), placeholderImage: UIImage(named: "placeholder.png")) ``` -- For details about how to use the library and clear examples, see [The detailed How to use](Docs/HowToUse.md) +- For details about how to use the library and clear examples, see [The detailed How to use](https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/Docs/HowToUse.md) ## Animated Images (GIF) support -- Starting with the 4.0 version, we rely on [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) to take care of our animated images. -- To use it, simply make sure you use `FLAnimatedImageView` instead of `UIImageView`. -- **Note**: there is a backwards compatible feature, so if you are still trying to load a GIF into a `UIImageView`, it will only show the 1st frame as a static image. -- **Important**: FLAnimatedImage only works on the iOS platform, so for all the other platforms (OS X, tvOS, watchOS) we will fallback to the backwards compatibility feature described above +In 5.0, we introduced a brand new mechanism for supporting animated images. This includes animated image loading, rendering, decoding, and also supports customizations (for advanced users). +This animated image solution is available for `iOS`/`tvOS`/`macOS`. The `SDAnimatedImage` is subclass of `UIImage/NSImage`, and `SDAnimatedImageView` is subclass of `UIImageView/NSImageView`, to make them compatible with the common frameworks APIs. See [Animated Image](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#animated-image-50) for more detailed information. -Common Problems ---------------- +#### FLAnimatedImage integration has its own dedicated repo +In order to clean up things and make our core project do less things, we decided that the `FLAnimatedImage` integration does not belong here. From 5.0, this will still be available, but under a dedicated repo [SDWebImageFLPlugin](https://github.com/SDWebImage/SDWebImageFLPlugin). -### Using dynamic image size with UITableViewCell - -UITableView determines the size of the image by the first image set for a cell. If your remote images -don't have the same size as your placeholder image, you may experience strange anamorphic scaling issue. -The following article gives a way to workaround this issue: - -[http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/](http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/) - - -### Handle image refresh - -SDWebImage does very aggressive caching by default. It ignores all kind of caching control header returned by the HTTP server and cache the returned images with no time restriction. It implies your images URLs are static URLs pointing to images that never change. If the pointed image happen to change, some parts of the URL should change accordingly. - -If you don't control the image server you're using, you may not be able to change the URL when its content is updated. This is the case for Facebook avatar URLs for instance. In such case, you may use the `SDWebImageRefreshCached` flag. This will slightly degrade the performance but will respect the HTTP caching control headers: - -``` objective-c -[imageView sd_setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"] - placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"] - options:SDWebImageRefreshCached]; -``` - -### Add a progress indicator - -Add these before you call ```sd_setImageWithURL``` - -``` objective-c -[imageView setShowActivityIndicatorView:YES]; -[imageView setIndicatorStyle:UIActivityIndicatorViewStyleGray]; -``` - -``` swift -imageView.setShowActivityIndicatorView(true) -imageView.setIndicatorStyle(.Gray) -``` - -Installation ------------- +## Installation There are three ways to use SDWebImage in your project: - using CocoaPods @@ -148,22 +141,39 @@ There are three ways to use SDWebImage in your project: #### Podfile ``` platform :ios, '7.0' -pod 'SDWebImage', '~>3.8' +pod 'SDWebImage', '~> 4.0' +``` + +##### Swift and static framework + +Swift project previously have to use `use_frameworks!` to make all Pods into dynamic framework to let CocoaPods works. + +However, start with `CocoaPods 1.5.0+` (with `Xcode 9+`), which supports to build both Objective-C && Swift code into static framework. You can use modular headers to use SDWebImage as static framework, without the need of `use_frameworks!`: + ``` +platform :ios, '8.0' +# Uncomment the next line when you want all Pods as static framework +# use_modular_headers! +pod 'SDWebImage', :modular_headers => true +``` + +See more on [CocoaPods 1.5.0 — Swift Static Libraries](http://blog.cocoapods.org/CocoaPods-1.5.0/) + +If not, you still need to add `use_frameworks!` to use SDWebImage as dynamic framework: -If you are using Swift, be sure to add `use_frameworks!` and set your target to iOS 8+: ``` platform :ios, '8.0' use_frameworks! +pod 'SDWebImage' ``` #### Subspecs -There are 3 subspecs available now: `Core`, `MapKit` and `WebP` (this means you can install only some of the SDWebImage modules. By default, you get just `Core`, so if you need `WebP`, you need to specify it). +There are 2 subspecs available now: `Core` and `MapKit` (this means you can install only some of the SDWebImage modules. By default, you get just `Core`, so if you need `MapKit`, you need to specify it). Podfile example: ``` -pod 'SDWebImage/WebP' +pod 'SDWebImage/MapKit' ``` ### Installation with Carthage (iOS 8+) @@ -172,20 +182,23 @@ pod 'SDWebImage/WebP' To install with carthage, follow the instruction on [Carthage](https://github.com/Carthage/Carthage) -#### Cartfile -``` -github "rs/SDWebImage" -``` +Carthage users can point to this repository and use whichever generated framework they'd like: SDWebImage, SDWebImageMapKit or both. + +Make the following entry in your Cartfile: `github "SDWebImage/SDWebImage"` +Then run `carthage update` +If this is your first time using Carthage in the project, you'll need to go through some additional steps as explained [over at Carthage](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application). + +> NOTE: At this time, Carthage does not provide a way to build only specific repository subcomponents (or equivalent of CocoaPods's subspecs). All components and their dependencies will be built with the above command. However, you don't need to copy frameworks you aren't using into your project. For instance, if you aren't using `SDWebImageMapKit`, feel free to delete that framework from the Carthage Build directory after `carthage update` completes. ### Installation by cloning the repository -- see [Manual install](Docs/ManualInstallation.md) +- see [Manual install](https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/Docs/ManualInstallation.md) ### Import headers in your source files -In the source files where you need to use the library, import the header file: +In the source files where you need to use the library, import the umbrella header file: ```objective-c -#import +#import ``` ### Build Project @@ -199,17 +212,38 @@ community can help you solve it. ## Collaborators - [Konstantinos K.](https://github.com/mythodeia) - [Bogdan Poplauschi](https://github.com/bpoplauschi) +- [Chester Liu](https://github.com/skyline75489) +- [DreamPiggy](https://github.com/dreampiggy) +- [Wu Zhong](https://github.com/zhongwuzw) ## Licenses -All source code is licensed under the [MIT License](https://raw.github.com/rs/SDWebImage/master/LICENSE). +All source code is licensed under the [MIT License](https://raw.github.com/SDWebImage/SDWebImage/master/LICENSE). ## Architecture +#### High Level Diagram +

+ +

+ +#### Overall Class Diagram +

+ +

+ +#### Top Level API Diagram

- +

+#### Main Sequence Diagram

- +

+ +#### More detailed diagrams +- [Manager API Diagram](https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/Docs/Diagrams/SDWebImageManagerClassDiagram.png) +- [Coders API Diagram](https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/Docs/Diagrams/SDWebImageCodersClassDiagram.png) +- [Loader API Diagram](https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/Docs/Diagrams/SDWebImageLoaderClassDiagram.png) +- [Cache API Diagram](https://raw.githubusercontent.com/SDWebImage/SDWebImage/master/Docs/Diagrams/SDWebImageCacheClassDiagram.png) diff --git a/Pods/SDWebImage/SDWebImage/NSButton+WebCache.h b/Pods/SDWebImage/SDWebImage/NSButton+WebCache.h new file mode 100644 index 00000000..85aa3fc7 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/NSButton+WebCache.h @@ -0,0 +1,337 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +#if SD_MAC + +#import "SDWebImageManager.h" + +@interface NSButton (WebCache) + +#pragma mark - Image + +/** + * Get the current image URL. + */ +@property (nonatomic, strong, readonly, nullable) NSURL *sd_currentImageURL; + +/** + * Set the button `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT; + +/** + * Set the button `image` with an `url` and a placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @see sd_setImageWithURL:placeholderImage:options: + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT; + +/** + * Set the button `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT; + +/** + * Set the button `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context; + +/** + * Set the button `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the button `image` with an `url`, placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT; + +/** + * Set the button `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the button `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the button `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + * @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock; + +#pragma mark - Alternate Image + +/** + * Get the current alternateImage URL. + */ +@property (nonatomic, strong, readonly, nullable) NSURL *sd_currentAlternateImageURL; + +/** + * Set the button `alternateImage` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the alternateImage. + */ +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT; + +/** + * Set the button `alternateImage` with an `url` and a placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the alternateImage. + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. + * @see sd_setAlternateImageWithURL:placeholderImage:options: + */ +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT; + +/** + * Set the button `alternateImage` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the alternateImage. + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. + * @param options The options to use when downloading the alternateImage. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT; + +/** + * Set the button `alternateImage` with an `url`, placeholder, custom options and context. + * + * The download is asynchronous and cached. + * + * @param url The url for the alternateImage. + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. + * @param options The options to use when downloading the alternateImage. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + */ +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context; + +/** + * Set the button `alternateImage` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the alternateImage. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the alternateImage parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the alternateImage was retrieved from the local cache or from the network. + * The fourth parameter is the original alternateImage url. + */ +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the button `alternateImage` with an `url`, placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the alternateImage. + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the alternateImage parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the alternateImage was retrieved from the local cache or from the network. + * The fourth parameter is the original alternateImage url. + */ +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT; + +/** + * Set the button `alternateImage` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the alternateImage. + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. + * @param options The options to use when downloading the alternateImage. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the alternateImage parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the alternateImage was retrieved from the local cache or from the network. + * The fourth parameter is the original alternateImage url. + */ +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the button `alternateImage` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the alternateImage. + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. + * @param options The options to use when downloading the alternateImage. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while alternateImage is downloading + * @note the progress block is executed on a background queue + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the alternateImage parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the alternateImage was retrieved from the local cache or from the network. + * The fourth parameter is the original alternateImage url. + */ +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the button `alternateImage` with an `url`, placeholder, custom options and context. + * + * The download is asynchronous and cached. + * + * @param url The url for the alternateImage. + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. + * @param options The options to use when downloading the alternateImage. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + * @param progressBlock A block called while alternateImage is downloading + * @note the progress block is executed on a background queue + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the alternateImage parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the alternateImage was retrieved from the local cache or from the network. + * The fourth parameter is the original alternateImage url. + */ +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock; + +#pragma mark - Cancel + +/** + * Cancel the current image download + */ +- (void)sd_cancelCurrentImageLoad; + +/** + * Cancel the current alternateImage download + */ +- (void)sd_cancelCurrentAlternateImageLoad; + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/NSButton+WebCache.m b/Pods/SDWebImage/SDWebImage/NSButton+WebCache.m new file mode 100644 index 00000000..8800cea5 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/NSButton+WebCache.m @@ -0,0 +1,171 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "NSButton+WebCache.h" + +#if SD_MAC + +#import "objc/runtime.h" +#import "UIView+WebCacheOperation.h" +#import "UIView+WebCache.h" + +static NSString * const SDAlternateImageOperationKey = @"NSButtonAlternateImageOperation"; + +@implementation NSButton (WebCache) + +#pragma mark - Image + +- (void)sd_setImageWithURL:(nullable NSURL *)url { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:context progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock { + self.sd_currentImageURL = url; + [self sd_internalSetImageWithURL:url + placeholderImage:placeholder + options:options + context:context + setImageBlock:nil + progress:progressBlock + completed:^(NSImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType, imageURL); + } + }]; +} + +#pragma mark - Alternate Image + +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url { + [self sd_setAlternateImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; +} + +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder { + [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; +} + +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; +} + +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context { + [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:options context:context progress:nil completed:nil]; +} + +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setAlternateImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; +} + +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; +} + +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock { + self.sd_currentAlternateImageURL = url; + + SDWebImageMutableContext *mutableContext; + if (context) { + mutableContext = [context mutableCopy]; + } else { + mutableContext = [NSMutableDictionary dictionary]; + } + mutableContext[SDWebImageContextSetImageOperationKey] = SDAlternateImageOperationKey; + @weakify(self); + [self sd_internalSetImageWithURL:url + placeholderImage:placeholder + options:options + context:mutableContext + setImageBlock:^(NSImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { + @strongify(self); + self.alternateImage = image; + } + progress:progressBlock + completed:^(NSImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType, imageURL); + } + }]; +} + +#pragma mark - Cancel + +- (void)sd_cancelCurrentImageLoad { + [self sd_cancelImageLoadOperationWithKey:NSStringFromClass([self class])]; +} + +- (void)sd_cancelCurrentAlternateImageLoad { + [self sd_cancelImageLoadOperationWithKey:SDAlternateImageOperationKey]; +} + +#pragma mar - Private + +- (NSURL *)sd_currentImageURL { + return objc_getAssociatedObject(self, @selector(sd_currentImageURL)); +} + +- (void)setSd_currentImageURL:(NSURL *)sd_currentImageURL { + objc_setAssociatedObject(self, @selector(sd_currentImageURL), sd_currentImageURL, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (NSURL *)sd_currentAlternateImageURL { + return objc_getAssociatedObject(self, @selector(sd_currentAlternateImageURL)); +} + +- (void)setSd_currentAlternateImageURL:(NSURL *)sd_currentAlternateImageURL { + objc_setAssociatedObject(self, @selector(sd_currentAlternateImageURL), sd_currentAlternateImageURL, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h b/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h index b23b0bd4..8c48f671 100644 --- a/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h +++ b/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h @@ -10,14 +10,19 @@ #import #import "SDWebImageCompat.h" -typedef NS_ENUM(NSInteger, SDImageFormat) { - SDImageFormatUndefined = -1, - SDImageFormatJPEG = 0, - SDImageFormatPNG, - SDImageFormatGIF, - SDImageFormatTIFF, - SDImageFormatWebP -}; +/** + You can use switch case like normal enum. It's also recommended to add a default case. You should not assume anything about the raw value. + For custom coder plugin, it can also extern the enum for supported format. See `SDImageCoder` for more detailed information. + */ +typedef NSInteger SDImageFormat NS_TYPED_EXTENSIBLE_ENUM; +static const SDImageFormat SDImageFormatUndefined = -1; +static const SDImageFormat SDImageFormatJPEG = 0; +static const SDImageFormat SDImageFormatPNG = 1; +static const SDImageFormat SDImageFormatGIF = 2; +static const SDImageFormat SDImageFormatTIFF = 3; +static const SDImageFormat SDImageFormatWebP = 4; +static const SDImageFormat SDImageFormatHEIC = 5; +static const SDImageFormat SDImageFormatHEIF = 6; @interface NSData (ImageContentType) @@ -30,4 +35,20 @@ typedef NS_ENUM(NSInteger, SDImageFormat) { */ + (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data; +/** + * Convert SDImageFormat to UTType + * + * @param format Format as SDImageFormat + * @return The UTType as CFStringRef + */ ++ (nonnull CFStringRef)sd_UTTypeFromImageFormat:(SDImageFormat)format CF_RETURNS_NOT_RETAINED NS_SWIFT_NAME(sd_UTType(from:)); + +/** + * Convert UTTyppe to SDImageFormat + * + * @param uttype The UTType as CFStringRef + * @return The Format as SDImageFormat + */ ++ (SDImageFormat)sd_imageFormatFromUTType:(nonnull CFStringRef)uttype; + @end diff --git a/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m b/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m index 7364715f..192b539a 100644 --- a/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m +++ b/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m @@ -8,7 +8,17 @@ */ #import "NSData+ImageContentType.h" +#if SD_MAC +#import +#else +#import +#endif +// Currently Image/IO does not support WebP +#define kSDUTTypeWebP ((__bridge CFStringRef)@"public.webp") +// AVFileTypeHEIC/AVFileTypeHEIF is defined in AVFoundation via iOS 11, we use this without import AVFoundation +#define kSDUTTypeHEIC ((__bridge CFStringRef)@"public.heic") +#define kSDUTTypeHEIF ((__bridge CFStringRef)@"public.heif") @implementation NSData (ImageContentType) @@ -17,6 +27,7 @@ + (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data { return SDImageFormatUndefined; } + // File signatures table: http://www.garykessler.net/library/file_sigs.html uint8_t c; [data getBytes:&c length:1]; switch (c) { @@ -29,18 +40,92 @@ + (SDImageFormat)sd_imageFormatForImageData:(nullable NSData *)data { case 0x49: case 0x4D: return SDImageFormatTIFF; - case 0x52: - // R as RIFF for WEBP - if (data.length < 12) { - return SDImageFormatUndefined; + case 0x52: { + if (data.length >= 12) { + //RIFF....WEBP + NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; + if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { + return SDImageFormatWebP; + } } - - NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; - if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { - return SDImageFormatWebP; + break; + } + case 0x00: { + if (data.length >= 12) { + //....ftypheic ....ftypheix ....ftyphevc ....ftyphevx + NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(4, 8)] encoding:NSASCIIStringEncoding]; + if ([testString isEqualToString:@"ftypheic"] + || [testString isEqualToString:@"ftypheix"] + || [testString isEqualToString:@"ftyphevc"] + || [testString isEqualToString:@"ftyphevx"]) { + return SDImageFormatHEIC; + } + //....ftypmif1 ....ftypmsf1 + if ([testString isEqualToString:@"ftypmif1"] || [testString isEqualToString:@"ftypmsf1"]) { + return SDImageFormatHEIF; + } } + break; + } } return SDImageFormatUndefined; } ++ (nonnull CFStringRef)sd_UTTypeFromImageFormat:(SDImageFormat)format { + CFStringRef UTType; + switch (format) { + case SDImageFormatJPEG: + UTType = kUTTypeJPEG; + break; + case SDImageFormatPNG: + UTType = kUTTypePNG; + break; + case SDImageFormatGIF: + UTType = kUTTypeGIF; + break; + case SDImageFormatTIFF: + UTType = kUTTypeTIFF; + break; + case SDImageFormatWebP: + UTType = kSDUTTypeWebP; + break; + case SDImageFormatHEIC: + UTType = kSDUTTypeHEIC; + break; + case SDImageFormatHEIF: + UTType = kSDUTTypeHEIF; + break; + default: + // default is kUTTypePNG + UTType = kUTTypePNG; + break; + } + return UTType; +} + ++ (SDImageFormat)sd_imageFormatFromUTType:(CFStringRef)uttype { + if (!uttype) { + return SDImageFormatUndefined; + } + SDImageFormat imageFormat; + if (CFStringCompare(uttype, kUTTypeJPEG, 0) == kCFCompareEqualTo) { + imageFormat = SDImageFormatJPEG; + } else if (CFStringCompare(uttype, kUTTypePNG, 0) == kCFCompareEqualTo) { + imageFormat = SDImageFormatPNG; + } else if (CFStringCompare(uttype, kUTTypeGIF, 0) == kCFCompareEqualTo) { + imageFormat = SDImageFormatGIF; + } else if (CFStringCompare(uttype, kUTTypeTIFF, 0) == kCFCompareEqualTo) { + imageFormat = SDImageFormatTIFF; + } else if (CFStringCompare(uttype, kSDUTTypeWebP, 0) == kCFCompareEqualTo) { + imageFormat = SDImageFormatWebP; + } else if (CFStringCompare(uttype, kSDUTTypeHEIC, 0) == kCFCompareEqualTo) { + imageFormat = SDImageFormatHEIC; + } else if (CFStringCompare(uttype, kSDUTTypeHEIF, 0) == kCFCompareEqualTo) { + imageFormat = SDImageFormatHEIF; + } else { + imageFormat = SDImageFormatUndefined; + } + return imageFormat; +} + @end diff --git a/Pods/SDWebImage/SDWebImage/NSImage+Compatibility.h b/Pods/SDWebImage/SDWebImage/NSImage+Compatibility.h new file mode 100644 index 00000000..80020258 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/NSImage+Compatibility.h @@ -0,0 +1,52 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +// This category is provided to easily write cross-platform(AppKit/UIKit) code. For common usage, see `UIImage+Metadata.h`. + +#if SD_MAC + +@interface NSImage (Compatibility) + +/** +The underlying Core Graphics image object. This will actually use `CGImageForProposedRect` with the image size. + */ +@property (nonatomic, readonly, nullable) CGImageRef CGImage; +/** + The scale factor of the image. This wil actually use `bestRepresentationForRect` with image size and pixel size to calculate the scale factor. If failed, use the default value 1.0. Should be greater than or equal to 1.0. + */ +@property (nonatomic, readonly) CGFloat scale; + +// These are convenience methods to make AppKit's `NSImage` match UIKit's `UIImage` behavior. The scale factor should be greater than or equal to 1.0. + +/** + Returns an image object with the scale factor and orientation. The representation is created from the Core Graphics image object. + @note The difference between this and `initWithCGImage:size` is that `initWithCGImage:size` will actually create a `NSCGImageSnapshotRep` representation and always use `backingScaleFactor` as scale factor. So we should avoid it and use `NSBitmapImageRep` with `initWithCGImage:` instead. + @note The difference between this and UIKit's `UIImage` equivalent method is the way to process orientation. If the provided image orientation is not equal to Up orientation, this method will firstly rotate the CGImage to the correct orientation to work compatible with `NSImageView`. However, UIKit will not actually rotate CGImage and just store it as `imageOrientation` property. + + @param cgImage A Core Graphics image object + @param scale The image scale factor + @param orientation The orientation of the image data + @return The image object + */ +- (nonnull instancetype)initWithCGImage:(nonnull CGImageRef)cgImage scale:(CGFloat)scale orientation:(CGImagePropertyOrientation)orientation; + +/** + Returns an image object with the scale factor. The representation is created from the image data. + @note The difference between these this and `initWithData:` is that `initWithData:` will always use `backingScaleFactor` as scale factor. + + @param data The image data + @param scale The image scale factor + @return The image object + */ +- (nullable instancetype)initWithData:(nonnull NSData *)data scale:(CGFloat)scale; + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/NSImage+Compatibility.m b/Pods/SDWebImage/SDWebImage/NSImage+Compatibility.m new file mode 100644 index 00000000..b42a2e09 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/NSImage+Compatibility.m @@ -0,0 +1,89 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "NSImage+Compatibility.h" + +#if SD_MAC + +#import "SDImageCoderHelper.h" + +@implementation NSImage (Compatibility) + +- (CGImageRef)CGImage { + NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height); + CGImageRef cgImage = [self CGImageForProposedRect:&imageRect context:nil hints:nil]; + return cgImage; +} + +- (CGFloat)scale { + CGFloat scale = 1; + NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height); + NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil]; + CGFloat width = imageRep.size.width; + CGFloat height = imageRep.size.height; + NSUInteger pixelWidth = imageRep.pixelsWide; + NSUInteger pixelHeight = imageRep.pixelsHigh; + if (width > 0 && height > 0) { + CGFloat widthScale = pixelWidth / width; + CGFloat heightScale = pixelHeight / height; + if (widthScale == heightScale && widthScale >= 1) { + // Protect because there may be `NSImageRepMatchesDevice` (0) + scale = widthScale; + } + } + + return scale; +} + +- (instancetype)initWithCGImage:(CGImageRef)cgImage scale:(CGFloat)scale orientation:(CGImagePropertyOrientation)orientation { + NSBitmapImageRep *imageRep; + if (orientation != kCGImagePropertyOrientationUp) { + // AppKit design is different from UIKit. Where CGImage based image rep does not respect to any orientation. Only data based image rep which contains the EXIF metadata can automatically detect orientation. + // This should be nonnull, until the memory is exhausted cause `CGBitmapContextCreate` failed. + CGImageRef rotatedCGImage = [SDImageCoderHelper CGImageCreateDecoded:cgImage orientation:orientation]; + imageRep = [[NSBitmapImageRep alloc] initWithCGImage:rotatedCGImage]; + CGImageRelease(rotatedCGImage); + } else { + imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; + } + if (scale < 1) { + scale = 1; + } + CGFloat pixelWidth = imageRep.pixelsWide; + CGFloat pixelHeight = imageRep.pixelsHigh; + NSSize size = NSMakeSize(pixelWidth / scale, pixelHeight / scale); + self = [self initWithSize:size]; + if (self) { + imageRep.size = size; + [self addRepresentation:imageRep]; + } + return self; +} + +- (instancetype)initWithData:(NSData *)data scale:(CGFloat)scale { + NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithData:data]; + if (!imageRep) { + return nil; + } + if (scale < 1) { + scale = 1; + } + CGFloat pixelWidth = imageRep.pixelsWide; + CGFloat pixelHeight = imageRep.pixelsHigh; + NSSize size = NSMakeSize(pixelWidth / scale, pixelHeight / scale); + self = [self initWithSize:size]; + if (self) { + imageRep.size = size; + [self addRepresentation:imageRep]; + } + return self; +} + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/NSImage+WebCache.m b/Pods/SDWebImage/SDWebImage/NSImage+WebCache.m deleted file mode 100644 index 518b498c..00000000 --- a/Pods/SDWebImage/SDWebImage/NSImage+WebCache.m +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "NSImage+WebCache.h" - -#if SD_MAC - -@implementation NSImage (WebCache) - -- (CGImageRef)CGImage { - NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height); - CGImageRef cgImage = [self CGImageForProposedRect:&imageRect context:NULL hints:nil]; - return cgImage; -} - -- (NSArray *)images { - return nil; -} - -- (BOOL)isGIF { - return NO; -} - -@end - -#endif - diff --git a/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+RoundedCorners.h b/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+RoundedCorners.h new file mode 100644 index 00000000..224f2597 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+RoundedCorners.h @@ -0,0 +1,24 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +#if SD_MAC + +#import "UIImage+Transform.h" + +@interface NSBezierPath (RoundedCorners) + +/** + Convenience way to create a bezier path with the specify rounding corners on macOS. Same as the one on `UIBezierPath`. + */ ++ (nonnull instancetype)sd_bezierPathWithRoundedRect:(NSRect)rect byRoundingCorners:(SDRectCorner)corners cornerRadius:(CGFloat)cornerRadius; + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+RoundedCorners.m b/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+RoundedCorners.m new file mode 100644 index 00000000..d217bf14 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+RoundedCorners.m @@ -0,0 +1,42 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "NSBezierPath+RoundedCorners.h" + +#if SD_MAC + +@implementation NSBezierPath (RoundedCorners) + ++ (instancetype)sd_bezierPathWithRoundedRect:(NSRect)rect byRoundingCorners:(SDRectCorner)corners cornerRadius:(CGFloat)cornerRadius { + NSBezierPath *path = [NSBezierPath bezierPath]; + + CGFloat maxCorner = MIN(NSWidth(rect), NSHeight(rect)) / 2; + + CGFloat topLeftRadius = MIN(maxCorner, (corners & SDRectCornerTopLeft) ? cornerRadius : 0); + CGFloat topRightRadius = MIN(maxCorner, (corners & SDRectCornerTopRight) ? cornerRadius : 0); + CGFloat bottomLeftRadius = MIN(maxCorner, (corners & SDRectCornerBottomLeft) ? cornerRadius : 0); + CGFloat bottomRightRadius = MIN(maxCorner, (corners & SDRectCornerBottomRight) ? cornerRadius : 0); + + NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect)); + NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect)); + NSPoint bottomLeft = NSMakePoint(NSMinX(rect), NSMinY(rect)); + NSPoint bottomRight = NSMakePoint(NSMaxX(rect), NSMinY(rect)); + + [path moveToPoint:NSMakePoint(NSMidX(rect), NSMaxY(rect))]; + [path appendBezierPathWithArcFromPoint:topLeft toPoint:bottomLeft radius:topLeftRadius]; + [path appendBezierPathWithArcFromPoint:bottomLeft toPoint:bottomRight radius:bottomLeftRadius]; + [path appendBezierPathWithArcFromPoint:bottomRight toPoint:topRight radius:bottomRightRadius]; + [path appendBezierPathWithArcFromPoint:topRight toPoint:topLeft radius:topRightRadius]; + [path closePath]; + + return path; +} + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.h b/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.h new file mode 100644 index 00000000..ecc68be8 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.h @@ -0,0 +1,20 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +@class SDAsyncBlockOperation; +typedef void (^SDAsyncBlock)(SDAsyncBlockOperation * __nonnull asyncOperation); + +@interface SDAsyncBlockOperation : NSOperation + +- (nonnull instancetype)initWithBlock:(nonnull SDAsyncBlock)block; ++ (nonnull instancetype)blockOperationWithBlock:(nonnull SDAsyncBlock)block; +- (void)complete; + +@end diff --git a/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.m b/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.m new file mode 100644 index 00000000..8862ef8e --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.m @@ -0,0 +1,67 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDAsyncBlockOperation.h" + +@interface SDAsyncBlockOperation () + +@property (assign, nonatomic, getter = isExecuting) BOOL executing; +@property (assign, nonatomic, getter = isFinished) BOOL finished; +@property (nonatomic, copy, nonnull) SDAsyncBlock executionBlock; + +@end + +@implementation SDAsyncBlockOperation + +@synthesize executing = _executing; +@synthesize finished = _finished; + +- (nonnull instancetype)initWithBlock:(nonnull SDAsyncBlock)block { + self = [super init]; + if (self) { + self.executionBlock = block; + } + return self; +} + ++ (nonnull instancetype)blockOperationWithBlock:(nonnull SDAsyncBlock)block { + SDAsyncBlockOperation *operation = [[SDAsyncBlockOperation alloc] initWithBlock:block]; + return operation; +} + +- (void)start { + if (self.isCancelled) { + return; + } + + [self willChangeValueForKey:@"isExecuting"]; + self.executing = YES; + [self didChangeValueForKey:@"isExecuting"]; + + if (self.executionBlock) { + self.executionBlock(self); + } else { + [self complete]; + } +} + +- (void)cancel { + [super cancel]; + [self complete]; +} + +- (void)complete { + [self willChangeValueForKey:@"isExecuting"]; + [self willChangeValueForKey:@"isFinished"]; + self.executing = NO; + self.finished = YES; + [self didChangeValueForKey:@"isExecuting"]; + [self didChangeValueForKey:@"isFinished"]; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/Private/SDImageAPNGCoderInternal.h b/Pods/SDWebImage/SDWebImage/Private/SDImageAPNGCoderInternal.h new file mode 100644 index 00000000..93d53a6f --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDImageAPNGCoderInternal.h @@ -0,0 +1,17 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "SDImageAPNGCoder.h" + +@interface SDImageAPNGCoder () + +- (float)sd_frameDurationAtIndex:(NSUInteger)index source:(nonnull CGImageSourceRef)source; +- (NSUInteger)sd_imageLoopCountWithSource:(nonnull CGImageSourceRef)source; + +@end diff --git a/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.h b/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.h new file mode 100644 index 00000000..68184187 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.h @@ -0,0 +1,23 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +// Apple parse the Asset Catalog compiled file(`Assets.car`) by CoreUI.framework, however it's a private framework and there are no other ways to directly get the data. So we just process the normal bundle files :) + +@interface SDImageAssetManager : NSObject + +@property (nonatomic, strong, nonnull) NSMapTable *imageTable; + ++ (nonnull instancetype)sharedAssetManager; +- (nullable NSString *)getPathForName:(nonnull NSString *)name bundle:(nonnull NSBundle *)bundle preferredScale:(nonnull CGFloat *)scale; +- (nullable UIImage *)imageForName:(nonnull NSString *)name; +- (void)storeImage:(nonnull UIImage *)image forName:(nonnull NSString *)name; + +@end diff --git a/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.m b/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.m new file mode 100644 index 00000000..1dc5503c --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.m @@ -0,0 +1,157 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageAssetManager.h" + +static NSArray *SDBundlePreferredScales() { + static NSArray *scales; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ +#if SD_WATCH + CGFloat screenScale = [WKInterfaceDevice currentDevice].screenScale; +#elif SD_UIKIT + CGFloat screenScale = [UIScreen mainScreen].scale; +#elif SD_MAC + CGFloat screenScale = [NSScreen mainScreen].backingScaleFactor; +#endif + if (screenScale <= 1) { + scales = @[@1,@2,@3]; + } else if (screenScale <= 2) { + scales = @[@2,@3,@1]; + } else { + scales = @[@3,@2,@1]; + } + }); + return scales; +} + +@implementation SDImageAssetManager { + dispatch_semaphore_t _lock; +} + ++ (instancetype)sharedAssetManager { + static dispatch_once_t onceToken; + static SDImageAssetManager *assetManager; + dispatch_once(&onceToken, ^{ + assetManager = [[SDImageAssetManager alloc] init]; + }); + return assetManager; +} + +- (instancetype)init { + self = [super init]; + if (self) { + NSPointerFunctionsOptions valueOptions; +#if SD_MAC + // Apple says that NSImage use a weak reference to value + valueOptions = NSPointerFunctionsWeakMemory; +#else + // Apple says that UIImage use a strong reference to value + valueOptions = NSPointerFunctionsStrongMemory; +#endif + _imageTable = [NSMapTable mapTableWithKeyOptions:NSPointerFunctionsCopyIn valueOptions:valueOptions]; + _lock = dispatch_semaphore_create(1); +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif + } + return self; +} + +- (void)dealloc { +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif +} + +- (void)didReceiveMemoryWarning:(NSNotification *)notification { + SD_LOCK(_lock); + [self.imageTable removeAllObjects]; + SD_UNLOCK(_lock); +} + +- (NSString *)getPathForName:(NSString *)name bundle:(NSBundle *)bundle preferredScale:(CGFloat *)scale { + NSParameterAssert(name); + NSParameterAssert(bundle); + NSString *path; + if (name.length == 0) { + return path; + } + if ([name hasSuffix:@"/"]) { + return path; + } + NSString *extension = name.pathExtension; + if (extension.length == 0) { + // If no extension, follow Apple's doc, check PNG format + extension = @"png"; + } + name = [name stringByDeletingPathExtension]; + + CGFloat providedScale = *scale; + NSArray *scales = SDBundlePreferredScales(); + + // Check if file name contains scale + for (size_t i = 0; i < scales.count; i++) { + NSNumber *scaleValue = scales[i]; + if ([name hasSuffix:[NSString stringWithFormat:@"@%@x", scaleValue]]) { + path = [bundle pathForResource:name ofType:extension]; + if (path) { + *scale = scaleValue.doubleValue; // override + return path; + } + } + } + + // Search with provided scale first + if (providedScale != 0) { + NSString *scaledName = [name stringByAppendingFormat:@"@%@x", @(providedScale)]; + path = [bundle pathForResource:scaledName ofType:extension]; + if (path) { + return path; + } + } + + // Search with preferred scale + for (size_t i = 0; i < scales.count; i++) { + NSNumber *scaleValue = scales[i]; + if (scaleValue.doubleValue == providedScale) { + // Ignore provided scale + continue; + } + NSString *scaledName = [name stringByAppendingFormat:@"@%@x", scaleValue]; + path = [bundle pathForResource:scaledName ofType:extension]; + if (path) { + *scale = scaleValue.doubleValue; // override + return path; + } + } + + // Search without scale + path = [bundle pathForResource:name ofType:extension]; + + return path; +} + +- (UIImage *)imageForName:(NSString *)name { + NSParameterAssert(name); + UIImage *image; + SD_LOCK(_lock); + image = [self.imageTable objectForKey:name]; + SD_UNLOCK(_lock); + return image; +} + +- (void)storeImage:(UIImage *)image forName:(NSString *)name { + NSParameterAssert(image); + NSParameterAssert(name); + SD_LOCK(_lock); + [self.imageTable setObject:image forKey:name]; + SD_UNLOCK(_lock); +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h b/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h new file mode 100644 index 00000000..fddf78c1 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h @@ -0,0 +1,21 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +// This is used for operation management, but not for operation queue execute +@interface SDImageCachesManagerOperation : NSOperation + +@property (nonatomic, assign, readonly) NSUInteger pendingCount; + +- (void)beginWithTotalCount:(NSUInteger)totalCount; +- (void)completeOne; +- (void)done; + +@end diff --git a/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.m b/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.m new file mode 100644 index 00000000..131a18fe --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.m @@ -0,0 +1,83 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageCachesManagerOperation.h" + +@implementation SDImageCachesManagerOperation +{ + dispatch_semaphore_t _pendingCountLock; +} + +@synthesize executing = _executing; +@synthesize finished = _finished; +@synthesize cancelled = _cancelled; +@synthesize pendingCount = _pendingCount; + +- (instancetype)init { + if (self = [super init]) { + _pendingCountLock = dispatch_semaphore_create(1); + _pendingCount = 0; + } + return self; +} + +- (void)beginWithTotalCount:(NSUInteger)totalCount { + self.executing = YES; + self.finished = NO; + _pendingCount = totalCount; +} + +- (NSUInteger)pendingCount { + SD_LOCK(_pendingCountLock); + NSUInteger pendingCount = _pendingCount; + SD_UNLOCK(_pendingCountLock); + return pendingCount; +} + +- (void)completeOne { + SD_LOCK(_pendingCountLock); + _pendingCount = _pendingCount > 0 ? _pendingCount - 1 : 0; + SD_UNLOCK(_pendingCountLock); +} + +- (void)cancel { + self.cancelled = YES; + [self reset]; +} + +- (void)done { + self.finished = YES; + self.executing = NO; + [self reset]; +} + +- (void)reset { + SD_LOCK(_pendingCountLock); + _pendingCount = 0; + SD_UNLOCK(_pendingCountLock); +} + +- (void)setFinished:(BOOL)finished { + [self willChangeValueForKey:@"isFinished"]; + _finished = finished; + [self didChangeValueForKey:@"isFinished"]; +} + +- (void)setExecuting:(BOOL)executing { + [self willChangeValueForKey:@"isExecuting"]; + _executing = executing; + [self didChangeValueForKey:@"isExecuting"]; +} + +- (void)setCancelled:(BOOL)cancelled { + [self willChangeValueForKey:@"isCancelled"]; + _cancelled = cancelled; + [self didChangeValueForKey:@"isCancelled"]; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/NSImage+WebCache.h b/Pods/SDWebImage/SDWebImage/Private/SDImageGIFCoderInternal.h similarity index 64% rename from Pods/SDWebImage/SDWebImage/NSImage+WebCache.h rename to Pods/SDWebImage/SDWebImage/Private/SDImageGIFCoderInternal.h index 7515d407..769d206c 100644 --- a/Pods/SDWebImage/SDWebImage/NSImage+WebCache.h +++ b/Pods/SDWebImage/SDWebImage/Private/SDImageGIFCoderInternal.h @@ -7,17 +7,10 @@ */ #import "SDWebImageCompat.h" +#import "SDImageGIFCoder.h" -#if SD_MAC +@interface SDImageGIFCoder () -#import - -@interface NSImage (WebCache) - -- (CGImageRef)CGImage; -- (NSArray *)images; -- (BOOL)isGIF; +- (float)sd_frameDurationAtIndex:(NSUInteger)index source:(nonnull CGImageSourceRef)source; @end - -#endif diff --git a/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.h b/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.h new file mode 100644 index 00000000..edcb1ab0 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.h @@ -0,0 +1,61 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDmetamacros.h" + +#ifndef SD_LOCK +#define SD_LOCK(lock) dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER); +#endif + +#ifndef SD_UNLOCK +#define SD_UNLOCK(lock) dispatch_semaphore_signal(lock); +#endif + +#ifndef weakify +#define weakify(...) \ +sd_keywordify \ +metamacro_foreach_cxt(sd_weakify_,, __weak, __VA_ARGS__) +#endif + +#ifndef strongify +#define strongify(...) \ +sd_keywordify \ +_Pragma("clang diagnostic push") \ +_Pragma("clang diagnostic ignored \"-Wshadow\"") \ +metamacro_foreach(sd_strongify_,, __VA_ARGS__) \ +_Pragma("clang diagnostic pop") +#endif + +#define sd_weakify_(INDEX, CONTEXT, VAR) \ +CONTEXT __typeof__(VAR) metamacro_concat(VAR, _weak_) = (VAR); + +#define sd_strongify_(INDEX, VAR) \ +__strong __typeof__(VAR) VAR = metamacro_concat(VAR, _weak_); + +#if DEBUG +#define sd_keywordify autoreleasepool {} +#else +#define sd_keywordify try {} @catch (...) {} +#endif + +#ifndef onExit +#define onExit \ +sd_keywordify \ +__strong sd_cleanupBlock_t metamacro_concat(sd_exitBlock_, __LINE__) __attribute__((cleanup(sd_executeCleanupBlock), unused)) = ^ +#endif + +typedef void (^sd_cleanupBlock_t)(void); + +#if defined(__cplusplus) +extern "C" { +#endif + void sd_executeCleanupBlock (__strong sd_cleanupBlock_t *block); +#if defined(__cplusplus) +} +#endif diff --git a/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.m b/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.m new file mode 100644 index 00000000..e4981af2 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.m @@ -0,0 +1,13 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDInternalMacros.h" + +void sd_executeCleanupBlock (__strong sd_cleanupBlock_t *block) { + (*block)(); +} diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h b/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.h similarity index 56% rename from Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h rename to Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.h index 8f8df86b..4fd16228 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h +++ b/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.h @@ -1,7 +1,6 @@ /* * This file is part of the SDWebImage package. * (c) Olivier Poitrey - * (c) james * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -10,10 +9,11 @@ #import #import "SDWebImageCompat.h" -@interface UIImage (ForceDecode) +@interface SDWeakProxy : NSProxy -+ (nullable UIImage *)decodedImageWithImage:(nullable UIImage *)image; +@property (nonatomic, weak, readonly, nullable) id target; -+ (nullable UIImage *)decodedAndScaledDownImageWithImage:(nullable UIImage *)image; +- (nonnull instancetype)initWithTarget:(nonnull id)target; ++ (nonnull instancetype)proxyWithTarget:(nonnull id)target; @end diff --git a/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.m b/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.m new file mode 100644 index 00000000..19a45931 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.m @@ -0,0 +1,79 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWeakProxy.h" + +@implementation SDWeakProxy + +- (instancetype)initWithTarget:(id)target { + _target = target; + return self; +} + ++ (instancetype)proxyWithTarget:(id)target { + return [[SDWeakProxy alloc] initWithTarget:target]; +} + +- (id)forwardingTargetForSelector:(SEL)selector { + return _target; +} + +- (void)forwardInvocation:(NSInvocation *)invocation { + void *null = NULL; + [invocation setReturnValue:&null]; +} + +- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector { + return [NSObject instanceMethodSignatureForSelector:@selector(init)]; +} + +- (BOOL)respondsToSelector:(SEL)aSelector { + return [_target respondsToSelector:aSelector]; +} + +- (BOOL)isEqual:(id)object { + return [_target isEqual:object]; +} + +- (NSUInteger)hash { + return [_target hash]; +} + +- (Class)superclass { + return [_target superclass]; +} + +- (Class)class { + return [_target class]; +} + +- (BOOL)isKindOfClass:(Class)aClass { + return [_target isKindOfClass:aClass]; +} + +- (BOOL)isMemberOfClass:(Class)aClass { + return [_target isMemberOfClass:aClass]; +} + +- (BOOL)conformsToProtocol:(Protocol *)aProtocol { + return [_target conformsToProtocol:aProtocol]; +} + +- (BOOL)isProxy { + return YES; +} + +- (NSString *)description { + return [_target description]; +} + +- (NSString *)debugDescription { + return [_target debugDescription]; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/Private/SDmetamacros.h b/Pods/SDWebImage/SDWebImage/Private/SDmetamacros.h new file mode 100644 index 00000000..dd90d99b --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/SDmetamacros.h @@ -0,0 +1,667 @@ +/** + * Macros for metaprogramming + * ExtendedC + * + * Copyright (C) 2012 Justin Spahr-Summers + * Released under the MIT license + */ + +#ifndef EXTC_METAMACROS_H +#define EXTC_METAMACROS_H + + +/** + * Executes one or more expressions (which may have a void type, such as a call + * to a function that returns no value) and always returns true. + */ +#define metamacro_exprify(...) \ + ((__VA_ARGS__), true) + +/** + * Returns a string representation of VALUE after full macro expansion. + */ +#define metamacro_stringify(VALUE) \ + metamacro_stringify_(VALUE) + +/** + * Returns A and B concatenated after full macro expansion. + */ +#define metamacro_concat(A, B) \ + metamacro_concat_(A, B) + +/** + * Returns the Nth variadic argument (starting from zero). At least + * N + 1 variadic arguments must be given. N must be between zero and twenty, + * inclusive. + */ +#define metamacro_at(N, ...) \ + metamacro_concat(metamacro_at, N)(__VA_ARGS__) + +/** + * Returns the number of arguments (up to twenty) provided to the macro. At + * least one argument must be provided. + * + * Inspired by P99: http://p99.gforge.inria.fr + */ +#define metamacro_argcount(...) \ + metamacro_at(20, __VA_ARGS__, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1) + +/** + * Identical to #metamacro_foreach_cxt, except that no CONTEXT argument is + * given. Only the index and current argument will thus be passed to MACRO. + */ +#define metamacro_foreach(MACRO, SEP, ...) \ + metamacro_foreach_cxt(metamacro_foreach_iter, SEP, MACRO, __VA_ARGS__) + +/** + * For each consecutive variadic argument (up to twenty), MACRO is passed the + * zero-based index of the current argument, CONTEXT, and then the argument + * itself. The results of adjoining invocations of MACRO are then separated by + * SEP. + * + * Inspired by P99: http://p99.gforge.inria.fr + */ +#define metamacro_foreach_cxt(MACRO, SEP, CONTEXT, ...) \ + metamacro_concat(metamacro_foreach_cxt, metamacro_argcount(__VA_ARGS__))(MACRO, SEP, CONTEXT, __VA_ARGS__) + +/** + * Identical to #metamacro_foreach_cxt. This can be used when the former would + * fail due to recursive macro expansion. + */ +#define metamacro_foreach_cxt_recursive(MACRO, SEP, CONTEXT, ...) \ + metamacro_concat(metamacro_foreach_cxt_recursive, metamacro_argcount(__VA_ARGS__))(MACRO, SEP, CONTEXT, __VA_ARGS__) + +/** + * In consecutive order, appends each variadic argument (up to twenty) onto + * BASE. The resulting concatenations are then separated by SEP. + * + * This is primarily useful to manipulate a list of macro invocations into instead + * invoking a different, possibly related macro. + */ +#define metamacro_foreach_concat(BASE, SEP, ...) \ + metamacro_foreach_cxt(metamacro_foreach_concat_iter, SEP, BASE, __VA_ARGS__) + +/** + * Iterates COUNT times, each time invoking MACRO with the current index + * (starting at zero) and CONTEXT. The results of adjoining invocations of MACRO + * are then separated by SEP. + * + * COUNT must be an integer between zero and twenty, inclusive. + */ +#define metamacro_for_cxt(COUNT, MACRO, SEP, CONTEXT) \ + metamacro_concat(metamacro_for_cxt, COUNT)(MACRO, SEP, CONTEXT) + +/** + * Returns the first argument given. At least one argument must be provided. + * + * This is useful when implementing a variadic macro, where you may have only + * one variadic argument, but no way to retrieve it (for example, because \c ... + * always needs to match at least one argument). + * + * @code + +#define varmacro(...) \ + metamacro_head(__VA_ARGS__) + + * @endcode + */ +#define metamacro_head(...) \ + metamacro_head_(__VA_ARGS__, 0) + +/** + * Returns every argument except the first. At least two arguments must be + * provided. + */ +#define metamacro_tail(...) \ + metamacro_tail_(__VA_ARGS__) + +/** + * Returns the first N (up to twenty) variadic arguments as a new argument list. + * At least N variadic arguments must be provided. + */ +#define metamacro_take(N, ...) \ + metamacro_concat(metamacro_take, N)(__VA_ARGS__) + +/** + * Removes the first N (up to twenty) variadic arguments from the given argument + * list. At least N variadic arguments must be provided. + */ +#define metamacro_drop(N, ...) \ + metamacro_concat(metamacro_drop, N)(__VA_ARGS__) + +/** + * Decrements VAL, which must be a number between zero and twenty, inclusive. + * + * This is primarily useful when dealing with indexes and counts in + * metaprogramming. + */ +#define metamacro_dec(VAL) \ + metamacro_at(VAL, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19) + +/** + * Increments VAL, which must be a number between zero and twenty, inclusive. + * + * This is primarily useful when dealing with indexes and counts in + * metaprogramming. + */ +#define metamacro_inc(VAL) \ + metamacro_at(VAL, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21) + +/** + * If A is equal to B, the next argument list is expanded; otherwise, the + * argument list after that is expanded. A and B must be numbers between zero + * and twenty, inclusive. Additionally, B must be greater than or equal to A. + * + * @code + +// expands to true +metamacro_if_eq(0, 0)(true)(false) + +// expands to false +metamacro_if_eq(0, 1)(true)(false) + + * @endcode + * + * This is primarily useful when dealing with indexes and counts in + * metaprogramming. + */ +#define metamacro_if_eq(A, B) \ + metamacro_concat(metamacro_if_eq, A)(B) + +/** + * Identical to #metamacro_if_eq. This can be used when the former would fail + * due to recursive macro expansion. + */ +#define metamacro_if_eq_recursive(A, B) \ + metamacro_concat(metamacro_if_eq_recursive, A)(B) + +/** + * Returns 1 if N is an even number, or 0 otherwise. N must be between zero and + * twenty, inclusive. + * + * For the purposes of this test, zero is considered even. + */ +#define metamacro_is_even(N) \ + metamacro_at(N, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1) + +/** + * Returns the logical NOT of B, which must be the number zero or one. + */ +#define metamacro_not(B) \ + metamacro_at(B, 1, 0) + +// IMPLEMENTATION DETAILS FOLLOW! +// Do not write code that depends on anything below this line. +#define metamacro_stringify_(VALUE) # VALUE +#define metamacro_concat_(A, B) A ## B +#define metamacro_foreach_iter(INDEX, MACRO, ARG) MACRO(INDEX, ARG) +#define metamacro_head_(FIRST, ...) FIRST +#define metamacro_tail_(FIRST, ...) __VA_ARGS__ +#define metamacro_consume_(...) +#define metamacro_expand_(...) __VA_ARGS__ + +// implemented from scratch so that metamacro_concat() doesn't end up nesting +#define metamacro_foreach_concat_iter(INDEX, BASE, ARG) metamacro_foreach_concat_iter_(BASE, ARG) +#define metamacro_foreach_concat_iter_(BASE, ARG) BASE ## ARG + +// metamacro_at expansions +#define metamacro_at0(...) metamacro_head(__VA_ARGS__) +#define metamacro_at1(_0, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at2(_0, _1, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at3(_0, _1, _2, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at4(_0, _1, _2, _3, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at5(_0, _1, _2, _3, _4, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at6(_0, _1, _2, _3, _4, _5, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at7(_0, _1, _2, _3, _4, _5, _6, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at8(_0, _1, _2, _3, _4, _5, _6, _7, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at9(_0, _1, _2, _3, _4, _5, _6, _7, _8, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at10(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at11(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at12(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at13(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at14(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at15(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at16(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at17(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at18(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at19(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, ...) metamacro_head(__VA_ARGS__) +#define metamacro_at20(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, ...) metamacro_head(__VA_ARGS__) + +// metamacro_foreach_cxt expansions +#define metamacro_foreach_cxt0(MACRO, SEP, CONTEXT) +#define metamacro_foreach_cxt1(MACRO, SEP, CONTEXT, _0) MACRO(0, CONTEXT, _0) + +#define metamacro_foreach_cxt2(MACRO, SEP, CONTEXT, _0, _1) \ + metamacro_foreach_cxt1(MACRO, SEP, CONTEXT, _0) \ + SEP \ + MACRO(1, CONTEXT, _1) + +#define metamacro_foreach_cxt3(MACRO, SEP, CONTEXT, _0, _1, _2) \ + metamacro_foreach_cxt2(MACRO, SEP, CONTEXT, _0, _1) \ + SEP \ + MACRO(2, CONTEXT, _2) + +#define metamacro_foreach_cxt4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \ + metamacro_foreach_cxt3(MACRO, SEP, CONTEXT, _0, _1, _2) \ + SEP \ + MACRO(3, CONTEXT, _3) + +#define metamacro_foreach_cxt5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \ + metamacro_foreach_cxt4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \ + SEP \ + MACRO(4, CONTEXT, _4) + +#define metamacro_foreach_cxt6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \ + metamacro_foreach_cxt5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \ + SEP \ + MACRO(5, CONTEXT, _5) + +#define metamacro_foreach_cxt7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \ + metamacro_foreach_cxt6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \ + SEP \ + MACRO(6, CONTEXT, _6) + +#define metamacro_foreach_cxt8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \ + metamacro_foreach_cxt7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \ + SEP \ + MACRO(7, CONTEXT, _7) + +#define metamacro_foreach_cxt9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \ + metamacro_foreach_cxt8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \ + SEP \ + MACRO(8, CONTEXT, _8) + +#define metamacro_foreach_cxt10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \ + metamacro_foreach_cxt9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \ + SEP \ + MACRO(9, CONTEXT, _9) + +#define metamacro_foreach_cxt11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \ + metamacro_foreach_cxt10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \ + SEP \ + MACRO(10, CONTEXT, _10) + +#define metamacro_foreach_cxt12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \ + metamacro_foreach_cxt11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \ + SEP \ + MACRO(11, CONTEXT, _11) + +#define metamacro_foreach_cxt13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \ + metamacro_foreach_cxt12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \ + SEP \ + MACRO(12, CONTEXT, _12) + +#define metamacro_foreach_cxt14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \ + metamacro_foreach_cxt13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \ + SEP \ + MACRO(13, CONTEXT, _13) + +#define metamacro_foreach_cxt15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \ + metamacro_foreach_cxt14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \ + SEP \ + MACRO(14, CONTEXT, _14) + +#define metamacro_foreach_cxt16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \ + metamacro_foreach_cxt15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \ + SEP \ + MACRO(15, CONTEXT, _15) + +#define metamacro_foreach_cxt17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \ + metamacro_foreach_cxt16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \ + SEP \ + MACRO(16, CONTEXT, _16) + +#define metamacro_foreach_cxt18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \ + metamacro_foreach_cxt17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \ + SEP \ + MACRO(17, CONTEXT, _17) + +#define metamacro_foreach_cxt19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \ + metamacro_foreach_cxt18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \ + SEP \ + MACRO(18, CONTEXT, _18) + +#define metamacro_foreach_cxt20(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19) \ + metamacro_foreach_cxt19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \ + SEP \ + MACRO(19, CONTEXT, _19) + +// metamacro_foreach_cxt_recursive expansions +#define metamacro_foreach_cxt_recursive0(MACRO, SEP, CONTEXT) +#define metamacro_foreach_cxt_recursive1(MACRO, SEP, CONTEXT, _0) MACRO(0, CONTEXT, _0) + +#define metamacro_foreach_cxt_recursive2(MACRO, SEP, CONTEXT, _0, _1) \ + metamacro_foreach_cxt_recursive1(MACRO, SEP, CONTEXT, _0) \ + SEP \ + MACRO(1, CONTEXT, _1) + +#define metamacro_foreach_cxt_recursive3(MACRO, SEP, CONTEXT, _0, _1, _2) \ + metamacro_foreach_cxt_recursive2(MACRO, SEP, CONTEXT, _0, _1) \ + SEP \ + MACRO(2, CONTEXT, _2) + +#define metamacro_foreach_cxt_recursive4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \ + metamacro_foreach_cxt_recursive3(MACRO, SEP, CONTEXT, _0, _1, _2) \ + SEP \ + MACRO(3, CONTEXT, _3) + +#define metamacro_foreach_cxt_recursive5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \ + metamacro_foreach_cxt_recursive4(MACRO, SEP, CONTEXT, _0, _1, _2, _3) \ + SEP \ + MACRO(4, CONTEXT, _4) + +#define metamacro_foreach_cxt_recursive6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \ + metamacro_foreach_cxt_recursive5(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4) \ + SEP \ + MACRO(5, CONTEXT, _5) + +#define metamacro_foreach_cxt_recursive7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \ + metamacro_foreach_cxt_recursive6(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5) \ + SEP \ + MACRO(6, CONTEXT, _6) + +#define metamacro_foreach_cxt_recursive8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \ + metamacro_foreach_cxt_recursive7(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6) \ + SEP \ + MACRO(7, CONTEXT, _7) + +#define metamacro_foreach_cxt_recursive9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \ + metamacro_foreach_cxt_recursive8(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7) \ + SEP \ + MACRO(8, CONTEXT, _8) + +#define metamacro_foreach_cxt_recursive10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \ + metamacro_foreach_cxt_recursive9(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8) \ + SEP \ + MACRO(9, CONTEXT, _9) + +#define metamacro_foreach_cxt_recursive11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \ + metamacro_foreach_cxt_recursive10(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \ + SEP \ + MACRO(10, CONTEXT, _10) + +#define metamacro_foreach_cxt_recursive12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \ + metamacro_foreach_cxt_recursive11(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \ + SEP \ + MACRO(11, CONTEXT, _11) + +#define metamacro_foreach_cxt_recursive13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \ + metamacro_foreach_cxt_recursive12(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \ + SEP \ + MACRO(12, CONTEXT, _12) + +#define metamacro_foreach_cxt_recursive14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \ + metamacro_foreach_cxt_recursive13(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \ + SEP \ + MACRO(13, CONTEXT, _13) + +#define metamacro_foreach_cxt_recursive15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \ + metamacro_foreach_cxt_recursive14(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13) \ + SEP \ + MACRO(14, CONTEXT, _14) + +#define metamacro_foreach_cxt_recursive16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \ + metamacro_foreach_cxt_recursive15(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14) \ + SEP \ + MACRO(15, CONTEXT, _15) + +#define metamacro_foreach_cxt_recursive17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \ + metamacro_foreach_cxt_recursive16(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15) \ + SEP \ + MACRO(16, CONTEXT, _16) + +#define metamacro_foreach_cxt_recursive18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \ + metamacro_foreach_cxt_recursive17(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \ + SEP \ + MACRO(17, CONTEXT, _17) + +#define metamacro_foreach_cxt_recursive19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \ + metamacro_foreach_cxt_recursive18(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17) \ + SEP \ + MACRO(18, CONTEXT, _18) + +#define metamacro_foreach_cxt_recursive20(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19) \ + metamacro_foreach_cxt_recursive19(MACRO, SEP, CONTEXT, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18) \ + SEP \ + MACRO(19, CONTEXT, _19) + +// metamacro_for_cxt expansions +#define metamacro_for_cxt0(MACRO, SEP, CONTEXT) +#define metamacro_for_cxt1(MACRO, SEP, CONTEXT) MACRO(0, CONTEXT) + +#define metamacro_for_cxt2(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt1(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(1, CONTEXT) + +#define metamacro_for_cxt3(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt2(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(2, CONTEXT) + +#define metamacro_for_cxt4(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt3(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(3, CONTEXT) + +#define metamacro_for_cxt5(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt4(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(4, CONTEXT) + +#define metamacro_for_cxt6(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt5(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(5, CONTEXT) + +#define metamacro_for_cxt7(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt6(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(6, CONTEXT) + +#define metamacro_for_cxt8(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt7(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(7, CONTEXT) + +#define metamacro_for_cxt9(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt8(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(8, CONTEXT) + +#define metamacro_for_cxt10(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt9(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(9, CONTEXT) + +#define metamacro_for_cxt11(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt10(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(10, CONTEXT) + +#define metamacro_for_cxt12(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt11(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(11, CONTEXT) + +#define metamacro_for_cxt13(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt12(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(12, CONTEXT) + +#define metamacro_for_cxt14(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt13(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(13, CONTEXT) + +#define metamacro_for_cxt15(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt14(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(14, CONTEXT) + +#define metamacro_for_cxt16(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt15(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(15, CONTEXT) + +#define metamacro_for_cxt17(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt16(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(16, CONTEXT) + +#define metamacro_for_cxt18(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt17(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(17, CONTEXT) + +#define metamacro_for_cxt19(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt18(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(18, CONTEXT) + +#define metamacro_for_cxt20(MACRO, SEP, CONTEXT) \ + metamacro_for_cxt19(MACRO, SEP, CONTEXT) \ + SEP \ + MACRO(19, CONTEXT) + +// metamacro_if_eq expansions +#define metamacro_if_eq0(VALUE) \ + metamacro_concat(metamacro_if_eq0_, VALUE) + +#define metamacro_if_eq0_0(...) __VA_ARGS__ metamacro_consume_ +#define metamacro_if_eq0_1(...) metamacro_expand_ +#define metamacro_if_eq0_2(...) metamacro_expand_ +#define metamacro_if_eq0_3(...) metamacro_expand_ +#define metamacro_if_eq0_4(...) metamacro_expand_ +#define metamacro_if_eq0_5(...) metamacro_expand_ +#define metamacro_if_eq0_6(...) metamacro_expand_ +#define metamacro_if_eq0_7(...) metamacro_expand_ +#define metamacro_if_eq0_8(...) metamacro_expand_ +#define metamacro_if_eq0_9(...) metamacro_expand_ +#define metamacro_if_eq0_10(...) metamacro_expand_ +#define metamacro_if_eq0_11(...) metamacro_expand_ +#define metamacro_if_eq0_12(...) metamacro_expand_ +#define metamacro_if_eq0_13(...) metamacro_expand_ +#define metamacro_if_eq0_14(...) metamacro_expand_ +#define metamacro_if_eq0_15(...) metamacro_expand_ +#define metamacro_if_eq0_16(...) metamacro_expand_ +#define metamacro_if_eq0_17(...) metamacro_expand_ +#define metamacro_if_eq0_18(...) metamacro_expand_ +#define metamacro_if_eq0_19(...) metamacro_expand_ +#define metamacro_if_eq0_20(...) metamacro_expand_ + +#define metamacro_if_eq1(VALUE) metamacro_if_eq0(metamacro_dec(VALUE)) +#define metamacro_if_eq2(VALUE) metamacro_if_eq1(metamacro_dec(VALUE)) +#define metamacro_if_eq3(VALUE) metamacro_if_eq2(metamacro_dec(VALUE)) +#define metamacro_if_eq4(VALUE) metamacro_if_eq3(metamacro_dec(VALUE)) +#define metamacro_if_eq5(VALUE) metamacro_if_eq4(metamacro_dec(VALUE)) +#define metamacro_if_eq6(VALUE) metamacro_if_eq5(metamacro_dec(VALUE)) +#define metamacro_if_eq7(VALUE) metamacro_if_eq6(metamacro_dec(VALUE)) +#define metamacro_if_eq8(VALUE) metamacro_if_eq7(metamacro_dec(VALUE)) +#define metamacro_if_eq9(VALUE) metamacro_if_eq8(metamacro_dec(VALUE)) +#define metamacro_if_eq10(VALUE) metamacro_if_eq9(metamacro_dec(VALUE)) +#define metamacro_if_eq11(VALUE) metamacro_if_eq10(metamacro_dec(VALUE)) +#define metamacro_if_eq12(VALUE) metamacro_if_eq11(metamacro_dec(VALUE)) +#define metamacro_if_eq13(VALUE) metamacro_if_eq12(metamacro_dec(VALUE)) +#define metamacro_if_eq14(VALUE) metamacro_if_eq13(metamacro_dec(VALUE)) +#define metamacro_if_eq15(VALUE) metamacro_if_eq14(metamacro_dec(VALUE)) +#define metamacro_if_eq16(VALUE) metamacro_if_eq15(metamacro_dec(VALUE)) +#define metamacro_if_eq17(VALUE) metamacro_if_eq16(metamacro_dec(VALUE)) +#define metamacro_if_eq18(VALUE) metamacro_if_eq17(metamacro_dec(VALUE)) +#define metamacro_if_eq19(VALUE) metamacro_if_eq18(metamacro_dec(VALUE)) +#define metamacro_if_eq20(VALUE) metamacro_if_eq19(metamacro_dec(VALUE)) + +// metamacro_if_eq_recursive expansions +#define metamacro_if_eq_recursive0(VALUE) \ + metamacro_concat(metamacro_if_eq_recursive0_, VALUE) + +#define metamacro_if_eq_recursive0_0(...) __VA_ARGS__ metamacro_consume_ +#define metamacro_if_eq_recursive0_1(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_2(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_3(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_4(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_5(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_6(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_7(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_8(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_9(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_10(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_11(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_12(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_13(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_14(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_15(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_16(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_17(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_18(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_19(...) metamacro_expand_ +#define metamacro_if_eq_recursive0_20(...) metamacro_expand_ + +#define metamacro_if_eq_recursive1(VALUE) metamacro_if_eq_recursive0(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive2(VALUE) metamacro_if_eq_recursive1(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive3(VALUE) metamacro_if_eq_recursive2(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive4(VALUE) metamacro_if_eq_recursive3(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive5(VALUE) metamacro_if_eq_recursive4(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive6(VALUE) metamacro_if_eq_recursive5(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive7(VALUE) metamacro_if_eq_recursive6(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive8(VALUE) metamacro_if_eq_recursive7(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive9(VALUE) metamacro_if_eq_recursive8(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive10(VALUE) metamacro_if_eq_recursive9(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive11(VALUE) metamacro_if_eq_recursive10(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive12(VALUE) metamacro_if_eq_recursive11(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive13(VALUE) metamacro_if_eq_recursive12(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive14(VALUE) metamacro_if_eq_recursive13(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive15(VALUE) metamacro_if_eq_recursive14(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive16(VALUE) metamacro_if_eq_recursive15(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive17(VALUE) metamacro_if_eq_recursive16(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive18(VALUE) metamacro_if_eq_recursive17(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive19(VALUE) metamacro_if_eq_recursive18(metamacro_dec(VALUE)) +#define metamacro_if_eq_recursive20(VALUE) metamacro_if_eq_recursive19(metamacro_dec(VALUE)) + +// metamacro_take expansions +#define metamacro_take0(...) +#define metamacro_take1(...) metamacro_head(__VA_ARGS__) +#define metamacro_take2(...) metamacro_head(__VA_ARGS__), metamacro_take1(metamacro_tail(__VA_ARGS__)) +#define metamacro_take3(...) metamacro_head(__VA_ARGS__), metamacro_take2(metamacro_tail(__VA_ARGS__)) +#define metamacro_take4(...) metamacro_head(__VA_ARGS__), metamacro_take3(metamacro_tail(__VA_ARGS__)) +#define metamacro_take5(...) metamacro_head(__VA_ARGS__), metamacro_take4(metamacro_tail(__VA_ARGS__)) +#define metamacro_take6(...) metamacro_head(__VA_ARGS__), metamacro_take5(metamacro_tail(__VA_ARGS__)) +#define metamacro_take7(...) metamacro_head(__VA_ARGS__), metamacro_take6(metamacro_tail(__VA_ARGS__)) +#define metamacro_take8(...) metamacro_head(__VA_ARGS__), metamacro_take7(metamacro_tail(__VA_ARGS__)) +#define metamacro_take9(...) metamacro_head(__VA_ARGS__), metamacro_take8(metamacro_tail(__VA_ARGS__)) +#define metamacro_take10(...) metamacro_head(__VA_ARGS__), metamacro_take9(metamacro_tail(__VA_ARGS__)) +#define metamacro_take11(...) metamacro_head(__VA_ARGS__), metamacro_take10(metamacro_tail(__VA_ARGS__)) +#define metamacro_take12(...) metamacro_head(__VA_ARGS__), metamacro_take11(metamacro_tail(__VA_ARGS__)) +#define metamacro_take13(...) metamacro_head(__VA_ARGS__), metamacro_take12(metamacro_tail(__VA_ARGS__)) +#define metamacro_take14(...) metamacro_head(__VA_ARGS__), metamacro_take13(metamacro_tail(__VA_ARGS__)) +#define metamacro_take15(...) metamacro_head(__VA_ARGS__), metamacro_take14(metamacro_tail(__VA_ARGS__)) +#define metamacro_take16(...) metamacro_head(__VA_ARGS__), metamacro_take15(metamacro_tail(__VA_ARGS__)) +#define metamacro_take17(...) metamacro_head(__VA_ARGS__), metamacro_take16(metamacro_tail(__VA_ARGS__)) +#define metamacro_take18(...) metamacro_head(__VA_ARGS__), metamacro_take17(metamacro_tail(__VA_ARGS__)) +#define metamacro_take19(...) metamacro_head(__VA_ARGS__), metamacro_take18(metamacro_tail(__VA_ARGS__)) +#define metamacro_take20(...) metamacro_head(__VA_ARGS__), metamacro_take19(metamacro_tail(__VA_ARGS__)) + +// metamacro_drop expansions +#define metamacro_drop0(...) __VA_ARGS__ +#define metamacro_drop1(...) metamacro_tail(__VA_ARGS__) +#define metamacro_drop2(...) metamacro_drop1(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop3(...) metamacro_drop2(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop4(...) metamacro_drop3(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop5(...) metamacro_drop4(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop6(...) metamacro_drop5(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop7(...) metamacro_drop6(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop8(...) metamacro_drop7(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop9(...) metamacro_drop8(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop10(...) metamacro_drop9(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop11(...) metamacro_drop10(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop12(...) metamacro_drop11(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop13(...) metamacro_drop12(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop14(...) metamacro_drop13(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop15(...) metamacro_drop14(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop16(...) metamacro_drop15(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop17(...) metamacro_drop16(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop18(...) metamacro_drop17(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop19(...) metamacro_drop18(metamacro_tail(__VA_ARGS__)) +#define metamacro_drop20(...) metamacro_drop19(metamacro_tail(__VA_ARGS__)) + +#endif diff --git a/Pods/SDWebImage/SDWebImage/Private/UIColor+HexString.h b/Pods/SDWebImage/SDWebImage/Private/UIColor+HexString.h new file mode 100644 index 00000000..2a8a3d80 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/UIColor+HexString.h @@ -0,0 +1,18 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +@interface UIColor (HexString) + +/** + Convenience way to get hex string from color. The output should always be 32-bit RGBA hex string like `#00000000`. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *sd_hexString; + +@end diff --git a/Pods/SDWebImage/SDWebImage/Private/UIColor+HexString.m b/Pods/SDWebImage/SDWebImage/Private/UIColor+HexString.m new file mode 100644 index 00000000..aebb6e3b --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/Private/UIColor+HexString.m @@ -0,0 +1,42 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIColor+HexString.h" + +@implementation UIColor (HexString) + +- (NSString *)sd_hexString { + CGFloat red, green, blue, alpha; +#if SD_UIKIT + if (![self getRed:&red green:&green blue:&blue alpha:&alpha]) { + [self getWhite:&red alpha:&alpha]; + green = red; + blue = red; + } +#else + @try { + [self getRed:&red green:&green blue:&blue alpha:&alpha]; + } + @catch (NSException *exception) { + [self getWhite:&red alpha:&alpha]; + green = red; + blue = red; + } +#endif + + red = roundf(red * 255.f); + green = roundf(green * 255.f); + blue = roundf(blue * 255.f); + alpha = roundf(alpha * 255.f); + + uint hex = ((uint)alpha << 24) | ((uint)red << 16) | ((uint)green << 8) | ((uint)blue); + + return [NSString stringWithFormat:@"#%08x", hex]; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDAnimatedImage.h b/Pods/SDWebImage/SDWebImage/SDAnimatedImage.h new file mode 100644 index 00000000..2112685a --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDAnimatedImage.h @@ -0,0 +1,104 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "SDImageCoder.h" + + +/** + This is the protocol for SDAnimatedImage class only but not for SDAnimatedImageCoder. If you want to provide a custom animated image class with full advanced function, you can conform to this instead of the base protocol. + */ +@protocol SDAnimatedImage + +@required +/** + Initializes and returns the image object with the specified data, scale factor and possible animation decoding options. + @note We use this to create animated image instance for normal animation decoding. + + @param data The data object containing the image data. + @param scale The scale factor to assume when interpreting the image data. Applying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the `size` property. + @param options A dictionary containing any animation decoding options. + @return An initialized object + */ +- (nullable instancetype)initWithData:(nonnull NSData *)data scale:(CGFloat)scale options:(nullable SDImageCoderOptions *)options; + +/** + Initializes the image with an animated coder. You can use the coder to decode the image frame later. + @note We use this with animated coder which conforms to `SDProgressiveImageCoder` for progressive animation decoding. + + @param animatedCoder An animated coder which conform `SDAnimatedImageCoder` protocol + @param scale The scale factor to assume when interpreting the image data. Applying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the `size` property. + @return An initialized object + */ +- (nullable instancetype)initWithAnimatedCoder:(nonnull id)animatedCoder scale:(CGFloat)scale; + +@optional +// These methods are used for optional advanced feature, like image frame preloading. +/** + Pre-load all animated image frame into memory. Then later frame image request can directly return the frame for index without decoding. + This method may be called on background thread. + + @note If one image instance is shared by lots of imageViews, the CPU performance for large animated image will drop down because the request frame index will be random (not in order) and the decoder should take extra effort to keep it re-entrant. You can use this to reduce CPU usage if need. Attention this will consume more memory usage. + */ +- (void)preloadAllFrames; + +/** + Unload all animated image frame from memory if are already pre-loaded. Then later frame image request need decoding. You can use this to free up the memory usage if need. + */ +- (void)unloadAllFrames; + +/** + Returns a Boolean value indicating whether all animated image frames are already pre-loaded into memory. + */ +@property (nonatomic, assign, readonly, getter=isAllFramesLoaded) BOOL allFramesLoaded; + +@end + +@interface SDAnimatedImage : UIImage + +// 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. ++ (nullable instancetype)imageNamed:(nonnull NSString *)name; // Cache in memory, no Asset Catalog support +#if __has_include() ++ (nullable instancetype)imageNamed:(nonnull NSString *)name inBundle:(nullable NSBundle *)bundle compatibleWithTraitCollection:(nullable UITraitCollection *)traitCollection; // Cache in memory, no Asset Catalog support +#else ++ (nullable instancetype)imageNamed:(nonnull NSString *)name inBundle:(nullable NSBundle *)bundle; // Cache in memory, no Asset Catalog support +#endif ++ (nullable instancetype)imageWithContentsOfFile:(nonnull NSString *)path; ++ (nullable instancetype)imageWithData:(nonnull NSData *)data; ++ (nullable instancetype)imageWithData:(nonnull NSData *)data scale:(CGFloat)scale; +- (nullable instancetype)initWithContentsOfFile:(nonnull NSString *)path; +- (nullable instancetype)initWithData:(nonnull NSData *)data; +- (nullable instancetype)initWithData:(nonnull NSData *)data scale:(CGFloat)scale; + +/** + Current animated image format. + */ +@property (nonatomic, assign, readonly) SDImageFormat animatedImageFormat; + +/** + Current animated image data, you can use this instead of CGImage to create another instance. + If the current image is not animated image, this value is nil. + */ +@property (nonatomic, copy, readonly, nullable) NSData *animatedImageData; + +/** + The scale factor of the image. + + @note For UIKit, this just call super instead. + @note For AppKit, `NSImage` can contains multiple image representations with different scales. However, this class does not do that from the design. We processs the scale like UIKit. This wil actually be calculated from image size and pixel size. + */ +@property (nonatomic, readonly) CGFloat scale; + +// By default, animated image frames are returned by decoding just in time without keeping into memory. But you can choose to preload them into memory as well, See the decsription in `SDAnimatedImage` protocol. +// After preloaded, there is no huge difference on performance between this and UIImage's `animatedImageWithImages:duration:`. But UIImage's animation have some issues such like blanking and pausing during segue when using in `UIImageView`. It's recommend to use only if need. +- (void)preloadAllFrames; +- (void)unloadAllFrames; +@property (nonatomic, assign, readonly, getter=isAllFramesLoaded) BOOL allFramesLoaded; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDAnimatedImage.m b/Pods/SDWebImage/SDWebImage/SDAnimatedImage.m new file mode 100644 index 00000000..9fbd13e3 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDAnimatedImage.m @@ -0,0 +1,292 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDAnimatedImage.h" +#import "NSImage+Compatibility.h" +#import "SDImageCoder.h" +#import "SDImageCodersManager.h" +#import "SDImageFrame.h" +#import "UIImage+MemoryCacheCost.h" +#import "SDImageAssetManager.h" +#import "objc/runtime.h" + +static CGFloat SDImageScaleFromPath(NSString *string) { + if (string.length == 0 || [string hasSuffix:@"/"]) return 1; + NSString *name = string.stringByDeletingPathExtension; + __block CGFloat scale = 1; + + NSRegularExpression *pattern = [NSRegularExpression regularExpressionWithPattern:@"@[0-9]+\\.?[0-9]*x$" options:NSRegularExpressionAnchorsMatchLines error:nil]; + [pattern enumerateMatchesInString:name options:kNilOptions range:NSMakeRange(0, name.length) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) { + if (result.range.location >= 3) { + scale = [string substringWithRange:NSMakeRange(result.range.location + 1, result.range.length - 2)].doubleValue; + } + }]; + + return scale; +} + +@interface SDAnimatedImage () + +@property (nonatomic, strong) id coder; +@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; + +@end + +@implementation SDAnimatedImage +@dynamic scale; // call super + +#pragma mark - UIImage override method ++ (instancetype)imageNamed:(NSString *)name { +#if __has_include() + return [self imageNamed:name inBundle:nil compatibleWithTraitCollection:nil]; +#else + return [self imageNamed:name inBundle:nil]; +#endif +} + +#if __has_include() ++ (instancetype)imageNamed:(NSString *)name inBundle:(NSBundle *)bundle compatibleWithTraitCollection:(UITraitCollection *)traitCollection { + if (!traitCollection) { + traitCollection = UIScreen.mainScreen.traitCollection; + } + CGFloat scale = traitCollection.displayScale; + return [self imageNamed:name inBundle:bundle scale:scale]; +} +#else ++ (instancetype)imageNamed:(NSString *)name inBundle:(NSBundle *)bundle { + return [self imageNamed:name inBundle:bundle scale:0]; +} +#endif + +// 0 scale means automatically check ++ (instancetype)imageNamed:(NSString *)name inBundle:(NSBundle *)bundle scale:(CGFloat)scale { + if (!name) { + return nil; + } + if (!bundle) { + bundle = [NSBundle mainBundle]; + } + SDImageAssetManager *assetManager = [SDImageAssetManager sharedAssetManager]; + SDAnimatedImage *image = (SDAnimatedImage *)[assetManager imageForName:name]; + if ([image isKindOfClass:[SDAnimatedImage class]]) { + return image; + } + NSString *path = [assetManager getPathForName:name bundle:bundle preferredScale:&scale]; + if (!path) { + return image; + } + NSData *data = [NSData dataWithContentsOfFile:path]; + if (!data) { + return image; + } + image = [[self alloc] initWithData:data scale:scale]; + if (image) { + [assetManager storeImage:image forName:name]; + } + + return image; +} + ++ (instancetype)imageWithContentsOfFile:(NSString *)path { + return [[self alloc] initWithContentsOfFile:path]; +} + ++ (instancetype)imageWithData:(NSData *)data { + return [[self alloc] initWithData:data]; +} + ++ (instancetype)imageWithData:(NSData *)data scale:(CGFloat)scale { + return [[self alloc] initWithData:data scale:scale]; +} + +- (instancetype)initWithContentsOfFile:(NSString *)path { + NSData *data = [NSData dataWithContentsOfFile:path]; + return [self initWithData:data scale:SDImageScaleFromPath(path)]; +} + +- (instancetype)initWithData:(NSData *)data { + return [self initWithData:data scale:1]; +} + +- (instancetype)initWithData:(NSData *)data scale:(CGFloat)scale { + return [self initWithData:data scale:scale options:nil]; +} + +- (instancetype)initWithData:(NSData *)data scale:(CGFloat)scale options:(SDImageCoderOptions *)options { + if (!data || data.length == 0) { + return nil; + } + data = [data copy]; // avoid mutable data + id animatedCoder = nil; + for (idcoder in [SDImageCodersManager sharedManager].coders) { + if ([coder conformsToProtocol:@protocol(SDAnimatedImageCoder)]) { + if ([coder canDecodeFromData:data]) { + if (!options) { + options = @{SDImageCoderDecodeScaleFactor : @(scale)}; + } + animatedCoder = [[[coder class] alloc] initWithAnimatedImageData:data options:options]; + break; + } + } + } + if (!animatedCoder) { + return nil; + } + return [self initWithAnimatedCoder:animatedCoder scale:scale]; +} + +- (instancetype)initWithAnimatedCoder:(id)animatedCoder scale:(CGFloat)scale { + if (!animatedCoder) { + return nil; + } + if (scale <= 0) { + scale = 1; + } + UIImage *image = [animatedCoder animatedImageFrameAtIndex:0]; + if (!image) { + return nil; + } +#if SD_MAC + self = [super initWithCGImage:image.CGImage scale:scale orientation:kCGImagePropertyOrientationUp]; +#else + self = [super initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; +#endif + if (self) { + _coder = animatedCoder; + NSData *data = [animatedCoder animatedImageData]; + SDImageFormat format = [NSData sd_imageFormatForImageData:data]; + _animatedImageFormat = format; + } + return self; +} + +#pragma mark - Preload +- (void)preloadAllFrames { + if (!self.isAllFramesLoaded) { + NSMutableArray *frames = [NSMutableArray arrayWithCapacity:self.animatedImageFrameCount]; + for (size_t i = 0; i < self.animatedImageFrameCount; i++) { + UIImage *image = [self animatedImageFrameAtIndex:i]; + NSTimeInterval duration = [self animatedImageDurationAtIndex:i]; + SDImageFrame *frame = [SDImageFrame frameWithImage:image duration:duration]; // through the image should be nonnull, used as nullable for `animatedImageFrameAtIndex:` + [frames addObject:frame]; + } + self.loadedAnimatedImageFrames = frames; + self.allFramesLoaded = YES; + } +} + +- (void)unloadAllFrames { + if (self.isAllFramesLoaded) { + self.loadedAnimatedImageFrames = nil; + self.allFramesLoaded = NO; + } +} + +#pragma mark - NSSecureCoding +- (instancetype)initWithCoder:(NSCoder *)aDecoder { + self = [super initWithCoder:aDecoder]; + if (self) { + NSData *animatedImageData = [aDecoder decodeObjectOfClass:[NSData class] forKey:NSStringFromSelector(@selector(animatedImageData))]; + CGFloat scale = self.scale; + if (!animatedImageData) { + return self; + } + id animatedCoder = nil; + for (idcoder in [SDImageCodersManager sharedManager].coders) { + if ([coder conformsToProtocol:@protocol(SDAnimatedImageCoder)]) { + if ([coder canDecodeFromData:animatedImageData]) { + animatedCoder = [[[coder class] alloc] initWithAnimatedImageData:animatedImageData options:@{SDImageCoderDecodeScaleFactor : @(scale)}]; + break; + } + } + } + if (!animatedCoder) { + return self; + } + _coder = animatedCoder; + SDImageFormat format = [NSData sd_imageFormatForImageData:animatedImageData]; + _animatedImageFormat = format; + } + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder { + [super encodeWithCoder:aCoder]; + NSData *animatedImageData = self.animatedImageData; + if (animatedImageData) { + [aCoder encodeObject:animatedImageData forKey:NSStringFromSelector(@selector(animatedImageData))]; + } +} + ++ (BOOL)supportsSecureCoding { + return YES; +} + +#pragma mark - SDAnimatedImage + +- (NSData *)animatedImageData { + return [self.coder animatedImageData]; +} + +- (NSUInteger)animatedImageLoopCount { + return [self.coder animatedImageLoopCount]; +} + +- (NSUInteger)animatedImageFrameCount { + return [self.coder animatedImageFrameCount]; +} + +- (UIImage *)animatedImageFrameAtIndex:(NSUInteger)index { + if (index >= self.animatedImageFrameCount) { + return nil; + } + if (self.isAllFramesLoaded) { + SDImageFrame *frame = [self.loadedAnimatedImageFrames objectAtIndex:index]; + return frame.image; + } + return [self.coder animatedImageFrameAtIndex:index]; +} + +- (NSTimeInterval)animatedImageDurationAtIndex:(NSUInteger)index { + if (index >= self.animatedImageFrameCount) { + return 0; + } + if (self.isAllFramesLoaded) { + SDImageFrame *frame = [self.loadedAnimatedImageFrames objectAtIndex:index]; + return frame.duration; + } + return [self.coder animatedImageDurationAtIndex:index]; +} + +@end + +@implementation SDAnimatedImage (MemoryCacheCost) + +- (NSUInteger)sd_memoryCost { + NSNumber *value = objc_getAssociatedObject(self, @selector(sd_memoryCost)); + if (value != nil) { + return value.unsignedIntegerValue; + } + + CGImageRef imageRef = self.CGImage; + if (!imageRef) { + return 0; + } + NSUInteger bytesPerFrame = CGImageGetBytesPerRow(imageRef) * CGImageGetHeight(imageRef); + NSUInteger frameCount = 1; + if (self.isAllFramesLoaded) { + frameCount = self.animatedImageFrameCount; + } + frameCount = frameCount > 0 ? frameCount : 1; + NSUInteger cost = bytesPerFrame * frameCount; + return cost; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDAnimatedImageRep.h b/Pods/SDWebImage/SDWebImage/SDAnimatedImageRep.h new file mode 100644 index 00000000..929d82af --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDAnimatedImageRep.h @@ -0,0 +1,21 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +#if SD_MAC + +// A subclass of `NSBitmapImageRep` to fix that GIF loop count issue because `NSBitmapImageRep` will reset `NSImageCurrentFrameDuration` by using `kCGImagePropertyGIFDelayTime` but not `kCGImagePropertyGIFUnclampedDelayTime`. +// Built in GIF coder use this instead of `NSBitmapImageRep` for better GIF rendering. If you do not want this, only enable `SDImageIOCoder`, which just call `NSImage` API and actually use `NSBitmapImageRep` for GIF image. +// This also support APNG format using `SDImageAPNGCoder`. Which provide full alpha-channel support and the correct duration match the `kCGImagePropertyAPNGUnclampedDelayTime`. + +@interface SDAnimatedImageRep : NSBitmapImageRep + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDAnimatedImageRep.m b/Pods/SDWebImage/SDWebImage/SDAnimatedImageRep.m new file mode 100644 index 00000000..1e473b2b --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDAnimatedImageRep.m @@ -0,0 +1,104 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDAnimatedImageRep.h" + +#if SD_MAC + +#import "SDImageGIFCoderInternal.h" +#import "SDImageAPNGCoderInternal.h" + +@interface SDAnimatedImageRep () + +@property (nonatomic, assign, readonly, nullable) CGImageSourceRef imageSource; + +@end + +@implementation SDAnimatedImageRep + +// `NSBitmapImageRep`'s `imageRepWithData:` is not designed initlizer ++ (instancetype)imageRepWithData:(NSData *)data { + SDAnimatedImageRep *imageRep = [[SDAnimatedImageRep alloc] initWithData:data]; + return imageRep; +} + +// We should override init method for `NSBitmapImageRep` to do initlize about animated image format +- (instancetype)initWithData:(NSData *)data { + self = [super initWithData:data]; + if (self) { + CGImageSourceRef imageSource = self.imageSource; + if (!imageSource) { + return self; + } + NSUInteger frameCount = CGImageSourceGetCount(imageSource); + if (frameCount <= 1) { + return self; + } + CFStringRef type = CGImageSourceGetType(imageSource); + if (!type) { + return self; + } + if (CFStringCompare(type, kUTTypeGIF, 0) == kCFCompareEqualTo) { + // GIF + // Do nothing because NSBitmapImageRep support it + } else if (CFStringCompare(type, kUTTypePNG, 0) == kCFCompareEqualTo) { + // APNG + // Do initilize about frame count, current frame/duration and loop count + [self setProperty:NSImageFrameCount withValue:@(frameCount)]; + [self setProperty:NSImageCurrentFrame withValue:@(0)]; + NSUInteger loopCount = [[SDImageAPNGCoder sharedCoder] sd_imageLoopCountWithSource:imageSource]; + [self setProperty:NSImageLoopCount withValue:@(loopCount)]; + } + } + return self; +} + +// `NSBitmapImageRep` will use `kCGImagePropertyGIFDelayTime` whenever you call `setProperty:withValue:` with `NSImageCurrentFrame` to change the current frame. We override it and use the actual `kCGImagePropertyGIFUnclampedDelayTime` if need. +- (void)setProperty:(NSBitmapImageRepPropertyKey)property withValue:(id)value { + [super setProperty:property withValue:value]; + if ([property isEqualToString:NSImageCurrentFrame]) { + // Access the image source + CGImageSourceRef imageSource = self.imageSource; + if (!imageSource) { + return; + } + // Check format type + CFStringRef type = CGImageSourceGetType(imageSource); + if (!type) { + return; + } + NSUInteger index = [value unsignedIntegerValue]; + float frameDuration = 0; + if (CFStringCompare(type, kUTTypeGIF, 0) == kCFCompareEqualTo) { + // GIF + frameDuration = [[SDImageGIFCoder sharedCoder] sd_frameDurationAtIndex:index source:imageSource]; + } else if (CFStringCompare(type, kUTTypePNG, 0) == kCFCompareEqualTo) { + // APNG + frameDuration = [[SDImageAPNGCoder sharedCoder] sd_frameDurationAtIndex:index source:imageSource]; + } + if (!frameDuration) { + return; + } + // Reset super frame duration with the actual frame duration + [super setProperty:NSImageCurrentFrameDuration withValue:@(frameDuration)]; + } +} + +- (CGImageSourceRef)imageSource { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + if (_tiffData) { + return (__bridge CGImageSourceRef)(_tiffData); + } +#pragma GCC diagnostic pop + return NULL; +} + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDAnimatedImageView+WebCache.h b/Pods/SDWebImage/SDWebImage/SDAnimatedImageView+WebCache.h new file mode 100644 index 00000000..ef677564 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDAnimatedImageView+WebCache.h @@ -0,0 +1,165 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDAnimatedImageView.h" + +#if SD_UIKIT || SD_MAC + +#import "SDWebImageManager.h" + +@interface SDAnimatedImageView (WebCache) + +/** + * Set the imageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT; + +/** + * Set the imageView `image` with an `url` and a placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @see sd_setImageWithURL:placeholderImage:options: + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT; + +/** + * Set the imageView `image` with an `url`, placeholder, custom options and context. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context; + +/** + * Set the imageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder, custom options and context. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + * @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock; + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDAnimatedImageView+WebCache.m b/Pods/SDWebImage/SDWebImage/SDAnimatedImageView+WebCache.m new file mode 100644 index 00000000..beb56b2c --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDAnimatedImageView+WebCache.m @@ -0,0 +1,79 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDAnimatedImageView+WebCache.h" + +#if SD_UIKIT || SD_MAC + +#import "UIView+WebCache.h" +#import "SDAnimatedImage.h" + +@implementation SDAnimatedImageView (WebCache) + +- (void)sd_setImageWithURL:(nullable NSURL *)url { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:context progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock { + Class animatedImageClass = [SDAnimatedImage class]; + SDWebImageMutableContext *mutableContext; + if (context) { + mutableContext = [context mutableCopy]; + } else { + mutableContext = [NSMutableDictionary dictionary]; + } + mutableContext[SDWebImageContextAnimatedImageClass] = animatedImageClass; + [self sd_internalSetImageWithURL:url + placeholderImage:placeholder + options:options + context:mutableContext + setImageBlock:nil + progress:progressBlock + completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType, imageURL); + } + }]; +} + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDAnimatedImageView.h b/Pods/SDWebImage/SDWebImage/SDAnimatedImageView.h new file mode 100644 index 00000000..ec5bda13 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDAnimatedImageView.h @@ -0,0 +1,70 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +#if SD_UIKIT || SD_MAC + +#import "SDAnimatedImage.h" + +/** + A drop-in replacement for UIImageView/NSImageView, you can use this for animated image rendering. + Call `setImage:` with `UIImage(NSImage)` which conform to `SDAnimatedImage` protocol will start animated image rendering. Call with normal UIImage(NSImage) will back to normal UIImageView(NSImageView) rendering + For UIKit: use `-startAnimating`, `-stopAnimating` to control animating. `isAnimating` to check animation state. + For AppKit: use `-setAnimates:` to control animating, `animates` to check animation state. This view is layer-backed. + */ +@interface SDAnimatedImageView : UIImageView + +/** + Current display frame image. + */ +@property (nonatomic, strong, readonly, nullable) UIImage *currentFrame; +/** + Current frame index, zero based. This value is KVO Compliance. + */ +@property (nonatomic, assign, readonly) NSUInteger currentFrameIndex; +/** + Current loop count since its latest animating. This value is KVO Compliance. + */ +@property (nonatomic, assign, readonly) NSUInteger currentLoopCount; +/** + YES to choose `animationRepeatCount` property for animation loop count. No to use animated image's `animatedImageLoopCount` instead. + Default is NO. + */ +@property (nonatomic, assign) BOOL shouldCustomLoopCount; +/** + Total loop count for animated image rendering. Default is animated image's loop count. + If you need to set custom loop count, set `shouldCustomLoopCount` to YES and change this value. + This class override UIImageView's `animationRepeatCount` property on iOS, use this property as well. + */ +@property (nonatomic, assign) NSInteger animationRepeatCount; +/** + Provide a max buffer size by bytes. This is used to adjust frame buffer count and can be useful when the decoding cost is expensive (such as Animated WebP software decoding). Default is 0. + `0` means automatically adjust by calculating current memory usage. + `1` means without any buffer cache, each of frames will be decoded and then be freed after rendering. (Lowest Memory and Highest CPU) + `NSUIntegerMax` means cache all the buffer. (Lowest CPU and Highest Memory) + */ +@property (nonatomic, assign) NSUInteger maxBufferSize; +/** + Whehter or not to enable incremental image load for animated image. This is for the animated image which `sd_isIncremental` is YES (See `UIImage+Metadata.h`). If enable, animated image rendering will stop at the last frame available currently, and continue when another `setImage:` trigger, where the new animated image's `animatedImageData` should be updated from the previous one. If the `sd_isIncremental` is NO. The incremental image load stop. + @note If you are confused about this description, open Chrome browser to view some large GIF images with low network speed to see the animation behavior. + @note The best practice to use incremental load is using `initWithAnimatedCoder:scale:` in `SDAnimatedImage` with animated coder which conform to `SDProgressiveImageCoder` as well. Then call incremental update and incremental decode method to produce the image. + Default is YES. Set to NO to only render the static poster for incremental animated image. + */ +@property (nonatomic, assign) BOOL shouldIncrementalLoad; + +#if SD_UIKIT +/** + You can specify a runloop mode to let it rendering. + Default is NSRunLoopCommonModes on multi-core iOS device, NSDefaultRunLoopMode on single-core iOS device + */ +@property (nonatomic, copy, nonnull) NSRunLoopMode runLoopMode; +#endif +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDAnimatedImageView.m b/Pods/SDWebImage/SDWebImage/SDAnimatedImageView.m new file mode 100644 index 00000000..e898362b --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDAnimatedImageView.m @@ -0,0 +1,724 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDAnimatedImageView.h" + +#if SD_UIKIT || SD_MAC + +#import "UIImage+Metadata.h" +#import "NSImage+Compatibility.h" +#import "SDWeakProxy.h" +#import +#import + +#if SD_MAC +#import +static CVReturn renderCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *inNow, const CVTimeStamp *inOutputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext); +#endif + +static NSUInteger SDDeviceTotalMemory() { + return (NSUInteger)[[NSProcessInfo processInfo] physicalMemory]; +} + +static NSUInteger SDDeviceFreeMemory() { + mach_port_t host_port = mach_host_self(); + mach_msg_type_number_t host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); + vm_size_t page_size; + vm_statistics_data_t vm_stat; + kern_return_t kern; + + kern = host_page_size(host_port, &page_size); + if (kern != KERN_SUCCESS) return 0; + kern = host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size); + if (kern != KERN_SUCCESS) return 0; + return vm_stat.free_count * page_size; +} + +@interface SDAnimatedImageView () + +@property (nonatomic, strong, readwrite) UIImage *currentFrame; +@property (nonatomic, assign, readwrite) NSUInteger currentFrameIndex; +@property (nonatomic, assign, readwrite) NSUInteger currentLoopCount; +@property (nonatomic, assign) NSUInteger totalFrameCount; +@property (nonatomic, assign) NSUInteger totalLoopCount; +@property (nonatomic, strong) UIImage *animatedImage; +@property (nonatomic, strong) NSMutableDictionary *frameBuffer; +@property (nonatomic, assign) NSTimeInterval currentTime; +@property (nonatomic, assign) BOOL bufferMiss; +@property (nonatomic, assign) BOOL shouldAnimate; +@property (nonatomic, assign) BOOL isProgressive; +@property (nonatomic, assign) NSUInteger maxBufferCount; +@property (nonatomic, strong) NSOperationQueue *fetchQueue; +@property (nonatomic, strong) dispatch_semaphore_t lock; +@property (nonatomic, assign) CGFloat animatedImageScale; +#if SD_MAC +@property (nonatomic, assign) CVDisplayLinkRef displayLink; +#else +@property (nonatomic, strong) CADisplayLink *displayLink; +#endif + +@end + +@implementation SDAnimatedImageView +#if SD_UIKIT +@dynamic animationRepeatCount; // we re-use this property from `UIImageView` super class on iOS. +#endif + +#pragma mark - Initializers + +#if SD_MAC ++ (instancetype)imageViewWithImage:(NSImage *)image +{ + NSRect frame = NSMakeRect(0, 0, image.size.width, image.size.height); + SDAnimatedImageView *imageView = [[SDAnimatedImageView alloc] initWithFrame:frame]; + [imageView setImage:image]; + return imageView; +} +#else +// -initWithImage: isn't documented as a designated initializer of UIImageView, but it actually seems to be. +// Using -initWithImage: doesn't call any of the other designated initializers. +- (instancetype)initWithImage:(UIImage *)image +{ + self = [super initWithImage:image]; + if (self) { + [self commonInit]; + } + return self; +} + +// -initWithImage:highlightedImage: also isn't documented as a designated initializer of UIImageView, but it doesn't call any other designated initializers. +- (instancetype)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage +{ + self = [super initWithImage:image highlightedImage:highlightedImage]; + if (self) { + [self commonInit]; + } + return self; +} +#endif + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self commonInit]; + } + return self; +} + +- (instancetype)initWithCoder:(NSCoder *)aDecoder +{ + self = [super initWithCoder:aDecoder]; + if (self) { + [self commonInit]; + } + return self; +} + +- (void)commonInit +{ + self.shouldCustomLoopCount = NO; + self.shouldIncrementalLoad = YES; + self.lock = dispatch_semaphore_create(1); +#if SD_MAC + self.wantsLayer = YES; + // Default value from `NSImageView` + self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawOnSetNeedsDisplay; + self.imageScaling = NSImageScaleProportionallyDown; + self.imageAlignment = NSImageAlignCenter; +#endif +#if SD_UIKIT + self.runLoopMode = [[self class] defaultRunLoopMode]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif +} + +- (void)resetAnimatedImage +{ + self.animatedImage = nil; + self.totalFrameCount = 0; + self.totalLoopCount = 0; + self.currentFrame = nil; + self.currentFrameIndex = 0; + self.currentLoopCount = 0; + self.currentTime = 0; + self.bufferMiss = NO; + self.shouldAnimate = NO; + self.isProgressive = NO; + self.maxBufferCount = 0; + self.animatedImageScale = 1; + [_fetchQueue cancelAllOperations]; + _fetchQueue = nil; + SD_LOCK(self.lock); + [_frameBuffer removeAllObjects]; + _frameBuffer = nil; + SD_UNLOCK(self.lock); +} + +- (void)resetProgressiveImage +{ + self.animatedImage = nil; + self.totalFrameCount = 0; + self.totalLoopCount = 0; + // preserve current state + self.shouldAnimate = NO; + self.isProgressive = YES; + self.maxBufferCount = 0; + self.animatedImageScale = 1; + // preserve buffer cache +} + +#pragma mark - Accessors +#pragma mark Public + +- (void)setImage:(UIImage *)image +{ + if (self.image == image) { + return; + } + + // Check Progressive rendering + [self updateIsProgressiveWithImage:image]; + + if (self.isProgressive) { + // Reset all value, but keep current state + [self resetProgressiveImage]; + } else { + // Stop animating + [self stopAnimating]; + // Reset all value + [self resetAnimatedImage]; + } + + // We need call super method to keep function. This will impliedly call `setNeedsDisplay`. But we have no way to avoid this when using animated image. So we call `setNeedsDisplay` again at the end. + super.image = image; + if ([image conformsToProtocol:@protocol(SDAnimatedImage)]) { + NSUInteger animatedImageFrameCount = ((UIImage *)image).animatedImageFrameCount; + // Check the frame count + if (animatedImageFrameCount <= 1) { + return; + } + // If progressive rendering is disabled but animated image is incremental. Only show poster image + if (!self.isProgressive && image.sd_isIncremental) { + return; + } + self.animatedImage = (UIImage *)image; + self.totalFrameCount = animatedImageFrameCount; + // Get the current frame and loop count. + self.totalLoopCount = self.animatedImage.animatedImageLoopCount; + // Get the scale + self.animatedImageScale = image.scale; + if (!self.isProgressive) { + self.currentFrame = image; + SD_LOCK(self.lock); + self.frameBuffer[@(self.currentFrameIndex)] = self.currentFrame; + SD_UNLOCK(self.lock); + } + + // Ensure disabled highlighting; it's not supported (see `-setHighlighted:`). + super.highlighted = NO; + + // Calculate max buffer size + [self calculateMaxBufferCount]; + // Update should animate + [self updateShouldAnimate]; + if (self.shouldAnimate) { + [self startAnimating]; + } + + [self.layer setNeedsDisplay]; +#if SD_MAC + [self.layer displayIfNeeded]; // macOS's imageViewLayer may not equal to self.layer. But `[super setImage:]` will impliedly mark it needsDisplay. We call `[self.layer displayIfNeeded]` to immediately refresh the imageViewLayer to avoid flashing +#endif + } +} + +#if SD_UIKIT +- (void)setRunLoopMode:(NSString *)runLoopMode +{ + if (![@[NSDefaultRunLoopMode, NSRunLoopCommonModes] containsObject:runLoopMode]) { + NSAssert(NO, @"Invalid run loop mode: %@", runLoopMode); + _runLoopMode = [[self class] defaultRunLoopMode]; + } else { + _runLoopMode = runLoopMode; + } +} +#endif + +#pragma mark - Private +- (NSOperationQueue *)fetchQueue +{ + if (!_fetchQueue) { + _fetchQueue = [[NSOperationQueue alloc] init]; + _fetchQueue.maxConcurrentOperationCount = 1; + } + return _fetchQueue; +} + +- (NSMutableDictionary *)frameBuffer +{ + if (!_frameBuffer) { + _frameBuffer = [NSMutableDictionary dictionary]; + } + return _frameBuffer; +} + +#if SD_MAC +- (CVDisplayLinkRef)displayLink +{ + if (!_displayLink) { + CVReturn error = CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink); + if (error) { + return NULL; + } + CVDisplayLinkSetOutputCallback(_displayLink, renderCallback, (__bridge void *)self); + } + return _displayLink; +} +#else +- (CADisplayLink *)displayLink +{ + if (!_displayLink) { + // It is important to note the use of a weak proxy here to avoid a retain cycle. `-displayLinkWithTarget:selector:` + // will retain its target until it is invalidated. We use a weak proxy so that the image view will get deallocated + // independent of the display link's lifetime. Upon image view deallocation, we invalidate the display + // link which will lead to the deallocation of both the display link and the weak proxy. + SDWeakProxy *weakProxy = [SDWeakProxy proxyWithTarget:self]; + _displayLink = [CADisplayLink displayLinkWithTarget:weakProxy selector:@selector(displayDidRefresh:)]; + [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:self.runLoopMode]; + } + return _displayLink; +} +#endif + +#pragma mark - Life Cycle + +- (void)dealloc +{ + // Removes the display link from all run loop modes. +#if SD_MAC + if (_displayLink) { + CVDisplayLinkRelease(_displayLink); + _displayLink = NULL; + } +#else + [_displayLink invalidate]; + _displayLink = nil; + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif +} + +- (void)didReceiveMemoryWarning:(NSNotification *)notification { + [_fetchQueue cancelAllOperations]; + [_fetchQueue addOperationWithBlock:^{ + NSNumber *currentFrameIndex = @(self.currentFrameIndex); + SD_LOCK(self.lock); + NSArray *keys = self.frameBuffer.allKeys; + // only keep the next frame for later rendering + for (NSNumber * key in keys) { + if (![key isEqualToNumber:currentFrameIndex]) { + [self.frameBuffer removeObjectForKey:key]; + } + } + SD_UNLOCK(self.lock); + }]; +} + +#pragma mark - UIView Method Overrides +#pragma mark Observing View-Related Changes + +#if SD_MAC +- (void)viewDidMoveToSuperview +#else +- (void)didMoveToSuperview +#endif +{ +#if SD_MAC + [super viewDidMoveToSuperview]; +#else + [super didMoveToSuperview]; +#endif + + [self updateShouldAnimate]; + if (self.shouldAnimate) { + [self startAnimating]; + } else { + [self stopAnimating]; + } +} + +#if SD_MAC +- (void)viewDidMoveToWindow +#else +- (void)didMoveToWindow +#endif +{ +#if SD_MAC + [super viewDidMoveToWindow]; +#else + [super didMoveToWindow]; +#endif + + [self updateShouldAnimate]; + if (self.shouldAnimate) { + [self startAnimating]; + } else { + [self stopAnimating]; + } +} + +#if SD_MAC +- (void)setAlphaValue:(CGFloat)alphaValue +#else +- (void)setAlpha:(CGFloat)alpha +#endif +{ +#if SD_MAC + [super setAlphaValue:alphaValue]; +#else + [super setAlpha:alpha]; +#endif + + [self updateShouldAnimate]; + if (self.shouldAnimate) { + [self startAnimating]; + } else { + [self stopAnimating]; + } +} + +- (void)setHidden:(BOOL)hidden +{ + [super setHidden:hidden]; + + [self updateShouldAnimate]; + if (self.shouldAnimate) { + [self startAnimating]; + } else { + [self stopAnimating]; + } +} + +#pragma mark - UIImageView Method Overrides +#pragma mark Image Data + +- (void)startAnimating +{ + if (self.animatedImage) { +#if SD_MAC + CVDisplayLinkStart(self.displayLink); +#else + self.displayLink.paused = NO; +#endif + } else { +#if SD_UIKIT + [super startAnimating]; +#endif + } +} + +- (void)stopAnimating +{ + if (self.animatedImage) { +#if SD_MAC + CVDisplayLinkStop(_displayLink); +#else + _displayLink.paused = YES; +#endif + } else { +#if SD_UIKIT + [super stopAnimating]; +#endif + } +} + +- (BOOL)isAnimating +{ + BOOL isAnimating = NO; + if (self.animatedImage) { +#if SD_MAC + isAnimating = CVDisplayLinkIsRunning(self.displayLink); +#else + isAnimating = !self.displayLink.isPaused; +#endif + } else { +#if SD_UIKIT + isAnimating = [super isAnimating]; +#endif + } + return isAnimating; +} + +#if SD_MAC +- (void)setAnimates:(BOOL)animates +{ + [super setAnimates:animates]; + if (animates) { + [self startAnimating]; + } else { + [self stopAnimating]; + } +} +#endif + +#pragma mark Highlighted Image Unsupport + +- (void)setHighlighted:(BOOL)highlighted +{ + // Highlighted image is unsupported for animated images, but implementing it breaks the image view when embedded in a UICollectionViewCell. + if (!self.animatedImage) { + [super setHighlighted:highlighted]; + } +} + + +#pragma mark - Private Methods +#pragma mark Animation + +// Don't repeatedly check our window & superview in `-displayDidRefresh:` for performance reasons. +// Just update our cached value whenever the animated image or visibility (window, superview, hidden, alpha) is changed. +- (void)updateShouldAnimate +{ +#if SD_MAC + BOOL isVisible = self.window && self.superview && ![self isHidden] && self.alphaValue > 0.0 && self.animates; +#else + BOOL isVisible = self.window && self.superview && ![self isHidden] && self.alpha > 0.0; +#endif + self.shouldAnimate = self.animatedImage && self.totalFrameCount > 1 && isVisible; +} + +// Update progressive status only after `setImage:` call. +- (void)updateIsProgressiveWithImage:(UIImage *)image +{ + self.isProgressive = NO; + if (!self.shouldIncrementalLoad) { + // Early return + return; + } + if ([image conformsToProtocol:@protocol(SDAnimatedImage)] && image.sd_isIncremental) { + UIImage *previousImage = self.image; + if ([previousImage conformsToProtocol:@protocol(SDAnimatedImage)] && previousImage.sd_isIncremental) { + NSData *previousData = [((UIImage *)previousImage) animatedImageData]; + NSData *currentData = [((UIImage *)image) animatedImageData]; + // Check whether to use progressive rendering or not + if (!previousData || !currentData) { + // Early return + return; + } + + // Warning: normally the `previousData` is same instance as `currentData` because our `SDAnimatedImage` class share the same `coder` instance internally. But there may be a race condition, that later retrived `currentData` is already been updated and it's not the same instance as `previousData`. + // And for protocol extensible design, we should not assume `SDAnimatedImage` protocol implementations always share same instance. So both of two reasons, we need that `rangeOfData` check. + if ([currentData isEqualToData:previousData]) { + // If current data is the same data (or instance) as previous data + self.isProgressive = YES; + } else if (currentData.length > previousData.length) { + // If current data is appended by previous data, use `NSDataSearchAnchored`, search is limited to start of currentData + NSRange range = [currentData rangeOfData:previousData options:NSDataSearchAnchored range:NSMakeRange(0, previousData.length)]; + if (range.location != NSNotFound) { + // Contains hole previous data and they start with the same beginning + self.isProgressive = YES; + } + } + } else { + // Previous image is not progressive, so start progressive rendering + self.isProgressive = YES; + } + } +} + +#if SD_MAC +- (void)displayDidRefresh:(CVDisplayLinkRef)displayLink duration:(NSTimeInterval)duration +#else +- (void)displayDidRefresh:(CADisplayLink *)displayLink +#endif +{ + // If for some reason a wild call makes it through when we shouldn't be animating, bail. + // Early return! + if (!self.shouldAnimate) { + return; + } + +#if SD_UIKIT + NSTimeInterval duration = displayLink.duration * displayLink.frameInterval; +#endif + NSUInteger totalFrameCount = self.totalFrameCount; + NSUInteger currentFrameIndex = self.currentFrameIndex; + NSUInteger nextFrameIndex = (currentFrameIndex + 1) % totalFrameCount; + + // Check if we have the frame buffer firstly to improve performance + if (!self.bufferMiss) { + // Then check if timestamp is reached + self.currentTime += duration; + NSTimeInterval currentDuration = [self.animatedImage animatedImageDurationAtIndex:currentFrameIndex]; + if (self.currentTime < currentDuration) { + // Current frame timestamp not reached, return + return; + } + self.currentTime -= currentDuration; + NSTimeInterval nextDuration = [self.animatedImage animatedImageDurationAtIndex:nextFrameIndex]; + if (self.currentTime > nextDuration) { + // Do not skip frame + self.currentTime = nextDuration; + } + } + + // Update the current frame + UIImage *currentFrame; + UIImage *fetchFrame; + SD_LOCK(self.lock); + currentFrame = self.frameBuffer[@(currentFrameIndex)]; + fetchFrame = currentFrame ? self.frameBuffer[@(nextFrameIndex)] : nil; + SD_UNLOCK(self.lock); + BOOL bufferFull = NO; + if (currentFrame) { + SD_LOCK(self.lock); + // Remove the frame buffer if need + if (self.frameBuffer.count > self.maxBufferCount) { + self.frameBuffer[@(currentFrameIndex)] = nil; + } + // Check whether we can stop fetch + if (self.frameBuffer.count == totalFrameCount) { + bufferFull = YES; + } + SD_UNLOCK(self.lock); + self.currentFrame = currentFrame; + self.currentFrameIndex = nextFrameIndex; + self.bufferMiss = NO; + [self.layer setNeedsDisplay]; + } else { + self.bufferMiss = YES; + } + + // Update the loop count when last frame rendered + if (nextFrameIndex == 0 && !self.bufferMiss) { + // Progressive image reach the current last frame index. Keep the state and stop animating. Wait for later restart + if (self.isProgressive) { + // Recovery the current frame index and removed frame buffer (See above) + self.currentFrameIndex = currentFrameIndex; + SD_LOCK(self.lock); + self.frameBuffer[@(currentFrameIndex)] = self.currentFrame; + SD_UNLOCK(self.lock); + [self stopAnimating]; + return; + } + // Update the loop count + self.currentLoopCount++; + // if reached the max loop count, stop animating, 0 means loop indefinitely + NSUInteger maxLoopCount = self.shouldCustomLoopCount ? self.animationRepeatCount : self.totalLoopCount; + if (maxLoopCount != 0 && (self.currentLoopCount >= maxLoopCount)) { + [self stopAnimating]; + return; + } + } + + // Check if we should prefetch next frame or current frame + NSUInteger fetchFrameIndex; + if (self.bufferMiss) { + // When buffer miss, means the decode speed is slower than render speed, we fetch current miss frame + fetchFrameIndex = currentFrameIndex; + } else { + // Or, most cases, the decode speed is faster than render speed, we fetch next frame + fetchFrameIndex = nextFrameIndex; + } + + if (!fetchFrame && !bufferFull && self.fetchQueue.operationCount == 0) { + // Prefetch next frame in background queue + UIImage *animatedImage = self.animatedImage; + NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ + UIImage *frame = [animatedImage animatedImageFrameAtIndex:fetchFrameIndex]; + SD_LOCK(self.lock); + self.frameBuffer[@(fetchFrameIndex)] = frame; + SD_UNLOCK(self.lock); + }]; + [self.fetchQueue addOperation:operation]; + } +} + ++ (NSString *)defaultRunLoopMode +{ + // Key off `activeProcessorCount` (as opposed to `processorCount`) since the system could shut down cores in certain situations. + return [NSProcessInfo processInfo].activeProcessorCount > 1 ? NSRunLoopCommonModes : NSDefaultRunLoopMode; +} + + +#pragma mark Providing the Layer's Content +#pragma mark - CALayerDelegate + +- (void)displayLayer:(CALayer *)layer +{ + if (_currentFrame) { + layer.contentsScale = self.animatedImageScale; + layer.contents = (__bridge id)_currentFrame.CGImage; + } +} + +#if SD_MAC +// Layer-backed NSImageView optionally optimize to use a subview to do actual layer rendering. +// When the optimization is turned on, it calls `updateLayer` instead of `displayLayer:` to update subview's layer. +// When the optimization it turned off, this return nil and calls `displayLayer:` directly. +- (CALayer *)imageViewLayer { + NSView *imageView = imageView = objc_getAssociatedObject(self, NSSelectorFromString(@"_imageView")); + if (!imageView) { + // macOS 10.14 + imageView = objc_getAssociatedObject(self, NSSelectorFromString(@"_imageSubview")); + } + return imageView.layer; +} + +- (void)updateLayer +{ + if (_currentFrame) { + [self displayLayer:self.imageViewLayer]; + } else { + [super updateLayer]; + } +} +#endif + + +#pragma mark - Util +- (void)calculateMaxBufferCount { + NSUInteger bytes = CGImageGetBytesPerRow(self.currentFrame.CGImage) * CGImageGetHeight(self.currentFrame.CGImage); + if (bytes == 0) bytes = 1024; + + NSUInteger max = 0; + if (self.maxBufferSize > 0) { + max = self.maxBufferSize; + } else { + // Calculate based on current memory, these factors are by experience + NSUInteger total = SDDeviceTotalMemory(); + NSUInteger free = SDDeviceFreeMemory(); + max = MIN(total * 0.2, free * 0.6); + } + + NSUInteger maxBufferCount = (double)max / (double)bytes; + if (!maxBufferCount) { + // At least 1 frame + maxBufferCount = 1; + } + + self.maxBufferCount = maxBufferCount; +} + +@end + +#if SD_MAC +static CVReturn renderCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *inNow, const CVTimeStamp *inOutputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext) { + // Calculate refresh duration + NSTimeInterval duration = (double)inOutputTime->videoRefreshPeriod / ((double)inOutputTime->videoTimeScale * inOutputTime->rateScalar); + // CVDisplayLink callback is not on main queue + SDAnimatedImageView *imageView = (__bridge SDAnimatedImageView *)displayLinkContext; + __weak SDAnimatedImageView *weakImageView = imageView; + dispatch_async(dispatch_get_main_queue(), ^{ + [weakImageView displayDidRefresh:displayLink duration:duration]; + }); + return kCVReturnSuccess; +} +#endif + +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDDiskCache.h b/Pods/SDWebImage/SDWebImage/SDDiskCache.h new file mode 100644 index 00000000..626ca2e0 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDDiskCache.h @@ -0,0 +1,119 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +@class SDImageCacheConfig; +// A protocol to allow custom disk cache used in SDImageCache. +@protocol SDDiskCache + +// All of these method are called from the same global queue to avoid blocking on main queue and thread-safe problem. But it's also recommend to ensure thread-safe yourself using lock or other ways. +@required +/** + Create a new disk cache based on the specified path. You can check `maxDiskSize` and `maxDiskAge` used for disk cache. + + @param cachePath Full path of a directory in which the cache will write data. + Once initialized you should not read and write to this directory. + @param config The cache config to be used to create the cache. + + @return A new cache object, or nil if an error occurs. + */ +- (nullable instancetype)initWithCachePath:(nonnull NSString *)cachePath config:(nonnull SDImageCacheConfig *)config; + +/** + Returns a boolean value that indicates whether a given key is in cache. + This method may blocks the calling thread until file read finished. + + @param key A string identifying the data. If nil, just return NO. + @return Whether the key is in cache. + */ +- (BOOL)containsDataForKey:(nonnull NSString *)key; + +/** + Returns the data associated with a given key. + This method may blocks the calling thread until file read finished. + + @param key A string identifying the data. If nil, just return nil. + @return The value associated with key, or nil if no value is associated with key. + */ +- (nullable NSData *)dataForKey:(nonnull NSString *)key; + +/** + Sets the value of the specified key in the cache. + This method may blocks the calling thread until file write finished. + + @param data The data to be stored in the cache. + @param key The key with which to associate the value. If nil, this method has no effect. + */ +- (void)setData:(nullable NSData *)data forKey:(nonnull NSString *)key; + +/** + Removes the value of the specified key in the cache. + This method may blocks the calling thread until file delete finished. + + @param key The key identifying the value to be removed. If nil, this method has no effect. + */ +- (void)removeDataForKey:(nonnull NSString *)key; + +/** + Empties the cache. + This method may blocks the calling thread until file delete finished. + */ +- (void)removeAllData; + +/** + Removes the expired data from the cache. You can choose the data to remove base on `ageLimit`, `countLimit` and `sizeLimit` options. + */ +- (void)removeExpiredData; + +/** + The cache path for key + + @param key A string identifying the value + @return The cache path for key. Or nil if the key can not associate to a path + */ +- (nullable NSString *)cachePathForKey:(nonnull NSString *)key; + +/** + Returns the number of data in this cache. + This method may blocks the calling thread until file read finished. + + @return The total data count. + */ +- (NSUInteger)totalCount; + +/** + Returns the total size (in bytes) of data in this cache. + This method may blocks the calling thread until file read finished. + + @return The total data size in bytes. + */ +- (NSUInteger)totalSize; + +@end + +// The built-in disk cache +@interface SDDiskCache : NSObject + +@property (nonatomic, strong, readonly, nonnull) SDImageCacheConfig *config; + +- (nonnull instancetype)init NS_UNAVAILABLE; + +/** + Move the cache directory from old location to new location, the old location will be removed after finish. + If the old location does not exist, does nothing. + If the new location does not exist, only do a movement of directory. + If the new location does exist, will move and merge the files from old location. + If the new location does exist, but is not a directory, will remove it and do a movement of directory. + + @param srcPath old location of cache directory + @param dstPath new location of cache directory + */ +- (void)moveCacheDirectoryFromPath:(nonnull NSString *)srcPath toPath:(nonnull NSString *)dstPath; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDDiskCache.m b/Pods/SDWebImage/SDWebImage/SDDiskCache.m new file mode 100644 index 00000000..21648972 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDDiskCache.m @@ -0,0 +1,291 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDDiskCache.h" +#import "SDImageCacheConfig.h" +#import + +@interface SDDiskCache () + +@property (nonatomic, copy) NSString *diskCachePath; +@property (nonatomic, strong, nonnull) NSFileManager *fileManager; + +@end + +@implementation SDDiskCache + +- (instancetype)init { + NSAssert(NO, @"Use `initWithCachePath:` with the disk cache path"); + return nil; +} + +#pragma mark - SDcachePathForKeyDiskCache Protocol +- (instancetype)initWithCachePath:(NSString *)cachePath config:(nonnull SDImageCacheConfig *)config { + if (self = [super init]) { + _diskCachePath = cachePath; + _config = config; + [self commonInit]; + } + return self; +} + +- (void)commonInit { + if (self.config.fileManager) { + self.fileManager = self.config.fileManager; + } else { + self.fileManager = [NSFileManager new]; + } +} + +- (BOOL)containsDataForKey:(NSString *)key { + NSParameterAssert(key); + NSString *filePath = [self cachePathForKey:key]; + BOOL exists = [self.fileManager fileExistsAtPath:filePath]; + + // fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name + // checking the key with and without the extension + if (!exists) { + exists = [self.fileManager fileExistsAtPath:filePath.stringByDeletingPathExtension]; + } + + return exists; +} + +- (NSData *)dataForKey:(NSString *)key { + NSParameterAssert(key); + NSString *filePath = [self cachePathForKey:key]; + NSData *data = [NSData dataWithContentsOfFile:filePath options:self.config.diskCacheReadingOptions error:nil]; + if (data) { + return data; + } + + // fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name + // checking the key with and without the extension + data = [NSData dataWithContentsOfFile:filePath.stringByDeletingPathExtension options:self.config.diskCacheReadingOptions error:nil]; + if (data) { + return data; + } + + return nil; +} + +- (void)setData:(NSData *)data forKey:(NSString *)key { + NSParameterAssert(data); + NSParameterAssert(key); + if (![self.fileManager fileExistsAtPath:self.diskCachePath]) { + [self.fileManager createDirectoryAtPath:self.diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL]; + } + + // get cache Path for image key + NSString *cachePathForKey = [self cachePathForKey:key]; + // transform to NSUrl + NSURL *fileURL = [NSURL fileURLWithPath:cachePathForKey]; + + [data writeToURL:fileURL options:self.config.diskCacheWritingOptions error:nil]; + + // disable iCloud backup + if (self.config.shouldDisableiCloud) { + // ignore iCloud backup resource value error + [fileURL setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil]; + } +} + +- (void)removeDataForKey:(NSString *)key { + NSParameterAssert(key); + NSString *filePath = [self cachePathForKey:key]; + [self.fileManager removeItemAtPath:filePath error:nil]; +} + +- (void)removeAllData { + [self.fileManager removeItemAtPath:self.diskCachePath error:nil]; + [self.fileManager createDirectoryAtPath:self.diskCachePath + withIntermediateDirectories:YES + attributes:nil + error:NULL]; +} + +- (void)removeExpiredData { + NSURL *diskCacheURL = [NSURL fileURLWithPath:self.diskCachePath isDirectory:YES]; + + // Compute content date key to be used for tests + NSURLResourceKey cacheContentDateKey = NSURLContentModificationDateKey; + switch (self.config.diskCacheExpireType) { + case SDImageCacheConfigExpireTypeAccessDate: + cacheContentDateKey = NSURLContentAccessDateKey; + break; + + case SDImageCacheConfigExpireTypeModificationDate: + cacheContentDateKey = NSURLContentModificationDateKey; + break; + + default: + break; + } + + NSArray *resourceKeys = @[NSURLIsDirectoryKey, cacheContentDateKey, NSURLTotalFileAllocatedSizeKey]; + + // This enumerator prefetches useful properties for our cache files. + NSDirectoryEnumerator *fileEnumerator = [self.fileManager enumeratorAtURL:diskCacheURL + includingPropertiesForKeys:resourceKeys + options:NSDirectoryEnumerationSkipsHiddenFiles + errorHandler:NULL]; + + NSDate *expirationDate = (self.config.maxDiskAge < 0) ? nil: [NSDate dateWithTimeIntervalSinceNow:-self.config.maxDiskAge]; + NSMutableDictionary *> *cacheFiles = [NSMutableDictionary dictionary]; + NSUInteger currentCacheSize = 0; + + // Enumerate all of the files in the cache directory. This loop has two purposes: + // + // 1. Removing files that are older than the expiration date. + // 2. Storing file attributes for the size-based cleanup pass. + NSMutableArray *urlsToDelete = [[NSMutableArray alloc] init]; + for (NSURL *fileURL in fileEnumerator) { + NSError *error; + NSDictionary *resourceValues = [fileURL resourceValuesForKeys:resourceKeys error:&error]; + + // Skip directories and errors. + if (error || !resourceValues || [resourceValues[NSURLIsDirectoryKey] boolValue]) { + continue; + } + + // Remove files that are older than the expiration date; + NSDate *modifiedDate = resourceValues[cacheContentDateKey]; + if (expirationDate && [[modifiedDate laterDate:expirationDate] isEqualToDate:expirationDate]) { + [urlsToDelete addObject:fileURL]; + continue; + } + + // Store a reference to this file and account for its total size. + NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey]; + currentCacheSize += totalAllocatedSize.unsignedIntegerValue; + cacheFiles[fileURL] = resourceValues; + } + + for (NSURL *fileURL in urlsToDelete) { + [self.fileManager removeItemAtURL:fileURL error:nil]; + } + + // If our remaining disk cache exceeds a configured maximum size, perform a second + // size-based cleanup pass. We delete the oldest files first. + NSUInteger maxDiskSize = self.config.maxDiskSize; + if (maxDiskSize > 0 && currentCacheSize > maxDiskSize) { + // Target half of our maximum cache size for this cleanup pass. + const NSUInteger desiredCacheSize = maxDiskSize / 2; + + // Sort the remaining cache files by their last modification time or last access time (oldest first). + NSArray *sortedFiles = [cacheFiles keysSortedByValueWithOptions:NSSortConcurrent + usingComparator:^NSComparisonResult(id obj1, id obj2) { + return [obj1[cacheContentDateKey] compare:obj2[cacheContentDateKey]]; + }]; + + // Delete files until we fall below our desired cache size. + for (NSURL *fileURL in sortedFiles) { + if ([self.fileManager removeItemAtURL:fileURL error:nil]) { + NSDictionary *resourceValues = cacheFiles[fileURL]; + NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey]; + currentCacheSize -= totalAllocatedSize.unsignedIntegerValue; + + if (currentCacheSize < desiredCacheSize) { + break; + } + } + } + } +} + +- (nullable NSString *)cachePathForKey:(NSString *)key { + NSParameterAssert(key); + return [self cachePathForKey:key inPath:self.diskCachePath]; +} + +- (NSUInteger)totalSize { + NSUInteger size = 0; + NSDirectoryEnumerator *fileEnumerator = [self.fileManager enumeratorAtPath:self.diskCachePath]; + for (NSString *fileName in fileEnumerator) { + NSString *filePath = [self.diskCachePath stringByAppendingPathComponent:fileName]; + NSDictionary *attrs = [self.fileManager attributesOfItemAtPath:filePath error:nil]; + size += [attrs fileSize]; + } + return size; +} + +- (NSUInteger)totalCount { + NSUInteger count = 0; + NSDirectoryEnumerator *fileEnumerator = [self.fileManager enumeratorAtPath:self.diskCachePath]; + count = fileEnumerator.allObjects.count; + return count; +} + +#pragma mark - Cache paths + +- (nullable NSString *)cachePathForKey:(nullable NSString *)key inPath:(nonnull NSString *)path { + NSString *filename = SDDiskCacheFileNameForKey(key); + return [path stringByAppendingPathComponent:filename]; +} + +- (void)moveCacheDirectoryFromPath:(nonnull NSString *)srcPath toPath:(nonnull NSString *)dstPath { + NSParameterAssert(srcPath); + NSParameterAssert(dstPath); + // Check if old path is equal to new path + if ([srcPath isEqualToString:dstPath]) { + return; + } + BOOL isDirectory; + // Check if old path is directory + if (![self.fileManager fileExistsAtPath:srcPath isDirectory:&isDirectory] || !isDirectory) { + return; + } + // Check if new path is directory + if (![self.fileManager fileExistsAtPath:dstPath isDirectory:&isDirectory] || !isDirectory) { + if (!isDirectory) { + // New path is not directory, remove file + [self.fileManager removeItemAtPath:dstPath error:nil]; + } + NSString *dstParentPath = [dstPath stringByDeletingLastPathComponent]; + // Creates any non-existent parent directories as part of creating the directory in path + if (![self.fileManager fileExistsAtPath:dstParentPath]) { + [self.fileManager createDirectoryAtPath:dstParentPath withIntermediateDirectories:YES attributes:nil error:NULL]; + } + // New directory does not exist, rename directory + [self.fileManager moveItemAtPath:srcPath toPath:dstPath error:nil]; + } else { + // New directory exist, merge the files + NSDirectoryEnumerator *dirEnumerator = [self.fileManager enumeratorAtPath:srcPath]; + NSString *file; + while ((file = [dirEnumerator nextObject])) { + [self.fileManager moveItemAtPath:[srcPath stringByAppendingPathComponent:file] toPath:[dstPath stringByAppendingPathComponent:file] error:nil]; + } + // Remove the old path + [self.fileManager removeItemAtPath:srcPath error:nil]; + } +} + +#pragma mark - Hash + +#define SD_MAX_FILE_EXTENSION_LENGTH (NAME_MAX - CC_MD5_DIGEST_LENGTH * 2 - 1) + +static inline NSString * _Nonnull SDDiskCacheFileNameForKey(NSString * _Nullable key) { + const char *str = key.UTF8String; + if (str == NULL) { + str = ""; + } + unsigned char r[CC_MD5_DIGEST_LENGTH]; + CC_MD5(str, (CC_LONG)strlen(str), r); + NSURL *keyURL = [NSURL URLWithString:key]; + NSString *ext = keyURL ? keyURL.pathExtension : key.pathExtension; + // File system has file name length limit, we need to check if ext is too long, we don't add it to the filename + if (ext.length > SD_MAX_FILE_EXTENSION_LENGTH) { + ext = nil; + } + NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%@", + r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], + r[11], r[12], r[13], r[14], r[15], ext.length == 0 ? @"" : [NSString stringWithFormat:@".%@", ext]]; + return filename; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageAPNGCoder.h b/Pods/SDWebImage/SDWebImage/SDImageAPNGCoder.h new file mode 100644 index 00000000..a674a95b --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageAPNGCoder.h @@ -0,0 +1,19 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDImageCoder.h" + +/** + Built in coder using ImageIO that supports APNG encoding/decoding + */ +@interface SDImageAPNGCoder : NSObject + +@property (nonatomic, class, readonly, nonnull) SDImageAPNGCoder *sharedCoder; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageAPNGCoder.m b/Pods/SDWebImage/SDWebImage/SDImageAPNGCoder.m new file mode 100644 index 00000000..64384122 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageAPNGCoder.m @@ -0,0 +1,424 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageAPNGCoder.h" +#import +#import "NSData+ImageContentType.h" +#import "UIImage+Metadata.h" +#import "NSImage+Compatibility.h" +#import "SDImageCoderHelper.h" +#import "SDAnimatedImageRep.h" + +// iOS 8 Image/IO framework binary does not contains these APNG contants, so we define them. Thanks Apple :) +#if (__IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0) +const CFStringRef kCGImagePropertyAPNGLoopCount = (__bridge CFStringRef)@"LoopCount"; +const CFStringRef kCGImagePropertyAPNGDelayTime = (__bridge CFStringRef)@"DelayTime"; +const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef)@"UnclampedDelayTime"; +#endif + +@interface SDAPNGCoderFrame : NSObject + +@property (nonatomic, assign) NSUInteger index; // Frame index (zero based) +@property (nonatomic, assign) NSTimeInterval duration; // Frame duration in seconds + +@end + +@implementation SDAPNGCoderFrame +@end + +@implementation SDImageAPNGCoder { + size_t _width, _height; + CGImageSourceRef _imageSource; + NSData *_imageData; + CGFloat _scale; + NSUInteger _loopCount; + NSUInteger _frameCount; + NSArray *_frames; + BOOL _finished; +} + +- (void)dealloc +{ + if (_imageSource) { + CFRelease(_imageSource); + _imageSource = NULL; + } +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif +} + +- (void)didReceiveMemoryWarning:(NSNotification *)notification +{ + if (_imageSource) { + for (size_t i = 0; i < _frameCount; i++) { + CGImageSourceRemoveCacheAtIndex(_imageSource, i); + } + } +} + ++ (instancetype)sharedCoder { + static SDImageAPNGCoder *coder; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + coder = [[SDImageAPNGCoder alloc] init]; + }); + return coder; +} + +#pragma mark - Decode +- (BOOL)canDecodeFromData:(nullable NSData *)data { + return ([NSData sd_imageFormatForImageData:data] == SDImageFormatPNG); +} + +- (UIImage *)decodedImageWithData:(NSData *)data options:(nullable SDImageCoderOptions *)options { + if (!data) { + return nil; + } + CGFloat scale = 1; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } + +#if SD_MAC + SDAnimatedImageRep *imageRep = [[SDAnimatedImageRep alloc] initWithData:data]; + NSSize size = NSMakeSize(imageRep.pixelsWide / scale, imageRep.pixelsHigh / scale); + imageRep.size = size; + NSImage *animatedImage = [[NSImage alloc] initWithSize:size]; + [animatedImage addRepresentation:imageRep]; + return animatedImage; +#else + + CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); + if (!source) { + return nil; + } + size_t count = CGImageSourceGetCount(source); + UIImage *animatedImage; + + BOOL decodeFirstFrame = [options[SDImageCoderDecodeFirstFrameOnly] boolValue]; + if (decodeFirstFrame || count <= 1) { + animatedImage = [[UIImage alloc] initWithData:data scale:scale]; + } else { + NSMutableArray *frames = [NSMutableArray array]; + + for (size_t i = 0; i < count; i++) { + CGImageRef imageRef = CGImageSourceCreateImageAtIndex(source, i, NULL); + if (!imageRef) { + continue; + } + + float duration = [self sd_frameDurationAtIndex:i source:source]; + UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp]; + CGImageRelease(imageRef); + + SDImageFrame *frame = [SDImageFrame frameWithImage:image duration:duration]; + [frames addObject:frame]; + } + + NSUInteger loopCount = [self sd_imageLoopCountWithSource:source]; + + animatedImage = [SDImageCoderHelper animatedImageWithFrames:frames]; + animatedImage.sd_imageLoopCount = loopCount; + } + animatedImage.sd_imageFormat = SDImageFormatPNG; + CFRelease(source); + + return animatedImage; +#endif +} + +- (NSUInteger)sd_imageLoopCountWithSource:(CGImageSourceRef)source { + NSUInteger loopCount = 0; + NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, nil); + NSDictionary *pngProperties = imageProperties[(__bridge NSString *)kCGImagePropertyPNGDictionary]; + if (pngProperties) { + NSNumber *apngLoopCount = pngProperties[(__bridge NSString *)kCGImagePropertyAPNGLoopCount]; + if (apngLoopCount != nil) { + loopCount = apngLoopCount.unsignedIntegerValue; + } + } + return loopCount; +} + +- (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { + float frameDuration = 0.1f; + CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); + NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; + NSDictionary *pngProperties = frameProperties[(NSString *)kCGImagePropertyPNGDictionary]; + + NSNumber *delayTimeUnclampedProp = pngProperties[(__bridge NSString *)kCGImagePropertyAPNGUnclampedDelayTime]; + if (delayTimeUnclampedProp != nil) { + frameDuration = [delayTimeUnclampedProp floatValue]; + } else { + NSNumber *delayTimeProp = pngProperties[(__bridge NSString *)kCGImagePropertyAPNGDelayTime]; + if (delayTimeProp != nil) { + frameDuration = [delayTimeProp floatValue]; + } + } + + if (frameDuration < 0.011f) { + frameDuration = 0.100f; + } + + CFRelease(cfFrameProperties); + return frameDuration; +} + +#pragma mark - Encode +- (BOOL)canEncodeToFormat:(SDImageFormat)format { + return (format == SDImageFormatPNG); +} + +- (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format options:(nullable SDImageCoderOptions *)options { + if (!image) { + return nil; + } + + if (format != SDImageFormatPNG) { + return nil; + } + + NSMutableData *imageData = [NSMutableData data]; + CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:SDImageFormatPNG]; + NSArray *frames = [SDImageCoderHelper framesFromAnimatedImage:image]; + + // Create an image destination. APNG does not support EXIF image orientation + CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count, NULL); + if (!imageDestination) { + // Handle failure. + return nil; + } + NSMutableDictionary *properties = [NSMutableDictionary dictionary]; + double compressionQuality = 1; + if (options[SDImageCoderEncodeCompressionQuality]) { + compressionQuality = [options[SDImageCoderEncodeCompressionQuality] doubleValue]; + } + properties[(__bridge NSString *)kCGImageDestinationLossyCompressionQuality] = @(compressionQuality); + + BOOL encodeFirstFrame = [options[SDImageCoderEncodeFirstFrameOnly] boolValue]; + if (encodeFirstFrame || frames.count == 0) { + // for static single PNG images + CGImageDestinationAddImage(imageDestination, image.CGImage, (__bridge CFDictionaryRef)properties); + } else { + // for animated APNG images + NSUInteger loopCount = image.sd_imageLoopCount; + NSDictionary *pngProperties = @{(__bridge NSString *)kCGImagePropertyAPNGLoopCount : @(loopCount)}; + properties[(__bridge NSString *)kCGImagePropertyPNGDictionary] = pngProperties; + CGImageDestinationSetProperties(imageDestination, (__bridge CFDictionaryRef)properties); + + for (size_t i = 0; i < frames.count; i++) { + SDImageFrame *frame = frames[i]; + float frameDuration = frame.duration; + CGImageRef frameImageRef = frame.image.CGImage; + NSDictionary *frameProperties = @{(__bridge NSString *)kCGImagePropertyPNGDictionary : @{(__bridge NSString *)kCGImagePropertyAPNGDelayTime : @(frameDuration)}}; + CGImageDestinationAddImage(imageDestination, frameImageRef, (__bridge CFDictionaryRef)frameProperties); + } + } + // Finalize the destination. + if (CGImageDestinationFinalize(imageDestination) == NO) { + // Handle failure. + imageData = nil; + } + + CFRelease(imageDestination); + + return [imageData copy]; +} + +#pragma mark - Progressive Decode + +- (BOOL)canIncrementalDecodeFromData:(NSData *)data { + return ([NSData sd_imageFormatForImageData:data] == SDImageFormatPNG); +} + +- (instancetype)initIncrementalWithOptions:(nullable SDImageCoderOptions *)options { + self = [super init]; + if (self) { + CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:SDImageFormatPNG]; + _imageSource = CGImageSourceCreateIncremental((__bridge CFDictionaryRef)@{(__bridge NSString *)kCGImageSourceTypeIdentifierHint : (__bridge NSString *)imageUTType}); + CGFloat scale = 1; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } + _scale = scale; +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif + } + return self; +} + +- (void)updateIncrementalData:(NSData *)data finished:(BOOL)finished { + if (_finished) { + return; + } + _imageData = data; + _finished = finished; + + // The following code is from http://www.cocoaintheshell.com/2011/05/progressive-images-download-imageio/ + // Thanks to the author @Nyx0uf + + // Update the data source, we must pass ALL the data, not just the new bytes + CGImageSourceUpdateData(_imageSource, (__bridge CFDataRef)data, finished); + + if (_width + _height == 0) { + CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(_imageSource, 0, NULL); + if (properties) { + CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight); + if (val) CFNumberGetValue(val, kCFNumberLongType, &_height); + val = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth); + if (val) CFNumberGetValue(val, kCFNumberLongType, &_width); + CFRelease(properties); + } + } + + // For animated image progressive decoding because the frame count and duration may be changed. + [self scanAndCheckFramesValidWithImageSource:_imageSource]; +} + +- (UIImage *)incrementalDecodedImageWithOptions:(SDImageCoderOptions *)options { + UIImage *image; + + if (_width + _height > 0) { + // Create the image + CGImageRef partialImageRef = CGImageSourceCreateImageAtIndex(_imageSource, 0, NULL); + + if (partialImageRef) { + CGFloat scale = _scale; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } +#if SD_UIKIT || SD_WATCH + image = [[UIImage alloc] initWithCGImage:partialImageRef scale:scale orientation:UIImageOrientationUp]; +#else + image = [[UIImage alloc] initWithCGImage:partialImageRef scale:scale orientation:kCGImagePropertyOrientationUp]; +#endif + CGImageRelease(partialImageRef); + image.sd_imageFormat = SDImageFormatPNG; + } + } + + return image; +} + +#pragma mark - SDAnimatedImageCoder +- (nullable instancetype)initWithAnimatedImageData:(nullable NSData *)data options:(nullable SDImageCoderOptions *)options { + if (!data) { + return nil; + } + self = [super init]; + if (self) { + CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); + if (!imageSource) { + return nil; + } + BOOL framesValid = [self scanAndCheckFramesValidWithImageSource:imageSource]; + if (!framesValid) { + CFRelease(imageSource); + return nil; + } + CGFloat scale = 1; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } + _scale = scale; + _imageSource = imageSource; + _imageData = data; +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif + } + return self; +} + +- (BOOL)scanAndCheckFramesValidWithImageSource:(CGImageSourceRef)imageSource +{ + if (!imageSource) { + return NO; + } + NSUInteger frameCount = CGImageSourceGetCount(imageSource); + NSUInteger loopCount = [self sd_imageLoopCountWithSource:imageSource]; + NSMutableArray *frames = [NSMutableArray array]; + + for (size_t i = 0; i < frameCount; i++) { + SDAPNGCoderFrame *frame = [[SDAPNGCoderFrame alloc] init]; + frame.index = i; + frame.duration = [self sd_frameDurationAtIndex:i source:imageSource]; + [frames addObject:frame]; + } + + _frameCount = frameCount; + _loopCount = loopCount; + _frames = [frames copy]; + + return YES; +} + +- (NSData *)animatedImageData +{ + return _imageData; +} + +- (NSUInteger)animatedImageLoopCount +{ + return _loopCount; +} + +- (NSUInteger)animatedImageFrameCount +{ + return _frameCount; +} + +- (NSTimeInterval)animatedImageDurationAtIndex:(NSUInteger)index +{ + if (index >= _frameCount) { + return 0; + } + return _frames[index].duration; +} + +- (UIImage *)animatedImageFrameAtIndex:(NSUInteger)index +{ + CGImageRef imageRef = CGImageSourceCreateImageAtIndex(_imageSource, index, NULL); + if (!imageRef) { + return nil; + } + // Image/IO create CGImage does not decompressed, so we do this because this is called background queue, this can avoid main queue block when rendering(especially when one more imageViews use the same image instance) + CGImageRef newImageRef = [SDImageCoderHelper CGImageCreateDecoded:imageRef]; + if (!newImageRef) { + newImageRef = imageRef; + } else { + CGImageRelease(imageRef); + } +#if SD_MAC + UIImage *image = [[UIImage alloc] initWithCGImage:newImageRef scale:_scale orientation:kCGImagePropertyOrientationUp]; +#else + UIImage *image = [UIImage imageWithCGImage:newImageRef scale:_scale orientation:UIImageOrientationUp]; +#endif + CGImageRelease(newImageRef); + return image; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCache.h b/Pods/SDWebImage/SDWebImage/SDImageCache.h index 9ae2eb44..bcbd3068 100644 --- a/Pods/SDWebImage/SDWebImage/SDImageCache.h +++ b/Pods/SDWebImage/SDWebImage/SDImageCache.h @@ -8,33 +8,46 @@ #import #import "SDWebImageCompat.h" +#import "SDWebImageDefine.h" +#import "SDImageCacheConfig.h" +#import "SDImageCacheDefine.h" -@class SDImageCacheConfig; - -typedef NS_ENUM(NSInteger, SDImageCacheType) { +typedef NS_OPTIONS(NSUInteger, SDImageCacheOptions) { + /** + * By default, we do not query image data when the image is already cached in memory. This mask can force to query image data at the same time. However, this query is asynchronously unless you specify `SDImageCacheQueryMemoryDataSync` + */ + SDImageCacheQueryMemoryData = 1 << 0, + /** + * By default, when you only specify `SDImageCacheQueryMemoryData`, we query the memory image data asynchronously. Combined this mask as well to query the memory image data synchronously. + */ + SDImageCacheQueryMemoryDataSync = 1 << 1, + /** + * By default, when the memory cache miss, we query the disk cache asynchronously. This mask can force to query disk cache (when memory cache miss) synchronously. + @note These 3 query options can be combined together. For the full list about these masks combination, see wiki page. + */ + SDImageCacheQueryDiskDataSync = 1 << 2, + /** + * 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 << 3, /** - * The image wasn't available the SDWebImage caches, but was downloaded from the web. + * 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. */ - SDImageCacheTypeNone, + SDImageCacheAvoidDecodeImage = 1 << 4, /** - * The image was obtained from the disk cache. + * By default, we decode the animated image. This flag can force decode the first frame only and produece the static image. */ - SDImageCacheTypeDisk, + SDImageCacheDecodeFirstFrameOnly = 1 << 5, /** - * The image was obtained from the memory 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 */ - SDImageCacheTypeMemory + SDImageCachePreloadAllFrames = 1 << 6 }; -typedef void(^SDCacheQueryCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType); - -typedef void(^SDWebImageCheckCacheCompletionBlock)(BOOL isInCache); - -typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize); - - /** - * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed + * SDImageCache maintains a memory cache and a disk cache. Disk cache write operations are performed * asynchronous so it doesn’t add unnecessary latency to the UI. */ @interface SDImageCache : NSObject @@ -42,28 +55,29 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot #pragma mark - Properties /** - * Cache Config object - storing all kind of settings + * Cache Config object - storing all kind of settings. + * The property is copy so change of currrent config will not accidentally affect other cache's config. */ -@property (nonatomic, nonnull, readonly) SDImageCacheConfig *config; +@property (nonatomic, copy, nonnull, readonly) SDImageCacheConfig *config; /** - * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory. + * The disk cache's root path */ -@property (assign, nonatomic) NSUInteger maxMemoryCost; +@property (nonatomic, copy, nonnull, readonly) NSString *diskCachePath; /** - * The maximum number of objects the cache should hold. + * The additional disk cache path to check if the query from disk cache not exist; + * The `key` param is the image cache key. The returned file path will be used to load the disk cache. If return nil, ignore it. + * Useful if you want to bundle pre-loaded images with your app */ -@property (assign, nonatomic) NSUInteger maxMemoryCountLimit; +@property (nonatomic, copy, nullable) SDImageCacheAdditionalCachePathBlock additionalCachePathBlock; #pragma mark - Singleton and initialization /** * Returns global shared cache instance - * - * @return SDImageCache global instance */ -+ (nonnull instancetype)sharedImageCache; +@property (nonatomic, class, readonly, nonnull) SDImageCache *sharedImageCache; /** * Init a new cache store with a specific namespace @@ -73,25 +87,36 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot - (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns; /** - * Init a new cache store with a specific namespace and directory + * Init a new cache store with a specific namespace and directory. + * If you don't provide the disk cache directory, we will use the User Cache directory with prefix (~/Library/Caches/com.hackemist.SDImageCache/). * * @param ns The namespace to use for this cache store * @param directory Directory to cache disk images in */ - (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns - diskCacheDirectory:(nonnull NSString *)directory NS_DESIGNATED_INITIALIZER; + diskCacheDirectory:(nullable NSString *)directory; -#pragma mark - Cache paths +/** + * Init a new cache store with a specific namespace, directory and file manager + * The final disk cache directory should looks like ($directory/$namespace). And the default config of shared cache, should result in (~/Library/Caches/com.hackemist.SDImageCache/default/) + * + * @param ns The namespace to use for this cache store + * @param directory Directory to cache disk images in + * @param config The cache config to be used to create the cache. You can provide custom memory cache or disk cache class in the cache config + */ +- (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns + diskCacheDirectory:(nullable NSString *)directory + config:(nullable SDImageCacheConfig *)config NS_DESIGNATED_INITIALIZER; -- (nullable NSString *)makeDiskCachePath:(nonnull NSString*)fullNamespace; +#pragma mark - Cache paths /** - * Add a read-only cache path to search for images pre-cached by SDImageCache - * Useful if you want to bundle pre-loaded images with your app - * - * @param path The path to use for this read-only cache path + Get the cache path for a certain key + + @param key The unique image cache key + @return The cache path. You can check `lastPathComponent` to grab the file name. */ -- (void)addReadOnlyCachePath:(nonnull NSString *)path; +- (nullable NSString *)cachePathForKey:(nullable NSString *)key; #pragma mark - Store Ops @@ -111,7 +136,7 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot * * @param image The image to store * @param key The unique image cache key, usually it's image absolute URL - * @param toDisk Store the image to disk cache if YES + * @param toDisk Store the image to disk cache if YES. If NO, the completion block is called synchronously * @param completionBlock A block executed after the operation is finished */ - (void)storeImage:(nullable UIImage *)image @@ -127,7 +152,7 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot * instead of converting the given image object into a storable/compressed image format in order * to save quality and CPU * @param key The unique image cache key, usually it's image absolute URL - * @param toDisk Store the image to disk cache if YES + * @param toDisk Store the image to disk cache if YES. If NO, the completion block is called synchronously * @param completionBlock A block executed after the operation is finished */ - (void)storeImage:(nullable UIImage *)image @@ -137,25 +162,52 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot completion:(nullable SDWebImageNoParamsBlock)completionBlock; /** - * Synchronously store image NSData into disk cache at the given key. + * Synchronously store image into memory cache at the given key. * - * @warning This method is synchronous, make sure to call it from the ioQueue + * @param image The image to store + * @param key The unique image cache key, usually it's image absolute URL + */ +- (void)storeImageToMemory:(nullable UIImage*)image + forKey:(nullable NSString *)key; + +/** + * Synchronously store image data into disk cache at the given key. * * @param imageData The image data to store * @param key The unique image cache key, usually it's image absolute URL */ -- (void)storeImageDataToDisk:(nullable NSData *)imageData forKey:(nullable NSString *)key; +- (void)storeImageDataToDisk:(nullable NSData *)imageData + forKey:(nullable NSString *)key; -#pragma mark - Query and Retrieve Ops + +#pragma mark - Contains and Check Ops /** - * Async check if image exists in disk cache already (does not load the image) + * Asynchronously check if image exists in disk cache already (does not load the image) * * @param key the key describing the url * @param completionBlock the block to be executed when the check is done. * @note the completion block will be always executed on the main queue */ -- (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock; +- (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDImageCacheCheckCompletionBlock)completionBlock; + +/** + * Synchronously check if image data exists in disk cache already (does not load the image) + * + * @param key the key describing the url + */ +- (BOOL)diskImageDataExistsWithKey:(nullable NSString *)key; + +#pragma mark - Query and Retrieve Ops + +/** + * Asynchronously queries the cache with operation and call the completion when done. + * Query the image data for the given key synchronously. + * + * @param key The unique key used to store the wanted image + * @return The image data for the given key, or nil if not found. + */ +- (nullable NSData *)diskImageDataForKey:(nullable NSString *)key; /** * Operation that queries the cache asynchronously and call the completion when done. @@ -165,33 +217,59 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot * * @return a NSOperation instance containing the cache op */ -- (nullable NSOperation *)queryCacheOperationForKey:(nullable NSString *)key done:(nullable SDCacheQueryCompletedBlock)doneBlock; +- (nullable NSOperation *)queryCacheOperationForKey:(nullable NSString *)key done:(nullable SDImageCacheQueryCompletionBlock)doneBlock; /** - * Query the memory cache synchronously. + * Asynchronously queries the cache with operation and call the completion when done. + * + * @param key The unique key used to store the wanted image + * @param options A mask to specify options to use for this cache query + * @param doneBlock The completion block. Will not get called if the operation is cancelled + * + * @return a NSOperation instance containing the cache op + */ +- (nullable NSOperation *)queryCacheOperationForKey:(nullable NSString *)key options:(SDImageCacheOptions)options done:(nullable SDImageCacheQueryCompletionBlock)doneBlock; + +/** + * Asynchronously queries the cache with operation and call the completion when done. + * + * @param key The unique key used to store the wanted image + * @param options A mask to specify options to use for this cache query + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + * @param doneBlock The completion block. Will not get called if the operation is cancelled + * + * @return a NSOperation instance containing the cache op + */ +- (nullable NSOperation *)queryCacheOperationForKey:(nullable NSString *)key options:(SDImageCacheOptions)options context:(nullable SDWebImageContext *)context done:(nullable SDImageCacheQueryCompletionBlock)doneBlock; + +/** + * Synchronously query the memory cache. * * @param key The unique key used to store the image + * @return The image for the given key, or nil if not found. */ - (nullable UIImage *)imageFromMemoryCacheForKey:(nullable NSString *)key; /** - * Query the disk cache synchronously. + * Synchronously query the disk cache. * * @param key The unique key used to store the image + * @return The image for the given key, or nil if not found. */ - (nullable UIImage *)imageFromDiskCacheForKey:(nullable NSString *)key; /** - * Query the cache (memory and or disk) synchronously after checking the memory cache. + * Synchronously query the cache (memory and or disk) after checking the memory cache. * * @param key The unique key used to store the image + * @return The image for the given key, or nil if not found. */ - (nullable UIImage *)imageFromCacheForKey:(nullable NSString *)key; #pragma mark - Remove Ops /** - * Remove the image from memory and disk cache asynchronously + * Asynchronously remove the image from memory and disk cache * * @param key The unique image cache key * @param completion A block that should be executed after the image has been removed (optional) @@ -199,29 +277,43 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot - (void)removeImageForKey:(nullable NSString *)key withCompletion:(nullable SDWebImageNoParamsBlock)completion; /** - * Remove the image from memory and optionally disk cache asynchronously + * Asynchronously remove the image from memory and optionally disk cache * * @param key The unique image cache key - * @param fromDisk Also remove cache entry from disk if YES + * @param fromDisk Also remove cache entry from disk if YES. If NO, the completion block is called synchronously * @param completion A block that should be executed after the image has been removed (optional) */ - (void)removeImageForKey:(nullable NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(nullable SDWebImageNoParamsBlock)completion; +/** + Synchronously remove the image from memory cache. + + @param key The unique image cache key + */ +- (void)removeImageFromMemoryForKey:(nullable NSString *)key; + +/** + Synchronously remove the image from disk cache. + + @param key The unique image cache key + */ +- (void)removeImageFromDiskForKey:(nullable NSString *)key; + #pragma mark - Cache clean Ops /** - * Clear all memory cached images + * Synchronously Clear all memory cached images */ - (void)clearMemory; /** - * Async clear all disk cached images. Non-blocking method - returns immediately. + * Asynchronously clear all disk cached images. Non-blocking method - returns immediately. * @param completion A block that should be executed after cache expiration completes (optional) */ - (void)clearDiskOnCompletion:(nullable SDWebImageNoParamsBlock)completion; /** - * Async remove all expired cached image from disk. Non-blocking method - returns immediately. + * Asynchronously remove all expired cached image from disk. Non-blocking method - returns immediately. * @param completionBlock A block that should be executed after cache expiration completes (optional) */ - (void)deleteOldFilesWithCompletionBlock:(nullable SDWebImageNoParamsBlock)completionBlock; @@ -229,39 +321,25 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot #pragma mark - Cache Info /** - * Get the size used by the disk cache + * Get the total bytes size of images in the disk cache */ -- (NSUInteger)getSize; +- (NSUInteger)totalDiskSize; /** * Get the number of images in the disk cache */ -- (NSUInteger)getDiskCount; +- (NSUInteger)totalDiskCount; /** * Asynchronously calculate the disk cache's size. */ -- (void)calculateSizeWithCompletionBlock:(nullable SDWebImageCalculateSizeBlock)completionBlock; +- (void)calculateSizeWithCompletionBlock:(nullable SDImageCacheCalculateSizeBlock)completionBlock; -#pragma mark - Cache Paths - -/** - * Get the cache path for a certain key (needs the cache path root folder) - * - * @param key the key (can be obtained from url using cacheKeyForURL) - * @param path the cache path root folder - * - * @return the cache path - */ -- (nullable NSString *)cachePathForKey:(nullable NSString *)key inPath:(nonnull NSString *)path; +@end /** - * Get the default cache path for a certain key - * - * @param key the key (can be obtained from url using cacheKeyForURL) - * - * @return the default cache path + * SDImageCache is the built-in image cache implementation for web image manager. It adopts `SDImageCache` protocol to provide the function for web image manager to use for image loading process. */ -- (nullable NSString *)defaultCachePathForKey:(nullable NSString *)key; +@interface SDImageCache (SDImageCache) @end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCache.m b/Pods/SDWebImage/SDWebImage/SDImageCache.m index acd5ee6a..10506e82 100644 --- a/Pods/SDWebImage/SDWebImage/SDImageCache.m +++ b/Pods/SDWebImage/SDWebImage/SDImageCache.m @@ -7,61 +7,28 @@ */ #import "SDImageCache.h" -#import "SDWebImageDecoder.h" -#import "UIImage+MultiFormat.h" -#import -#import "UIImage+GIF.h" -#import "NSData+ImageContentType.h" -#import "NSImage+WebCache.h" -#import "SDImageCacheConfig.h" - -// See https://github.com/rs/SDWebImage/pull/1141 for discussion -@interface AutoPurgeCache : NSCache -@end - -@implementation AutoPurgeCache - -- (nonnull instancetype)init { - self = [super init]; - if (self) { -#if SD_UIKIT - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAllObjects) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; -#endif - } - return self; -} - -- (void)dealloc { -#if SD_UIKIT - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; -#endif -} - -@end - - -FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { -#if SD_MAC - return image.size.height * image.size.width; -#elif SD_UIKIT || SD_WATCH - return image.size.height * image.size.width * image.scale * image.scale; -#endif -} +#import "SDMemoryCache.h" +#import "SDDiskCache.h" +#import "NSImage+Compatibility.h" +#import "SDImageCodersManager.h" +#import "SDImageTransformer.h" +#import "SDImageCoderHelper.h" +#import "SDAnimatedImage.h" +#import "UIImage+MemoryCacheCost.h" @interface SDImageCache () #pragma mark - Properties -@property (strong, nonatomic, nonnull) NSCache *memCache; -@property (strong, nonatomic, nonnull) NSString *diskCachePath; -@property (strong, nonatomic, nullable) NSMutableArray *customPaths; -@property (SDDispatchQueueSetterSementics, nonatomic, nullable) dispatch_queue_t ioQueue; +@property (nonatomic, strong, nonnull) id memCache; +@property (nonatomic, strong, nonnull) id diskCache; +@property (nonatomic, copy, readwrite, nonnull) SDImageCacheConfig *config; +@property (nonatomic, copy, readwrite, nonnull) NSString *diskCachePath; +@property (nonatomic, strong, nullable) dispatch_queue_t ioQueue; @end -@implementation SDImageCache { - NSFileManager *_fileManager; -} +@implementation SDImageCache #pragma mark - Singleton, init, dealloc @@ -79,52 +46,63 @@ - (instancetype)init { } - (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns { - NSString *path = [self makeDiskCachePath:ns]; - return [self initWithNamespace:ns diskCacheDirectory:path]; + return [self initWithNamespace:ns diskCacheDirectory:nil]; } - (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns - diskCacheDirectory:(nonnull NSString *)directory { + diskCacheDirectory:(nullable NSString *)directory { + return [self initWithNamespace:ns diskCacheDirectory:directory config:SDImageCacheConfig.defaultCacheConfig]; +} + +- (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns + diskCacheDirectory:(nullable NSString *)directory + config:(nullable SDImageCacheConfig *)config { if ((self = [super init])) { - NSString *fullNamespace = [@"com.hackemist.SDWebImageCache." stringByAppendingString:ns]; + NSAssert(ns, @"Cache namespace should not be nil"); // Create IO serial queue - _ioQueue = dispatch_queue_create("com.hackemist.SDWebImageCache", DISPATCH_QUEUE_SERIAL); + _ioQueue = dispatch_queue_create("com.hackemist.SDImageCache", DISPATCH_QUEUE_SERIAL); - _config = [[SDImageCacheConfig alloc] init]; + if (!config) { + config = SDImageCacheConfig.defaultCacheConfig; + } + _config = [config copy]; // Init the memory cache - _memCache = [[AutoPurgeCache alloc] init]; - _memCache.name = fullNamespace; - + NSAssert([config.memoryCacheClass conformsToProtocol:@protocol(SDMemoryCache)], @"Custom memory cache class must conform to `SDMemoryCache` protocol"); + _memCache = [[config.memoryCacheClass alloc] initWithConfig:_config]; + // Init the disk cache if (directory != nil) { - _diskCachePath = [directory stringByAppendingPathComponent:fullNamespace]; + _diskCachePath = [directory stringByAppendingPathComponent:ns]; } else { - NSString *path = [self makeDiskCachePath:ns]; + NSString *path = [[[self userCacheDirectory] stringByAppendingPathComponent:@"com.hackemist.SDImageCache"] stringByAppendingPathComponent:ns]; _diskCachePath = path; } - - dispatch_sync(_ioQueue, ^{ - _fileManager = [NSFileManager new]; - }); + + NSAssert([config.diskCacheClass conformsToProtocol:@protocol(SDDiskCache)], @"Custom disk cache class must conform to `SDDiskCache` protocol"); + _diskCache = [[config.diskCacheClass alloc] initWithCachePath:_diskCachePath config:_config]; + + // Check and migrate disk cache directory if need + [self migrateDiskCacheDirectory]; #if SD_UIKIT // Subscribe to app events [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(clearMemory) - name:UIApplicationDidReceiveMemoryWarningNotification - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(deleteOldFiles) + selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(backgroundDeleteOldFiles) + selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil]; +#endif +#if SD_MAC + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(applicationWillTerminate:) + name:NSApplicationWillTerminateNotification + object:nil]; #endif } @@ -133,55 +111,35 @@ - (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - SDDispatchQueueRelease(_ioQueue); -} - -- (void)checkIfQueueIsIOQueue { - const char *currentQueueLabel = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL); - const char *ioQueueLabel = dispatch_queue_get_label(self.ioQueue); - if (strcmp(currentQueueLabel, ioQueueLabel) != 0) { - NSLog(@"This method should be called from the ioQueue"); - } } #pragma mark - Cache paths -- (void)addReadOnlyCachePath:(nonnull NSString *)path { - if (!self.customPaths) { - self.customPaths = [NSMutableArray new]; - } - - if (![self.customPaths containsObject:path]) { - [self.customPaths addObject:path]; - } -} - -- (nullable NSString *)cachePathForKey:(nullable NSString *)key inPath:(nonnull NSString *)path { - NSString *filename = [self cachedFileNameForKey:key]; - return [path stringByAppendingPathComponent:filename]; -} - -- (nullable NSString *)defaultCachePathForKey:(nullable NSString *)key { - return [self cachePathForKey:key inPath:self.diskCachePath]; -} - -- (nullable NSString *)cachedFileNameForKey:(nullable NSString *)key { - const char *str = key.UTF8String; - if (str == NULL) { - str = ""; +- (nullable NSString *)cachePathForKey:(nullable NSString *)key { + if (!key) { + return nil; } - unsigned char r[CC_MD5_DIGEST_LENGTH]; - CC_MD5(str, (CC_LONG)strlen(str), r); - NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%@", - r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], - r[11], r[12], r[13], r[14], r[15], [key.pathExtension isEqualToString:@""] ? @"" : [NSString stringWithFormat:@".%@", key.pathExtension]]; - - return filename; + return [self.diskCache cachePathForKey:key]; } -- (nullable NSString *)makeDiskCachePath:(nonnull NSString*)fullNamespace { +- (nullable NSString *)userCacheDirectory { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - return [paths[0] stringByAppendingPathComponent:fullNamespace]; + return paths.firstObject; +} + +- (void)migrateDiskCacheDirectory { + if ([self.diskCache isKindOfClass:[SDDiskCache class]]) { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + // ~/Library/Caches/com.hackemist.SDImageCache/default/ + NSString *newDefaultPath = [[[self userCacheDirectory] stringByAppendingPathComponent:@"com.hackemist.SDImageCache"] stringByAppendingPathComponent:@"default"]; + // ~/Library/Caches/default/com.hackemist.SDWebImageCache.default/ + NSString *oldDefaultPath = [[[self userCacheDirectory] stringByAppendingPathComponent:@"default"] stringByAppendingPathComponent:@"com.hackemist.SDWebImageCache.default"]; + dispatch_async(self.ioQueue, ^{ + [((SDDiskCache *)self.diskCache) moveCacheDirectoryFromPath:oldDefaultPath toPath:newDefaultPath]; + }); + }); + } } #pragma mark - Store Ops @@ -204,6 +162,15 @@ - (void)storeImage:(nullable UIImage *)image forKey:(nullable NSString *)key toDisk:(BOOL)toDisk completion:(nullable SDWebImageNoParamsBlock)completionBlock { + return [self storeImage:image imageData:imageData forKey:key toMemory:YES toDisk:toDisk completion:completionBlock]; +} + +- (void)storeImage:(nullable UIImage *)image + imageData:(nullable NSData *)imageData + forKey:(nullable NSString *)key + toMemory:(BOOL)toMemory + toDisk:(BOOL)toDisk + completion:(nullable SDWebImageNoParamsBlock)completionBlock { if (!image || !key) { if (completionBlock) { completionBlock(); @@ -211,21 +178,28 @@ - (void)storeImage:(nullable UIImage *)image return; } // if memory cache is enabled - if (self.config.shouldCacheImagesInMemory) { - NSUInteger cost = SDCacheCostForImage(image); + if (toMemory && self.config.shouldCacheImagesInMemory) { + NSUInteger cost = image.sd_memoryCost; [self.memCache setObject:image forKey:key cost:cost]; } if (toDisk) { dispatch_async(self.ioQueue, ^{ - NSData *data = imageData; - - if (!data && image) { - SDImageFormat imageFormatFromData = [NSData sd_imageFormatForImageData:data]; - data = [image sd_imageDataAsFormat:imageFormatFromData]; + @autoreleasepool { + NSData *data = imageData; + if (!data && image) { + // If we do not have any data to detect image format, check whether it contains alpha channel to use PNG or JPEG format + SDImageFormat format; + if ([SDImageCoderHelper CGImageContainsAlpha:image.CGImage]) { + format = SDImageFormatPNG; + } else { + format = SDImageFormatJPEG; + } + data = [[SDImageCodersManager sharedManager] encodedDataWithImage:image format:format options:nil]; + } + [self _storeImageDataToDisk:data forKey:key]; } - [self storeImageDataToDisk:data forKey:key]; if (completionBlock) { dispatch_async(dispatch_get_main_queue(), ^{ completionBlock(); @@ -239,42 +213,39 @@ - (void)storeImage:(nullable UIImage *)image } } -- (void)storeImageDataToDisk:(nullable NSData *)imageData forKey:(nullable NSString *)key { +- (void)storeImageToMemory:(UIImage *)image forKey:(NSString *)key { + if (!image || !key) { + return; + } + NSUInteger cost = image.sd_memoryCost; + [self.memCache setObject:image forKey:key cost:cost]; +} + +- (void)storeImageDataToDisk:(nullable NSData *)imageData + forKey:(nullable NSString *)key { if (!imageData || !key) { return; } - [self checkIfQueueIsIOQueue]; - - if (![_fileManager fileExistsAtPath:_diskCachePath]) { - [_fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL]; + dispatch_sync(self.ioQueue, ^{ + [self _storeImageDataToDisk:imageData forKey:key]; + }); +} + +// Make sure to call form io queue by caller +- (void)_storeImageDataToDisk:(nullable NSData *)imageData forKey:(nullable NSString *)key { + if (!imageData || !key) { + return; } - // get cache Path for image key - NSString *cachePathForKey = [self defaultCachePathForKey:key]; - // transform to NSUrl - NSURL *fileURL = [NSURL fileURLWithPath:cachePathForKey]; - - [_fileManager createFileAtPath:cachePathForKey contents:imageData attributes:nil]; - - // disable iCloud backup - if (self.config.shouldDisableiCloud) { - [fileURL setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil]; - } + [self.diskCache setData:imageData forKey:key]; } #pragma mark - Query and Retrieve Ops -- (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock { - dispatch_async(_ioQueue, ^{ - BOOL exists = [_fileManager fileExistsAtPath:[self defaultCachePathForKey:key]]; - - // fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name - // checking the key with and without the extension - if (!exists) { - exists = [_fileManager fileExistsAtPath:[self defaultCachePathForKey:key].stringByDeletingPathExtension]; - } - +- (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDImageCacheCheckCompletionBlock)completionBlock { + dispatch_async(self.ioQueue, ^{ + BOOL exists = [self _diskImageDataExistsWithKey:key]; if (completionBlock) { dispatch_async(dispatch_get_main_queue(), ^{ completionBlock(exists); @@ -283,6 +254,40 @@ - (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDW }); } +- (BOOL)diskImageDataExistsWithKey:(nullable NSString *)key { + if (!key) { + return NO; + } + + __block BOOL exists = NO; + dispatch_sync(self.ioQueue, ^{ + exists = [self _diskImageDataExistsWithKey:key]; + }); + + return exists; +} + +// Make sure to call form io queue by caller +- (BOOL)_diskImageDataExistsWithKey:(nullable NSString *)key { + if (!key) { + return NO; + } + + return [self.diskCache containsDataForKey:key]; +} + +- (nullable NSData *)diskImageDataForKey:(nullable NSString *)key { + if (!key) { + return nil; + } + __block NSData *imageData = nil; + dispatch_sync(self.ioQueue, ^{ + imageData = [self diskImageDataBySearchingAllPathsForKey:key]; + }); + + return imageData; +} + - (nullable UIImage *)imageFromMemoryCacheForKey:(nullable NSString *)key { return [self.memCache objectForKey:key]; } @@ -290,7 +295,7 @@ - (nullable UIImage *)imageFromMemoryCacheForKey:(nullable NSString *)key { - (nullable UIImage *)imageFromDiskCacheForKey:(nullable NSString *)key { UIImage *diskImage = [self diskImageForKey:key]; if (diskImage && self.config.shouldCacheImagesInMemory) { - NSUInteger cost = SDCacheCostForImage(diskImage); + NSUInteger cost = diskImage.sd_memoryCost; [self.memCache setObject:diskImage forKey:key cost:cost]; } @@ -310,101 +315,127 @@ - (nullable UIImage *)imageFromCacheForKey:(nullable NSString *)key { } - (nullable NSData *)diskImageDataBySearchingAllPathsForKey:(nullable NSString *)key { - NSString *defaultPath = [self defaultCachePathForKey:key]; - NSData *data = [NSData dataWithContentsOfFile:defaultPath]; - if (data) { - return data; + if (!key) { + return nil; } - - // fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name - // checking the key with and without the extension - data = [NSData dataWithContentsOfFile:defaultPath.stringByDeletingPathExtension]; + + NSData *data = [self.diskCache dataForKey:key]; if (data) { return data; } - - NSArray *customPaths = [self.customPaths copy]; - for (NSString *path in customPaths) { - NSString *filePath = [self cachePathForKey:key inPath:path]; - NSData *imageData = [NSData dataWithContentsOfFile:filePath]; - if (imageData) { - return imageData; - } - - // fallback because of https://github.com/rs/SDWebImage/pull/976 that added the extension to the disk file name - // checking the key with and without the extension - imageData = [NSData dataWithContentsOfFile:filePath.stringByDeletingPathExtension]; - if (imageData) { - return imageData; + + // Addtional cache path for custom pre-load cache + if (self.additionalCachePathBlock) { + NSString *filePath = self.additionalCachePathBlock(key); + if (filePath) { + data = [NSData dataWithContentsOfFile:filePath options:self.config.diskCacheReadingOptions error:nil]; } } - return nil; + return data; } - (nullable UIImage *)diskImageForKey:(nullable NSString *)key { - NSData *data = [self diskImageDataBySearchingAllPathsForKey:key]; + NSData *data = [self diskImageDataForKey:key]; + return [self diskImageForKey:key data:data]; +} + +- (nullable UIImage *)diskImageForKey:(nullable NSString *)key data:(nullable NSData *)data { + return [self diskImageForKey:key data:data options:0 context:nil]; +} + +- (nullable UIImage *)diskImageForKey:(nullable NSString *)key data:(nullable NSData *)data options:(SDImageCacheOptions)options context:(SDWebImageContext *)context { if (data) { - UIImage *image = [UIImage sd_imageWithData:data]; - image = [self scaledImageForKey:key image:image]; - if (self.config.shouldDecompressImages) { - image = [UIImage decodedImageWithImage:image]; - } + UIImage *image = SDImageCacheDecodeImageData(data, key, [[self class] imageOptionsFromCacheOptions:options], context); return image; - } - else { + } else { return nil; } } -- (nullable UIImage *)scaledImageForKey:(nullable NSString *)key image:(nullable UIImage *)image { - return SDScaledImageForKey(key, image); +- (nullable NSOperation *)queryCacheOperationForKey:(NSString *)key done:(SDImageCacheQueryCompletionBlock)doneBlock { + return [self queryCacheOperationForKey:key options:0 done:doneBlock]; } -- (nullable NSOperation *)queryCacheOperationForKey:(nullable NSString *)key done:(nullable SDCacheQueryCompletedBlock)doneBlock { +- (nullable NSOperation *)queryCacheOperationForKey:(NSString *)key options:(SDImageCacheOptions)options done:(SDImageCacheQueryCompletionBlock)doneBlock { + return [self queryCacheOperationForKey:key options:options context:nil done:doneBlock]; +} + +- (nullable NSOperation *)queryCacheOperationForKey:(nullable NSString *)key options:(SDImageCacheOptions)options context:(nullable SDWebImageContext *)context done:(nullable SDImageCacheQueryCompletionBlock)doneBlock { if (!key) { if (doneBlock) { doneBlock(nil, nil, SDImageCacheTypeNone); } return nil; } - + + id transformer = context[SDWebImageContextImageTransformer]; + if (transformer) { + // grab the transformed disk image if transformer provided + NSString *transformerKey = [transformer transformerKey]; + key = SDTransformedKeyForKey(key, transformerKey); + } + // First check the in-memory cache... UIImage *image = [self imageFromMemoryCacheForKey:key]; - if (image) { - NSData *diskData = nil; - if ([image isGIF]) { - diskData = [self diskImageDataBySearchingAllPathsForKey:key]; - } + BOOL shouldQueryMemoryOnly = (image && !(options & SDImageCacheQueryMemoryData)); + if (shouldQueryMemoryOnly) { if (doneBlock) { - doneBlock(image, diskData, SDImageCacheTypeMemory); + doneBlock(image, nil, SDImageCacheTypeMemory); } return nil; } - + + // Second check the disk cache... NSOperation *operation = [NSOperation new]; - dispatch_async(self.ioQueue, ^{ + // Check whether we need to synchronously query disk + // 1. in-memory cache hit & memoryDataSync + // 2. in-memory cache miss & diskDataSync + BOOL shouldQueryDiskSync = ((image && options & SDImageCacheQueryMemoryDataSync) || + (!image && options & SDImageCacheQueryDiskDataSync)); + void(^queryDiskBlock)(void) = ^{ if (operation.isCancelled) { // do not call the completion if cancelled return; } - + @autoreleasepool { NSData *diskData = [self diskImageDataBySearchingAllPathsForKey:key]; - UIImage *diskImage = [self diskImageForKey:key]; - if (diskImage && self.config.shouldCacheImagesInMemory) { - NSUInteger cost = SDCacheCostForImage(diskImage); - [self.memCache setObject:diskImage forKey:key cost:cost]; + UIImage *diskImage; + SDImageCacheType cacheType = SDImageCacheTypeNone; + if (image) { + // the image is from in-memory cache, but need image data + diskImage = image; + cacheType = SDImageCacheTypeMemory; + } else if (diskData) { + cacheType = SDImageCacheTypeDisk; + // decode image data only if in-memory cache missed + diskImage = [self diskImageForKey:key data:diskData options:options context:context]; + if (diskImage && self.config.shouldCacheImagesInMemory) { + NSUInteger cost = diskImage.sd_memoryCost; + [self.memCache setObject:diskImage forKey:key cost:cost]; + } } - + if (doneBlock) { - dispatch_async(dispatch_get_main_queue(), ^{ - doneBlock(diskImage, diskData, SDImageCacheTypeDisk); - }); + if (shouldQueryDiskSync) { + doneBlock(diskImage, diskData, cacheType); + } else { + dispatch_async(dispatch_get_main_queue(), ^{ + doneBlock(diskImage, diskData, cacheType); + }); + } } } - }); - + }; + + // Query in ioQueue to keep IO-safe + if (shouldQueryDiskSync) { + dispatch_sync(self.ioQueue, queryDiskBlock); + } else { + dispatch_async(self.ioQueue, queryDiskBlock); + } + return operation; } @@ -415,17 +446,21 @@ - (void)removeImageForKey:(nullable NSString *)key withCompletion:(nullable SDWe } - (void)removeImageForKey:(nullable NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(nullable SDWebImageNoParamsBlock)completion { + [self removeImageForKey:key fromMemory:YES fromDisk:fromDisk withCompletion:completion]; +} + +- (void)removeImageForKey:(nullable NSString *)key fromMemory:(BOOL)fromMemory fromDisk:(BOOL)fromDisk withCompletion:(nullable SDWebImageNoParamsBlock)completion { if (key == nil) { return; } - if (self.config.shouldCacheImagesInMemory) { + if (fromMemory && self.config.shouldCacheImagesInMemory) { [self.memCache removeObjectForKey:key]; } if (fromDisk) { dispatch_async(self.ioQueue, ^{ - [_fileManager removeItemAtPath:[self defaultCachePathForKey:key] error:nil]; + [self.diskCache removeDataForKey:key]; if (completion) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -433,28 +468,35 @@ - (void)removeImageForKey:(nullable NSString *)key fromDisk:(BOOL)fromDisk withC }); } }); - } else if (completion){ + } else if (completion) { completion(); } - } -# pragma mark - Mem Cache settings - -- (void)setMaxMemoryCost:(NSUInteger)maxMemoryCost { - self.memCache.totalCostLimit = maxMemoryCost; -} - -- (NSUInteger)maxMemoryCost { - return self.memCache.totalCostLimit; +- (void)removeImageFromMemoryForKey:(NSString *)key { + if (!key) { + return; + } + + [self.memCache removeObjectForKey:key]; } -- (NSUInteger)maxMemoryCountLimit { - return self.memCache.countLimit; +- (void)removeImageFromDiskForKey:(NSString *)key { + if (!key) { + return; + } + dispatch_sync(self.ioQueue, ^{ + [self _removeImageFromDiskForKey:key]; + }); } -- (void)setMaxMemoryCountLimit:(NSUInteger)maxCountLimit { - self.memCache.countLimit = maxCountLimit; +// Make sure to call form io queue by caller +- (void)_removeImageFromDiskForKey:(NSString *)key { + if (!key) { + return; + } + + [self.diskCache removeDataForKey:key]; } #pragma mark - Cache clean Ops @@ -465,12 +507,7 @@ - (void)clearMemory { - (void)clearDiskOnCompletion:(nullable SDWebImageNoParamsBlock)completion { dispatch_async(self.ioQueue, ^{ - [_fileManager removeItemAtPath:self.diskCachePath error:nil]; - [_fileManager createDirectoryAtPath:self.diskCachePath - withIntermediateDirectories:YES - attributes:nil - error:NULL]; - + [self.diskCache removeAllData]; if (completion) { dispatch_async(dispatch_get_main_queue(), ^{ completion(); @@ -479,81 +516,9 @@ - (void)clearDiskOnCompletion:(nullable SDWebImageNoParamsBlock)completion { }); } -- (void)deleteOldFiles { - [self deleteOldFilesWithCompletionBlock:nil]; -} - - (void)deleteOldFilesWithCompletionBlock:(nullable SDWebImageNoParamsBlock)completionBlock { dispatch_async(self.ioQueue, ^{ - NSURL *diskCacheURL = [NSURL fileURLWithPath:self.diskCachePath isDirectory:YES]; - NSArray *resourceKeys = @[NSURLIsDirectoryKey, NSURLContentModificationDateKey, NSURLTotalFileAllocatedSizeKey]; - - // This enumerator prefetches useful properties for our cache files. - NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtURL:diskCacheURL - includingPropertiesForKeys:resourceKeys - options:NSDirectoryEnumerationSkipsHiddenFiles - errorHandler:NULL]; - - NSDate *expirationDate = [NSDate dateWithTimeIntervalSinceNow:-self.config.maxCacheAge]; - NSMutableDictionary *> *cacheFiles = [NSMutableDictionary dictionary]; - NSUInteger currentCacheSize = 0; - - // Enumerate all of the files in the cache directory. This loop has two purposes: - // - // 1. Removing files that are older than the expiration date. - // 2. Storing file attributes for the size-based cleanup pass. - NSMutableArray *urlsToDelete = [[NSMutableArray alloc] init]; - for (NSURL *fileURL in fileEnumerator) { - NSError *error; - NSDictionary *resourceValues = [fileURL resourceValuesForKeys:resourceKeys error:&error]; - - // Skip directories and errors. - if (error || !resourceValues || [resourceValues[NSURLIsDirectoryKey] boolValue]) { - continue; - } - - // Remove files that are older than the expiration date; - NSDate *modificationDate = resourceValues[NSURLContentModificationDateKey]; - if ([[modificationDate laterDate:expirationDate] isEqualToDate:expirationDate]) { - [urlsToDelete addObject:fileURL]; - continue; - } - - // Store a reference to this file and account for its total size. - NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey]; - currentCacheSize += totalAllocatedSize.unsignedIntegerValue; - cacheFiles[fileURL] = resourceValues; - } - - for (NSURL *fileURL in urlsToDelete) { - [_fileManager removeItemAtURL:fileURL error:nil]; - } - - // If our remaining disk cache exceeds a configured maximum size, perform a second - // size-based cleanup pass. We delete the oldest files first. - if (self.config.maxCacheSize > 0 && currentCacheSize > self.config.maxCacheSize) { - // Target half of our maximum cache size for this cleanup pass. - const NSUInteger desiredCacheSize = self.config.maxCacheSize / 2; - - // Sort the remaining cache files by their last modification time (oldest first). - NSArray *sortedFiles = [cacheFiles keysSortedByValueWithOptions:NSSortConcurrent - usingComparator:^NSComparisonResult(id obj1, id obj2) { - return [obj1[NSURLContentModificationDateKey] compare:obj2[NSURLContentModificationDateKey]]; - }]; - - // Delete files until we fall below our desired cache size. - for (NSURL *fileURL in sortedFiles) { - if ([_fileManager removeItemAtURL:fileURL error:nil]) { - NSDictionary *resourceValues = cacheFiles[fileURL]; - NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey]; - currentCacheSize -= totalAllocatedSize.unsignedIntegerValue; - - if (currentCacheSize < desiredCacheSize) { - break; - } - } - } - } + [self.diskCache removeExpiredData]; if (completionBlock) { dispatch_async(dispatch_get_main_queue(), ^{ completionBlock(); @@ -562,8 +527,21 @@ - (void)deleteOldFilesWithCompletionBlock:(nullable SDWebImageNoParamsBlock)comp }); } +#pragma mark - UIApplicationWillTerminateNotification + +#if SD_UIKIT || SD_MAC +- (void)applicationWillTerminate:(NSNotification *)notification { + [self deleteOldFilesWithCompletionBlock:nil]; +} +#endif + +#pragma mark - UIApplicationDidEnterBackgroundNotification + #if SD_UIKIT -- (void)backgroundDeleteOldFiles { +- (void)applicationDidEnterBackground:(NSNotification *)notification { + if (!self.config.shouldRemoveExpiredDataWhenEnterBackground) { + return; + } Class UIApplicationClass = NSClassFromString(@"UIApplication"); if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { return; @@ -586,47 +564,26 @@ - (void)backgroundDeleteOldFiles { #pragma mark - Cache Info -- (NSUInteger)getSize { +- (NSUInteger)totalDiskSize { __block NSUInteger size = 0; dispatch_sync(self.ioQueue, ^{ - NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath]; - for (NSString *fileName in fileEnumerator) { - NSString *filePath = [self.diskCachePath stringByAppendingPathComponent:fileName]; - NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil]; - size += [attrs fileSize]; - } + size = [self.diskCache totalSize]; }); return size; } -- (NSUInteger)getDiskCount { +- (NSUInteger)totalDiskCount { __block NSUInteger count = 0; dispatch_sync(self.ioQueue, ^{ - NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath]; - count = fileEnumerator.allObjects.count; + count = [self.diskCache totalCount]; }); return count; } -- (void)calculateSizeWithCompletionBlock:(nullable SDWebImageCalculateSizeBlock)completionBlock { - NSURL *diskCacheURL = [NSURL fileURLWithPath:self.diskCachePath isDirectory:YES]; - +- (void)calculateSizeWithCompletionBlock:(nullable SDImageCacheCalculateSizeBlock)completionBlock { dispatch_async(self.ioQueue, ^{ - NSUInteger fileCount = 0; - NSUInteger totalSize = 0; - - NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtURL:diskCacheURL - includingPropertiesForKeys:@[NSFileSize] - options:NSDirectoryEnumerationSkipsHiddenFiles - errorHandler:NULL]; - - for (NSURL *fileURL in fileEnumerator) { - NSNumber *fileSize; - [fileURL getResourceValue:&fileSize forKey:NSURLFileSizeKey error:NULL]; - totalSize += fileSize.unsignedIntegerValue; - fileCount += 1; - } - + NSUInteger fileCount = [self.diskCache totalCount]; + NSUInteger totalSize = [self.diskCache totalSize]; if (completionBlock) { dispatch_async(dispatch_get_main_queue(), ^{ completionBlock(fileCount, totalSize); @@ -635,5 +592,167 @@ - (void)calculateSizeWithCompletionBlock:(nullable SDWebImageCalculateSizeBlock) }); } +#pragma mark - Helper ++ (SDWebImageOptions)imageOptionsFromCacheOptions:(SDImageCacheOptions)cacheOptions { + SDWebImageOptions options = 0; + if (cacheOptions & SDImageCacheScaleDownLargeImages) options |= SDWebImageScaleDownLargeImages; + if (cacheOptions & SDImageCacheDecodeFirstFrameOnly) options |= SDWebImageDecodeFirstFrameOnly; + if (cacheOptions & SDImageCachePreloadAllFrames) options |= SDWebImagePreloadAllFrames; + if (cacheOptions & SDImageCacheAvoidDecodeImage) options |= SDWebImageAvoidDecodeImage; + + return options; +} + +@end + +@implementation SDImageCache (SDImageCache) + +#pragma mark - SDImageCache + +- (id)queryImageForKey:(NSString *)key options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context completion:(nullable SDImageCacheQueryCompletionBlock)completionBlock { + SDImageCacheOptions cacheOptions = 0; + if (options & SDWebImageQueryMemoryData) cacheOptions |= SDImageCacheQueryMemoryData; + if (options & SDWebImageQueryMemoryDataSync) cacheOptions |= SDImageCacheQueryMemoryDataSync; + if (options & SDWebImageQueryDiskDataSync) cacheOptions |= SDImageCacheQueryDiskDataSync; + if (options & SDWebImageScaleDownLargeImages) cacheOptions |= SDImageCacheScaleDownLargeImages; + if (options & SDWebImageAvoidDecodeImage) cacheOptions |= SDImageCacheAvoidDecodeImage; + if (options & SDWebImageDecodeFirstFrameOnly) cacheOptions |= SDImageCacheDecodeFirstFrameOnly; + if (options & SDWebImagePreloadAllFrames) cacheOptions |= SDImageCachePreloadAllFrames; + return [self queryCacheOperationForKey:key options:cacheOptions context:context done:completionBlock]; +} + +- (void)storeImage:(UIImage *)image imageData:(NSData *)imageData forKey:(nullable NSString *)key cacheType:(SDImageCacheType)cacheType completion:(nullable SDWebImageNoParamsBlock)completionBlock { + switch (cacheType) { + case SDImageCacheTypeNone: { + [self storeImage:image imageData:imageData forKey:key toMemory:NO toDisk:NO completion:completionBlock]; + } + break; + case SDImageCacheTypeMemory: { + [self storeImage:image imageData:imageData forKey:key toMemory:YES toDisk:NO completion:completionBlock]; + } + break; + case SDImageCacheTypeDisk: { + [self storeImage:image imageData:imageData forKey:key toMemory:NO toDisk:YES completion:completionBlock]; + } + break; + case SDImageCacheTypeAll: { + [self storeImage:image imageData:imageData forKey:key toMemory:YES toDisk:YES completion:completionBlock]; + } + break; + default: { + if (completionBlock) { + completionBlock(); + } + } + break; + } +} + +- (void)removeImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(nullable SDWebImageNoParamsBlock)completionBlock { + switch (cacheType) { + case SDImageCacheTypeNone: { + [self removeImageForKey:key fromMemory:NO fromDisk:NO withCompletion:completionBlock]; + } + break; + case SDImageCacheTypeMemory: { + [self removeImageForKey:key fromMemory:YES fromDisk:NO withCompletion:completionBlock]; + } + break; + case SDImageCacheTypeDisk: { + [self removeImageForKey:key fromMemory:NO fromDisk:YES withCompletion:completionBlock]; + } + break; + case SDImageCacheTypeAll: { + [self removeImageForKey:key fromMemory:YES fromDisk:YES withCompletion:completionBlock]; + } + break; + default: { + if (completionBlock) { + completionBlock(); + } + } + break; + } +} + +- (void)containsImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(nullable SDImageCacheContainsCompletionBlock)completionBlock { + switch (cacheType) { + case SDImageCacheTypeNone: { + if (completionBlock) { + completionBlock(SDImageCacheTypeNone); + } + } + break; + case SDImageCacheTypeMemory: { + BOOL isInMemoryCache = ([self imageFromMemoryCacheForKey:key] != nil); + if (completionBlock) { + completionBlock(isInMemoryCache ? SDImageCacheTypeMemory : SDImageCacheTypeNone); + } + } + break; + case SDImageCacheTypeDisk: { + [self diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) { + if (completionBlock) { + completionBlock(isInDiskCache ? SDImageCacheTypeDisk : SDImageCacheTypeNone); + } + }]; + } + break; + case SDImageCacheTypeAll: { + BOOL isInMemoryCache = ([self imageFromMemoryCacheForKey:key] != nil); + if (isInMemoryCache) { + if (completionBlock) { + completionBlock(SDImageCacheTypeMemory); + } + return; + } + [self diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) { + if (completionBlock) { + completionBlock(isInDiskCache ? SDImageCacheTypeDisk : SDImageCacheTypeNone); + } + }]; + } + break; + default: + if (completionBlock) { + completionBlock(SDImageCacheTypeNone); + } + break; + } +} + +- (void)clearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock { + switch (cacheType) { + case SDImageCacheTypeNone: { + if (completionBlock) { + completionBlock(); + } + } + break; + case SDImageCacheTypeMemory: { + [self clearMemory]; + if (completionBlock) { + completionBlock(); + } + } + break; + case SDImageCacheTypeDisk: { + [self clearDiskOnCompletion:completionBlock]; + } + break; + case SDImageCacheTypeAll: { + [self clearMemory]; + [self clearDiskOnCompletion:completionBlock]; + } + break; + default: { + if (completionBlock) { + completionBlock(); + } + } + break; + } +} + @end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCacheConfig.h b/Pods/SDWebImage/SDWebImage/SDImageCacheConfig.h index fd83527d..97bf37e1 100644 --- a/Pods/SDWebImage/SDWebImage/SDImageCacheConfig.h +++ b/Pods/SDWebImage/SDWebImage/SDImageCacheConfig.h @@ -1,40 +1,125 @@ -// -// SDImageCacheConfig.h -// SDWebImage -// -// Created by Bogdan on 09/09/16. -// Copyright © 2016 Dailymotion. All rights reserved. -// +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ #import #import "SDWebImageCompat.h" -@interface SDImageCacheConfig : NSObject +typedef NS_ENUM(NSUInteger, SDImageCacheConfigExpireType) { + /** + * When the image is accessed it will update this value + */ + SDImageCacheConfigExpireTypeAccessDate, + /** + * The image was obtained from the disk cache (Default) + */ + SDImageCacheConfigExpireTypeModificationDate +}; + +// This class conform to NSCopying, make sure to add the property in `copyWithZone:` as well. +@interface SDImageCacheConfig : NSObject /** - * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. - * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. + Gets the default cache config used for shared instance or initialization when it does not provide any cache config. Such as `SDImageCache.sharedImageCache`. + @note You can modify the property on default cache config, which can be used for later created cache instance. The already created cache instance does not get affected. */ -@property (assign, nonatomic) BOOL shouldDecompressImages; +@property (nonatomic, class, readonly, nonnull) SDImageCacheConfig *defaultCacheConfig; /** - * disable iCloud backup [defaults to YES] + * Whether or not to disable iCloud backup + * Defaults to YES. */ @property (assign, nonatomic) BOOL shouldDisableiCloud; /** - * use memory cache [defaults to YES] + * Whether or not to use memory cache + * @note When the memory cache is disabled, the weak memory cache will also be disabled. + * Defaults to YES. */ @property (assign, nonatomic) BOOL shouldCacheImagesInMemory; +/* + * The option to control weak memory cache for images. When enable, `SDImageCache`'s memory cache will use a weak maptable to store the image at the same time when it stored to memory, and get removed at the same time. + * However when memory warning is triggered, since the weak maptable does not hold a strong reference to image instance, even when the memory cache itself is purged, some images which are held strongly by UIImageViews or other live instances can be recovered again, to avoid later re-query from disk cache or network. This may be helpful for the case, for example, when app enter background and memory is purged, cause cell flashing after re-enter foreground. + * Defautls to YES. You can change this option dynamically. + */ +@property (assign, nonatomic) BOOL shouldUseWeakMemoryCache; + +/** + * Whether or not to remove the expired disk data when application entering the background. (Not works for macOS) + * Defaults to YES. + */ +@property (assign, nonatomic) BOOL shouldRemoveExpiredDataWhenEnterBackground; + +/** + * The reading options while reading cache from disk. + * Defaults to 0. You can set this to `NSDataReadingMappedIfSafe` to improve performance. + */ +@property (assign, nonatomic) NSDataReadingOptions diskCacheReadingOptions; + +/** + * The writing options while writing cache to disk. + * Defaults to `NSDataWritingAtomic`. You can set this to `NSDataWritingWithoutOverwriting` to prevent overwriting an existing file. + */ +@property (assign, nonatomic) NSDataWritingOptions diskCacheWritingOptions; + +/** + * The maximum length of time to keep an image in the disk cache, in seconds. + * Setting this to a negative value means no expiring. + * Setting this to zero means that all cached files would be removed when do expiration check. + * Defaults to 1 weak. + */ +@property (assign, nonatomic) NSTimeInterval maxDiskAge; + +/** + * The maximum size of the disk cache, in bytes. + * Defaults to 0. Which means there is no cache size limit. + */ +@property (assign, nonatomic) NSUInteger maxDiskSize; + +/** + * The maximum "total cost" of the in-memory image cache. The cost function is the bytes size held in memory. + * @note The memory cost is bytes size in memory, but not simple pixels count. For common ARGB8888 image, one pixel is 4 bytes (32 bits). + * Defaults to 0. Which means there is no memory cost limit. + */ +@property (assign, nonatomic) NSUInteger maxMemoryCost; + +/** + * The maximum number of objects in-memory image cache should hold. + * Defaults to 0. Which means there is no memory count limit. + */ +@property (assign, nonatomic) NSUInteger maxMemoryCount; + +/* + * The attribute which the clear cache will be checked against when clearing the disk cache + * Default is Modified Date + */ +@property (assign, nonatomic) SDImageCacheConfigExpireType diskCacheExpireType; + +/** + * The custom file manager for disk cache. Pass nil to let disk cache choose the proper file manager. + * Defaults to nil. + * @note This value does not support dynamic changes. Which means further modification on this value after cache initlized has no effect. + * @note Since `NSFileManager` does not support `NSCopying`. We just pass this by reference during copying. So it's not recommend to set this value on `defaultCacheConfig`. + */ +@property (strong, nonatomic, nullable) NSFileManager *fileManager; + /** - * The maximum length of time to keep an image in the cache, in seconds + * The custom memory cache class. Provided class instance must conform to `SDMemoryCache` protocol to allow usage. + * Defaults to built-in `SDMemoryCache` class. + * @note This value does not support dynamic changes. Which means further modification on this value after cache initlized has no effect. */ -@property (assign, nonatomic) NSInteger maxCacheAge; +@property (assign, nonatomic, nonnull) Class memoryCacheClass; /** - * The maximum size of the cache, in bytes. + * The custom disk cache class. Provided class instance must conform to `SDDiskCache` protocol to allow usage. + * Defaults to built-in `SDDiskCache` class. + * @note This value does not support dynamic changes. Which means further modification on this value after cache initlized has no effect. */ -@property (assign, nonatomic) NSUInteger maxCacheSize; +@property (assign ,nonatomic, nonnull) Class diskCacheClass; @end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCacheConfig.m b/Pods/SDWebImage/SDWebImage/SDImageCacheConfig.m index c154265a..40a53348 100644 --- a/Pods/SDWebImage/SDWebImage/SDImageCacheConfig.m +++ b/Pods/SDWebImage/SDWebImage/SDImageCacheConfig.m @@ -1,26 +1,63 @@ -// -// SDImageCacheConfig.m -// SDWebImage -// -// Created by Bogdan on 09/09/16. -// Copyright © 2016 Dailymotion. All rights reserved. -// +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ #import "SDImageCacheConfig.h" +#import "SDMemoryCache.h" +#import "SDDiskCache.h" -static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week +static SDImageCacheConfig *_defaultCacheConfig; +static const NSInteger kDefaultCacheMaxDiskAge = 60 * 60 * 24 * 7; // 1 week @implementation SDImageCacheConfig ++ (SDImageCacheConfig *)defaultCacheConfig { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _defaultCacheConfig = [SDImageCacheConfig new]; + }); + return _defaultCacheConfig; +} + - (instancetype)init { if (self = [super init]) { - _shouldDecompressImages = YES; _shouldDisableiCloud = YES; _shouldCacheImagesInMemory = YES; - _maxCacheAge = kDefaultCacheMaxCacheAge; - _maxCacheSize = 0; + _shouldUseWeakMemoryCache = YES; + _shouldRemoveExpiredDataWhenEnterBackground = YES; + _diskCacheReadingOptions = 0; + _diskCacheWritingOptions = NSDataWritingAtomic; + _maxDiskAge = kDefaultCacheMaxDiskAge; + _maxDiskSize = 0; + _diskCacheExpireType = SDImageCacheConfigExpireTypeModificationDate; + _memoryCacheClass = [SDMemoryCache class]; + _diskCacheClass = [SDDiskCache class]; } return self; } +- (id)copyWithZone:(NSZone *)zone { + SDImageCacheConfig *config = [[[self class] allocWithZone:zone] init]; + config.shouldDisableiCloud = self.shouldDisableiCloud; + config.shouldCacheImagesInMemory = self.shouldCacheImagesInMemory; + config.shouldUseWeakMemoryCache = self.shouldUseWeakMemoryCache; + config.shouldRemoveExpiredDataWhenEnterBackground = self.shouldRemoveExpiredDataWhenEnterBackground; + config.diskCacheReadingOptions = self.diskCacheReadingOptions; + config.diskCacheWritingOptions = self.diskCacheWritingOptions; + config.maxDiskAge = self.maxDiskAge; + config.maxDiskSize = self.maxDiskSize; + config.maxMemoryCost = self.maxMemoryCost; + config.maxMemoryCount = self.maxMemoryCount; + config.diskCacheExpireType = self.diskCacheExpireType; + config.fileManager = self.fileManager; // NSFileManager does not conform to NSCopying, just pass the reference + config.memoryCacheClass = self.memoryCacheClass; + config.diskCacheClass = self.diskCacheClass; + + return config; +} + @end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCacheDefine.h b/Pods/SDWebImage/SDWebImage/SDImageCacheDefine.h new file mode 100644 index 00000000..8b09e963 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageCacheDefine.h @@ -0,0 +1,124 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" +#import "SDWebImageOperation.h" +#import "SDWebImageDefine.h" + +typedef NS_ENUM(NSInteger, SDImageCacheType) { + /** + * For query and contains op in response, means the image isn't available in the image cache + * For op in request, this type is not available and take no effect. + */ + SDImageCacheTypeNone, + /** + * For query and contains op in response, means the image was obtained from the disk cache. + * For op in request, means process only disk cache. + */ + SDImageCacheTypeDisk, + /** + * For query and contains op in response, means the image was obtained from the memory cache. + * For op in request, means process only memory cache. + */ + SDImageCacheTypeMemory, + /** + * For query and contains op in response, this type is not available and take no effect. + * For op in request, means process both memory cache and disk cache. + */ + SDImageCacheTypeAll +}; + +typedef void(^SDImageCacheCheckCompletionBlock)(BOOL isInCache); +typedef void(^SDImageCacheCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize); +typedef NSString * _Nullable (^SDImageCacheAdditionalCachePathBlock)(NSString * _Nonnull key); +typedef void(^SDImageCacheQueryCompletionBlock)(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType); +typedef void(^SDImageCacheContainsCompletionBlock)(SDImageCacheType containsCacheType); + +/** + This is the built-in decoding process for image query from cache. + @note If you want to implement your custom loader with `queryImageForKey:options:context:completion:` API, but also want to keep compatible with SDWebImage's behavior, you'd better use this to produce image. + + @param imageData The image data from the cache. Should not be nil + @param cacheKey The image cache key from the input. Should not be nil + @param options The options arg from the input + @param context The context arg from the input + @return The decoded image for current image data query from cache + */ +FOUNDATION_EXPORT UIImage * _Nullable SDImageCacheDecodeImageData(NSData * _Nonnull imageData, NSString * _Nonnull cacheKey, SDWebImageOptions options, SDWebImageContext * _Nullable context); + +/** + This is the image cache protocol to provide custom image cache for `SDWebImageManager`. + Though the best practice to custom image cache, is to write your own class which conform `SDMemoryCache` or `SDDiskCache` protocol for `SDImageCache` class (See more on `SDImageCacheConfig.memoryCacheClass & SDImageCacheConfig.diskCacheClass`). + However, if your own cache implementation contains more advanced feature beyond `SDImageCache` itself, you can consider to provide this instead. For example, you can even use a cache manager like `SDImageCachesManager` to register multiple caches. + */ +@protocol SDImageCache + +@required +/** + Query the cached image from image cache for given key. The operation can be used to cancel the query. + If image is cached in memory, completion is called synchronously, else aynchronously and depends on the options arg (See `SDWebImageQueryDiskSync`) + + @param key The image cache key + @param options A mask to specify options to use for this query + @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + @param completionBlock The completion block. Will not get called if the operation is cancelled + @return The operation for this query + */ +- (nullable id)queryImageForKey:(nullable NSString *)key + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + completion:(nullable SDImageCacheQueryCompletionBlock)completionBlock; + +/** + Store the image into image cache for the given key. If cache type is memory only, completion is called synchronously, else aynchronously. + + @param image The image to store + @param imageData The image data to be used for disk storage + @param key The image cache key + @param cacheType The image store op cache type + @param completionBlock A block executed after the operation is finished + */ +- (void)storeImage:(nullable UIImage *)image + imageData:(nullable NSData *)imageData + forKey:(nullable NSString *)key + cacheType:(SDImageCacheType)cacheType + completion:(nullable SDWebImageNoParamsBlock)completionBlock; + +/** + Remove the image from image cache for the given key. If cache type is memory only, completion is called synchronously, else aynchronously. + + @param key The image cache key + @param cacheType The image remove op cache type + @param completionBlock A block executed after the operation is finished + */ +- (void)removeImageForKey:(nullable NSString *)key + cacheType:(SDImageCacheType)cacheType + completion:(nullable SDWebImageNoParamsBlock)completionBlock; + +/** + Check if image cache contains the image for the given key (does not load the image). If image is cached in memory, completion is called synchronously, else aynchronously. + + @param key The image cache key + @param cacheType The image contains op cache type + @param completionBlock A block executed after the operation is finished. + */ +- (void)containsImageForKey:(nullable NSString *)key + cacheType:(SDImageCacheType)cacheType + completion:(nullable SDImageCacheContainsCompletionBlock)completionBlock; + +/** + Clear all the cached images for image cache. If cache type is memory only, completion is called synchronously, else aynchronously. + + @param cacheType The image clear op cache type + @param completionBlock A block executed after the operation is finished + */ +- (void)clearWithCacheType:(SDImageCacheType)cacheType + completion:(nullable SDWebImageNoParamsBlock)completionBlock; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCacheDefine.m b/Pods/SDWebImage/SDWebImage/SDImageCacheDefine.m new file mode 100644 index 00000000..423e0583 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageCacheDefine.m @@ -0,0 +1,63 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageCacheDefine.h" +#import "SDImageCodersManager.h" +#import "SDImageCoderHelper.h" +#import "SDAnimatedImage.h" +#import "UIImage+Metadata.h" + +UIImage * _Nullable SDImageCacheDecodeImageData(NSData * _Nonnull imageData, NSString * _Nonnull cacheKey, SDWebImageOptions options, SDWebImageContext * _Nullable context) { + UIImage *image; + BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly; + NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor]; + CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey); + if (scale < 1) { + scale = 1; + } + SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)}; + if (context) { + SDImageCoderMutableOptions *mutableCoderOptions = [coderOptions mutableCopy]; + [mutableCoderOptions setValue:context forKey:SDImageCoderWebImageContext]; + coderOptions = [mutableCoderOptions copy]; + } + + if (!decodeFirstFrame) { + Class animatedImageClass = context[SDWebImageContextAnimatedImageClass]; + // check whether we should use `SDAnimatedImage` + if ([animatedImageClass isSubclassOfClass:[UIImage class]] && [animatedImageClass conformsToProtocol:@protocol(SDAnimatedImage)]) { + image = [[animatedImageClass alloc] initWithData:imageData scale:scale options:coderOptions]; + if (options & SDWebImagePreloadAllFrames && [image respondsToSelector:@selector(preloadAllFrames)]) { + [((id)image) preloadAllFrames]; + } + } + } + if (!image) { + image = [[SDImageCodersManager sharedManager] decodedImageWithData:imageData options:coderOptions]; + } + if (image) { + BOOL shouldDecode = (options & SDWebImageAvoidDecodeImage) == 0; + if ([image conformsToProtocol:@protocol(SDAnimatedImage)]) { + // `SDAnimatedImage` do not decode + shouldDecode = NO; + } else if (image.sd_isAnimated) { + // animated image do not decode + shouldDecode = NO; + } + if (shouldDecode) { + BOOL shouldScaleDown = options & SDWebImageScaleDownLargeImages; + if (shouldScaleDown) { + image = [SDImageCoderHelper decodedAndScaledDownImageWithImage:image limitBytes:0]; + } else { + image = [SDImageCoderHelper decodedImageWithImage:image]; + } + } + } + + return image; +} diff --git a/Pods/SDWebImage/SDWebImage/SDImageCachesManager.h b/Pods/SDWebImage/SDWebImage/SDImageCachesManager.h new file mode 100644 index 00000000..db6a9a43 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageCachesManager.h @@ -0,0 +1,77 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDImageCacheDefine.h" + +typedef NS_ENUM(NSUInteger, SDImageCachesManagerOperationPolicy) { + SDImageCachesManagerOperationPolicySerial, // process all caches serially (from the highest priority to the lowest priority cache by order) + SDImageCachesManagerOperationPolicyConcurrent, // process all caches concurrently + SDImageCachesManagerOperationPolicyHighestOnly, // process the highest priority cache only + SDImageCachesManagerOperationPolicyLowestOnly // process the lowest priority cache only +}; + +@interface SDImageCachesManager : NSObject + +/** + Returns the global shared caches manager instance. By default we will set [`SDImageCache.sharedImageCache`] into the caches array. + */ +@property (nonatomic, class, readonly, nonnull) SDImageCachesManager *sharedManager; + +// These are op policy for cache manager. + +/** + Operation policy for query op. + Defaults to `Serial`, means query all caches serially (one completion called then next begin) until one cache query success (`image` != nil). + */ +@property (nonatomic, assign) SDImageCachesManagerOperationPolicy queryOperationPolicy; + +/** + Operation policy for store op. + Defaults to `HighestOnly`, means store to the highest priority cache only. + */ +@property (nonatomic, assign) SDImageCachesManagerOperationPolicy storeOperationPolicy; + +/** + Operation policy for remove op. + Defaults to `Concurrent`, means remove all caches concurrently. + */ +@property (nonatomic, assign) SDImageCachesManagerOperationPolicy removeOperationPolicy; + +/** + Operation policy for contains op. + Defaults to `Serial`, means check all caches serially (one completion called then next begin) until one cache check success (`containsCacheType` != None). + */ +@property (nonatomic, assign) SDImageCachesManagerOperationPolicy containsOperationPolicy; + +/** + Operation policy for clear op. + Defaults to `Concurrent`, means clear all caches concurrently. + */ +@property (nonatomic, assign) SDImageCachesManagerOperationPolicy clearOperationPolicy; + +/** + All caches in caches manager. The caches array is a priority queue, which means the later added cache will have the highest priority + */ +@property (nonatomic, copy, nullable) NSArray> *caches; + +/** + Add a new cache to the end of caches array. Which has the highest priority. + + @param cache cache + */ +- (void)addCache:(nonnull id)cache; + +/** + Remove a cache in the caches array. + + @param cache cache + */ +- (void)removeCache:(nonnull id)cache; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCachesManager.m b/Pods/SDWebImage/SDWebImage/SDImageCachesManager.m new file mode 100644 index 00000000..e8d8d319 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageCachesManager.m @@ -0,0 +1,552 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageCachesManager.h" +#import "SDImageCachesManagerOperation.h" +#import "SDImageCache.h" + +@interface SDImageCachesManager () + +@property (nonatomic, strong, nonnull) dispatch_semaphore_t cachesLock; + +@end + +@implementation SDImageCachesManager +{ + NSMutableArray> *_imageCaches; +} + ++ (SDImageCachesManager *)sharedManager { + static dispatch_once_t onceToken; + static SDImageCachesManager *manager; + dispatch_once(&onceToken, ^{ + manager = [[SDImageCachesManager alloc] init]; + }); + return manager; +} + +- (instancetype)init { + self = [super init]; + if (self) { + self.queryOperationPolicy = SDImageCachesManagerOperationPolicySerial; + self.storeOperationPolicy = SDImageCachesManagerOperationPolicyHighestOnly; + self.removeOperationPolicy = SDImageCachesManagerOperationPolicyConcurrent; + self.containsOperationPolicy = SDImageCachesManagerOperationPolicySerial; + self.clearOperationPolicy = SDImageCachesManagerOperationPolicyConcurrent; + // initialize with default image caches + _imageCaches = [NSMutableArray arrayWithObject:[SDImageCache sharedImageCache]]; + _cachesLock = dispatch_semaphore_create(1); + } + return self; +} + +- (NSArray> *)caches { + SD_LOCK(self.cachesLock); + NSArray> *caches = [_imageCaches copy]; + SD_UNLOCK(self.cachesLock); + return caches; +} + +- (void)setCaches:(NSArray> *)caches { + SD_LOCK(self.cachesLock); + [_imageCaches removeAllObjects]; + if (caches.count) { + [_imageCaches addObjectsFromArray:caches]; + } + SD_UNLOCK(self.cachesLock); +} + +#pragma mark - Cache IO operations + +- (void)addCache:(id)cache { + if (![cache conformsToProtocol:@protocol(SDImageCache)]) { + return; + } + SD_LOCK(self.cachesLock); + [_imageCaches addObject:cache]; + SD_UNLOCK(self.cachesLock); +} + +- (void)removeCache:(id)cache { + if (![cache conformsToProtocol:@protocol(SDImageCache)]) { + return; + } + SD_LOCK(self.cachesLock); + [_imageCaches removeObject:cache]; + SD_UNLOCK(self.cachesLock); +} + +#pragma mark - SDImageCache + +- (id)queryImageForKey:(NSString *)key options:(SDWebImageOptions)options context:(SDWebImageContext *)context completion:(SDImageCacheQueryCompletionBlock)completionBlock { + if (!key) { + return nil; + } + NSArray> *caches = self.caches; + NSUInteger count = caches.count; + if (count == 0) { + return nil; + } else if (count == 1) { + return [caches.firstObject queryImageForKey:key options:options context:context completion:completionBlock]; + } + switch (self.queryOperationPolicy) { + case SDImageCachesManagerOperationPolicyHighestOnly: { + id cache = caches.lastObject; + return [cache queryImageForKey:key options:options context:context completion:completionBlock]; + } + break; + case SDImageCachesManagerOperationPolicyLowestOnly: { + id cache = caches.firstObject; + return [cache queryImageForKey:key options:options context:context completion:completionBlock]; + } + break; + case SDImageCachesManagerOperationPolicyConcurrent: { + SDImageCachesManagerOperation *operation = [SDImageCachesManagerOperation new]; + [operation beginWithTotalCount:caches.count]; + [self concurrentQueryImageForKey:key options:options context:context completion:completionBlock enumerator:caches.reverseObjectEnumerator operation:operation]; + return operation; + } + break; + case SDImageCachesManagerOperationPolicySerial: { + SDImageCachesManagerOperation *operation = [SDImageCachesManagerOperation new]; + [operation beginWithTotalCount:caches.count]; + [self serialQueryImageForKey:key options:options context:context completion:completionBlock enumerator:caches.reverseObjectEnumerator operation:operation]; + return operation; + } + break; + default: + return nil; + break; + } +} + +- (void)storeImage:(UIImage *)image imageData:(NSData *)imageData forKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock { + if (!key) { + return; + } + NSArray> *caches = self.caches; + NSUInteger count = caches.count; + if (count == 0) { + return; + } else if (count == 1) { + [caches.firstObject storeImage:image imageData:imageData forKey:key cacheType:cacheType completion:completionBlock]; + return; + } + switch (self.storeOperationPolicy) { + case SDImageCachesManagerOperationPolicyHighestOnly: { + id cache = caches.lastObject; + [cache storeImage:image imageData:imageData forKey:key cacheType:cacheType completion:completionBlock]; + } + break; + case SDImageCachesManagerOperationPolicyLowestOnly: { + id cache = caches.firstObject; + [cache storeImage:image imageData:imageData forKey:key cacheType:cacheType completion:completionBlock]; + } + break; + case SDImageCachesManagerOperationPolicyConcurrent: { + SDImageCachesManagerOperation *operation = [SDImageCachesManagerOperation new]; + [operation beginWithTotalCount:caches.count]; + [self concurrentStoreImage:image imageData:imageData forKey:key cacheType:cacheType completion:completionBlock enumerator:caches.reverseObjectEnumerator operation:operation]; + } + break; + case SDImageCachesManagerOperationPolicySerial: { + [self serialStoreImage:image imageData:imageData forKey:key cacheType:cacheType completion:completionBlock enumerator:caches.reverseObjectEnumerator]; + } + break; + default: + break; + } +} + +- (void)removeImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock { + if (!key) { + return; + } + NSArray> *caches = self.caches; + NSUInteger count = caches.count; + if (count == 0) { + return; + } else if (count == 1) { + [caches.firstObject removeImageForKey:key cacheType:cacheType completion:completionBlock]; + return; + } + switch (self.removeOperationPolicy) { + case SDImageCachesManagerOperationPolicyHighestOnly: { + id cache = caches.lastObject; + [cache removeImageForKey:key cacheType:cacheType completion:completionBlock]; + } + break; + case SDImageCachesManagerOperationPolicyLowestOnly: { + id cache = caches.firstObject; + [cache removeImageForKey:key cacheType:cacheType completion:completionBlock]; + } + break; + case SDImageCachesManagerOperationPolicyConcurrent: { + SDImageCachesManagerOperation *operation = [SDImageCachesManagerOperation new]; + [operation beginWithTotalCount:caches.count]; + [self concurrentRemoveImageForKey:key cacheType:cacheType completion:completionBlock enumerator:caches.reverseObjectEnumerator operation:operation]; + } + break; + case SDImageCachesManagerOperationPolicySerial: { + [self serialRemoveImageForKey:key cacheType:cacheType completion:completionBlock enumerator:caches.reverseObjectEnumerator]; + } + break; + default: + break; + } +} + +- (void)containsImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDImageCacheContainsCompletionBlock)completionBlock { + if (!key) { + return; + } + NSArray> *caches = self.caches; + NSUInteger count = caches.count; + if (count == 0) { + return; + } else if (count == 1) { + [caches.firstObject containsImageForKey:key cacheType:cacheType completion:completionBlock]; + return; + } + switch (self.clearOperationPolicy) { + case SDImageCachesManagerOperationPolicyHighestOnly: { + id cache = caches.lastObject; + [cache containsImageForKey:key cacheType:cacheType completion:completionBlock]; + } + break; + case SDImageCachesManagerOperationPolicyLowestOnly: { + id cache = caches.firstObject; + [cache containsImageForKey:key cacheType:cacheType completion:completionBlock]; + } + break; + case SDImageCachesManagerOperationPolicyConcurrent: { + SDImageCachesManagerOperation *operation = [SDImageCachesManagerOperation new]; + [operation beginWithTotalCount:caches.count]; + [self concurrentContainsImageForKey:key cacheType:cacheType completion:completionBlock enumerator:caches.reverseObjectEnumerator operation:operation]; + } + break; + case SDImageCachesManagerOperationPolicySerial: { + SDImageCachesManagerOperation *operation = [SDImageCachesManagerOperation new]; + [operation beginWithTotalCount:caches.count]; + [self serialContainsImageForKey:key cacheType:cacheType completion:completionBlock enumerator:caches.reverseObjectEnumerator operation:operation]; + } + break; + default: + break; + } +} + +- (void)clearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock { + NSArray> *caches = self.caches; + NSUInteger count = caches.count; + if (count == 0) { + return; + } else if (count == 1) { + [caches.firstObject clearWithCacheType:cacheType completion:completionBlock]; + return; + } + switch (self.clearOperationPolicy) { + case SDImageCachesManagerOperationPolicyHighestOnly: { + id cache = caches.lastObject; + [cache clearWithCacheType:cacheType completion:completionBlock]; + } + break; + case SDImageCachesManagerOperationPolicyLowestOnly: { + id cache = caches.firstObject; + [cache clearWithCacheType:cacheType completion:completionBlock]; + } + break; + case SDImageCachesManagerOperationPolicyConcurrent: { + SDImageCachesManagerOperation *operation = [SDImageCachesManagerOperation new]; + [operation beginWithTotalCount:caches.count]; + [self concurrentClearWithCacheType:cacheType completion:completionBlock enumerator:caches.reverseObjectEnumerator operation:operation]; + } + break; + case SDImageCachesManagerOperationPolicySerial: { + [self serialClearWithCacheType:cacheType completion:completionBlock enumerator:caches.reverseObjectEnumerator]; + } + break; + default: + break; + } +} + +#pragma mark - Concurrent Operation + +- (void)concurrentQueryImageForKey:(NSString *)key options:(SDWebImageOptions)options context:(SDWebImageContext *)context completion:(SDImageCacheQueryCompletionBlock)completionBlock enumerator:(NSEnumerator> *)enumerator operation:(SDImageCachesManagerOperation *)operation { + NSParameterAssert(enumerator); + NSParameterAssert(operation); + for (id cache in enumerator) { + [cache queryImageForKey:key options:options context:context completion:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) { + if (operation.isCancelled) { + // Cancelled + return; + } + if (operation.isFinished) { + // Finished + return; + } + [operation completeOne]; + if (image) { + // Success + [operation done]; + if (completionBlock) { + completionBlock(image, data, cacheType); + } + return; + } + if (operation.pendingCount == 0) { + // Complete + [operation done]; + if (completionBlock) { + completionBlock(nil, nil, SDImageCacheTypeNone); + } + } + }]; + } +} + +- (void)concurrentStoreImage:(UIImage *)image imageData:(NSData *)imageData forKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator> *)enumerator operation:(SDImageCachesManagerOperation *)operation { + NSParameterAssert(enumerator); + NSParameterAssert(operation); + for (id cache in enumerator) { + [cache storeImage:image imageData:imageData forKey:key cacheType:cacheType completion:^{ + if (operation.isCancelled) { + // Cancelled + return; + } + if (operation.isFinished) { + // Finished + return; + } + [operation completeOne]; + if (operation.pendingCount == 0) { + // Complete + [operation done]; + if (completionBlock) { + completionBlock(); + } + } + }]; + } +} + +- (void)concurrentRemoveImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator> *)enumerator operation:(SDImageCachesManagerOperation *)operation { + NSParameterAssert(enumerator); + NSParameterAssert(operation); + for (id cache in enumerator) { + [cache removeImageForKey:key cacheType:cacheType completion:^{ + if (operation.isCancelled) { + // Cancelled + return; + } + if (operation.isFinished) { + // Finished + return; + } + [operation completeOne]; + if (operation.pendingCount == 0) { + // Complete + [operation done]; + if (completionBlock) { + completionBlock(); + } + } + }]; + } +} + +- (void)concurrentContainsImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDImageCacheContainsCompletionBlock)completionBlock enumerator:(NSEnumerator> *)enumerator operation:(SDImageCachesManagerOperation *)operation { + NSParameterAssert(enumerator); + NSParameterAssert(operation); + for (id cache in enumerator) { + [cache containsImageForKey:key cacheType:cacheType completion:^(SDImageCacheType containsCacheType) { + if (operation.isCancelled) { + // Cancelled + return; + } + if (operation.isFinished) { + // Finished + return; + } + [operation completeOne]; + if (containsCacheType != SDImageCacheTypeNone) { + // Success + [operation done]; + if (completionBlock) { + completionBlock(containsCacheType); + } + return; + } + if (operation.pendingCount == 0) { + // Complete + [operation done]; + if (completionBlock) { + completionBlock(SDImageCacheTypeNone); + } + } + }]; + } +} + +- (void)concurrentClearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator> *)enumerator operation:(SDImageCachesManagerOperation *)operation { + NSParameterAssert(enumerator); + NSParameterAssert(operation); + for (id cache in enumerator) { + [cache clearWithCacheType:cacheType completion:^{ + if (operation.isCancelled) { + // Cancelled + return; + } + if (operation.isFinished) { + // Finished + return; + } + [operation completeOne]; + if (operation.pendingCount == 0) { + // Complete + [operation done]; + if (completionBlock) { + completionBlock(); + } + } + }]; + } +} + +#pragma mark - Serial Operation + +- (void)serialQueryImageForKey:(NSString *)key options:(SDWebImageOptions)options context:(SDWebImageContext *)context completion:(SDImageCacheQueryCompletionBlock)completionBlock enumerator:(NSEnumerator> *)enumerator operation:(SDImageCachesManagerOperation *)operation { + NSParameterAssert(enumerator); + NSParameterAssert(operation); + id cache = enumerator.nextObject; + if (!cache) { + // Complete + [operation done]; + if (completionBlock) { + completionBlock(nil, nil, SDImageCacheTypeNone); + } + return; + } + @weakify(self); + [cache queryImageForKey:key options:options context:context completion:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) { + @strongify(self); + if (operation.isCancelled) { + // Cancelled + return; + } + if (operation.isFinished) { + // Finished + return; + } + [operation completeOne]; + if (image) { + // Success + [operation done]; + if (completionBlock) { + completionBlock(image, data, cacheType); + } + return; + } + // Next + [self serialQueryImageForKey:key options:options context:context completion:completionBlock enumerator:enumerator operation:operation]; + }]; +} + +- (void)serialStoreImage:(UIImage *)image imageData:(NSData *)imageData forKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator> *)enumerator { + NSParameterAssert(enumerator); + id cache = enumerator.nextObject; + if (!cache) { + // Complete + if (completionBlock) { + completionBlock(); + } + return; + } + @weakify(self); + [cache storeImage:image imageData:imageData forKey:key cacheType:cacheType completion:^{ + @strongify(self); + // Next + [self serialStoreImage:image imageData:imageData forKey:key cacheType:cacheType completion:completionBlock enumerator:enumerator]; + }]; +} + +- (void)serialRemoveImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator> *)enumerator { + NSParameterAssert(enumerator); + id cache = enumerator.nextObject; + if (!cache) { + // Complete + if (completionBlock) { + completionBlock(); + } + return; + } + @weakify(self); + [cache removeImageForKey:key cacheType:cacheType completion:^{ + @strongify(self); + // Next + [self serialRemoveImageForKey:key cacheType:cacheType completion:completionBlock enumerator:enumerator]; + }]; +} + +- (void)serialContainsImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDImageCacheContainsCompletionBlock)completionBlock enumerator:(NSEnumerator> *)enumerator operation:(SDImageCachesManagerOperation *)operation { + NSParameterAssert(enumerator); + NSParameterAssert(operation); + id cache = enumerator.nextObject; + if (!cache) { + // Complete + [operation done]; + if (completionBlock) { + completionBlock(SDImageCacheTypeNone); + } + return; + } + @weakify(self); + [cache containsImageForKey:key cacheType:cacheType completion:^(SDImageCacheType containsCacheType) { + @strongify(self); + if (operation.isCancelled) { + // Cancelled + return; + } + if (operation.isFinished) { + // Finished + return; + } + [operation completeOne]; + if (containsCacheType != SDImageCacheTypeNone) { + // Success + [operation done]; + if (completionBlock) { + completionBlock(containsCacheType); + } + return; + } + // Next + [self serialContainsImageForKey:key cacheType:cacheType completion:completionBlock enumerator:enumerator operation:operation]; + }]; +} + +- (void)serialClearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator> *)enumerator { + NSParameterAssert(enumerator); + id cache = enumerator.nextObject; + if (!cache) { + // Complete + if (completionBlock) { + completionBlock(); + } + return; + } + @weakify(self); + [cache clearWithCacheType:cacheType completion:^{ + @strongify(self); + // Next + [self serialClearWithCacheType:cacheType completion:completionBlock enumerator:enumerator]; + }]; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCoder.h b/Pods/SDWebImage/SDWebImage/SDImageCoder.h new file mode 100644 index 00000000..3b2049e5 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageCoder.h @@ -0,0 +1,218 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" +#import "NSData+ImageContentType.h" + +typedef NSString * SDImageCoderOption NS_STRING_ENUM; +typedef NSDictionary SDImageCoderOptions; +typedef NSMutableDictionary SDImageCoderMutableOptions; + +#pragma mark - Coder Options +// These options are for image decoding +/** + A Boolean value indicating whether to decode the first frame only for animated image during decoding. (NSNumber). If not provide, decode animated image if need. + @note works for `SDImageCoder`. + */ +FOUNDATION_EXPORT SDImageCoderOption _Nonnull const SDImageCoderDecodeFirstFrameOnly; +/** + A CGFloat value which is greater than or equal to 1.0. This value specify the image scale factor for decoding. If not provide, use 1.0. (NSNumber) + @note works for `SDImageCoder`, `SDProgressiveImageCoder`, `SDAnimatedImageCoder`. + */ +FOUNDATION_EXPORT SDImageCoderOption _Nonnull const SDImageCoderDecodeScaleFactor; + +// These options are for image encoding +/** + A Boolean value indicating whether to encode the first frame only for animated image during encoding. (NSNumber). If not provide, encode animated image if need. + @note works for `SDImageCoder`. + */ +FOUNDATION_EXPORT SDImageCoderOption _Nonnull const SDImageCoderEncodeFirstFrameOnly; +/** + A double value between 0.0-1.0 indicating the encode compression quality to produce the image data. 1.0 resulting in no compression and 0.0 resulting in the maximum compression possible. If not provide, use 1.0. (NSNumber) + @note works for `SDImageCoder` + */ +FOUNDATION_EXPORT SDImageCoderOption _Nonnull const SDImageCoderEncodeCompressionQuality; + +/** + A SDWebImageContext object which hold the original context options from top-level API. (SDWebImageContext) + This option is ignored for all built-in coders and take no effect. + But this may be useful for some custom coders, because some business logic may dependent on things other than image or image data inforamtion only. + See `SDWebImageContext` for more detailed information. + */ +FOUNDATION_EXPORT SDImageCoderOption _Nonnull const SDImageCoderWebImageContext; + +#pragma mark - Coder +/** + This is the image coder protocol to provide custom image decoding/encoding. + These methods are all required to implement. + @note Pay attention that these methods are not called from main queue. + */ +@protocol SDImageCoder + +@required +#pragma mark - Decoding +/** + Returns YES if this coder can decode some data. Otherwise, the data should be passed to another coder. + + @param data The image data so we can look at it + @return YES if this coder can decode the data, NO otherwise + */ +- (BOOL)canDecodeFromData:(nullable NSData *)data; + +/** + Decode the image data to image. + @note This protocol may supports decode animated image frames. You can use `+[SDImageCoderHelper animatedImageWithFrames:]` to produce an animated image with frames. + + @param data The image data to be decoded + @param options A dictionary containing any decoding options. Pass @{SDImageCoderDecodeScaleFactor: @(1.0)} to specify scale factor for image. Pass @{SDImageCoderDecodeFirstFrameOnly: @(YES)} to decode the first frame only. + @return The decoded image from data + */ +- (nullable UIImage *)decodedImageWithData:(nullable NSData *)data + options:(nullable SDImageCoderOptions *)options; + +#pragma mark - Encoding + +/** + Returns YES if this coder can encode some image. Otherwise, it should be passed to another coder. + For custom coder which introduce new image format, you'd better define a new `SDImageFormat` using like this. If you're creating public coder plugin for new image format, also update `https://github.com/rs/SDWebImage/wiki/Coder-Plugin-List` to avoid same value been defined twice. + * @code + static const SDImageFormat SDImageFormatHEIF = 10; + * @endcode + + @param format The image format + @return YES if this coder can encode the image, NO otherwise + */ +- (BOOL)canEncodeToFormat:(SDImageFormat)format NS_SWIFT_NAME(canEncode(to:)); + +/** + Encode the image to image data. + @note This protocol may supports encode animated image frames. You can use `+[SDImageCoderHelper framesFromAnimatedImage:]` to assemble an animated image with frames. + + @param image The image to be encoded + @param format The image format to encode, you should note `SDImageFormatUndefined` format is also possible + @param options A dictionary containing any encoding options. Pass @{SDImageCoderEncodeCompressionQuality: @(1)} to specify compression quality. + @return The encoded image data + */ +- (nullable NSData *)encodedDataWithImage:(nullable UIImage *)image + format:(SDImageFormat)format + options:(nullable SDImageCoderOptions *)options; + +@end + +#pragma mark - Progressive Coder +/** + This is the image coder protocol to provide custom progressive image decoding. + These methods are all required to implement. + @note Pay attention that these methods are not called from main queue. + */ +@protocol SDProgressiveImageCoder + +@required +/** + Returns YES if this coder can incremental decode some data. Otherwise, it should be passed to another coder. + + @param data The image data so we can look at it + @return YES if this coder can decode the data, NO otherwise + */ +- (BOOL)canIncrementalDecodeFromData:(nullable NSData *)data; + +/** + Because incremental decoding need to keep the decoded context, we will alloc a new instance with the same class for each download operation to avoid conflicts + This init method should not return nil + + @param options A dictionary containing any progressive decoding options (instance-level). Pass @{SDImageCoderDecodeScaleFactor: @(1.0)} to specify scale factor for progressive animated image (each frames should use the same scale). + @return A new instance to do incremental decoding for the specify image format + */ +- (nonnull instancetype)initIncrementalWithOptions:(nullable SDImageCoderOptions *)options; + +/** + Update the incremental decoding when new image data available + + @param data The image data has been downloaded so far + @param finished Whether the download has finished + */ +- (void)updateIncrementalData:(nullable NSData *)data finished:(BOOL)finished; + +/** + Incremental decode the current image data to image. + @note Due to the performance issue for progressive decoding and the integration for image view. This method may only return the first frame image even if the image data is animated image. If you want progressive animated image decoding, conform to `SDAnimatedImageCoder` protocol as well and use `animatedImageFrameAtIndex:` instead. + + @param options A dictionary containing any progressive decoding options. Pass @{SDImageCoderDecodeScaleFactor: @(1.0)} to specify scale factor for progressive image + @return The decoded image from current data + */ +- (nullable UIImage *)incrementalDecodedImageWithOptions:(nullable SDImageCoderOptions *)options; + +@end + +#pragma mark - Animated Image Provider +/** + This is the animated image protocol to provide the basic function for animated image rendering. It's adopted by `SDAnimatedImage` and `SDAnimatedImageCoder` + */ +@protocol SDAnimatedImageProvider + +@required +/** + The original animated image data for current image. If current image is not an animated format, return nil. + We may use this method to grab back the original image data if need, such as NSCoding or compare. + + @return The animated image data + */ +@property (nonatomic, copy, readonly, nullable) NSData *animatedImageData; + +/** + Total animated frame count. + If the frame count is less than 1, then the methods below will be ignored. + + @return Total animated frame count. + */ +@property (nonatomic, assign, readonly) NSUInteger animatedImageFrameCount; +/** + Animation loop count, 0 means infinite looping. + + @return Animation loop count + */ +@property (nonatomic, assign, readonly) NSUInteger animatedImageLoopCount; +/** + Returns the frame image from a specified index. + @note The index maybe randomly if one image was set to different imageViews, keep it re-entrant. (It's not recommend to store the images into array because it's memory consuming) + + @param index Frame index (zero based). + @return Frame's image + */ +- (nullable UIImage *)animatedImageFrameAtIndex:(NSUInteger)index; +/** + Returns the frames's duration from a specified index. + @note The index maybe randomly if one image was set to different imageViews, keep it re-entrant. (It's recommend to store the durations into array because it's not memory-consuming) + + @param index Frame index (zero based). + @return Frame's duration + */ +- (NSTimeInterval)animatedImageDurationAtIndex:(NSUInteger)index; + +@end + +#pragma mark - Animated Coder +/** + This is the animated image coder protocol for custom animated image class like `SDAnimatedImage`. Through it inherit from `SDImageCoder`. We currentlly only use the method `canDecodeFromData:` to detect the proper coder for specify animated image format. + */ +@protocol SDAnimatedImageCoder + +@required +/** + Because animated image coder should keep the original data, we will alloc a new instance with the same class for the specify animated image data + The init method should return nil if it can't decode the specify animated image data to produce any frame. + After the instance created, we may call methods in `SDAnimatedImageProvider` to produce animated image frame. + + @param data The animated image data to be decode + @param options A dictionary containing any animated decoding options (instance-level). Pass @{SDImageCoderDecodeScaleFactor: @(1.0)} to specify scale factor for animated image (each frames should use the same scale). + @return A new instance to do animated decoding for specify image data + */ +- (nullable instancetype)initWithAnimatedImageData:(nullable NSData *)data options:(nullable SDImageCoderOptions *)options; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCoder.m b/Pods/SDWebImage/SDWebImage/SDImageCoder.m new file mode 100644 index 00000000..c963376b --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageCoder.m @@ -0,0 +1,17 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageCoder.h" + +SDImageCoderOption const SDImageCoderDecodeFirstFrameOnly = @"decodeFirstFrameOnly"; +SDImageCoderOption const SDImageCoderDecodeScaleFactor = @"decodeScaleFactor"; + +SDImageCoderOption const SDImageCoderEncodeFirstFrameOnly = @"encodeFirstFrameOnly"; +SDImageCoderOption const SDImageCoderEncodeCompressionQuality = @"encodeCompressionQuality"; + +SDImageCoderOption const SDImageCoderWebImageContext = @"webImageContext"; diff --git a/Pods/SDWebImage/SDWebImage/SDImageCoderHelper.h b/Pods/SDWebImage/SDWebImage/SDImageCoderHelper.h new file mode 100644 index 00000000..dcb3b491 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageCoderHelper.h @@ -0,0 +1,107 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" +#import "SDImageFrame.h" + +@interface SDImageCoderHelper : NSObject + +/** + Return an animated image with frames array. + For UIKit, this will apply the patch and then create animated UIImage. The patch is because that `+[UIImage animatedImageWithImages:duration:]` just use the average of duration for each image. So it will not work if different frame has different duration. Therefore we repeat the specify frame for specify times to let it work. + For AppKit, NSImage does not support animates other than GIF. This will try to encode the frames to GIF format and then create an animated NSImage for rendering. Attention the animated image may loss some detail if the input frames contain full alpha channel because GIF only supports 1 bit alpha channel. (For 1 pixel, either transparent or not) + + @param frames The frames array. If no frames or frames is empty, return nil + @return A animated image for rendering on UIImageView(UIKit) or NSImageView(AppKit) + */ ++ (UIImage * _Nullable)animatedImageWithFrames:(NSArray * _Nullable)frames; + +/** + Return frames array from an animated image. + For UIKit, this will unapply the patch for the description above and then create frames array. This will also work for normal animated UIImage. + For AppKit, NSImage does not support animates other than GIF. This will try to decode the GIF imageRep and then create frames array. + + @param animatedImage A animated image. If it's not animated, return nil + @return The frames array + */ ++ (NSArray * _Nullable)framesFromAnimatedImage:(UIImage * _Nullable)animatedImage NS_SWIFT_NAME(frames(from:)); + +/** + Return the shared device-dependent RGB color space. This follows The Get Rule. + On iOS, it's created with deviceRGB (if available, use sRGB). + On macOS, it's from the screen colorspace (if failed, use deviceRGB) + Because it's shared, you should not retain or release this object. + + @return The device-dependent RGB color space + */ ++ (CGColorSpaceRef _Nonnull)colorSpaceGetDeviceRGB CF_RETURNS_NOT_RETAINED; + +/** + Check whether CGImage contains alpha channel. + + @param cgImage The CGImage + @return Return YES if CGImage contains alpha channel, otherwise return NO + */ ++ (BOOL)CGImageContainsAlpha:(_Nonnull CGImageRef)cgImage; + +/** + Create a decoded CGImage by the provided CGImage. This follows The Create Rule and you are response to call release after usage. + It will detect whether image contains alpha channel, then create a new bitmap context with the same size of image, and draw it. This can ensure that the image do not need extra decoding after been set to the imageView. + @note This actually call `CGImageCreateDecoded:orientation:` with the Up orientation. + + @param cgImage The CGImage + @return A new created decoded image + */ ++ (CGImageRef _Nullable)CGImageCreateDecoded:(_Nonnull CGImageRef)cgImage CF_RETURNS_RETAINED; + +/** + Create a decoded CGImage by the provided CGImage and orientation. This follows The Create Rule and you are response to call release after usage. + It will detect whether image contains alpha channel, then create a new bitmap context with the same size of image, and draw it. This can ensure that the image do not need extra decoding after been set to the imageView. + + @param cgImage The CGImage + @param orientation The EXIF image orientation. + @return A new created decoded image + */ ++ (CGImageRef _Nullable)CGImageCreateDecoded:(_Nonnull CGImageRef)cgImage orientation:(CGImagePropertyOrientation)orientation CF_RETURNS_RETAINED; + +/** + Return the decoded image by the provided image. This one unlike `CGImageCreateDecoded:`, will not decode the image which contains alpha channel or animated image + @param image The image to be decoded + @return The decoded image + */ ++ (UIImage * _Nullable)decodedImageWithImage:(UIImage * _Nullable)image; + +/** + Return the decoded and probably scaled down image by the provided image. If the image is large than the limit size, will try to scale down. Or just works as `decodedImageWithImage:` + + @param image The image to be decoded and scaled down + @param bytes The limit bytes size. Provide 0 to use the build-in limit. + @return The decoded and probably scaled down image + */ ++ (UIImage * _Nullable)decodedAndScaledDownImageWithImage:(UIImage * _Nullable)image limitBytes:(NSUInteger)bytes; + +#if SD_UIKIT || SD_WATCH +/** + Convert an EXIF image orientation to an iOS one. + + @param exifOrientation EXIF orientation + @return iOS orientation + */ ++ (UIImageOrientation)imageOrientationFromEXIFOrientation:(CGImagePropertyOrientation)exifOrientation NS_SWIFT_NAME(imageOrientation(from:)); + +/** + Convert an iOS orientation to an EXIF image orientation. + + @param imageOrientation iOS orientation + @return EXIF orientation + */ ++ (CGImagePropertyOrientation)exifOrientationFromImageOrientation:(UIImageOrientation)imageOrientation; +#endif + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCoderHelper.m b/Pods/SDWebImage/SDWebImage/SDImageCoderHelper.m new file mode 100644 index 00000000..7a75eb0c --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageCoderHelper.m @@ -0,0 +1,628 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageCoderHelper.h" +#import "SDImageFrame.h" +#import "NSImage+Compatibility.h" +#import "NSData+ImageContentType.h" +#import "SDAnimatedImageRep.h" +#import "UIImage+ForceDecode.h" +#import "UIImage+Metadata.h" + +#if SD_UIKIT || SD_WATCH +static const size_t kBytesPerPixel = 4; +static const size_t kBitsPerComponent = 8; + +/* + * Defines the maximum size in MB of the decoded image when the flag `SDWebImageScaleDownLargeImages` is set + * Suggested value for iPad1 and iPhone 3GS: 60. + * Suggested value for iPad2 and iPhone 4: 120. + * Suggested value for iPhone 3G and iPod 2 and earlier devices: 30. + */ +static const CGFloat kDestImageSizeMB = 60.f; + +/* + * Defines the maximum size in MB of a tile used to decode image when the flag `SDWebImageScaleDownLargeImages` is set + * Suggested value for iPad1 and iPhone 3GS: 20. + * Suggested value for iPad2 and iPhone 4: 40. + * Suggested value for iPhone 3G and iPod 2 and earlier devices: 10. + */ +static const CGFloat kSourceImageTileSizeMB = 20.f; + +static const CGFloat kBytesPerMB = 1024.0f * 1024.0f; +static const CGFloat kPixelsPerMB = kBytesPerMB / kBytesPerPixel; +static const CGFloat kDestTotalPixels = kDestImageSizeMB * kPixelsPerMB; +static const CGFloat kTileTotalPixels = kSourceImageTileSizeMB * kPixelsPerMB; + +static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to overlap the seems where tiles meet. +#endif + +@implementation SDImageCoderHelper + ++ (UIImage *)animatedImageWithFrames:(NSArray *)frames { + NSUInteger frameCount = frames.count; + if (frameCount == 0) { + return nil; + } + + UIImage *animatedImage; + +#if SD_UIKIT || SD_WATCH + NSUInteger durations[frameCount]; + for (size_t i = 0; i < frameCount; i++) { + durations[i] = frames[i].duration * 1000; + } + NSUInteger const gcd = gcdArray(frameCount, durations); + __block NSUInteger totalDuration = 0; + NSMutableArray *animatedImages = [NSMutableArray arrayWithCapacity:frameCount]; + [frames enumerateObjectsUsingBlock:^(SDImageFrame * _Nonnull frame, NSUInteger idx, BOOL * _Nonnull stop) { + UIImage *image = frame.image; + NSUInteger duration = frame.duration * 1000; + totalDuration += duration; + NSUInteger repeatCount; + if (gcd) { + repeatCount = duration / gcd; + } else { + repeatCount = 1; + } + for (size_t i = 0; i < repeatCount; ++i) { + [animatedImages addObject:image]; + } + }]; + + animatedImage = [UIImage animatedImageWithImages:animatedImages duration:totalDuration / 1000.f]; + +#else + + NSMutableData *imageData = [NSMutableData data]; + CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:SDImageFormatGIF]; + // Create an image destination. GIF does not support EXIF image orientation + CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frameCount, NULL); + if (!imageDestination) { + // Handle failure. + return nil; + } + + for (size_t i = 0; i < frameCount; i++) { + @autoreleasepool { + SDImageFrame *frame = frames[i]; + float frameDuration = frame.duration; + CGImageRef frameImageRef = frame.image.CGImage; + NSDictionary *frameProperties = @{(__bridge NSString *)kCGImagePropertyGIFDictionary : @{(__bridge NSString *)kCGImagePropertyGIFDelayTime : @(frameDuration)}}; + CGImageDestinationAddImage(imageDestination, frameImageRef, (__bridge CFDictionaryRef)frameProperties); + } + } + // Finalize the destination. + if (CGImageDestinationFinalize(imageDestination) == NO) { + // Handle failure. + CFRelease(imageDestination); + return nil; + } + CFRelease(imageDestination); + CGFloat scale = frames.firstObject.image.scale; + if (scale < 1) { + scale = 1; + } + SDAnimatedImageRep *imageRep = [[SDAnimatedImageRep alloc] initWithData:imageData]; + NSSize size = NSMakeSize(imageRep.pixelsWide / scale, imageRep.pixelsHigh / scale); + imageRep.size = size; + animatedImage = [[NSImage alloc] initWithSize:size]; + [animatedImage addRepresentation:imageRep]; +#endif + + return animatedImage; +} + ++ (NSArray *)framesFromAnimatedImage:(UIImage *)animatedImage { + if (!animatedImage) { + return nil; + } + + NSMutableArray *frames = [NSMutableArray array]; + NSUInteger frameCount = 0; + +#if SD_UIKIT || SD_WATCH + NSArray *animatedImages = animatedImage.images; + frameCount = animatedImages.count; + if (frameCount == 0) { + return nil; + } + + NSTimeInterval avgDuration = animatedImage.duration / frameCount; + if (avgDuration == 0) { + avgDuration = 0.1; // if it's a animated image but no duration, set it to default 100ms (this do not have that 10ms limit like GIF or WebP to allow custom coder provide the limit) + } + + __block NSUInteger index = 0; + __block NSUInteger repeatCount = 1; + __block UIImage *previousImage = animatedImages.firstObject; + [animatedImages enumerateObjectsUsingBlock:^(UIImage * _Nonnull image, NSUInteger idx, BOOL * _Nonnull stop) { + // ignore first + if (idx == 0) { + return; + } + if ([image isEqual:previousImage]) { + repeatCount++; + } else { + SDImageFrame *frame = [SDImageFrame frameWithImage:previousImage duration:avgDuration * repeatCount]; + [frames addObject:frame]; + repeatCount = 1; + index++; + } + previousImage = image; + // last one + if (idx == frameCount - 1) { + SDImageFrame *frame = [SDImageFrame frameWithImage:previousImage duration:avgDuration * repeatCount]; + [frames addObject:frame]; + } + }]; + +#else + + NSRect imageRect = NSMakeRect(0, 0, animatedImage.size.width, animatedImage.size.height); + NSImageRep *imageRep = [animatedImage bestRepresentationForRect:imageRect context:nil hints:nil]; + NSBitmapImageRep *bitmapImageRep; + if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) { + bitmapImageRep = (NSBitmapImageRep *)imageRep; + } + if (!bitmapImageRep) { + return nil; + } + frameCount = [[bitmapImageRep valueForProperty:NSImageFrameCount] unsignedIntegerValue]; + if (frameCount == 0) { + return nil; + } + CGFloat scale = animatedImage.scale; + + for (size_t i = 0; i < frameCount; i++) { + @autoreleasepool { + // NSBitmapImageRep need to manually change frame. "Good taste" API + [bitmapImageRep setProperty:NSImageCurrentFrame withValue:@(i)]; + float frameDuration = [[bitmapImageRep valueForProperty:NSImageCurrentFrameDuration] floatValue]; + NSImage *frameImage = [[NSImage alloc] initWithCGImage:bitmapImageRep.CGImage scale:scale orientation:kCGImagePropertyOrientationUp]; + SDImageFrame *frame = [SDImageFrame frameWithImage:frameImage duration:frameDuration]; + [frames addObject:frame]; + } + } +#endif + + return frames; +} + ++ (CGColorSpaceRef)colorSpaceGetDeviceRGB { +#if SD_MAC + CGColorSpaceRef screenColorSpace = NSScreen.mainScreen.colorSpace.CGColorSpace; + if (screenColorSpace) { + return screenColorSpace; + } +#endif + static CGColorSpaceRef colorSpace; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ +#if SD_UIKIT + if (@available(iOS 9.0, tvOS 9.0, *)) { + colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); + } else { + colorSpace = CGColorSpaceCreateDeviceRGB(); + } +#else + colorSpace = CGColorSpaceCreateDeviceRGB(); +#endif + }); + return colorSpace; +} + ++ (BOOL)CGImageContainsAlpha:(CGImageRef)cgImage { + if (!cgImage) { + return NO; + } + CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(cgImage); + BOOL hasAlpha = !(alphaInfo == kCGImageAlphaNone || + alphaInfo == kCGImageAlphaNoneSkipFirst || + alphaInfo == kCGImageAlphaNoneSkipLast); + return hasAlpha; +} + ++ (CGImageRef)CGImageCreateDecoded:(CGImageRef)cgImage { + return [self CGImageCreateDecoded:cgImage orientation:kCGImagePropertyOrientationUp]; +} + ++ (CGImageRef)CGImageCreateDecoded:(CGImageRef)cgImage orientation:(CGImagePropertyOrientation)orientation { + if (!cgImage) { + return NULL; + } + size_t width = CGImageGetWidth(cgImage); + size_t height = CGImageGetHeight(cgImage); + if (width == 0 || height == 0) return NULL; + BOOL hasAlpha = [self CGImageContainsAlpha:cgImage]; + // iOS prefer BGRA8888 (premultiplied) or BGRX8888 bitmapInfo for screen rendering, which is same as `UIGraphicsBeginImageContext()` or `- [CALayer drawInContext:]` + // Though you can use any supported bitmapInfo (see: https://developer.apple.com/library/content/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_context/dq_context.html#//apple_ref/doc/uid/TP30001066-CH203-BCIBHHBB ) and let Core Graphics reorder it when you call `CGContextDrawImage` + // But since our build-in coders use this bitmapInfo, this can have a little performance benefit + CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Host; + bitmapInfo |= hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst; + CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 0, [self colorSpaceGetDeviceRGB], bitmapInfo); + if (!context) { + return NULL; + } + + // Apply transform + CGAffineTransform transform = SDCGContextTransformFromOrientation(orientation, CGSizeMake(width, height)); + CGRect rect; + switch (orientation) { + case kCGImagePropertyOrientationLeft: + case kCGImagePropertyOrientationLeftMirrored: + case kCGImagePropertyOrientationRight: + case kCGImagePropertyOrientationRightMirrored: { + // These orientation should swap width & height + rect = CGRectMake(0, 0, height, width); + } + break; + default: { + rect = CGRectMake(0, 0, width, height); + } + break; + } + CGContextConcatCTM(context, transform); + CGContextDrawImage(context, rect, cgImage); + CGImageRef newImageRef = CGBitmapContextCreateImage(context); + CGContextRelease(context); + + return newImageRef; +} + ++ (UIImage *)decodedImageWithImage:(UIImage *)image { +#if SD_MAC + return image; +#else + if (![self shouldDecodeImage:image]) { + return image; + } + + CGImageRef imageRef = [self CGImageCreateDecoded:image.CGImage]; + if (!imageRef) { + return image; + } + UIImage *decodedImage = [[UIImage alloc] initWithCGImage:imageRef scale:image.scale orientation:image.imageOrientation]; + CGImageRelease(imageRef); + decodedImage.sd_isDecoded = YES; + decodedImage.sd_imageFormat = image.sd_imageFormat; + return decodedImage; +#endif +} + ++ (UIImage *)decodedAndScaledDownImageWithImage:(UIImage *)image limitBytes:(NSUInteger)bytes { +#if SD_MAC + return image; +#else + if (![self shouldDecodeImage:image]) { + return image; + } + + if (![self shouldScaleDownImage:image limitBytes:bytes]) { + return [self decodedImageWithImage:image]; + } + + CGFloat destTotalPixels; + CGFloat tileTotalPixels; + if (bytes > 0) { + destTotalPixels = bytes / kBytesPerPixel; + tileTotalPixels = destTotalPixels / 3; + } else { + destTotalPixels = kDestTotalPixels; + tileTotalPixels = kTileTotalPixels; + } + CGContextRef destContext; + + // autorelease the bitmap context and all vars to help system to free memory when there are memory warning. + // on iOS7, do not forget to call [[SDImageCache sharedImageCache] clearMemory]; + @autoreleasepool { + CGImageRef sourceImageRef = image.CGImage; + + CGSize sourceResolution = CGSizeZero; + sourceResolution.width = CGImageGetWidth(sourceImageRef); + sourceResolution.height = CGImageGetHeight(sourceImageRef); + CGFloat sourceTotalPixels = sourceResolution.width * sourceResolution.height; + // Determine the scale ratio to apply to the input image + // that results in an output image of the defined size. + // see kDestImageSizeMB, and how it relates to destTotalPixels. + CGFloat imageScale = sqrt(destTotalPixels / sourceTotalPixels); + CGSize destResolution = CGSizeZero; + destResolution.width = (int)(sourceResolution.width * imageScale); + destResolution.height = (int)(sourceResolution.height * imageScale); + + // device color space + CGColorSpaceRef colorspaceRef = [self colorSpaceGetDeviceRGB]; + BOOL hasAlpha = [self CGImageContainsAlpha:sourceImageRef]; + // iOS display alpha info (BGRA8888/BGRX8888) + CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Host; + bitmapInfo |= hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst; + + // kCGImageAlphaNone is not supported in CGBitmapContextCreate. + // Since the original image here has no alpha info, use kCGImageAlphaNoneSkipFirst + // to create bitmap graphics contexts without alpha info. + destContext = CGBitmapContextCreate(NULL, + destResolution.width, + destResolution.height, + kBitsPerComponent, + 0, + colorspaceRef, + bitmapInfo); + + if (destContext == NULL) { + return image; + } + CGContextSetInterpolationQuality(destContext, kCGInterpolationHigh); + + // Now define the size of the rectangle to be used for the + // incremental blits from the input image to the output image. + // we use a source tile width equal to the width of the source + // image due to the way that iOS retrieves image data from disk. + // iOS must decode an image from disk in full width 'bands', even + // if current graphics context is clipped to a subrect within that + // band. Therefore we fully utilize all of the pixel data that results + // from a decoding opertion by achnoring our tile size to the full + // width of the input image. + CGRect sourceTile = CGRectZero; + sourceTile.size.width = sourceResolution.width; + // The source tile height is dynamic. Since we specified the size + // of the source tile in MB, see how many rows of pixels high it + // can be given the input image width. + sourceTile.size.height = (int)(tileTotalPixels / sourceTile.size.width ); + sourceTile.origin.x = 0.0f; + // The output tile is the same proportions as the input tile, but + // scaled to image scale. + CGRect destTile; + destTile.size.width = destResolution.width; + destTile.size.height = sourceTile.size.height * imageScale; + destTile.origin.x = 0.0f; + // The source seem overlap is proportionate to the destination seem overlap. + // this is the amount of pixels to overlap each tile as we assemble the ouput image. + float sourceSeemOverlap = (int)((kDestSeemOverlap/destResolution.height)*sourceResolution.height); + CGImageRef sourceTileImageRef; + // calculate the number of read/write operations required to assemble the + // output image. + int iterations = (int)( sourceResolution.height / sourceTile.size.height ); + // If tile height doesn't divide the image height evenly, add another iteration + // to account for the remaining pixels. + int remainder = (int)sourceResolution.height % (int)sourceTile.size.height; + if(remainder) { + iterations++; + } + // Add seem overlaps to the tiles, but save the original tile height for y coordinate calculations. + float sourceTileHeightMinusOverlap = sourceTile.size.height; + sourceTile.size.height += sourceSeemOverlap; + destTile.size.height += kDestSeemOverlap; + for( int y = 0; y < iterations; ++y ) { + @autoreleasepool { + sourceTile.origin.y = y * sourceTileHeightMinusOverlap + sourceSeemOverlap; + destTile.origin.y = destResolution.height - (( y + 1 ) * sourceTileHeightMinusOverlap * imageScale + kDestSeemOverlap); + sourceTileImageRef = CGImageCreateWithImageInRect( sourceImageRef, sourceTile ); + if( y == iterations - 1 && remainder ) { + float dify = destTile.size.height; + destTile.size.height = CGImageGetHeight( sourceTileImageRef ) * imageScale; + dify -= destTile.size.height; + destTile.origin.y += dify; + } + CGContextDrawImage( destContext, destTile, sourceTileImageRef ); + CGImageRelease( sourceTileImageRef ); + } + } + + CGImageRef destImageRef = CGBitmapContextCreateImage(destContext); + CGContextRelease(destContext); + if (destImageRef == NULL) { + return image; + } + UIImage *destImage = [[UIImage alloc] initWithCGImage:destImageRef scale:image.scale orientation:image.imageOrientation]; + CGImageRelease(destImageRef); + if (destImage == nil) { + return image; + } + destImage.sd_isDecoded = YES; + destImage.sd_imageFormat = image.sd_imageFormat; + return destImage; + } +#endif +} + +#if SD_UIKIT || SD_WATCH +// Convert an EXIF image orientation to an iOS one. ++ (UIImageOrientation)imageOrientationFromEXIFOrientation:(CGImagePropertyOrientation)exifOrientation { + UIImageOrientation imageOrientation = UIImageOrientationUp; + switch (exifOrientation) { + case kCGImagePropertyOrientationUp: + imageOrientation = UIImageOrientationUp; + break; + case kCGImagePropertyOrientationDown: + imageOrientation = UIImageOrientationDown; + break; + case kCGImagePropertyOrientationLeft: + imageOrientation = UIImageOrientationLeft; + break; + case kCGImagePropertyOrientationRight: + imageOrientation = UIImageOrientationRight; + break; + case kCGImagePropertyOrientationUpMirrored: + imageOrientation = UIImageOrientationUpMirrored; + break; + case kCGImagePropertyOrientationDownMirrored: + imageOrientation = UIImageOrientationDownMirrored; + break; + case kCGImagePropertyOrientationLeftMirrored: + imageOrientation = UIImageOrientationLeftMirrored; + break; + case kCGImagePropertyOrientationRightMirrored: + imageOrientation = UIImageOrientationRightMirrored; + break; + default: + break; + } + return imageOrientation; +} + +// Convert an iOS orientation to an EXIF image orientation. ++ (CGImagePropertyOrientation)exifOrientationFromImageOrientation:(UIImageOrientation)imageOrientation { + CGImagePropertyOrientation exifOrientation = kCGImagePropertyOrientationUp; + switch (imageOrientation) { + case UIImageOrientationUp: + exifOrientation = kCGImagePropertyOrientationUp; + break; + case UIImageOrientationDown: + exifOrientation = kCGImagePropertyOrientationDown; + break; + case UIImageOrientationLeft: + exifOrientation = kCGImagePropertyOrientationLeft; + break; + case UIImageOrientationRight: + exifOrientation = kCGImagePropertyOrientationRight; + break; + case UIImageOrientationUpMirrored: + exifOrientation = kCGImagePropertyOrientationUpMirrored; + break; + case UIImageOrientationDownMirrored: + exifOrientation = kCGImagePropertyOrientationDownMirrored; + break; + case UIImageOrientationLeftMirrored: + exifOrientation = kCGImagePropertyOrientationLeftMirrored; + break; + case UIImageOrientationRightMirrored: + exifOrientation = kCGImagePropertyOrientationRightMirrored; + break; + default: + break; + } + return exifOrientation; +} +#endif + +#pragma mark - Helper Fuction +#if SD_UIKIT || SD_WATCH ++ (BOOL)shouldDecodeImage:(nullable UIImage *)image { + // Avoid extra decode + if (image.sd_isDecoded) { + return NO; + } + // Prevent "CGBitmapContextCreateImage: invalid context 0x0" error + if (image == nil) { + return NO; + } + // do not decode animated images + if (image.images != nil) { + return NO; + } + + return YES; +} + ++ (BOOL)shouldScaleDownImage:(nonnull UIImage *)image limitBytes:(NSUInteger)bytes { + BOOL shouldScaleDown = YES; + + CGImageRef sourceImageRef = image.CGImage; + CGSize sourceResolution = CGSizeZero; + sourceResolution.width = CGImageGetWidth(sourceImageRef); + sourceResolution.height = CGImageGetHeight(sourceImageRef); + float sourceTotalPixels = sourceResolution.width * sourceResolution.height; + if (sourceTotalPixels <= 0) { + return NO; + } + CGFloat destTotalPixels; + if (bytes > 0) { + destTotalPixels = bytes / kBytesPerPixel; + } else { + destTotalPixels = kDestTotalPixels; + } + if (destTotalPixels <= kPixelsPerMB) { + // Too small to scale down + return NO; + } + float imageScale = destTotalPixels / sourceTotalPixels; + if (imageScale < 1) { + shouldScaleDown = YES; + } else { + shouldScaleDown = NO; + } + + return shouldScaleDown; +} +#endif + +static inline CGAffineTransform SDCGContextTransformFromOrientation(CGImagePropertyOrientation orientation, CGSize size) { + // Inspiration from @libfeihu + // We need to calculate the proper transformation to make the image upright. + // We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored. + CGAffineTransform transform = CGAffineTransformIdentity; + + switch (orientation) { + case kCGImagePropertyOrientationDown: + case kCGImagePropertyOrientationDownMirrored: + transform = CGAffineTransformTranslate(transform, size.width, size.height); + transform = CGAffineTransformRotate(transform, M_PI); + break; + + case kCGImagePropertyOrientationLeft: + case kCGImagePropertyOrientationLeftMirrored: + transform = CGAffineTransformTranslate(transform, size.width, 0); + transform = CGAffineTransformRotate(transform, M_PI_2); + break; + + case kCGImagePropertyOrientationRight: + case kCGImagePropertyOrientationRightMirrored: + transform = CGAffineTransformTranslate(transform, 0, size.height); + transform = CGAffineTransformRotate(transform, -M_PI_2); + break; + case kCGImagePropertyOrientationUp: + case kCGImagePropertyOrientationUpMirrored: + break; + } + + switch (orientation) { + case kCGImagePropertyOrientationUpMirrored: + case kCGImagePropertyOrientationDownMirrored: + transform = CGAffineTransformTranslate(transform, size.width, 0); + transform = CGAffineTransformScale(transform, -1, 1); + break; + + case kCGImagePropertyOrientationLeftMirrored: + case kCGImagePropertyOrientationRightMirrored: + transform = CGAffineTransformTranslate(transform, size.height, 0); + transform = CGAffineTransformScale(transform, -1, 1); + break; + case kCGImagePropertyOrientationUp: + case kCGImagePropertyOrientationDown: + case kCGImagePropertyOrientationLeft: + case kCGImagePropertyOrientationRight: + break; + } + + return transform; +} + +#if SD_UIKIT || SD_WATCH +static NSUInteger gcd(NSUInteger a, NSUInteger b) { + NSUInteger c; + while (a != 0) { + c = a; + a = b % a; + b = c; + } + return b; +} + +static NSUInteger gcdArray(size_t const count, NSUInteger const * const values) { + if (count == 0) { + return 0; + } + NSUInteger result = values[0]; + for (size_t i = 1; i < count; ++i) { + result = gcd(values[i], result); + } + return result; +} +#endif + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCodersManager.h b/Pods/SDWebImage/SDWebImage/SDImageCodersManager.h new file mode 100644 index 00000000..14b655da --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageCodersManager.h @@ -0,0 +1,58 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDImageCoder.h" + +/** + Global object holding the array of coders, so that we avoid passing them from object to object. + Uses a priority queue behind scenes, which means the latest added coders have the highest priority. + This is done so when encoding/decoding something, we go through the list and ask each coder if they can handle the current data. + That way, users can add their custom coders while preserving our existing prebuilt ones + + Note: the `coders` getter will return the coders in their reversed order + Example: + - by default we internally set coders = `IOCoder`, `GIFCoder`, `APNGCoder` + - calling `coders` will return `@[IOCoder, GIFCoder, APNGCoder]` + - call `[addCoder:[MyCrazyCoder new]]` + - calling `coders` now returns `@[IOCoder, GIFCoder, APNGCoder, MyCrazyCoder]` + + Coders + ------ + A coder must conform to the `SDImageCoder` protocol or even to `SDProgressiveImageCoder` if it supports progressive decoding + Conformance is important because that way, they will implement `canDecodeFromData` or `canEncodeToFormat` + Those methods are called on each coder in the array (using the priority order) until one of them returns YES. + That means that coder can decode that data / encode to that format + */ +@interface SDImageCodersManager : NSObject + +/** + Returns the global shared coders manager instance. + */ +@property (nonatomic, class, readonly, nonnull) SDImageCodersManager *sharedManager; + +/** + All coders in coders manager. The coders array is a priority queue, which means the later added coder will have the highest priority + */ +@property (nonatomic, copy, nullable) NSArray> *coders; + +/** + Add a new coder to the end of coders array. Which has the highest priority. + + @param coder coder + */ +- (void)addCoder:(nonnull id)coder; + +/** + Remove a coder in the coders array. + + @param coder coder + */ +- (void)removeCoder:(nonnull id)coder; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageCodersManager.m b/Pods/SDWebImage/SDWebImage/SDImageCodersManager.m new file mode 100644 index 00000000..2a25fdb2 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageCodersManager.m @@ -0,0 +1,131 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageCodersManager.h" +#import "SDImageIOCoder.h" +#import "SDImageGIFCoder.h" +#import "SDImageAPNGCoder.h" + +@interface SDImageCodersManager () + +@property (nonatomic, strong, nonnull) dispatch_semaphore_t codersLock; + +@end + +@implementation SDImageCodersManager +{ + NSMutableArray> *_imageCoders; +} + ++ (nonnull instancetype)sharedManager { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} + +- (instancetype)init { + if (self = [super init]) { + // initialize with default coders + _imageCoders = [NSMutableArray arrayWithArray:@[[SDImageIOCoder sharedCoder], [SDImageGIFCoder sharedCoder], [SDImageAPNGCoder sharedCoder]]]; + _codersLock = dispatch_semaphore_create(1); + } + return self; +} + +- (NSArray> *)coders +{ + SD_LOCK(self.codersLock); + NSArray> *coders = [_imageCoders copy]; + SD_UNLOCK(self.codersLock); + return coders; +} + +- (void)setCoders:(NSArray> *)coders +{ + SD_LOCK(self.codersLock); + [_imageCoders removeAllObjects]; + if (coders.count) { + [_imageCoders addObjectsFromArray:coders]; + } + SD_UNLOCK(self.codersLock); +} + +#pragma mark - Coder IO operations + +- (void)addCoder:(nonnull id)coder { + if (![coder conformsToProtocol:@protocol(SDImageCoder)]) { + return; + } + SD_LOCK(self.codersLock); + [_imageCoders addObject:coder]; + SD_UNLOCK(self.codersLock); +} + +- (void)removeCoder:(nonnull id)coder { + if (![coder conformsToProtocol:@protocol(SDImageCoder)]) { + return; + } + SD_LOCK(self.codersLock); + [_imageCoders removeObject:coder]; + SD_UNLOCK(self.codersLock); +} + +#pragma mark - SDImageCoder +- (BOOL)canDecodeFromData:(NSData *)data { + NSArray> *coders = self.coders; + for (id coder in coders.reverseObjectEnumerator) { + if ([coder canDecodeFromData:data]) { + return YES; + } + } + return NO; +} + +- (BOOL)canEncodeToFormat:(SDImageFormat)format { + NSArray> *coders = self.coders; + for (id coder in coders.reverseObjectEnumerator) { + if ([coder canEncodeToFormat:format]) { + return YES; + } + } + return NO; +} + +- (UIImage *)decodedImageWithData:(NSData *)data options:(nullable SDImageCoderOptions *)options { + if (!data) { + return nil; + } + UIImage *image; + NSArray> *coders = self.coders; + for (id coder in coders.reverseObjectEnumerator) { + if ([coder canDecodeFromData:data]) { + image = [coder decodedImageWithData:data options:options]; + break; + } + } + + return image; +} + +- (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format options:(nullable SDImageCoderOptions *)options { + if (!image) { + return nil; + } + NSArray> *coders = self.coders; + for (id coder in coders.reverseObjectEnumerator) { + if ([coder canEncodeToFormat:format]) { + return [coder encodedDataWithImage:image format:format options:options]; + } + } + return nil; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageFrame.h b/Pods/SDWebImage/SDWebImage/SDImageFrame.h new file mode 100644 index 00000000..a1082b46 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageFrame.h @@ -0,0 +1,34 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +@interface SDImageFrame : NSObject + +// This class is used for creating animated images via `animatedImageWithFrames` in `SDImageCoderHelper`. Attention if you need to specify animated images loop count, use `sd_imageLoopCount` property in `UIImage+Metadata.h`. + +/** + The image of current frame. You should not set an animated image. + */ +@property (nonatomic, strong, readonly, nonnull) UIImage *image; +/** + The duration of current frame to be displayed. The number is seconds but not milliseconds. You should not set this to zero. + */ +@property (nonatomic, readonly, assign) NSTimeInterval duration; + +/** + Create a frame instance with specify image and duration + + @param image current frame's image + @param duration current frame's duration + @return frame instance + */ ++ (instancetype _Nonnull)frameWithImage:(UIImage * _Nonnull)image duration:(NSTimeInterval)duration; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageFrame.m b/Pods/SDWebImage/SDWebImage/SDImageFrame.m new file mode 100644 index 00000000..f035af54 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageFrame.m @@ -0,0 +1,28 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageFrame.h" + +@interface SDImageFrame () + +@property (nonatomic, strong, readwrite, nonnull) UIImage *image; +@property (nonatomic, readwrite, assign) NSTimeInterval duration; + +@end + +@implementation SDImageFrame + ++ (instancetype)frameWithImage:(UIImage *)image duration:(NSTimeInterval)duration { + SDImageFrame *frame = [[SDImageFrame alloc] init]; + frame.image = image; + frame.duration = duration; + + return frame; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageGIFCoder.h b/Pods/SDWebImage/SDWebImage/SDImageGIFCoder.h new file mode 100644 index 00000000..1ecc7cb5 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageGIFCoder.h @@ -0,0 +1,22 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDImageCoder.h" + +/** + Built in coder using ImageIO that supports animated GIF encoding/decoding + @note `SDImageIOCoder` supports GIF but only as static (will use the 1st frame). + @note Use `SDImageGIFCoder` for fully animated GIFs. For `UIImageView`, it will produce animated `UIImage`(`NSImage` on macOS) for rendering. For `SDAnimatedImageView`, it will use `SDAnimatedImage` for rendering. + @note The recommended approach for animated GIFs is using `SDAnimatedImage` with `SDAnimatedImageView`. It's more performant than `UIImageView` for GIF displaying(especially on memory usage) + */ +@interface SDImageGIFCoder : NSObject + +@property (nonatomic, class, readonly, nonnull) SDImageGIFCoder *sharedCoder; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageGIFCoder.m b/Pods/SDWebImage/SDWebImage/SDImageGIFCoder.m new file mode 100644 index 00000000..2bea5b94 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageGIFCoder.m @@ -0,0 +1,419 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageGIFCoder.h" +#import "NSImage+Compatibility.h" +#import "UIImage+Metadata.h" +#import +#import "NSData+ImageContentType.h" +#import "SDImageCoderHelper.h" +#import "SDAnimatedImageRep.h" + +@interface SDGIFCoderFrame : NSObject + +@property (nonatomic, assign) NSUInteger index; // Frame index (zero based) +@property (nonatomic, assign) NSTimeInterval duration; // Frame duration in seconds + +@end + +@implementation SDGIFCoderFrame +@end + +@implementation SDImageGIFCoder { + size_t _width, _height; + CGImageSourceRef _imageSource; + NSData *_imageData; + CGFloat _scale; + NSUInteger _loopCount; + NSUInteger _frameCount; + NSArray *_frames; + BOOL _finished; +} + +- (void)dealloc +{ + if (_imageSource) { + CFRelease(_imageSource); + _imageSource = NULL; + } +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif +} + +- (void)didReceiveMemoryWarning:(NSNotification *)notification +{ + if (_imageSource) { + for (size_t i = 0; i < _frameCount; i++) { + CGImageSourceRemoveCacheAtIndex(_imageSource, i); + } + } +} + ++ (instancetype)sharedCoder { + static SDImageGIFCoder *coder; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + coder = [[SDImageGIFCoder alloc] init]; + }); + return coder; +} + +#pragma mark - Decode +- (BOOL)canDecodeFromData:(nullable NSData *)data { + return ([NSData sd_imageFormatForImageData:data] == SDImageFormatGIF); +} + +- (UIImage *)decodedImageWithData:(NSData *)data options:(nullable SDImageCoderOptions *)options { + if (!data) { + return nil; + } + CGFloat scale = 1; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } + +#if SD_MAC + SDAnimatedImageRep *imageRep = [[SDAnimatedImageRep alloc] initWithData:data]; + NSSize size = NSMakeSize(imageRep.pixelsWide / scale, imageRep.pixelsHigh / scale); + imageRep.size = size; + NSImage *animatedImage = [[NSImage alloc] initWithSize:size]; + [animatedImage addRepresentation:imageRep]; + return animatedImage; +#else + + CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); + if (!source) { + return nil; + } + size_t count = CGImageSourceGetCount(source); + UIImage *animatedImage; + + BOOL decodeFirstFrame = [options[SDImageCoderDecodeFirstFrameOnly] boolValue]; + if (decodeFirstFrame || count <= 1) { + animatedImage = [[UIImage alloc] initWithData:data scale:scale]; + } else { + NSMutableArray *frames = [NSMutableArray array]; + + for (size_t i = 0; i < count; i++) { + CGImageRef imageRef = CGImageSourceCreateImageAtIndex(source, i, NULL); + if (!imageRef) { + continue; + } + + float duration = [self sd_frameDurationAtIndex:i source:source]; + UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp]; + CGImageRelease(imageRef); + + SDImageFrame *frame = [SDImageFrame frameWithImage:image duration:duration]; + [frames addObject:frame]; + } + + NSUInteger loopCount = [self sd_imageLoopCountWithSource:source]; + + animatedImage = [SDImageCoderHelper animatedImageWithFrames:frames]; + animatedImage.sd_imageLoopCount = loopCount; + } + animatedImage.sd_imageFormat = SDImageFormatGIF; + CFRelease(source); + + return animatedImage; +#endif +} + +- (NSUInteger)sd_imageLoopCountWithSource:(CGImageSourceRef)source { + NSUInteger loopCount = 1; + NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, nil); + NSDictionary *gifProperties = imageProperties[(__bridge NSString *)kCGImagePropertyGIFDictionary]; + if (gifProperties) { + NSNumber *gifLoopCount = gifProperties[(__bridge NSString *)kCGImagePropertyGIFLoopCount]; + if (gifLoopCount != nil) { + loopCount = gifLoopCount.unsignedIntegerValue; + } + } + return loopCount; +} + +- (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { + float frameDuration = 0.1f; + CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); + if (!cfFrameProperties) { + return frameDuration; + } + NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; + NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary]; + + NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime]; + if (delayTimeUnclampedProp != nil) { + frameDuration = [delayTimeUnclampedProp floatValue]; + } else { + NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime]; + if (delayTimeProp != nil) { + frameDuration = [delayTimeProp floatValue]; + } + } + + // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. + // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify + // a duration of <= 10 ms. See and + // for more information. + + if (frameDuration < 0.011f) { + frameDuration = 0.100f; + } + + CFRelease(cfFrameProperties); + return frameDuration; +} + +#pragma mark - Progressive Decode + +- (BOOL)canIncrementalDecodeFromData:(NSData *)data { + return ([NSData sd_imageFormatForImageData:data] == SDImageFormatGIF); +} + +- (instancetype)initIncrementalWithOptions:(nullable SDImageCoderOptions *)options { + self = [super init]; + if (self) { + CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:SDImageFormatGIF]; + _imageSource = CGImageSourceCreateIncremental((__bridge CFDictionaryRef)@{(__bridge NSString *)kCGImageSourceTypeIdentifierHint : (__bridge NSString *)imageUTType}); + CGFloat scale = 1; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } + _scale = scale; +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif + } + return self; +} + +- (void)updateIncrementalData:(NSData *)data finished:(BOOL)finished { + if (_finished) { + return; + } + _imageData = data; + _finished = finished; + + // The following code is from http://www.cocoaintheshell.com/2011/05/progressive-images-download-imageio/ + // Thanks to the author @Nyx0uf + + // Update the data source, we must pass ALL the data, not just the new bytes + CGImageSourceUpdateData(_imageSource, (__bridge CFDataRef)data, finished); + + if (_width + _height == 0) { + CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(_imageSource, 0, NULL); + if (properties) { + CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight); + if (val) CFNumberGetValue(val, kCFNumberLongType, &_height); + val = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth); + if (val) CFNumberGetValue(val, kCFNumberLongType, &_width); + CFRelease(properties); + } + } + + // For animated image progressive decoding because the frame count and duration may be changed. + [self scanAndCheckFramesValidWithImageSource:_imageSource]; +} + +- (UIImage *)incrementalDecodedImageWithOptions:(SDImageCoderOptions *)options { + UIImage *image; + + if (_width + _height > 0) { + // Create the image + CGImageRef partialImageRef = CGImageSourceCreateImageAtIndex(_imageSource, 0, NULL); + + if (partialImageRef) { + CGFloat scale = _scale; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } +#if SD_UIKIT || SD_WATCH + image = [[UIImage alloc] initWithCGImage:partialImageRef scale:scale orientation:UIImageOrientationUp]; +#else + image = [[UIImage alloc] initWithCGImage:partialImageRef scale:scale orientation:kCGImagePropertyOrientationUp]; +#endif + CGImageRelease(partialImageRef); + image.sd_imageFormat = SDImageFormatGIF; + } + } + + return image; +} + +#pragma mark - Encode +- (BOOL)canEncodeToFormat:(SDImageFormat)format { + return (format == SDImageFormatGIF); +} + +- (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format options:(nullable SDImageCoderOptions *)options { + if (!image) { + return nil; + } + + if (format != SDImageFormatGIF) { + return nil; + } + + NSMutableData *imageData = [NSMutableData data]; + CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:SDImageFormatGIF]; + NSArray *frames = [SDImageCoderHelper framesFromAnimatedImage:image]; + + // Create an image destination. GIF does not support EXIF image orientation + CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, frames.count, NULL); + if (!imageDestination) { + // Handle failure. + return nil; + } + NSMutableDictionary *properties = [NSMutableDictionary dictionary]; + double compressionQuality = 1; + if (options[SDImageCoderEncodeCompressionQuality]) { + compressionQuality = [options[SDImageCoderEncodeCompressionQuality] doubleValue]; + } + properties[(__bridge NSString *)kCGImageDestinationLossyCompressionQuality] = @(compressionQuality); + + BOOL encodeFirstFrame = [options[SDImageCoderEncodeFirstFrameOnly] boolValue]; + if (encodeFirstFrame || frames.count == 0) { + // for static single GIF images + CGImageDestinationAddImage(imageDestination, image.CGImage, (__bridge CFDictionaryRef)properties); + } else { + // for animated GIF images + NSUInteger loopCount = image.sd_imageLoopCount; + NSDictionary *gifProperties = @{(__bridge NSString *)kCGImagePropertyGIFLoopCount : @(loopCount)}; + properties[(__bridge NSString *)kCGImagePropertyGIFDictionary] = gifProperties; + CGImageDestinationSetProperties(imageDestination, (__bridge CFDictionaryRef)properties); + + for (size_t i = 0; i < frames.count; i++) { + SDImageFrame *frame = frames[i]; + float frameDuration = frame.duration; + CGImageRef frameImageRef = frame.image.CGImage; + NSDictionary *frameProperties = @{(__bridge NSString *)kCGImagePropertyGIFDictionary : @{(__bridge NSString *)kCGImagePropertyGIFDelayTime : @(frameDuration)}}; + CGImageDestinationAddImage(imageDestination, frameImageRef, (__bridge CFDictionaryRef)frameProperties); + } + } + // Finalize the destination. + if (CGImageDestinationFinalize(imageDestination) == NO) { + // Handle failure. + imageData = nil; + } + + CFRelease(imageDestination); + + return [imageData copy]; +} + +#pragma mark - SDAnimatedImageCoder +- (nullable instancetype)initWithAnimatedImageData:(nullable NSData *)data options:(nullable SDImageCoderOptions *)options { + if (!data) { + return nil; + } + self = [super init]; + if (self) { + CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); + if (!imageSource) { + return nil; + } + BOOL framesValid = [self scanAndCheckFramesValidWithImageSource:imageSource]; + if (!framesValid) { + CFRelease(imageSource); + return nil; + } + CGFloat scale = 1; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } + _scale = scale; + _imageSource = imageSource; + _imageData = data; +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif + } + return self; +} + +- (BOOL)scanAndCheckFramesValidWithImageSource:(CGImageSourceRef)imageSource { + if (!imageSource) { + return NO; + } + NSUInteger frameCount = CGImageSourceGetCount(imageSource); + NSUInteger loopCount = [self sd_imageLoopCountWithSource:imageSource]; + NSMutableArray *frames = [NSMutableArray array]; + + for (size_t i = 0; i < frameCount; i++) { + SDGIFCoderFrame *frame = [[SDGIFCoderFrame alloc] init]; + frame.index = i; + frame.duration = [self sd_frameDurationAtIndex:i source:imageSource]; + [frames addObject:frame]; + } + + _frameCount = frameCount; + _loopCount = loopCount; + _frames = [frames copy]; + + return YES; +} + +- (NSData *)animatedImageData { + return _imageData; +} + +- (NSUInteger)animatedImageLoopCount { + return _loopCount; +} + +- (NSUInteger)animatedImageFrameCount { + return _frameCount; +} + +- (NSTimeInterval)animatedImageDurationAtIndex:(NSUInteger)index { + if (index >= _frameCount) { + return 0; + } + return _frames[index].duration; +} + +- (UIImage *)animatedImageFrameAtIndex:(NSUInteger)index { + CGImageRef imageRef = CGImageSourceCreateImageAtIndex(_imageSource, index, NULL); + if (!imageRef) { + return nil; + } + // Image/IO create CGImage does not decode, so we do this because this is called background queue, this can avoid main queue block when rendering(especially when one more imageViews use the same image instance) + CGImageRef newImageRef = [SDImageCoderHelper CGImageCreateDecoded:imageRef]; + if (!newImageRef) { + newImageRef = imageRef; + } else { + CGImageRelease(imageRef); + } +#if SD_MAC + UIImage *image = [[UIImage alloc] initWithCGImage:newImageRef scale:_scale orientation:kCGImagePropertyOrientationUp]; +#else + UIImage *image = [[UIImage alloc] initWithCGImage:newImageRef scale:_scale orientation:UIImageOrientationUp]; +#endif + CGImageRelease(newImageRef); + return image; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageGraphics.h b/Pods/SDWebImage/SDWebImage/SDImageGraphics.h new file mode 100644 index 00000000..6a41e9a2 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageGraphics.h @@ -0,0 +1,21 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import + +/** + These following graphics context method are provided to easily write cross-platform(AppKit/UIKit) code. + For UIKit, these methods just call the same method in `UIGraphics.h`. See the documentation for usage. + For AppKit, these methods use `NSGraphicsContext` to create image context and match the behavior like UIKit. + */ +FOUNDATION_EXPORT CGContextRef __nullable SDGraphicsGetCurrentContext(void) CF_RETURNS_NOT_RETAINED; +FOUNDATION_EXPORT void SDGraphicsBeginImageContext(CGSize size); +FOUNDATION_EXPORT void SDGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale); +FOUNDATION_EXPORT void SDGraphicsEndImageContext(void); +FOUNDATION_EXPORT UIImage * __nullable SDGraphicsGetImageFromCurrentImageContext(void); diff --git a/Pods/SDWebImage/SDWebImage/SDImageGraphics.m b/Pods/SDWebImage/SDWebImage/SDImageGraphics.m new file mode 100644 index 00000000..e7c4ed45 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageGraphics.m @@ -0,0 +1,105 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageGraphics.h" +#import "NSImage+Compatibility.h" +#import "objc/runtime.h" + +#if SD_MAC +static void *kNSGraphicsContextScaleFactorKey; + +static CGContextRef SDCGContextCreateBitmapContext(CGSize size, BOOL opaque, CGFloat scale) { + if (scale == 0) { + // Match `UIGraphicsBeginImageContextWithOptions`, reset to the scale factor of the device’s main screen if scale is 0. + scale = [NSScreen mainScreen].backingScaleFactor; + } + size_t width = ceil(size.width * scale); + size_t height = ceil(size.height * scale); + if (width < 1 || height < 1) return NULL; + + //pre-multiplied BGRA for non-opaque, BGRX for opaque, 8-bits per component, as Apple's doc + CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); + CGImageAlphaInfo alphaInfo = kCGBitmapByteOrder32Host | (opaque ? kCGImageAlphaNoneSkipFirst : kCGImageAlphaPremultipliedFirst); + CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 0, space, kCGBitmapByteOrderDefault | alphaInfo); + CGColorSpaceRelease(space); + if (!context) { + return NULL; + } + CGContextScaleCTM(context, scale, scale); + + return context; +} +#endif + +CGContextRef SDGraphicsGetCurrentContext(void) { +#if SD_UIKIT || SD_WATCH + return UIGraphicsGetCurrentContext(); +#else + return NSGraphicsContext.currentContext.CGContext; +#endif +} + +void SDGraphicsBeginImageContext(CGSize size) { +#if SD_UIKIT || SD_WATCH + UIGraphicsBeginImageContext(size); +#else + SDGraphicsBeginImageContextWithOptions(size, NO, 1.0); +#endif +} + +void SDGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale) { +#if SD_UIKIT || SD_WATCH + UIGraphicsBeginImageContextWithOptions(size, opaque, scale); +#else + CGContextRef context = SDCGContextCreateBitmapContext(size, opaque, scale); + if (!context) { + return; + } + NSGraphicsContext *graphicsContext = [NSGraphicsContext graphicsContextWithCGContext:context flipped:NO]; + objc_setAssociatedObject(graphicsContext, &kNSGraphicsContextScaleFactorKey, @(scale), OBJC_ASSOCIATION_RETAIN); + CGContextRelease(context); + [NSGraphicsContext saveGraphicsState]; + NSGraphicsContext.currentContext = graphicsContext; +#endif +} + +void SDGraphicsEndImageContext(void) { +#if SD_UIKIT || SD_WATCH + UIGraphicsEndImageContext(); +#else + [NSGraphicsContext restoreGraphicsState]; +#endif +} + +UIImage * SDGraphicsGetImageFromCurrentImageContext(void) { +#if SD_UIKIT || SD_WATCH + return UIGraphicsGetImageFromCurrentImageContext(); +#else + NSGraphicsContext *context = NSGraphicsContext.currentContext; + CGContextRef contextRef = context.CGContext; + if (!contextRef) { + return nil; + } + CGImageRef imageRef = CGBitmapContextCreateImage(contextRef); + if (!imageRef) { + return nil; + } + CGFloat scale = 0; + NSNumber *scaleFactor = objc_getAssociatedObject(context, &kNSGraphicsContextScaleFactorKey); + if ([scaleFactor isKindOfClass:[NSNumber class]]) { + scale = scaleFactor.doubleValue; + } + if (!scale) { + // reset to the scale factor of the device’s main screen if scale is 0. + scale = [NSScreen mainScreen].backingScaleFactor; + } + NSImage *image = [[NSImage alloc] initWithCGImage:imageRef scale:scale orientation:kCGImagePropertyOrientationUp]; + CGImageRelease(imageRef); + return image; +#endif +} diff --git a/Pods/SDWebImage/SDWebImage/SDImageIOCoder.h b/Pods/SDWebImage/SDWebImage/SDImageIOCoder.h new file mode 100644 index 00000000..98682ed6 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageIOCoder.h @@ -0,0 +1,30 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDImageCoder.h" + +/** + Built in coder that supports PNG, JPEG, TIFF, includes support for progressive decoding. + + GIF + Also supports static GIF (meaning will only handle the 1st frame). + For a full GIF support, we recommend `SDAnimatedImageView` to keep both CPU and memory balanced. + + HEIC + This coder also supports HEIC format because ImageIO supports it natively. But it depends on the system capabilities, so it won't work on all devices, see: https://devstreaming-cdn.apple.com/videos/wwdc/2017/511tj33587vdhds/511/511_working_with_heif_and_hevc.pdf + Decode(Software): !Simulator && (iOS 11 || tvOS 11 || macOS 10.13) + Decode(Hardware): !Simulator && ((iOS 11 && A9Chip) || (macOS 10.13 && 6thGenerationIntelCPU)) + Encode(Software): macOS 10.13 + Encode(Hardware): !Simulator && ((iOS 11 && A10FusionChip) || (macOS 10.13 && 6thGenerationIntelCPU)) + */ +@interface SDImageIOCoder : NSObject + +@property (nonatomic, class, readonly, nonnull) SDImageIOCoder *sharedCoder; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageIOCoder.m b/Pods/SDWebImage/SDWebImage/SDImageIOCoder.m new file mode 100644 index 00000000..c745fa1f --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageIOCoder.m @@ -0,0 +1,322 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageIOCoder.h" +#import "SDImageCoderHelper.h" +#import "NSImage+Compatibility.h" +#import +#import "UIImage+Metadata.h" + +@implementation SDImageIOCoder { + size_t _width, _height; + CGImagePropertyOrientation _orientation; + CGImageSourceRef _imageSource; + CGFloat _scale; + BOOL _finished; +} + +- (void)dealloc { + if (_imageSource) { + CFRelease(_imageSource); + _imageSource = NULL; + } +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif +} + +- (void)didReceiveMemoryWarning:(NSNotification *)notification +{ + if (_imageSource) { + CGImageSourceRemoveCacheAtIndex(_imageSource, 0); + } +} + ++ (instancetype)sharedCoder { + static SDImageIOCoder *coder; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + coder = [[SDImageIOCoder alloc] init]; + }); + return coder; +} + +#pragma mark - Decode +- (BOOL)canDecodeFromData:(nullable NSData *)data { + switch ([NSData sd_imageFormatForImageData:data]) { + case SDImageFormatWebP: + // Do not support WebP decoding + return NO; + case SDImageFormatHEIC: + // Check HEIC decoding compatibility + return [[self class] canDecodeFromHEICFormat]; + case SDImageFormatHEIF: + // Check HEIF decoding compatibility + return [[self class] canDecodeFromHEIFFormat]; + default: + return YES; + } +} + +- (UIImage *)decodedImageWithData:(NSData *)data options:(nullable SDImageCoderOptions *)options { + if (!data) { + return nil; + } + CGFloat scale = 1; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } + + UIImage *image = [[UIImage alloc] initWithData:data scale:scale]; + image.sd_imageFormat = [NSData sd_imageFormatForImageData:data]; + return image; +} + +#pragma mark - Progressive Decode + +- (BOOL)canIncrementalDecodeFromData:(NSData *)data { + switch ([NSData sd_imageFormatForImageData:data]) { + case SDImageFormatWebP: + // Do not support WebP progressive decoding + return NO; + case SDImageFormatHEIC: + // Check HEIC decoding compatibility + return [[self class] canDecodeFromHEICFormat]; + case SDImageFormatHEIF: + // Check HEIF decoding compatibility + return [[self class] canDecodeFromHEIFFormat]; + default: + return YES; + } +} + +- (instancetype)initIncrementalWithOptions:(nullable SDImageCoderOptions *)options { + self = [super init]; + if (self) { + _imageSource = CGImageSourceCreateIncremental(NULL); + CGFloat scale = 1; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } + _scale = scale; +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif + } + return self; +} + +- (void)updateIncrementalData:(NSData *)data finished:(BOOL)finished { + if (_finished) { + return; + } + _finished = finished; + + // The following code is from http://www.cocoaintheshell.com/2011/05/progressive-images-download-imageio/ + // Thanks to the author @Nyx0uf + + // Update the data source, we must pass ALL the data, not just the new bytes + CGImageSourceUpdateData(_imageSource, (__bridge CFDataRef)data, finished); + + if (_width + _height == 0) { + CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(_imageSource, 0, NULL); + if (properties) { + NSInteger orientationValue = 1; + CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight); + if (val) CFNumberGetValue(val, kCFNumberLongType, &_height); + val = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth); + if (val) CFNumberGetValue(val, kCFNumberLongType, &_width); + val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); + if (val) CFNumberGetValue(val, kCFNumberNSIntegerType, &orientationValue); + CFRelease(properties); + + // When we draw to Core Graphics, we lose orientation information, + // which means the image below born of initWithCGIImage will be + // oriented incorrectly sometimes. (Unlike the image born of initWithData + // in didCompleteWithError.) So save it here and pass it on later. + _orientation = (CGImagePropertyOrientation)orientationValue; + } + } +} + +- (UIImage *)incrementalDecodedImageWithOptions:(SDImageCoderOptions *)options { + UIImage *image; + + if (_width + _height > 0) { + // Create the image + CGImageRef partialImageRef = CGImageSourceCreateImageAtIndex(_imageSource, 0, NULL); + + if (partialImageRef) { + CGFloat scale = _scale; + NSNumber *scaleFactor = options[SDImageCoderDecodeScaleFactor]; + if (scaleFactor != nil) { + scale = [scaleFactor doubleValue]; + if (scale < 1) { + scale = 1; + } + } +#if SD_UIKIT || SD_WATCH + UIImageOrientation imageOrientation = [SDImageCoderHelper imageOrientationFromEXIFOrientation:_orientation]; + image = [[UIImage alloc] initWithCGImage:partialImageRef scale:scale orientation:imageOrientation]; +#else + image = [[UIImage alloc] initWithCGImage:partialImageRef scale:scale orientation:_orientation]; +#endif + CGImageRelease(partialImageRef); + CFStringRef uttype = CGImageSourceGetType(_imageSource); + image.sd_imageFormat = [NSData sd_imageFormatFromUTType:uttype]; + } + } + + return image; +} + +#pragma mark - Encode +- (BOOL)canEncodeToFormat:(SDImageFormat)format { + switch (format) { + case SDImageFormatWebP: + // Do not support WebP encoding + return NO; + case SDImageFormatHEIC: + // Check HEIC encoding compatibility + return [[self class] canEncodeToHEICFormat]; + case SDImageFormatHEIF: + // Check HEIF encoding compatibility + return [[self class] canEncodeToHEIFFormat]; + default: + return YES; + } +} + +- (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format options:(nullable SDImageCoderOptions *)options { + if (!image) { + return nil; + } + + if (format == SDImageFormatUndefined) { + BOOL hasAlpha = [SDImageCoderHelper CGImageContainsAlpha:image.CGImage]; + if (hasAlpha) { + format = SDImageFormatPNG; + } else { + format = SDImageFormatJPEG; + } + } + + NSMutableData *imageData = [NSMutableData data]; + CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format]; + + // Create an image destination. + CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, 1, NULL); + if (!imageDestination) { + // Handle failure. + return nil; + } + + NSMutableDictionary *properties = [NSMutableDictionary dictionary]; +#if SD_UIKIT || SD_WATCH + CGImagePropertyOrientation exifOrientation = [SDImageCoderHelper exifOrientationFromImageOrientation:image.imageOrientation]; +#else + CGImagePropertyOrientation exifOrientation = kCGImagePropertyOrientationUp; +#endif + properties[(__bridge NSString *)kCGImagePropertyOrientation] = @(exifOrientation); + double compressionQuality = 1; + if (options[SDImageCoderEncodeCompressionQuality]) { + compressionQuality = [options[SDImageCoderEncodeCompressionQuality] doubleValue]; + } + properties[(__bridge NSString *)kCGImageDestinationLossyCompressionQuality] = @(compressionQuality); + + // Add your image to the destination. + CGImageDestinationAddImage(imageDestination, image.CGImage, (__bridge CFDictionaryRef)properties); + + // Finalize the destination. + if (CGImageDestinationFinalize(imageDestination) == NO) { + // Handle failure. + imageData = nil; + } + + CFRelease(imageDestination); + + return [imageData copy]; +} + ++ (BOOL)canDecodeFromHEICFormat { + static BOOL canDecode = NO; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:SDImageFormatHEIC]; + NSArray *imageUTTypes = (__bridge_transfer NSArray *)CGImageSourceCopyTypeIdentifiers(); + if ([imageUTTypes containsObject:(__bridge NSString *)(imageUTType)]) { + canDecode = YES; + } + }); + return canDecode; +} + ++ (BOOL)canDecodeFromHEIFFormat { + static BOOL canDecode = NO; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:SDImageFormatHEIF]; + NSArray *imageUTTypes = (__bridge_transfer NSArray *)CGImageSourceCopyTypeIdentifiers(); + if ([imageUTTypes containsObject:(__bridge NSString *)(imageUTType)]) { + canDecode = YES; + } + }); + return canDecode; +} + ++ (BOOL)canEncodeToHEICFormat { + static BOOL canEncode = NO; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSMutableData *imageData = [NSMutableData data]; + CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:SDImageFormatHEIC]; + + // Create an image destination. + CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, 1, NULL); + if (!imageDestination) { + // Can't encode to HEIC + canEncode = NO; + } else { + // Can encode to HEIC + CFRelease(imageDestination); + canEncode = YES; + } + }); + return canEncode; +} + ++ (BOOL)canEncodeToHEIFFormat { + static BOOL canEncode = NO; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSMutableData *imageData = [NSMutableData data]; + CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:SDImageFormatHEIF]; + + // Create an image destination. + CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, 1, NULL); + if (!imageDestination) { + // Can't encode to HEIF + canEncode = NO; + } else { + // Can encode to HEIF + CFRelease(imageDestination); + canEncode = YES; + } + }); + return canEncode; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageLoader.h b/Pods/SDWebImage/SDWebImage/SDImageLoader.h new file mode 100644 index 00000000..136ac9e4 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageLoader.h @@ -0,0 +1,100 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "SDWebImageDefine.h" +#import "SDWebImageOperation.h" + +typedef void(^SDImageLoaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL); +typedef void(^SDImageLoaderCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished); + +#pragma mark - Context Options + +/** + A `UIImage` instance from `SDWebImageManager` when you specify `SDWebImageRefreshCached` and image cache hit. + This can be a hint for image loader to load the image from network and refresh the image from remote location if needed. If the image from remote location does not change, you should call the completion with `SDWebImageErrorCacheNotModified` error. (UIImage) + @note If you don't implement `SDWebImageRefreshCached` support, you do not need to care abot this context option. + */ +FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextLoaderCachedImage; + +#pragma mark - Helper method + +/** + This is the built-in decoding process for image download from network or local file. + @note If you want to implement your custom loader with `requestImageWithURL:options:context:progress:completed:` API, but also want to keep compatible with SDWebImage's behavior, you'd better use this to produce image. + + @param imageData The image data from the network. Should not be nil + @param imageURL The image URL from the input. Should not be nil + @param options The options arg from the input + @param context The context arg from the input + @return The decoded image for current image data load from the network + */ +FOUNDATION_EXPORT UIImage * _Nullable SDImageLoaderDecodeImageData(NSData * _Nonnull imageData, NSURL * _Nonnull imageURL, SDWebImageOptions options, SDWebImageContext * _Nullable context); + +/** + This is the built-in decoding process for image progressive download from network. It's used when `SDWebImageProgressiveLoad` option is set. (It's not required when your loader does not support progressive image loading) + @note If you want to implement your custom loader with `requestImageWithURL:options:context:progress:completed:` API, but also want to keep compatible with SDWebImage's behavior, you'd better use this to produce image. + + @param imageData The image data from the network so far. Should not be nil + @param imageURL The image URL from the input. Should not be nil + @param finished Pass NO to specify the download process has not finished. Pass YES when all image data has finished. + @param operation The loader operation associated with current progressive download. Why to provide this is because progressive decoding need to store the partial decoded context for each operation to avoid conflict. You should provide the operation from `loadImageWithURL:` method return value. + @param options The options arg from the input + @param context The context arg from the input + @return The decoded progressive image for current image data load from the network + */ +FOUNDATION_EXPORT UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NSData * _Nonnull imageData, NSURL * _Nonnull imageURL, BOOL finished, id _Nonnull operation, SDWebImageOptions options, SDWebImageContext * _Nullable context); + +#pragma mark - SDImageLoader + +// This is the protocol to specify custom image load process. You can create your own class to conform this protocol and use as a image loader to load image from network or any avaiable remote resources defined by yourself. +// If you want to implement custom loader for image download from network or local file, you just need to concentrate on image data download only. After the download finish, call `SDImageLoaderDecodeImageData` or `SDImageLoaderDecodeProgressiveImageData` to use the built-in decoding process and produce image (Remember to call in the global queue). And finally callback the completion block. +// If you directlly get the image instance using some third-party SDKs, such as image directlly from Photos framework. You can process the image data and image instance by yourself without that built-in decoding process. And finally callback the completion block. +// @note It's your responsibility to load the image in the desired global queue(to avoid block main queue). We do not dispatch these method call in a global queue but just from the call queue (For `SDWebImageManager`, it typically call from the main queue). + +@protocol SDImageLoader + +/** + Whether current image loader supports to load the provide image URL. + This will be checked everytime a new image request come for loader. If this return NO, we will mark this image load as failed. If return YES, we will start to call `requestImageWithURL:options:context:progress:completed:`. + + @param url The image URL to be loaded. + @return YES to continue download, NO to stop download. + */ +- (BOOL)canRequestImageForURL:(nullable NSURL *)url; + +/** + Load the image and image data with the given URL and return the image data. You're responsible for producing the image instance. + + @param url The URL represent the image. Note this may not be a HTTP URL + @param options A mask to specify options to use for this request + @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue + @param completedBlock A block called when operation has been completed. + @return An operation which allow the user to cancel the current request. + */ +- (nullable id)requestImageWithURL:(nullable NSURL *)url + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDImageLoaderCompletedBlock)completedBlock; + + +/** + Whether the error from image loader should be marked indded un-recoverable or not. + If this return YES, failed URL which does not using `SDWebImageRetryFailed` will be blocked into black list. Else not. + + @param url The URL represent the image. Note this may not be a HTTP URL + @param error The URL's loading error, from previous `requestImageWithURL:options:context:progress:completed:` completedBlock's error. + @return Whether to block this url or not. Return YES to mark this URL as failed. + */ +- (BOOL)shouldBlockFailedURLWithURL:(nonnull NSURL *)url + error:(nonnull NSError *)error; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageLoader.m b/Pods/SDWebImage/SDWebImage/SDImageLoader.m new file mode 100644 index 00000000..7d3db1a9 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageLoader.m @@ -0,0 +1,153 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageLoader.h" +#import "SDWebImageCacheKeyFilter.h" +#import "SDImageCodersManager.h" +#import "SDImageCoderHelper.h" +#import "SDAnimatedImage.h" +#import "UIImage+Metadata.h" +#import "objc/runtime.h" + +static void * SDImageLoaderProgressiveCoderKey = &SDImageLoaderProgressiveCoderKey; + +UIImage * _Nullable SDImageLoaderDecodeImageData(NSData * _Nonnull imageData, NSURL * _Nonnull imageURL, SDWebImageOptions options, SDWebImageContext * _Nullable context) { + NSCParameterAssert(imageData); + NSCParameterAssert(imageURL); + + UIImage *image; + id cacheKeyFilter = context[SDWebImageContextCacheKeyFilter]; + NSString *cacheKey; + if (cacheKeyFilter) { + cacheKey = [cacheKeyFilter cacheKeyForURL:imageURL]; + } else { + cacheKey = imageURL.absoluteString; + } + BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly; + NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor]; + CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey); + if (scale < 1) { + scale = 1; + } + SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)}; + if (context) { + SDImageCoderMutableOptions *mutableCoderOptions = [coderOptions mutableCopy]; + [mutableCoderOptions setValue:context forKey:SDImageCoderWebImageContext]; + coderOptions = [mutableCoderOptions copy]; + } + + if (!decodeFirstFrame) { + // check whether we should use `SDAnimatedImage` + Class animatedImageClass = context[SDWebImageContextAnimatedImageClass]; + if ([animatedImageClass isSubclassOfClass:[UIImage class]] && [animatedImageClass conformsToProtocol:@protocol(SDAnimatedImage)]) { + image = [[animatedImageClass alloc] initWithData:imageData scale:scale options:coderOptions]; + if (options & SDWebImagePreloadAllFrames && [image respondsToSelector:@selector(preloadAllFrames)]) { + [((id)image) preloadAllFrames]; + } + } + } + if (!image) { + image = [[SDImageCodersManager sharedManager] decodedImageWithData:imageData options:coderOptions]; + } + if (image) { + BOOL shouldDecode = (options & SDWebImageAvoidDecodeImage) == 0; + if ([image conformsToProtocol:@protocol(SDAnimatedImage)]) { + // `SDAnimatedImage` do not decode + shouldDecode = NO; + } else if (image.sd_isAnimated) { + // animated image do not decode + shouldDecode = NO; + } + + if (shouldDecode) { + BOOL shouldScaleDown = options & SDWebImageScaleDownLargeImages; + if (shouldScaleDown) { + image = [SDImageCoderHelper decodedAndScaledDownImageWithImage:image limitBytes:0]; + } else { + image = [SDImageCoderHelper decodedImageWithImage:image]; + } + } + } + + return image; +} + +UIImage * _Nullable SDImageLoaderDecodeProgressiveImageData(NSData * _Nonnull imageData, NSURL * _Nonnull imageURL, BOOL finished, id _Nonnull operation, SDWebImageOptions options, SDWebImageContext * _Nullable context) { + NSCParameterAssert(imageData); + NSCParameterAssert(imageURL); + NSCParameterAssert(operation); + + UIImage *image; + id cacheKeyFilter = context[SDWebImageContextCacheKeyFilter]; + NSString *cacheKey; + if (cacheKeyFilter) { + cacheKey = [cacheKeyFilter cacheKeyForURL:imageURL]; + } else { + cacheKey = imageURL.absoluteString; + } + BOOL decodeFirstFrame = options & SDWebImageDecodeFirstFrameOnly; + NSNumber *scaleValue = context[SDWebImageContextImageScaleFactor]; + CGFloat scale = scaleValue.doubleValue >= 1 ? scaleValue.doubleValue : SDImageScaleFactorForKey(cacheKey); + if (scale < 1) { + scale = 1; + } + SDImageCoderOptions *coderOptions = @{SDImageCoderDecodeFirstFrameOnly : @(decodeFirstFrame), SDImageCoderDecodeScaleFactor : @(scale)}; + if (context) { + SDImageCoderMutableOptions *mutableCoderOptions = [coderOptions mutableCopy]; + [mutableCoderOptions setValue:context forKey:SDImageCoderWebImageContext]; + coderOptions = [mutableCoderOptions copy]; + } + + id progressiveCoder = objc_getAssociatedObject(operation, SDImageLoaderProgressiveCoderKey); + if (!progressiveCoder) { + // We need to create a new instance for progressive decoding to avoid conflicts + for (idcoder in [SDImageCodersManager sharedManager].coders.reverseObjectEnumerator) { + if ([coder conformsToProtocol:@protocol(SDProgressiveImageCoder)] && + [((id)coder) canIncrementalDecodeFromData:imageData]) { + progressiveCoder = [[[coder class] alloc] initIncrementalWithOptions:coderOptions]; + break; + } + } + objc_setAssociatedObject(operation, SDImageLoaderProgressiveCoderKey, progressiveCoder, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + // If we can't find any progressive coder, disable progressive download + if (!progressiveCoder) { + return nil; + } + + [progressiveCoder updateIncrementalData:imageData finished:finished]; + if (!decodeFirstFrame) { + // check whether we should use `SDAnimatedImage` + Class animatedImageClass = context[SDWebImageContextAnimatedImageClass]; + if ([animatedImageClass isSubclassOfClass:[UIImage class]] && [animatedImageClass conformsToProtocol:@protocol(SDAnimatedImage)] && [progressiveCoder conformsToProtocol:@protocol(SDAnimatedImageCoder)]) { + image = [[animatedImageClass alloc] initWithAnimatedCoder:(id)progressiveCoder scale:scale]; + } + } + if (!image) { + image = [progressiveCoder incrementalDecodedImageWithOptions:coderOptions]; + } + if (image) { + BOOL shouldDecode = (options & SDWebImageAvoidDecodeImage) == 0; + if ([image 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]; + } + // mark the image as progressive (completionBlock one are not mark as progressive) + image.sd_isIncremental = YES; + } + + return image; +} + +SDWebImageContextOption const SDWebImageContextLoaderCachedImage = @"loaderCachedImage"; diff --git a/Pods/SDWebImage/SDWebImage/SDImageLoadersManager.h b/Pods/SDWebImage/SDWebImage/SDImageLoadersManager.h new file mode 100644 index 00000000..948ca3fa --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageLoadersManager.h @@ -0,0 +1,37 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageLoader.h" + +@interface SDImageLoadersManager : NSObject + +/** + Returns the global shared loaders manager instance. By default we will set [`SDWebImageDownloader.sharedDownloader`] into the loaders array. + */ +@property (nonatomic, class, readonly, nonnull) SDImageLoadersManager *sharedManager; + +/** + All image loaders in manager. The loaders array is a priority queue, which means the later added loader will have the highest priority + */ +@property (nonatomic, copy, nullable) NSArray>* loaders; + +/** + Add a new image loader to the end of loaders array. Which has the highest priority. + + @param loader loader + */ +- (void)addLoader:(nonnull id)loader; + +/** + Remove a image loader in the loaders array. + + @param loader loader + */ +- (void)removeLoader:(nonnull id)loader; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageLoadersManager.m b/Pods/SDWebImage/SDWebImage/SDImageLoadersManager.m new file mode 100644 index 00000000..002ef95a --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageLoadersManager.m @@ -0,0 +1,113 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageLoadersManager.h" +#import "SDWebImageDownloader.h" + +@interface SDImageLoadersManager () + +@property (nonatomic, strong, nonnull) dispatch_semaphore_t loadersLock; + +@end + +@implementation SDImageLoadersManager +{ + NSMutableArray>* _imageLoaders; +} + ++ (SDImageLoadersManager *)sharedManager { + static dispatch_once_t onceToken; + static SDImageLoadersManager *manager; + dispatch_once(&onceToken, ^{ + manager = [[SDImageLoadersManager alloc] init]; + }); + return manager; +} + +- (instancetype)init { + self = [super init]; + if (self) { + // initialize with default image loaders + _imageLoaders = [NSMutableArray arrayWithObject:[SDWebImageDownloader sharedDownloader]]; + _loadersLock = dispatch_semaphore_create(1); + } + return self; +} + +- (NSArray> *)loaders { + SD_LOCK(self.loadersLock); + NSArray>* loaders = [_imageLoaders copy]; + SD_UNLOCK(self.loadersLock); + return loaders; +} + +- (void)setLoaders:(NSArray> *)loaders { + SD_LOCK(self.loadersLock); + [_imageLoaders removeAllObjects]; + if (loaders.count) { + [_imageLoaders addObjectsFromArray:loaders]; + } + SD_UNLOCK(self.loadersLock); +} + +#pragma mark - Loader Property + +- (void)addLoader:(id)loader { + if (![loader conformsToProtocol:@protocol(SDImageLoader)]) { + return; + } + SD_LOCK(self.loadersLock); + [_imageLoaders addObject:loader]; + SD_UNLOCK(self.loadersLock); +} + +- (void)removeLoader:(id)loader { + if (![loader conformsToProtocol:@protocol(SDImageLoader)]) { + return; + } + SD_LOCK(self.loadersLock); + [_imageLoaders removeObject:loader]; + SD_UNLOCK(self.loadersLock); +} + +#pragma mark - SDImageLoader + +- (BOOL)canRequestImageForURL:(nullable NSURL *)url { + NSArray> *loaders = self.loaders; + for (id loader in loaders.reverseObjectEnumerator) { + if ([loader canRequestImageForURL:url]) { + return YES; + } + } + return NO; +} + +- (id)requestImageWithURL:(NSURL *)url options:(SDWebImageOptions)options context:(SDWebImageContext *)context progress:(SDImageLoaderProgressBlock)progressBlock completed:(SDImageLoaderCompletedBlock)completedBlock { + if (!url) { + return nil; + } + NSArray> *loaders = self.loaders; + for (id loader in loaders.reverseObjectEnumerator) { + if ([loader canRequestImageForURL:url]) { + return [loader requestImageWithURL:url options:options context:context progress:progressBlock completed:completedBlock]; + } + } + return nil; +} + +- (BOOL)shouldBlockFailedURLWithURL:(NSURL *)url error:(NSError *)error { + NSArray> *loaders = self.loaders; + for (id loader in loaders.reverseObjectEnumerator) { + if ([loader canRequestImageForURL:url]) { + return [loader shouldBlockFailedURLWithURL:url error:error]; + } + } + return NO; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDImageTransformer.h b/Pods/SDWebImage/SDWebImage/SDImageTransformer.h new file mode 100644 index 00000000..0a569ccc --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageTransformer.h @@ -0,0 +1,155 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "UIImage+Transform.h" + +/** + Return the transformed cache key which applied with specify transformerKey. + + @param key The original cache key + @param transformerKey The transformer key from the transformer + @return The transformed cache key + */ +FOUNDATION_EXPORT NSString * _Nullable SDTransformedKeyForKey(NSString * _Nullable key, NSString * _Nonnull transformerKey); + +/** + A transformer protocol to transform the image load from cache or from download. + You can provide transformer to cache and manager (Through the `transformer` property or context option `SDWebImageContextImageTransformer`). + + @note The transform process is called from a global queue in order to not to block the main queue. + */ +@protocol SDImageTransformer + +@required +/** + For each transformer, it must contains its cache key to used to store the image cache or query from the cache. This key will be appened after the original cache key generated by URL or from user. + + @return The cache key to appended after the original cache key. Should not be nil. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *transformerKey; + +/** + Transform the image to another image. + + @param image The image to be transformed + @param key The cache key associated to the image + @return The transformed image, or nil if transform failed + */ +- (nullable UIImage *)transformedImageWithImage:(nonnull UIImage *)image forKey:(nonnull NSString *)key; + +@end + +#pragma mark - Pipeline + +// Pipeline transformer. Which you can bind multiple transformers together to let the image to be transformed one by one in order and generate the final image. +// Because transformers are lightweight, if you want to append or arrange transfomers, create another pipeline transformer instead. This class is considered as immutable. +@interface SDImagePipelineTransformer : NSObject + +@property (nonatomic, copy, readonly, nonnull) NSArray> *transformers; + +- (nonnull instancetype)init NS_UNAVAILABLE; ++ (nonnull instancetype)transformerWithTransformers:(nonnull NSArray> *)transformers; + +@end + +// There are some built-in transformers based on the `UIImage+Transformer` category to provide the common image geometry, image blending and image effect process. Those transform are useful for static image only but you can create your own to support animated image as well. +// Because transformers are lightweight, these class are considered as immutable. +#pragma mark - Image Geometry + +// Image round corner transformer +@interface SDImageRoundCornerTransformer: NSObject + +@property (nonatomic, assign, readonly) CGFloat cornerRadius; +@property (nonatomic, assign, readonly) SDRectCorner corners; +@property (nonatomic, assign, readonly) CGFloat borderWidth; +@property (nonatomic, strong, readonly, nullable) UIColor *borderColor; + +- (nonnull instancetype)init NS_UNAVAILABLE; ++ (nonnull instancetype)transformerWithRadius:(CGFloat)cornerRadius corners:(SDRectCorner)corners borderWidth:(CGFloat)borderWidth borderColor:(nullable UIColor *)borderColor; + +@end + +// Image resizing transformer +@interface SDImageResizingTransformer : NSObject + +@property (nonatomic, assign, readonly) CGSize size; +@property (nonatomic, assign, readonly) SDImageScaleMode scaleMode; + +- (nonnull instancetype)init NS_UNAVAILABLE; ++ (nonnull instancetype)transformerWithSize:(CGSize)size scaleMode:(SDImageScaleMode)scaleMode; + +@end + +// Image cropping transformer +@interface SDImageCroppingTransformer : NSObject + +@property (nonatomic, assign, readonly) CGRect rect; + +- (nonnull instancetype)init NS_UNAVAILABLE; ++ (nonnull instancetype)transformerWithRect:(CGRect)rect; + +@end + +// Image flipping transformer +@interface SDImageFlippingTransformer : NSObject + +@property (nonatomic, assign, readonly) BOOL horizontal; +@property (nonatomic, assign, readonly) BOOL vertical; + +- (nonnull instancetype)init NS_UNAVAILABLE; ++ (nonnull instancetype)transformerWithHorizontal:(BOOL)horizontal vertical:(BOOL)vertical; + +@end + +// Image rotation transformer +@interface SDImageRotationTransformer : NSObject + +@property (nonatomic, assign, readonly) CGFloat angle; +@property (nonatomic, assign, readonly) BOOL fitSize; + +- (nonnull instancetype)init NS_UNAVAILABLE; ++ (nonnull instancetype)transformerWithAngle:(CGFloat)angle fitSize:(BOOL)fitSize; + +@end + +#pragma mark - Image Blending + +// Image tint color transformer +@interface SDImageTintTransformer : NSObject + +@property (nonatomic, strong, readonly, nonnull) UIColor *tintColor; + +- (nonnull instancetype)init NS_UNAVAILABLE; ++ (nonnull instancetype)transformerWithColor:(nonnull UIColor *)tintColor; + +@end + +#pragma mark - Image Effect + +// Image blur effect transformer +@interface SDImageBlurTransformer : NSObject + +@property (nonatomic, assign, readonly) CGFloat blurRadius; + +- (nonnull instancetype)init NS_UNAVAILABLE; ++ (nonnull instancetype)transformerWithRadius:(CGFloat)blurRadius; + +@end + +#if SD_UIKIT || SD_MAC +// Core Image filter transformer +@interface SDImageFilterTransformer: NSObject + +@property (nonatomic, strong, readonly, nonnull) CIFilter *filter; + +- (nonnull instancetype)init NS_UNAVAILABLE; ++ (nonnull instancetype)transformerWithFilter:(nonnull CIFilter *)filter; + +@end +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDImageTransformer.m b/Pods/SDWebImage/SDWebImage/SDImageTransformer.m new file mode 100644 index 00000000..26ee45cd --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDImageTransformer.m @@ -0,0 +1,326 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageTransformer.h" +#import "UIColor+HexString.h" +#if SD_UIKIT || SD_MAC +#import +#endif + +// Separator for different transformerKey, for example, `image.png` |> flip(YES,NO) |> rotate(pi/4,YES) => 'image-SDImageFlippingTransformer(1,0)-SDImageRotationTransformer(0.78539816339,1).png' +static NSString * const SDImageTransformerKeySeparator = @"-"; + +NSString * _Nullable SDTransformedKeyForKey(NSString * _Nullable key, NSString * _Nonnull transformerKey) { + if (!key || !transformerKey) { + return nil; + } + // Find the file extension + NSURL *keyURL = [NSURL URLWithString:key]; + NSString *ext = keyURL ? keyURL.pathExtension : key.pathExtension; + if (ext.length > 0) { + // For non-file URL + if (keyURL && !keyURL.isFileURL) { + // keep anything except path (like URL query) + NSURLComponents *component = [NSURLComponents componentsWithURL:keyURL resolvingAgainstBaseURL:NO]; + component.path = [[[component.path.stringByDeletingPathExtension stringByAppendingString:SDImageTransformerKeySeparator] stringByAppendingString:transformerKey] stringByAppendingPathExtension:ext]; + return component.URL.absoluteString; + } else { + // file URL + return [[[key.stringByDeletingPathExtension stringByAppendingString:SDImageTransformerKeySeparator] stringByAppendingString:transformerKey] stringByAppendingPathExtension:ext]; + } + } else { + return [[key stringByAppendingString:SDImageTransformerKeySeparator] stringByAppendingString:transformerKey]; + } +} + +@interface SDImagePipelineTransformer () + +@property (nonatomic, copy, readwrite, nonnull) NSArray> *transformers; +@property (nonatomic, copy, readwrite) NSString *transformerKey; + +@end + +@implementation SDImagePipelineTransformer + ++ (instancetype)transformerWithTransformers:(NSArray> *)transformers { + SDImagePipelineTransformer *transformer = [SDImagePipelineTransformer new]; + transformer.transformers = transformers; + transformer.transformerKey = [[self class] cacheKeyForTransformers:transformers]; + + return transformer; +} + ++ (NSString *)cacheKeyForTransformers:(NSArray> *)transformers { + if (transformers.count == 0) { + return @""; + } + NSMutableArray *cacheKeys = [NSMutableArray arrayWithCapacity:transformers.count]; + [transformers enumerateObjectsUsingBlock:^(id _Nonnull transformer, NSUInteger idx, BOOL * _Nonnull stop) { + NSString *cacheKey = transformer.transformerKey; + [cacheKeys addObject:cacheKey]; + }]; + + return [cacheKeys componentsJoinedByString:SDImageTransformerKeySeparator]; +} + +- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key { + if (!image) { + return nil; + } + UIImage *transformedImage = image; + for (id transformer in self.transformers) { + transformedImage = [transformer transformedImageWithImage:transformedImage forKey:key]; + } + return transformedImage; +} + +@end + +@interface SDImageRoundCornerTransformer () + +@property (nonatomic, assign) CGFloat cornerRadius; +@property (nonatomic, assign) SDRectCorner corners; +@property (nonatomic, assign) CGFloat borderWidth; +@property (nonatomic, strong, nullable) UIColor *borderColor; + +@end + +@implementation SDImageRoundCornerTransformer + ++ (instancetype)transformerWithRadius:(CGFloat)cornerRadius corners:(SDRectCorner)corners borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor { + SDImageRoundCornerTransformer *transformer = [SDImageRoundCornerTransformer new]; + transformer.cornerRadius = cornerRadius; + transformer.corners = corners; + transformer.borderWidth = borderWidth; + transformer.borderColor = borderColor; + + return transformer; +} + +- (NSString *)transformerKey { + return [NSString stringWithFormat:@"SDImageRoundCornerTransformer(%f,%lu,%f,%@)", self.cornerRadius, (unsigned long)self.corners, self.borderWidth, self.borderColor.sd_hexString]; +} + +- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key { + if (!image) { + return nil; + } + return [image sd_roundedCornerImageWithRadius:self.cornerRadius corners:self.corners borderWidth:self.borderWidth borderColor:self.borderColor]; +} + +@end + +@interface SDImageResizingTransformer () + +@property (nonatomic, assign) CGSize size; +@property (nonatomic, assign) SDImageScaleMode scaleMode; + +@end + +@implementation SDImageResizingTransformer + ++ (instancetype)transformerWithSize:(CGSize)size scaleMode:(SDImageScaleMode)scaleMode { + SDImageResizingTransformer *transformer = [SDImageResizingTransformer new]; + transformer.size = size; + transformer.scaleMode = scaleMode; + + return transformer; +} + +- (NSString *)transformerKey { + CGSize size = self.size; + return [NSString stringWithFormat:@"SDImageResizingTransformer({%f,%f},%lu)", size.width, size.height, (unsigned long)self.scaleMode]; +} + +- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key { + if (!image) { + return nil; + } + return [image sd_resizedImageWithSize:self.size scaleMode:self.scaleMode]; +} + +@end + +@interface SDImageCroppingTransformer () + +@property (nonatomic, assign) CGRect rect; + +@end + +@implementation SDImageCroppingTransformer + ++ (instancetype)transformerWithRect:(CGRect)rect { + SDImageCroppingTransformer *transformer = [SDImageCroppingTransformer new]; + transformer.rect = rect; + + return transformer; +} + +- (NSString *)transformerKey { + CGRect rect = self.rect; + return [NSString stringWithFormat:@"SDImageCroppingTransformer({%f,%f,%f,%f})", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height]; +} + +- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key { + if (!image) { + return nil; + } + return [image sd_croppedImageWithRect:self.rect]; +} + +@end + +@interface SDImageFlippingTransformer () + +@property (nonatomic, assign) BOOL horizontal; +@property (nonatomic, assign) BOOL vertical; + +@end + +@implementation SDImageFlippingTransformer + ++ (instancetype)transformerWithHorizontal:(BOOL)horizontal vertical:(BOOL)vertical { + SDImageFlippingTransformer *transformer = [SDImageFlippingTransformer new]; + transformer.horizontal = horizontal; + transformer.vertical = vertical; + + return transformer; +} + +- (NSString *)transformerKey { + return [NSString stringWithFormat:@"SDImageFlippingTransformer(%d,%d)", self.horizontal, self.vertical]; +} + +- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key { + if (!image) { + return nil; + } + return [image sd_flippedImageWithHorizontal:self.horizontal vertical:self.vertical]; +} + +@end + +@interface SDImageRotationTransformer () + +@property (nonatomic, assign) CGFloat angle; +@property (nonatomic, assign) BOOL fitSize; + +@end + +@implementation SDImageRotationTransformer + ++ (instancetype)transformerWithAngle:(CGFloat)angle fitSize:(BOOL)fitSize { + SDImageRotationTransformer *transformer = [SDImageRotationTransformer new]; + transformer.angle = angle; + transformer.fitSize = fitSize; + + return transformer; +} + +- (NSString *)transformerKey { + return [NSString stringWithFormat:@"SDImageRotationTransformer(%f,%d)", self.angle, self.fitSize]; +} + +- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key { + if (!image) { + return nil; + } + return [image sd_rotatedImageWithAngle:self.angle fitSize:self.fitSize]; +} + +@end + +#pragma mark - Image Blending + +@interface SDImageTintTransformer () + +@property (nonatomic, strong, nonnull) UIColor *tintColor; + +@end + +@implementation SDImageTintTransformer + ++ (instancetype)transformerWithColor:(UIColor *)tintColor { + SDImageTintTransformer *transformer = [SDImageTintTransformer new]; + transformer.tintColor = tintColor; + + return transformer; +} + +- (NSString *)transformerKey { + return [NSString stringWithFormat:@"SDImageTintTransformer(%@)", self.tintColor.sd_hexString]; +} + +- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key { + if (!image) { + return nil; + } + return [image sd_tintedImageWithColor:self.tintColor]; +} + +@end + +#pragma mark - Image Effect + +@interface SDImageBlurTransformer () + +@property (nonatomic, assign) CGFloat blurRadius; + +@end + +@implementation SDImageBlurTransformer + ++ (instancetype)transformerWithRadius:(CGFloat)blurRadius { + SDImageBlurTransformer *transformer = [SDImageBlurTransformer new]; + transformer.blurRadius = blurRadius; + + return transformer; +} + +- (NSString *)transformerKey { + return [NSString stringWithFormat:@"SDImageBlurTransformer(%f)", self.blurRadius]; +} + +- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key { + if (!image) { + return nil; + } + return [image sd_blurredImageWithRadius:self.blurRadius]; +} + +@end + +#if SD_UIKIT || SD_MAC +@interface SDImageFilterTransformer () + +@property (nonatomic, strong, nonnull) CIFilter *filter; + +@end + +@implementation SDImageFilterTransformer + ++ (instancetype)transformerWithFilter:(CIFilter *)filter { + SDImageFilterTransformer *transformer = [SDImageFilterTransformer new]; + transformer.filter = filter; + + return transformer; +} + +- (NSString *)transformerKey { + return [NSString stringWithFormat:@"SDImageFilterTransformer(%@)", self.filter.name]; +} + +- (UIImage *)transformedImageWithImage:(UIImage *)image forKey:(NSString *)key { + if (!image) { + return nil; + } + return [image sd_filteredImageWithFilter:self.filter]; +} + +@end +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDMemoryCache.h b/Pods/SDWebImage/SDWebImage/SDMemoryCache.h new file mode 100644 index 00000000..48c0c5f2 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDMemoryCache.h @@ -0,0 +1,73 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +@class SDImageCacheConfig; +// A protocol to allow custom memory cache used in SDImageCache. +@protocol SDMemoryCache + +@required +/** + Create a new memory cache instance with the specify cache config. You can check `maxMemoryCost` and `maxMemoryCount` used for memory cache. + + @param config The cache config to be used to create the cache. + @return The new memory cache instance. + */ +- (nonnull instancetype)initWithConfig:(nonnull SDImageCacheConfig *)config; + +/** + Returns the value associated with a given key. + + @param key An object identifying the value. If nil, just return nil. + @return The value associated with key, or nil if no value is associated with key. + */ +- (nullable id)objectForKey:(nonnull id)key; + +/** + Sets the value of the specified key in the cache (0 cost). + + @param object The object to be stored in the cache. If nil, it calls `removeObjectForKey:`. + @param key The key with which to associate the value. If nil, this method has no effect. + @discussion Unlike an NSMutableDictionary object, a cache does not copy the key + objects that are put into it. + */ +- (void)setObject:(nullable id)object forKey:(nonnull id)key; + +/** + Sets the value of the specified key in the cache, and associates the key-value + pair with the specified cost. + + @param object The object to store in the cache. If nil, it calls `removeObjectForKey`. + @param key The key with which to associate the value. If nil, this method has no effect. + @param cost The cost with which to associate the key-value pair. + @discussion Unlike an NSMutableDictionary object, a cache does not copy the key + objects that are put into it. + */ +- (void)setObject:(nullable id)object forKey:(nonnull id)key cost:(NSUInteger)cost; + +/** + Removes the value of the specified key in the cache. + + @param key The key identifying the value to be removed. If nil, this method has no effect. + */ +- (void)removeObjectForKey:(nonnull id)key; + +/** + Empties the cache immediately. + */ +- (void)removeAllObjects; + +@end + +// A memory cache which auto purge the cache on memory warning and support weak cache. +@interface SDMemoryCache : NSCache + +@property (nonatomic, strong, nonnull, readonly) SDImageCacheConfig *config; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDMemoryCache.m b/Pods/SDWebImage/SDWebImage/SDMemoryCache.m new file mode 100644 index 00000000..8a03f117 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDMemoryCache.m @@ -0,0 +1,152 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDMemoryCache.h" +#import "SDImageCacheConfig.h" +#import "UIImage+MemoryCacheCost.h" + +static void * SDMemoryCacheContext = &SDMemoryCacheContext; + +@interface SDMemoryCache () + +@property (nonatomic, strong, nullable) SDImageCacheConfig *config; +@property (nonatomic, strong, nonnull) NSMapTable *weakCache; // strong-weak cache +@property (nonatomic, strong, nonnull) dispatch_semaphore_t weakCacheLock; // a lock to keep the access to `weakCache` thread-safe + +@end + +@implementation SDMemoryCache + +- (void)dealloc { + [_config removeObserver:self forKeyPath:NSStringFromSelector(@selector(maxMemoryCost)) context:SDMemoryCacheContext]; + [_config removeObserver:self forKeyPath:NSStringFromSelector(@selector(maxMemoryCount)) context:SDMemoryCacheContext]; +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#endif +} + +- (instancetype)init { + self = [super init]; + if (self) { + _config = [[SDImageCacheConfig alloc] init]; + [self commonInit]; + } + return self; +} + +- (instancetype)initWithConfig:(SDImageCacheConfig *)config { + self = [super init]; + if (self) { + _config = config; + [self commonInit]; + } + return self; +} + +- (void)commonInit { + self.weakCache = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory valueOptions:NSPointerFunctionsWeakMemory capacity:0]; + self.weakCacheLock = dispatch_semaphore_create(1); + + SDImageCacheConfig *config = self.config; + self.totalCostLimit = config.maxMemoryCost; + self.countLimit = config.maxMemoryCount; + + [config addObserver:self forKeyPath:NSStringFromSelector(@selector(maxMemoryCost)) options:0 context:SDMemoryCacheContext]; + [config addObserver:self forKeyPath:NSStringFromSelector(@selector(maxMemoryCount)) options:0 context:SDMemoryCacheContext]; + +#if SD_UIKIT + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(didReceiveMemoryWarning:) + name:UIApplicationDidReceiveMemoryWarningNotification + object:nil]; +#endif +} + +// Current this seems no use on macOS (macOS use virtual memory and do not clear cache when memory warning). So we only override on iOS/tvOS platform. +#if SD_UIKIT +- (void)didReceiveMemoryWarning:(NSNotification *)notification { + // Only remove cache, but keep weak cache + [super removeAllObjects]; +} + +// `setObject:forKey:` just call this with 0 cost. Override this is enough +- (void)setObject:(id)obj forKey:(id)key cost:(NSUInteger)g { + [super setObject:obj forKey:key cost:g]; + if (!self.config.shouldUseWeakMemoryCache) { + return; + } + if (key && obj) { + // Store weak cache + SD_LOCK(self.weakCacheLock); + [self.weakCache setObject:obj forKey:key]; + SD_UNLOCK(self.weakCacheLock); + } +} + +- (id)objectForKey:(id)key { + id obj = [super objectForKey:key]; + if (!self.config.shouldUseWeakMemoryCache) { + return obj; + } + if (key && !obj) { + // Check weak cache + SD_LOCK(self.weakCacheLock); + obj = [self.weakCache objectForKey:key]; + SD_UNLOCK(self.weakCacheLock); + if (obj) { + // Sync cache + NSUInteger cost = 0; + if ([obj isKindOfClass:[UIImage class]]) { + cost = [(UIImage *)obj sd_memoryCost]; + } + [super setObject:obj forKey:key cost:cost]; + } + } + return obj; +} + +- (void)removeObjectForKey:(id)key { + [super removeObjectForKey:key]; + if (!self.config.shouldUseWeakMemoryCache) { + return; + } + if (key) { + // Remove weak cache + SD_LOCK(self.weakCacheLock); + [self.weakCache removeObjectForKey:key]; + SD_UNLOCK(self.weakCacheLock); + } +} + +- (void)removeAllObjects { + [super removeAllObjects]; + if (!self.config.shouldUseWeakMemoryCache) { + return; + } + // Manually remove should also remove weak cache + SD_LOCK(self.weakCacheLock); + [self.weakCache removeAllObjects]; + SD_UNLOCK(self.weakCacheLock); +} +#endif + +#pragma mark - KVO + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + if (context == SDMemoryCacheContext) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(maxMemoryCost))]) { + self.totalCostLimit = self.config.maxMemoryCost; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(maxMemoryCount))]) { + self.countLimit = self.config.maxMemoryCount; + } + } else { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageCacheKeyFilter.h b/Pods/SDWebImage/SDWebImage/SDWebImageCacheKeyFilter.h new file mode 100644 index 00000000..05dde712 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageCacheKeyFilter.h @@ -0,0 +1,26 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +typedef NSString * _Nullable(^SDWebImageCacheKeyFilterBlock)(NSURL * _Nonnull url); + +// This is the protocol for cache key filter. We can use a block to specify the cache key filter. But Using protocol can make this extensible, and allow Swift user to use it easily instead of using `@convention(block)` to store a block into context options. +@protocol SDWebImageCacheKeyFilter + +- (nullable NSString *)cacheKeyForURL:(nonnull NSURL *)url; + +@end + +@interface SDWebImageCacheKeyFilter : NSObject + +- (nonnull instancetype)initWithBlock:(nonnull SDWebImageCacheKeyFilterBlock)block; ++ (nonnull instancetype)cacheKeyFilterWithBlock:(nonnull SDWebImageCacheKeyFilterBlock)block; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageCacheKeyFilter.m b/Pods/SDWebImage/SDWebImage/SDWebImageCacheKeyFilter.m new file mode 100644 index 00000000..b4ebb8b4 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageCacheKeyFilter.m @@ -0,0 +1,39 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCacheKeyFilter.h" + +@interface SDWebImageCacheKeyFilter () + +@property (nonatomic, copy, nonnull) SDWebImageCacheKeyFilterBlock block; + +@end + +@implementation SDWebImageCacheKeyFilter + +- (instancetype)initWithBlock:(SDWebImageCacheKeyFilterBlock)block { + self = [super init]; + if (self) { + self.block = block; + } + return self; +} + ++ (instancetype)cacheKeyFilterWithBlock:(SDWebImageCacheKeyFilterBlock)block { + SDWebImageCacheKeyFilter *cacheKeyFilter = [[SDWebImageCacheKeyFilter alloc] initWithBlock:block]; + return cacheKeyFilter; +} + +- (NSString *)cacheKeyForURL:(NSURL *)url { + if (!self.block) { + return nil; + } + return self.block(url); +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageCacheSerializer.h b/Pods/SDWebImage/SDWebImage/SDWebImageCacheSerializer.h new file mode 100644 index 00000000..1a6c1698 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageCacheSerializer.h @@ -0,0 +1,26 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +typedef NSData * _Nullable(^SDWebImageCacheSerializerBlock)(UIImage * _Nonnull image, NSData * _Nullable data, NSURL * _Nullable imageURL); + +// This is the protocol for cache serializer. We can use a block to specify the cache serializer. But Using protocol can make this extensible, and allow Swift user to use it easily instead of using `@convention(block)` to store a block into context options. +@protocol SDWebImageCacheSerializer + +- (nullable NSData *)cacheDataWithImage:(nonnull UIImage *)image originalData:(nullable NSData *)data imageURL:(nullable NSURL *)imageURL; + +@end + +@interface SDWebImageCacheSerializer : NSObject + +- (nonnull instancetype)initWithBlock:(nonnull SDWebImageCacheSerializerBlock)block; ++ (nonnull instancetype)cacheSerializerWithBlock:(nonnull SDWebImageCacheSerializerBlock)block; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageCacheSerializer.m b/Pods/SDWebImage/SDWebImage/SDWebImageCacheSerializer.m new file mode 100644 index 00000000..51528e68 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageCacheSerializer.m @@ -0,0 +1,39 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCacheSerializer.h" + +@interface SDWebImageCacheSerializer () + +@property (nonatomic, copy, nonnull) SDWebImageCacheSerializerBlock block; + +@end + +@implementation SDWebImageCacheSerializer + +- (instancetype)initWithBlock:(SDWebImageCacheSerializerBlock)block { + self = [super init]; + if (self) { + self.block = block; + } + return self; +} + ++ (instancetype)cacheSerializerWithBlock:(SDWebImageCacheSerializerBlock)block { + SDWebImageCacheSerializer *cacheSerializer = [[SDWebImageCacheSerializer alloc] initWithBlock:block]; + return cacheSerializer; +} + +- (NSData *)cacheDataWithImage:(UIImage *)image originalData:(NSData *)data imageURL:(nullable NSURL *)imageURL { + if (!self.block) { + return nil; + } + return self.block(image, data, imageURL); +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h b/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h index f555c27d..f47a248a 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h +++ b/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h @@ -13,10 +13,9 @@ #error SDWebImage does not support Objective-C Garbage Collection #endif -// Apple's defines from TargetConditionals.h are a bit weird. // Seems like TARGET_OS_MAC is always defined (on all platforms). -// To determine if we are running on OSX, we can only relly on TARGET_OS_IPHONE=0 and all the other platforms -#if !TARGET_OS_IPHONE && !TARGET_OS_IOS && !TARGET_OS_TV && !TARGET_OS_WATCH +// To determine if we are running on macOS, use TARGET_OS_OSX in Xcode 8 +#if TARGET_OS_OSX #define SD_MAC 1 #else #define SD_MAC 0 @@ -60,16 +59,21 @@ #ifndef UIView #define UIView NSView #endif -#else - #if __IPHONE_OS_VERSION_MIN_REQUIRED != 20000 && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 - #error SDWebImage doesn't support Deployment Target version < 5.0 + #ifndef UIColor + #define UIColor NSColor #endif - +#else #if SD_UIKIT #import #endif #if SD_WATCH #import + #ifndef UIView + #define UIView WKInterfaceObject + #endif + #ifndef UIImageView + #define UIImageView WKInterfaceImage + #endif #endif #endif @@ -81,31 +85,11 @@ #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type #endif -#if OS_OBJECT_USE_OBJC - #undef SDDispatchQueueRelease - #undef SDDispatchQueueSetterSementics - #define SDDispatchQueueRelease(q) - #define SDDispatchQueueSetterSementics strong -#else - #undef SDDispatchQueueRelease - #undef SDDispatchQueueSetterSementics - #define SDDispatchQueueRelease(q) (dispatch_release(q)) - #define SDDispatchQueueSetterSementics assign -#endif - -extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); - -typedef void(^SDWebImageNoParamsBlock)(); - -extern NSString *const SDWebImageErrorDomain; - #ifndef dispatch_main_async_safe #define dispatch_main_async_safe(block)\ - if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) {\ + if (dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) == dispatch_queue_get_label(dispatch_get_main_queue())) {\ block();\ } else {\ dispatch_async(dispatch_get_main_queue(), block);\ } #endif - -static int64_t kAsyncTestTimeout = 5; diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m b/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m index ade04be1..12974010 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m +++ b/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m @@ -9,51 +9,9 @@ #import "SDWebImageCompat.h" #if !__has_feature(objc_arc) -#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag + #error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag #endif -inline UIImage *SDScaledImageForKey(NSString * _Nullable key, UIImage * _Nullable image) { - if (!image) { - return nil; - } - -#if SD_MAC - return image; -#elif SD_UIKIT || SD_WATCH - if ((image.images).count > 0) { - NSMutableArray *scaledImages = [NSMutableArray array]; - - for (UIImage *tempImage in image.images) { - [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; - } - - return [UIImage animatedImageWithImages:scaledImages duration:image.duration]; - } - else { -#if SD_WATCH - if ([[WKInterfaceDevice currentDevice] respondsToSelector:@selector(screenScale)]) { -#elif SD_UIKIT - if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { +#if !OS_OBJECT_USE_OBJC + #error SDWebImage need ARC for dispatch object #endif - CGFloat scale = 1; - if (key.length >= 8) { - NSRange range = [key rangeOfString:@"@2x."]; - if (range.location != NSNotFound) { - scale = 2.0; - } - - range = [key rangeOfString:@"@3x."]; - if (range.location != NSNotFound) { - scale = 3.0; - } - } - - UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; - image = scaledImage; - } - return image; - } -#endif -} - -NSString *const SDWebImageErrorDomain = @"SDWebImageErrorDomain"; diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m b/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m deleted file mode 100644 index cf5e6760..00000000 --- a/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m +++ /dev/null @@ -1,279 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * (c) james - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "SDWebImageDecoder.h" - -@implementation UIImage (ForceDecode) - -#if SD_UIKIT || SD_WATCH -static const size_t kBytesPerPixel = 4; -static const size_t kBitsPerComponent = 8; - -+ (nullable UIImage *)decodedImageWithImage:(nullable UIImage *)image { - if (![UIImage shouldDecodeImage:image]) { - return image; - } - - // autorelease the bitmap context and all vars to help system to free memory when there are memory warning. - // on iOS7, do not forget to call [[SDImageCache sharedImageCache] clearMemory]; - @autoreleasepool{ - - CGImageRef imageRef = image.CGImage; - CGColorSpaceRef colorspaceRef = [UIImage colorSpaceForImageRef:imageRef]; - - size_t width = CGImageGetWidth(imageRef); - size_t height = CGImageGetHeight(imageRef); - size_t bytesPerRow = kBytesPerPixel * width; - - // kCGImageAlphaNone is not supported in CGBitmapContextCreate. - // Since the original image here has no alpha info, use kCGImageAlphaNoneSkipLast - // to create bitmap graphics contexts without alpha info. - CGContextRef context = CGBitmapContextCreate(NULL, - width, - height, - kBitsPerComponent, - bytesPerRow, - colorspaceRef, - kCGBitmapByteOrderDefault|kCGImageAlphaNoneSkipLast); - if (context == NULL) { - return image; - } - - // Draw the image into the context and retrieve the new bitmap image without alpha - CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); - CGImageRef imageRefWithoutAlpha = CGBitmapContextCreateImage(context); - UIImage *imageWithoutAlpha = [UIImage imageWithCGImage:imageRefWithoutAlpha - scale:image.scale - orientation:image.imageOrientation]; - - CGContextRelease(context); - CGImageRelease(imageRefWithoutAlpha); - - return imageWithoutAlpha; - } -} - -/* - * Defines the maximum size in MB of the decoded image when the flag `SDWebImageScaleDownLargeImages` is set - * Suggested value for iPad1 and iPhone 3GS: 60. - * Suggested value for iPad2 and iPhone 4: 120. - * Suggested value for iPhone 3G and iPod 2 and earlier devices: 30. - */ -static const CGFloat kDestImageSizeMB = 60.0f; - -/* - * Defines the maximum size in MB of a tile used to decode image when the flag `SDWebImageScaleDownLargeImages` is set - * Suggested value for iPad1 and iPhone 3GS: 20. - * Suggested value for iPad2 and iPhone 4: 40. - * Suggested value for iPhone 3G and iPod 2 and earlier devices: 10. - */ -static const CGFloat kSourceImageTileSizeMB = 20.0f; - -static const CGFloat kBytesPerMB = 1024.0f * 1024.0f; -static const CGFloat kPixelsPerMB = kBytesPerMB / kBytesPerPixel; -static const CGFloat kDestTotalPixels = kDestImageSizeMB * kPixelsPerMB; -static const CGFloat kTileTotalPixels = kSourceImageTileSizeMB * kPixelsPerMB; - -static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to overlap the seems where tiles meet. - -+ (nullable UIImage *)decodedAndScaledDownImageWithImage:(nullable UIImage *)image { - if (![UIImage shouldDecodeImage:image]) { - return image; - } - - if (![UIImage shouldScaleDownImage:image]) { - return [UIImage decodedImageWithImage:image]; - } - - CGContextRef destContext; - - // autorelease the bitmap context and all vars to help system to free memory when there are memory warning. - // on iOS7, do not forget to call [[SDImageCache sharedImageCache] clearMemory]; - @autoreleasepool { - CGImageRef sourceImageRef = image.CGImage; - - CGSize sourceResolution = CGSizeZero; - sourceResolution.width = CGImageGetWidth(sourceImageRef); - sourceResolution.height = CGImageGetHeight(sourceImageRef); - float sourceTotalPixels = sourceResolution.width * sourceResolution.height; - // Determine the scale ratio to apply to the input image - // that results in an output image of the defined size. - // see kDestImageSizeMB, and how it relates to destTotalPixels. - float imageScale = kDestTotalPixels / sourceTotalPixels; - CGSize destResolution = CGSizeZero; - destResolution.width = (int)(sourceResolution.width*imageScale); - destResolution.height = (int)(sourceResolution.height*imageScale); - - // current color space - CGColorSpaceRef colorspaceRef = [UIImage colorSpaceForImageRef:sourceImageRef]; - - size_t bytesPerRow = kBytesPerPixel * destResolution.width; - - // Allocate enough pixel data to hold the output image. - void* destBitmapData = malloc( bytesPerRow * destResolution.height ); - if (destBitmapData == NULL) { - return image; - } - - // kCGImageAlphaNone is not supported in CGBitmapContextCreate. - // Since the original image here has no alpha info, use kCGImageAlphaNoneSkipLast - // to create bitmap graphics contexts without alpha info. - destContext = CGBitmapContextCreate(destBitmapData, - destResolution.width, - destResolution.height, - kBitsPerComponent, - bytesPerRow, - colorspaceRef, - kCGBitmapByteOrderDefault|kCGImageAlphaNoneSkipLast); - - if (destContext == NULL) { - free(destBitmapData); - return image; - } - CGContextSetInterpolationQuality(destContext, kCGInterpolationHigh); - - // Now define the size of the rectangle to be used for the - // incremental blits from the input image to the output image. - // we use a source tile width equal to the width of the source - // image due to the way that iOS retrieves image data from disk. - // iOS must decode an image from disk in full width 'bands', even - // if current graphics context is clipped to a subrect within that - // band. Therefore we fully utilize all of the pixel data that results - // from a decoding opertion by achnoring our tile size to the full - // width of the input image. - CGRect sourceTile = CGRectZero; - sourceTile.size.width = sourceResolution.width; - // The source tile height is dynamic. Since we specified the size - // of the source tile in MB, see how many rows of pixels high it - // can be given the input image width. - sourceTile.size.height = (int)(kTileTotalPixels / sourceTile.size.width ); - sourceTile.origin.x = 0.0f; - // The output tile is the same proportions as the input tile, but - // scaled to image scale. - CGRect destTile; - destTile.size.width = destResolution.width; - destTile.size.height = sourceTile.size.height * imageScale; - destTile.origin.x = 0.0f; - // The source seem overlap is proportionate to the destination seem overlap. - // this is the amount of pixels to overlap each tile as we assemble the ouput image. - float sourceSeemOverlap = (int)((kDestSeemOverlap/destResolution.height)*sourceResolution.height); - CGImageRef sourceTileImageRef; - // calculate the number of read/write operations required to assemble the - // output image. - int iterations = (int)( sourceResolution.height / sourceTile.size.height ); - // If tile height doesn't divide the image height evenly, add another iteration - // to account for the remaining pixels. - int remainder = (int)sourceResolution.height % (int)sourceTile.size.height; - if(remainder) { - iterations++; - } - // Add seem overlaps to the tiles, but save the original tile height for y coordinate calculations. - float sourceTileHeightMinusOverlap = sourceTile.size.height; - sourceTile.size.height += sourceSeemOverlap; - destTile.size.height += kDestSeemOverlap; - for( int y = 0; y < iterations; ++y ) { - @autoreleasepool { - sourceTile.origin.y = y * sourceTileHeightMinusOverlap + sourceSeemOverlap; - destTile.origin.y = destResolution.height - (( y + 1 ) * sourceTileHeightMinusOverlap * imageScale + kDestSeemOverlap); - sourceTileImageRef = CGImageCreateWithImageInRect( sourceImageRef, sourceTile ); - if( y == iterations - 1 && remainder ) { - float dify = destTile.size.height; - destTile.size.height = CGImageGetHeight( sourceTileImageRef ) * imageScale; - dify -= destTile.size.height; - destTile.origin.y += dify; - } - CGContextDrawImage( destContext, destTile, sourceTileImageRef ); - CGImageRelease( sourceTileImageRef ); - } - } - - CGImageRef destImageRef = CGBitmapContextCreateImage(destContext); - CGContextRelease(destContext); - if (destImageRef == NULL) { - return image; - } - UIImage *destImage = [UIImage imageWithCGImage:destImageRef scale:image.scale orientation:image.imageOrientation]; - CGImageRelease(destImageRef); - if (destImage == nil) { - return image; - } - return destImage; - } -} - -+ (BOOL)shouldDecodeImage:(nullable UIImage *)image { - // Prevent "CGBitmapContextCreateImage: invalid context 0x0" error - if (image == nil) { - return NO; - } - - // do not decode animated images - if (image.images != nil) { - return NO; - } - - CGImageRef imageRef = image.CGImage; - - CGImageAlphaInfo alpha = CGImageGetAlphaInfo(imageRef); - BOOL anyAlpha = (alpha == kCGImageAlphaFirst || - alpha == kCGImageAlphaLast || - alpha == kCGImageAlphaPremultipliedFirst || - alpha == kCGImageAlphaPremultipliedLast); - // do not decode images with alpha - if (anyAlpha) { - return NO; - } - - return YES; -} - -+ (BOOL)shouldScaleDownImage:(nonnull UIImage *)image { - BOOL shouldScaleDown = YES; - - CGImageRef sourceImageRef = image.CGImage; - CGSize sourceResolution = CGSizeZero; - sourceResolution.width = CGImageGetWidth(sourceImageRef); - sourceResolution.height = CGImageGetHeight(sourceImageRef); - float sourceTotalPixels = sourceResolution.width * sourceResolution.height; - float imageScale = kDestTotalPixels / sourceTotalPixels; - if (imageScale < 1) { - shouldScaleDown = YES; - } else { - shouldScaleDown = NO; - } - - return shouldScaleDown; -} - -+ (CGColorSpaceRef)colorSpaceForImageRef:(CGImageRef)imageRef { - // current - CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(CGImageGetColorSpace(imageRef)); - CGColorSpaceRef colorspaceRef = CGImageGetColorSpace(imageRef); - - BOOL unsupportedColorSpace = (imageColorSpaceModel == kCGColorSpaceModelUnknown || - imageColorSpaceModel == kCGColorSpaceModelMonochrome || - imageColorSpaceModel == kCGColorSpaceModelCMYK || - imageColorSpaceModel == kCGColorSpaceModelIndexed); - if (unsupportedColorSpace) { - colorspaceRef = CGColorSpaceCreateDeviceRGB(); - CFAutorelease(colorspaceRef); - } - return colorspaceRef; -} -#elif SD_MAC -+ (nullable UIImage *)decodedImageWithImage:(nullable UIImage *)image { - return image; -} - -+ (nullable UIImage *)decodedAndScaledDownImageWithImage:(nullable UIImage *)image { - return image; -} -#endif - -@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDefine.h b/Pods/SDWebImage/SDWebImage/SDWebImageDefine.h new file mode 100644 index 00000000..999c3b92 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageDefine.h @@ -0,0 +1,229 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +typedef void(^SDWebImageNoParamsBlock)(void); +typedef NSString * SDWebImageContextOption NS_EXTENSIBLE_STRING_ENUM; +typedef NSDictionary SDWebImageContext; +typedef NSMutableDictionary SDWebImageMutableContext; + +#pragma mark - Image scale + +/** + Return the image scale factor for the specify key, supports file name and url key. + This is the built-in way to check the scale factor when we have no context about it. Because scale factor is not stored in image data (It's typically from filename). + However, you can also provide custom scale factor as well, see `SDWebImageContextImageScaleFactor`. + + @param key The image cache key + @return The scale factor for image + */ +FOUNDATION_EXPORT CGFloat SDImageScaleFactorForKey(NSString * _Nullable key); + +/** + Scale the image with the scale factor for the specify key. If no need to scale, return the original image. + This works for `UIImage`(UIKit) or `NSImage`(AppKit). And this function also preserve the associated value in `UIImage+Metadata.h`. + @note This is actually a convenience function, which firstlly call `SDImageScaleFactorForKey` and then call `SDScaledImageForScaleFactor`, kept for backward compatibility. + + @param key The image cache key + @param image The image + @return The scaled image + */ +FOUNDATION_EXPORT UIImage * _Nullable SDScaledImageForKey(NSString * _Nullable key, UIImage * _Nullable image); + +/** + Scale the image with the scale factor. If no need to scale, return the original image. + This works for `UIImage`(UIKit) or `NSImage`(AppKit). And this function also preserve the associated value in `UIImage+Metadata.h`. + + @param scale The image scale factor + @param image The image + @return The scaled image + */ +FOUNDATION_EXPORT UIImage * _Nullable SDScaledImageForScaleFactor(CGFloat scale, UIImage * _Nullable image); + +#pragma mark - WebCache Options + +typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { + /** + * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying. + * This flag disable this blacklisting. + */ + SDWebImageRetryFailed = 1 << 0, + + /** + * By default, image downloads are started during UI interactions, this flags disable this feature, + * leading to delayed download on UIScrollView deceleration for instance. + */ + SDWebImageLowPriority = 1 << 1, + + /** + * This flag enables progressive download, the image is displayed progressively during download as a browser would do. + * By default, the image is only displayed once completely downloaded. + */ + SDWebImageProgressiveLoad = 1 << 2, + + /** + * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. + * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. + * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics. + * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image. + * + * Use this flag only if you can't make your URLs static with embedded cache busting parameter. + */ + SDWebImageRefreshCached = 1 << 3, + + /** + * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for + * extra time in background to let the request finish. If the background task expires the operation will be cancelled. + */ + SDWebImageContinueInBackground = 1 << 4, + + /** + * Handles cookies stored in NSHTTPCookieStore by setting + * NSMutableURLRequest.HTTPShouldHandleCookies = YES; + */ + SDWebImageHandleCookies = 1 << 5, + + /** + * Enable to allow untrusted SSL certificates. + * Useful for testing purposes. Use with caution in production. + */ + SDWebImageAllowInvalidSSLCertificates = 1 << 6, + + /** + * By default, images are loaded in the order in which they were queued. This flag moves them to + * the front of the queue. + */ + SDWebImageHighPriority = 1 << 7, + + /** + * By default, placeholder images are loaded while the image is loading. This flag will delay the loading + * of the placeholder image until after the image has finished loading. + */ + SDWebImageDelayPlaceholder = 1 << 8, + + /** + * We usually don't apply transform on animated images as most transformers could not manage animated images. + * Use this flag to transform them anyway. + */ + SDWebImageTransformAnimatedImage = 1 << 9, + + /** + * By default, image is added to the imageView after download. But in some cases, we want to + * have the hand before setting the image (apply a filter or add it with cross-fade animation for instance) + * Use this flag if you want to manually set the image in the completion when success + */ + SDWebImageAvoidAutoSetImage = 1 << 10, + + /** + * 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. + * This flag take no effect if `SDWebImageAvoidDecodeImage` is set. And it will be ignored if `SDWebImageProgressiveLoad` is set. + */ + SDWebImageScaleDownLargeImages = 1 << 11, + + /** + * By default, we do not query image data when the image is already cached in memory. This mask can force to query image data at the same time. However, this query is asynchronously unless you specify `SDWebImageQueryMemoryDataSync` + */ + SDWebImageQueryMemoryData = 1 << 12, + + /** + * By default, when you only specify `SDWebImageQueryMemoryData`, we query the memory image data asynchronously. Combined this mask as well to query the memory image data synchronously. + * @note Query data synchronously is not recommend, unless you want to ensure the image is loaded in the same runloop to avoid flashing during cell reusing. + */ + SDWebImageQueryMemoryDataSync = 1 << 13, + + /** + * By default, when the memory cache miss, we query the disk cache asynchronously. This mask can force to query disk cache (when memory cache miss) synchronously. + * @note These 3 query options can be combined together. For the full list about these masks combination, see wiki page. + * @note Query data synchronously is not recommend, unless you want to ensure the image is loaded in the same runloop to avoid flashing during cell reusing. + */ + SDWebImageQueryDiskDataSync = 1 << 14, + + /** + * By default, when the cache missed, the image is load from the loader. This flag can prevent this to load from cache only. + */ + SDWebImageFromCacheOnly = 1 << 15, + + /** + * By default, we query the cache before the image is load from the loader. This flag can prevent this to load from loader only. + */ + SDWebImageFromLoaderOnly = 1 << 16, + + /** + * By default, when you use `SDWebImageTransition` to do some view transition after the image load finished, this transition is only applied for image download from the network. This mask can force to apply view transition for memory and disk cache as well. + */ + SDWebImageForceTransition = 1 << 17, + + /** + * 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. + */ + SDWebImageAvoidDecodeImage = 1 << 18, + + /** + * By default, we decode the animated image. This flag can force decode the first frame only and produece the static image. + */ + SDWebImageDecodeFirstFrameOnly = 1 << 19, + + /** + * By default, for `SDAnimatedImage`, we decode the animated image frame during rendering to reduce memory usage. However, you can specify to preload all frames into memory to reduce CPU usage when the animated image is shared by lots of imageViews. + * This will actually trigger `preloadAllAnimatedImageFrames` in the background queue(Disk Cache & Download only). + */ + SDWebImagePreloadAllFrames = 1 << 20 +}; + + +#pragma mark - Context Options + +/** + A String to be used as the operation key for view category to store the image load operation. This is used for view instance which supports different image loading process. If nil, will use the class name as operation key. (NSString *) + */ +FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextSetImageOperationKey; + +/** + A SDWebImageManager instance to control the image download and cache process using in UIImageView+WebCache category and likes. If not provided, use the shared manager (SDWebImageManager *) + */ +FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextCustomManager; + +/** + A id instance which conforms `SDImageTransformer` protocol. It's used for image transform after the image load finished and store the transformed image to cache. If you provide one, it will ignore the `transformer` in manager and use provided one instead. (id) + */ +FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextImageTransformer; + +/** + A CGFloat raw value which specify the image scale factor. The number should be greater than or equal to 1.0. If not provide or the number is invalid, we will use the cache key to specify the scale factor. (NSNumber) + */ +FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextImageScaleFactor; + +/** + A SDImageCacheType raw value which specify the cache type when the image has just been downloaded and will be stored to the cache. Specify `SDImageCacheTypeNone` to disable cache storage; `SDImageCacheTypeDisk` to store in disk cache only; `SDImageCacheTypeMemory` to store in memory only. And `SDImageCacheTypeAll` to store in both memory cache and disk cache. + If not provide or the value is invalid, we will use `SDImageCacheTypeAll`. (NSNumber) + */ +FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextStoreCacheType; + +/** + A Class object which the instance is a `UIImage/NSImage` subclass and adopt `SDAnimatedImage` protocol. We will call `initWithData:scale:options:` to create the instance (or `initWithAnimatedCoder:scale:` when using progressive download) . If the instance create failed, fallback to normal `UIImage/NSImage`. + This can be used to improve animated images rendering performance (especially memory usage on big animated images) with `SDAnimatedImageView` (Class). + */ +FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextAnimatedImageClass; + +/** + A id instance to modify the image download request. It's used for downloader to modify the original request from URL and options. If you provide one, it will ignore the `requestModifier` in downloader and use provided one instead. (id) + */ +FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextDownloadRequestModifier; + +/** + A id instance to convert an URL into a cache key. It's used when manager need cache key to use image cache. If you provide one, it will ignore the `cacheKeyFilter` in manager and use provided one instead. (id) + */ +FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextCacheKeyFilter; + +/** + A id instance to convert the decoded image, the source downloaded data, to the actual data. It's used for manager to store image to the disk cache. If you provide one, it will ignore the `cacheSerializer` in manager and use provided one instead. (id) + */ +FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextCacheSerializer; diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDefine.m b/Pods/SDWebImage/SDWebImage/SDWebImageDefine.m new file mode 100644 index 00000000..d339020a --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageDefine.m @@ -0,0 +1,128 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageDefine.h" +#import "UIImage+Metadata.h" +#import "NSImage+Compatibility.h" + +#pragma mark - Image scale + +static inline NSArray * _Nonnull SDImageScaleFactors() { + return @[@2, @3]; +} + +inline CGFloat SDImageScaleFactorForKey(NSString * _Nullable key) { + CGFloat scale = 1; + if (!key) { + return scale; + } + // Check if target OS support scale +#if SD_WATCH + if ([[WKInterfaceDevice currentDevice] respondsToSelector:@selector(screenScale)]) +#elif SD_UIKIT + if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) +#elif SD_MAC + if ([[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)]) +#endif + { + // a@2x.png -> 8 + if (key.length >= 8) { + // Fast check + BOOL isURL = [key hasPrefix:@"http://"] || [key hasPrefix:@"https://"]; + for (NSNumber *scaleFactor in SDImageScaleFactors()) { + // @2x. for file name and normal url + NSString *fileScale = [NSString stringWithFormat:@"@%@x.", scaleFactor]; + if ([key containsString:fileScale]) { + scale = scaleFactor.doubleValue; + return scale; + } + if (isURL) { + // %402x. for url encode + NSString *urlScale = [NSString stringWithFormat:@"%%40%@x.", scaleFactor]; + if ([key containsString:urlScale]) { + scale = scaleFactor.doubleValue; + return scale; + } + } + } + } + } + return scale; +} + +inline UIImage * _Nullable SDScaledImageForKey(NSString * _Nullable key, UIImage * _Nullable image) { + if (!image) { + return nil; + } + CGFloat scale = SDImageScaleFactorForKey(key); + return SDScaledImageForScaleFactor(scale, image); +} + +inline UIImage * _Nullable SDScaledImageForScaleFactor(CGFloat scale, UIImage * _Nullable image) { + if (!image) { + return nil; + } + if (scale <= 1) { + return image; + } + if (scale == image.scale) { + return image; + } + UIImage *scaledImage; + if (image.sd_isAnimated) { + UIImage *animatedImage; +#if SD_UIKIT || SD_WATCH + // `UIAnimatedImage` images share the same size and scale. + NSMutableArray *scaledImages = [NSMutableArray array]; + + for (UIImage *tempImage in image.images) { + UIImage *tempScaledImage = [[UIImage alloc] initWithCGImage:tempImage.CGImage scale:scale orientation:tempImage.imageOrientation]; + [scaledImages addObject:tempScaledImage]; + } + + animatedImage = [UIImage animatedImageWithImages:scaledImages duration:image.duration]; + animatedImage.sd_imageLoopCount = image.sd_imageLoopCount; +#else + // Animated GIF for `NSImage` need to grab `NSBitmapImageRep`; + NSRect imageRect = NSMakeRect(0, 0, image.size.width, image.size.height); + NSImageRep *imageRep = [image bestRepresentationForRect:imageRect context:nil hints:nil]; + NSBitmapImageRep *bitmapImageRep; + if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) { + bitmapImageRep = (NSBitmapImageRep *)imageRep; + } + if (bitmapImageRep) { + NSSize size = NSMakeSize(image.size.width / scale, image.size.height / scale); + animatedImage = [[NSImage alloc] initWithSize:size]; + [animatedImage addRepresentation:bitmapImageRep]; + } +#endif + scaledImage = animatedImage; + } else { +#if SD_UIKIT || SD_WATCH + scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; +#else + scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:kCGImagePropertyOrientationUp]; +#endif + } + scaledImage.sd_isIncremental = image.sd_isIncremental; + scaledImage.sd_imageFormat = image.sd_imageFormat; + + return scaledImage; +} + +#pragma mark - Context option + +SDWebImageContextOption const SDWebImageContextSetImageOperationKey = @"setImageOperationKey"; +SDWebImageContextOption const SDWebImageContextCustomManager = @"customManager"; +SDWebImageContextOption const SDWebImageContextImageTransformer = @"imageTransformer"; +SDWebImageContextOption const SDWebImageContextImageScaleFactor = @"imageScaleFactor"; +SDWebImageContextOption const SDWebImageContextStoreCacheType = @"storeCacheType"; +SDWebImageContextOption const SDWebImageContextAnimatedImageClass = @"animatedImageClass"; +SDWebImageContextOption const SDWebImageContextDownloadRequestModifier = @"downloadRequestModifier"; +SDWebImageContextOption const SDWebImageContextCacheKeyFilter = @"cacheKeyFilter"; +SDWebImageContextOption const SDWebImageContextCacheSerializer = @"cacheSerializer"; diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h b/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h index 94bc76e5..f4e3830f 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h +++ b/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h @@ -8,11 +8,22 @@ #import #import "SDWebImageCompat.h" +#import "SDWebImageDefine.h" #import "SDWebImageOperation.h" +#import "SDWebImageDownloaderConfig.h" +#import "SDWebImageDownloaderRequestModifier.h" +#import "SDImageLoader.h" typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { + /** + * Put the download in the low queue priority and task priority. + */ SDWebImageDownloaderLowPriority = 1 << 0, - SDWebImageDownloaderProgressiveDownload = 1 << 1, + + /** + * This flag enables progressive download, the image is displayed progressively during download as a browser would do. + */ + SDWebImageDownloaderProgressiveLoad = 1 << 1, /** * By default, request prevent the use of NSURLCache. With this flag, NSURLCache @@ -22,15 +33,15 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { /** * Call completion block with nil image/imageData if the image was read from NSURLCache - * (to be combined with `SDWebImageDownloaderUseNSURLCache`). + * And the error code is `SDWebImageErrorCacheNotModified` + * This flag should be combined with `SDWebImageDownloaderUseNSURLCache`. */ - SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, + /** * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for * extra time in background to let the request finish. If the background task expires the operation will be cancelled. */ - SDWebImageDownloaderContinueInBackground = 1 << 4, /** @@ -46,125 +57,123 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6, /** - * Put the image in the high priority queue. + * Put the download in the high queue priority and task priority. */ SDWebImageDownloaderHighPriority = 1 << 7, /** - * Scale down the image + * 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. + * This flag take no effect if `SDWebImageDownloaderAvoidDecodeImage` is set. And it will be ignored if `SDWebImageDownloaderProgressiveLoad` is set. */ SDWebImageDownloaderScaleDownLargeImages = 1 << 8, -}; - -typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { + /** - * Default value. All download operations will execute in queue style (first-in-first-out). + * 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. */ - SDWebImageDownloaderFIFOExecutionOrder, - + SDWebImageDownloaderAvoidDecodeImage = 1 << 9, + + /** + * By default, we decode the animated image. This flag can force decode the first frame only and produece the static image. + */ + SDWebImageDownloaderDecodeFirstFrameOnly = 1 << 10, + /** - * All download operations will execute in stack style (last-in-first-out). + * 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 network */ - SDWebImageDownloaderLIFOExecutionOrder + SDWebImageDownloaderPreloadAllFrames = 1 << 11 }; -extern NSString * _Nonnull const SDWebImageDownloadStartNotification; -extern NSString * _Nonnull const SDWebImageDownloadStopNotification; - -typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL); - -typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished); +FOUNDATION_EXPORT NSNotificationName _Nonnull const SDWebImageDownloadStartNotification; +FOUNDATION_EXPORT NSNotificationName _Nonnull const SDWebImageDownloadReceiveResponseNotification; +FOUNDATION_EXPORT NSNotificationName _Nonnull const SDWebImageDownloadStopNotification; +FOUNDATION_EXPORT NSNotificationName _Nonnull const SDWebImageDownloadFinishNotification; -typedef NSDictionary SDHTTPHeadersDictionary; -typedef NSMutableDictionary SDHTTPHeadersMutableDictionary; - -typedef SDHTTPHeadersDictionary * _Nullable (^SDWebImageDownloaderHeadersFilterBlock)(NSURL * _Nullable url, SDHTTPHeadersDictionary * _Nullable headers); +typedef SDImageLoaderProgressBlock SDWebImageDownloaderProgressBlock; +typedef SDImageLoaderCompletedBlock SDWebImageDownloaderCompletedBlock; /** * A token associated with each download. Can be used to cancel a download */ -@interface SDWebImageDownloadToken : NSObject - -@property (nonatomic, strong, nullable) NSURL *url; -@property (nonatomic, strong, nullable) id downloadOperationCancelToken; - -@end - +@interface SDWebImageDownloadToken : NSObject /** - * Asynchronous downloader dedicated and optimized for image loading. + Cancel the current download. */ -@interface SDWebImageDownloader : NSObject +- (void)cancel; /** - * Decompressing images that are downloaded and cached can improve performance but can consume lot of memory. - * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. + The download's URL. */ -@property (assign, nonatomic) BOOL shouldDecompressImages; +@property (nonatomic, strong, nullable, readonly) NSURL *url; /** - * The maximum number of concurrent downloads + The download's request. */ -@property (assign, nonatomic) NSInteger maxConcurrentDownloads; +@property (nonatomic, strong, nullable, readonly) NSURLRequest *request; /** - * Shows the current amount of downloads that still need to be downloaded + The download's response. */ -@property (readonly, nonatomic) NSUInteger currentDownloadCount; +@property (nonatomic, strong, nullable, readonly) NSURLResponse *response; + +@end /** - * The timeout value (in seconds) for the download operation. Default: 15.0. + * Asynchronous downloader dedicated and optimized for image loading. */ -@property (assign, nonatomic) NSTimeInterval downloadTimeout; - +@interface SDWebImageDownloader : NSObject /** - * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. + * Downloader Config object - storing all kind of settings. + * Most config properties support dynamic changes during download, except something like `sessionConfiguration`, see `SDWebImageDownloaderConfig` for more detail. */ -@property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder; +@property (nonatomic, copy, readonly, nonnull) SDWebImageDownloaderConfig *config; /** - * Singleton method, returns the shared instance - * - * @return global shared instance of downloader class + * Set the request modifier to modify the original download request before image load. + * This request modifier method will be called for each downloading image request. Return the original request means no modication. Return nil will cancel the download request. + * Defaults to nil, means does not modify the original download request. + * @note If you want to modify single request, consider using `SDWebImageContextDownloadRequestModifier` context option. */ -+ (nonnull instancetype)sharedDownloader; +@property (nonatomic, strong, nullable) id requestModifier; /** - * Set the default URL credential to be set for request operations. + * The configuration in use by the internal NSURLSession. If you want to provide a custom sessionConfiguration, use `SDWebImageDownloaderConfig.sessionConfiguration` and create a new downloader instance. + @note This is immutable according to NSURLSession's documentation. Mutating this object directly has no effect. */ -@property (strong, nonatomic, nullable) NSURLCredential *urlCredential; +@property (nonatomic, readonly, nonnull) NSURLSessionConfiguration *sessionConfiguration; /** - * Set username + * Gets/Sets the download queue suspension state. */ -@property (strong, nonatomic, nullable) NSString *username; +@property (nonatomic, assign, getter=isSuspended) BOOL suspended; /** - * Set password + * Shows the current amount of downloads that still need to be downloaded */ -@property (strong, nonatomic, nullable) NSString *password; +@property (nonatomic, assign, readonly) NSUInteger currentDownloadCount; /** - * Set filter to pick headers for downloading image HTTP request. - * - * This block will be invoked for each downloading image request, returned - * NSDictionary will be used as headers in corresponding HTTP request. + * Returns the global shared downloader instance. Which use the `SDWebImageDownloaderConfig.defaultDownloaderConfig` config. */ -@property (nonatomic, copy, nullable) SDWebImageDownloaderHeadersFilterBlock headersFilter; +@property (nonatomic, class, readonly, nonnull) SDWebImageDownloader *sharedDownloader; /** - * Creates an instance of a downloader with specified session configuration. - * *Note*: `timeoutIntervalForRequest` is going to be overwritten. - * @return new instance of downloader class + Creates an instance of a downloader with specified downloader config. + You can specify session configuration, timeout or operation class through downloader config. + + @param config The downloader config. If you specify nil, the `defaultDownloaderConfig` will be used. + @return new instance of downloader class */ -- (nonnull instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)sessionConfiguration NS_DESIGNATED_INITIALIZER; +- (nonnull instancetype)initWithConfig:(nullable SDWebImageDownloaderConfig *)config NS_DESIGNATED_INITIALIZER; /** * Set a value for a HTTP header to be appended to each download HTTP request. * - * @param value The value for the header field. Use `nil` value to remove the header. + * @param value The value for the header field. Use `nil` value to remove the header field. * @param field The name of the header field to set. */ - (void)setValue:(nullable NSString *)value forHTTPHeaderField:(nullable NSString *)field; @@ -177,14 +186,26 @@ typedef SDHTTPHeadersDictionary * _Nullable (^SDWebImageDownloaderHeadersFilterB - (nullable NSString *)valueForHTTPHeaderField:(nullable NSString *)field; /** - * Sets a subclass of `SDWebImageDownloaderOperation` as the default - * `NSOperation` to be used each time SDWebImage constructs a request - * operation to download an image. + * Creates a SDWebImageDownloader async downloader instance with a given URL + * + * The delegate will be informed when the image is finish downloaded or an error has happen. + * + * @see SDWebImageDownloaderDelegate * - * @param operationClass The subclass of `SDWebImageDownloaderOperation` to set - * as default. Passing `nil` will revert to `SDWebImageDownloaderOperation`. + * @param url The URL to the image to download + * @param completedBlock A block called once the download is completed. + * If the download succeeded, the image parameter is set, in case of error, + * error parameter is set with the error. The last parameter is always YES + * if SDWebImageDownloaderProgressiveDownload isn't use. With the + * SDWebImageDownloaderProgressiveDownload option, this block is called + * repeatedly with the partial image object and the finished argument set to NO + * before to be called a last time with the full image and finished argument + * set to YES. In case of error, the finished argument is always YES. + * + * @return A token (SDWebImageDownloadToken) that can be used to cancel this operation */ -- (void)setOperationClass:(nullable Class)operationClass; +- (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url + completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock; /** * Creates a SDWebImageDownloader async downloader instance with a given URL @@ -200,13 +221,13 @@ typedef SDHTTPHeadersDictionary * _Nullable (^SDWebImageDownloaderHeadersFilterB * @param completedBlock A block called once the download is completed. * If the download succeeded, the image parameter is set, in case of error, * error parameter is set with the error. The last parameter is always YES - * if SDWebImageDownloaderProgressiveDownload isn't use. With the - * SDWebImageDownloaderProgressiveDownload option, this block is called + * if SDWebImageDownloaderProgressiveLoad isn't use. With the + * SDWebImageDownloaderProgressiveLoad option, this block is called * repeatedly with the partial image object and the finished argument set to NO * before to be called a last time with the full image and finished argument * set to YES. In case of error, the finished argument is always YES. * - * @return A token (SDWebImageDownloadToken) that can be passed to -cancel: to cancel this operation + * @return A token (SDWebImageDownloadToken) that can be used to cancel this operation */ - (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url options:(SDWebImageDownloaderOptions)options @@ -214,20 +235,48 @@ typedef SDHTTPHeadersDictionary * _Nullable (^SDWebImageDownloaderHeadersFilterB completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock; /** - * Cancels a download that was previously queued using -downloadImageWithURL:options:progress:completed: + * Creates a SDWebImageDownloader async downloader instance with a given URL * - * @param token The token received from -downloadImageWithURL:options:progress:completed: that should be canceled. + * The delegate will be informed when the image is finish downloaded or an error has happen. + * + * @see SDWebImageDownloaderDelegate + * + * @param url The URL to the image to download + * @param options The options to be used for this download + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + * @param progressBlock A block called repeatedly while the image is downloading + * @note the progress block is executed on a background queue + * @param completedBlock A block called once the download is completed. + * + * @return A token (SDWebImageDownloadToken) that can be used to cancel this operation */ -- (void)cancel:(nullable SDWebImageDownloadToken *)token; +- (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url + options:(SDWebImageDownloaderOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock + completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock; /** - * Sets the download queue suspension state + * Cancels all download operations in the queue */ -- (void)setSuspended:(BOOL)suspended; +- (void)cancelAllDownloads; /** - * Cancels all download operations in the queue + * Invalidates the managed session, optionally canceling pending operations. + * @note If you use custom downloader instead of the shared downloader, you need call this method when you do not use it to avoid memory leak + * @param cancelPendingOperations Whether or not to cancel pending operations. + * @note Calling this method on the shared downloader has no effect. */ -- (void)cancelAllDownloads; +- (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations; + +@end + + +/** + SDWebImageDownloader is the built-in image loader conform to `SDImageLoader`. Which provide the HTTP/HTTPS/FTP download, or local file URL using NSURLSession. + However, this downloader class itself also support customization for advanced users. You can specify `operationClass` in download config to custom download operation, See `SDWebImageDownloaderOperation`. + If you want to provide some image loader which beyond network or local file, consider to create your own custom class conform to `SDImageLoader`. + */ +@interface SDWebImageDownloader (SDImageLoader) @end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m b/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m index 189d1630..da244659 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m +++ b/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m @@ -7,22 +7,41 @@ */ #import "SDWebImageDownloader.h" +#import "SDWebImageDownloaderConfig.h" #import "SDWebImageDownloaderOperation.h" -#import +#import "SDWebImageError.h" -@implementation SDWebImageDownloadToken -@end +NSNotificationName const SDWebImageDownloadStartNotification = @"SDWebImageDownloadStartNotification"; +NSNotificationName const SDWebImageDownloadReceiveResponseNotification = @"SDWebImageDownloadReceiveResponseNotification"; +NSNotificationName const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNotification"; +NSNotificationName const SDWebImageDownloadFinishNotification = @"SDWebImageDownloadFinishNotification"; + +static void * SDWebImageDownloaderContext = &SDWebImageDownloaderContext; + +@interface SDWebImageDownloadToken () + +@property (nonatomic, strong, nullable, readwrite) NSURL *url; +@property (nonatomic, strong, nullable, readwrite) NSURLRequest *request; +@property (nonatomic, strong, nullable, readwrite) NSURLResponse *response; +@property (nonatomic, strong, nullable, readwrite) id downloadOperationCancelToken; +@property (nonatomic, weak, nullable) NSOperation *downloadOperation; +@property (nonatomic, weak, nullable) SDWebImageDownloader *downloader; +@property (nonatomic, assign, getter=isCancelled) BOOL cancelled; +- (nonnull instancetype)init NS_UNAVAILABLE; ++ (nonnull instancetype)new NS_UNAVAILABLE; +- (nonnull instancetype)initWithDownloadOperation:(nullable NSOperation *)downloadOperation; + +@end @interface SDWebImageDownloader () @property (strong, nonatomic, nonnull) NSOperationQueue *downloadQueue; @property (weak, nonatomic, nullable) NSOperation *lastAddedOperation; -@property (assign, nonatomic, nullable) Class operationClass; -@property (strong, nonatomic, nonnull) NSMutableDictionary *URLOperations; -@property (strong, nonatomic, nullable) SDHTTPHeadersMutableDictionary *HTTPHeaders; -// This queue is used to serialize the handling of the network responses of all the download operation in a single queue -@property (SDDispatchQueueSetterSementics, nonatomic, nullable) dispatch_queue_t barrierQueue; +@property (strong, nonatomic, nonnull) NSMutableDictionary *> *URLOperations; +@property (strong, nonatomic, nullable) NSMutableDictionary *HTTPHeaders; +@property (strong, nonatomic, nonnull) dispatch_semaphore_t HTTPHeadersLock; // A lock to keep the access to `HTTPHeaders` thread-safe +@property (strong, nonatomic, nonnull) dispatch_semaphore_t operationsLock; // A lock to keep the access to `URLOperations` thread-safe // The session in which data tasks will run @property (strong, nonatomic) NSURLSession *session; @@ -64,36 +83,57 @@ + (nonnull instancetype)sharedDownloader { } - (nonnull instancetype)init { - return [self initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; + return [self initWithConfig:SDWebImageDownloaderConfig.defaultDownloaderConfig]; } -- (nonnull instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)sessionConfiguration { - if ((self = [super init])) { - _operationClass = [SDWebImageDownloaderOperation class]; - _shouldDecompressImages = YES; - _executionOrder = SDWebImageDownloaderFIFOExecutionOrder; +- (instancetype)initWithConfig:(SDWebImageDownloaderConfig *)config { + self = [super init]; + if (self) { + if (!config) { + config = SDWebImageDownloaderConfig.defaultDownloaderConfig; + } + _config = [config copy]; + [_config addObserver:self forKeyPath:NSStringFromSelector(@selector(maxConcurrentDownloads)) options:0 context:SDWebImageDownloaderContext]; _downloadQueue = [NSOperationQueue new]; - _downloadQueue.maxConcurrentOperationCount = 6; + _downloadQueue.maxConcurrentOperationCount = _config.maxConcurrentDownloads; _downloadQueue.name = @"com.hackemist.SDWebImageDownloader"; _URLOperations = [NSMutableDictionary new]; -#ifdef SD_WEBP - _HTTPHeaders = [@{@"Accept": @"image/webp,image/*;q=0.8"} mutableCopy]; -#else - _HTTPHeaders = [@{@"Accept": @"image/*;q=0.8"} mutableCopy]; + NSMutableDictionary *headerDictionary = [NSMutableDictionary dictionary]; + NSString *userAgent = nil; +#if SD_UIKIT + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; +#elif SD_WATCH + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]]; +#elif SD_MAC + userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]; #endif - _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT); - _downloadTimeout = 15.0; - - sessionConfiguration.timeoutIntervalForRequest = _downloadTimeout; - + if (userAgent) { + if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) { + NSMutableString *mutableUserAgent = [userAgent mutableCopy]; + if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) { + userAgent = mutableUserAgent; + } + } + headerDictionary[@"User-Agent"] = userAgent; + } + headerDictionary[@"Accept"] = @"image/*;q=0.8"; + _HTTPHeaders = headerDictionary; + _HTTPHeadersLock = dispatch_semaphore_create(1); + _operationsLock = dispatch_semaphore_create(1); + NSURLSessionConfiguration *sessionConfiguration = _config.sessionConfiguration; + if (!sessionConfiguration) { + sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration]; + } /** * Create the session for this task * We send nil as delegate queue so that the session creates a serial operation queue for performing all delegate * method calls and completion handler calls. */ - self.session = [NSURLSession sessionWithConfiguration:sessionConfiguration - delegate:self - delegateQueue:nil]; + _session = [NSURLSession sessionWithConfiguration:sessionConfiguration + delegate:self + delegateQueue:nil]; } return self; } @@ -101,158 +141,247 @@ - (nonnull instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfi - (void)dealloc { [self.session invalidateAndCancel]; self.session = nil; - + [self.downloadQueue cancelAllOperations]; - SDDispatchQueueRelease(_barrierQueue); + [self.config removeObserver:self forKeyPath:NSStringFromSelector(@selector(maxConcurrentDownloads)) context:SDWebImageDownloaderContext]; } -- (void)setValue:(nullable NSString *)value forHTTPHeaderField:(nullable NSString *)field { - if (value) { - self.HTTPHeaders[field] = value; +- (void)invalidateSessionAndCancel:(BOOL)cancelPendingOperations { + if (self == [SDWebImageDownloader sharedDownloader]) { + return; } - else { - [self.HTTPHeaders removeObjectForKey:field]; + if (cancelPendingOperations) { + [self.session invalidateAndCancel]; + } else { + [self.session finishTasksAndInvalidate]; } } -- (nullable NSString *)valueForHTTPHeaderField:(nullable NSString *)field { - return self.HTTPHeaders[field]; -} - -- (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads { - _downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads; +- (void)setValue:(nullable NSString *)value forHTTPHeaderField:(nullable NSString *)field { + if (!field) { + return; + } + SD_LOCK(self.HTTPHeadersLock); + [self.HTTPHeaders setValue:value forKey:field]; + SD_UNLOCK(self.HTTPHeadersLock); } -- (NSUInteger)currentDownloadCount { - return _downloadQueue.operationCount; +- (nullable NSString *)valueForHTTPHeaderField:(nullable NSString *)field { + if (!field) { + return nil; + } + SD_LOCK(self.HTTPHeadersLock); + NSString *value = [self.HTTPHeaders objectForKey:field]; + SD_UNLOCK(self.HTTPHeadersLock); + return value; } -- (NSInteger)maxConcurrentDownloads { - return _downloadQueue.maxConcurrentOperationCount; +- (nullable SDWebImageDownloadToken *)downloadImageWithURL:(NSURL *)url + completed:(SDWebImageDownloaderCompletedBlock)completedBlock { + return [self downloadImageWithURL:url options:0 progress:nil completed:completedBlock]; } -- (void)setOperationClass:(nullable Class)operationClass { - if (operationClass && [operationClass isSubclassOfClass:[NSOperation class]] && [operationClass conformsToProtocol:@protocol(SDWebImageDownloaderOperationInterface)]) { - _operationClass = operationClass; - } else { - _operationClass = [SDWebImageDownloaderOperation class]; - } +- (nullable SDWebImageDownloadToken *)downloadImageWithURL:(NSURL *)url + options:(SDWebImageDownloaderOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageDownloaderCompletedBlock)completedBlock { + return [self downloadImageWithURL:url options:options context:nil progress:progressBlock completed:completedBlock]; } - (nullable SDWebImageDownloadToken *)downloadImageWithURL:(nullable NSURL *)url options:(SDWebImageDownloaderOptions)options + context:(nullable SDWebImageContext *)context progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock { - __weak SDWebImageDownloader *wself = self; - - return [self addProgressCallback:progressBlock completedBlock:completedBlock forURL:url createCallback:^SDWebImageDownloaderOperation *{ - __strong __typeof (wself) sself = wself; - NSTimeInterval timeoutInterval = sself.downloadTimeout; - if (timeoutInterval == 0.0) { - timeoutInterval = 15.0; - } - - // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise - NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval]; - request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies); - request.HTTPShouldUsePipelining = YES; - if (sself.headersFilter) { - request.allHTTPHeaderFields = sself.headersFilter(url, [sself.HTTPHeaders copy]); - } - else { - request.allHTTPHeaderFields = sself.HTTPHeaders; + // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data. + if (url == nil) { + if (completedBlock) { + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorInvalidURL userInfo:@{NSLocalizedDescriptionKey : @"Image url is nil"}]; + completedBlock(nil, nil, error, YES); } - SDWebImageDownloaderOperation *operation = [[sself.operationClass alloc] initWithRequest:request inSession:sself.session options:options]; - operation.shouldDecompressImages = sself.shouldDecompressImages; - - if (sself.urlCredential) { - operation.credential = sself.urlCredential; - } else if (sself.username && sself.password) { - operation.credential = [NSURLCredential credentialWithUser:sself.username password:sself.password persistence:NSURLCredentialPersistenceForSession]; + return nil; + } + + SD_LOCK(self.operationsLock); + NSOperation *operation = [self.URLOperations objectForKey:url]; + // There is a case that the operation may be marked as finished or cancelled, but not been removed from `self.URLOperations`. + if (!operation || operation.isFinished || operation.isCancelled) { + operation = [self createDownloaderOperationWithUrl:url options:options context:context]; + if (!operation) { + SD_UNLOCK(self.operationsLock); + if (completedBlock) { + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorInvalidDownloadOperation userInfo:@{NSLocalizedDescriptionKey : @"Downloader operation is nil"}]; + completedBlock(nil, nil, error, YES); + } + return nil; } - + @weakify(self); + operation.completionBlock = ^{ + @strongify(self); + if (!self) { + return; + } + SD_LOCK(self.operationsLock); + [self.URLOperations removeObjectForKey:url]; + SD_UNLOCK(self.operationsLock); + }; + self.URLOperations[url] = operation; + // Add operation to operation queue only after all configuration done according to Apple's doc. + // `addOperation:` does not synchronously execute the `operation.completionBlock` so this will not cause deadlock. + [self.downloadQueue addOperation:operation]; + } + else if (!operation.isExecuting) { if (options & SDWebImageDownloaderHighPriority) { operation.queuePriority = NSOperationQueuePriorityHigh; } else if (options & SDWebImageDownloaderLowPriority) { operation.queuePriority = NSOperationQueuePriorityLow; + } else { + operation.queuePriority = NSOperationQueuePriorityNormal; } + } + SD_UNLOCK(self.operationsLock); + + id downloadOperationCancelToken = [operation addHandlersForProgress:progressBlock completed:completedBlock]; + + SDWebImageDownloadToken *token = [[SDWebImageDownloadToken alloc] initWithDownloadOperation:operation]; + token.url = url; + token.request = operation.request; + token.downloadOperationCancelToken = downloadOperationCancelToken; + token.downloader = self; + + return token; +} - [sself.downloadQueue addOperation:operation]; - if (sself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) { - // Emulate LIFO execution order by systematically adding new operations as last operation's dependency - [sself.lastAddedOperation addDependency:operation]; - sself.lastAddedOperation = operation; +- (nullable NSOperation *)createDownloaderOperationWithUrl:(nonnull NSURL *)url + options:(SDWebImageDownloaderOptions)options + context:(nullable SDWebImageContext *)context { + NSTimeInterval timeoutInterval = self.config.downloadTimeout; + if (timeoutInterval == 0.0) { + timeoutInterval = 15.0; + } + + // 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.HTTPShouldUsePipelining = YES; + SD_LOCK(self.HTTPHeadersLock); + mutableRequest.allHTTPHeaderFields = self.HTTPHeaders; + SD_UNLOCK(self.HTTPHeadersLock); + id requestModifier; + if ([context valueForKey:SDWebImageContextDownloadRequestModifier]) { + requestModifier = [context valueForKey:SDWebImageContextDownloadRequestModifier]; + } else { + requestModifier = self.requestModifier; + } + + NSURLRequest *request; + if (requestModifier) { + NSURLRequest *modifiedRequest = [requestModifier modifiedRequestWithRequest:[mutableRequest copy]]; + // If modified request is nil, early return + if (!modifiedRequest) { + return nil; + } else { + request = [modifiedRequest copy]; } - - return operation; - }]; + } else { + request = [mutableRequest copy]; + } + Class operationClass = self.config.operationClass; + if (operationClass && [operationClass isSubclassOfClass:[NSOperation class]] && [operationClass conformsToProtocol:@protocol(SDWebImageDownloaderOperation)]) { + // Custom operation class + } else { + operationClass = [SDWebImageDownloaderOperation class]; + } + NSOperation *operation = [[operationClass alloc] initWithRequest:request inSession:self.session options:options context:context]; + + if ([operation respondsToSelector:@selector(setCredential:)]) { + if (self.config.urlCredential) { + operation.credential = self.config.urlCredential; + } else if (self.config.username && self.config.password) { + operation.credential = [NSURLCredential credentialWithUser:self.config.username password:self.config.password persistence:NSURLCredentialPersistenceForSession]; + } + } + + if ([operation respondsToSelector:@selector(setMinimumProgressInterval:)]) { + operation.minimumProgressInterval = MIN(MAX(self.config.minimumProgressInterval, 0), 1); + } + + if (options & SDWebImageDownloaderHighPriority) { + operation.queuePriority = NSOperationQueuePriorityHigh; + } else if (options & SDWebImageDownloaderLowPriority) { + operation.queuePriority = NSOperationQueuePriorityLow; + } + + if (self.config.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) { + // Emulate LIFO execution order by systematically adding new operations as last operation's dependency + [self.lastAddedOperation addDependency:operation]; + self.lastAddedOperation = operation; + } + + return operation; } - (void)cancel:(nullable SDWebImageDownloadToken *)token { - dispatch_barrier_async(self.barrierQueue, ^{ - SDWebImageDownloaderOperation *operation = self.URLOperations[token.url]; + NSURL *url = token.url; + if (!url) { + return; + } + SD_LOCK(self.operationsLock); + NSOperation *operation = [self.URLOperations objectForKey:url]; + if (operation) { BOOL canceled = [operation cancel:token.downloadOperationCancelToken]; if (canceled) { - [self.URLOperations removeObjectForKey:token.url]; + [self.URLOperations removeObjectForKey:url]; } - }); + } + SD_UNLOCK(self.operationsLock); } -- (nullable SDWebImageDownloadToken *)addProgressCallback:(SDWebImageDownloaderProgressBlock)progressBlock - completedBlock:(SDWebImageDownloaderCompletedBlock)completedBlock - forURL:(nullable NSURL *)url - createCallback:(SDWebImageDownloaderOperation *(^)())createCallback { - // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data. - if (url == nil) { - if (completedBlock != nil) { - completedBlock(nil, nil, nil, NO); - } - return nil; - } +- (void)cancelAllDownloads { + [self.downloadQueue cancelAllOperations]; +} - __block SDWebImageDownloadToken *token = nil; +#pragma mark - Properties - dispatch_barrier_sync(self.barrierQueue, ^{ - SDWebImageDownloaderOperation *operation = self.URLOperations[url]; - if (!operation) { - operation = createCallback(); - self.URLOperations[url] = operation; - - __weak SDWebImageDownloaderOperation *woperation = operation; - operation.completionBlock = ^{ - SDWebImageDownloaderOperation *soperation = woperation; - if (!soperation) return; - if (self.URLOperations[url] == soperation) { - [self.URLOperations removeObjectForKey:url]; - }; - }; - } - id downloadOperationCancelToken = [operation addHandlersForProgress:progressBlock completed:completedBlock]; +- (BOOL)isSuspended { + return self.downloadQueue.isSuspended; +} - token = [SDWebImageDownloadToken new]; - token.url = url; - token.downloadOperationCancelToken = downloadOperationCancelToken; - }); +- (void)setSuspended:(BOOL)suspended { + self.downloadQueue.suspended = suspended; +} - return token; +- (NSUInteger)currentDownloadCount { + return self.downloadQueue.operationCount; } -- (void)setSuspended:(BOOL)suspended { - (self.downloadQueue).suspended = suspended; +- (NSURLSessionConfiguration *)sessionConfiguration { + return self.session.configuration; } -- (void)cancelAllDownloads { - [self.downloadQueue cancelAllOperations]; +#pragma mark - KVO + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + if (context == SDWebImageDownloaderContext) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(maxConcurrentDownloads))]) { + self.downloadQueue.maxConcurrentOperationCount = self.config.maxConcurrentDownloads; + } + } else { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } } #pragma mark Helper methods -- (SDWebImageDownloaderOperation *)operationWithTask:(NSURLSessionTask *)task { - SDWebImageDownloaderOperation *returnOperation = nil; - for (SDWebImageDownloaderOperation *operation in self.downloadQueue.operations) { - if (operation.dataTask.taskIdentifier == task.taskIdentifier) { - returnOperation = operation; - break; +- (NSOperation *)operationWithTask:(NSURLSessionTask *)task { + NSOperation *returnOperation = nil; + for (NSOperation *operation in self.downloadQueue.operations) { + if ([operation respondsToSelector:@selector(dataTask)]) { + if (operation.dataTask.taskIdentifier == task.taskIdentifier) { + returnOperation = operation; + break; + } } } return returnOperation; @@ -266,17 +395,23 @@ - (void)URLSession:(NSURLSession *)session completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler { // Identify the operation that runs this task and pass it the delegate method - SDWebImageDownloaderOperation *dataOperation = [self operationWithTask:dataTask]; - - [dataOperation URLSession:session dataTask:dataTask didReceiveResponse:response completionHandler:completionHandler]; + NSOperation *dataOperation = [self operationWithTask:dataTask]; + if ([dataOperation respondsToSelector:@selector(URLSession:dataTask:didReceiveResponse:completionHandler:)]) { + [dataOperation URLSession:session dataTask:dataTask didReceiveResponse:response completionHandler:completionHandler]; + } else { + if (completionHandler) { + completionHandler(NSURLSessionResponseAllow); + } + } } - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data { // Identify the operation that runs this task and pass it the delegate method - SDWebImageDownloaderOperation *dataOperation = [self operationWithTask:dataTask]; - - [dataOperation URLSession:session dataTask:dataTask didReceiveData:data]; + NSOperation *dataOperation = [self operationWithTask:dataTask]; + if ([dataOperation respondsToSelector:@selector(URLSession:dataTask:didReceiveData:)]) { + [dataOperation URLSession:session dataTask:dataTask didReceiveData:data]; + } } - (void)URLSession:(NSURLSession *)session @@ -285,31 +420,151 @@ - (void)URLSession:(NSURLSession *)session completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler { // Identify the operation that runs this task and pass it the delegate method - SDWebImageDownloaderOperation *dataOperation = [self operationWithTask:dataTask]; - - [dataOperation URLSession:session dataTask:dataTask willCacheResponse:proposedResponse completionHandler:completionHandler]; + NSOperation *dataOperation = [self operationWithTask:dataTask]; + if ([dataOperation respondsToSelector:@selector(URLSession:dataTask:willCacheResponse:completionHandler:)]) { + [dataOperation URLSession:session dataTask:dataTask willCacheResponse:proposedResponse completionHandler:completionHandler]; + } else { + if (completionHandler) { + completionHandler(proposedResponse); + } + } } #pragma mark NSURLSessionTaskDelegate - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error { + // Identify the operation that runs this task and pass it the delegate method - SDWebImageDownloaderOperation *dataOperation = [self operationWithTask:task]; - - [dataOperation URLSession:session task:task didCompleteWithError:error]; + NSOperation *dataOperation = [self operationWithTask:task]; + if ([dataOperation respondsToSelector:@selector(URLSession:task:didCompleteWithError:)]) { + [dataOperation URLSession:session task:task didCompleteWithError:error]; + } } - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task willPerformHTTPRedirection:(NSHTTPURLResponse *)response newRequest:(NSURLRequest *)request completionHandler:(void (^)(NSURLRequest * _Nullable))completionHandler { - completionHandler(request); + // Identify the operation that runs this task and pass it the delegate method + NSOperation *dataOperation = [self operationWithTask:task]; + if ([dataOperation respondsToSelector:@selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)]) { + [dataOperation URLSession:session task:task willPerformHTTPRedirection:response newRequest:request completionHandler:completionHandler]; + } else { + if (completionHandler) { + completionHandler(request); + } + } } - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { // Identify the operation that runs this task and pass it the delegate method - SDWebImageDownloaderOperation *dataOperation = [self operationWithTask:task]; + NSOperation *dataOperation = [self operationWithTask:task]; + if ([dataOperation respondsToSelector:@selector(URLSession:task:didReceiveChallenge:completionHandler:)]) { + [dataOperation URLSession:session task:task didReceiveChallenge:challenge completionHandler:completionHandler]; + } else { + if (completionHandler) { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + } + } +} + +@end + +@implementation SDWebImageDownloadToken + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self name:SDWebImageDownloadReceiveResponseNotification object:nil]; +} + +- (instancetype)initWithDownloadOperation:(NSOperation *)downloadOperation { + self = [super init]; + if (self) { + _downloadOperation = downloadOperation; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadReceiveResponse:) name:SDWebImageDownloadReceiveResponseNotification object:downloadOperation]; + } + return self; +} + +- (void)downloadReceiveResponse:(NSNotification *)notification { + NSOperation *downloadOperation = notification.object; + if (downloadOperation && downloadOperation == self.downloadOperation) { + self.response = downloadOperation.response; + } +} + +- (void)cancel { + @synchronized (self) { + if (self.isCancelled) { + return; + } + self.cancelled = YES; + if (self.downloader) { + // Downloader is alive, cancel token + [self.downloader cancel:self]; + } else { + // Downloader is dealloced, only cancel download operation + [self.downloadOperation cancel:self.downloadOperationCancelToken]; + } + self.downloadOperationCancelToken = nil; + } +} + +@end + +@implementation SDWebImageDownloader (SDImageLoader) + +- (BOOL)canRequestImageForURL:(NSURL *)url { + if (!url) { + return NO; + } + // Always pass YES to let URLSession or custom download operation to determine + return YES; +} - [dataOperation URLSession:session task:task didReceiveChallenge:challenge completionHandler:completionHandler]; +- (id)requestImageWithURL:(NSURL *)url options:(SDWebImageOptions)options context:(SDWebImageContext *)context progress:(SDImageLoaderProgressBlock)progressBlock completed:(SDImageLoaderCompletedBlock)completedBlock { + UIImage *cachedImage = context[SDWebImageContextLoaderCachedImage]; + + SDWebImageDownloaderOptions downloaderOptions = 0; + if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority; + if (options & SDWebImageProgressiveLoad) downloaderOptions |= SDWebImageDownloaderProgressiveLoad; + if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache; + if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground; + if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies; + if (options & SDWebImageAllowInvalidSSLCertificates) downloaderOptions |= SDWebImageDownloaderAllowInvalidSSLCertificates; + if (options & SDWebImageHighPriority) downloaderOptions |= SDWebImageDownloaderHighPriority; + if (options & SDWebImageScaleDownLargeImages) downloaderOptions |= SDWebImageDownloaderScaleDownLargeImages; + if (options & SDWebImageAvoidDecodeImage) downloaderOptions |= SDWebImageDownloaderAvoidDecodeImage; + if (options & SDWebImageDecodeFirstFrameOnly) downloaderOptions |= SDWebImageDownloaderDecodeFirstFrameOnly; + if (options & SDWebImagePreloadAllFrames) downloaderOptions |= SDWebImageDownloaderPreloadAllFrames; + + if (cachedImage && options & SDWebImageRefreshCached) { + // force progressive off if image already cached but forced refreshing + downloaderOptions &= ~SDWebImageDownloaderProgressiveLoad; + // ignore image read from NSURLCache if image if cached but force refreshing + downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse; + } + + return [self downloadImageWithURL:url options:downloaderOptions context:context progress:progressBlock completed:completedBlock]; +} + +- (BOOL)shouldBlockFailedURLWithURL:(NSURL *)url error:(NSError *)error { + BOOL shouldBlockFailedURL; + // Filter the error domain and check error codes + if ([error.domain isEqualToString:SDWebImageErrorDomain]) { + shouldBlockFailedURL = ( error.code == SDWebImageErrorInvalidURL + || error.code == SDWebImageErrorBadImageData); + } else if ([error.domain isEqualToString:NSURLErrorDomain]) { + shouldBlockFailedURL = ( error.code != NSURLErrorNotConnectedToInternet + && error.code != NSURLErrorCancelled + && error.code != NSURLErrorTimedOut + && error.code != NSURLErrorInternationalRoamingOff + && error.code != NSURLErrorDataNotAllowed + && error.code != NSURLErrorCannotFindHost + && error.code != NSURLErrorCannotConnectToHost + && error.code != NSURLErrorNetworkConnectionLost); + } else { + shouldBlockFailedURL = NO; + } + return shouldBlockFailedURL; } @end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderConfig.h b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderConfig.h new file mode 100644 index 00000000..669d13a5 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderConfig.h @@ -0,0 +1,93 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { + /** + * Default value. All download operations will execute in queue style (first-in-first-out). + */ + SDWebImageDownloaderFIFOExecutionOrder, + + /** + * All download operations will execute in stack style (last-in-first-out). + */ + SDWebImageDownloaderLIFOExecutionOrder +}; + +@interface SDWebImageDownloaderConfig : NSObject + +/** + Gets the default downloader config used for shared instance or initialization when it does not provide any downloader config. Such as `SDWebImageDownloader.sharedDownloader`. + @note You can modify the property on default downloader config, which can be used for later created downloader instance. The already created downloader instance does not get affected. + */ +@property (nonatomic, class, readonly, nonnull) SDWebImageDownloaderConfig *defaultDownloaderConfig; + +/** + * The maximum number of concurrent downloads. + * Defaults to 6. + */ +@property (nonatomic, assign) NSInteger maxConcurrentDownloads; + +/** + * The timeout value (in seconds) for each download operation. + * Defaults to 15.0. + */ +@property (nonatomic, assign) NSTimeInterval downloadTimeout; + +/** + * The minimum interval about progress percent during network downloading. Which means the next progress callback and current progress callback's progress percent difference should be larger or equal to this value. However, the final finish download progress callback does not get effected. + * The value should be 0.0-1.0. + * @note If you're using progressive decoding feature, this will also effect the image refresh rate. + * @note This value may enhance the performance if you don't want progress callback too frequently. + * Defaults to 0, which means each time we receive the new data from URLSession, we callback the progressBlock immediately. + */ +@property (nonatomic, assign) double minimumProgressInterval; + +/** + * The custom session configuration in use by NSURLSession. If you don't provide one, we will use `defaultSessionConfiguration` instead. + * Defatuls to nil. + * @note This property does not support dynamic changes, means it's immutable after the downloader instance initialized. + */ +@property (nonatomic, strong, nullable) NSURLSessionConfiguration *sessionConfiguration; + +/** + * Gets/Sets a subclass of `SDWebImageDownloaderOperation` as the default + * `NSOperation` to be used each time SDWebImage constructs a request + * operation to download an image. + * Defaults to nil. + * @note Passing `NSOperation` to set as default. Passing `nil` will revert to `SDWebImageDownloaderOperation`. + */ +@property (nonatomic, assign, nullable) Class operationClass; + +/** + * Changes download operations execution order. + * Defaults to `SDWebImageDownloaderFIFOExecutionOrder`. + */ +@property (nonatomic, assign) SDWebImageDownloaderExecutionOrder executionOrder; + +/** + * Set the default URL credential to be set for request operations. + * Defaults to nil. + */ +@property (nonatomic, copy, nullable) NSURLCredential *urlCredential; + +/** + * Set username using for HTTP Basic authentication. + * Defaults to nil. + */ +@property (nonatomic, copy, nullable) NSString *username; + +/** + * Set password using for HTTP Basic authentication. + * Defautls to nil. + */ +@property (nonatomic, copy, nullable) NSString *password; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderConfig.m b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderConfig.m new file mode 100644 index 00000000..1fc93308 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderConfig.m @@ -0,0 +1,49 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageDownloaderConfig.h" + +static SDWebImageDownloaderConfig * _defaultDownloaderConfig; + +@implementation SDWebImageDownloaderConfig + ++ (SDWebImageDownloaderConfig *)defaultDownloaderConfig { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _defaultDownloaderConfig = [SDWebImageDownloaderConfig new]; + }); + return _defaultDownloaderConfig; +} + +- (instancetype)init { + self = [super init]; + if (self) { + _maxConcurrentDownloads = 6; + _downloadTimeout = 15.0; + _executionOrder = SDWebImageDownloaderFIFOExecutionOrder; + } + return self; +} + +- (id)copyWithZone:(NSZone *)zone { + SDWebImageDownloaderConfig *config = [[[self class] allocWithZone:zone] init]; + config.maxConcurrentDownloads = self.maxConcurrentDownloads; + config.downloadTimeout = self.downloadTimeout; + config.minimumProgressInterval = self.minimumProgressInterval; + config.sessionConfiguration = [self.sessionConfiguration copyWithZone:zone]; + config.operationClass = self.operationClass; + config.executionOrder = self.executionOrder; + config.urlCredential = self.urlCredential; + config.username = self.username; + config.password = self.password; + + return config; +} + + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h index b1908550..b660771f 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h +++ b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h @@ -10,35 +10,39 @@ #import "SDWebImageDownloader.h" #import "SDWebImageOperation.h" -extern NSString * _Nonnull const SDWebImageDownloadStartNotification; -extern NSString * _Nonnull const SDWebImageDownloadReceiveResponseNotification; -extern NSString * _Nonnull const SDWebImageDownloadStopNotification; -extern NSString * _Nonnull const SDWebImageDownloadFinishNotification; - - - /** Describes a downloader operation. If one wants to use a custom downloader op, it needs to inherit from `NSOperation` and conform to this protocol + For the description about these methods, see `SDWebImageDownloaderOperation` + @note If your custom operation class does not use `NSURLSession` at all, do not implement the optional methods and session delegate methods. */ -@protocol SDWebImageDownloaderOperationInterface - +@protocol SDWebImageDownloaderOperation +@required - (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request inSession:(nullable NSURLSession *)session options:(SDWebImageDownloaderOptions)options; +- (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request + inSession:(nullable NSURLSession *)session + options:(SDWebImageDownloaderOptions)options + context:(nullable SDWebImageContext *)context; + - (nullable id)addHandlersForProgress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock; -- (BOOL)shouldDecompressImages; -- (void)setShouldDecompressImages:(BOOL)value; +- (BOOL)cancel:(nullable id)token; + +@property (strong, nonatomic, readonly, nullable) NSURLRequest *request; +@property (strong, nonatomic, readonly, nullable) NSURLResponse *response; -- (nullable NSURLCredential *)credential; -- (void)setCredential:(nullable NSURLCredential *)value; +@optional +@property (strong, nonatomic, readonly, nullable) NSURLSessionTask *dataTask; +@property (strong, nonatomic, nullable) NSURLCredential *credential; +@property (assign, nonatomic) double minimumProgressInterval; @end -@interface SDWebImageDownloaderOperation : NSOperation +@interface SDWebImageDownloaderOperation : NSOperation /** * The request used by the operation's task. @@ -46,40 +50,55 @@ extern NSString * _Nonnull const SDWebImageDownloadFinishNotification; @property (strong, nonatomic, readonly, nullable) NSURLRequest *request; /** - * The operation's task + * The response returned by the operation's task. */ -@property (strong, nonatomic, readonly, nullable) NSURLSessionTask *dataTask; - - -@property (assign, nonatomic) BOOL shouldDecompressImages; +@property (strong, nonatomic, readonly, nullable) NSURLResponse *response; /** - * Was used to determine whether the URL connection should consult the credential storage for authenticating the connection. - * @deprecated Not used for a couple of versions + * The operation's task */ -@property (nonatomic, assign) BOOL shouldUseCredentialStorage __deprecated_msg("Property deprecated. Does nothing. Kept only for backwards compatibility"); +@property (strong, nonatomic, readonly, nullable) NSURLSessionTask *dataTask; /** - * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. + * The credential used for authentication challenges in `-URLSession:task:didReceiveChallenge:completionHandler:`. * * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. */ -@property (nonatomic, strong, nullable) NSURLCredential *credential; +@property (strong, nonatomic, nullable) NSURLCredential *credential; + +/** + * The minimum interval about progress percent during network downloading. Which means the next progress callback and current progress callback's progress percent difference should be larger or equal to this value. However, the final finish download progress callback does not get effected. + * The value should be 0.0-1.0. + * @note If you're using progressive decoding feature, this will also effect the image refresh rate. + * @note This value may enhance the performance if you don't want progress callback too frequently. + * Defaults to 0, which means each time we receive the new data from URLSession, we callback the progressBlock immediately. + */ +@property (assign, nonatomic) double minimumProgressInterval; /** - * The SDWebImageDownloaderOptions for the receiver. + * The options for the receiver. */ @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; /** - * The expected size of data. + * The context for the receiver. */ -@property (assign, nonatomic) NSInteger expectedSize; +@property (copy, nonatomic, readonly, nullable) SDWebImageContext *context; /** - * The response returned by the operation's connection. + * Initializes a `SDWebImageDownloaderOperation` object + * + * @see SDWebImageDownloaderOperation + * + * @param request the URL request + * @param session the URL session in which this operation will run + * @param options downloader options + * + * @return the initialized instance */ -@property (strong, nonatomic, nullable) NSURLResponse *response; +- (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request + inSession:(nullable NSURLSession *)session + options:(SDWebImageDownloaderOptions)options; /** * Initializes a `SDWebImageDownloaderOperation` object @@ -89,12 +108,14 @@ extern NSString * _Nonnull const SDWebImageDownloadFinishNotification; * @param request the URL request * @param session the URL session in which this operation will run * @param options downloader options + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. * * @return the initialized instance */ - (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request inSession:(nullable NSURLSession *)session - options:(SDWebImageDownloaderOptions)options NS_DESIGNATED_INITIALIZER; + options:(SDWebImageDownloaderOptions)options + context:(nullable SDWebImageContext *)context NS_DESIGNATED_INITIALIZER; /** * Adds handlers for progress and completion. Returns a tokent that can be passed to -cancel: to cancel this set of diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m index 63df1afe..c3dc3693 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m +++ b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m @@ -7,16 +7,14 @@ */ #import "SDWebImageDownloaderOperation.h" -#import "SDWebImageDecoder.h" -#import "UIImage+MultiFormat.h" -#import -#import "SDWebImageManager.h" -#import "NSImage+WebCache.h" +#import "SDWebImageError.h" -NSString *const SDWebImageDownloadStartNotification = @"SDWebImageDownloadStartNotification"; -NSString *const SDWebImageDownloadReceiveResponseNotification = @"SDWebImageDownloadReceiveResponseNotification"; -NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNotification"; -NSString *const SDWebImageDownloadFinishNotification = @"SDWebImageDownloadFinishNotification"; +// iOS 8 Foundation.framework extern these symbol but the define is in CFNetwork.framework. We just fix this without import CFNetwork.framework +#if (__IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0) +const float NSURLSessionTaskPriorityHigh = 0.75; +const float NSURLSessionTaskPriorityDefault = 0.5; +const float NSURLSessionTaskPriorityLow = 0.25; +#endif static NSString *const kProgressCallbackKey = @"progress"; static NSString *const kCompletedCallbackKey = @"completed"; @@ -27,9 +25,18 @@ @interface SDWebImageDownloaderOperation () @property (strong, nonatomic, nonnull) NSMutableArray *callbackBlocks; +@property (assign, nonatomic, readwrite) SDWebImageDownloaderOptions options; +@property (copy, nonatomic, readwrite, nullable) SDWebImageContext *context; + @property (assign, nonatomic, getter = isExecuting) BOOL executing; @property (assign, nonatomic, getter = isFinished) BOOL finished; @property (strong, nonatomic, nullable) NSMutableData *imageData; +@property (copy, nonatomic, nullable) NSData *cachedData; // for `SDWebImageDownloaderIgnoreCachedResponse` +@property (assign, nonatomic) NSUInteger expectedSize; // may be 0 +@property (assign, nonatomic) NSUInteger receivedSize; +@property (strong, nonatomic, nullable, readwrite) NSURLResponse *response; +@property (strong, nonatomic, nullable) NSError *responseError; +@property (assign, nonatomic) double previousProgress; // previous progress percent // This is weak because it is injected by whoever manages this session. If this gets nil-ed out, we won't be able to run // the task associated with this operation @@ -39,21 +46,16 @@ @interface SDWebImageDownloaderOperation () @property (strong, nonatomic, readwrite, nullable) NSURLSessionTask *dataTask; -@property (SDDispatchQueueSetterSementics, nonatomic, nullable) dispatch_queue_t barrierQueue; +@property (strong, nonatomic, nonnull) dispatch_semaphore_t callbacksLock; // a lock to keep the access to `callbackBlocks` thread-safe +@property (strong, nonatomic, nonnull) dispatch_queue_t coderQueue; // the queue to do image decoding #if SD_UIKIT @property (assign, nonatomic) UIBackgroundTaskIdentifier backgroundTaskId; #endif @end -@implementation SDWebImageDownloaderOperation { - size_t width, height; -#if SD_UIKIT || SD_WATCH - UIImageOrientation orientation; -#endif - BOOL responseFromCached; -} +@implementation SDWebImageDownloaderOperation @synthesize executing = _executing; @synthesize finished = _finished; @@ -62,57 +64,60 @@ - (nonnull instancetype)init { return [self initWithRequest:nil inSession:nil options:0]; } +- (instancetype)initWithRequest:(NSURLRequest *)request inSession:(NSURLSession *)session options:(SDWebImageDownloaderOptions)options { + return [self initWithRequest:request inSession:session options:options context:nil]; +} + - (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request inSession:(nullable NSURLSession *)session - options:(SDWebImageDownloaderOptions)options { + options:(SDWebImageDownloaderOptions)options + context:(nullable SDWebImageContext *)context { if ((self = [super init])) { _request = [request copy]; - _shouldDecompressImages = YES; _options = options; + _context = [context copy]; _callbackBlocks = [NSMutableArray new]; _executing = NO; _finished = NO; _expectedSize = 0; _unownedSession = session; - responseFromCached = YES; // Initially wrong until `- URLSession:dataTask:willCacheResponse:completionHandler: is called or not called - _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderOperationBarrierQueue", DISPATCH_QUEUE_CONCURRENT); + _callbacksLock = dispatch_semaphore_create(1); + _coderQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderOperationCoderQueue", DISPATCH_QUEUE_SERIAL); +#if SD_UIKIT + _backgroundTaskId = UIBackgroundTaskInvalid; +#endif } return self; } -- (void)dealloc { - SDDispatchQueueRelease(_barrierQueue); -} - - (nullable id)addHandlersForProgress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDWebImageDownloaderCompletedBlock)completedBlock { SDCallbacksDictionary *callbacks = [NSMutableDictionary new]; if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy]; if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy]; - dispatch_barrier_async(self.barrierQueue, ^{ - [self.callbackBlocks addObject:callbacks]; - }); + SD_LOCK(self.callbacksLock); + [self.callbackBlocks addObject:callbacks]; + SD_UNLOCK(self.callbacksLock); return callbacks; } - (nullable NSArray *)callbacksForKey:(NSString *)key { - __block NSMutableArray *callbacks = nil; - dispatch_sync(self.barrierQueue, ^{ - // We need to remove [NSNull null] because there might not always be a progress block for each callback - callbacks = [[self.callbackBlocks valueForKey:key] mutableCopy]; - [callbacks removeObjectIdenticalTo:[NSNull null]]; - }); - return [callbacks copy]; // strip mutability here + SD_LOCK(self.callbacksLock); + NSMutableArray *callbacks = [[self.callbackBlocks valueForKey:key] mutableCopy]; + SD_UNLOCK(self.callbacksLock); + // We need to remove [NSNull null] because there might not always be a progress block for each callback + [callbacks removeObjectIdenticalTo:[NSNull null]]; + return [callbacks copy]; // strip mutability here } - (BOOL)cancel:(nullable id)token { - __block BOOL shouldCancel = NO; - dispatch_barrier_sync(self.barrierQueue, ^{ - [self.callbackBlocks removeObjectIdenticalTo:token]; - if (self.callbackBlocks.count == 0) { - shouldCancel = YES; - } - }); + BOOL shouldCancel = NO; + SD_LOCK(self.callbacksLock); + [self.callbackBlocks removeObjectIdenticalTo:token]; + if (self.callbackBlocks.count == 0) { + shouldCancel = YES; + } + SD_UNLOCK(self.callbacksLock); if (shouldCancel) { [self cancel]; } @@ -131,22 +136,15 @@ - (void)start { Class UIApplicationClass = NSClassFromString(@"UIApplication"); BOOL hasApplication = UIApplicationClass && [UIApplicationClass respondsToSelector:@selector(sharedApplication)]; if (hasApplication && [self shouldContinueWhenAppEntersBackground]) { - __weak __typeof__ (self) wself = self; + __weak typeof(self) wself = self; UIApplication * app = [UIApplicationClass performSelector:@selector(sharedApplication)]; self.backgroundTaskId = [app beginBackgroundTaskWithExpirationHandler:^{ - __strong __typeof (wself) sself = wself; - - if (sself) { - [sself cancel]; - - [app endBackgroundTask:sself.backgroundTaskId]; - sself.backgroundTaskId = UIBackgroundTaskInvalid; - } + [wself cancel]; }]; } #endif NSURLSession *session = self.unownedSession; - if (!self.unownedSession) { + if (!session) { NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration]; sessionConfig.timeoutIntervalForRequest = 15; @@ -155,40 +153,55 @@ - (void)start { * We send nil as delegate queue so that the session creates a serial operation queue for performing all delegate * method calls and completion handler calls. */ - self.ownedSession = [NSURLSession sessionWithConfiguration:sessionConfig - delegate:self - delegateQueue:nil]; - session = self.ownedSession; + session = [NSURLSession sessionWithConfiguration:sessionConfig + delegate:self + delegateQueue:nil]; + self.ownedSession = session; + } + + if (self.options & SDWebImageDownloaderIgnoreCachedResponse) { + // Grab the cached data for later check + NSURLCache *URLCache = session.configuration.URLCache; + if (!URLCache) { + URLCache = [NSURLCache sharedURLCache]; + } + NSCachedURLResponse *cachedResponse; + // NSURLCache's `cachedResponseForRequest:` is not thread-safe, see https://developer.apple.com/documentation/foundation/nsurlcache#2317483 + @synchronized (URLCache) { + cachedResponse = [URLCache cachedResponseForRequest:self.request]; + } + if (cachedResponse) { + self.cachedData = cachedResponse.data; + } } self.dataTask = [session dataTaskWithRequest:self.request]; self.executing = YES; } - - [self.dataTask resume]; if (self.dataTask) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability" + if ([self.dataTask respondsToSelector:@selector(setPriority:)]) { + if (self.options & SDWebImageDownloaderHighPriority) { + self.dataTask.priority = NSURLSessionTaskPriorityHigh; + } else if (self.options & SDWebImageDownloaderLowPriority) { + self.dataTask.priority = NSURLSessionTaskPriorityLow; + } + } +#pragma clang diagnostic pop + [self.dataTask resume]; for (SDWebImageDownloaderProgressBlock progressBlock in [self callbacksForKey:kProgressCallbackKey]) { progressBlock(0, NSURLResponseUnknownLength, self.request.URL); } + __block typeof(self) strongSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:strongSelf]; }); } else { - [self callCompletionBlocksWithError:[NSError errorWithDomain:NSURLErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Connection can't be initialized"}]]; - } - -#if SD_UIKIT - Class UIApplicationClass = NSClassFromString(@"UIApplication"); - if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { - return; - } - if (self.backgroundTaskId != UIBackgroundTaskInvalid) { - UIApplication * app = [UIApplication performSelector:@selector(sharedApplication)]; - [app endBackgroundTask:self.backgroundTaskId]; - self.backgroundTaskId = UIBackgroundTaskInvalid; + [self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorInvalidDownloadOperation userInfo:@{NSLocalizedDescriptionKey : @"Task can't be initialized"}]]; + [self done]; } -#endif } - (void)cancel { @@ -203,11 +216,12 @@ - (void)cancelInternal { if (self.dataTask) { [self.dataTask cancel]; + __block typeof(self) strongSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:strongSelf]; }); - // As we cancelled the connection, its callback won't be called and thus won't + // As we cancelled the task, its callback won't be called and thus won't // maintain the isFinished and isExecuting flags. if (self.isExecuting) self.executing = NO; if (!self.isFinished) self.finished = YES; @@ -223,14 +237,26 @@ - (void)done { } - (void)reset { - dispatch_barrier_async(self.barrierQueue, ^{ - [self.callbackBlocks removeAllObjects]; - }); - self.dataTask = nil; - self.imageData = nil; - if (self.ownedSession) { - [self.ownedSession invalidateAndCancel]; - self.ownedSession = nil; + SD_LOCK(self.callbacksLock); + [self.callbackBlocks removeAllObjects]; + SD_UNLOCK(self.callbacksLock); + + @synchronized (self) { + self.dataTask = nil; + + if (self.ownedSession) { + [self.ownedSession invalidateAndCancel]; + self.ownedSession = nil; + } + +#if SD_UIKIT + if (self.backgroundTaskId != UIBackgroundTaskInvalid) { + // If backgroundTaskId != UIBackgroundTaskInvalid, sharedApplication is always exist + UIApplication * app = [UIApplication performSelector:@selector(sharedApplication)]; + [app endBackgroundTask:self.backgroundTaskId]; + self.backgroundTaskId = UIBackgroundTaskInvalid; + } +#endif } } @@ -256,129 +282,87 @@ - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler { - + NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow; + NSInteger expected = (NSInteger)response.expectedContentLength; + expected = expected > 0 ? expected : 0; + self.expectedSize = expected; + self.response = response; + NSInteger statusCode = [response respondsToSelector:@selector(statusCode)] ? ((NSHTTPURLResponse *)response).statusCode : 200; + BOOL valid = statusCode >= 200 && statusCode < 400; + if (!valid) { + self.responseError = [NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorInvalidDownloadStatusCode userInfo:@{SDWebImageErrorDownloadStatusCodeKey : @(statusCode)}]; + } //'304 Not Modified' is an exceptional one - if (![response respondsToSelector:@selector(statusCode)] || (((NSHTTPURLResponse *)response).statusCode < 400 && ((NSHTTPURLResponse *)response).statusCode != 304)) { - NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0; - self.expectedSize = expected; + //URLSession current behavior will return 200 status code when the server respond 304 and URLCache hit. But this is not a standard behavior and we just add a check + if (statusCode == 304 && !self.cachedData) { + valid = NO; + self.responseError = [NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorCacheNotModified userInfo:nil]; + } + + if (valid) { for (SDWebImageDownloaderProgressBlock progressBlock in [self callbacksForKey:kProgressCallbackKey]) { progressBlock(0, expected, self.request.URL); } - - self.imageData = [[NSMutableData alloc] initWithCapacity:expected]; - self.response = response; - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadReceiveResponseNotification object:self]; - }); - } - else { - NSUInteger code = ((NSHTTPURLResponse *)response).statusCode; - - //This is the case when server returns '304 Not Modified'. It means that remote image is not changed. - //In case of 304 we need just cancel the operation and return cached image from the cache. - if (code == 304) { - [self cancelInternal]; - } else { - [self.dataTask cancel]; - } - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; - }); - - [self callCompletionBlocksWithError:[NSError errorWithDomain:NSURLErrorDomain code:((NSHTTPURLResponse *)response).statusCode userInfo:nil]]; - - [self done]; + } else { + // Status code invalid and marked as cancelled. Do not call `[self.dataTask cancel]` which may mass up URLSession life cycle + disposition = NSURLSessionResponseCancel; } + __block typeof(self) strongSelf = self; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadReceiveResponseNotification object:strongSelf]; + }); if (completionHandler) { - completionHandler(NSURLSessionResponseAllow); + completionHandler(disposition); } } - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data { + if (!self.imageData) { + self.imageData = [[NSMutableData alloc] initWithCapacity:self.expectedSize]; + } [self.imageData appendData:data]; - - if ((self.options & SDWebImageDownloaderProgressiveDownload) && self.expectedSize > 0) { - // The following code is from http://www.cocoaintheshell.com/2011/05/progressive-images-download-imageio/ - // Thanks to the author @Nyx0uf - - // Get the total bytes downloaded - const NSInteger totalSize = self.imageData.length; - - // Update the data source, we must pass ALL the data, not just the new bytes - CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)self.imageData, NULL); - - if (width + height == 0) { - CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); - if (properties) { - NSInteger orientationValue = -1; - CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight); - if (val) CFNumberGetValue(val, kCFNumberLongType, &height); - val = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth); - if (val) CFNumberGetValue(val, kCFNumberLongType, &width); - val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); - if (val) CFNumberGetValue(val, kCFNumberNSIntegerType, &orientationValue); - CFRelease(properties); - - // When we draw to Core Graphics, we lose orientation information, - // which means the image below born of initWithCGIImage will be - // oriented incorrectly sometimes. (Unlike the image born of initWithData - // in didCompleteWithError.) So save it here and pass it on later. -#if SD_UIKIT || SD_WATCH - orientation = [[self class] orientationFromPropertyValue:(orientationValue == -1 ? 1 : orientationValue)]; -#endif - } + + self.receivedSize = self.imageData.length; + if (self.expectedSize == 0) { + // Unknown expectedSize, immediately call progressBlock and return + for (SDWebImageDownloaderProgressBlock progressBlock in [self callbacksForKey:kProgressCallbackKey]) { + progressBlock(self.receivedSize, self.expectedSize, self.request.URL); } + return; + } + + // Get the finish status + BOOL finished = (self.receivedSize >= self.expectedSize); + // Get the current progress + double currentProgress = (double)self.receivedSize / (double)self.expectedSize; + double previousProgress = self.previousProgress; + double progressInterval = currentProgress - previousProgress; + // Check if we need callback progress + if (!finished && (progressInterval < self.minimumProgressInterval)) { + return; + } + self.previousProgress = currentProgress; - if (width + height > 0 && totalSize < self.expectedSize) { - // Create the image - CGImageRef partialImageRef = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL); - -#if SD_UIKIT || SD_WATCH - // Workaround for iOS anamorphic image - if (partialImageRef) { - const size_t partialHeight = CGImageGetHeight(partialImageRef); - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef bmContext = CGBitmapContextCreate(NULL, width, height, 8, width * 4, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); - CGColorSpaceRelease(colorSpace); - if (bmContext) { - CGContextDrawImage(bmContext, (CGRect){.origin.x = 0.0f, .origin.y = 0.0f, .size.width = width, .size.height = partialHeight}, partialImageRef); - CGImageRelease(partialImageRef); - partialImageRef = CGBitmapContextCreateImage(bmContext); - CGContextRelease(bmContext); - } - else { - CGImageRelease(partialImageRef); - partialImageRef = nil; - } - } -#endif - - if (partialImageRef) { -#if SD_UIKIT || SD_WATCH - UIImage *image = [UIImage imageWithCGImage:partialImageRef scale:1 orientation:orientation]; -#elif SD_MAC - UIImage *image = [[UIImage alloc] initWithCGImage:partialImageRef size:NSZeroSize]; -#endif - NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL]; - UIImage *scaledImage = [self scaledImageForKey:key image:image]; - if (self.shouldDecompressImages) { - image = [UIImage decodedImageWithImage:scaledImage]; - } - else { - image = scaledImage; + if (self.options & SDWebImageDownloaderProgressiveLoad) { + // Get the image data + NSData *imageData = [self.imageData copy]; + + // progressive decode the image in coder queue + dispatch_async(self.coderQueue, ^{ + @autoreleasepool { + UIImage *image = SDImageLoaderDecodeProgressiveImageData(imageData, self.request.URL, finished, self, [[self class] imageOptionsFromDownloaderOptions:self.options], self.context); + if (image) { + // We do not keep the progressive decoding image even when `finished`=YES. Because they are for view rendering but not take full function from downloader options. And some coders implementation may not keep consistent between progressive decoding and normal decoding. + + [self callCompletionBlocksWithImage:image imageData:nil error:nil finished:NO]; } - CGImageRelease(partialImageRef); - - [self callCompletionBlocksWithImage:image imageData:nil error:nil finished:NO]; } - } - - CFRelease(imageSource); + }); } - + for (SDWebImageDownloaderProgressBlock progressBlock in [self callbacksForKey:kProgressCallbackKey]) { - progressBlock(self.imageData.length, self.expectedSize, self.request.URL); + progressBlock(self.receivedSize, self.expectedSize, self.request.URL); } } @@ -386,11 +370,10 @@ - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask willCacheResponse:(NSCachedURLResponse *)proposedResponse completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler { - - responseFromCached = NO; // If this method is called, it means the response wasn't read from cache + NSCachedURLResponse *cachedResponse = proposedResponse; - if (self.request.cachePolicy == NSURLRequestReloadIgnoringLocalCacheData) { + if (!(self.options & SDWebImageDownloaderUseNSURLCache)) { // Prevents caching of responses cachedResponse = nil; } @@ -404,56 +387,59 @@ - (void)URLSession:(NSURLSession *)session - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error { @synchronized(self) { self.dataTask = nil; + __block typeof(self) strongSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:strongSelf]; if (!error) { - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadFinishNotification object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadFinishNotification object:strongSelf]; } }); } + // make sure to call `[self done]` to mark operation as finished if (error) { + // custom error instead of URLSession error + if (self.responseError) { + error = self.responseError; + } [self callCompletionBlocksWithError:error]; + [self done]; } else { if ([self callbacksForKey:kCompletedCallbackKey].count > 0) { - /** - * See #1608 and #1623 - apparently, there is a race condition on `NSURLCache` that causes a crash - * Limited the calls to `cachedResponseForRequest:` only for cases where we should ignore the cached response - * and images for which responseFromCached is YES (only the ones that cannot be cached). - * Note: responseFromCached is set to NO inside `willCacheResponse:`. This method doesn't get called for large images or images behind authentication - */ - if (self.options & SDWebImageDownloaderIgnoreCachedResponse && responseFromCached && [[NSURLCache sharedURLCache] cachedResponseForRequest:self.request]) { - // hack - [self callCompletionBlocksWithImage:nil imageData:nil error:nil finished:YES]; - } else if (self.imageData) { - UIImage *image = [UIImage sd_imageWithData:self.imageData]; - NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL]; - image = [self scaledImageForKey:key image:image]; - - // Do not force decoding animated GIFs - if (!image.images) { - if (self.shouldDecompressImages) { - if (self.options & SDWebImageDownloaderScaleDownLargeImages) { -#if SD_UIKIT || SD_WATCH - image = [UIImage decodedAndScaledDownImageWithImage:image]; - [self.imageData setData:UIImagePNGRepresentation(image)]; -#endif - } else { - image = [UIImage decodedImageWithImage:image]; - } - } - } - if (CGSizeEqualToSize(image.size, CGSizeZero)) { - [self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Downloaded image has 0 pixels"}]]; + NSData *imageData = [self.imageData copy]; + self.imageData = nil; + if (imageData) { + /** if you specified to only use cached data via `SDWebImageDownloaderIgnoreCachedResponse`, + * then we should check if the cached data is equal to image data + */ + if (self.options & SDWebImageDownloaderIgnoreCachedResponse && [self.cachedData isEqualToData:imageData]) { + self.responseError = [NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorCacheNotModified userInfo:nil]; + // call completion block with not modified error + [self callCompletionBlocksWithError:self.responseError]; + [self done]; } else { - [self callCompletionBlocksWithImage:image imageData:self.imageData error:nil finished:YES]; + // decode the image in coder queue + dispatch_async(self.coderQueue, ^{ + @autoreleasepool { + UIImage *image = SDImageLoaderDecodeImageData(imageData, self.request.URL, [[self class] imageOptionsFromDownloaderOptions:self.options], self.context); + CGSize imageSize = image.size; + if (imageSize.width == 0 || imageSize.height == 0) { + [self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorBadImageData userInfo:@{NSLocalizedDescriptionKey : @"Downloaded image has 0 pixels"}]]; + } else { + [self callCompletionBlocksWithImage:image imageData:imageData error:nil finished:YES]; + } + [self done]; + } + }); } } else { - [self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Image data is nil"}]]; + [self callCompletionBlocksWithError:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorBadImageData userInfo:@{NSLocalizedDescriptionKey : @"Image data is nil"}]]; + [self done]; } + } else { + [self done]; } } - [self done]; } - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { @@ -487,34 +473,14 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didRece } #pragma mark Helper methods - -#if SD_UIKIT || SD_WATCH -+ (UIImageOrientation)orientationFromPropertyValue:(NSInteger)value { - switch (value) { - case 1: - return UIImageOrientationUp; - case 3: - return UIImageOrientationDown; - case 8: - return UIImageOrientationLeft; - case 6: - return UIImageOrientationRight; - case 2: - return UIImageOrientationUpMirrored; - case 4: - return UIImageOrientationDownMirrored; - case 5: - return UIImageOrientationLeftMirrored; - case 7: - return UIImageOrientationRightMirrored; - default: - return UIImageOrientationUp; - } -} -#endif - -- (nullable UIImage *)scaledImageForKey:(nullable NSString *)key image:(nullable UIImage *)image { - return SDScaledImageForKey(key, image); ++ (SDWebImageOptions)imageOptionsFromDownloaderOptions:(SDWebImageDownloaderOptions)downloadOptions { + SDWebImageOptions options = 0; + if (downloadOptions & SDWebImageDownloaderScaleDownLargeImages) options |= SDWebImageScaleDownLargeImages; + if (downloadOptions & SDWebImageDownloaderDecodeFirstFrameOnly) options |= SDWebImageDecodeFirstFrameOnly; + if (downloadOptions & SDWebImageDownloaderPreloadAllFrames) options |= SDWebImagePreloadAllFrames; + if (downloadOptions & SDWebImageDownloaderAvoidDecodeImage) options |= SDWebImageAvoidDecodeImage; + + return options; } - (BOOL)shouldContinueWhenAppEntersBackground { diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderRequestModifier.h b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderRequestModifier.h new file mode 100644 index 00000000..fc449059 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderRequestModifier.h @@ -0,0 +1,26 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +typedef NSURLRequest * _Nullable (^SDWebImageDownloaderRequestModifierBlock)(NSURLRequest * _Nonnull request); + +// This is the protocol for downloader request modifier. We can use a block to specify the downloader request modifier. But Using protocol can make this extensible, and allow Swift user to use it easily instead of using `@convention(block)` to store a block into context options. +@protocol SDWebImageDownloaderRequestModifier + +- (nullable NSURLRequest *)modifiedRequestWithRequest:(nonnull NSURLRequest *)request; + +@end + +@interface SDWebImageDownloaderRequestModifier : NSObject + +- (nonnull instancetype)initWithBlock:(nonnull SDWebImageDownloaderRequestModifierBlock)block; ++ (nonnull instancetype)requestModifierWithBlock:(nonnull SDWebImageDownloaderRequestModifierBlock)block; + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderRequestModifier.m b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderRequestModifier.m new file mode 100644 index 00000000..22d044af --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderRequestModifier.m @@ -0,0 +1,39 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageDownloaderRequestModifier.h" + +@interface SDWebImageDownloaderRequestModifier () + +@property (nonatomic, copy, nonnull) SDWebImageDownloaderRequestModifierBlock block; + +@end + +@implementation SDWebImageDownloaderRequestModifier + +- (instancetype)initWithBlock:(SDWebImageDownloaderRequestModifierBlock)block { + self = [super init]; + if (self) { + self.block = block; + } + return self; +} + ++ (instancetype)requestModifierWithBlock:(SDWebImageDownloaderRequestModifierBlock)block { + SDWebImageDownloaderRequestModifier *requestModifier = [[SDWebImageDownloaderRequestModifier alloc] initWithBlock:block]; + return requestModifier; +} + +- (NSURLRequest *)modifiedRequestWithRequest:(NSURLRequest *)request { + if (!self.block) { + return nil; + } + return self.block(request); +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageError.h b/Pods/SDWebImage/SDWebImage/SDWebImageError.h new file mode 100644 index 00000000..1b18d7c6 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageError.h @@ -0,0 +1,22 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * (c) Jamie Pinkham + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +FOUNDATION_EXPORT NSErrorDomain const _Nonnull SDWebImageErrorDomain; + +FOUNDATION_EXPORT NSErrorUserInfoKey const _Nonnull SDWebImageErrorDownloadStatusCodeKey; + +typedef NS_ERROR_ENUM(SDWebImageErrorDomain, SDWebImageError) { + SDWebImageErrorInvalidURL = 1000, // The URL is invalid, such as nil URL or corrupted URL + SDWebImageErrorBadImageData = 1001, // The image data can not be decoded to image, or the image data is empty + SDWebImageErrorCacheNotModified = 1002, // The remote location specify that the cached image is not modified, such as the HTTP response 304 code. It's useful for `SDWebImageRefreshCached` + SDWebImageErrorInvalidDownloadOperation = 2000, // The image download operation is invalid, such as nil operation or unexpected error occur when operation initialized + SDWebImageErrorInvalidDownloadStatusCode = 2001, // The image downloda response a invalid status code. You can check the status code in error's userInfo under `SDWebImageErrorDownloadStatusCodeKey` +}; diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageError.m b/Pods/SDWebImage/SDWebImage/SDWebImageError.m new file mode 100644 index 00000000..6d174769 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageError.m @@ -0,0 +1,13 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * (c) Jamie Pinkham + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageError.h" + +NSErrorDomain const _Nonnull SDWebImageErrorDomain = @"SDWebImageErrorDomain"; +NSErrorUserInfoKey const _Nonnull SDWebImageErrorDownloadStatusCodeKey = @"SDWebImageErrorDownloadStatusCodeKey"; diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageIndicator.h b/Pods/SDWebImage/SDWebImage/SDWebImageIndicator.h new file mode 100644 index 00000000..9716dd90 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageIndicator.h @@ -0,0 +1,97 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +#if SD_UIKIT || SD_MAC + +// A protocol to custom the indicator during the image loading +// All of these methods are called from main queue +@protocol SDWebImageIndicator + +@required +/** + The view associate to the indicator. + + @return The indicator view + */ +@property (nonatomic, strong, readonly, nonnull) UIView *indicatorView; +/** + Start the animating for indicator. + */ +- (void)startAnimatingIndicator; +/** + Stop the animating for indicator. + */ +- (void)stopAnimatingIndicator; + +@optional +/** + Update the loading progress (0-1.0) for indicator. Optional + + @param progress The progress, value between 0 and 1.0 + */ +- (void)updateIndicatorProgress:(double)progress; + +@end + +#pragma mark - Activity Indicator + +// Activity indicator class +// for UIKit(macOS), it use a `UIActivityIndicatorView` +// for AppKit(macOS), it use a `NSProgressIndicator` with the spinning style +@interface SDWebImageActivityIndicator : NSObject + +#if SD_UIKIT +@property (nonatomic, strong, readonly, nonnull) UIActivityIndicatorView *indicatorView; +#else +@property (nonatomic, strong, readonly, nonnull) NSProgressIndicator *indicatorView; +#endif + +@end + +// Convenience way to use activity indicator. +@interface SDWebImageActivityIndicator (Conveniences) + +/// gray-style activity indicator +@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayIndicator; +/// large gray-style activity indicator +@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *grayLargeIndicator; +/// white-style activity indicator +@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteIndicator; +/// large white-style activity indicator +@property (nonatomic, class, nonnull, readonly) SDWebImageActivityIndicator *whiteLargeIndicator; + +@end + +#pragma mark - Progress Indicator + +// Progress indicator class +// for UIKit(macOS), it use a `UIProgressView` +// for AppKit(macOS), it use a `NSProgressIndicator` with the bar style +@interface SDWebImageProgressIndicator : NSObject + +#if SD_UIKIT +@property (nonatomic, strong, readonly, nonnull) UIProgressView *indicatorView; +#else +@property (nonatomic, strong, readonly, nonnull) NSProgressIndicator *indicatorView; +#endif + +@end + +// Convenience way to create progress indicator. Remember to specify the indicator width or use layout constraint if need. +@interface SDWebImageProgressIndicator (Conveniences) + +/// default-style progress indicator +@property (nonatomic, class, nonnull, readonly) SDWebImageProgressIndicator *defaultIndicator; +/// bar-style progress indicator +@property (nonatomic, class, nonnull, readonly) SDWebImageProgressIndicator *barIndicator API_UNAVAILABLE(macos, tvos); + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageIndicator.m b/Pods/SDWebImage/SDWebImage/SDWebImageIndicator.m new file mode 100644 index 00000000..bec23fbc --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageIndicator.m @@ -0,0 +1,233 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageIndicator.h" + +#if SD_UIKIT || SD_MAC + +#if SD_MAC +#import +#endif + +#pragma mark - Activity Indicator + +@interface SDWebImageActivityIndicator () + +#if SD_UIKIT +@property (nonatomic, strong, readwrite, nonnull) UIActivityIndicatorView *indicatorView; +#else +@property (nonatomic, strong, readwrite, nonnull) NSProgressIndicator *indicatorView; +#endif + +@end + +@implementation SDWebImageActivityIndicator + +- (instancetype)init { + self = [super init]; + if (self) { + [self commonInit]; + } + return self; +} + +#if SD_UIKIT +- (void)commonInit { + self.indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; + self.indicatorView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin; +} +#endif + +#if SD_MAC +- (void)commonInit { + self.indicatorView = [[NSProgressIndicator alloc] initWithFrame:NSZeroRect]; + self.indicatorView.style = NSProgressIndicatorStyleSpinning; + self.indicatorView.controlSize = NSControlSizeSmall; + [self.indicatorView sizeToFit]; + self.indicatorView.autoresizingMask = NSViewMaxXMargin | NSViewMinXMargin | NSViewMaxYMargin | NSViewMinYMargin; +} +#endif + +- (void)startAnimatingIndicator { +#if SD_UIKIT + [self.indicatorView startAnimating]; +#else + [self.indicatorView startAnimation:nil]; +#endif + self.indicatorView.hidden = NO; +} + +- (void)stopAnimatingIndicator { +#if SD_UIKIT + [self.indicatorView stopAnimating]; +#else + [self.indicatorView stopAnimation:nil]; +#endif + self.indicatorView.hidden = YES; +} + +@end + +@implementation SDWebImageActivityIndicator (Conveniences) + ++ (SDWebImageActivityIndicator *)grayIndicator { + SDWebImageActivityIndicator *indicator = [SDWebImageActivityIndicator new]; +#if SD_UIKIT +#if SD_IOS + indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; +#else + indicator.indicatorView.color = [UIColor colorWithWhite:0 alpha:0.45]; // Color from `UIActivityIndicatorViewStyleGray` +#endif +#endif + return indicator; +} + ++ (SDWebImageActivityIndicator *)grayLargeIndicator { + SDWebImageActivityIndicator *indicator = SDWebImageActivityIndicator.grayIndicator; +#if SD_UIKIT + UIColor *grayColor = indicator.indicatorView.color; + indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; + indicator.indicatorView.color = grayColor; +#else + indicator.indicatorView.controlSize = NSControlSizeRegular; +#endif + [indicator.indicatorView sizeToFit]; + return indicator; +} + ++ (SDWebImageActivityIndicator *)whiteIndicator { + SDWebImageActivityIndicator *indicator = [SDWebImageActivityIndicator new]; +#if SD_UIKIT + indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite; +#else + CIFilter *lighten = [CIFilter filterWithName:@"CIColorControls"]; + [lighten setDefaults]; + [lighten setValue:@(1) forKey:kCIInputBrightnessKey]; + indicator.indicatorView.contentFilters = @[lighten]; +#endif + return indicator; +} + ++ (SDWebImageActivityIndicator *)whiteLargeIndicator { + SDWebImageActivityIndicator *indicator = SDWebImageActivityIndicator.whiteIndicator; +#if SD_UIKIT + indicator.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; +#else + indicator.indicatorView.controlSize = NSControlSizeRegular; + [indicator.indicatorView sizeToFit]; +#endif + return indicator; +} + +@end + +#pragma mark - Progress Indicator + +@interface SDWebImageProgressIndicator () + +#if SD_UIKIT +@property (nonatomic, strong, readwrite, nonnull) UIProgressView *indicatorView; +#else +@property (nonatomic, strong, readwrite, nonnull) NSProgressIndicator *indicatorView; +#endif + +@end + +@implementation SDWebImageProgressIndicator + +- (instancetype)init { + self = [super init]; + if (self) { + [self commonInit]; + } + return self; +} + +#if SD_UIKIT +- (void)commonInit { + self.indicatorView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault]; + self.indicatorView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin; +} +#endif + +#if SD_MAC +- (void)commonInit { + self.indicatorView = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0, 0, 160, 0)]; // Width from `UIProgressView` default width + self.indicatorView.style = NSProgressIndicatorStyleBar; + self.indicatorView.controlSize = NSControlSizeSmall; + [self.indicatorView sizeToFit]; + self.indicatorView.autoresizingMask = NSViewMaxXMargin | NSViewMinXMargin | NSViewMaxYMargin | NSViewMinYMargin; +} +#endif + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability" +- (void)startAnimatingIndicator { + self.indicatorView.hidden = NO; +#if SD_UIKIT + if ([self.indicatorView respondsToSelector:@selector(observedProgress)] && self.indicatorView.observedProgress) { + // Ignore NSProgress + } else { + self.indicatorView.progress = 0; + } +#else + self.indicatorView.indeterminate = YES; + self.indicatorView.doubleValue = 0; + [self.indicatorView startAnimation:nil]; +#endif +} + +- (void)stopAnimatingIndicator { + self.indicatorView.hidden = YES; +#if SD_UIKIT + if ([self.indicatorView respondsToSelector:@selector(observedProgress)] && self.indicatorView.observedProgress) { + // Ignore NSProgress + } else { + self.indicatorView.progress = 1; + } +#else + self.indicatorView.indeterminate = NO; + self.indicatorView.doubleValue = 100; + [self.indicatorView stopAnimation:nil]; +#endif +} + +- (void)updateIndicatorProgress:(double)progress { +#if SD_UIKIT + if ([self.indicatorView respondsToSelector:@selector(observedProgress)] && self.indicatorView.observedProgress) { + // Ignore NSProgress + } else { + [self.indicatorView setProgress:progress animated:YES]; + } +#else + self.indicatorView.indeterminate = progress > 0 ? NO : YES; + self.indicatorView.doubleValue = progress * 100; +#endif +} +#pragma clang diagnostic pop + +@end + +@implementation SDWebImageProgressIndicator (Conveniences) + ++ (SDWebImageProgressIndicator *)defaultIndicator { + SDWebImageProgressIndicator *indicator = [SDWebImageProgressIndicator new]; + return indicator; +} + +#if SD_IOS ++ (SDWebImageProgressIndicator *)barIndicator { + SDWebImageProgressIndicator *indicator = [SDWebImageProgressIndicator new]; + indicator.indicatorView.progressViewStyle = UIProgressViewStyleBar; + return indicator; +} +#endif + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageManager.h b/Pods/SDWebImage/SDWebImage/SDWebImageManager.h index ba8b7555..94e09420 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImageManager.h +++ b/Pods/SDWebImage/SDWebImage/SDWebImageManager.h @@ -8,100 +8,35 @@ #import "SDWebImageCompat.h" #import "SDWebImageOperation.h" -#import "SDWebImageDownloader.h" -#import "SDImageCache.h" - -typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { - /** - * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying. - * This flag disable this blacklisting. - */ - SDWebImageRetryFailed = 1 << 0, - - /** - * By default, image downloads are started during UI interactions, this flags disable this feature, - * leading to delayed download on UIScrollView deceleration for instance. - */ - SDWebImageLowPriority = 1 << 1, - - /** - * This flag disables on-disk caching - */ - SDWebImageCacheMemoryOnly = 1 << 2, - - /** - * This flag enables progressive download, the image is displayed progressively during download as a browser would do. - * By default, the image is only displayed once completely downloaded. - */ - SDWebImageProgressiveDownload = 1 << 3, - - /** - * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. - * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. - * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics. - * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image. - * - * Use this flag only if you can't make your URLs static with embedded cache busting parameter. - */ - SDWebImageRefreshCached = 1 << 4, - - /** - * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for - * extra time in background to let the request finish. If the background task expires the operation will be cancelled. - */ - SDWebImageContinueInBackground = 1 << 5, - - /** - * Handles cookies stored in NSHTTPCookieStore by setting - * NSMutableURLRequest.HTTPShouldHandleCookies = YES; - */ - SDWebImageHandleCookies = 1 << 6, - - /** - * Enable to allow untrusted SSL certificates. - * Useful for testing purposes. Use with caution in production. - */ - SDWebImageAllowInvalidSSLCertificates = 1 << 7, - - /** - * By default, images are loaded in the order in which they were queued. This flag moves them to - * the front of the queue. - */ - SDWebImageHighPriority = 1 << 8, - - /** - * By default, placeholder images are loaded while the image is loading. This flag will delay the loading - * of the placeholder image until after the image has finished loading. - */ - SDWebImageDelayPlaceholder = 1 << 9, - - /** - * We usually don't call transformDownloadedImage delegate method on animated images, - * as most transformation code would mangle it. - * Use this flag to transform them anyway. - */ - SDWebImageTransformAnimatedImage = 1 << 10, - - /** - * By default, image is added to the imageView after download. But in some cases, we want to - * have the hand before setting the image (apply a filter or add it with cross-fade animation for instance) - * Use this flag if you want to manually set the image in the completion when success - */ - SDWebImageAvoidAutoSetImage = 1 << 11, - - /** - * 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. - * If `SDWebImageProgressiveDownload` flag is set the scale down is deactivated. - */ - SDWebImageScaleDownLargeImages = 1 << 12 -}; +#import "SDImageCacheDefine.h" +#import "SDImageLoader.h" +#import "SDImageTransformer.h" +#import "SDWebImageCacheKeyFilter.h" +#import "SDWebImageCacheSerializer.h" typedef void(^SDExternalCompletionBlock)(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL); typedef void(^SDInternalCompletionBlock)(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL); -typedef NSString * _Nullable (^SDWebImageCacheKeyFilterBlock)(NSURL * _Nullable url); +// A combined operation representing the cache and loader operation. You can use it to cancel the load process. +@interface SDWebImageCombinedOperation : NSObject + +/** + Cancel the current operation, including cache and loader process + */ +- (void)cancel; + +/** + The cache operation from the image cache query + */ +@property (strong, nonatomic, nullable, readonly) id cacheOperation; + +/** + The loader operation from the image loader (such as download operation) + */ +@property (strong, nonatomic, nullable, readonly) id loaderOperation; + +@end @class SDWebImageManager; @@ -118,19 +53,17 @@ typedef NSString * _Nullable (^SDWebImageCacheKeyFilterBlock)(NSURL * _Nullable * * @return Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied. */ -- (BOOL)imageManager:(nonnull SDWebImageManager *)imageManager shouldDownloadImageForURL:(nullable NSURL *)imageURL; +- (BOOL)imageManager:(nonnull SDWebImageManager *)imageManager shouldDownloadImageForURL:(nonnull NSURL *)imageURL; /** - * Allows to transform the image immediately after it has been downloaded and just before to cache it on disk and memory. - * NOTE: This method is called from a global queue in order to not to block the main thread. - * - * @param imageManager The current `SDWebImageManager` - * @param image The image to transform - * @param imageURL The url of the image to transform - * - * @return The transformed image object. + * Controls the complicated logic to mark as failed URLs when download error occur. + * If the delegate implement this method, we will not use the built-in way to mark URL as failed based on error code; + @param imageManager The current `SDWebImageManager` + @param imageURL The url of the image + @param error The download error for the url + @return Whether to block this url or not. Return YES to mark this URL as failed. */ -- (nullable UIImage *)imageManager:(nonnull SDWebImageManager *)imageManager transformDownloadedImage:(nullable UIImage *)image withURL:(nullable NSURL *)imageURL; +- (BOOL)imageManager:(nonnull SDWebImageManager *)imageManager shouldBlockFailedURL:(nonnull NSURL *)imageURL withError:(nonnull NSError *)error; @end @@ -158,41 +91,90 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager]; */ @interface SDWebImageManager : NSObject +/** + * The delegate for manager. Defatuls to nil. + */ @property (weak, nonatomic, nullable) id delegate; -@property (strong, nonatomic, readonly, nullable) SDImageCache *imageCache; -@property (strong, nonatomic, readonly, nullable) SDWebImageDownloader *imageDownloader; +/** + * The image cache used by manager to query image cache. + */ +@property (strong, nonatomic, readonly, nonnull) id imageCache; + +/** + * The image loader used by manager to load image. + */ +@property (strong, nonatomic, readonly, nonnull) id imageLoader; + +/** + The image transformer for manager. It's used for image transform after the image load finished and store the transformed image to cache, see `SDImageTransformer`. + Defaults to nil, which means no transform is applied. + @note This will affect all the load requests for this manager if you provide. However, you can pass `SDWebImageContextImageTransformer` in context arg to explicitly use that transformer instead. + */ +@property (strong, nonatomic, nullable) id transformer; /** - * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can - * be used to remove dynamic part of an image URL. + * The cache filter is used to convert an URL into a cache key each time SDWebImageManager need cache key to use image cache. * * The following example sets a filter in the application delegate that will remove any query-string from the * URL before to use it as a cache key: * * @code - -[[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) { + SDWebImageManager.sharedManager.cacheKeyFilter =[SDWebImageCacheKeyFilter cacheKeyFilterWithBlock:^NSString * _Nullable(NSURL * _Nonnull url) { url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; return [url absoluteString]; -}]; + }]; + * @endcode + */ +@property (nonatomic, strong, nullable) id cacheKeyFilter; +/** + * The cache serializer is used to convert the decoded image, the source downloaded data, to the actual data used for storing to the disk cache. If you return nil, means to generate the data from the image instance, see `SDImageCache`. + * For example, if you are using WebP images and facing the slow decoding time issue when later retriving from disk cache again. You can try to encode the decoded image to JPEG/PNG format to disk cache instead of source downloaded data. + * @note The `image` arg is nonnull, but when you also provide a image transformer and the image is transformed, the `data` arg may be nil, take attention to this case. + * @note This method is called from a global queue in order to not to block the main thread. + * @code + SDWebImageManager.sharedManager.cacheSerializer = [SDWebImageCacheSerializer cacheSerializerWithBlock:^NSData * _Nullable(UIImage * _Nonnull image, NSData * _Nullable data, NSURL * _Nullable imageURL) { + SDImageFormat format = [NSData sd_imageFormatForImageData:data]; + switch (format) { + case SDImageFormatWebP: + return image.images ? data : nil; + default: + return data; + } +}]; * @endcode + * The default value is nil. Means we just store the source downloaded data to disk cache. */ -@property (nonatomic, copy, nullable) SDWebImageCacheKeyFilterBlock cacheKeyFilter; +@property (nonatomic, strong, nullable) id cacheSerializer; /** - * Returns global SDWebImageManager instance. - * - * @return SDWebImageManager shared instance + * Check one or more operations running + */ +@property (nonatomic, assign, readonly, getter=isRunning) BOOL running; + +/** + The default image cache when the manager which is created with no arguments. Such as shared manager or init. + Defaults to nil. Means using `SDImageCache.sharedImageCache` + */ +@property (nonatomic, class, nullable) id defaultImageCache; + +/** + The default image loader for manager which is created with no arguments. Such as shared manager or init. + Defaults to nil. Means using `SDWebImageDownloader.sharedDownloader` + */ +@property (nonatomic, class, nullable) id defaultImageLoader; + +/** + * Returns global shared manager instance. */ -+ (nonnull instancetype)sharedManager; +@property (nonatomic, class, readonly, nonnull) SDWebImageManager *sharedManager; /** - * Allows to specify instance of cache and image downloader used with image manager. - * @return new instance of `SDWebImageManager` with specified cache and downloader. + * Allows to specify instance of cache and image loader used with image manager. + * @return new instance of `SDWebImageManager` with specified cache and loader. */ -- (nonnull instancetype)initWithCache:(nonnull SDImageCache *)cache downloader:(nonnull SDWebImageDownloader *)downloader NS_DESIGNATED_INITIALIZER; +- (nonnull instancetype)initWithCache:(nonnull id)cache loader:(nonnull id)loader NS_DESIGNATED_INITIALIZER; /** * Downloads the image at the given URL if not present in cache or return the cached version otherwise. @@ -211,28 +193,36 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager]; * The forth parameter is an `SDImageCacheType` enum indicating if the image was retrieved from the local cache * or from the memory cache or from the network. * - * The fith parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is + * The fith parameter is set to NO when the SDWebImageProgressiveLoad option is used and the image is * downloading. This block is thus called repeatedly with a partial image. When image is fully downloaded, the * block is called a last time with the full image and the last parameter set to YES. * * The last parameter is the original image URL * - * @return Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation + * @return Returns an instance of SDWebImageCombinedOperation, which you can cancel the loading process. */ -- (nullable id )loadImageWithURL:(nullable NSURL *)url - options:(SDWebImageOptions)options - progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock - completed:(nullable SDInternalCompletionBlock)completedBlock; +- (nullable SDWebImageCombinedOperation *)loadImageWithURL:(nullable NSURL *)url + options:(SDWebImageOptions)options + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nonnull SDInternalCompletionBlock)completedBlock; /** - * Saves image to cache for given URL + * Downloads the image at the given URL if not present in cache or return the cached version otherwise. * - * @param image The image to cache - * @param url The URL to the image + * @param url The URL to the image + * @param options A mask to specify options to use for this request + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + * @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue + * @param completedBlock A block called when operation has been completed. * + * @return Returns an instance of SDWebImageCombinedOperation, which you can cancel the loading process. */ - -- (void)saveImageToCache:(nullable UIImage *)image forURL:(nullable NSURL *)url; +- (nullable SDWebImageCombinedOperation *)loadImageWithURL:(nullable NSURL *)url + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nonnull SDInternalCompletionBlock)completedBlock; /** * Cancel all current operations @@ -240,35 +230,7 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager]; - (void)cancelAll; /** - * Check one or more operations running - */ -- (BOOL)isRunning; - -/** - * Async check if image has already been cached - * - * @param url image url - * @param completionBlock the block to be executed when the check is finished - * - * @note the completion block is always executed on the main queue - */ -- (void)cachedImageExistsForURL:(nullable NSURL *)url - completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock; - -/** - * Async check if image has already been cached on disk only - * - * @param url image url - * @param completionBlock the block to be executed when the check is finished - * - * @note the completion block is always executed on the main queue - */ -- (void)diskImageExistsForURL:(nullable NSURL *)url - completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock; - - -/** - *Return the cache key for a given URL + * Return the cache key for a given URL */ - (nullable NSString *)cacheKeyForURL:(nullable NSURL *)url; diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageManager.m b/Pods/SDWebImage/SDWebImage/SDWebImageManager.m index d7d6865d..666148dd 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImageManager.m +++ b/Pods/SDWebImage/SDWebImage/SDWebImageManager.m @@ -7,28 +7,58 @@ */ #import "SDWebImageManager.h" -#import -#import "NSImage+WebCache.h" +#import "SDImageCache.h" +#import "SDWebImageDownloader.h" +#import "UIImage+Metadata.h" +#import "SDWebImageError.h" -@interface SDWebImageCombinedOperation : NSObject +static id _defaultImageCache; +static id _defaultImageLoader; + +@interface SDWebImageCombinedOperation () @property (assign, nonatomic, getter = isCancelled) BOOL cancelled; -@property (copy, nonatomic, nullable) SDWebImageNoParamsBlock cancelBlock; -@property (strong, nonatomic, nullable) NSOperation *cacheOperation; +@property (strong, nonatomic, readwrite, nullable) id loaderOperation; +@property (strong, nonatomic, readwrite, nullable) id cacheOperation; +@property (weak, nonatomic, nullable) SDWebImageManager *manager; @end @interface SDWebImageManager () @property (strong, nonatomic, readwrite, nonnull) SDImageCache *imageCache; -@property (strong, nonatomic, readwrite, nonnull) SDWebImageDownloader *imageDownloader; +@property (strong, nonatomic, readwrite, nonnull) id imageLoader; @property (strong, nonatomic, nonnull) NSMutableSet *failedURLs; -@property (strong, nonatomic, nonnull) NSMutableArray *runningOperations; +@property (strong, nonatomic, nonnull) dispatch_semaphore_t failedURLsLock; // a lock to keep the access to `failedURLs` thread-safe +@property (strong, nonatomic, nonnull) NSMutableSet *runningOperations; +@property (strong, nonatomic, nonnull) dispatch_semaphore_t runningOperationsLock; // a lock to keep the access to `runningOperations` thread-safe @end @implementation SDWebImageManager ++ (id)defaultImageCache { + return _defaultImageCache; +} + ++ (void)setDefaultImageCache:(id)defaultImageCache { + if (defaultImageCache && ![defaultImageCache conformsToProtocol:@protocol(SDImageCache)]) { + return; + } + _defaultImageCache = defaultImageCache; +} + ++ (id)defaultImageLoader { + return _defaultImageLoader; +} + ++ (void)setDefaultImageLoader:(id)defaultImageLoader { + if (defaultImageLoader && ![defaultImageLoader conformsToProtocol:@protocol(SDImageLoader)]) { + return; + } + _defaultImageLoader = defaultImageLoader; +} + + (nonnull instancetype)sharedManager { static dispatch_once_t once; static id instance; @@ -39,73 +69,54 @@ + (nonnull instancetype)sharedManager { } - (nonnull instancetype)init { - SDImageCache *cache = [SDImageCache sharedImageCache]; - SDWebImageDownloader *downloader = [SDWebImageDownloader sharedDownloader]; - return [self initWithCache:cache downloader:downloader]; + id cache = [[self class] defaultImageCache]; + if (!cache) { + cache = [SDImageCache sharedImageCache]; + } + id loader = [[self class] defaultImageLoader]; + if (!loader) { + loader = [SDWebImageDownloader sharedDownloader]; + } + return [self initWithCache:cache loader:loader]; } -- (nonnull instancetype)initWithCache:(nonnull SDImageCache *)cache downloader:(nonnull SDWebImageDownloader *)downloader { +- (nonnull instancetype)initWithCache:(nonnull id)cache loader:(nonnull id)loader { if ((self = [super init])) { _imageCache = cache; - _imageDownloader = downloader; + _imageLoader = loader; _failedURLs = [NSMutableSet new]; - _runningOperations = [NSMutableArray new]; + _failedURLsLock = dispatch_semaphore_create(1); + _runningOperations = [NSMutableSet new]; + _runningOperationsLock = dispatch_semaphore_create(1); } return self; } - (nullable NSString *)cacheKeyForURL:(nullable NSURL *)url { + return [self cacheKeyForURL:url cacheKeyFilter:self.cacheKeyFilter]; +} + +- (nullable NSString *)cacheKeyForURL:(nullable NSURL *)url cacheKeyFilter:(id)cacheKeyFilter { if (!url) { return @""; } - if (self.cacheKeyFilter) { - return self.cacheKeyFilter(url); + if (cacheKeyFilter) { + return [cacheKeyFilter cacheKeyForURL:url]; } else { return url.absoluteString; } } -- (void)cachedImageExistsForURL:(nullable NSURL *)url - completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock { - NSString *key = [self cacheKeyForURL:url]; - - BOOL isInMemoryCache = ([self.imageCache imageFromMemoryCacheForKey:key] != nil); - - if (isInMemoryCache) { - // making sure we call the completion block on the main queue - dispatch_async(dispatch_get_main_queue(), ^{ - if (completionBlock) { - completionBlock(YES); - } - }); - return; - } - - [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) { - // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch - if (completionBlock) { - completionBlock(isInDiskCache); - } - }]; -} - -- (void)diskImageExistsForURL:(nullable NSURL *)url - completion:(nullable SDWebImageCheckCacheCompletionBlock)completionBlock { - NSString *key = [self cacheKeyForURL:url]; - - [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) { - // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch - if (completionBlock) { - completionBlock(isInDiskCache); - } - }]; +- (SDWebImageCombinedOperation *)loadImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDImageLoaderProgressBlock)progressBlock completed:(SDInternalCompletionBlock)completedBlock { + return [self loadImageWithURL:url options:options context:nil progress:progressBlock completed:completedBlock]; } -- (id )loadImageWithURL:(nullable NSURL *)url - options:(SDWebImageOptions)options - progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock - completed:(nullable SDInternalCompletionBlock)completedBlock { +- (SDWebImageCombinedOperation *)loadImageWithURL:(nullable NSURL *)url + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nonnull SDInternalCompletionBlock)completedBlock { // Invoking this method without a completedBlock is pointless NSAssert(completedBlock != nil, @"If you mean to prefetch the image, use -[SDWebImagePrefetcher prefetchURLs] instead"); @@ -120,162 +131,218 @@ - (void)diskImageExistsForURL:(nullable NSURL *)url url = nil; } - __block SDWebImageCombinedOperation *operation = [SDWebImageCombinedOperation new]; - __weak SDWebImageCombinedOperation *weakOperation = operation; + SDWebImageCombinedOperation *operation = [SDWebImageCombinedOperation new]; + operation.manager = self; BOOL isFailedUrl = NO; if (url) { - @synchronized (self.failedURLs) { - isFailedUrl = [self.failedURLs containsObject:url]; - } + SD_LOCK(self.failedURLsLock); + isFailedUrl = [self.failedURLs containsObject:url]; + SD_UNLOCK(self.failedURLsLock); } if (url.absoluteString.length == 0 || (!(options & SDWebImageRetryFailed) && isFailedUrl)) { - [self callCompletionBlockForOperation:operation completion:completedBlock error:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil] url:url]; + [self callCompletionBlockForOperation:operation completion:completedBlock error:[NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorInvalidURL userInfo:@{NSLocalizedDescriptionKey : @"Image url is nil"}] url:url]; return operation; } - @synchronized (self.runningOperations) { - [self.runningOperations addObject:operation]; - } - NSString *key = [self cacheKeyForURL:url]; - - operation.cacheOperation = [self.imageCache queryCacheOperationForKey:key done:^(UIImage *cachedImage, NSData *cachedData, SDImageCacheType cacheType) { - if (operation.isCancelled) { - [self safelyRemoveOperationFromRunning:operation]; - return; - } - - if ((!cachedImage || options & SDWebImageRefreshCached) && (![self.delegate respondsToSelector:@selector(imageManager:shouldDownloadImageForURL:)] || [self.delegate imageManager:self shouldDownloadImageForURL:url])) { - if (cachedImage && options & SDWebImageRefreshCached) { - // If image was found in the cache but SDWebImageRefreshCached is provided, notify about the cached image - // AND try to re-download it in order to let a chance to NSURLCache to refresh it from server. - [self callCompletionBlockForOperation:weakOperation completion:completedBlock image:cachedImage data:cachedData error:nil cacheType:cacheType finished:YES url:url]; - } + SD_LOCK(self.runningOperationsLock); + [self.runningOperations addObject:operation]; + SD_UNLOCK(self.runningOperationsLock); + + // Preprocess the context arg to provide the default value from manager + context = [self processedContextWithContext:context]; + + // Start the entry to load image from cache + [self callCacheProcessForOperation:operation url:url options:options context:context progress:progressBlock completed:completedBlock]; - // download if no image or requested to refresh anyway, and download allowed by delegate - SDWebImageDownloaderOptions downloaderOptions = 0; - if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority; - if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload; - if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache; - if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground; - if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies; - if (options & SDWebImageAllowInvalidSSLCertificates) downloaderOptions |= SDWebImageDownloaderAllowInvalidSSLCertificates; - if (options & SDWebImageHighPriority) downloaderOptions |= SDWebImageDownloaderHighPriority; - if (options & SDWebImageScaleDownLargeImages) downloaderOptions |= SDWebImageDownloaderScaleDownLargeImages; - - if (cachedImage && options & SDWebImageRefreshCached) { - // force progressive off if image already cached but forced refreshing - downloaderOptions &= ~SDWebImageDownloaderProgressiveDownload; - // ignore image read from NSURLCache if image if cached but force refreshing - downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse; - } - - SDWebImageDownloadToken *subOperationToken = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *downloadedData, NSError *error, BOOL finished) { - __strong __typeof(weakOperation) strongOperation = weakOperation; - if (!strongOperation || strongOperation.isCancelled) { - // Do nothing if the operation was cancelled - // See #699 for more details - // if we would call the completedBlock, there could be a race condition between this block and another completedBlock for the same object, so if this one is called second, we will overwrite the new data - } else if (error) { - [self callCompletionBlockForOperation:strongOperation completion:completedBlock error:error url:url]; - - if ( error.code != NSURLErrorNotConnectedToInternet - && error.code != NSURLErrorCancelled - && error.code != NSURLErrorTimedOut - && error.code != NSURLErrorInternationalRoamingOff - && error.code != NSURLErrorDataNotAllowed - && error.code != NSURLErrorCannotFindHost - && error.code != NSURLErrorCannotConnectToHost) { - @synchronized (self.failedURLs) { - [self.failedURLs addObject:url]; - } - } - } - else { - if ((options & SDWebImageRetryFailed)) { - @synchronized (self.failedURLs) { - [self.failedURLs removeObject:url]; - } - } - - BOOL cacheOnDisk = !(options & SDWebImageCacheMemoryOnly); - - if (options & SDWebImageRefreshCached && cachedImage && !downloadedImage) { - // Image refresh hit the NSURLCache cache, do not call the completion block - } else if (downloadedImage && (!downloadedImage.images || (options & SDWebImageTransformAnimatedImage)) && [self.delegate respondsToSelector:@selector(imageManager:transformDownloadedImage:withURL:)]) { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ - UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url]; - - if (transformedImage && finished) { - BOOL imageWasTransformed = ![transformedImage isEqual:downloadedImage]; - // pass nil if the image was transformed, so we can recalculate the data from the image - [self.imageCache storeImage:transformedImage imageData:(imageWasTransformed ? nil : downloadedData) forKey:key toDisk:cacheOnDisk completion:nil]; - } - - [self callCompletionBlockForOperation:strongOperation completion:completedBlock image:transformedImage data:downloadedData error:nil cacheType:SDImageCacheTypeNone finished:finished url:url]; - }); - } else { - if (downloadedImage && finished) { - [self.imageCache storeImage:downloadedImage imageData:downloadedData forKey:key toDisk:cacheOnDisk completion:nil]; - } - [self callCompletionBlockForOperation:strongOperation completion:completedBlock image:downloadedImage data:downloadedData error:nil cacheType:SDImageCacheTypeNone finished:finished url:url]; - } - } + return operation; +} - if (finished) { - [self safelyRemoveOperationFromRunning:strongOperation]; - } - }]; - operation.cancelBlock = ^{ - [self.imageDownloader cancel:subOperationToken]; - __strong __typeof(weakOperation) strongOperation = weakOperation; - [self safelyRemoveOperationFromRunning:strongOperation]; - }; - } else if (cachedImage) { - __strong __typeof(weakOperation) strongOperation = weakOperation; - [self callCompletionBlockForOperation:strongOperation completion:completedBlock image:cachedImage data:cachedData error:nil cacheType:cacheType finished:YES url:url]; - [self safelyRemoveOperationFromRunning:operation]; - } else { - // Image not in cache and download disallowed by delegate - __strong __typeof(weakOperation) strongOperation = weakOperation; - [self callCompletionBlockForOperation:strongOperation completion:completedBlock image:nil data:nil error:nil cacheType:SDImageCacheTypeNone finished:YES url:url]; - [self safelyRemoveOperationFromRunning:operation]; - } - }]; +- (void)cancelAll { + SD_LOCK(self.runningOperationsLock); + NSSet *copiedOperations = [self.runningOperations copy]; + SD_UNLOCK(self.runningOperationsLock); + [copiedOperations makeObjectsPerformSelector:@selector(cancel)]; // This will call `safelyRemoveOperationFromRunning:` and remove from the array +} - return operation; +- (BOOL)isRunning { + BOOL isRunning = NO; + SD_LOCK(self.runningOperationsLock); + isRunning = (self.runningOperations.count > 0); + SD_UNLOCK(self.runningOperationsLock); + return isRunning; } -- (void)saveImageToCache:(nullable UIImage *)image forURL:(nullable NSURL *)url { - if (image && url) { - NSString *key = [self cacheKeyForURL:url]; - [self.imageCache storeImage:image forKey:key toDisk:YES completion:nil]; +#pragma mark - Private + +// Query cache process +- (void)callCacheProcessForOperation:(nonnull SDWebImageCombinedOperation *)operation + url:(nonnull NSURL *)url + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDInternalCompletionBlock)completedBlock { + // Check whether we should query cache + BOOL shouldQueryCache = (options & SDWebImageFromLoaderOnly) == 0; + if (shouldQueryCache) { + id cacheKeyFilter = context[SDWebImageContextCacheKeyFilter]; + NSString *key = [self cacheKeyForURL:url cacheKeyFilter:cacheKeyFilter]; + @weakify(operation); + operation.cacheOperation = [self.imageCache queryImageForKey:key options:options context:context completion:^(UIImage * _Nullable cachedImage, NSData * _Nullable cachedData, SDImageCacheType cacheType) { + @strongify(operation); + if (!operation || operation.isCancelled) { + [self safelyRemoveOperationFromRunning:operation]; + return; + } + // Continue download process + [self callDownloadProcessForOperation:operation url:url options:options context:context cachedImage:cachedImage cachedData:cachedData cacheType:cacheType progress:progressBlock completed:completedBlock]; + }]; + } else { + // Continue download process + [self callDownloadProcessForOperation:operation url:url options:options context:context cachedImage:nil cachedData:nil cacheType:SDImageCacheTypeNone progress:progressBlock completed:completedBlock]; } } -- (void)cancelAll { - @synchronized (self.runningOperations) { - NSArray *copiedOperations = [self.runningOperations copy]; - [copiedOperations makeObjectsPerformSelector:@selector(cancel)]; - [self.runningOperations removeObjectsInArray:copiedOperations]; +// Download process +- (void)callDownloadProcessForOperation:(nonnull SDWebImageCombinedOperation *)operation + url:(nonnull NSURL *)url + options:(SDWebImageOptions)options + context:(SDWebImageContext *)context + cachedImage:(nullable UIImage *)cachedImage + cachedData:(nullable NSData *)cachedData + cacheType:(SDImageCacheType)cacheType + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDInternalCompletionBlock)completedBlock { + // Check whether we should download image from network + BOOL shouldDownload = (options & SDWebImageFromCacheOnly) == 0; + shouldDownload &= (!cachedImage || options & SDWebImageRefreshCached); + shouldDownload &= (![self.delegate respondsToSelector:@selector(imageManager:shouldDownloadImageForURL:)] || [self.delegate imageManager:self shouldDownloadImageForURL:url]); + shouldDownload &= [self.imageLoader canRequestImageForURL:url]; + if (shouldDownload) { + if (cachedImage && options & SDWebImageRefreshCached) { + // If image was found in the cache but SDWebImageRefreshCached is provided, notify about the cached image + // AND try to re-download it in order to let a chance to NSURLCache to refresh it from server. + [self callCompletionBlockForOperation:operation completion:completedBlock image:cachedImage data:cachedData error:nil cacheType:cacheType finished:YES url:url]; + // Pass the cached image to the image loader. The image loader should check whether the remote image is equal to the cached image. + SDWebImageMutableContext *mutableContext; + if (context) { + mutableContext = [context mutableCopy]; + } else { + mutableContext = [NSMutableDictionary dictionary]; + } + mutableContext[SDWebImageContextLoaderCachedImage] = cachedImage; + context = [mutableContext copy]; + } + + // `SDWebImageCombinedOperation` -> `SDWebImageDownloadToken` -> `downloadOperationCancelToken`, which is a `SDCallbacksDictionary` and retain the completed block below, so we need weak-strong again to avoid retain cycle + @weakify(operation); + operation.loaderOperation = [self.imageLoader requestImageWithURL:url options:options context:context progress:progressBlock completed:^(UIImage *downloadedImage, NSData *downloadedData, NSError *error, BOOL finished) { + @strongify(operation); + if (!operation || operation.isCancelled) { + // Do nothing if the operation was cancelled + // See #699 for more details + // if we would call the completedBlock, there could be a race condition between this block and another completedBlock for the same object, so if this one is called second, we will overwrite the new data + } else if (cachedImage && options & SDWebImageRefreshCached && [error.domain isEqualToString:SDWebImageErrorDomain] && error.code == SDWebImageErrorCacheNotModified) { + // Image refresh hit the NSURLCache cache, do not call the completion block + } else if (error) { + [self callCompletionBlockForOperation:operation completion:completedBlock error:error url:url]; + BOOL shouldBlockFailedURL = [self shouldBlockFailedURLWithURL:url error:error]; + + if (shouldBlockFailedURL) { + SD_LOCK(self.failedURLsLock); + [self.failedURLs addObject:url]; + SD_UNLOCK(self.failedURLsLock); + } + } else { + if ((options & SDWebImageRetryFailed)) { + SD_LOCK(self.failedURLsLock); + [self.failedURLs removeObject:url]; + SD_UNLOCK(self.failedURLsLock); + } + + [self callStoreCacheProcessForOperation:operation url:url options:options context:context downloadedImage:downloadedImage downloadedData:downloadedData finished:finished progress:progressBlock completed:completedBlock]; + } + + if (finished) { + [self safelyRemoveOperationFromRunning:operation]; + } + }]; + } else if (cachedImage) { + [self callCompletionBlockForOperation:operation completion:completedBlock image:cachedImage data:cachedData error:nil cacheType:cacheType finished:YES url:url]; + [self safelyRemoveOperationFromRunning:operation]; + } else { + // Image not in cache and download disallowed by delegate + [self callCompletionBlockForOperation:operation completion:completedBlock image:nil data:nil error:nil cacheType:SDImageCacheTypeNone finished:YES url:url]; + [self safelyRemoveOperationFromRunning:operation]; } } -- (BOOL)isRunning { - BOOL isRunning = NO; - @synchronized (self.runningOperations) { - isRunning = (self.runningOperations.count > 0); +// Store cache process +- (void)callStoreCacheProcessForOperation:(nonnull SDWebImageCombinedOperation *)operation + url:(nonnull NSURL *)url + options:(SDWebImageOptions)options + context:(SDWebImageContext *)context + downloadedImage:(nullable UIImage *)downloadedImage + downloadedData:(nullable NSData *)downloadedData + finished:(BOOL)finished + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDInternalCompletionBlock)completedBlock { + SDImageCacheType storeCacheType = SDImageCacheTypeAll; + if (context[SDWebImageContextStoreCacheType]) { + storeCacheType = [context[SDWebImageContextStoreCacheType] integerValue]; + } + id cacheKeyFilter = context[SDWebImageContextCacheKeyFilter]; + NSString *key = [self cacheKeyForURL:url cacheKeyFilter:cacheKeyFilter]; + id transformer = context[SDWebImageContextImageTransformer]; + id cacheSerializer = context[SDWebImageContextCacheSerializer]; + if (downloadedImage && (!downloadedImage.sd_isAnimated || (options & SDWebImageTransformAnimatedImage)) && transformer) { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + @autoreleasepool { + UIImage *transformedImage = [transformer transformedImageWithImage:downloadedImage forKey:key]; + if (transformedImage && finished) { + NSString *transformerKey = [transformer transformerKey]; + NSString *cacheKey = SDTransformedKeyForKey(key, transformerKey); + BOOL imageWasTransformed = ![transformedImage isEqual:downloadedImage]; + NSData *cacheData; + // pass nil if the image was transformed, so we can recalculate the data from the image + if (cacheSerializer && (storeCacheType == SDImageCacheTypeDisk || storeCacheType == SDImageCacheTypeAll)) { + cacheData = [cacheSerializer cacheDataWithImage:transformedImage originalData:(imageWasTransformed ? nil : downloadedData) imageURL:url]; + } else { + cacheData = (imageWasTransformed ? nil : downloadedData); + } + [self.imageCache storeImage:transformedImage imageData:cacheData forKey:cacheKey cacheType:storeCacheType completion:nil]; + } + + [self callCompletionBlockForOperation:operation completion:completedBlock image:transformedImage data:downloadedData error:nil cacheType:SDImageCacheTypeNone finished:finished url:url]; + } + }); + } else { + if (downloadedImage && finished) { + if (cacheSerializer && (storeCacheType == SDImageCacheTypeDisk || storeCacheType == SDImageCacheTypeAll)) { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + @autoreleasepool { + NSData *cacheData = [cacheSerializer cacheDataWithImage:downloadedImage originalData:downloadedData imageURL:url]; + [self.imageCache storeImage:downloadedImage imageData:cacheData forKey:key cacheType:storeCacheType completion:nil]; + } + }); + } else { + [self.imageCache storeImage:downloadedImage imageData:downloadedData forKey:key cacheType:storeCacheType completion:nil]; + } + } + [self callCompletionBlockForOperation:operation completion:completedBlock image:downloadedImage data:downloadedData error:nil cacheType:SDImageCacheTypeNone finished:finished url:url]; } - return isRunning; } +#pragma mark - Helper + - (void)safelyRemoveOperationFromRunning:(nullable SDWebImageCombinedOperation*)operation { - @synchronized (self.runningOperations) { - if (operation) { - [self.runningOperations removeObject:operation]; - } + if (!operation) { + return; } + SD_LOCK(self.runningOperationsLock); + [self.runningOperations removeObject:operation]; + SD_UNLOCK(self.runningOperationsLock); } - (void)callCompletionBlockForOperation:(nullable SDWebImageCombinedOperation*)operation @@ -300,36 +367,66 @@ - (void)callCompletionBlockForOperation:(nullable SDWebImageCombinedOperation*)o }); } -@end - - -@implementation SDWebImageCombinedOperation +- (BOOL)shouldBlockFailedURLWithURL:(nonnull NSURL *)url + error:(nonnull NSError *)error { + // Check whether we should block failed url + BOOL shouldBlockFailedURL; + if ([self.delegate respondsToSelector:@selector(imageManager:shouldBlockFailedURL:withError:)]) { + shouldBlockFailedURL = [self.delegate imageManager:self shouldBlockFailedURL:url withError:error]; + } else { + shouldBlockFailedURL = [self.imageLoader shouldBlockFailedURLWithURL:url error:error]; + } + + return shouldBlockFailedURL; +} -- (void)setCancelBlock:(nullable SDWebImageNoParamsBlock)cancelBlock { - // check if the operation is already cancelled, then we just call the cancelBlock - if (self.isCancelled) { - if (cancelBlock) { - cancelBlock(); - } - _cancelBlock = nil; // don't forget to nil the cancelBlock, otherwise we will get crashes +- (SDWebImageContext *)processedContextWithContext:(SDWebImageContext *)context { + SDWebImageMutableContext *mutableContext = [SDWebImageMutableContext dictionary]; + + // Image Transformer from manager + if (!context[SDWebImageContextImageTransformer]) { + id transformer = self.transformer; + [mutableContext setValue:transformer forKey:SDWebImageContextImageTransformer]; + } + // Cache key filter from manager + if (!context[SDWebImageContextCacheKeyFilter]) { + id cacheKeyFilter = self.cacheKeyFilter; + [mutableContext setValue:cacheKeyFilter forKey:SDWebImageContextCacheKeyFilter]; + } + // Cache serializer from manager + if (!context[SDWebImageContextCacheSerializer]) { + id cacheSerializer = self.cacheSerializer; + [mutableContext setValue:cacheSerializer forKey:SDWebImageContextCacheSerializer]; + } + + if (mutableContext.count == 0) { + return context; } else { - _cancelBlock = [cancelBlock copy]; + [mutableContext addEntriesFromDictionary:context]; + return [mutableContext copy]; } } +@end + + +@implementation SDWebImageCombinedOperation + - (void)cancel { - self.cancelled = YES; - if (self.cacheOperation) { - [self.cacheOperation cancel]; - self.cacheOperation = nil; - } - if (self.cancelBlock) { - self.cancelBlock(); - - // TODO: this is a temporary fix to #809. - // Until we can figure the exact cause of the crash, going with the ivar instead of the setter -// self.cancelBlock = nil; - _cancelBlock = nil; + @synchronized(self) { + if (self.isCancelled) { + return; + } + self.cancelled = YES; + if (self.cacheOperation) { + [self.cacheOperation cancel]; + self.cacheOperation = nil; + } + if (self.loaderOperation) { + [self.loaderOperation cancel]; + self.loaderOperation = nil; + } + [self.manager safelyRemoveOperationFromRunning:self]; } } diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h b/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h index 71094ee3..e92c13e0 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h +++ b/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h @@ -13,3 +13,8 @@ - (void)cancel; @end + +// NSOperation conform to `SDWebImageOperation` +@interface NSOperation (SDWebImageOperation) + +@end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h b/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h index d0a91ed7..44c11d5a 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h +++ b/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h @@ -11,12 +11,26 @@ @class SDWebImagePrefetcher; +@interface SDWebImagePrefetchToken : NSObject + +/** + * Cancel the current prefetching. + */ +- (void)cancel; + +/** + list of URLs of current prefetching. + */ +@property (nonatomic, copy, readonly, nullable) NSArray *urls; + +@end + @protocol SDWebImagePrefetcherDelegate @optional /** - * Called when an image was prefetched. + * Called when an image was prefetched. Which means it's called when one URL from any of prefetching finished. * * @param imagePrefetcher The current image prefetcher * @param imageURL The image url that was prefetched @@ -26,7 +40,7 @@ - (void)imagePrefetcher:(nonnull SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(nullable NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; /** - * Called when all images are prefetched. + * Called when all images are prefetched. Which means it's called when all URLs from all of prefetching finished. * @param imagePrefetcher The current image prefetcher * @param totalCount The total number of images that were prefetched (whether successful or not) * @param skippedCount The total number of images that were skipped @@ -44,31 +58,42 @@ typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, @interface SDWebImagePrefetcher : NSObject /** - * The web image manager + * The web image manager used by prefetcher to prefetch images. + * @note You can specify a standalone manager and downloader with custom configuration suitable for image prefetching. Such as `currentDownloadCount` or `downloadTimeout`. */ @property (strong, nonatomic, readonly, nonnull) SDWebImageManager *manager; /** * Maximum number of URLs to prefetch at the same time. Defaults to 3. */ -@property (nonatomic, assign) NSUInteger maxConcurrentDownloads; +@property (nonatomic, assign) NSUInteger maxConcurrentPrefetchCount; /** - * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority. + * The options for prefetcher. Defaults to SDWebImageLowPriority. */ @property (nonatomic, assign) SDWebImageOptions options; /** - * Queue options for Prefetcher. Defaults to Main Queue. + * The context for prefetcher. Defaults to nil. */ -@property (nonatomic, assign, nonnull) dispatch_queue_t prefetcherQueue; +@property (nonatomic, copy, nullable) SDWebImageContext *context; +/** + * Queue options for prefetcher when call the progressBlock, completionBlock and delegate methods. Defaults to Main Queue. + * @note The call is asynchronously to avoid blocking target queue. + * @note The delegate queue should be set before any prefetching start and may not be changed during prefetching to avoid thread-safe problem. + */ +@property (strong, nonatomic, nonnull) dispatch_queue_t delegateQueue; + +/** + * The delegate for the prefetcher. Defatuls to nil. + */ @property (weak, nonatomic, nullable) id delegate; /** - * Return the global image prefetcher instance. + * Returns the global shared image prefetcher instance. It use a standalone manager which is different from shared manager. */ -+ (nonnull instancetype)sharedImagePrefetcher; +@property (nonatomic, class, readonly, nonnull) SDWebImagePrefetcher *sharedImagePrefetcher; /** * Allows you to instantiate a prefetcher with any arbitrary image manager. @@ -76,35 +101,35 @@ typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, - (nonnull instancetype)initWithImageManager:(nonnull SDWebImageManager *)manager NS_DESIGNATED_INITIALIZER; /** - * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, - * currently one image is downloaded at a time, - * and skips images for failed downloads and proceed to the next image in the list. - * Any previously-running prefetch operations are canceled. + * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching. It based on the image manager so the image may from the cache and network according to the `options` property. + * Prefetching is seperate to each other, which means the progressBlock and completionBlock you provide is bind to the prefetching for the list of urls. + * Attention that call this will not cancel previous fetched urls. You should keep the token return by this to cancel or cancel all the prefetch. * * @param urls list of URLs to prefetch + * @return the token to cancel the current prefetching. */ -- (void)prefetchURLs:(nullable NSArray *)urls; +- (nullable SDWebImagePrefetchToken *)prefetchURLs:(nullable NSArray *)urls; /** - * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, - * currently one image is downloaded at a time, - * and skips images for failed downloads and proceed to the next image in the list. - * Any previously-running prefetch operations are canceled. + * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching. It based on the image manager so the image may from the cache and network according to the `options` property. + * Prefetching is seperate to each other, which means the progressBlock and completionBlock you provide is bind to the prefetching for the list of urls. + * Attention that call this will not cancel previous fetched urls. You should keep the token return by this to cancel or cancel all the prefetch. * * @param urls list of URLs to prefetch * @param progressBlock block to be called when progress updates; * first parameter is the number of completed (successful or not) requests, * second parameter is the total number of images originally requested to be prefetched - * @param completionBlock block to be called when prefetching is completed + * @param completionBlock block to be called when the current prefetching is completed * first param is the number of completed (successful or not) requests, * second parameter is the number of skipped requests + * @return the token to cancel the current prefetching. */ -- (void)prefetchURLs:(nullable NSArray *)urls - progress:(nullable SDWebImagePrefetcherProgressBlock)progressBlock - completed:(nullable SDWebImagePrefetcherCompletionBlock)completionBlock; +- (nullable SDWebImagePrefetchToken *)prefetchURLs:(nullable NSArray *)urls + progress:(nullable SDWebImagePrefetcherProgressBlock)progressBlock + completed:(nullable SDWebImagePrefetcherCompletionBlock)completionBlock; /** - * Remove and cancel queued list + * Remove and cancel all the prefeching for the prefetcher. */ - (void)cancelPrefetching; diff --git a/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m b/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m index b66357f1..e141e24e 100644 --- a/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m +++ b/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m @@ -7,17 +7,34 @@ */ #import "SDWebImagePrefetcher.h" +#import "SDAsyncBlockOperation.h" +#import + +@interface SDWebImagePrefetchToken () { + @public + // Though current implementation, `SDWebImageManager` completion block is always on main queue. But however, there is no guarantee in docs. And we may introduce config to specify custom queue in the future. + // These value are just used as incrementing counter, keep thread-safe using memory_order_relaxed for performance. + atomic_ulong _skippedCount; + atomic_ulong _finishedCount; + atomic_flag _isAllFinished; + + unsigned long _totalCount; +} + +@property (nonatomic, copy, readwrite) NSArray *urls; +@property (nonatomic, strong) NSPointerArray *loadOperations; +@property (nonatomic, strong) NSPointerArray *prefetchOperations; +@property (nonatomic, weak) SDWebImagePrefetcher *prefetcher; +@property (nonatomic, copy, nullable) SDWebImagePrefetcherCompletionBlock completionBlock; +@property (nonatomic, copy, nullable) SDWebImagePrefetcherProgressBlock progressBlock; + +@end @interface SDWebImagePrefetcher () @property (strong, nonatomic, nonnull) SDWebImageManager *manager; -@property (strong, nonatomic, nullable) NSArray *prefetchURLs; -@property (assign, nonatomic) NSUInteger requestedCount; -@property (assign, nonatomic) NSUInteger skippedCount; -@property (assign, nonatomic) NSUInteger finishedCount; -@property (assign, nonatomic) NSTimeInterval startedTime; -@property (copy, nonatomic, nullable) SDWebImagePrefetcherCompletionBlock completionBlock; -@property (copy, nonatomic, nullable) SDWebImagePrefetcherProgressBlock progressBlock; +@property (strong, atomic, nonnull) NSMutableSet *runningTokens; +@property (strong, nonatomic, nonnull) NSOperationQueue *prefetchQueue; @end @@ -39,104 +56,230 @@ - (nonnull instancetype)init { - (nonnull instancetype)initWithImageManager:(SDWebImageManager *)manager { if ((self = [super init])) { _manager = manager; + _runningTokens = [NSMutableSet set]; _options = SDWebImageLowPriority; - _prefetcherQueue = dispatch_get_main_queue(); - self.maxConcurrentDownloads = 3; + _delegateQueue = dispatch_get_main_queue(); + _prefetchQueue = [NSOperationQueue new]; + self.maxConcurrentPrefetchCount = 3; } return self; } -- (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads { - self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads; +- (void)setMaxConcurrentPrefetchCount:(NSUInteger)maxConcurrentPrefetchCount { + self.prefetchQueue.maxConcurrentOperationCount = maxConcurrentPrefetchCount; } -- (NSUInteger)maxConcurrentDownloads { - return self.manager.imageDownloader.maxConcurrentDownloads; +- (NSUInteger)maxConcurrentPrefetchCount { + return self.prefetchQueue.maxConcurrentOperationCount; } -- (void)startPrefetchingAtIndex:(NSUInteger)index { - if (index >= self.prefetchURLs.count) return; - self.requestedCount++; - [self.manager loadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (!finished) return; - self.finishedCount++; +#pragma mark - Prefetch +- (nullable SDWebImagePrefetchToken *)prefetchURLs:(nullable NSArray *)urls { + return [self prefetchURLs:urls progress:nil completed:nil]; +} - if (image) { - if (self.progressBlock) { - self.progressBlock(self.finishedCount,(self.prefetchURLs).count); - } +- (nullable SDWebImagePrefetchToken *)prefetchURLs:(nullable NSArray *)urls + progress:(nullable SDWebImagePrefetcherProgressBlock)progressBlock + completed:(nullable SDWebImagePrefetcherCompletionBlock)completionBlock { + if (!urls || urls.count == 0) { + if (completionBlock) { + completionBlock(0, 0); } - else { - if (self.progressBlock) { - self.progressBlock(self.finishedCount,(self.prefetchURLs).count); + return nil; + } + SDWebImagePrefetchToken *token = [SDWebImagePrefetchToken new]; + token.prefetcher = self; + token.urls = urls; + token->_skippedCount = 0; + token->_finishedCount = 0; + token->_totalCount = token.urls.count; + atomic_flag_clear(&(token->_isAllFinished)); + token.loadOperations = [NSPointerArray weakObjectsPointerArray]; + token.prefetchOperations = [NSPointerArray weakObjectsPointerArray]; + token.progressBlock = progressBlock; + token.completionBlock = completionBlock; + [self addRunningToken:token]; + [self startPrefetchWithToken:token]; + + return token; +} + +- (void)startPrefetchWithToken:(SDWebImagePrefetchToken * _Nonnull)token { + NSPointerArray *operations = token.loadOperations; + for (NSURL *url in token.urls) { + @weakify(self); + SDAsyncBlockOperation *prefetchOperation = [SDAsyncBlockOperation blockOperationWithBlock:^(SDAsyncBlockOperation * _Nonnull asyncOperation) { + @strongify(self); + if (!self || asyncOperation.isCancelled) { + return; } - // Add last failed - self.skippedCount++; - } - if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) { - [self.delegate imagePrefetcher:self - didPrefetchURL:self.prefetchURLs[index] - finishedCount:self.finishedCount - totalCount:self.prefetchURLs.count - ]; - } - if (self.prefetchURLs.count > self.requestedCount) { - dispatch_async(self.prefetcherQueue, ^{ - [self startPrefetchingAtIndex:self.requestedCount]; - }); - } else if (self.finishedCount == self.requestedCount) { - [self reportStatus]; - if (self.completionBlock) { - self.completionBlock(self.finishedCount, self.skippedCount); - self.completionBlock = nil; + id operation = [self.manager loadImageWithURL:url options:self.options context:self.context progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + @strongify(self); + if (!self) { + return; + } + if (!finished) { + return; + } + atomic_fetch_add_explicit(&(token->_finishedCount), 1, memory_order_relaxed); + if (error) { + // Add last failed + atomic_fetch_add_explicit(&(token->_skippedCount), 1, memory_order_relaxed); + } + + // Current operation finished + [self callProgressBlockForToken:token imageURL:imageURL]; + + if (atomic_load_explicit(&(token->_finishedCount), memory_order_relaxed) == token->_totalCount) { + // All finished + if (!atomic_flag_test_and_set_explicit(&(token->_isAllFinished), memory_order_relaxed)) { + [self callCompletionBlockForToken:token]; + [self removeRunningToken:token]; + } + } + [asyncOperation complete]; + }]; + NSAssert(operation != nil, @"Operation should not be nil, [SDWebImageManager loadImageWithURL:options:context:progress:completed:] break prefetch logic"); + @synchronized (token) { + [operations addPointer:(__bridge void *)operation]; } - self.progressBlock = nil; + }]; + @synchronized (token) { + [token.prefetchOperations addPointer:(__bridge void *)prefetchOperation]; } - }]; + [self.prefetchQueue addOperation:prefetchOperation]; + } } -- (void)reportStatus { - NSUInteger total = (self.prefetchURLs).count; - if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) { - [self.delegate imagePrefetcher:self - didFinishWithTotalCount:(total - self.skippedCount) - skippedCount:self.skippedCount - ]; +#pragma mark - Cancel +- (void)cancelPrefetching { + @synchronized(self.runningTokens) { + NSSet *copiedTokens = [self.runningTokens copy]; + [copiedTokens makeObjectsPerformSelector:@selector(cancel)]; + [self.runningTokens removeAllObjects]; } } -- (void)prefetchURLs:(nullable NSArray *)urls { - [self prefetchURLs:urls progress:nil completed:nil]; +- (void)callProgressBlockForToken:(SDWebImagePrefetchToken *)token imageURL:(NSURL *)url { + if (!token) { + return; + } + BOOL shouldCallDelegate = [self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]; + NSUInteger tokenFinishedCount = [self tokenFinishedCount]; + NSUInteger tokenTotalCount = [self tokenTotalCount]; + NSUInteger finishedCount = atomic_load_explicit(&(token->_finishedCount), memory_order_relaxed); + NSUInteger totalCount = token->_totalCount; + dispatch_async(self.delegateQueue, ^{ + if (shouldCallDelegate) { + [self.delegate imagePrefetcher:self didPrefetchURL:url finishedCount:tokenFinishedCount totalCount:tokenTotalCount]; + } + if (token.progressBlock) { + token.progressBlock(finishedCount, totalCount); + } + }); } -- (void)prefetchURLs:(nullable NSArray *)urls - progress:(nullable SDWebImagePrefetcherProgressBlock)progressBlock - completed:(nullable SDWebImagePrefetcherCompletionBlock)completionBlock { - [self cancelPrefetching]; // Prevent duplicate prefetch request - self.startedTime = CFAbsoluteTimeGetCurrent(); - self.prefetchURLs = urls; - self.completionBlock = completionBlock; - self.progressBlock = progressBlock; +- (void)callCompletionBlockForToken:(SDWebImagePrefetchToken *)token { + if (!token) { + return; + } + BOOL shoulCallDelegate = [self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)] && ([self countOfRunningTokens] == 1); // last one + NSUInteger tokenTotalCount = [self tokenTotalCount]; + NSUInteger tokenSkippedCount = [self tokenSkippedCount]; + NSUInteger finishedCount = atomic_load_explicit(&(token->_finishedCount), memory_order_relaxed); + NSUInteger skippedCount = atomic_load_explicit(&(token->_skippedCount), memory_order_relaxed); + dispatch_async(self.delegateQueue, ^{ + if (shoulCallDelegate) { + [self.delegate imagePrefetcher:self didFinishWithTotalCount:tokenTotalCount skippedCount:tokenSkippedCount]; + } + if (token.completionBlock) { + token.completionBlock(finishedCount, skippedCount); + } + }); +} - if (urls.count == 0) { - if (completionBlock) { - completionBlock(0,0); +#pragma mark - Helper +- (NSUInteger)tokenTotalCount { + NSUInteger tokenTotalCount = 0; + @synchronized (self.runningTokens) { + for (SDWebImagePrefetchToken *token in self.runningTokens) { + tokenTotalCount += token->_totalCount; + } + } + return tokenTotalCount; +} + +- (NSUInteger)tokenSkippedCount { + NSUInteger tokenSkippedCount = 0; + @synchronized (self.runningTokens) { + for (SDWebImagePrefetchToken *token in self.runningTokens) { + tokenSkippedCount += atomic_load_explicit(&(token->_skippedCount), memory_order_relaxed); } - } else { - // Starts prefetching from the very first image on the list with the max allowed concurrency - NSUInteger listCount = self.prefetchURLs.count; - for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { - [self startPrefetchingAtIndex:i]; + } + return tokenSkippedCount; +} + +- (NSUInteger)tokenFinishedCount { + NSUInteger tokenFinishedCount = 0; + @synchronized (self.runningTokens) { + for (SDWebImagePrefetchToken *token in self.runningTokens) { + tokenFinishedCount += atomic_load_explicit(&(token->_finishedCount), memory_order_relaxed); } } + return tokenFinishedCount; } -- (void)cancelPrefetching { - self.prefetchURLs = nil; - self.skippedCount = 0; - self.requestedCount = 0; - self.finishedCount = 0; - [self.manager cancelAll]; +- (void)addRunningToken:(SDWebImagePrefetchToken *)token { + if (!token) { + return; + } + @synchronized (self.runningTokens) { + [self.runningTokens addObject:token]; + } +} + +- (void)removeRunningToken:(SDWebImagePrefetchToken *)token { + if (!token) { + return; + } + @synchronized (self.runningTokens) { + [self.runningTokens removeObject:token]; + } +} + +- (NSUInteger)countOfRunningTokens { + NSUInteger count = 0; + @synchronized (self.runningTokens) { + count = self.runningTokens.count; + } + return count; +} + +@end + +@implementation SDWebImagePrefetchToken + +- (void)cancel { + @synchronized (self) { + [self.prefetchOperations compact]; + for (id operation in self.prefetchOperations) { + if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]) { + [operation cancel]; + } + } + self.prefetchOperations.count = 0; + + [self.loadOperations compact]; + for (id operation in self.loadOperations) { + if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]) { + [operation cancel]; + } + } + self.loadOperations.count = 0; + } + self.completionBlock = nil; + self.progressBlock = nil; + [self.prefetcher removeRunningToken:self]; } @end diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageTransition.h b/Pods/SDWebImage/SDWebImage/SDWebImageTransition.h new file mode 100644 index 00000000..e841a962 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageTransition.h @@ -0,0 +1,87 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +#if SD_UIKIT || SD_MAC +#import "SDImageCache.h" + +// This class is used to provide a transition animation after the view category load image finished. Use this on `sd_imageTransition` in UIView+WebCache.h +// for UIKit(iOS & tvOS), we use `+[UIView transitionWithView:duration:options:animations:completion]` for transition animation. +// for AppKit(macOS), we use `+[NSAnimationContext runAnimationGroup:completionHandler:]` for transition animation. You can call `+[NSAnimationContext currentContext]` to grab the context during animations block. +// These transition are provided for basic usage. If you need complicated animation, consider to directly use Core Animation or use `SDWebImageAvoidAutoSetImage` and implement your own after image load finished. + +#if SD_UIKIT +typedef UIViewAnimationOptions SDWebImageAnimationOptions; +#else +typedef NS_OPTIONS(NSUInteger, SDWebImageAnimationOptions) { + SDWebImageAnimationOptionAllowsImplicitAnimation = 1 << 0, // specify `allowsImplicitAnimation` for the `NSAnimationContext` +}; +#endif + +typedef void (^SDWebImageTransitionPreparesBlock)(__kindof UIView * _Nonnull view, UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL); +typedef void (^SDWebImageTransitionAnimationsBlock)(__kindof UIView * _Nonnull view, UIImage * _Nullable image); +typedef void (^SDWebImageTransitionCompletionBlock)(BOOL finished); + +@interface SDWebImageTransition : NSObject + +/** + By default, we set the image to the view at the beginning of the animtions. You can disable this and provide custom set image process + */ +@property (nonatomic, assign) BOOL avoidAutoSetImage; +/** + The duration of the transition animation, measured in seconds. Defaults to 0.5. + */ +@property (nonatomic, assign) NSTimeInterval duration; +/** + The timing function used for all animations within this transition animation (macOS). + */ +@property (nonatomic, strong, nullable) CAMediaTimingFunction *timingFunction API_UNAVAILABLE(ios, tvos, watchos); +/** + A mask of options indicating how you want to perform the animations. + */ +@property (nonatomic, assign) SDWebImageAnimationOptions animationOptions; +/** + A block object to be executed before the animation sequence starts. + */ +@property (nonatomic, copy, nullable) SDWebImageTransitionPreparesBlock prepares; +/** + A block object that contains the changes you want to make to the specified view. + */ +@property (nonatomic, copy, nullable) SDWebImageTransitionAnimationsBlock animations; +/** + A block object to be executed when the animation sequence ends. + */ +@property (nonatomic, copy, nullable) SDWebImageTransitionCompletionBlock completion; + +@end + +// Convenience way to create transition. Remember to specify the duration if needed. +// for UIKit, these transition just use the correspond `animationOptions`. By default we enable `UIViewAnimationOptionAllowUserInteraction` to allow user interaction during transition. +// for AppKit, these transition use Core Animation in `animations`. So your view must be layer-backed. Set `wantsLayer = YES` before you apply it. + +@interface SDWebImageTransition (Conveniences) + +/// Fade transition. +@property (nonatomic, class, nonnull, readonly) SDWebImageTransition *fadeTransition; +/// Flip from left transition. +@property (nonatomic, class, nonnull, readonly) SDWebImageTransition *flipFromLeftTransition; +/// Flip from right transition. +@property (nonatomic, class, nonnull, readonly) SDWebImageTransition *flipFromRightTransition; +/// Flip from top transition. +@property (nonatomic, class, nonnull, readonly) SDWebImageTransition *flipFromTopTransition; +/// Flip from bottom transition. +@property (nonatomic, class, nonnull, readonly) SDWebImageTransition *flipFromBottomTransition; +/// Curl up transition. +@property (nonatomic, class, nonnull, readonly) SDWebImageTransition *curlUpTransition; +/// Curl down transition. +@property (nonatomic, class, nonnull, readonly) SDWebImageTransition *curlDownTransition; + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/SDWebImageTransition.m b/Pods/SDWebImage/SDWebImage/SDWebImageTransition.m new file mode 100644 index 00000000..b04a4c34 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/SDWebImageTransition.m @@ -0,0 +1,137 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageTransition.h" + +#if SD_UIKIT || SD_MAC + +#if SD_MAC +#import +#endif + +@implementation SDWebImageTransition + +- (instancetype)init { + self = [super init]; + if (self) { + self.duration = 0.5; + } + return self; +} + +@end + +@implementation SDWebImageTransition (Conveniences) + ++ (SDWebImageTransition *)fadeTransition { + SDWebImageTransition *transition = [SDWebImageTransition new]; +#if SD_UIKIT + transition.animationOptions = UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction; +#else + transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { + CATransition *trans = [CATransition animation]; + trans.type = kCATransitionFade; + [view.layer addAnimation:trans forKey:kCATransition]; + }; +#endif + return transition; +} + ++ (SDWebImageTransition *)flipFromLeftTransition { + SDWebImageTransition *transition = [SDWebImageTransition new]; +#if SD_UIKIT + transition.animationOptions = UIViewAnimationOptionTransitionFlipFromLeft | UIViewAnimationOptionAllowUserInteraction; +#else + transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { + CATransition *trans = [CATransition animation]; + trans.type = kCATransitionPush; + trans.subtype = kCATransitionFromLeft; + [view.layer addAnimation:trans forKey:kCATransition]; + }; +#endif + return transition; +} + ++ (SDWebImageTransition *)flipFromRightTransition { + SDWebImageTransition *transition = [SDWebImageTransition new]; +#if SD_UIKIT + transition.animationOptions = UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationOptionAllowUserInteraction; +#else + transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { + CATransition *trans = [CATransition animation]; + trans.type = kCATransitionPush; + trans.subtype = kCATransitionFromRight; + [view.layer addAnimation:trans forKey:kCATransition]; + }; +#endif + return transition; +} + ++ (SDWebImageTransition *)flipFromTopTransition { + SDWebImageTransition *transition = [SDWebImageTransition new]; +#if SD_UIKIT + transition.animationOptions = UIViewAnimationOptionTransitionFlipFromTop | UIViewAnimationOptionAllowUserInteraction; +#else + transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { + CATransition *trans = [CATransition animation]; + trans.type = kCATransitionPush; + trans.subtype = kCATransitionFromTop; + [view.layer addAnimation:trans forKey:kCATransition]; + }; +#endif + return transition; +} + ++ (SDWebImageTransition *)flipFromBottomTransition { + SDWebImageTransition *transition = [SDWebImageTransition new]; +#if SD_UIKIT + transition.animationOptions = UIViewAnimationOptionTransitionFlipFromBottom | UIViewAnimationOptionAllowUserInteraction; +#else + transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { + CATransition *trans = [CATransition animation]; + trans.type = kCATransitionPush; + trans.subtype = kCATransitionFromBottom; + [view.layer addAnimation:trans forKey:kCATransition]; + }; +#endif + return transition; +} + ++ (SDWebImageTransition *)curlUpTransition { + SDWebImageTransition *transition = [SDWebImageTransition new]; +#if SD_UIKIT + transition.animationOptions = UIViewAnimationOptionTransitionCurlUp | UIViewAnimationOptionAllowUserInteraction; +#else + transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { + CATransition *trans = [CATransition animation]; + trans.type = kCATransitionReveal; + trans.subtype = kCATransitionFromTop; + [view.layer addAnimation:trans forKey:kCATransition]; + }; +#endif + return transition; +} + ++ (SDWebImageTransition *)curlDownTransition { + SDWebImageTransition *transition = [SDWebImageTransition new]; +#if SD_UIKIT + transition.animationOptions = UIViewAnimationOptionTransitionCurlDown | UIViewAnimationOptionAllowUserInteraction; +#else + transition.animations = ^(__kindof NSView * _Nonnull view, NSImage * _Nullable image) { + CATransition *trans = [CATransition animation]; + trans.type = kCATransitionReveal; + trans.subtype = kCATransitionFromBottom; + [view.layer addAnimation:trans forKey:kCATransition]; + }; +#endif + return transition; +} + +@end + +#endif diff --git a/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h b/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h index c43b7491..8cb99de3 100644 --- a/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h +++ b/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h @@ -17,12 +17,12 @@ */ @interface UIButton (WebCache) +#pragma mark - Image + /** * Get the current image URL. */ -- (nullable NSURL *)sd_currentImageURL; - -#pragma mark - Image +@property (nonatomic, strong, readonly, nullable) NSURL *sd_currentImageURL; /** * Get the image URL for a control state. @@ -32,7 +32,7 @@ - (nullable NSURL *)sd_imageURLForState:(UIControlState)state; /** - * Set the imageView `image` with an `url`. + * Set the button `image` with an `url`. * * The download is asynchronous and cached. * @@ -40,10 +40,10 @@ * @param state The state that uses the specified title. The values are described in UIControlState. */ - (void)sd_setImageWithURL:(nullable NSURL *)url - forState:(UIControlState)state; + forState:(UIControlState)state NS_REFINED_FOR_SWIFT; /** - * Set the imageView `image` with an `url` and a placeholder. + * Set the button `image` with an `url` and a placeholder. * * The download is asynchronous and cached. * @@ -54,10 +54,10 @@ */ - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state - placeholderImage:(nullable UIImage *)placeholder; + placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT; /** - * Set the imageView `image` with an `url`, placeholder and custom options. + * Set the button `image` with an `url`, placeholder and custom options. * * The download is asynchronous and cached. * @@ -69,15 +69,70 @@ - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder - options:(SDWebImageOptions)options; + options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT; + +/** + * Set the button `image` with an `url`, placeholder, custom options and context. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + forState:(UIControlState)state + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context; + +/** + * Set the button `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + forState:(UIControlState)state + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the button `image` with an `url`, placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + forState:(UIControlState)state + placeholderImage:(nullable UIImage *)placeholder + completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT; /** - * Set the imageView `image` with an `url`. + * Set the button `image` with an `url`, placeholder and custom options. * * The download is asynchronous and cached. * * @param url The url for the image. * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. * @param completedBlock A block called when operation has been completed. This block has no return value * and takes the requested UIImage as first parameter. In case of error the image parameter * is nil and the second parameter may contain an NSError. The third parameter is a Boolean @@ -86,16 +141,21 @@ */ - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock; /** - * Set the imageView `image` with an `url`, placeholder. + * Set the button `image` with an `url`, placeholder and custom options. * * The download is asynchronous and cached. * * @param url The url for the image. * @param state The state that uses the specified title. The values are described in UIControlState. * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue * @param completedBlock A block called when operation has been completed. This block has no return value * and takes the requested UIImage as first parameter. In case of error the image parameter * is nil and the second parameter may contain an NSError. The third parameter is a Boolean @@ -105,10 +165,12 @@ - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock; /** - * Set the imageView `image` with an `url`, placeholder and custom options. + * Set the button `image` with an `url`, placeholder, custom options and context. * * The download is asynchronous and cached. * @@ -116,6 +178,9 @@ * @param state The state that uses the specified title. The values are described in UIControlState. * @param placeholder The image to be set initially, until the image request finishes. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + * @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue * @param completedBlock A block called when operation has been completed. This block has no return value * and takes the requested UIImage as first parameter. In case of error the image parameter * is nil and the second parameter may contain an NSError. The third parameter is a Boolean @@ -126,12 +191,26 @@ forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock; -#pragma mark - Background image +#pragma mark - Background Image + +/** + * Get the current background image URL. + */ +@property (nonatomic, strong, readonly, nullable) NSURL *sd_currentBackgroundImageURL; + +/** + * Get the background image URL for a control state. + * + * @param state Which state you want to know the URL for. The values are described in UIControlState. + */ +- (nullable NSURL *)sd_backgroundImageURLForState:(UIControlState)state; /** - * Set the backgroundImageView `image` with an `url`. + * Set the button `backgroundImage` with an `url`. * * The download is asynchronous and cached. * @@ -139,10 +218,10 @@ * @param state The state that uses the specified title. The values are described in UIControlState. */ - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url - forState:(UIControlState)state; + forState:(UIControlState)state NS_REFINED_FOR_SWIFT; /** - * Set the backgroundImageView `image` with an `url` and a placeholder. + * Set the button `backgroundImage` with an `url` and a placeholder. * * The download is asynchronous and cached. * @@ -153,10 +232,10 @@ */ - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state - placeholderImage:(nullable UIImage *)placeholder; + placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT; /** - * Set the backgroundImageView `image` with an `url`, placeholder and custom options. + * Set the button `backgroundImage` with an `url`, placeholder and custom options. * * The download is asynchronous and cached. * @@ -168,10 +247,27 @@ - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder - options:(SDWebImageOptions)options; + options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT; /** - * Set the backgroundImageView `image` with an `url`. + * Set the button `backgroundImage` with an `url`, placeholder, custom options and context. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + */ +- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url + forState:(UIControlState)state + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context; + +/** + * Set the button `backgroundImage` with an `url`. * * The download is asynchronous and cached. * @@ -188,7 +284,7 @@ completed:(nullable SDExternalCompletionBlock)completedBlock; /** - * Set the backgroundImageView `image` with an `url`, placeholder. + * Set the button `backgroundImage` with an `url`, placeholder. * * The download is asynchronous and cached. * @@ -204,16 +300,62 @@ - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder + completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT; + +/** + * Set the button `backgroundImage` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url + forState:(UIControlState)state + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the button `backgroundImage` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url + forState:(UIControlState)state + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock; /** - * Set the backgroundImageView `image` with an `url`, placeholder and custom options. + * Set the button `backgroundImage` with an `url`, placeholder, custom options and context. * * The download is asynchronous and cached. * * @param url The url for the image. * @param placeholder The image to be set initially, until the image request finishes. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + * @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue * @param completedBlock A block called when operation has been completed. This block has no return value * and takes the requested UIImage as first parameter. In case of error the image parameter * is nil and the second parameter may contain an NSError. The third parameter is a Boolean @@ -224,6 +366,8 @@ forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock; #pragma mark - Cancel diff --git a/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m b/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m index 63f75e40..e31ba9b5 100644 --- a/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m +++ b/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m @@ -16,26 +16,42 @@ static char imageURLStorageKey; -typedef NSMutableDictionary SDStateImageURLDictionary; +typedef NSMutableDictionary SDStateImageURLDictionary; + +static inline NSString * imageURLKeyForState(UIControlState state) { + return [NSString stringWithFormat:@"image_%lu", (unsigned long)state]; +} + +static inline NSString * backgroundImageURLKeyForState(UIControlState state) { + return [NSString stringWithFormat:@"backgroundImage_%lu", (unsigned long)state]; +} + +static inline NSString * imageOperationKeyForState(UIControlState state) { + return [NSString stringWithFormat:@"UIButtonImageOperation%lu", (unsigned long)state]; +} + +static inline NSString * backgroundImageOperationKeyForState(UIControlState state) { + return [NSString stringWithFormat:@"UIButtonBackgroundImageOperation%lu", (unsigned long)state]; +} @implementation UIButton (WebCache) +#pragma mark - Image + - (nullable NSURL *)sd_currentImageURL { - NSURL *url = self.imageURLStorage[@(self.state)]; + NSURL *url = self.sd_imageURLStorage[imageURLKeyForState(self.state)]; if (!url) { - url = self.imageURLStorage[@(UIControlStateNormal)]; + url = self.sd_imageURLStorage[imageURLKeyForState(UIControlStateNormal)]; } return url; } - (nullable NSURL *)sd_imageURLForState:(UIControlState)state { - return self.imageURLStorage[@(state)]; + return self.sd_imageURLStorage[imageURLKeyForState(state)]; } -#pragma mark - Image - - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state { [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; } @@ -45,7 +61,11 @@ - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state } - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options { - [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options context:context progress:nil completed:nil]; } - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state completed:(nullable SDExternalCompletionBlock)completedBlock { @@ -56,31 +76,66 @@ - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; } +- (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; +} + - (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { if (!url) { - [self.imageURLStorage removeObjectForKey:@(state)]; - return; + [self.sd_imageURLStorage removeObjectForKey:imageURLKeyForState(state)]; + } else { + self.sd_imageURLStorage[imageURLKeyForState(state)] = url; } - self.imageURLStorage[@(state)] = url; - - __weak typeof(self)weakSelf = self; + SDWebImageMutableContext *mutableContext; + if (context) { + mutableContext = [context mutableCopy]; + } else { + mutableContext = [NSMutableDictionary dictionary]; + } + mutableContext[SDWebImageContextSetImageOperationKey] = imageOperationKeyForState(state); + @weakify(self); [self sd_internalSetImageWithURL:url placeholderImage:placeholder options:options - operationKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)] - setImageBlock:^(UIImage *image, NSData *imageData) { - [weakSelf setImage:image forState:state]; + context:mutableContext + setImageBlock:^(UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { + @strongify(self); + [self setImage:image forState:state]; } - progress:nil - completed:completedBlock]; + progress:progressBlock + completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType, imageURL); + } + }]; } -#pragma mark - Background image +#pragma mark - Background Image + +- (nullable NSURL *)sd_currentBackgroundImageURL { + NSURL *url = self.sd_imageURLStorage[backgroundImageURLKeyForState(self.state)]; + + if (!url) { + url = self.sd_imageURLStorage[backgroundImageURLKeyForState(UIControlStateNormal)]; + } + + return url; +} + +- (nullable NSURL *)sd_backgroundImageURLForState:(UIControlState)state { + return self.sd_imageURLStorage[backgroundImageURLKeyForState(state)]; +} - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state { [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; @@ -91,7 +146,11 @@ - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlSt } - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options progress:nil completed:nil]; +} + +- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options context:context progress:nil completed:nil]; } - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state completed:(nullable SDExternalCompletionBlock)completedBlock { @@ -102,47 +161,64 @@ - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlSt [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; } +- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 context:nil progress:progressBlock completed:completedBlock]; +} + - (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { if (!url) { - [self.imageURLStorage removeObjectForKey:@(state)]; - return; + [self.sd_imageURLStorage removeObjectForKey:backgroundImageURLKeyForState(state)]; + } else { + self.sd_imageURLStorage[backgroundImageURLKeyForState(state)] = url; } - self.imageURLStorage[@(state)] = url; - - __weak typeof(self)weakSelf = self; + SDWebImageMutableContext *mutableContext; + if (context) { + mutableContext = [context mutableCopy]; + } else { + mutableContext = [NSMutableDictionary dictionary]; + } + mutableContext[SDWebImageContextSetImageOperationKey] = imageOperationKeyForState(state); + @weakify(self); [self sd_internalSetImageWithURL:url placeholderImage:placeholder options:options - operationKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)] - setImageBlock:^(UIImage *image, NSData *imageData) { - [weakSelf setBackgroundImage:image forState:state]; + context:mutableContext + setImageBlock:^(UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { + @strongify(self); + [self setBackgroundImage:image forState:state]; } - progress:nil - completed:completedBlock]; + progress:progressBlock + completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType, imageURL); + } + }]; } -- (void)sd_setImageLoadOperation:(id)operation forState:(UIControlState)state { - [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; -} +#pragma mark - Cancel - (void)sd_cancelImageLoadForState:(UIControlState)state { - [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; -} - -- (void)sd_setBackgroundImageLoadOperation:(id)operation forState:(UIControlState)state { - [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; + [self sd_cancelImageLoadOperationWithKey:imageOperationKeyForState(state)]; } - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state { - [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; + [self sd_cancelImageLoadOperationWithKey:backgroundImageOperationKeyForState(state)]; } -- (SDStateImageURLDictionary *)imageURLStorage { +#pragma mark - Private + +- (SDStateImageURLDictionary *)sd_imageURLStorage { SDStateImageURLDictionary *storage = objc_getAssociatedObject(self, &imageURLStorageKey); if (!storage) { storage = [NSMutableDictionary dictionary]; diff --git a/Pods/SDWebImage/SDWebImage/UIImage+ForceDecode.h b/Pods/SDWebImage/SDWebImage/UIImage+ForceDecode.h new file mode 100644 index 00000000..d0ec4bb7 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/UIImage+ForceDecode.h @@ -0,0 +1,43 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +@interface UIImage (ForceDecode) + +/** + A bool value indicating whether the image has already been decoded. This can help to avoid extra force decode. + */ +@property (nonatomic, assign) BOOL sd_isDecoded; + +/** + Decode the provided image. This is useful if you want to force decode the image before rendering to improve performance. + + @param image The image to be decoded + @return The decoded image + */ ++ (nullable UIImage *)sd_decodedImageWithImage:(nullable UIImage *)image; + +/** + Decode and scale down the provided image + + @param image The image to be decoded + @return The decoded and scaled down image + */ ++ (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:(nullable UIImage *)image; + +/** + Decode and scale down the provided image with limit bytes + + @param image The image to be decoded + @param bytes The limit bytes size. Provide 0 to use the build-in limit. + @return The decoded and scaled down image + */ ++ (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:(nullable UIImage *)image limitBytes:(NSUInteger)bytes; + +@end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+ForceDecode.m b/Pods/SDWebImage/SDWebImage/UIImage+ForceDecode.m new file mode 100644 index 00000000..7eda3f6f --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/UIImage+ForceDecode.m @@ -0,0 +1,42 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIImage+ForceDecode.h" +#import "SDImageCoderHelper.h" +#import "objc/runtime.h" + +@implementation UIImage (ForceDecode) + +- (BOOL)sd_isDecoded { + NSNumber *value = objc_getAssociatedObject(self, @selector(sd_isDecoded)); + return value.boolValue; +} + +- (void)setSd_isDecoded:(BOOL)sd_isDecoded { + objc_setAssociatedObject(self, @selector(sd_isDecoded), @(sd_isDecoded), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + ++ (UIImage *)sd_decodedImageWithImage:(UIImage *)image { + if (!image) { + return nil; + } + return [SDImageCoderHelper decodedImageWithImage:image]; +} + ++ (UIImage *)sd_decodedAndScaledDownImageWithImage:(UIImage *)image { + return [self sd_decodedAndScaledDownImageWithImage:image limitBytes:0]; +} + ++ (UIImage *)sd_decodedAndScaledDownImageWithImage:(UIImage *)image limitBytes:(NSUInteger)bytes { + if (!image) { + return nil; + } + return [SDImageCoderHelper decodedAndScaledDownImageWithImage:image limitBytes:bytes]; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+GIF.h b/Pods/SDWebImage/SDWebImage/UIImage+GIF.h old mode 100755 new mode 100644 index 479d5723..38b986be --- a/Pods/SDWebImage/SDWebImage/UIImage+GIF.h +++ b/Pods/SDWebImage/SDWebImage/UIImage+GIF.h @@ -9,16 +9,16 @@ #import "SDWebImageCompat.h" +// This category is just use as a convenience method. For more detail control, use methods in `UIImage+MultiFormat.h` or directlly use `SDImageCoder` @interface UIImage (GIF) /** - * Compatibility method - creates an animated UIImage from an NSData, it will only contain the 1st frame image - */ -+ (UIImage *)sd_animatedGIFWithData:(NSData *)data; + Creates an animated UIImage from an NSData. + This will create animated image if the data is Animated GIF. And will create a static image is the data is Static GIF. -/** - * Checks if an UIImage instance is a GIF. Will use the `images` array + @param data The GIF data + @return The created image */ -- (BOOL)isGIF; ++ (nullable UIImage *)sd_imageWithGIFData:(nullable NSData *)data; @end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+GIF.m b/Pods/SDWebImage/SDWebImage/UIImage+GIF.m old mode 100755 new mode 100644 index 9301777f..7158cf31 --- a/Pods/SDWebImage/SDWebImage/UIImage+GIF.m +++ b/Pods/SDWebImage/SDWebImage/UIImage+GIF.m @@ -8,53 +8,15 @@ */ #import "UIImage+GIF.h" -#import -#import "objc/runtime.h" -#import "NSImage+WebCache.h" +#import "SDImageGIFCoder.h" @implementation UIImage (GIF) -+ (UIImage *)sd_animatedGIFWithData:(NSData *)data { ++ (nullable UIImage *)sd_imageWithGIFData:(nullable NSData *)data { if (!data) { return nil; } - - CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); - - size_t count = CGImageSourceGetCount(source); - - UIImage *staticImage; - - if (count <= 1) { - staticImage = [[UIImage alloc] initWithData:data]; - } else { - // we will only retrieve the 1st frame. the full GIF support is available via the FLAnimatedImageView category. - // this here is only code to allow drawing animated images as static ones -#if SD_WATCH - CGFloat scale = 1; - scale = [WKInterfaceDevice currentDevice].screenScale; -#elif SD_UIKIT - CGFloat scale = 1; - scale = [UIScreen mainScreen].scale; -#endif - - CGImageRef CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL); -#if SD_UIKIT || SD_WATCH - UIImage *frameImage = [UIImage imageWithCGImage:CGImage scale:scale orientation:UIImageOrientationUp]; - staticImage = [UIImage animatedImageWithImages:@[frameImage] duration:0.0f]; -#elif SD_MAC - staticImage = [[UIImage alloc] initWithCGImage:CGImage size:NSZeroSize]; -#endif - CGImageRelease(CGImage); - } - - CFRelease(source); - - return staticImage; -} - -- (BOOL)isGIF { - return (self.images != nil); + return [[SDImageGIFCoder sharedCoder] decodedImageWithData:data options:0]; } @end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+MemoryCacheCost.h b/Pods/SDWebImage/SDWebImage/UIImage+MemoryCacheCost.h new file mode 100644 index 00000000..262c9964 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/UIImage+MemoryCacheCost.h @@ -0,0 +1,24 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +@interface UIImage (MemoryCacheCost) + +/** + The memory cache cost for specify image used by image cache. The cost function is the bytes size held in memory. + If you set some associated object to `UIImage`, you can set the custom value to indicate the memory cost. + + For `UIImage`, this method return the single frame bytes size when `image.images` is nil for static image. Retuen full frame bytes size when `image.images` is not nil for animated image. + For `NSImage`, this method return the single frame bytes size because `NSImage` does not store all frames in memory. + @note Note that because of the limitations of category this property can get out of sync if you create another instance with CGImage or other methods. + @note For custom animated class conforms to `SDAnimatedImage`, you can override this getter method in your subclass to return a more proper value instead, which representing the current frame's total bytes. + */ +@property (assign, nonatomic) NSUInteger sd_memoryCost; + +@end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+MemoryCacheCost.m b/Pods/SDWebImage/SDWebImage/UIImage+MemoryCacheCost.m new file mode 100644 index 00000000..b0883b1f --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/UIImage+MemoryCacheCost.m @@ -0,0 +1,46 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIImage+MemoryCacheCost.h" +#import "objc/runtime.h" +#import "NSImage+Compatibility.h" + +FOUNDATION_STATIC_INLINE NSUInteger SDMemoryCacheCostForImage(UIImage *image) { + CGImageRef imageRef = image.CGImage; + if (!imageRef) { + return 0; + } + NSUInteger bytesPerFrame = CGImageGetBytesPerRow(imageRef) * CGImageGetHeight(imageRef); + NSUInteger frameCount; +#if SD_MAC + frameCount = 1; +#elif SD_UIKIT || SD_WATCH + frameCount = image.images.count > 0 ? image.images.count : 1; +#endif + NSUInteger cost = bytesPerFrame * frameCount; + return cost; +} + +@implementation UIImage (MemoryCacheCost) + +- (NSUInteger)sd_memoryCost { + NSNumber *value = objc_getAssociatedObject(self, @selector(sd_memoryCost)); + NSUInteger memoryCost; + if (value != nil) { + memoryCost = [value unsignedIntegerValue]; + } else { + memoryCost = SDMemoryCacheCostForImage(self); + } + return memoryCost; +} + +- (void)setSd_memoryCost:(NSUInteger)sd_memoryCost { + objc_setAssociatedObject(self, @selector(sd_memoryCost), @(sd_memoryCost), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+Metadata.h b/Pods/SDWebImage/SDWebImage/UIImage+Metadata.h new file mode 100644 index 00000000..a05e8056 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/UIImage+Metadata.h @@ -0,0 +1,46 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "NSData+ImageContentType.h" + +@interface UIImage (Metadata) + +/** + * UIKit: + * For static image format, this value is always 0. + * For animated image format, 0 means infinite looping. + * Note that because of the limitations of categories this property can get out of sync if you create another instance with CGImage or other methods. + * AppKit: + * NSImage currently only support animated via GIF imageRep unlike UIImage. + * The getter of this property will get the loop count from GIF imageRep + * The setter of this property will set the loop count from GIF imageRep + */ +@property (nonatomic, assign) NSUInteger sd_imageLoopCount; + +/** + * UIKit: + * Check the `images` array property + * AppKit: + * NSImage currently only support animated via GIF imageRep unlike UIImage. It will check the imageRep's frame count. + */ +@property (nonatomic, assign, readonly) BOOL sd_isAnimated; + +/** + * The image format represent the original compressed image data format. + * If you don't manually specify a format, this information is retrieve from CGImage using `CGImageGetUTType`, which may return nil for non-CG based image. At this time it will return `SDImageFormatUndefined` as default value. + * @note Note that because of the limitations of categories this property can get out of sync if you create another instance with CGImage or other methods. + */ +@property (nonatomic, assign) SDImageFormat sd_imageFormat; + +/** + A bool value indicating whether the image is during incremental decoding and may not contains full pixels. + */ +@property (nonatomic, assign) BOOL sd_isIncremental; + +@end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+Metadata.m b/Pods/SDWebImage/SDWebImage/UIImage+Metadata.m new file mode 100644 index 00000000..3c9bf929 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/UIImage+Metadata.m @@ -0,0 +1,108 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIImage+Metadata.h" +#import "NSImage+Compatibility.h" +#import "objc/runtime.h" + +@implementation UIImage (Metadata) + +#if SD_UIKIT || SD_WATCH + +- (NSUInteger)sd_imageLoopCount { + NSUInteger imageLoopCount = 0; + NSNumber *value = objc_getAssociatedObject(self, @selector(sd_imageLoopCount)); + if ([value isKindOfClass:[NSNumber class]]) { + imageLoopCount = value.unsignedIntegerValue; + } + return imageLoopCount; +} + +- (void)setSd_imageLoopCount:(NSUInteger)sd_imageLoopCount { + NSNumber *value = @(sd_imageLoopCount); + objc_setAssociatedObject(self, @selector(sd_imageLoopCount), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (BOOL)sd_isAnimated { + return (self.images != nil); +} + +#else + +- (NSUInteger)sd_imageLoopCount { + NSUInteger imageLoopCount = 0; + NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height); + NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil]; + NSBitmapImageRep *bitmapImageRep; + if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) { + bitmapImageRep = (NSBitmapImageRep *)imageRep; + } + if (bitmapImageRep) { + imageLoopCount = [[bitmapImageRep valueForProperty:NSImageLoopCount] unsignedIntegerValue]; + } + return imageLoopCount; +} + +- (void)setSd_imageLoopCount:(NSUInteger)sd_imageLoopCount { + NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height); + NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil]; + NSBitmapImageRep *bitmapImageRep; + if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) { + bitmapImageRep = (NSBitmapImageRep *)imageRep; + } + if (bitmapImageRep) { + [bitmapImageRep setProperty:NSImageLoopCount withValue:@(sd_imageLoopCount)]; + } +} + +- (BOOL)sd_isAnimated { + BOOL isGIF = NO; + NSRect imageRect = NSMakeRect(0, 0, self.size.width, self.size.height); + NSImageRep *imageRep = [self bestRepresentationForRect:imageRect context:nil hints:nil]; + NSBitmapImageRep *bitmapImageRep; + if ([imageRep isKindOfClass:[NSBitmapImageRep class]]) { + bitmapImageRep = (NSBitmapImageRep *)imageRep; + } + if (bitmapImageRep) { + NSUInteger frameCount = [[bitmapImageRep valueForProperty:NSImageFrameCount] unsignedIntegerValue]; + isGIF = frameCount > 1 ? YES : NO; + } + return isGIF; +} + +#endif + +- (SDImageFormat)sd_imageFormat { + SDImageFormat imageFormat = SDImageFormatUndefined; + NSNumber *value = objc_getAssociatedObject(self, @selector(sd_imageFormat)); + if ([value isKindOfClass:[NSNumber class]]) { + imageFormat = value.integerValue; + return imageFormat; + } + // Check CGImage's UTType, may return nil for non-Image/IO based image + if (@available(iOS 9.0, tvOS 9.0, macOS 10.11, watchOS 2.0, *)) { + CFStringRef uttype = CGImageGetUTType(self.CGImage); + imageFormat = [NSData sd_imageFormatFromUTType:uttype]; + } + return imageFormat; +} + +- (void)setSd_imageFormat:(SDImageFormat)sd_imageFormat { + objc_setAssociatedObject(self, @selector(sd_imageFormat), @(sd_imageFormat), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (void)setSd_isIncremental:(BOOL)sd_isIncremental { + objc_setAssociatedObject(self, @selector(sd_isIncremental), @(sd_isIncremental), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (BOOL)sd_isIncremental { + NSNumber *value = objc_getAssociatedObject(self, @selector(sd_isIncremental)); + return value.boolValue; +} + +@end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h b/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h index bec411e0..d3496582 100644 --- a/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h +++ b/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h @@ -10,9 +10,67 @@ #import "NSData+ImageContentType.h" @interface UIImage (MultiFormat) +#pragma mark - Decode +/** + Create and decode a image with the specify image data + @param data The image data + @return The created image + */ + (nullable UIImage *)sd_imageWithData:(nullable NSData *)data; + +/** + Create and decode a image with the specify image data and scale + + @param data The image data + @param scale The image scale factor. Should be greater than or equal to 1.0. + @return The created image + */ ++ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data scale:(CGFloat)scale; + +/** + Create and decode a image with the specify image data and scale, allow specify animate/static control + + @param data The image data + @param scale The image scale factor. Should be greater than or equal to 1.0. + @param firstFrameOnly Even if the image data is animated image format, decode the first frame only as static image. + @return The created image + */ ++ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data scale:(CGFloat)scale firstFrameOnly:(BOOL)firstFrameOnly; + +#pragma mark - Encode +/** + Encode the current image to the data, the image format is unspecified + + @return The encoded data. If can't encode, return nil + */ - (nullable NSData *)sd_imageData; -- (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat; + +/** + Encode the current image to data with the specify image format + + @param imageFormat The specify image format + @return The encoded data. If can't encode, return nil + */ +- (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat NS_SWIFT_NAME(sd_imageData(as:)); + +/** + Encode the current image to data with the specify image format and compression quality + + @param imageFormat The specify image format + @param compressionQuality The quality of the resulting image data. Value between 0.0-1.0. Some coders may not support compression quality. + @return The encoded data. If can't encode, return nil + */ +- (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat compressionQuality:(double)compressionQuality NS_SWIFT_NAME(sd_imageData(as:compressionQuality:)); + +/** + Encode the current image to data with the specify image format and compression quality, allow specify animate/static control + + @param imageFormat The specify image format + @param compressionQuality The quality of the resulting image data. Value between 0.0-1.0. Some coders may not support compression quality. + @param firstFrameOnly Even if the image is animated image, encode the first frame only as static image. + @return The encoded data. If can't encode, return nil + */ +- (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat compressionQuality:(double)compressionQuality firstFrameOnly:(BOOL)firstFrameOnly NS_SWIFT_NAME(sd_imageData(as:compressionQuality:firstFrameOnly:)); @end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m b/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m index 378f3892..c70a3808 100644 --- a/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m +++ b/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m @@ -7,155 +7,44 @@ */ #import "UIImage+MultiFormat.h" -#import "UIImage+GIF.h" -#import "NSData+ImageContentType.h" -#import - -#ifdef SD_WEBP -#import "UIImage+WebP.h" -#endif +#import "SDImageCodersManager.h" @implementation UIImage (MultiFormat) + (nullable UIImage *)sd_imageWithData:(nullable NSData *)data { - if (!data) { - return nil; - } - - UIImage *image; - SDImageFormat imageFormat = [NSData sd_imageFormatForImageData:data]; - if (imageFormat == SDImageFormatGIF) { - image = [UIImage sd_animatedGIFWithData:data]; - } -#ifdef SD_WEBP - else if (imageFormat == SDImageFormatWebP) - { - image = [UIImage sd_imageWithWebPData:data]; - } -#endif - else { - image = [[UIImage alloc] initWithData:data]; -#if SD_UIKIT || SD_WATCH - UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data]; - if (orientation != UIImageOrientationUp) { - image = [UIImage imageWithCGImage:image.CGImage - scale:image.scale - orientation:orientation]; - } -#endif - } - - - return image; + return [self sd_imageWithData:data scale:1]; } -#if SD_UIKIT || SD_WATCH -+(UIImageOrientation)sd_imageOrientationFromImageData:(nonnull NSData *)imageData { - UIImageOrientation result = UIImageOrientationUp; - CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); - if (imageSource) { - CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); - if (properties) { - CFTypeRef val; - int exifOrientation; - val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); - if (val) { - CFNumberGetValue(val, kCFNumberIntType, &exifOrientation); - result = [self sd_exifOrientationToiOSOrientation:exifOrientation]; - } // else - if it's not set it remains at up - CFRelease((CFTypeRef) properties); - } else { - //NSLog(@"NO PROPERTIES, FAIL"); - } - CFRelease(imageSource); - } - return result; ++ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data scale:(CGFloat)scale { + return [self sd_imageWithData:data scale:scale firstFrameOnly:NO]; } -#pragma mark EXIF orientation tag converter -// Convert an EXIF image orientation to an iOS one. -// reference see here: http://sylvana.net/jpegcrop/exif_orientation.html -+ (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation { - UIImageOrientation orientation = UIImageOrientationUp; - switch (exifOrientation) { - case 1: - orientation = UIImageOrientationUp; - break; - - case 3: - orientation = UIImageOrientationDown; - break; - - case 8: - orientation = UIImageOrientationLeft; - break; - - case 6: - orientation = UIImageOrientationRight; - break; - - case 2: - orientation = UIImageOrientationUpMirrored; - break; - - case 4: - orientation = UIImageOrientationDownMirrored; - break; - - case 5: - orientation = UIImageOrientationLeftMirrored; - break; - - case 7: - orientation = UIImageOrientationRightMirrored; - break; - default: - break; ++ (nullable UIImage *)sd_imageWithData:(nullable NSData *)data scale:(CGFloat)scale firstFrameOnly:(BOOL)firstFrameOnly { + if (!data) { + return nil; + } + if (scale < 1) { + scale = 1; } - return orientation; + SDImageCoderOptions *options = @{SDImageCoderDecodeScaleFactor : @(scale), SDImageCoderDecodeFirstFrameOnly : @(firstFrameOnly)}; + return [[SDImageCodersManager sharedManager] decodedImageWithData:data options:options]; } -#endif - (nullable NSData *)sd_imageData { return [self sd_imageDataAsFormat:SDImageFormatUndefined]; } - (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat { - NSData *imageData = nil; - if (self) { -#if SD_UIKIT || SD_WATCH - int alphaInfo = CGImageGetAlphaInfo(self.CGImage); - BOOL hasAlpha = !(alphaInfo == kCGImageAlphaNone || - alphaInfo == kCGImageAlphaNoneSkipFirst || - alphaInfo == kCGImageAlphaNoneSkipLast); - - BOOL usePNG = hasAlpha; - - // the imageFormat param has priority here. But if the format is undefined, we relly on the alpha channel - if (imageFormat != SDImageFormatUndefined) { - usePNG = (imageFormat == SDImageFormatPNG); - } - - if (usePNG) { - imageData = UIImagePNGRepresentation(self); - } else { - imageData = UIImageJPEGRepresentation(self, (CGFloat)1.0); - } -#else - NSBitmapImageFileType imageFileType = NSJPEGFileType; - if (imageFormat == SDImageFormatGIF) { - imageFileType = NSGIFFileType; - } else if (imageFormat == SDImageFormatPNG) { - imageFileType = NSPNGFileType; - } - - imageData = [NSBitmapImageRep representationOfImageRepsInArray:self.representations - usingType:imageFileType - properties:@{}]; -#endif - } - return imageData; + return [self sd_imageDataAsFormat:imageFormat compressionQuality:1]; } +- (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat compressionQuality:(double)compressionQuality { + return [self sd_imageDataAsFormat:imageFormat compressionQuality:compressionQuality firstFrameOnly:NO]; +} + +- (nullable NSData *)sd_imageDataAsFormat:(SDImageFormat)imageFormat compressionQuality:(double)compressionQuality firstFrameOnly:(BOOL)firstFrameOnly { + SDImageCoderOptions *options = @{SDImageCoderEncodeCompressionQuality : @(compressionQuality), SDImageCoderEncodeFirstFrameOnly : @(firstFrameOnly)}; + return [[SDImageCodersManager sharedManager] encodedDataWithImage:self format:imageFormat options:options]; +} @end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+Transform.h b/Pods/SDWebImage/SDWebImage/UIImage+Transform.h new file mode 100644 index 00000000..717c08cc --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/UIImage+Transform.h @@ -0,0 +1,146 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" + +typedef NS_ENUM(NSUInteger, SDImageScaleMode) { + SDImageScaleModeFill = 0, + SDImageScaleModeAspectFit = 1, + SDImageScaleModeAspectFill = 2 +}; + +#if SD_UIKIT || SD_WATCH +typedef UIRectCorner SDRectCorner; +#else +typedef NS_OPTIONS(NSUInteger, SDRectCorner) { + SDRectCornerTopLeft = 1 << 0, + SDRectCornerTopRight = 1 << 1, + SDRectCornerBottomLeft = 1 << 2, + SDRectCornerBottomRight = 1 << 3, + SDRectCornerAllCorners = ~0UL +}; +#endif + +/** + Provide some commen method for `UIImage`. + Image process is based on Core Graphics and vImage. + */ +@interface UIImage (Transform) + +#pragma mark - Image Geometry + +/** + Returns a new image which is resized from this image. + You can specify a larger or smaller size than the image size. The image content will be changed with the scale mode. + + @param size The new size to be resized, values should be positive. + @param scaleMode The scale mode for image content. + @return The new image with the given size. + */ +- (nullable UIImage *)sd_resizedImageWithSize:(CGSize)size scaleMode:(SDImageScaleMode)scaleMode; + +/** + Returns a new image which is cropped from this image. + + @param rect Image's inner rect. + @return The new image with the cropping rect. + */ +- (nullable UIImage *)sd_croppedImageWithRect:(CGRect)rect; + +/** + Rounds a new image with a given corner radius and corners. + + @param cornerRadius The radius of each corner oval. Values larger than half the + rectangle's width or height are clamped appropriately to + half the width or height. + @param corners A bitmask value that identifies the corners that you want + rounded. You can use this parameter to round only a subset + of the corners of the rectangle. + @param borderWidth The inset border line width. Values larger than half the rectangle's + width or height are clamped appropriately to half the width + or height. + @param borderColor The border stroke color. nil means clear color. + @return The new image with the round corner. + */ +- (nullable UIImage *)sd_roundedCornerImageWithRadius:(CGFloat)cornerRadius + corners:(SDRectCorner)corners + borderWidth:(CGFloat)borderWidth + borderColor:(nullable UIColor *)borderColor; + +/** + Returns a new rotated image (relative to the center). + + @param angle Rotated radians in counterclockwise.⟲ + @param fitSize YES: new image's size is extend to fit all content. + NO: image's size will not change, content may be clipped. + @return The new image with the rotation. + */ +- (nullable UIImage *)sd_rotatedImageWithAngle:(CGFloat)angle fitSize:(BOOL)fitSize; + +/** + Returns a new horizontally(vertically) flipped image. + + @param horizontal YES to flip the image horizontally. ⇋ + @param vertical YES to flip the image vertically. ⥯ + @return The new image with the flipping. + */ +- (nullable UIImage *)sd_flippedImageWithHorizontal:(BOOL)horizontal vertical:(BOOL)vertical; + +#pragma mark - Image Blending + +/** + Return a tinted image with the given color. This actually use alpha blending of current image and the tint color. + + @param tintColor The tint color. + @return The new image with the tint color. + */ +- (nullable UIImage *)sd_tintedImageWithColor:(nonnull UIColor *)tintColor; + +/** + Return the pixel color at specify position. The point is from the top-left to the bottom-right and 0-based. The returned the color is always be RGBA format. The image must be CG-based. + @note The point's x/y should not be smaller than 0, or greater than or equal to width/height. + @note The overhead of object creation means this method is best suited for infrequent color sampling. For heavy image processing, grab the raw bitmap data and process yourself. + + @param point The position of pixel + @return The color for specify pixel, or nil if any error occur + */ +- (nullable UIColor *)sd_colorAtPoint:(CGPoint)point; + +/** + Return the pixel color array with specify rectangle. The rect is from the top-left to the bottom-right and 0-based. The returned the color is always be RGBA format. The image must be CG-based. + @note The rect's width/height should not be smaller than or equal to 0. The minX/minY should not be smaller than 0. The maxX/maxY should not be greater than width/height. Attention this limit is different from `sd_colorAtPoint:` (point: (0, 0) like rect: (0, 0, 1, 1)) + @note The overhead of object creation means this method is best suited for infrequent color sampling. For heavy image processing, grab the raw bitmap data and process yourself. + + @param rect The rectangle of pixels + @return The color array for specify pixels, or nil if any error occur + */ +- (nullable NSArray *)sd_colorsWithRect:(CGRect)rect; + +#pragma mark - Image Effect + +/** + Return a new image applied a blur effect. + + @param blurRadius The radius of the blur in points, 0 means no blur effect. + + @return The new image with blur effect, or nil if an error occurs (e.g. no enough memory). + */ +- (nullable UIImage *)sd_blurredImageWithRadius:(CGFloat)blurRadius; + +#if SD_UIKIT || SD_MAC +/** + Return a new image applied a CIFilter. + + @param filter The CIFilter to be applied to the image. + @return The new image with the CIFilter, or nil if an error occurs (e.g. no + enough memory). + */ +- (nullable UIImage *)sd_filteredImageWithFilter:(nonnull CIFilter *)filter; +#endif + +@end diff --git a/Pods/SDWebImage/SDWebImage/UIImage+Transform.m b/Pods/SDWebImage/SDWebImage/UIImage+Transform.m new file mode 100644 index 00000000..acf86fb1 --- /dev/null +++ b/Pods/SDWebImage/SDWebImage/UIImage+Transform.m @@ -0,0 +1,589 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIImage+Transform.h" +#import "NSImage+Compatibility.h" +#import "SDImageGraphics.h" +#import "NSBezierPath+RoundedCorners.h" +#import +#if SD_UIKIT || SD_MAC +#import +#endif + +static inline CGRect SDCGRectFitWithScaleMode(CGRect rect, CGSize size, SDImageScaleMode scaleMode) { + rect = CGRectStandardize(rect); + size.width = size.width < 0 ? -size.width : size.width; + size.height = size.height < 0 ? -size.height : size.height; + CGPoint center = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); + switch (scaleMode) { + case SDImageScaleModeAspectFit: + case SDImageScaleModeAspectFill: { + if (rect.size.width < 0.01 || rect.size.height < 0.01 || + size.width < 0.01 || size.height < 0.01) { + rect.origin = center; + rect.size = CGSizeZero; + } else { + CGFloat scale; + if (scaleMode == SDImageScaleModeAspectFit) { + if (size.width / size.height < rect.size.width / rect.size.height) { + scale = rect.size.height / size.height; + } else { + scale = rect.size.width / size.width; + } + } else { + if (size.width / size.height < rect.size.width / rect.size.height) { + scale = rect.size.width / size.width; + } else { + scale = rect.size.height / size.height; + } + } + size.width *= scale; + size.height *= scale; + rect.size = size; + rect.origin = CGPointMake(center.x - size.width * 0.5, center.y - size.height * 0.5); + } + } break; + case SDImageScaleModeFill: + default: { + rect = rect; + } + } + return rect; +} + +static inline UIColor * SDGetColorFromPixel(Pixel_8888 pixel, CGBitmapInfo bitmapInfo) { + // Get alpha info, byteOrder info + CGImageAlphaInfo alphaInfo = bitmapInfo & kCGBitmapAlphaInfoMask; + CGBitmapInfo byteOrderInfo = bitmapInfo & kCGBitmapByteOrderMask; + CGFloat r = 0, g = 0, b = 0, a = 255.0; + + BOOL byteOrderNormal = NO; + switch (byteOrderInfo) { + case kCGBitmapByteOrderDefault: { + byteOrderNormal = YES; + } break; + case kCGBitmapByteOrder32Little: { + } break; + case kCGBitmapByteOrder32Big: { + byteOrderNormal = YES; + } break; + default: break; + } + switch (alphaInfo) { + case kCGImageAlphaPremultipliedFirst: + case kCGImageAlphaFirst: { + if (byteOrderNormal) { + // ARGB8888 + a = pixel[0] / 255.0; + r = pixel[1] / 255.0; + g = pixel[2] / 255.0; + b = pixel[3] / 255.0; + } else { + // BGRA8888 + b = pixel[0] / 255.0; + g = pixel[1] / 255.0; + r = pixel[2] / 255.0; + a = pixel[3] / 255.0; + } + } + break; + case kCGImageAlphaPremultipliedLast: + case kCGImageAlphaLast: { + if (byteOrderNormal) { + // RGBA8888 + r = pixel[0] / 255.0; + g = pixel[1] / 255.0; + b = pixel[2] / 255.0; + a = pixel[3] / 255.0; + } else { + // ABGR8888 + a = pixel[0] / 255.0; + b = pixel[1] / 255.0; + g = pixel[2] / 255.0; + r = pixel[3] / 255.0; + } + } + break; + case kCGImageAlphaNone: { + if (byteOrderNormal) { + // RGB + r = pixel[0] / 255.0; + g = pixel[1] / 255.0; + b = pixel[2] / 255.0; + } else { + // BGR + b = pixel[0] / 255.0; + g = pixel[1] / 255.0; + r = pixel[2] / 255.0; + } + } + break; + case kCGImageAlphaNoneSkipLast: { + if (byteOrderNormal) { + // RGBX + r = pixel[0] / 255.0; + g = pixel[1] / 255.0; + b = pixel[2] / 255.0; + } else { + // XBGR + b = pixel[1] / 255.0; + g = pixel[2] / 255.0; + r = pixel[3] / 255.0; + } + } + break; + case kCGImageAlphaNoneSkipFirst: { + if (byteOrderNormal) { + // XRGB + r = pixel[1] / 255.0; + g = pixel[2] / 255.0; + b = pixel[3] / 255.0; + } else { + // BGRX + b = pixel[0] / 255.0; + g = pixel[1] / 255.0; + r = pixel[2] / 255.0; + } + } + break; + case kCGImageAlphaOnly: { + // A + a = pixel[0]; + } + break; + default: + break; + } + + return [UIColor colorWithRed:r green:g blue:b alpha:a]; +} + +@implementation UIImage (Transform) + +- (void)sd_drawInRect:(CGRect)rect withScaleMode:(SDImageScaleMode)scaleMode clipsToBounds:(BOOL)clips { + CGRect drawRect = SDCGRectFitWithScaleMode(rect, self.size, scaleMode); + if (drawRect.size.width == 0 || drawRect.size.height == 0) return; + if (clips) { + CGContextRef context = SDGraphicsGetCurrentContext(); + if (context) { + CGContextSaveGState(context); + CGContextAddRect(context, rect); + CGContextClip(context); + [self drawInRect:drawRect]; + CGContextRestoreGState(context); + } + } else { + [self drawInRect:drawRect]; + } +} + +- (UIImage *)sd_resizedImageWithSize:(CGSize)size scaleMode:(SDImageScaleMode)scaleMode { + if (size.width <= 0 || size.height <= 0) return nil; + SDGraphicsBeginImageContextWithOptions(size, NO, self.scale); + [self sd_drawInRect:CGRectMake(0, 0, size.width, size.height) withScaleMode:scaleMode clipsToBounds:NO]; + UIImage *image = SDGraphicsGetImageFromCurrentImageContext(); + SDGraphicsEndImageContext(); + return image; +} + +- (UIImage *)sd_croppedImageWithRect:(CGRect)rect { + if (!self.CGImage) return nil; + rect.origin.x *= self.scale; + rect.origin.y *= self.scale; + rect.size.width *= self.scale; + rect.size.height *= self.scale; + if (rect.size.width <= 0 || rect.size.height <= 0) return nil; + CGImageRef imageRef = CGImageCreateWithImageInRect(self.CGImage, rect); + if (!imageRef) { + return nil; + } +#if SD_UIKIT || SD_WATCH + UIImage *image = [UIImage imageWithCGImage:imageRef scale:self.scale orientation:self.imageOrientation]; +#else + UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:self.scale orientation:kCGImagePropertyOrientationUp]; +#endif + CGImageRelease(imageRef); + return image; +} + +- (UIImage *)sd_roundedCornerImageWithRadius:(CGFloat)cornerRadius corners:(SDRectCorner)corners borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor { + if (!self.CGImage) return nil; + SDGraphicsBeginImageContextWithOptions(self.size, NO, self.scale); + CGContextRef context = SDGraphicsGetCurrentContext(); + CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height); + + CGFloat minSize = MIN(self.size.width, self.size.height); + if (borderWidth < minSize / 2) { +#if SD_UIKIT || SD_WATCH + UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectInset(rect, borderWidth, borderWidth) byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)]; +#else + NSBezierPath *path = [NSBezierPath sd_bezierPathWithRoundedRect:CGRectInset(rect, borderWidth, borderWidth) byRoundingCorners:corners cornerRadius:cornerRadius]; +#endif + [path closePath]; + + CGContextSaveGState(context); + [path addClip]; + CGContextDrawImage(context, rect, self.CGImage); + CGContextRestoreGState(context); + } + + if (borderColor && borderWidth < minSize / 2 && borderWidth > 0) { + CGFloat strokeInset = (floor(borderWidth * self.scale) + 0.5) / self.scale; + CGRect strokeRect = CGRectInset(rect, strokeInset, strokeInset); + CGFloat strokeRadius = cornerRadius > self.scale / 2 ? cornerRadius - self.scale / 2 : 0; +#if SD_UIKIT || SD_WATCH + UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:strokeRect byRoundingCorners:corners cornerRadii:CGSizeMake(strokeRadius, strokeRadius)]; +#else + NSBezierPath *path = [NSBezierPath sd_bezierPathWithRoundedRect:strokeRect byRoundingCorners:corners cornerRadius:strokeRadius]; +#endif + [path closePath]; + + path.lineWidth = borderWidth; + [borderColor setStroke]; + [path stroke]; + } + + UIImage *image = SDGraphicsGetImageFromCurrentImageContext(); + SDGraphicsEndImageContext(); + return image; +} + +- (UIImage *)sd_rotatedImageWithAngle:(CGFloat)angle fitSize:(BOOL)fitSize { + if (!self.CGImage) return nil; + size_t width = (size_t)CGImageGetWidth(self.CGImage); + size_t height = (size_t)CGImageGetHeight(self.CGImage); + CGRect newRect = CGRectApplyAffineTransform(CGRectMake(0., 0., width, height), + fitSize ? CGAffineTransformMakeRotation(angle) : CGAffineTransformIdentity); + + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGContextRef context = CGBitmapContextCreate(NULL, + (size_t)newRect.size.width, + (size_t)newRect.size.height, + 8, + (size_t)newRect.size.width * 4, + colorSpace, + kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); + CGColorSpaceRelease(colorSpace); + if (!context) return nil; + + CGContextSetShouldAntialias(context, true); + CGContextSetAllowsAntialiasing(context, true); + CGContextSetInterpolationQuality(context, kCGInterpolationHigh); + + CGContextTranslateCTM(context, +(newRect.size.width * 0.5), +(newRect.size.height * 0.5)); + CGContextRotateCTM(context, angle); + + CGContextDrawImage(context, CGRectMake(-(width * 0.5), -(height * 0.5), width, height), self.CGImage); + CGImageRef imgRef = CGBitmapContextCreateImage(context); +#if SD_UIKIT || SD_WATCH + UIImage *img = [UIImage imageWithCGImage:imgRef scale:self.scale orientation:self.imageOrientation]; +#else + UIImage *img = [[UIImage alloc] initWithCGImage:imgRef scale:self.scale orientation:kCGImagePropertyOrientationUp]; +#endif + CGImageRelease(imgRef); + CGContextRelease(context); + return img; +} + +- (UIImage *)sd_flippedImageWithHorizontal:(BOOL)horizontal vertical:(BOOL)vertical { + if (!self.CGImage) return nil; + size_t width = (size_t)CGImageGetWidth(self.CGImage); + size_t height = (size_t)CGImageGetHeight(self.CGImage); + size_t bytesPerRow = width * 4; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, bytesPerRow, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); + CGColorSpaceRelease(colorSpace); + if (!context) return nil; + + CGContextDrawImage(context, CGRectMake(0, 0, width, height), self.CGImage); + UInt8 *data = (UInt8 *)CGBitmapContextGetData(context); + if (!data) { + CGContextRelease(context); + return nil; + } + vImage_Buffer src = { data, height, width, bytesPerRow }; + vImage_Buffer dest = { data, height, width, bytesPerRow }; + if (vertical) { + vImageVerticalReflect_ARGB8888(&src, &dest, kvImageBackgroundColorFill); + } + if (horizontal) { + vImageHorizontalReflect_ARGB8888(&src, &dest, kvImageBackgroundColorFill); + } + CGImageRef imgRef = CGBitmapContextCreateImage(context); + CGContextRelease(context); +#if SD_UIKIT || SD_WATCH + UIImage *img = [UIImage imageWithCGImage:imgRef scale:self.scale orientation:self.imageOrientation]; +#else + UIImage *img = [[UIImage alloc] initWithCGImage:imgRef scale:self.scale orientation:kCGImagePropertyOrientationUp]; +#endif + CGImageRelease(imgRef); + return img; +} + +#pragma mark - Image Blending + +- (UIImage *)sd_tintedImageWithColor:(UIColor *)tintColor { + if (!self.CGImage) return nil; + if (!tintColor.CGColor) return nil; + + BOOL hasTint = CGColorGetAlpha(tintColor.CGColor) > __FLT_EPSILON__; + if (!hasTint) { +#if SD_UIKIT || SD_WATCH + return [UIImage imageWithCGImage:self.CGImage scale:self.scale orientation:self.imageOrientation]; +#else + return [[UIImage alloc] initWithCGImage:self.CGImage scale:self.scale orientation:kCGImagePropertyOrientationUp]; +#endif + } + + CGSize size = self.size; + CGRect rect = { CGPointZero, size }; + CGFloat scale = self.scale; + + // blend mode, see https://en.wikipedia.org/wiki/Alpha_compositing + CGBlendMode blendMode = kCGBlendModeSourceAtop; + + SDGraphicsBeginImageContextWithOptions(size, NO, scale); + CGContextRef context = SDGraphicsGetCurrentContext(); + CGContextDrawImage(context, rect, self.CGImage); + CGContextSetBlendMode(context, blendMode); + CGContextSetFillColorWithColor(context, tintColor.CGColor); + CGContextFillRect(context, rect); + UIImage *image = SDGraphicsGetImageFromCurrentImageContext(); + SDGraphicsEndImageContext(); + + return image; +} + +- (UIColor *)sd_colorAtPoint:(CGPoint)point { + if (!self) { + return nil; + } + CGImageRef imageRef = self.CGImage; + if (!imageRef) { + return nil; + } + + // Check point + CGFloat width = CGImageGetWidth(imageRef); + CGFloat height = CGImageGetHeight(imageRef); + if (point.x < 0 || point.y < 0 || point.x >= width || point.y >= height) { + return nil; + } + + // Get pixels + CGDataProviderRef provider = CGImageGetDataProvider(imageRef); + if (!provider) { + return nil; + } + CFDataRef data = CGDataProviderCopyData(provider); + if (!data) { + return nil; + } + + // Get pixel at point + size_t bytesPerRow = CGImageGetBytesPerRow(imageRef); + size_t components = CGImageGetBitsPerPixel(imageRef) / CGImageGetBitsPerComponent(imageRef); + + CFRange range = CFRangeMake(bytesPerRow * point.y + components * point.x, 4); + if (CFDataGetLength(data) < range.location + range.length) { + CFRelease(data); + return nil; + } + Pixel_8888 pixel = {0}; + CFDataGetBytes(data, range, pixel); + CFRelease(data); + + // Convert to color + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + return SDGetColorFromPixel(pixel, bitmapInfo); +} + +- (NSArray *)sd_colorsWithRect:(CGRect)rect { + if (!self) { + return nil; + } + CGImageRef imageRef = self.CGImage; + if (!imageRef) { + return nil; + } + + // Check rect + CGFloat width = CGImageGetWidth(imageRef); + CGFloat height = CGImageGetHeight(imageRef); + if (CGRectGetWidth(rect) <= 0 || CGRectGetHeight(rect) <= 0 || CGRectGetMinX(rect) < 0 || CGRectGetMinY(rect) < 0 || CGRectGetMaxX(rect) > width || CGRectGetMaxY(rect) > height) { + return nil; + } + + // Get pixels + CGDataProviderRef provider = CGImageGetDataProvider(imageRef); + if (!provider) { + return nil; + } + CFDataRef data = CGDataProviderCopyData(provider); + if (!data) { + return nil; + } + + // Get pixels with rect + size_t bytesPerRow = CGImageGetBytesPerRow(imageRef); + size_t components = CGImageGetBitsPerPixel(imageRef) / CGImageGetBitsPerComponent(imageRef); + + size_t start = bytesPerRow * CGRectGetMinY(rect) + components * CGRectGetMinX(rect); + size_t end = bytesPerRow * (CGRectGetMaxY(rect) - 1) + components * CGRectGetMaxX(rect); + if (CFDataGetLength(data) < (CFIndex)end) { + CFRelease(data); + return nil; + } + + const UInt8 *pixels = CFDataGetBytePtr(data); + size_t row = CGRectGetMinY(rect); + size_t col = CGRectGetMaxX(rect); + + // Convert to color + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + NSMutableArray *colors = [NSMutableArray arrayWithCapacity:CGRectGetWidth(rect) * CGRectGetHeight(rect)]; + for (size_t index = start; index < end; index += 4) { + if (index >= row * bytesPerRow + col * components) { + // Index beyond the end of current row, go next row + row++; + index = row * bytesPerRow + CGRectGetMinX(rect) * components; + index -= 4; + continue; + } + Pixel_8888 pixel = {pixels[index], pixels[index+1], pixels[index+2], pixels[index+3]}; + UIColor *color = SDGetColorFromPixel(pixel, bitmapInfo); + [colors addObject:color]; + } + CFRelease(data); + + return [colors copy]; +} + +#pragma mark - Image Effect + +// We use vImage to do box convolve for performance and support for watchOS. However, you can just use `CIFilter.CIBoxBlur`. For other blur effect, use any filter in `CICategoryBlur` +- (UIImage *)sd_blurredImageWithRadius:(CGFloat)blurRadius { + if (self.size.width < 1 || self.size.height < 1) { + return nil; + } + if (!self.CGImage) { + return nil; + } + + BOOL hasBlur = blurRadius > __FLT_EPSILON__; + if (!hasBlur) { + return self; + } + + CGFloat scale = self.scale; + CGImageRef imageRef = self.CGImage; + + vImage_Buffer effect = {}, scratch = {}; + vImage_Buffer *input = NULL, *output = NULL; + + vImage_CGImageFormat format = { + .bitsPerComponent = 8, + .bitsPerPixel = 32, + .colorSpace = NULL, + .bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little, //requests a BGRA buffer. + .version = 0, + .decode = NULL, + .renderingIntent = kCGRenderingIntentDefault + }; + + vImage_Error err; + err = vImageBuffer_InitWithCGImage(&effect, &format, NULL, imageRef, kvImagePrintDiagnosticsToConsole); + if (err != kvImageNoError) { + NSLog(@"UIImage+Transform error: vImageBuffer_InitWithCGImage returned error code %zi for inputImage: %@", err, self); + return nil; + } + err = vImageBuffer_Init(&scratch, effect.height, effect.width, format.bitsPerPixel, kvImageNoFlags); + if (err != kvImageNoError) { + NSLog(@"UIImage+Transform error: vImageBuffer_Init returned error code %zi for inputImage: %@", err, self); + return nil; + } + + input = &effect; + output = &scratch; + + if (hasBlur) { + // A description of how to compute the box kernel width from the Gaussian + // radius (aka standard deviation) appears in the SVG spec: + // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement + // + // For larger values of 's' (s >= 2.0), an approximation can be used: Three + // successive box-blurs build a piece-wise quadratic convolution kernel, which + // approximates the Gaussian kernel to within roughly 3%. + // + // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5) + // + // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel. + // + CGFloat inputRadius = blurRadius * scale; + if (inputRadius - 2.0 < __FLT_EPSILON__) inputRadius = 2.0; + uint32_t radius = floor((inputRadius * 3.0 * sqrt(2 * M_PI) / 4 + 0.5) / 2); + radius |= 1; // force radius to be odd so that the three box-blur methodology works. + int iterations; + if (blurRadius * scale < 0.5) iterations = 1; + else if (blurRadius * scale < 1.5) iterations = 2; + else iterations = 3; + NSInteger tempSize = vImageBoxConvolve_ARGB8888(input, output, NULL, 0, 0, radius, radius, NULL, kvImageGetTempBufferSize | kvImageEdgeExtend); + void *temp = malloc(tempSize); + for (int i = 0; i < iterations; i++) { + vImageBoxConvolve_ARGB8888(input, output, temp, 0, 0, radius, radius, NULL, kvImageEdgeExtend); + vImage_Buffer *tmp = input; + input = output; + output = tmp; + } + free(temp); + } + + CGImageRef effectCGImage = NULL; + effectCGImage = vImageCreateCGImageFromBuffer(input, &format, NULL, NULL, kvImageNoAllocate, NULL); + if (effectCGImage == NULL) { + effectCGImage = vImageCreateCGImageFromBuffer(input, &format, NULL, NULL, kvImageNoFlags, NULL); + free(input->data); + } + free(output->data); +#if SD_UIKIT || SD_WATCH + UIImage *outputImage = [UIImage imageWithCGImage:effectCGImage scale:self.scale orientation:self.imageOrientation]; +#else + UIImage *outputImage = [[UIImage alloc] initWithCGImage:effectCGImage scale:self.scale orientation:kCGImagePropertyOrientationUp]; +#endif + CGImageRelease(effectCGImage); + + return outputImage; +} + +#if SD_UIKIT || SD_MAC +- (UIImage *)sd_filteredImageWithFilter:(CIFilter *)filter { + if (!self.CGImage) return nil; + + CIContext *context = [CIContext context]; + CIImage *inputImage = [CIImage imageWithCGImage:self.CGImage]; + if (!inputImage) return nil; + + [filter setValue:inputImage forKey:kCIInputImageKey]; + CIImage *outputImage = filter.outputImage; + if (!outputImage) return nil; + + CGImageRef imageRef = [context createCGImage:outputImage fromRect:outputImage.extent]; + if (!imageRef) return nil; + +#if SD_UIKIT + UIImage *image = [UIImage imageWithCGImage:imageRef scale:self.scale orientation:self.imageOrientation]; +#else + UIImage *image = [[UIImage alloc] initWithCGImage:imageRef scale:self.scale orientation:kCGImagePropertyOrientationUp]; +#endif + CGImageRelease(imageRef); + + return image; +} +#endif + +@end diff --git a/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h b/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h index ceb71c2a..6cd3ba61 100644 --- a/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h +++ b/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h @@ -24,7 +24,7 @@ * * @param url The url for the image. */ -- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url; +- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT; /** * Set the imageView `highlightedImage` with an `url` and custom options. @@ -35,7 +35,20 @@ * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. */ - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url - options:(SDWebImageOptions)options; + options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT; + +/** + * Set the imageView `highlightedImage` with an `url`, custom options and context. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + */ +- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context; /** * Set the imageView `highlightedImage` with an `url`. @@ -50,7 +63,7 @@ * The fourth parameter is the original image url. */ - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url - completed:(nullable SDExternalCompletionBlock)completedBlock; + completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT; /** * Set the imageView `highlightedImage` with an `url` and custom options. @@ -86,7 +99,29 @@ */ - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options - progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock; + +/** + * Set the imageView `highlightedImage` with an `url`, custom options and context. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + * @param progressBlock A block called while image is downloading + * @note the progress block is executed on a background queue + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrieved from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock; @end diff --git a/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m b/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m index fb13bd8b..c2b4dcaa 100644 --- a/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m +++ b/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m @@ -13,6 +13,8 @@ #import "UIView+WebCacheOperation.h" #import "UIView+WebCache.h" +static NSString * const SDHighlightedImageOperationKey = @"UIImageViewImageOperationHighlighted"; + @implementation UIImageView (HighlightedWebCache) - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url { @@ -23,6 +25,10 @@ - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageO [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; } +- (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context { + [self sd_setHighlightedImageWithURL:url options:options context:context progress:nil completed:nil]; +} + - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock { [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; } @@ -31,20 +37,37 @@ - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageO [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; } +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:options context:nil progress:progressBlock completed:completedBlock]; +} + - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options - progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { - __weak typeof(self)weakSelf = self; + @weakify(self); + SDWebImageMutableContext *mutableContext; + if (context) { + mutableContext = [context mutableCopy]; + } else { + mutableContext = [NSMutableDictionary dictionary]; + } + mutableContext[SDWebImageContextSetImageOperationKey] = SDHighlightedImageOperationKey; [self sd_internalSetImageWithURL:url placeholderImage:nil options:options - operationKey:@"UIImageViewImageOperationHighlighted" - setImageBlock:^(UIImage *image, NSData *imageData) { - weakSelf.highlightedImage = image; + context:mutableContext + setImageBlock:^(UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { + @strongify(self); + self.highlightedImage = image; } progress:progressBlock - completed:completedBlock]; + completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType, imageURL); + } + }]; } @end diff --git a/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h b/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h index b1d954f9..844081f8 100644 --- a/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h +++ b/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h @@ -7,9 +7,6 @@ */ #import "SDWebImageCompat.h" - -#if SD_UIKIT || SD_MAC - #import "SDWebImageManager.h" /** @@ -30,11 +27,10 @@ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] - autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]; } - // Here we use the provided sd_setImageWithURL: method to load the web image + // Here we use the provided sd_setImageWithURL:placeholderImage: method to load the web image // Ensure you use a placeholder image otherwise cells will be initialized with no image [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder"]]; @@ -54,7 +50,7 @@ * * @param url The url for the image. */ -- (void)sd_setImageWithURL:(nullable NSURL *)url; +- (void)sd_setImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT; /** * Set the imageView `image` with an `url` and a placeholder. @@ -66,7 +62,7 @@ * @see sd_setImageWithURL:placeholderImage:options: */ - (void)sd_setImageWithURL:(nullable NSURL *)url - placeholderImage:(nullable UIImage *)placeholder; + placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT; /** * Set the imageView `image` with an `url`, placeholder and custom options. @@ -79,7 +75,22 @@ */ - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder - options:(SDWebImageOptions)options; + options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT; + +/** + * Set the imageView `image` with an `url`, placeholder, custom options and context. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + */ +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context; /** * Set the imageView `image` with an `url`. @@ -111,7 +122,7 @@ */ - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder - completed:(nullable SDExternalCompletionBlock)completedBlock; + completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT; /** * Set the imageView `image` with an `url`, placeholder and custom options. @@ -151,17 +162,18 @@ - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options - progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock + progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock; /** - * Set the imageView `image` with an `url` and optionally a placeholder image. + * Set the imageView `image` with an `url`, placeholder, custom options and context. * * The download is asynchronous and cached. * * @param url The url for the image. * @param placeholder The image to be set initially, until the image request finishes. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. * @param progressBlock A block called while image is downloading * @note the progress block is executed on a background queue * @param completedBlock A block called when operation has been completed. This block has no return value @@ -170,27 +182,11 @@ * indicating if the image was retrieved from the local cache or from the network. * The fourth parameter is the original image url. */ -- (void)sd_setImageWithPreviousCachedImageWithURL:(nullable NSURL *)url - placeholderImage:(nullable UIImage *)placeholder - options:(SDWebImageOptions)options - progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock - completed:(nullable SDExternalCompletionBlock)completedBlock; - -#if SD_UIKIT - -#pragma mark - Animation of multiple images - -/** - * Download an array of images and starts them in an animation loop - * - * @param arrayOfURLs An array of NSURL - */ -- (void)sd_setAnimationImagesWithURLs:(nonnull NSArray *)arrayOfURLs; - -- (void)sd_cancelCurrentAnimationImagesLoad; - -#endif +- (void)sd_setImageWithURL:(nullable NSURL *)url + placeholderImage:(nullable UIImage *)placeholder + options:(SDWebImageOptions)options + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDExternalCompletionBlock)completedBlock; @end - -#endif diff --git a/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m b/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m index 81f687ef..9d7f18e7 100644 --- a/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m +++ b/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m @@ -7,9 +7,6 @@ */ #import "UIImageView+WebCache.h" - -#if SD_UIKIT || SD_MAC - #import "objc/runtime.h" #import "UIView+WebCacheOperation.h" #import "UIView+WebCache.h" @@ -28,6 +25,10 @@ - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIIm [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; } +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:context progress:nil completed:nil]; +} + - (void)sd_setImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock { [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; } @@ -40,71 +41,27 @@ - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIIm [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; } +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock]; +} + - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options - progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock + context:(nullable SDWebImageContext *)context + progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock { [self sd_internalSetImageWithURL:url placeholderImage:placeholder options:options - operationKey:nil + context:context setImageBlock:nil progress:progressBlock - completed:completedBlock]; -} - -- (void)sd_setImageWithPreviousCachedImageWithURL:(nullable NSURL *)url - placeholderImage:(nullable UIImage *)placeholder - options:(SDWebImageOptions)options - progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock - completed:(nullable SDExternalCompletionBlock)completedBlock { - NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:url]; - UIImage *lastPreviousCachedImage = [[SDImageCache sharedImageCache] imageFromCacheForKey:key]; - - [self sd_setImageWithURL:url placeholderImage:lastPreviousCachedImage ?: placeholder options:options progress:progressBlock completed:completedBlock]; + completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType, imageURL); + } + }]; } -#if SD_UIKIT - -#pragma mark - Animation of multiple images - -- (void)sd_setAnimationImagesWithURLs:(nonnull NSArray *)arrayOfURLs { - [self sd_cancelCurrentAnimationImagesLoad]; - __weak __typeof(self)wself = self; - - NSMutableArray> *operationsArray = [[NSMutableArray alloc] init]; - - for (NSURL *logoImageURL in arrayOfURLs) { - id operation = [SDWebImageManager.sharedManager loadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (!wself) return; - dispatch_main_async_safe(^{ - __strong UIImageView *sself = wself; - [sself stopAnimating]; - if (sself && image) { - NSMutableArray *currentImages = [[sself animationImages] mutableCopy]; - if (!currentImages) { - currentImages = [[NSMutableArray alloc] init]; - } - [currentImages addObject:image]; - - sself.animationImages = currentImages; - [sself setNeedsLayout]; - } - [sself startAnimating]; - }); - }]; - [operationsArray addObject:operation]; - } - - [self sd_setImageLoadOperation:[operationsArray copy] forKey:@"UIImageViewAnimationImages"]; -} - -- (void)sd_cancelCurrentAnimationImagesLoad { - [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"]; -} -#endif - @end - -#endif diff --git a/Pods/SDWebImage/SDWebImage/UIView+WebCache.h b/Pods/SDWebImage/SDWebImage/UIView+WebCache.h index 4c575194..42d83054 100644 --- a/Pods/SDWebImage/SDWebImage/UIView+WebCache.h +++ b/Pods/SDWebImage/SDWebImage/UIView+WebCache.h @@ -7,22 +7,35 @@ */ #import "SDWebImageCompat.h" - -#if SD_UIKIT || SD_MAC - +#import "SDWebImageDefine.h" #import "SDWebImageManager.h" +#import "SDWebImageTransition.h" +#import "SDWebImageIndicator.h" -typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable imageData); +/** + The value specify that the image progress unit count cannot be determined because the progressBlock is not been called. + */ +FOUNDATION_EXPORT const int64_t SDWebImageProgressUnitCountUnknown; /* 1LL */ + +typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL); @interface UIView (WebCache) /** * Get the current image URL. * - * Note that because of the limitations of categories this property can get out of sync - * if you use setImage: directly. + * @note Note that because of the limitations of categories this property can get out of sync if you use setImage: directly. + */ +@property (nonatomic, strong, readonly, nullable) NSURL *sd_imageURL; + +/** + * The current image loading progress associated to the view. The unit count is the received size and excepted size of download. + * The `totalUnitCount` and `completedUnitCount` will be reset to 0 after a new image loading start (change from current queue). And they will be set to `SDWebImageProgressUnitCountUnknown` if the progressBlock not been called but the image loading success to mark the progress finished (change from main queue). + * @note You can use Key-Value Observing on the progress, but you should take care that the change to progress is from a background queue during download(the same as progressBlock). If you want to using KVO and update the UI, make sure to dispatch on the main queue. And it's recommand to use some KVO libs like KVOController because it's more safe and easy to use. + * @note The getter will create a progress instance if the value is nil. You can also set a custom progress instance and let it been updated during image loading + * @note Note that because of the limitations of categories this property can get out of sync if you update the progress directly. */ -- (nullable NSURL *)sd_imageURL; +@property (nonatomic, strong, null_resettable) NSProgress *sd_imageProgress; /** * Set the imageView `image` with an `url` and optionally a placeholder image. @@ -32,51 +45,54 @@ typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable ima * @param url The url for the image. * @param placeholder The image to be set initially, until the image request finishes. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - * @param operationKey A string to be used as the operation key. If nil, will use the class name - * @param setImageBlock Block used for custom set image code + * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold. + * @param setImageBlock Block used for custom set image code. If not provide, use the built-in set image code (supports `UIImageView/NSImageView` and `UIButton/NSButton` currently) * @param progressBlock A block called while image is downloading * @note the progress block is executed on a background queue - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrieved from the local cache or from the network. - * The fourth parameter is the original image url. + * @param completedBlock A block called when operation has been completed. + * This block has no return value and takes the requested UIImage as first parameter and the NSData representation as second parameter. + * In case of error the image parameter is nil and the third parameter may contain an NSError. + * + * The forth parameter is an `SDImageCacheType` enum indicating if the image was retrieved from the local cache + * or from the memory cache or from the network. + * + * The fith parameter normally is always YES. However, if you provide SDWebImageAvoidAutoSetImage with SDWebImageProgressiveLoad options to enable progressive downloading and set the image yourself. This block is thus called repeatedly with a partial image. When image is fully downloaded, the + * block is called a last time with the full image and the last parameter set to YES. + * + * The last parameter is the original image URL */ - (void)sd_internalSetImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options - operationKey:(nullable NSString *)operationKey + context:(nullable SDWebImageContext *)context setImageBlock:(nullable SDSetImageBlock)setImageBlock - progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock - completed:(nullable SDExternalCompletionBlock)completedBlock; + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDInternalCompletionBlock)completedBlock; /** - * Cancel the current download + * Cancel the current image load */ - (void)sd_cancelCurrentImageLoad; -#if SD_UIKIT +#if SD_UIKIT || SD_MAC -#pragma mark - Activity indicator +#pragma mark - Image Transition /** - * Show activity UIActivityIndicatorView + The image transition when image load finished. See `SDWebImageTransition`. + If you specify nil, do not do transition. Defautls to nil. */ -- (void)sd_setShowActivityIndicatorView:(BOOL)show; +@property (nonatomic, strong, nullable) SDWebImageTransition *sd_imageTransition; + +#pragma mark - Image Indicator /** - * set desired UIActivityIndicatorViewStyle - * - * @param style The style of the UIActivityIndicatorView + The image indicator during the image loading. If you do not need indicator, specify nil. Defaults to nil + The setter will remove the old indicator view and add new indicator view to current view's subview. + @note Because this is UI related, you should access only from the main queue. */ -- (void)sd_setIndicatorStyle:(UIActivityIndicatorViewStyle)style; - -- (BOOL)sd_showActivityIndicatorView; -- (void)sd_addActivityIndicator; -- (void)sd_removeActivityIndicator; +@property (nonatomic, strong, nullable) id sd_imageIndicator; #endif @end - -#endif diff --git a/Pods/SDWebImage/SDWebImage/UIView+WebCache.m b/Pods/SDWebImage/SDWebImage/UIView+WebCache.m index ad2b54c4..cb470c6c 100644 --- a/Pods/SDWebImage/SDWebImage/UIView+WebCache.m +++ b/Pods/SDWebImage/SDWebImage/UIView+WebCache.m @@ -7,194 +7,345 @@ */ #import "UIView+WebCache.h" - -#if SD_UIKIT || SD_MAC - #import "objc/runtime.h" #import "UIView+WebCacheOperation.h" +#import "SDWebImageError.h" -static char imageURLKey; - -#if SD_UIKIT -static char TAG_ACTIVITY_INDICATOR; -static char TAG_ACTIVITY_STYLE; -#endif -static char TAG_ACTIVITY_SHOW; +const int64_t SDWebImageProgressUnitCountUnknown = 1LL; @implementation UIView (WebCache) - (nullable NSURL *)sd_imageURL { - return objc_getAssociatedObject(self, &imageURLKey); + return objc_getAssociatedObject(self, @selector(sd_imageURL)); +} + +- (void)setSd_imageURL:(NSURL * _Nullable)sd_imageURL { + objc_setAssociatedObject(self, @selector(sd_imageURL), sd_imageURL, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (nullable NSString *)sd_latestOperationKey { + return objc_getAssociatedObject(self, @selector(sd_latestOperationKey)); +} + +- (void)setSd_latestOperationKey:(NSString * _Nullable)sd_latestOperationKey { + objc_setAssociatedObject(self, @selector(sd_latestOperationKey), sd_latestOperationKey, OBJC_ASSOCIATION_COPY_NONATOMIC); +} + +- (NSProgress *)sd_imageProgress { + NSProgress *progress = objc_getAssociatedObject(self, @selector(sd_imageProgress)); + if (!progress) { + progress = [[NSProgress alloc] initWithParent:nil userInfo:nil]; + self.sd_imageProgress = progress; + } + return progress; +} + +- (void)setSd_imageProgress:(NSProgress *)sd_imageProgress { + objc_setAssociatedObject(self, @selector(sd_imageProgress), sd_imageProgress, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } - (void)sd_internalSetImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options - operationKey:(nullable NSString *)operationKey + context:(nullable SDWebImageContext *)context setImageBlock:(nullable SDSetImageBlock)setImageBlock - progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock - completed:(nullable SDExternalCompletionBlock)completedBlock { - NSString *validOperationKey = operationKey ?: NSStringFromClass([self class]); + progress:(nullable SDImageLoaderProgressBlock)progressBlock + completed:(nullable SDInternalCompletionBlock)completedBlock { + context = [context copy]; // copy to avoid mutable object + NSString *validOperationKey = context[SDWebImageContextSetImageOperationKey]; + if (!validOperationKey) { + validOperationKey = NSStringFromClass([self class]); + } + self.sd_latestOperationKey = validOperationKey; [self sd_cancelImageLoadOperationWithKey:validOperationKey]; - objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + self.sd_imageURL = url; if (!(options & SDWebImageDelayPlaceholder)) { dispatch_main_async_safe(^{ - [self sd_setImage:placeholder imageData:nil basedOnClassOrViaCustomSetImageBlock:setImageBlock]; + [self sd_setImage:placeholder imageData:nil basedOnClassOrViaCustomSetImageBlock:setImageBlock cacheType:SDImageCacheTypeNone imageURL:url]; }); } if (url) { - // check if activityView is enabled or not - if ([self sd_showActivityIndicatorView]) { - [self sd_addActivityIndicator]; + // reset the progress + self.sd_imageProgress.totalUnitCount = 0; + self.sd_imageProgress.completedUnitCount = 0; + +#if SD_UIKIT || SD_MAC + // check and start image indicator + [self sd_startImageIndicator]; + id imageIndicator = self.sd_imageIndicator; +#endif + + SDWebImageManager *manager = context[SDWebImageContextCustomManager]; + if (!manager) { + manager = [SDWebImageManager sharedManager]; } - __weak __typeof(self)wself = self; - id operation = [SDWebImageManager.sharedManager loadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - __strong __typeof (wself) sself = wself; - [sself sd_removeActivityIndicator]; - if (!sself) { - return; + @weakify(self); + SDImageLoaderProgressBlock combinedProgressBlock = ^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) { + @strongify(self); + NSProgress *imageProgress = self.sd_imageProgress; + imageProgress.totalUnitCount = expectedSize; + imageProgress.completedUnitCount = receivedSize; +#if SD_UIKIT || SD_MAC + if ([imageIndicator respondsToSelector:@selector(updateIndicatorProgress:)]) { + double progress = imageProgress.fractionCompleted; + dispatch_async(dispatch_get_main_queue(), ^{ + [imageIndicator updateIndicatorProgress:progress]; + }); } - dispatch_main_async_safe(^{ - if (!sself) { - return; - } - if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) { - completedBlock(image, error, cacheType, url); - return; - } else if (image) { - [sself sd_setImage:image imageData:data basedOnClassOrViaCustomSetImageBlock:setImageBlock]; - [sself sd_setNeedsLayout]; - } else { - if ((options & SDWebImageDelayPlaceholder)) { - [sself sd_setImage:placeholder imageData:nil basedOnClassOrViaCustomSetImageBlock:setImageBlock]; - [sself sd_setNeedsLayout]; - } +#endif + if (progressBlock) { + progressBlock(receivedSize, expectedSize, targetURL); + } + }; + id operation = [manager loadImageWithURL:url options:options context:context progress:combinedProgressBlock completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + @strongify(self); + if (!self) { return; } + // if the progress not been updated, mark it to complete state + if (finished && !error && self.sd_imageProgress.totalUnitCount == 0 && self.sd_imageProgress.completedUnitCount == 0) { + self.sd_imageProgress.totalUnitCount = SDWebImageProgressUnitCountUnknown; + self.sd_imageProgress.completedUnitCount = SDWebImageProgressUnitCountUnknown; + } + +#if SD_UIKIT || SD_MAC + // check and stop image indicator + if (finished) { + [self sd_stopImageIndicator]; + } +#endif + + BOOL shouldCallCompletedBlock = finished || (options & SDWebImageAvoidAutoSetImage); + BOOL shouldNotSetImage = ((image && (options & SDWebImageAvoidAutoSetImage)) || + (!image && !(options & SDWebImageDelayPlaceholder))); + SDWebImageNoParamsBlock callCompletedBlockClojure = ^{ + if (!self) { return; } + if (!shouldNotSetImage) { + [self sd_setNeedsLayout]; } - if (completedBlock && finished) { - completedBlock(image, error, cacheType, url); + if (completedBlock && shouldCallCompletedBlock) { + completedBlock(image, data, error, cacheType, finished, url); } + }; + + // case 1a: we got an image, but the SDWebImageAvoidAutoSetImage flag is set + // OR + // case 1b: we got no image and the SDWebImageDelayPlaceholder is not set + if (shouldNotSetImage) { + dispatch_main_async_safe(callCompletedBlockClojure); + return; + } + + UIImage *targetImage = nil; + NSData *targetData = nil; + if (image) { + // case 2a: we got an image and the SDWebImageAvoidAutoSetImage is not set + targetImage = image; + targetData = data; + } else if (options & SDWebImageDelayPlaceholder) { + // case 2b: we got no image and the SDWebImageDelayPlaceholder flag is set + targetImage = placeholder; + targetData = nil; + } + +#if SD_UIKIT || SD_MAC + // check whether we should use the image transition + SDWebImageTransition *transition = nil; + if (finished && (options & SDWebImageForceTransition || cacheType == SDImageCacheTypeNone)) { + transition = self.sd_imageTransition; + } +#endif + dispatch_main_async_safe(^{ +#if SD_UIKIT || SD_MAC + [self sd_setImage:targetImage imageData:targetData basedOnClassOrViaCustomSetImageBlock:setImageBlock transition:transition cacheType:cacheType imageURL:imageURL]; +#else + [self sd_setImage:targetImage imageData:targetData basedOnClassOrViaCustomSetImageBlock:setImageBlock cacheType:cacheType imageURL:imageURL]; +#endif + callCompletedBlockClojure(); }); }]; [self sd_setImageLoadOperation:operation forKey:validOperationKey]; } else { +#if SD_UIKIT || SD_MAC + [self sd_stopImageIndicator]; +#endif dispatch_main_async_safe(^{ - [self sd_removeActivityIndicator]; if (completedBlock) { - NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; - completedBlock(nil, error, SDImageCacheTypeNone, url); + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:SDWebImageErrorInvalidURL userInfo:@{NSLocalizedDescriptionKey : @"Image url is nil"}]; + completedBlock(nil, nil, error, SDImageCacheTypeNone, YES, url); } }); } } - (void)sd_cancelCurrentImageLoad { - [self sd_cancelImageLoadOperationWithKey:NSStringFromClass([self class])]; + [self sd_cancelImageLoadOperationWithKey:self.sd_latestOperationKey]; } -- (void)sd_setImage:(UIImage *)image imageData:(NSData *)imageData basedOnClassOrViaCustomSetImageBlock:(SDSetImageBlock)setImageBlock { +- (void)sd_setImage:(UIImage *)image imageData:(NSData *)imageData basedOnClassOrViaCustomSetImageBlock:(SDSetImageBlock)setImageBlock cacheType:(SDImageCacheType)cacheType imageURL:(NSURL *)imageURL { +#if SD_UIKIT || SD_MAC + [self sd_setImage:image imageData:imageData basedOnClassOrViaCustomSetImageBlock:setImageBlock transition:nil cacheType:cacheType imageURL:imageURL]; +#else + // watchOS does not support view transition. Simplify the logic if (setImageBlock) { - setImageBlock(image, imageData); - return; + setImageBlock(image, imageData, cacheType, imageURL); + } else if ([self isKindOfClass:[UIImageView class]]) { + UIImageView *imageView = (UIImageView *)self; + [imageView setImage:image]; } - +#endif +} + #if SD_UIKIT || SD_MAC - if ([self isKindOfClass:[UIImageView class]]) { - UIImageView *imageView = (UIImageView *)self; - imageView.image = image; +- (void)sd_setImage:(UIImage *)image imageData:(NSData *)imageData basedOnClassOrViaCustomSetImageBlock:(SDSetImageBlock)setImageBlock transition:(SDWebImageTransition *)transition cacheType:(SDImageCacheType)cacheType imageURL:(NSURL *)imageURL { + UIView *view = self; + SDSetImageBlock finalSetImageBlock; + if (setImageBlock) { + finalSetImageBlock = setImageBlock; + } else if ([view isKindOfClass:[UIImageView class]]) { + UIImageView *imageView = (UIImageView *)view; + finalSetImageBlock = ^(UIImage *setImage, NSData *setImageData, SDImageCacheType setCacheType, NSURL *setImageURL) { + imageView.image = setImage; + }; + } +#if SD_UIKIT + else if ([view isKindOfClass:[UIButton class]]) { + UIButton *button = (UIButton *)view; + finalSetImageBlock = ^(UIImage *setImage, NSData *setImageData, SDImageCacheType setCacheType, NSURL *setImageURL) { + [button setImage:setImage forState:UIControlStateNormal]; + }; + } +#endif +#if SD_MAC + else if ([view isKindOfClass:[NSButton class]]) { + NSButton *button = (NSButton *)view; + finalSetImageBlock = ^(UIImage *setImage, NSData *setImageData, SDImageCacheType setCacheType, NSURL *setImageURL) { + button.image = setImage; + }; } #endif + if (transition) { #if SD_UIKIT - if ([self isKindOfClass:[UIButton class]]) { - UIButton *button = (UIButton *)self; - [button setImage:image forState:UIControlStateNormal]; - } + [UIView transitionWithView:view duration:0 options:0 animations:^{ + // 0 duration to let UIKit render placeholder and prepares block + if (transition.prepares) { + transition.prepares(view, image, imageData, cacheType, imageURL); + } + } completion:^(BOOL finished) { + [UIView transitionWithView:view duration:transition.duration options:transition.animationOptions animations:^{ + if (finalSetImageBlock && !transition.avoidAutoSetImage) { + finalSetImageBlock(image, imageData, cacheType, imageURL); + } + if (transition.animations) { + transition.animations(view, image); + } + } completion:transition.completion]; + }]; +#elif SD_MAC + [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull prepareContext) { + // 0 duration to let AppKit render placeholder and prepares block + prepareContext.duration = 0; + if (transition.prepares) { + transition.prepares(view, image, imageData, cacheType, imageURL); + } + } completionHandler:^{ + [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) { + context.duration = transition.duration; + context.timingFunction = transition.timingFunction; + context.allowsImplicitAnimation = (transition.animationOptions & SDWebImageAnimationOptionAllowsImplicitAnimation); + if (finalSetImageBlock && !transition.avoidAutoSetImage) { + finalSetImageBlock(image, imageData, cacheType, imageURL); + } + if (transition.animations) { + transition.animations(view, image); + } + } completionHandler:^{ + if (transition.completion) { + transition.completion(YES); + } + }]; + }]; #endif + } else { + if (finalSetImageBlock) { + finalSetImageBlock(image, imageData, cacheType, imageURL); + } + } } +#endif - (void)sd_setNeedsLayout { #if SD_UIKIT [self setNeedsLayout]; #elif SD_MAC [self setNeedsLayout:YES]; +#elif SD_WATCH + // Do nothing because WatchKit automatically layout the view after property change #endif } -#pragma mark - Activity indicator - -#pragma mark - -#if SD_UIKIT -- (UIActivityIndicatorView *)activityIndicator { - return (UIActivityIndicatorView *)objc_getAssociatedObject(self, &TAG_ACTIVITY_INDICATOR); -} +#if SD_UIKIT || SD_MAC -- (void)setActivityIndicator:(UIActivityIndicatorView *)activityIndicator { - objc_setAssociatedObject(self, &TAG_ACTIVITY_INDICATOR, activityIndicator, OBJC_ASSOCIATION_RETAIN); +#pragma mark - Image Transition +- (SDWebImageTransition *)sd_imageTransition { + return objc_getAssociatedObject(self, @selector(sd_imageTransition)); } -#endif -- (void)sd_setShowActivityIndicatorView:(BOOL)show { - objc_setAssociatedObject(self, &TAG_ACTIVITY_SHOW, @(show), OBJC_ASSOCIATION_RETAIN); +- (void)setSd_imageTransition:(SDWebImageTransition *)sd_imageTransition { + objc_setAssociatedObject(self, @selector(sd_imageTransition), sd_imageTransition, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } -- (BOOL)sd_showActivityIndicatorView { - return [objc_getAssociatedObject(self, &TAG_ACTIVITY_SHOW) boolValue]; +#pragma mark - Indicator +- (id)sd_imageIndicator { + return objc_getAssociatedObject(self, @selector(sd_imageIndicator)); } -#if SD_UIKIT -- (void)sd_setIndicatorStyle:(UIActivityIndicatorViewStyle)style{ - objc_setAssociatedObject(self, &TAG_ACTIVITY_STYLE, [NSNumber numberWithInt:style], OBJC_ASSOCIATION_RETAIN); +- (void)setSd_imageIndicator:(id)sd_imageIndicator { + // Remove the old indicator view + id previousIndicator = self.sd_imageIndicator; + [previousIndicator.indicatorView removeFromSuperview]; + + objc_setAssociatedObject(self, @selector(sd_imageIndicator), sd_imageIndicator, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + + // Add the new indicator view + UIView *view = sd_imageIndicator.indicatorView; + if (CGRectEqualToRect(view.frame, CGRectZero)) { + view.frame = self.bounds; + } + // Center the indicator view +#if SD_MAC + CGPoint center = CGPointMake(NSMidX(self.bounds), NSMidY(self.bounds)); + NSRect frame = view.frame; + view.frame = NSMakeRect(center.x - NSMidX(frame), center.y - NSMidY(frame), NSWidth(frame), NSHeight(frame)); +#else + view.center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); +#endif + view.hidden = NO; + [self addSubview:view]; } -- (int)sd_getIndicatorStyle{ - return [objc_getAssociatedObject(self, &TAG_ACTIVITY_STYLE) intValue]; +- (void)sd_startImageIndicator { + id imageIndicator = self.sd_imageIndicator; + if (!imageIndicator) { + return; + } + dispatch_main_async_safe(^{ + [imageIndicator startAnimatingIndicator]; + }); } -#endif -- (void)sd_addActivityIndicator { -#if SD_UIKIT - if (!self.activityIndicator) { - self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:[self sd_getIndicatorStyle]]; - self.activityIndicator.translatesAutoresizingMaskIntoConstraints = NO; - - dispatch_main_async_safe(^{ - [self addSubview:self.activityIndicator]; - - [self addConstraint:[NSLayoutConstraint constraintWithItem:self.activityIndicator - attribute:NSLayoutAttributeCenterX - relatedBy:NSLayoutRelationEqual - toItem:self - attribute:NSLayoutAttributeCenterX - multiplier:1.0 - constant:0.0]]; - [self addConstraint:[NSLayoutConstraint constraintWithItem:self.activityIndicator - attribute:NSLayoutAttributeCenterY - relatedBy:NSLayoutRelationEqual - toItem:self - attribute:NSLayoutAttributeCenterY - multiplier:1.0 - constant:0.0]]; - }); +- (void)sd_stopImageIndicator { + id imageIndicator = self.sd_imageIndicator; + if (!imageIndicator) { + return; } - dispatch_main_async_safe(^{ - [self.activityIndicator startAnimating]; + [imageIndicator stopAnimatingIndicator]; }); -#endif } -- (void)sd_removeActivityIndicator { -#if SD_UIKIT - if (self.activityIndicator) { - [self.activityIndicator removeFromSuperview]; - self.activityIndicator = nil; - } #endif -} @end - -#endif diff --git a/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h b/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h index f5e95fa6..65872521 100644 --- a/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h +++ b/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h @@ -7,20 +7,27 @@ */ #import "SDWebImageCompat.h" +#import "SDWebImageOperation.h" -#if SD_UIKIT || SD_MAC - -#import "SDWebImageManager.h" - +// These methods are used to support canceling for UIView image loading, it's designed to be used internal but not external. +// All the stored operations are weak, so it will be dalloced after image loading finished. If you need to store operations, use your own class to keep a strong reference for them. @interface UIView (WebCacheOperation) /** - * Set the image load operation (storage in a UIView based dictionary) + * Get the image load operation for key + * + * @param key key for identifying the operations + * @return the image load operation + */ +- (nullable id)sd_imageLoadOperationForKey:(nullable NSString *)key; + +/** + * Set the image load operation (storage in a UIView based weak map table) * * @param operation the operation * @param key key for storing the operation */ -- (void)sd_setImageLoadOperation:(nullable id)operation forKey:(nullable NSString *)key; +- (void)sd_setImageLoadOperation:(nullable id)operation forKey:(nullable NSString *)key; /** * Cancel all operations for the current UIView and key @@ -37,5 +44,3 @@ - (void)sd_removeImageLoadOperationWithKey:(nullable NSString *)key; @end - -#endif diff --git a/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m b/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m index a515a74f..83cec8aa 100644 --- a/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m +++ b/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m @@ -7,62 +7,78 @@ */ #import "UIView+WebCacheOperation.h" - -#if SD_UIKIT || SD_MAC - #import "objc/runtime.h" static char loadOperationKey; -typedef NSMutableDictionary SDOperationsDictionary; +// key is strong, value is weak because operation instance is retained by SDWebImageManager's runningOperations property +// we should use lock to keep thread-safe because these method may not be acessed from main queue +typedef NSMapTable> SDOperationsDictionary; @implementation UIView (WebCacheOperation) -- (SDOperationsDictionary *)operationDictionary { - SDOperationsDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); - if (operations) { +- (SDOperationsDictionary *)sd_operationDictionary { + @synchronized(self) { + SDOperationsDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); + if (operations) { + return operations; + } + operations = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory valueOptions:NSPointerFunctionsWeakMemory capacity:0]; + objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); return operations; } - operations = [NSMutableDictionary dictionary]; - objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - return operations; } -- (void)sd_setImageLoadOperation:(nullable id)operation forKey:(nullable NSString *)key { +- (nullable id)sd_imageLoadOperationForKey:(nullable NSString *)key { + id operation; + if (key) { + SDOperationsDictionary *operationDictionary = [self sd_operationDictionary]; + @synchronized (self) { + operation = [operationDictionary objectForKey:key]; + } + } + return operation; +} + +- (void)sd_setImageLoadOperation:(nullable id)operation forKey:(nullable NSString *)key { if (key) { [self sd_cancelImageLoadOperationWithKey:key]; if (operation) { - SDOperationsDictionary *operationDictionary = [self operationDictionary]; - operationDictionary[key] = operation; + SDOperationsDictionary *operationDictionary = [self sd_operationDictionary]; + @synchronized (self) { + [operationDictionary setObject:operation forKey:key]; + } } } } - (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key { - // Cancel in progress downloader from queue - SDOperationsDictionary *operationDictionary = [self operationDictionary]; - id operations = operationDictionary[key]; - if (operations) { - if ([operations isKindOfClass:[NSArray class]]) { - for (id operation in operations) { - if (operation) { - [operation cancel]; - } + if (key) { + // Cancel in progress downloader from queue + SDOperationsDictionary *operationDictionary = [self sd_operationDictionary]; + id operation; + + @synchronized (self) { + operation = [operationDictionary objectForKey:key]; + } + if (operation) { + if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]) { + [operation cancel]; + } + @synchronized (self) { + [operationDictionary removeObjectForKey:key]; } - } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ - [(id) operations cancel]; } - [operationDictionary removeObjectForKey:key]; } } - (void)sd_removeImageLoadOperationWithKey:(nullable NSString *)key { if (key) { - SDOperationsDictionary *operationDictionary = [self operationDictionary]; - [operationDictionary removeObjectForKey:key]; + SDOperationsDictionary *operationDictionary = [self sd_operationDictionary]; + @synchronized (self) { + [operationDictionary removeObjectForKey:key]; + } } } @end - -#endif diff --git a/Pods/SDWebImage/WebImage/SDWebImage.h b/Pods/SDWebImage/WebImage/SDWebImage.h new file mode 100644 index 00000000..b09d2d1d --- /dev/null +++ b/Pods/SDWebImage/WebImage/SDWebImage.h @@ -0,0 +1,84 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * (c) Florent Vilmart + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import + +#if SD_UIKIT +#import +#endif + +//! Project version number for WebImage. +FOUNDATION_EXPORT double WebImageVersionNumber; + +//! Project version string for WebImage. +FOUNDATION_EXPORT const unsigned char WebImageVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import + +// Mac +#if __has_include() +#import +#endif +#if __has_include() +#import +#endif +#if __has_include() +#import +#endif + +// MapKit +#if __has_include() +#import +#endif diff --git a/Pods/SDWebImage/WebImage/SDWebImage.modulemap b/Pods/SDWebImage/WebImage/SDWebImage.modulemap new file mode 100644 index 00000000..871087ca --- /dev/null +++ b/Pods/SDWebImage/WebImage/SDWebImage.modulemap @@ -0,0 +1,6 @@ +framework module SDWebImage { + umbrella header "SDWebImage.h" + + export * + module * { export * } +} diff --git a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-acknowledgements.markdown b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-acknowledgements.markdown index b61451ba..8be7b521 100644 --- a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-acknowledgements.markdown +++ b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-acknowledgements.markdown @@ -3,7 +3,7 @@ This application makes use of the following third party libraries: ## SDWebImage -Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com +Copyright (c) 2009-2018 Olivier Poitrey rs@dailymotion.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-acknowledgements.plist b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-acknowledgements.plist index a73280bd..a6c7afc8 100644 --- a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-acknowledgements.plist +++ b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-acknowledgements.plist @@ -14,7 +14,7 @@ FooterText - Copyright (c) 2016 Olivier Poitrey rs@dailymotion.com + Copyright (c) 2009-2018 Olivier Poitrey rs@dailymotion.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-frameworks.sh b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-frameworks.sh index 893c16a6..08e3eaac 100755 --- a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-frameworks.sh +++ b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-frameworks.sh @@ -1,11 +1,28 @@ #!/bin/sh set -e +set -u +set -o pipefail + +if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then + # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy + # frameworks to, so exit 0 (signalling the script phase was successful). + exit 0 +fi echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" +# Used as a return value for each invocation of `strip_invalid_archs` function. +STRIP_BINARY_RETVAL=0 + +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +# Copies and strips a vendored framework install_framework() { if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then @@ -23,9 +40,9 @@ install_framework() source="$(readlink "${source}")" fi - # use filter instead of exclude so missing patterns dont' throw errors - echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" - rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + # Use filter instead of exclude so missing patterns don't throw errors. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" local basename basename="$(basename -s .framework "$1")" @@ -54,24 +71,65 @@ install_framework() fi } +# Copies and strips a vendored dSYM +install_dsym() { + local source="$1" + if [ -r "$source" ]; then + # Copy the dSYM into a the targets temp dir. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" + + local basename + basename="$(basename -s .framework.dSYM "$source")" + binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then + strip_invalid_archs "$binary" + fi + + if [[ $STRIP_BINARY_RETVAL == 1 ]]; then + # Move the stripped file into its final destination. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" + else + # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. + touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" + fi + fi +} + # Signs a framework with the provided identity code_sign_if_enabled() { - if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then # Use the current code_sign_identitiy echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" - echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" - /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" + local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" + + if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + code_sign_cmd="$code_sign_cmd &" + fi + echo "$code_sign_cmd" + eval "$code_sign_cmd" fi } # Strip invalid architectures strip_invalid_archs() { binary="$1" - # Get architectures for current file - archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" + # Get architectures for current target binary + binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" + # Intersect them with the architectures we are building for + intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" + # If there are no archs supported by this binary then warn the user + if [[ -z "$intersected_archs" ]]; then + echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." + STRIP_BINARY_RETVAL=0 + return + fi stripped="" - for arch in $archs; do - if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then + for arch in $binary_archs; do + if ! [[ "${ARCHS}" == *"$arch"* ]]; then # Strip non-valid architectures in-place lipo -remove "$arch" -output "$binary" "$binary" || exit 1 stripped="$stripped $arch" @@ -80,5 +138,9 @@ strip_invalid_archs() { if [[ "$stripped" ]]; then echo "Stripped $binary of architectures:$stripped" fi + STRIP_BINARY_RETVAL=1 } +if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + wait +fi diff --git a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-resources.sh b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-resources.sh index 25e9d377..345301f2 100755 --- a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-resources.sh +++ b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-resources.sh @@ -1,5 +1,13 @@ #!/bin/sh set -e +set -u +set -o pipefail + +if [ -z ${UNLOCALIZED_RESOURCES_FOLDER_PATH+x} ]; then + # If UNLOCALIZED_RESOURCES_FOLDER_PATH is not set, then there's nowhere for us to copy + # resources to, so exit 0 (signalling the script phase was successful). + exit 0 +fi mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" @@ -8,7 +16,11 @@ RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt XCASSET_FILES=() -case "${TARGETED_DEVICE_FAMILY}" in +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +case "${TARGETED_DEVICE_FAMILY:-}" in 1,2) TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" ;; @@ -18,6 +30,12 @@ case "${TARGETED_DEVICE_FAMILY}" in 2) TARGET_DEVICE_ARGS="--target-device ipad" ;; + 3) + TARGET_DEVICE_ARGS="--target-device tv" + ;; + 4) + TARGET_DEVICE_ARGS="--target-device watch" + ;; *) TARGET_DEVICE_ARGS="--target-device mac" ;; @@ -38,29 +56,29 @@ EOM fi case $RESOURCE_PATH in *.storyboard) - echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} ;; *.xib) - echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} ;; *.framework) - echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" - echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" - rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" ;; *.xcdatamodel) - echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" ;; *.xcdatamodeld) - echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" ;; *.xcmappingmodel) - echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" + echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" ;; *.xcassets) @@ -68,7 +86,7 @@ EOM XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") ;; *) - echo "$RESOURCE_PATH" + echo "$RESOURCE_PATH" || true echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" ;; esac @@ -82,7 +100,7 @@ if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then fi rm -f "$RESOURCES_TO_COPY" -if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "${XCASSET_FILES:-}" ] then # Find all other xcassets (this unfortunately includes those of path pods and other targets). OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) @@ -92,5 +110,9 @@ then fi done <<<"$OTHER_XCASSETS" - printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + if [ -z ${ASSETCATALOG_COMPILER_APPICON_NAME+x} ]; then + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + else + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${TARGET_TEMP_DIR}/assetcatalog_generated_info_cocoapods.plist" + fi fi diff --git a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView.debug.xcconfig b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView.debug.xcconfig index 6a816758..3262d0bf 100644 --- a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView.debug.xcconfig +++ b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView.debug.xcconfig @@ -1,9 +1,9 @@ -ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SDWebImage" -LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SDWebImage" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/SDWebImage" OTHER_LDFLAGS = $(inherited) -ObjC -l"SDWebImage" -framework "ImageIO" -PODS_BUILD_DIR = $BUILD_DIR -PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView.release.xcconfig b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView.release.xcconfig index 6a816758..3262d0bf 100644 --- a/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView.release.xcconfig +++ b/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView.release.xcconfig @@ -1,9 +1,9 @@ -ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SDWebImage" -LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/SDWebImage" +LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/SDWebImage" OTHER_LDFLAGS = $(inherited) -ObjC -l"SDWebImage" -framework "ImageIO" -PODS_BUILD_DIR = $BUILD_DIR -PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. PODS_ROOT = ${SRCROOT}/Pods diff --git a/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch b/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch index aa992a4a..d34875a6 100644 --- a/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch +++ b/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch @@ -1,4 +1,13 @@ #ifdef __OBJC__ #import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif #endif +#import "SDInternalMacros.h" diff --git a/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig b/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig index 4fa7a3b1..05b9b8a3 100644 --- a/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig +++ b/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig @@ -1,9 +1,10 @@ -CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/SDWebImage +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SDWebImage" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SDWebImage" +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SDWebImage" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/SDWebImage" OTHER_LDFLAGS = -framework "ImageIO" -PODS_BUILD_DIR = $BUILD_DIR -PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/SDWebImage PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} SKIP_INSTALL = YES diff --git a/SDCycleScrollView.xcodeproj/project.pbxproj b/SDCycleScrollView.xcodeproj/project.pbxproj index f3ab0da0..cebd06f0 100644 --- a/SDCycleScrollView.xcodeproj/project.pbxproj +++ b/SDCycleScrollView.xcodeproj/project.pbxproj @@ -277,8 +277,6 @@ 9900D16A1ABEB2490077A6CB /* Sources */, 9900D16B1ABEB2490077A6CB /* Frameworks */, 9900D16C1ABEB2490077A6CB /* Resources */, - E493DAE9AB9CFD1B50FD213D /* [CP] Embed Pods Frameworks */, - C797362FCF67A7B71DDF0C59 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -382,43 +380,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-SDCycleScrollView-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; - showEnvVarsInLog = 0; - }; - C797362FCF67A7B71DDF0C59 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - E493DAE9AB9CFD1B50FD213D /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SDCycleScrollView/Pods-SDCycleScrollView-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -559,7 +530,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = SDCycleScrollView/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -577,7 +548,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = SDCycleScrollView/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/SDCycleScrollView.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SDCycleScrollView.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/SDCycleScrollView.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SDCycleScrollView.xcworkspace/xcuserdata/gaoshaodong.xcuserdatad/UserInterfaceState.xcuserstate b/SDCycleScrollView.xcworkspace/xcuserdata/gaoshaodong.xcuserdatad/UserInterfaceState.xcuserstate index 83c4cd57..a3346873 100644 Binary files a/SDCycleScrollView.xcworkspace/xcuserdata/gaoshaodong.xcuserdatad/UserInterfaceState.xcuserstate and b/SDCycleScrollView.xcworkspace/xcuserdata/gaoshaodong.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SDCycleScrollView.xcworkspace/xcuserdata/gaoshaodong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/SDCycleScrollView.xcworkspace/xcuserdata/gaoshaodong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 3719d4de..47a399e8 100644 --- a/SDCycleScrollView.xcworkspace/xcuserdata/gaoshaodong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/SDCycleScrollView.xcworkspace/xcuserdata/gaoshaodong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -10,7 +10,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m" - timestampString = "528985415.727425" + timestampString = "576605909.289" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "357" @@ -26,7 +26,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m" - timestampString = "528985415.72778" + timestampString = "576605909.289421" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "359" @@ -42,7 +42,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m" - timestampString = "528985415.728032" + timestampString = "576605909.289712" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "441" @@ -74,7 +74,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m" - timestampString = "528985415.728308" + timestampString = "576605909.2900881" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "584" diff --git a/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m b/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m index 9ccd0ecd..68741e88 100644 --- a/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m +++ b/SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m @@ -477,7 +477,7 @@ - (void)clearCache + (void)clearImagesCache { - [[[SDWebImageManager sharedManager] imageCache] clearDiskOnCompletion:nil]; + [[[SDWebImageManager sharedManager] imageCache] clearWithCacheType:SDImageCacheTypeDisk completion:nil]; } #pragma mark - life circles