Title: [272746] trunk/Source/WebCore
- Revision
- 272746
- Author
- da...@apple.com
- Date
- 2021-02-11 13:34:08 -0800 (Thu, 11 Feb 2021)
Log Message
Use a template to simplify repetitive code in ColorSpaceCG.cpp
https://bugs.webkit.org/show_bug.cgi?id=221770
Reviewed by Sam Weinig.
* platform/graphics/cg/ColorSpaceCG.cpp:
(WebCore::namedColorSpace): Added.
(WebCore::sRGBColorSpaceRef): Use namedColorSpace. Also took out long-obsolete
workaround for a bug in pre-2013 versions of Core Graphics on Windows.
(WebCore::adobeRGB1998ColorSpaceRef): Ditto.
(WebCore::displayP3ColorSpaceRef): Ditto.
(WebCore::extendedSRGBColorSpaceRef): Ditto.
(WebCore::ITUR_2020ColorSpaceRef): Ditto.
(WebCore::linearSRGBColorSpaceRef): Ditto.
(WebCore::ROMMRGBColorSpaceRef): Ditto.
(WebCore::xyzColorSpaceRef): Ditto.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (272745 => 272746)
--- trunk/Source/WebCore/ChangeLog 2021-02-11 21:33:19 UTC (rev 272745)
+++ trunk/Source/WebCore/ChangeLog 2021-02-11 21:34:08 UTC (rev 272746)
@@ -1,3 +1,22 @@
+2021-02-11 Darin Adler <da...@apple.com>
+
+ Use a template to simplify repetitive code in ColorSpaceCG.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=221770
+
+ Reviewed by Sam Weinig.
+
+ * platform/graphics/cg/ColorSpaceCG.cpp:
+ (WebCore::namedColorSpace): Added.
+ (WebCore::sRGBColorSpaceRef): Use namedColorSpace. Also took out long-obsolete
+ workaround for a bug in pre-2013 versions of Core Graphics on Windows.
+ (WebCore::adobeRGB1998ColorSpaceRef): Ditto.
+ (WebCore::displayP3ColorSpaceRef): Ditto.
+ (WebCore::extendedSRGBColorSpaceRef): Ditto.
+ (WebCore::ITUR_2020ColorSpaceRef): Ditto.
+ (WebCore::linearSRGBColorSpaceRef): Ditto.
+ (WebCore::ROMMRGBColorSpaceRef): Ditto.
+ (WebCore::xyzColorSpaceRef): Ditto.
+
2021-02-11 Aditya Keerthi <akeer...@apple.com>
[iOS][FCR] Range inputs have an incorrect RTL appearance
Modified: trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp (272745 => 272746)
--- trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp 2021-02-11 21:33:19 UTC (rev 272745)
+++ trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp 2021-02-11 21:34:08 UTC (rev 272746)
@@ -33,36 +33,26 @@
namespace WebCore {
-CGColorSpaceRef sRGBColorSpaceRef()
+template<const CFStringRef& colorSpaceNameGlobalConstant> static CGColorSpaceRef namedColorSpace()
{
- static CGColorSpaceRef sRGBColorSpace;
+ static CGColorSpaceRef colorSpace;
static std::once_flag onceFlag;
std::call_once(onceFlag, [] {
-#if PLATFORM(WIN)
- // Out-of-date CG installations will not honor kCGColorSpaceSRGB. This logic avoids
- // causing a crash under those conditions. Since the default color space in Windows
- // is sRGB, this all works out nicely.
- // FIXME: Is this still needed? rdar://problem/15213515 was fixed.
- sRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
- if (!sRGBColorSpace)
- sRGBColorSpace = CGColorSpaceCreateDeviceRGB();
-#else
- sRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
-#endif // PLATFORM(WIN)
+ colorSpace = CGColorSpaceCreateWithName(colorSpaceNameGlobalConstant);
+ ASSERT(colorSpace);
});
- return sRGBColorSpace;
+ return colorSpace;
}
+CGColorSpaceRef sRGBColorSpaceRef()
+{
+ return namedColorSpace<kCGColorSpaceSRGB>();
+}
+
#if HAVE(CORE_GRAPHICS_ADOBE_RGB_1998_COLOR_SPACE)
CGColorSpaceRef adobeRGB1998ColorSpaceRef()
{
- static CGColorSpaceRef adobeRGB1998ColorSpace;
- static std::once_flag onceFlag;
- std::call_once(onceFlag, [] {
- adobeRGB1998ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceAdobeRGB1998);
- ASSERT(adobeRGB1998ColorSpace);
- });
- return adobeRGB1998ColorSpace;
+ return namedColorSpace<kCGColorSpaceAdobeRGB1998>();
}
#endif
@@ -69,13 +59,7 @@
#if HAVE(CORE_GRAPHICS_DISPLAY_P3_COLOR_SPACE)
CGColorSpaceRef displayP3ColorSpaceRef()
{
- static CGColorSpaceRef displayP3ColorSpace;
- static std::once_flag onceFlag;
- std::call_once(onceFlag, [] {
- displayP3ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3);
- ASSERT(displayP3ColorSpace);
- });
- return displayP3ColorSpace;
+ return namedColorSpace<kCGColorSpaceDisplayP3>();
}
#endif
@@ -82,13 +66,7 @@
#if HAVE(CORE_GRAPHICS_EXTENDED_SRGB_COLOR_SPACE)
CGColorSpaceRef extendedSRGBColorSpaceRef()
{
- static CGColorSpaceRef extendedSRGBColorSpace;
- static std::once_flag onceFlag;
- std::call_once(onceFlag, [] {
- extendedSRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB);
- ASSERT(extendedSRGBColorSpace);
- });
- return extendedSRGBColorSpace;
+ return namedColorSpace<kCGColorSpaceExtendedSRGB>();
}
#endif
@@ -95,13 +73,7 @@
#if HAVE(CORE_GRAPHICS_ITUR_2020_COLOR_SPACE)
CGColorSpaceRef ITUR_2020ColorSpaceRef()
{
- static CGColorSpaceRef ITUR2020ColorSpace;
- static std::once_flag onceFlag;
- std::call_once(onceFlag, [] {
- ITUR2020ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020);
- ASSERT(ITUR2020ColorSpace);
- });
- return ITUR2020ColorSpace;
+ return namedColorSpace<kCGColorSpaceITUR_2020>();
}
#endif
@@ -116,13 +88,7 @@
#if HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE)
CGColorSpaceRef linearSRGBColorSpaceRef()
{
- static CGColorSpaceRef linearRGBColorSpace;
- static std::once_flag onceFlag;
- std::call_once(onceFlag, [] {
- linearRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceLinearSRGB);
- ASSERT(linearRGBColorSpace);
- });
- return linearRGBColorSpace;
+ return namedColorSpace<kCGColorSpaceLinearSRGB>();
}
#endif
@@ -129,13 +95,7 @@
#if HAVE(CORE_GRAPHICS_ROMMRGB_COLOR_SPACE)
CGColorSpaceRef ROMMRGBColorSpaceRef()
{
- static CGColorSpaceRef ROMMRGBColorSpace;
- static std::once_flag onceFlag;
- std::call_once(onceFlag, [] {
- ROMMRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceROMMRGB);
- ASSERT(ROMMRGBColorSpace);
- });
- return ROMMRGBColorSpace;
+ return namedColorSpace<kCGColorSpaceROMMRGB>();
}
#endif
@@ -142,13 +102,7 @@
#if HAVE(CORE_GRAPHICS_XYZ_COLOR_SPACE)
CGColorSpaceRef xyzColorSpaceRef()
{
- static CGColorSpaceRef xyzColorSpace;
- static std::once_flag onceFlag;
- std::call_once(onceFlag, [] {
- xyzColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericXYZ);
- ASSERT(xyzColorSpace);
- });
- return xyzColorSpace;
+ return namedColorSpace<kCGColorSpaceGenericXYZ>();
}
#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes