Changeset 225915 in webkit
- Timestamp:
- Dec 14, 2017, 11:33:09 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r225913 r225915 1 2017-12-14 Simon Fraser <simon.fraser@apple.com> 2 3 Remove ColorSpaceDeviceRGB and most users of the obsolete deviceRGB colorspace 4 https://bugs.webkit.org/show_bug.cgi?id=180689 5 6 Reviewed by Darin Adler. 7 8 Address issues noted by Darin in r225797: 9 10 Existing and new code mistakenly allocated colorspaces on every call, because 11 they didn't initialize the static variable on the first call. Avoid this mistake 12 by using dispatch_once() in these functions. 13 14 Fix a case where the extendedSRGBColorSpaceRef() fallback was returning deviceRGB 15 instead of sRGB. 16 17 * platform/graphics/cg/GraphicsContextCG.cpp: 18 (WebCore::sRGBColorSpaceRef): 19 (WebCore::linearRGBColorSpaceRef): 20 (WebCore::extendedSRGBColorSpaceRef): 21 (WebCore::displayP3ColorSpaceRef): 22 * platform/graphics/cocoa/GraphicsContextCocoa.mm: 23 (WebCore::linearRGBColorSpaceRef): 24 1 25 2017-12-13 Keith Miller <keith_miller@apple.com> 2 26 -
trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
r225797 r225915 75 75 CGColorSpaceRef sRGBColorSpaceRef() 76 76 { 77 static CGColorSpaceRef sRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); 77 static CGColorSpaceRef sRGBColorSpace; 78 static dispatch_once_t onceToken; 79 dispatch_once(&onceToken, ^{ 80 sRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); 78 81 #if PLATFORM(WIN) 79 // Out-of-date CG installations will not honor kCGColorSpaceSRGB. This logic avoids 80 // causing a crash under those conditions. Since the default color space in Windows 81 // is sRGB, this all works out nicely. 82 if (!sRGBSpace) 83 sRGBSpace = CGColorSpaceCreateDeviceRGB(); 82 // Out-of-date CG installations will not honor kCGColorSpaceSRGB. This logic avoids 83 // causing a crash under those conditions. Since the default color space in Windows 84 // is sRGB, this all works out nicely. 85 // FIXME: Is this still needed? rdar://problem/15213515 was fixed. 86 if (!sRGBColorSpace) 87 sRGBColorSpace = CGColorSpaceCreateDeviceRGB(); 84 88 #endif // PLATFORM(WIN) 85 return sRGBSpace; 89 }); 90 return sRGBColorSpace; 86 91 } 87 92 … … 90 95 CGColorSpaceRef linearRGBColorSpaceRef() 91 96 { 97 static CGColorSpaceRef linearRGBColorSpace; 98 static dispatch_once_t onceToken; 99 dispatch_once(&onceToken, ^{ 92 100 #if PLATFORM(WIN) 93 // FIXME: Windows should be able to use linear sRGB, this is tracked by http://webkit.org/b/80000.94 return CGColorSpaceCreateDeviceRGB();101 // FIXME: Windows should be able to use linear sRGB, this is tracked by http://webkit.org/b/80000. 102 linearRGBColorSpace = sRGBColorSpaceRef(); 95 103 #else 96 static CGColorSpaceRef linearRGBSpace; 97 linearRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceLinearSRGB); 98 return linearRGBSpace; 104 linearRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceLinearSRGB); 99 105 #endif 106 }); 107 108 return linearRGBColorSpace; 100 109 } 101 110 #endif … … 103 112 CGColorSpaceRef extendedSRGBColorSpaceRef() 104 113 { 105 static CGColorSpaceRef extendedSRGBSpace; 114 static CGColorSpaceRef extendedSRGBColorSpace; 115 static dispatch_once_t onceToken; 116 dispatch_once(&onceToken, ^{ 106 117 #if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) 107 extendedSRGBSpace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB);118 extendedSRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB); 108 119 #endif 109 // If there is no support for exteneded sRGB, fall back to sRGB. 110 if (!extendedSRGBSpace) 111 extendedSRGBSpace = CGColorSpaceCreateDeviceRGB(); 112 return extendedSRGBSpace; 120 // If there is no support for extended sRGB, fall back to sRGB. 121 if (!extendedSRGBColorSpace) 122 extendedSRGBColorSpace = sRGBColorSpaceRef(); 123 }); 124 return extendedSRGBColorSpace; 113 125 } 114 126 115 127 CGColorSpaceRef displayP3ColorSpaceRef() 116 128 { 117 static CGColorSpaceRef displayP3Space; 129 static CGColorSpaceRef displayP3ColorSpace; 130 static dispatch_once_t onceToken; 131 dispatch_once(&onceToken, ^{ 118 132 #if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 101100) 119 displayP3Space = CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3);133 displayP3ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3); 120 134 #else 121 displayP3Space = sRGBColorSpaceRef();135 displayP3ColorSpace = sRGBColorSpaceRef(); 122 136 #endif 123 return displayP3Space; 137 }); 138 return displayP3ColorSpace; 124 139 } 125 140 -
trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextCocoa.mm
r225797 r225915 369 369 CGColorSpaceRef linearRGBColorSpaceRef() 370 370 { 371 static CGColorSpaceRef linearSRGBSpace = nullptr; 372 373 if (linearSRGBSpace) 374 return linearSRGBSpace; 375 376 RetainPtr<NSString> iccProfilePath = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"linearSRGB" ofType:@"icc"]; 377 RetainPtr<NSData> iccProfileData = adoptNS([[NSData alloc] initWithContentsOfFile:iccProfilePath.get()]); 378 379 if (iccProfileData) 371 static CGColorSpaceRef linearSRGBColorSpace; 372 static dispatch_once_t onceToken; 373 dispatch_once(&onceToken, ^{ 374 RetainPtr<NSString> iccProfilePath = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"linearSRGB" ofType:@"icc"]; 375 RetainPtr<NSData> iccProfileData = adoptNS([[NSData alloc] initWithContentsOfFile:iccProfilePath.get()]); 376 if (iccProfileData) 380 377 #pragma clang diagnostic push 381 378 #pragma clang diagnostic ignored "-Wdeprecated-declarations" 382 linearSRGBSpace = CGColorSpaceCreateWithICCProfile((CFDataRef)iccProfileData.get());379 linearSRGBColorSpace = CGColorSpaceCreateWithICCProfile((CFDataRef)iccProfileData.get()); 383 380 #pragma clang diagnostic pop 384 381 385 // If we fail to load the linearized sRGB ICC profile, fall back to sRGB.386 if (!linearSRGBSpace)387 returnsRGBColorSpaceRef();388 389 return linearSRGB Space;382 // If we fail to load the linearized sRGB ICC profile, fall back to sRGB. 383 if (!linearSRGBColorSpace) 384 linearSRGBColorSpace = sRGBColorSpaceRef(); 385 }); 386 return linearSRGBColorSpace; 390 387 } 391 388 #endif
Note:
See TracChangeset
for help on using the changeset viewer.