Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: src/core/SkColorSpace.cpp

Issue 1949313003: Reland of SkOncePtr -> SkOnce (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/private/SkOncePtr.h ('k') | src/core/SkData.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « include/private/SkOncePtr.h ('k') | src/core/SkData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698