aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Florin Malita <fmalita@chromium.org>2017-07-19 10:32:28 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-19 14:55:24 +0000
commitfff3a40767df6d3a913c146d96b2b4284dffb4c5 (patch)
treef18895ee43241dfaf323feb46d429214b26acc84 /src
parent139eb805caca239bf451b4876e0d3a31dd9f0744 (diff)
Singleton SRGB color filters
Change-Id: I67e976e63bbb9ebb47616613e02adb97e6e2345c Reviewed-on: https://skia-review.googlesource.com/24303 Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkColorFilter.cpp12
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>();
}
///////////////////////////////////////////////////////////////////////////////////////////////////