Title: [226080] trunk/Source/WebCore
- Revision
- 226080
- Author
- d...@apple.com
- Date
- 2017-12-18 14:05:23 -0800 (Mon, 18 Dec 2017)
Log Message
Make some functions in GraphicsContextCG use call_once for statics
https://bugs.webkit.org/show_bug.cgi?id=180841
<rdar://problem/36058448>
Reviewed by Antoine Quint.
In preparation for making OffscreenCanvas operate inside a Worker,
make sure GraphicsContext is thread safe. Change some functions
that use a static to call_once.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::sRGBColorSpaceRef):
(WebCore::linearRGBColorSpaceRef):
(WebCore::extendedSRGBColorSpaceRef):
(WebCore::displayP3ColorSpaceRef):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (226079 => 226080)
--- trunk/Source/WebCore/ChangeLog 2017-12-18 22:04:36 UTC (rev 226079)
+++ trunk/Source/WebCore/ChangeLog 2017-12-18 22:05:23 UTC (rev 226080)
@@ -1,3 +1,21 @@
+2017-12-18 Dean Jackson <d...@apple.com>
+
+ Make some functions in GraphicsContextCG use call_once for statics
+ https://bugs.webkit.org/show_bug.cgi?id=180841
+ <rdar://problem/36058448>
+
+ Reviewed by Antoine Quint.
+
+ In preparation for making OffscreenCanvas operate inside a Worker,
+ make sure GraphicsContext is thread safe. Change some functions
+ that use a static to call_once.
+
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::sRGBColorSpaceRef):
+ (WebCore::linearRGBColorSpaceRef):
+ (WebCore::extendedSRGBColorSpaceRef):
+ (WebCore::displayP3ColorSpaceRef):
+
2017-12-18 Chris Dumez <cdu...@apple.com>
ExtendableMessageEvent.data should return the value it was initialized to
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (226079 => 226080)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2017-12-18 22:04:36 UTC (rev 226079)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2017-12-18 22:05:23 UTC (rev 226080)
@@ -74,22 +74,21 @@
CGColorSpaceRef sRGBColorSpaceRef()
{
- auto createColorSpace = []() {
+ static CGColorSpaceRef sRGBColorSpace;
+ 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.
- CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
- if (!colorSpace)
- colorSpace = CGColorSpaceCreateDeviceRGB();
- return colorSpace;
+ sRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+ if (!sRGBColorSpace)
+ sRGBColorSpace = CGColorSpaceCreateDeviceRGB();
#else
- return CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+ sRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
#endif // PLATFORM(WIN)
- };
-
- static CGColorSpaceRef sRGBColorSpace = createColorSpace();
+ });
return sRGBColorSpace;
}
@@ -97,16 +96,16 @@
// See GraphicsContextCocoa for the pre-10.12 implementation.
CGColorSpaceRef linearRGBColorSpaceRef()
{
- auto createColorSpace = []() {
+ static CGColorSpaceRef linearRGBColorSpace;
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
#if PLATFORM(WIN)
// FIXME: Windows should be able to use linear sRGB, this is tracked by http://webkit.org/b/80000.
- return sRGBColorSpaceRef();
+ linearRGBColorSpace = sRGBColorSpaceRef();
#else
- return CGColorSpaceCreateWithName(kCGColorSpaceLinearSRGB);
+ linearRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceLinearSRGB);
#endif
- };
-
- static CGColorSpaceRef linearRGBColorSpace = createColorSpace();
+ });
return linearRGBColorSpace;
}
#endif
@@ -113,7 +112,9 @@
CGColorSpaceRef extendedSRGBColorSpaceRef()
{
- auto createColorSpace = []() {
+ static CGColorSpaceRef extendedSRGBColorSpace;
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
CGColorSpaceRef colorSpace = NULL;
#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceExtendedSRGB);
@@ -121,25 +122,23 @@
// If there is no support for extended sRGB, fall back to sRGB.
if (!colorSpace)
colorSpace = sRGBColorSpaceRef();
-
- return colorSpace;
- };
-
- static CGColorSpaceRef extendedSRGBColorSpace = createColorSpace();
+
+ extendedSRGBColorSpace = colorSpace;
+ });
return extendedSRGBColorSpace;
}
CGColorSpaceRef displayP3ColorSpaceRef()
{
- auto createColorSpace = []() {
+ static CGColorSpaceRef displayP3ColorSpace;
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 101100)
- return CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3);
+ displayP3ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3);
#else
- return sRGBColorSpaceRef();
+ displayP3ColorSpace = sRGBColorSpaceRef();
#endif
- };
-
- static CGColorSpaceRef displayP3ColorSpace = createColorSpace();
+ });
return displayP3ColorSpace;
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes