aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2018-07-25 13:05:17 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-25 23:51:15 +0000
commite28a6b55dfbcd510d86cca39a167d179b81e4f4c (patch)
tree7d9151d55b67f749fd701b7c8fe52b6f922988d3 /src/utils
parent68300c270916b2740fccdbe6c6dce8f085e83316 (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/utils')
-rw-r--r--src/utils/SkPatchUtils.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/utils/SkPatchUtils.cpp b/src/utils/SkPatchUtils.cpp
index af91626b51..badd63ff15 100644
--- a/src/utils/SkPatchUtils.cpp
+++ b/src/utils/SkPatchUtils.cpp
@@ -8,6 +8,7 @@
#include "SkPatchUtils.h"
#include "SkColorData.h"
+#include "SkColorSpacePriv.h"
#include "SkGeometry.h"
#include "SkPM4f.h"
#include "SkTo.h"
@@ -254,8 +255,8 @@ struct SkRGBAf {
static void skcolor_to_float(SkRGBAf dst[], const SkColor src[], int count, SkColorSpace* dstCS,
bool doPremul) {
- // Source is always sRGB SkColor (safe because sRGB is a global singleton)
- auto srcCS = SkColorSpace::MakeSRGB().get();
+ // Source is always sRGB SkColor.
+ auto srcCS = sk_srgb_singleton();
auto op = doPremul ? SkColorSpaceXform::kPremul_AlphaOp : SkColorSpaceXform::kPreserve_AlphaOp;
SkAssertResult(SkColorSpaceXform::Apply(dstCS, SkColorSpaceXform::kRGBA_F32_ColorFormat, dst,
@@ -264,8 +265,8 @@ static void skcolor_to_float(SkRGBAf dst[], const SkColor src[], int count, SkCo
}
static void float_to_skcolor(SkColor dst[], const SkRGBAf src[], int count, SkColorSpace* srcCS) {
- // Destination is always sRGB SkColor (safe because sRGB is a global singleton)
- auto dstCS = SkColorSpace::MakeSRGB().get();
+ // Destination is always sRGB SkColor.
+ auto dstCS = sk_srgb_singleton();
SkAssertResult(SkColorSpaceXform::Apply(dstCS, SkColorSpaceXform::kBGRA_8888_ColorFormat, dst,
srcCS, SkColorSpaceXform::kRGBA_F32_ColorFormat, src,
count, SkColorSpaceXform::kPreserve_AlphaOp));
@@ -292,9 +293,9 @@ sk_sp<SkVertices> SkPatchUtils::MakeVertices(const SkPoint cubics[12], const SkC
return nullptr;
}
- // Treat null interpolation space as sRGB (safe because sRGB is a global singleton)
+ // Treat null interpolation space as sRGB.
if (!colorSpace) {
- colorSpace = SkColorSpace::MakeSRGB().get();
+ colorSpace = sk_srgb_singleton();
}
int vertexCount = SkToS32(mult64);