Use the NSString static variable to avoid bridge twice. For HEIC and APNG constants
This commit is contained in:
parent
859c76fa9f
commit
4638700886
|
@ -14,14 +14,20 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// iOS 8 Image/IO framework binary does not contains these APNG contants, so we define them. Thanks Apple :)
|
// 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)
|
static NSString * kSDCGImagePropertyAPNGLoopCount = @"LoopCount";
|
||||||
const CFStringRef kCGImagePropertyAPNGLoopCount = (__bridge CFStringRef)@"LoopCount";
|
static NSString * kSDCGImagePropertyAPNGDelayTime = @"DelayTime";
|
||||||
const CFStringRef kCGImagePropertyAPNGDelayTime = (__bridge CFStringRef)@"DelayTime";
|
static NSString * kSDCGImagePropertyAPNGUnclampedDelayTime = @"UnclampedDelayTime";
|
||||||
const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef)@"UnclampedDelayTime";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@implementation SDImageAPNGCoder
|
@implementation SDImageAPNGCoder
|
||||||
|
|
||||||
|
+ (void)initialize {
|
||||||
|
if (@available(iOS 9, *)) {
|
||||||
|
kSDCGImagePropertyAPNGLoopCount = (__bridge NSString *)kCGImagePropertyAPNGLoopCount;
|
||||||
|
kSDCGImagePropertyAPNGDelayTime = (__bridge NSString *)kCGImagePropertyAPNGDelayTime;
|
||||||
|
kSDCGImagePropertyAPNGUnclampedDelayTime = (__bridge NSString *)kCGImagePropertyAPNGUnclampedDelayTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+ (instancetype)sharedCoder {
|
+ (instancetype)sharedCoder {
|
||||||
static SDImageAPNGCoder *coder;
|
static SDImageAPNGCoder *coder;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
|
@ -46,15 +52,15 @@ const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)unclampedDelayTimeProperty {
|
+ (NSString *)unclampedDelayTimeProperty {
|
||||||
return (__bridge NSString *)kCGImagePropertyAPNGUnclampedDelayTime;
|
return kSDCGImagePropertyAPNGUnclampedDelayTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)delayTimeProperty {
|
+ (NSString *)delayTimeProperty {
|
||||||
return (__bridge NSString *)kCGImagePropertyAPNGDelayTime;
|
return kSDCGImagePropertyAPNGDelayTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)loopCountProperty {
|
+ (NSString *)loopCountProperty {
|
||||||
return (__bridge NSString *)kCGImagePropertyAPNGLoopCount;
|
return kSDCGImagePropertyAPNGLoopCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSUInteger)defaultLoopCount {
|
+ (NSUInteger)defaultLoopCount {
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
#import "SDImageHEICCoderInternal.h"
|
#import "SDImageHEICCoderInternal.h"
|
||||||
|
|
||||||
// These constantce are available from iOS 13+ and Xcode 11. This raw value is used for toolchain and firmware compatiblitiy
|
// These constantce are available from iOS 13+ and Xcode 11. This raw value is used for toolchain and firmware compatiblitiy
|
||||||
static CFStringRef kSDCGImagePropertyHEICSDictionary = (__bridge CFStringRef)@"{HEICS}";
|
static NSString * kSDCGImagePropertyHEICSDictionary = @"{HEICS}";
|
||||||
static CFStringRef kSDCGImagePropertyHEICSLoopCount = (__bridge CFStringRef)@"LoopCount";
|
static NSString * kSDCGImagePropertyHEICSLoopCount = @"LoopCount";
|
||||||
static CFStringRef kSDCGImagePropertyHEICSDelayTime = (__bridge CFStringRef)@"DelayTime";
|
static NSString * kSDCGImagePropertyHEICSDelayTime = @"DelayTime";
|
||||||
static CFStringRef kSDCGImagePropertyHEICSUnclampedDelayTime = (__bridge CFStringRef)@"UnclampedDelayTime";
|
static NSString * kSDCGImagePropertyHEICSUnclampedDelayTime = @"UnclampedDelayTime";
|
||||||
|
|
||||||
@implementation SDImageHEICCoder
|
@implementation SDImageHEICCoder
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ static CFStringRef kSDCGImagePropertyHEICSUnclampedDelayTime = (__bridge CFStrin
|
||||||
// Xcode 11
|
// Xcode 11
|
||||||
if (@available(iOS 13, tvOS 13, macOS 10.15, watchOS 6, *)) {
|
if (@available(iOS 13, tvOS 13, macOS 10.15, watchOS 6, *)) {
|
||||||
// Use SDK instead of raw value
|
// Use SDK instead of raw value
|
||||||
kSDCGImagePropertyHEICSDictionary = kCGImagePropertyHEICSDictionary;
|
kSDCGImagePropertyHEICSDictionary = (__bridge NSString *)kCGImagePropertyHEICSDictionary;
|
||||||
kSDCGImagePropertyHEICSLoopCount = kCGImagePropertyHEICSLoopCount;
|
kSDCGImagePropertyHEICSLoopCount = (__bridge NSString *)kCGImagePropertyHEICSLoopCount;
|
||||||
kSDCGImagePropertyHEICSDelayTime = kCGImagePropertyHEICSDelayTime;
|
kSDCGImagePropertyHEICSDelayTime = (__bridge NSString *)kCGImagePropertyHEICSDelayTime;
|
||||||
kSDCGImagePropertyHEICSUnclampedDelayTime = kCGImagePropertyHEICSUnclampedDelayTime;
|
kSDCGImagePropertyHEICSUnclampedDelayTime = (__bridge NSString *)kCGImagePropertyHEICSUnclampedDelayTime;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ static CFStringRef kSDCGImagePropertyHEICSUnclampedDelayTime = (__bridge CFStrin
|
||||||
switch ([NSData sd_imageFormatForImageData:data]) {
|
switch ([NSData sd_imageFormatForImageData:data]) {
|
||||||
case SDImageFormatHEIC:
|
case SDImageFormatHEIC:
|
||||||
// Check HEIC decoding compatibility
|
// Check HEIC decoding compatibility
|
||||||
return [SDImageHEICCoder canDecodeFromHEICFormat];
|
return [self.class canDecodeFromHEICFormat];
|
||||||
case SDImageFormatHEIF:
|
case SDImageFormatHEIF:
|
||||||
// Check HEIF decoding compatibility
|
// Check HEIF decoding compatibility
|
||||||
return [SDImageHEICCoder canDecodeFromHEIFFormat];
|
return [self.class canDecodeFromHEIFFormat];
|
||||||
default:
|
default:
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,10 @@ static CFStringRef kSDCGImagePropertyHEICSUnclampedDelayTime = (__bridge CFStrin
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case SDImageFormatHEIC:
|
case SDImageFormatHEIC:
|
||||||
// Check HEIC encoding compatibility
|
// Check HEIC encoding compatibility
|
||||||
return [SDImageHEICCoder canEncodeToHEICFormat];
|
return [self.class canEncodeToHEICFormat];
|
||||||
case SDImageFormatHEIF:
|
case SDImageFormatHEIF:
|
||||||
// Check HEIF encoding compatibility
|
// Check HEIF encoding compatibility
|
||||||
return [SDImageHEICCoder canEncodeToHEIFFormat];
|
return [self.class canEncodeToHEIFFormat];
|
||||||
default:
|
default:
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
@ -145,19 +145,19 @@ static CFStringRef kSDCGImagePropertyHEICSUnclampedDelayTime = (__bridge CFStrin
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)dictionaryProperty {
|
+ (NSString *)dictionaryProperty {
|
||||||
return (__bridge NSString *)kSDCGImagePropertyHEICSDictionary;
|
return kSDCGImagePropertyHEICSDictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)unclampedDelayTimeProperty {
|
+ (NSString *)unclampedDelayTimeProperty {
|
||||||
return (__bridge NSString *)kSDCGImagePropertyHEICSUnclampedDelayTime;
|
return kSDCGImagePropertyHEICSUnclampedDelayTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)delayTimeProperty {
|
+ (NSString *)delayTimeProperty {
|
||||||
return (__bridge NSString *)kSDCGImagePropertyHEICSDelayTime;
|
return kSDCGImagePropertyHEICSDelayTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)loopCountProperty {
|
+ (NSString *)loopCountProperty {
|
||||||
return (__bridge NSString *)kSDCGImagePropertyHEICSLoopCount;
|
return kSDCGImagePropertyHEICSLoopCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSUInteger)defaultLoopCount {
|
+ (NSUInteger)defaultLoopCount {
|
||||||
|
|
Loading…
Reference in New Issue