From ae6377c08e5c3735c65212ba9ff86fa51af7d68a Mon Sep 17 00:00:00 2001 From: msarett Date: Tue, 23 Aug 2016 14:36:20 -0700 Subject: 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 --- src/core/SkColorSpace.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/core/SkColorSpace.cpp') 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::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::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)); }); -- cgit v1.2.3