diff options
author | Mike Klein <mtklein@chromium.org> | 2018-07-25 13:05:17 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-25 23:51:15 +0000 |
commit | e28a6b55dfbcd510d86cca39a167d179b81e4f4c (patch) | |
tree | 7d9151d55b67f749fd701b7c8fe52b6f922988d3 /src/core/SkColorSpace.cpp | |
parent | 68300c270916b2740fccdbe6c6dce8f085e83316 (diff) |
add explicit accessor for sRGB singleton colorspaces
SkColorSpace::MakeSRGB().get() is scary, and causes more ref/unref
pairs than strictly necessary for these singletons.
This time the implementation is still in SkColorSpace.cpp,
so these should really work as singletons.
Change-Id: I40f2942c8dcde3040663a04c4f5330aca90868ae
Reviewed-on: https://skia-review.googlesource.com/143305
Auto-Submit: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/core/SkColorSpace.cpp')
-rw-r--r-- | src/core/SkColorSpace.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp index 3b08e29a89..239f98aac8 100644 --- a/src/core/SkColorSpace.cpp +++ b/src/core/SkColorSpace.cpp @@ -192,21 +192,21 @@ static SkColorSpace* singleton_colorspace(SkGammaNamed gamma, const float to_xyz return new SkColorSpace_XYZ(gamma, m44); } -static SkColorSpace* srgb() { +SkColorSpace* sk_srgb_singleton() { static SkColorSpace* cs = singleton_colorspace(kSRGB_SkGammaNamed, gSRGB_toXYZD50); return cs; } -static SkColorSpace* srgb_linear() { +SkColorSpace* sk_srgb_linear_singleton() { static SkColorSpace* cs = singleton_colorspace(kLinear_SkGammaNamed, gSRGB_toXYZD50); return cs; } sk_sp<SkColorSpace> SkColorSpace::MakeSRGB() { - return sk_ref_sp(srgb()); + return sk_ref_sp(sk_srgb_singleton()); } sk_sp<SkColorSpace> SkColorSpace::MakeSRGBLinear() { - return sk_ref_sp(srgb_linear()); + return sk_ref_sp(sk_srgb_linear_singleton()); } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -258,7 +258,7 @@ uint32_t SkColorSpace::toXYZD50Hash() const { } bool SkColorSpace::isSRGB() const { - return srgb() == this; + return sk_srgb_singleton() == this; } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -331,13 +331,13 @@ size_t SkColorSpace::writeToMemory(void* memory) const { SkASSERT(this->toXYZD50()); // If we have a named profile, only write the enum. const SkGammaNamed gammaNamed = this->gammaNamed(); - if (this == srgb()) { + if (this == sk_srgb_singleton()) { if (memory) { *((ColorSpaceHeader*) memory) = ColorSpaceHeader::Pack( k0_Version, kSRGB_NamedColorSpace, gammaNamed, 0); } return sizeof(ColorSpaceHeader); - } else if (this == srgb_linear()) { + } else if (this == sk_srgb_linear_singleton()) { if (memory) { *((ColorSpaceHeader*) memory) = ColorSpaceHeader::Pack( k0_Version, kSRGBLinear_NamedColorSpace, gammaNamed, 0); |