Merge pull request #3712 from dreampiggy/bugfix/unit_test_macos

Fix that `colorSpaceGetDeviceRGB` cache the color space even when active display changed
This commit is contained in:
DreamPiggy 2024-05-08 17:03:04 +08:00 committed by GitHub
commit b8b147d752
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 11 deletions

View File

@ -290,22 +290,23 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
}
+ (CGColorSpaceRef)colorSpaceGetDeviceRGB {
#if SD_MAC
NSScreen *mainScreen = nil;
if (@available(macOS 10.12, *)) {
mainScreen = [NSScreen mainScreen];
} else {
mainScreen = [NSScreen screens].firstObject;
}
CGColorSpaceRef colorSpace = mainScreen.colorSpace.CGColorSpace;
return colorSpace;
#else
static CGColorSpaceRef colorSpace;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
#if SD_MAC
NSScreen *mainScreen = nil;
if (@available(macOS 10.12, *)) {
mainScreen = [NSScreen mainScreen];
} else {
mainScreen = [NSScreen screens].firstObject;
}
colorSpace = mainScreen.colorSpace.CGColorSpace;
#else
colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
#endif
});
return colorSpace;
#endif
}
+ (SDImagePixelFormat)preferredPixelFormat:(BOOL)containsAlpha {

View File

@ -217,7 +217,7 @@
- (void)test14ThatHEIFWorks {
if (@available(iOS 11, tvOS 11, macOS 10.13, *)) {
NSURL *heifURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"TestImage" withExtension:@"heif"];
BOOL supportsEncoding = !SDTestCase.isCI; // GitHub Action Mac env currently does not support HEIC encoding
BOOL supportsEncoding = NO; // public.heif UTI alwsays return false, use public.heic
[self verifyCoder:[SDImageIOCoder sharedCoder]
withLocalImageURL:heifURL
supportsEncoding:supportsEncoding