diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkColorFilter.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp index d8e68c8db5..454fdb267c 100644 --- a/src/core/SkColorFilter.cpp +++ b/src/core/SkColorFilter.cpp @@ -277,14 +277,18 @@ void SkSRGBGammaColorFilter::toString(SkString* str) const { } #endif +template <SkSRGBGammaColorFilter::Direction dir> +sk_sp<SkColorFilter> MakeSRGBGammaCF() { + static SkColorFilter* gSingleton = new SkSRGBGammaColorFilter(dir); + return sk_ref_sp(gSingleton); +} + sk_sp<SkColorFilter> SkColorFilter::MakeLinearToSRGBGamma() { - return sk_sp<SkColorFilter>(new SkSRGBGammaColorFilter( - SkSRGBGammaColorFilter::Direction::kLinearToSRGB)); + return MakeSRGBGammaCF<SkSRGBGammaColorFilter::Direction::kLinearToSRGB>(); } sk_sp<SkColorFilter> SkColorFilter::MakeSRGBToLinearGamma() { - return sk_sp<SkColorFilter>(new SkSRGBGammaColorFilter( - SkSRGBGammaColorFilter::Direction::kSRGBToLinear)); + return MakeSRGBGammaCF<SkSRGBGammaColorFilter::Direction::kSRGBToLinear>(); } /////////////////////////////////////////////////////////////////////////////////////////////////// |