Refactory the implementation of that canDecode/canEncode, use single method with Set to check, instead of creating different internal files
This commit is contained in:
parent
53b2420789
commit
6fb20ce312
|
@ -103,7 +103,6 @@
|
||||||
325F7CCB238942AB00AEDFCC /* UIImage+ExtendedCacheData.m in Sources */ = {isa = PBXBuildFile; fileRef = 325F7CC9238942AB00AEDFCC /* UIImage+ExtendedCacheData.m */; };
|
325F7CCB238942AB00AEDFCC /* UIImage+ExtendedCacheData.m in Sources */ = {isa = PBXBuildFile; fileRef = 325F7CC9238942AB00AEDFCC /* UIImage+ExtendedCacheData.m */; };
|
||||||
325F7CCC2389463D00AEDFCC /* UIImage+ExtendedCacheData.m in Sources */ = {isa = PBXBuildFile; fileRef = 325F7CC9238942AB00AEDFCC /* UIImage+ExtendedCacheData.m */; };
|
325F7CCC2389463D00AEDFCC /* UIImage+ExtendedCacheData.m in Sources */ = {isa = PBXBuildFile; fileRef = 325F7CC9238942AB00AEDFCC /* UIImage+ExtendedCacheData.m */; };
|
||||||
325F7CCD2389467800AEDFCC /* UIImage+ExtendedCacheData.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 325F7CC8238942AB00AEDFCC /* UIImage+ExtendedCacheData.h */; };
|
325F7CCD2389467800AEDFCC /* UIImage+ExtendedCacheData.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 325F7CC8238942AB00AEDFCC /* UIImage+ExtendedCacheData.h */; };
|
||||||
3263626B24AEEE94008FB119 /* SDImageAWebPCoderInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 3263626A24AEEE94008FB119 /* SDImageAWebPCoderInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
|
||||||
3263626E24AEEEB0008FB119 /* SDImageAWebPCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 3263626C24AEEEB0008FB119 /* SDImageAWebPCoder.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
3263626E24AEEEB0008FB119 /* SDImageAWebPCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 3263626C24AEEEB0008FB119 /* SDImageAWebPCoder.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
3263626F24AEEEB0008FB119 /* SDImageAWebPCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3263626D24AEEEB0008FB119 /* SDImageAWebPCoder.m */; };
|
3263626F24AEEEB0008FB119 /* SDImageAWebPCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3263626D24AEEEB0008FB119 /* SDImageAWebPCoder.m */; };
|
||||||
326E2F2E236F0B23006F847F /* SDAnimatedImagePlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 326E2F2C236F0B23006F847F /* SDAnimatedImagePlayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
326E2F2E236F0B23006F847F /* SDAnimatedImagePlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 326E2F2C236F0B23006F847F /* SDAnimatedImagePlayer.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
@ -190,7 +189,6 @@
|
||||||
3298655D2337230C0071958B /* SDImageHEICCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3298655B2337230C0071958B /* SDImageHEICCoder.m */; };
|
3298655D2337230C0071958B /* SDImageHEICCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3298655B2337230C0071958B /* SDImageHEICCoder.m */; };
|
||||||
3298655E2337230C0071958B /* SDImageHEICCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3298655B2337230C0071958B /* SDImageHEICCoder.m */; };
|
3298655E2337230C0071958B /* SDImageHEICCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3298655B2337230C0071958B /* SDImageHEICCoder.m */; };
|
||||||
3298655F233723220071958B /* SDImageHEICCoder.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 3298655A2337230C0071958B /* SDImageHEICCoder.h */; };
|
3298655F233723220071958B /* SDImageHEICCoder.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 3298655A2337230C0071958B /* SDImageHEICCoder.h */; };
|
||||||
32986562233737C70071958B /* SDImageHEICCoderInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 32986560233737C70071958B /* SDImageHEICCoderInternal.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
|
||||||
329A185B1FFF5DFD008C9A2F /* UIImage+Metadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 329A18571FFF5DFD008C9A2F /* UIImage+Metadata.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
329A185B1FFF5DFD008C9A2F /* UIImage+Metadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 329A18571FFF5DFD008C9A2F /* UIImage+Metadata.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
329A185F1FFF5DFD008C9A2F /* UIImage+Metadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+Metadata.m */; };
|
329A185F1FFF5DFD008C9A2F /* UIImage+Metadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+Metadata.m */; };
|
||||||
329A18611FFF5DFD008C9A2F /* UIImage+Metadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+Metadata.m */; };
|
329A18611FFF5DFD008C9A2F /* UIImage+Metadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 329A18581FFF5DFD008C9A2F /* UIImage+Metadata.m */; };
|
||||||
|
@ -440,7 +438,6 @@
|
||||||
325F7CC523893B2E00AEDFCC /* SDFileAttributeHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDFileAttributeHelper.m; sourceTree = "<group>"; };
|
325F7CC523893B2E00AEDFCC /* SDFileAttributeHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDFileAttributeHelper.m; sourceTree = "<group>"; };
|
||||||
325F7CC8238942AB00AEDFCC /* UIImage+ExtendedCacheData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "UIImage+ExtendedCacheData.h"; path = "Core/UIImage+ExtendedCacheData.h"; sourceTree = "<group>"; };
|
325F7CC8238942AB00AEDFCC /* UIImage+ExtendedCacheData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "UIImage+ExtendedCacheData.h"; path = "Core/UIImage+ExtendedCacheData.h"; sourceTree = "<group>"; };
|
||||||
325F7CC9238942AB00AEDFCC /* UIImage+ExtendedCacheData.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "UIImage+ExtendedCacheData.m"; path = "Core/UIImage+ExtendedCacheData.m"; sourceTree = "<group>"; };
|
325F7CC9238942AB00AEDFCC /* UIImage+ExtendedCacheData.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "UIImage+ExtendedCacheData.m"; path = "Core/UIImage+ExtendedCacheData.m"; sourceTree = "<group>"; };
|
||||||
3263626A24AEEE94008FB119 /* SDImageAWebPCoderInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDImageAWebPCoderInternal.h; sourceTree = "<group>"; };
|
|
||||||
3263626C24AEEEB0008FB119 /* SDImageAWebPCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDImageAWebPCoder.h; path = Core/SDImageAWebPCoder.h; sourceTree = "<group>"; };
|
3263626C24AEEEB0008FB119 /* SDImageAWebPCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDImageAWebPCoder.h; path = Core/SDImageAWebPCoder.h; sourceTree = "<group>"; };
|
||||||
3263626D24AEEEB0008FB119 /* SDImageAWebPCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDImageAWebPCoder.m; path = Core/SDImageAWebPCoder.m; sourceTree = "<group>"; };
|
3263626D24AEEEB0008FB119 /* SDImageAWebPCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDImageAWebPCoder.m; path = Core/SDImageAWebPCoder.m; sourceTree = "<group>"; };
|
||||||
326E2F2C236F0B23006F847F /* SDAnimatedImagePlayer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SDAnimatedImagePlayer.h; path = Core/SDAnimatedImagePlayer.h; sourceTree = "<group>"; };
|
326E2F2C236F0B23006F847F /* SDAnimatedImagePlayer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SDAnimatedImagePlayer.h; path = Core/SDAnimatedImagePlayer.h; sourceTree = "<group>"; };
|
||||||
|
@ -464,7 +461,6 @@
|
||||||
3290FA031FA478AF0047D20C /* SDImageFrame.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDImageFrame.m; path = Core/SDImageFrame.m; sourceTree = "<group>"; };
|
3290FA031FA478AF0047D20C /* SDImageFrame.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDImageFrame.m; path = Core/SDImageFrame.m; sourceTree = "<group>"; };
|
||||||
3298655A2337230C0071958B /* SDImageHEICCoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SDImageHEICCoder.h; path = Core/SDImageHEICCoder.h; sourceTree = "<group>"; };
|
3298655A2337230C0071958B /* SDImageHEICCoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SDImageHEICCoder.h; path = Core/SDImageHEICCoder.h; sourceTree = "<group>"; };
|
||||||
3298655B2337230C0071958B /* SDImageHEICCoder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDImageHEICCoder.m; path = Core/SDImageHEICCoder.m; sourceTree = "<group>"; };
|
3298655B2337230C0071958B /* SDImageHEICCoder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDImageHEICCoder.m; path = Core/SDImageHEICCoder.m; sourceTree = "<group>"; };
|
||||||
32986560233737C70071958B /* SDImageHEICCoderInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDImageHEICCoderInternal.h; sourceTree = "<group>"; };
|
|
||||||
329A18571FFF5DFD008C9A2F /* UIImage+Metadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+Metadata.h"; path = "Core/UIImage+Metadata.h"; sourceTree = "<group>"; };
|
329A18571FFF5DFD008C9A2F /* UIImage+Metadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+Metadata.h"; path = "Core/UIImage+Metadata.h"; sourceTree = "<group>"; };
|
||||||
329A18581FFF5DFD008C9A2F /* UIImage+Metadata.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImage+Metadata.m"; path = "Core/UIImage+Metadata.m"; sourceTree = "<group>"; };
|
329A18581FFF5DFD008C9A2F /* UIImage+Metadata.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImage+Metadata.m"; path = "Core/UIImage+Metadata.m"; sourceTree = "<group>"; };
|
||||||
329F1235223FAA3B00B309FD /* SDmetamacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDmetamacros.h; sourceTree = "<group>"; };
|
329F1235223FAA3B00B309FD /* SDmetamacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDmetamacros.h; sourceTree = "<group>"; };
|
||||||
|
@ -690,8 +686,6 @@
|
||||||
325C460C223394D8004CAE11 /* SDImageCachesManagerOperation.h */,
|
325C460C223394D8004CAE11 /* SDImageCachesManagerOperation.h */,
|
||||||
325C460D223394D8004CAE11 /* SDImageCachesManagerOperation.m */,
|
325C460D223394D8004CAE11 /* SDImageCachesManagerOperation.m */,
|
||||||
32C78E39233371AD00C6B7F8 /* SDImageIOAnimatedCoderInternal.h */,
|
32C78E39233371AD00C6B7F8 /* SDImageIOAnimatedCoderInternal.h */,
|
||||||
32986560233737C70071958B /* SDImageHEICCoderInternal.h */,
|
|
||||||
3263626A24AEEE94008FB119 /* SDImageAWebPCoderInternal.h */,
|
|
||||||
3253F235244982D3006C2BE8 /* SDWebImageTransitionInternal.h */,
|
3253F235244982D3006C2BE8 /* SDWebImageTransitionInternal.h */,
|
||||||
325C461E2233A02E004CAE11 /* UIColor+SDHexString.h */,
|
325C461E2233A02E004CAE11 /* UIColor+SDHexString.h */,
|
||||||
325C461F2233A02E004CAE11 /* UIColor+SDHexString.m */,
|
325C461F2233A02E004CAE11 /* UIColor+SDHexString.m */,
|
||||||
|
@ -900,7 +894,6 @@
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
32B5CC60222F89C2005EB74E /* SDAsyncBlockOperation.h in Headers */,
|
32B5CC60222F89C2005EB74E /* SDAsyncBlockOperation.h in Headers */,
|
||||||
32986562233737C70071958B /* SDImageHEICCoderInternal.h in Headers */,
|
|
||||||
32D122202080B2EB003685A3 /* SDImageCacheDefine.h in Headers */,
|
32D122202080B2EB003685A3 /* SDImageCacheDefine.h in Headers */,
|
||||||
3298655C2337230C0071958B /* SDImageHEICCoder.h in Headers */,
|
3298655C2337230C0071958B /* SDImageHEICCoder.h in Headers */,
|
||||||
32B9B539206ED4230026769D /* SDWebImageDownloaderConfig.h in Headers */,
|
32B9B539206ED4230026769D /* SDWebImageDownloaderConfig.h in Headers */,
|
||||||
|
@ -923,7 +916,6 @@
|
||||||
43A918661D8308FE00B3925F /* SDImageCacheConfig.h in Headers */,
|
43A918661D8308FE00B3925F /* SDImageCacheConfig.h in Headers */,
|
||||||
3290FA061FA478AF0047D20C /* SDImageFrame.h in Headers */,
|
3290FA061FA478AF0047D20C /* SDImageFrame.h in Headers */,
|
||||||
326E2F33236F1D58006F847F /* SDDeviceHelper.h in Headers */,
|
326E2F33236F1D58006F847F /* SDDeviceHelper.h in Headers */,
|
||||||
3263626B24AEEE94008FB119 /* SDImageAWebPCoderInternal.h in Headers */,
|
|
||||||
329F1237223FAA3B00B309FD /* SDmetamacros.h in Headers */,
|
329F1237223FAA3B00B309FD /* SDmetamacros.h in Headers */,
|
||||||
324DF4B6200A14DC008A84CC /* SDWebImageDefine.h in Headers */,
|
324DF4B6200A14DC008A84CC /* SDWebImageDefine.h in Headers */,
|
||||||
32A09E3F233358B700339F9D /* SDImageIOAnimatedCoder.h in Headers */,
|
32A09E3F233358B700339F9D /* SDImageIOAnimatedCoder.h in Headers */,
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
#else
|
#else
|
||||||
#import <MobileCoreServices/MobileCoreServices.h>
|
#import <MobileCoreServices/MobileCoreServices.h>
|
||||||
#endif
|
#endif
|
||||||
#import "SDImageHEICCoderInternal.h"
|
#import "SDImageIOAnimatedCoderInternal.h"
|
||||||
#import "SDImageAWebPCoderInternal.h"
|
|
||||||
|
|
||||||
#define kSVGTagEnd @"</svg>"
|
#define kSVGTagEnd @"</svg>"
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
#import "SDImageGIFCoder.h"
|
#import "SDImageGIFCoder.h"
|
||||||
#import "SDImageAPNGCoder.h"
|
#import "SDImageAPNGCoder.h"
|
||||||
#import "SDImageHEICCoder.h"
|
#import "SDImageHEICCoder.h"
|
||||||
#import "SDImageHEICCoderInternal.h"
|
#import "SDImageAWebPCoder.h"
|
||||||
#import "SDImageAWebPCoderInternal.h"
|
|
||||||
|
|
||||||
@implementation SDAnimatedImageRep {
|
@implementation SDAnimatedImageRep {
|
||||||
CGImageSourceRef _imageSource;
|
CGImageSourceRef _imageSource;
|
||||||
|
@ -35,6 +34,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should override init method for `NSBitmapImageRep` to do initialize about animated image format
|
// We should override init method for `NSBitmapImageRep` to do initialize about animated image format
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||||
- (instancetype)initWithData:(NSData *)data {
|
- (instancetype)initWithData:(NSData *)data {
|
||||||
self = [super initWithData:data];
|
self = [super initWithData:data];
|
||||||
if (self) {
|
if (self) {
|
||||||
|
@ -119,6 +120,7 @@
|
||||||
[super setProperty:NSImageCurrentFrameDuration withValue:@(frameDuration)];
|
[super setProperty:NSImageCurrentFrameDuration withValue:@(frameDuration)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "SDImageAWebPCoder.h"
|
#import "SDImageAWebPCoder.h"
|
||||||
#import "SDImageAWebPCoderInternal.h"
|
|
||||||
#import "SDImageIOAnimatedCoderInternal.h"
|
#import "SDImageIOAnimatedCoderInternal.h"
|
||||||
|
|
||||||
// These constants are available from iOS 14+ and Xcode 12. This raw value is used for toolchain and firmware compatibility
|
// These constants are available from iOS 14+ and Xcode 12. This raw value is used for toolchain and firmware compatibility
|
||||||
|
@ -46,7 +45,7 @@ static NSString * kSDCGImagePropertyWebPUnclampedDelayTime = @"UnclampedDelayTim
|
||||||
switch ([NSData sd_imageFormatForImageData:data]) {
|
switch ([NSData sd_imageFormatForImageData:data]) {
|
||||||
case SDImageFormatWebP:
|
case SDImageFormatWebP:
|
||||||
// Check WebP decoding compatibility
|
// Check WebP decoding compatibility
|
||||||
return [self.class canDecodeFromWebPFormat];
|
return [self.class canDecodeFromFormat:SDImageFormatWebP];
|
||||||
default:
|
default:
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
@ -60,32 +59,12 @@ static NSString * kSDCGImagePropertyWebPUnclampedDelayTime = @"UnclampedDelayTim
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case SDImageFormatWebP:
|
case SDImageFormatWebP:
|
||||||
// Check WebP encoding compatibility
|
// Check WebP encoding compatibility
|
||||||
return [self.class canEncodeToWebPFormat];
|
return [self.class canEncodeToFormat:SDImageFormatWebP];
|
||||||
default:
|
default:
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - WebP Format
|
|
||||||
|
|
||||||
+ (BOOL)canDecodeFromWebPFormat {
|
|
||||||
static BOOL canDecode = NO;
|
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
dispatch_once(&onceToken, ^{
|
|
||||||
canDecode = [self canDecodeFromFormat:SDImageFormatWebP];
|
|
||||||
});
|
|
||||||
return canDecode;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (BOOL)canEncodeToWebPFormat {
|
|
||||||
static BOOL canEncode = NO;
|
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
dispatch_once(&onceToken, ^{
|
|
||||||
canEncode = [self canEncodeToFormat:SDImageFormatWebP];
|
|
||||||
});
|
|
||||||
return canEncode;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Subclass Override
|
#pragma mark - Subclass Override
|
||||||
|
|
||||||
+ (SDImageFormat)imageFormat {
|
+ (SDImageFormat)imageFormat {
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "SDImageHEICCoder.h"
|
#import "SDImageHEICCoder.h"
|
||||||
#import "SDImageHEICCoderInternal.h"
|
|
||||||
#import "SDImageIOAnimatedCoderInternal.h"
|
#import "SDImageIOAnimatedCoderInternal.h"
|
||||||
|
|
||||||
// These constants are available from iOS 13+ and Xcode 11. This raw value is used for toolchain and firmware compatibility
|
// These constants are available from iOS 13+ and Xcode 11. This raw value is used for toolchain and firmware compatibility
|
||||||
|
@ -46,10 +45,10 @@ static NSString * kSDCGImagePropertyHEICSUnclampedDelayTime = @"UnclampedDelayTi
|
||||||
switch ([NSData sd_imageFormatForImageData:data]) {
|
switch ([NSData sd_imageFormatForImageData:data]) {
|
||||||
case SDImageFormatHEIC:
|
case SDImageFormatHEIC:
|
||||||
// Check HEIC decoding compatibility
|
// Check HEIC decoding compatibility
|
||||||
return [self.class canDecodeFromHEICFormat];
|
return [self.class canDecodeFromFormat:SDImageFormatHEIC];
|
||||||
case SDImageFormatHEIF:
|
case SDImageFormatHEIF:
|
||||||
// Check HEIF decoding compatibility
|
// Check HEIF decoding compatibility
|
||||||
return [self.class canDecodeFromHEIFFormat];
|
return [self.class canDecodeFromFormat:SDImageFormatHEIF];
|
||||||
default:
|
default:
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
@ -63,53 +62,15 @@ static NSString * kSDCGImagePropertyHEICSUnclampedDelayTime = @"UnclampedDelayTi
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case SDImageFormatHEIC:
|
case SDImageFormatHEIC:
|
||||||
// Check HEIC encoding compatibility
|
// Check HEIC encoding compatibility
|
||||||
return [self.class canEncodeToHEICFormat];
|
return [self.class canEncodeToFormat:SDImageFormatHEIC];
|
||||||
case SDImageFormatHEIF:
|
case SDImageFormatHEIF:
|
||||||
// Check HEIF encoding compatibility
|
// Check HEIF encoding compatibility
|
||||||
return [self.class canEncodeToHEIFFormat];
|
return [self.class canEncodeToFormat:SDImageFormatHEIF];
|
||||||
default:
|
default:
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - HEIF Format
|
|
||||||
|
|
||||||
+ (BOOL)canDecodeFromHEICFormat {
|
|
||||||
static BOOL canDecode = NO;
|
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
dispatch_once(&onceToken, ^{
|
|
||||||
canDecode = [self canDecodeFromFormat:SDImageFormatHEIC];
|
|
||||||
});
|
|
||||||
return canDecode;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (BOOL)canDecodeFromHEIFFormat {
|
|
||||||
static BOOL canDecode = NO;
|
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
dispatch_once(&onceToken, ^{
|
|
||||||
canDecode = [self canDecodeFromFormat:SDImageFormatHEIF];
|
|
||||||
});
|
|
||||||
return canDecode;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (BOOL)canEncodeToHEICFormat {
|
|
||||||
static BOOL canEncode = NO;
|
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
dispatch_once(&onceToken, ^{
|
|
||||||
canEncode = [self canEncodeToFormat:SDImageFormatHEIC];
|
|
||||||
});
|
|
||||||
return canEncode;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (BOOL)canEncodeToHEIFFormat {
|
|
||||||
static BOOL canEncode = NO;
|
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
dispatch_once(&onceToken, ^{
|
|
||||||
canEncode = [self canEncodeToFormat:SDImageFormatHEIF];
|
|
||||||
});
|
|
||||||
return canEncode;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Subclass Override
|
#pragma mark - Subclass Override
|
||||||
|
|
||||||
+ (SDImageFormat)imageFormat {
|
+ (SDImageFormat)imageFormat {
|
||||||
|
|
|
@ -109,9 +109,14 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
|
||||||
#pragma mark - Utils
|
#pragma mark - Utils
|
||||||
|
|
||||||
+ (BOOL)canDecodeFromFormat:(SDImageFormat)format {
|
+ (BOOL)canDecodeFromFormat:(SDImageFormat)format {
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
static NSSet *imageUTTypeSet;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
NSArray *imageUTTypes = (__bridge_transfer NSArray *)CGImageSourceCopyTypeIdentifiers();
|
||||||
|
imageUTTypeSet = [NSSet setWithArray:imageUTTypes];
|
||||||
|
});
|
||||||
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
|
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
|
||||||
NSArray *imageUTTypes = (__bridge_transfer NSArray *)CGImageSourceCopyTypeIdentifiers();
|
if ([imageUTTypeSet containsObject:(__bridge NSString *)(imageUTType)]) {
|
||||||
if ([imageUTTypes containsObject:(__bridge NSString *)(imageUTType)]) {
|
|
||||||
// Can decode from target format
|
// Can decode from target format
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -119,19 +124,18 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (BOOL)canEncodeToFormat:(SDImageFormat)format {
|
+ (BOOL)canEncodeToFormat:(SDImageFormat)format {
|
||||||
NSMutableData *imageData = [NSMutableData data];
|
static dispatch_once_t onceToken;
|
||||||
|
static NSSet *imageUTTypeSet;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
NSArray *imageUTTypes = (__bridge_transfer NSArray *)CGImageDestinationCopyTypeIdentifiers();
|
||||||
|
imageUTTypeSet = [NSSet setWithArray:imageUTTypes];
|
||||||
|
});
|
||||||
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
|
CFStringRef imageUTType = [NSData sd_UTTypeFromImageFormat:format];
|
||||||
|
if ([imageUTTypeSet containsObject:(__bridge NSString *)(imageUTType)]) {
|
||||||
// Create an image destination.
|
|
||||||
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, imageUTType, 1, NULL);
|
|
||||||
if (!imageDestination) {
|
|
||||||
// Can't encode to target format
|
|
||||||
return NO;
|
|
||||||
} else {
|
|
||||||
// Can encode to target format
|
// Can encode to target format
|
||||||
CFRelease(imageDestination);
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSUInteger)imageLoopCountWithSource:(CGImageSourceRef)source {
|
+ (NSUInteger)imageLoopCountWithSource:(CGImageSourceRef)source {
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the SDWebImage package.
|
|
||||||
* (c) Olivier Poitrey <rs@dailymotion.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import "SDImageAWebPCoder.h"
|
|
||||||
|
|
||||||
// kUTTypeWebP seems not defined in public UTI framework, Apple use the hardcode string, we define them :)
|
|
||||||
#define kSDUTTypeWebP ((__bridge CFStringRef)@"org.webmproject.webp")
|
|
||||||
|
|
||||||
@interface SDImageAWebPCoder ()
|
|
||||||
|
|
||||||
+ (BOOL)canDecodeFromWebPFormat;
|
|
||||||
+ (BOOL)canEncodeToWebPFormat;
|
|
||||||
|
|
||||||
@end
|
|
|
@ -1,25 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the SDWebImage package.
|
|
||||||
* (c) Olivier Poitrey <rs@dailymotion.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import "SDImageHEICCoder.h"
|
|
||||||
|
|
||||||
// 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")
|
|
||||||
// HEIC Sequence (Animated Image)
|
|
||||||
#define kSDUTTypeHEICS ((__bridge CFStringRef)@"public.heics")
|
|
||||||
|
|
||||||
@interface SDImageHEICCoder ()
|
|
||||||
|
|
||||||
+ (BOOL)canDecodeFromHEICFormat;
|
|
||||||
+ (BOOL)canDecodeFromHEIFFormat;
|
|
||||||
+ (BOOL)canEncodeToHEICFormat;
|
|
||||||
+ (BOOL)canEncodeToHEIFFormat;
|
|
||||||
|
|
||||||
@end
|
|
|
@ -9,6 +9,14 @@
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SDImageIOAnimatedCoder.h"
|
#import "SDImageIOAnimatedCoder.h"
|
||||||
|
|
||||||
|
// 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")
|
||||||
|
// HEIC Sequence (Animated Image)
|
||||||
|
#define kSDUTTypeHEICS ((__bridge CFStringRef)@"public.heics")
|
||||||
|
// kUTTypeWebP seems not defined in public UTI framework, Apple use the hardcode string, we define them :)
|
||||||
|
#define kSDUTTypeWebP ((__bridge CFStringRef)@"org.webmproject.webp")
|
||||||
|
|
||||||
@interface SDImageIOAnimatedCoder ()
|
@interface SDImageIOAnimatedCoder ()
|
||||||
|
|
||||||
+ (NSTimeInterval)frameDurationAtIndex:(NSUInteger)index source:(nonnull CGImageSourceRef)source;
|
+ (NSTimeInterval)frameDurationAtIndex:(NSUInteger)index source:(nonnull CGImageSourceRef)source;
|
||||||
|
|
Loading…
Reference in New Issue