From e28a6b55dfbcd510d86cca39a167d179b81e4f4c Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Wed, 25 Jul 2018 13:05:17 -0400 Subject: 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 Commit-Queue: Brian Osman Reviewed-by: Brian Osman --- src/utils/SkPatchUtils.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/utils') 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 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); -- cgit v1.2.3