aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-08-23 14:36:20 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-23 14:36:20 -0700
commitae6377c08e5c3735c65212ba9ff86fa51af7d68a (patch)
tree57ae0f599ba46361bc14dccb7a89f8b4777afcb9 /src/core
parent19fe41e85e6ce3e78b3a69fce1cf28edf937027d (diff)
Make singleton SkColorSpaces thread safe
SkColorSpaces may be once-ptrs, so we can reuse common color spaces. This means that they must be thread safe. SkMatrix44 is not thread safe because it maintains a mutable type mask. This CL ensures that we precompute the type mask so we can use const SkMatrix44's safely. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2277463002 Review-Url: https://codereview.chromium.org/2277463002
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkColorSpace.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp
index 3a5d9c196a..6302075658 100644
--- a/src/core/SkColorSpace.cpp
+++ b/src/core/SkColorSpace.cpp
@@ -136,6 +136,9 @@ sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) {
sRGBOnce([] {
SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor);
srgbToxyzD50.set3x3RowMajorf(gSRGB_toXYZD50);
+
+ // Force the mutable type mask to be computed. This avoids races.
+ (void)srgbToxyzD50.getType();
sRGB.reset(new SkColorSpace_Base(kSRGB_GammaNamed, srgbToxyzD50, kSRGB_Named));
});
return sRGB;
@@ -144,6 +147,9 @@ sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) {
adobeRGBOnce([] {
SkMatrix44 adobergbToxyzD50(SkMatrix44::kUninitialized_Constructor);
adobergbToxyzD50.set3x3RowMajorf(gAdobeRGB_toXYZD50);
+
+ // Force the mutable type mask to be computed. This avoids races.
+ (void)adobergbToxyzD50.getType();
adobeRGB.reset(new SkColorSpace_Base(k2Dot2Curve_GammaNamed, adobergbToxyzD50,
kAdobeRGB_Named));
});