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
This commit is contained in:
parent
19fe41e85e
commit
ae6377c08e
@ -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));
|
||||
});
|
||||
|
@ -24,7 +24,7 @@ static void test_space(skiatest::Reporter* r, SkColorSpace* space,
|
||||
REPORTER_ASSERT(r, expectedGamma == space->gammaNamed());
|
||||
|
||||
|
||||
SkMatrix44 mat = space->xyz();
|
||||
const SkMatrix44& mat = space->xyz();
|
||||
const float src[] = {
|
||||
1, 0, 0, 1,
|
||||
0, 1, 0, 1,
|
||||
|
Loading…
Reference in New Issue
Block a user