Index: src/core/SkColorSpace.cpp |
diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp |
index 55ab4c177a57f77a57e09989f6ea584436262d54..889746f41bef471546e41323aac5a4d67860fbaf 100644 |
--- a/src/core/SkColorSpace.cpp |
+++ b/src/core/SkColorSpace.cpp |
@@ -7,7 +7,7 @@ |
#include "SkAtomics.h" |
#include "SkColorSpace.h" |
-#include "SkOncePtr.h" |
+#include "SkOnce.h" |
static bool color_space_almost_equal(float a, float b) { |
return SkTAbs(a - b) < 0.01f; |
@@ -42,8 +42,6 @@ |
0.3853f, 0.7170f, 0.0971f, // * G |
0.1430f, 0.0606f, 0.7139f, // * B |
}; |
- |
-SK_DECLARE_STATIC_ONCE_PTR(SkColorSpace, sRGB); |
sk_sp<SkColorSpace> SkColorSpace::NewRGB(SkGammas gammas, const SkMatrix44& toXYZD50) { |
// Check if we really have sRGB |
@@ -74,13 +72,17 @@ |
} |
sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) { |
+ static SkOnce once; |
+ static SkColorSpace* sRGB; |
+ |
switch (named) { |
case kSRGB_Named: { |
- SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor); |
- srgbToxyzD50.set3x3ColMajorf(gSRGB_toXYZD50); |
- return sk_ref_sp(sRGB.get([=]{ |
- return new SkColorSpace(SkGammas(2.2f, 2.2f, 2.2f), srgbToxyzD50, kSRGB_Named); |
- })); |
+ once([] { |
+ SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor); |
+ srgbToxyzD50.set3x3ColMajorf(gSRGB_toXYZD50); |
+ sRGB = new SkColorSpace(SkGammas(2.2f, 2.2f, 2.2f), srgbToxyzD50, kSRGB_Named); |
+ }); |
+ return sk_ref_sp(sRGB); |
} |
default: |
break; |