diff options
author | Brian Osman <brianosman@google.com> | 2016-10-24 09:24:02 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-10-24 14:02:27 +0000 |
commit | 526972ecb5411b84ba2f5e20252f178f9ee2151f (patch) | |
tree | ef89b6a40fcdf90ae8e0b00b8f7d247510e03656 | |
parent | 09732a6b0e7c4b087279095762f9d27a4f556aba (diff) |
Rename all color space factories from New* to Make*
Matches our naming convention for all other types - factories that
return sk_sp (or any type that intelligently manages its own
lifetime) are named Make.
Previous factories are still around, assuming
SK_SUPPORT_LEGACY_COLOR_SPACE_FACTORIES is defined. Enable that
define for Android, etc.
See also: https://codereview.chromium.org/2442053002/
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3822
Change-Id: Iaea9376490736b494e8ffc820831f052bbe1478d
Reviewed-on: https://skia-review.googlesource.com/3822
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
47 files changed, 178 insertions, 155 deletions
diff --git a/bench/ColorCodecBench.cpp b/bench/ColorCodecBench.cpp index fe3cdd24b5..11343dc334 100644 --- a/bench/ColorCodecBench.cpp +++ b/bench/ColorCodecBench.cpp @@ -92,9 +92,9 @@ void ColorCodecBench::decodeAndXformQCMS() { #endif void ColorCodecBench::xformOnly() { - sk_sp<SkColorSpace> srcSpace = SkColorSpace::NewICC(fSrcData->data(), fSrcData->size()); + sk_sp<SkColorSpace> srcSpace = SkColorSpace::MakeICC(fSrcData->data(), fSrcData->size()); if (!srcSpace) { - srcSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + srcSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); } std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(srcSpace.get(), fDstSpace.get()); @@ -160,8 +160,8 @@ void ColorCodecBench::onDelayedSetup() { } else #endif { - fDstSpace = FLAGS_srgb ? SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : - SkColorSpace::NewICC(dstData->data(), dstData->size()); + fDstSpace = FLAGS_srgb ? SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named) : + SkColorSpace::MakeICC(dstData->data(), dstData->size()); SkASSERT(fDstSpace); } @@ -178,7 +178,7 @@ void ColorCodecBench::onDelayedSetup() { float gammas[3] = { 1.8f, 2.0f, 2.5f, }; SkMatrix44 matrix = SkMatrix44(SkMatrix44::kUninitialized_Constructor); matrix.set3x3(0.30f, 0.31f, 0.28f, 0.32f, 0.33f, 0.29f, 0.27f, 0.30f, 0.30f); - fDstSpace = SkColorSpace::NewRGB(gammas, matrix); + fDstSpace = SkColorSpace::MakeRGB(gammas, matrix); } fDstInfo = fDstInfo.makeColorSpace(fDstSpace); diff --git a/bench/GrMipMapBench.cpp b/bench/GrMipMapBench.cpp index 096256c6cc..56b66ced25 100644 --- a/bench/GrMipMapBench.cpp +++ b/bench/GrMipMapBench.cpp @@ -36,8 +36,9 @@ protected: if (nullptr == context) { return; } + auto srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); SkImageInfo info = SkImageInfo::Make(fW, fH, kN32_SkColorType, kPremul_SkAlphaType, - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); + srgb); fSurface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info); } diff --git a/bench/SkLinearBitmapPipelineBench.cpp b/bench/SkLinearBitmapPipelineBench.cpp index ad5cf61882..d669ed9dcd 100644 --- a/bench/SkLinearBitmapPipelineBench.cpp +++ b/bench/SkLinearBitmapPipelineBench.cpp @@ -90,7 +90,7 @@ struct CommonBitmapFPBenchmark : public Benchmark { sk_ignore_unused_variable(trash); fInfo = SkImageInfo::MakeN32Premul(width, height, fIsSRGB ? - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr); + SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named) : nullptr); } bool isSuitableFor(Backend backend) override { diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index 6a0fb0445b..37e3f060bc 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -456,10 +456,10 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c kN32_SkColorType, kPremul_SkAlphaType, nullptr) CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaType, nullptr) - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); CPU_CONFIG(srgb, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType, srgbColorSpace) - auto srgbLinearColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + auto srgbLinearColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); CPU_CONFIG(f16, kRaster_Backend, kRGBA_F16_SkColorType, kPremul_SkAlphaType, srgbLinearColorSpace) } @@ -845,8 +845,8 @@ static Sink* create_sink(const SkCommandLineConfig* config) { #endif if (FLAGS_cpu) { - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); - auto srgbLinearColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + auto srgbLinearColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); SINK("565", RasterSink, kRGB_565_SkColorType); SINK("8888", RasterSink, kN32_SkColorType); diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index a38b96ee5a..8ff8b4c055 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -910,9 +910,9 @@ Error ColorCodecSrc::draw(SkCanvas* canvas) const { sk_sp<SkColorSpace> dstSpace = nullptr; if (kDst_sRGB_Mode == fMode) { - dstSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + dstSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); } else if (kDst_HPZR30w_Mode == fMode) { - dstSpace = SkColorSpace::NewICC(dstData->data(), dstData->size()); + dstSpace = SkColorSpace::MakeICC(dstData->data(), dstData->size()); } SkImageInfo decodeInfo = codec->getInfo().makeColorType(fColorType).makeColorSpace(dstSpace); diff --git a/fuzz/fuzz.cpp b/fuzz/fuzz.cpp index a4151359b8..db81882c79 100644 --- a/fuzz/fuzz.cpp +++ b/fuzz/fuzz.cpp @@ -387,7 +387,7 @@ int fuzz_skp(sk_sp<SkData> bytes) { } int fuzz_icc(sk_sp<SkData> bytes) { - sk_sp<SkColorSpace> space(SkColorSpace::NewICC(bytes->data(), bytes->size())); + sk_sp<SkColorSpace> space(SkColorSpace::MakeICC(bytes->data(), bytes->size())); if (!space) { SkDebugf("[terminated] Couldn't decode ICC.\n"); return 1; diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp index 0723c819a8..90df5bb3e4 100644 --- a/gm/all_bitmap_configs.cpp +++ b/gm/all_bitmap_configs.cpp @@ -266,7 +266,7 @@ DEF_SIMPLE_GM(all_variants_8888, canvas, 4 * SCALE + 30, 2 * SCALE + 10) { sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8); sk_sp<SkColorSpace> colorSpaces[] { - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named), + SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named), nullptr, }; for (auto colorSpace : colorSpaces) { diff --git a/gm/color4f.cpp b/gm/color4f.cpp index 8414659db9..715229d207 100644 --- a/gm/color4f.cpp +++ b/gm/color4f.cpp @@ -75,7 +75,7 @@ DEF_SIMPLE_GM(color4f, canvas, 1024, 260) { sk_sp<SkColorSpace> colorSpaces[]{ nullptr, - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) + SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named) }; for (auto colorSpace : colorSpaces) { const SkImageInfo info = SkImageInfo::Make(1024, 100, kN32_SkColorType, kPremul_SkAlphaType, @@ -111,9 +111,9 @@ DEF_SIMPLE_GM(color4shader, canvas, 1024, 260) { for (const auto& c4 : colors) { sk_sp<SkShader> shaders[] { SkShader::MakeColorShader(c4, nullptr), - SkShader::MakeColorShader(c4, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)), + SkShader::MakeColorShader(c4, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)), SkShader::MakeColorShader(c4, - SkColorSpace::NewRGB(SkColorSpace::kLinear_RenderTargetGamma, mat)), + SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, mat)), }; canvas->save(); diff --git a/gm/colorspacexform.cpp b/gm/colorspacexform.cpp index 33320ba5a8..6aea549ea8 100644 --- a/gm/colorspacexform.cpp +++ b/gm/colorspacexform.cpp @@ -35,9 +35,9 @@ protected: SkMatrix44 wideGamut(SkMatrix44::kUninitialized_Constructor); wideGamut.set3x3RowMajorf(kWideGamutRGB_toXYZD50); - sk_sp<SkColorSpace> srcSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> srcSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); sk_sp<SkColorSpace> dstSpace = - SkColorSpace::NewRGB(SkColorSpace::kLinear_RenderTargetGamma, wideGamut); + SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, wideGamut); std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(srcSpace.get(), dstSpace.get()); @@ -60,7 +60,7 @@ protected: canvas->save(); for (int i = 0; i < kNumColors; i++) { - sk_sp<SkColorSpace> space = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + auto space = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); sk_sp<SkShader> s = SkShader::MakeColorShader(colors[i], space); SkPaint paint; paint.setShader(s); diff --git a/gm/gamma.cpp b/gm/gamma.cpp index 80209e53f8..4e80bbf3b0 100644 --- a/gm/gamma.cpp +++ b/gm/gamma.cpp @@ -18,7 +18,7 @@ DEF_SIMPLE_GM(gamma, canvas, 850, 200) { const SkScalar tx = sz + 15.0f; const SkRect r = SkRect::MakeXYWH(0, 0, sz, sz); SkShader::TileMode rpt = SkShader::kRepeat_TileMode; - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); SkBitmap ditherBmp; ditherBmp.allocN32Pixels(2, 2); diff --git a/gm/gamut.cpp b/gm/gamut.cpp index 3c64915561..a54214ef35 100644 --- a/gm/gamut.cpp +++ b/gm/gamut.cpp @@ -132,13 +132,13 @@ static void draw_gamut_grid(SkCanvas* canvas, SkTArray<SkAutoTDelete<CellRendere switch (origInfo.colorType()) { case kRGBA_8888_SkColorType: case kBGRA_8888_SkColorType: - srgbCS = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); - wideCS = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGamma, + srgbCS = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + wideCS = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, wideGamutRGB_toXYZD50); break; case kRGBA_F16_SkColorType: - srgbCS = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); - wideCS = SkColorSpace::NewRGB(SkColorSpace::kLinear_RenderTargetGamma, + srgbCS = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); + wideCS = SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, wideGamutRGB_toXYZD50); break; default: diff --git a/gm/gradients.cpp b/gm/gradients.cpp index 4c0c8e7972..45b6564a64 100644 --- a/gm/gradients.cpp +++ b/gm/gradients.cpp @@ -61,7 +61,7 @@ static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data, static sk_sp<SkShader> MakeLinear4f(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm, const SkMatrix& localMatrix) { - auto srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + auto srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); return SkGradientShader::MakeLinear(pts, data.fColors4f, srgb, data.fPos, data.fCount, tm, 0, &localMatrix); } @@ -80,7 +80,7 @@ static sk_sp<SkShader> MakeRadial4f(const SkPoint pts[2], const GradData& data, SkPoint center; center.set(SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY)); - auto srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + auto srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); return SkGradientShader::MakeRadial(center, center.fX, data.fColors4f, srgb, data.fPos, data.fCount, tm, 0, &localMatrix); } @@ -99,7 +99,7 @@ static sk_sp<SkShader> MakeSweep4f(const SkPoint pts[2], const GradData& data, SkPoint center; center.set(SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY)); - auto srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + auto srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); return SkGradientShader::MakeSweep(center.fX, center.fY, data.fColors4f, srgb, data.fPos, data.fCount, 0, &localMatrix); } @@ -124,7 +124,7 @@ static sk_sp<SkShader> Make2Radial4f(const SkPoint pts[2], const GradData& data, SkScalarAve(pts[0].fY, pts[1].fY)); center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3) / 5), SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1) / 4)); - auto srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + auto srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); return SkGradientShader::MakeTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 7, center0, (pts[1].fX - pts[0].fX) / 2, data.fColors4f, srgb, data.fPos, data.fCount, tm, @@ -150,7 +150,7 @@ static sk_sp<SkShader> Make2Conical4f(const SkPoint pts[2], const GradData& data SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; center0.set(pts[0].fX + radius0, pts[0].fY + radius0); center1.set(pts[1].fX - radius1, pts[1].fY - radius1); - auto srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + auto srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); return SkGradientShader::MakeTwoPointConical(center1, radius1, center0, radius0, data.fColors4f, srgb, data.fPos, data.fCount, tm, 0, &localMatrix); diff --git a/gm/labpcsdemo.cpp b/gm/labpcsdemo.cpp index 4bd9ed8140..f9fffe1209 100644 --- a/gm/labpcsdemo.cpp +++ b/gm/labpcsdemo.cpp @@ -162,7 +162,7 @@ protected: if (iccData == nullptr) { return; } - sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewICC(iccData->bytes(), iccData->size()); + sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeICC(iccData->bytes(), iccData->size()); const int imageWidth = codec->getInfo().width(); const int imageHeight = codec->getInfo().height(); diff --git a/gm/mipmap.cpp b/gm/mipmap.cpp index baf5527556..fa25828f7d 100644 --- a/gm/mipmap.cpp +++ b/gm/mipmap.cpp @@ -89,7 +89,7 @@ static void show_mips(SkCanvas* canvas, SkImage* img) { */ DEF_SIMPLE_GM(mipmap_srgb, canvas, 260, 230) { sk_sp<SkImage> limg = make(nullptr); - sk_sp<SkImage> simg = make(SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); + sk_sp<SkImage> simg = make(SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); canvas->translate(10, 10); show_mips(canvas, limg.get()); @@ -140,7 +140,7 @@ static void show_mips_only(SkCanvas* canvas, SkImage* img) { */ DEF_SIMPLE_GM(mipmap_gray8_srgb, canvas, 260, 230) { sk_sp<SkImage> limg = make_g8_gradient(nullptr); - sk_sp<SkImage> simg = make_g8_gradient(SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); + sk_sp<SkImage> simg = make_g8_gradient(SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); canvas->translate(10, 10); show_mips_only(canvas, limg.get()); diff --git a/gyp/skia_for_android_framework_defines.gypi b/gyp/skia_for_android_framework_defines.gypi index f85d0730da..54ab773bc0 100644 --- a/gyp/skia_for_android_framework_defines.gypi +++ b/gyp/skia_for_android_framework_defines.gypi @@ -22,6 +22,7 @@ 'SK_IGNORE_GPU_DITHER', 'SK_SUPPORT_LEGACY_CLIP_REGIONOPS', 'SK_SUPPORT_LEGACY_SHADER_ISABITMAP', + 'SK_SUPPORT_LEGACY_COLOR_SPACE_FACTORIES', ], }, } diff --git a/include/core/SkColorSpace.h b/include/core/SkColorSpace.h index fc68fd4587..8d5705d455 100644 --- a/include/core/SkColorSpace.h +++ b/include/core/SkColorSpace.h @@ -93,20 +93,35 @@ public: * or as three exponents (R, G, B). * Gamut is specified using the matrix transformation to XYZ D50. */ - static sk_sp<SkColorSpace> NewRGB(RenderTargetGamma gamma, const SkMatrix44& toXYZD50); - static sk_sp<SkColorSpace> NewRGB(const SkColorSpaceTransferFn& coeffs, + static sk_sp<SkColorSpace> MakeRGB(RenderTargetGamma gamma, const SkMatrix44& toXYZD50); + static sk_sp<SkColorSpace> MakeRGB(const SkColorSpaceTransferFn& coeffs, const SkMatrix44& toXYZD50); - static sk_sp<SkColorSpace> NewRGB(const float exponents[3], const SkMatrix44& toXYZD50); + static sk_sp<SkColorSpace> MakeRGB(const float exponents[3], const SkMatrix44& toXYZD50); /** * Create a common, named SkColorSpace. */ - static sk_sp<SkColorSpace> NewNamed(Named); + static sk_sp<SkColorSpace> MakeNamed(Named); /** * Create an SkColorSpace from an ICC profile. */ - static sk_sp<SkColorSpace> NewICC(const void*, size_t); + static sk_sp<SkColorSpace> MakeICC(const void*, size_t); + +#ifdef SK_SUPPORT_LEGACY_COLOR_SPACE_FACTORIES + static sk_sp<SkColorSpace> NewRGB(RenderTargetGamma gamma, const SkMatrix44& toXYZD50) { + return MakeRGB(gamma, toXYZD50); + } + static sk_sp<SkColorSpace> NewRGB(const SkColorSpaceTransferFn& coeffs, + const SkMatrix44& toXYZD50) { + return MakeRGB(coeffs, toXYZD50); + } + static sk_sp<SkColorSpace> NewRGB(const float exponents[3], const SkMatrix44& toXYZD50) { + return MakeRGB(exponents, toXYZD50); + } + static sk_sp<SkColorSpace> NewNamed(Named named) { return MakeNamed(named); } + static sk_sp<SkColorSpace> NewICC(const void* input, size_t len) { return MakeICC(input, len); } +#endif /** * Returns true if the color space gamma is near enough to be approximated as sRGB. diff --git a/public.bzl b/public.bzl index 4655a645be..9308ecf249 100644 --- a/public.bzl +++ b/public.bzl @@ -613,6 +613,7 @@ DEFINES_ALL = [ "SK_SUPPORT_LEGACY_CLIP_REGIONOPS", "SK_SUPPORT_LEGACY_SHADER_ISABITMAP", "SK_SUPPORT_LEGACY_XFERMODE_OBJECT", + "SK_SUPPORT_LEGACY_COLOR_SPACE_FACTORIES", ] ################################################################################ diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 2194895e0d..20a1969d88 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -334,7 +334,7 @@ public: // Instead, we readPixels into a buffer that we claim is sRGB (readPixels doesn't // do gamut conversion), so these pixels then get thrown directly at the monitor, // giving us the expected results (the output is adapted to the monitor's gamut). - auto srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + auto srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); offscreenInfo = offscreenInfo.makeColorSpace(srgb); } SkBitmap bm; @@ -1593,7 +1593,7 @@ static sk_sp<SkColorSpace> getMonitorColorSpace() { const uint8_t* data = CFDataGetBytePtr(dataRef); size_t size = CFDataGetLength(dataRef); - sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewICC(data, size); + sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeICC(data, size); CFRelease(cs); CFRelease(dataRef); @@ -1618,7 +1618,7 @@ static sk_sp<SkColorSpace> getMonitorColorSpace() { DeleteDC(dc); if (success) { sk_sp<SkData> iccData = SkData::MakeFromFileName(icmPath); - return SkColorSpace::NewICC(iccData->data(), iccData->size()); + return SkColorSpace::MakeICC(iccData->data(), iccData->size()); } } } @@ -1660,13 +1660,13 @@ bool SampleWindow::onEvent(const SkEvent& evt) { sk_sp<SkColorSpace> colorSpace = nullptr; switch (gConfig[selected].fColorSpace) { case kSRGB_OutputColorSpace: - colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); break; case kMonitor_OutputColorSpace: colorSpace = getMonitorColorSpace(); if (!colorSpace) { // Fallback for platforms / machines where we can't get a monitor profile - colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); } break; case kLegacy_OutputColorSpace: diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index b9ae454a62..9f9f85c18a 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -229,14 +229,14 @@ bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut, sk_sp<SkData> iccData = get_icc_profile(decoderMgr->dinfo()); sk_sp<SkColorSpace> colorSpace = nullptr; if (iccData) { - colorSpace = SkColorSpace::NewICC(iccData->data(), iccData->size()); + colorSpace = SkColorSpace::MakeICC(iccData->data(), iccData->size()); if (!colorSpace) { SkCodecPrintf("Could not create SkColorSpace from ICC data.\n"); } } if (!colorSpace) { // Treat unmarked jpegs as sRGB. - colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); } const int width = decoderMgr->dinfo()->image_width; diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp index 23c74e2122..09efd10227 100644 --- a/src/codec/SkPngCodec.cpp +++ b/src/codec/SkPngCodec.cpp @@ -344,7 +344,7 @@ sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) { int compression; if (PNG_INFO_iCCP == png_get_iCCP(png_ptr, info_ptr, &name, &compression, &profile, &length)) { - return SkColorSpace::NewICC(profile, length); + return SkColorSpace::MakeICC(profile, length); } // Second, check for sRGB. @@ -355,7 +355,7 @@ sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) { // FIXME (msarett): Extract this information from the sRGB chunk once // we are able to handle this information in // SkColorSpace. - return SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + return SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); } // Next, check for chromaticities. @@ -386,12 +386,12 @@ sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) { gammas[1] = value; gammas[2] = value; - return SkColorSpace::NewRGB(gammas, toXYZD50); + return SkColorSpace::MakeRGB(gammas, toXYZD50); } // Default to sRGB gamma if the image has color space information, // but does not specify gamma. - return SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGamma, toXYZD50); + return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, toXYZD50); } // Last, check for gamma. @@ -407,7 +407,7 @@ sk_sp<SkColorSpace> read_color_space(png_structp png_ptr, png_infop info_ptr) { SkMatrix44 toXYZD50(SkMatrix44::kUninitialized_Constructor); toXYZD50.set3x3RowMajorf(gSRGB_toXYZD50); - return SkColorSpace::NewRGB(gammas, toXYZD50); + return SkColorSpace::MakeRGB(gammas, toXYZD50); } #endif // LIBPNG >= 1.6 @@ -988,7 +988,7 @@ void AutoCleanPng::infoCallback() { sk_sp<SkColorSpace> colorSpace = read_color_space(fPng_ptr, fInfo_ptr); if (!colorSpace) { // Treat unmarked pngs as sRGB. - colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); } SkEncodedInfo encodedInfo = SkEncodedInfo::Make(color, alpha, 8); diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp index 746e9b79ad..ca42093f3f 100644 --- a/src/codec/SkWebpCodec.cpp +++ b/src/codec/SkWebpCodec.cpp @@ -63,11 +63,11 @@ SkCodec* SkWebpCodec::NewFromStream(SkStream* stream) { SkAutoTCallVProc<WebPChunkIterator, WebPDemuxReleaseChunkIterator> autoCI(&chunkIterator); sk_sp<SkColorSpace> colorSpace = nullptr; if (WebPDemuxGetChunk(demux, "ICCP", 1, &chunkIterator)) { - colorSpace = SkColorSpace::NewICC(chunkIterator.chunk.bytes, chunkIterator.chunk.size); + colorSpace = SkColorSpace::MakeICC(chunkIterator.chunk.bytes, chunkIterator.chunk.size); } if (!colorSpace) { - colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); } // Since we do not yet support animation, we get the |width|, |height|, |color|, and |alpha| diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp index ba45d9b6f4..b6d8afee44 100644 --- a/src/core/SkColorSpace.cpp +++ b/src/core/SkColorSpace.cpp @@ -124,7 +124,7 @@ static bool xyz_almost_equal(const SkMatrix44& toXYZD50, const float* standard) color_space_almost_equal(toXYZD50.getFloat(3, 3), 1.0f); } -sk_sp<SkColorSpace> SkColorSpace::NewRGB(const float values[3], const SkMatrix44& toXYZD50) { +sk_sp<SkColorSpace> SkColorSpace::MakeRGB(const float values[3], const SkMatrix44& toXYZD50) { if (0.0f > values[0] || 0.0f > values[1] || 0.0f > values[2]) { return nullptr; } @@ -152,24 +152,24 @@ sk_sp<SkColorSpace> SkColorSpace::NewRGB(const float values[3], const SkMatrix44 gammas, toXYZD50, nullptr)); } - return SkColorSpace_Base::NewRGB(gammaNamed, toXYZD50); + return SkColorSpace_Base::MakeRGB(gammaNamed, toXYZD50); } -sk_sp<SkColorSpace> SkColorSpace_Base::NewRGB(SkGammaNamed gammaNamed, const SkMatrix44& toXYZD50) { +sk_sp<SkColorSpace> SkColorSpace_Base::MakeRGB(SkGammaNamed gammaNamed, const SkMatrix44& toXYZD50) { switch (gammaNamed) { case kSRGB_SkGammaNamed: if (xyz_almost_equal(toXYZD50, gSRGB_toXYZD50)) { - return SkColorSpace::NewNamed(kSRGB_Named); + return SkColorSpace::MakeNamed(kSRGB_Named); } break; case k2Dot2Curve_SkGammaNamed: if (xyz_almost_equal(toXYZD50, gAdobeRGB_toXYZD50)) { - return SkColorSpace::NewNamed(kAdobeRGB_Named); + return SkColorSpace::MakeNamed(kAdobeRGB_Named); } break; case kLinear_SkGammaNamed: if (xyz_almost_equal(toXYZD50, gSRGB_toXYZD50)) { - return SkColorSpace::NewNamed(kSRGBLinear_Named); + return SkColorSpace::MakeNamed(kSRGBLinear_Named); } break; case kNonStandard_SkGammaNamed: @@ -182,29 +182,29 @@ sk_sp<SkColorSpace> SkColorSpace_Base::NewRGB(SkGammaNamed gammaNamed, const SkM return sk_sp<SkColorSpace>(new SkColorSpace_XYZ(gammaNamed, toXYZD50)); } -sk_sp<SkColorSpace> SkColorSpace::NewRGB(RenderTargetGamma gamma, const SkMatrix44& toXYZD50) { +sk_sp<SkColorSpace> SkColorSpace::MakeRGB(RenderTargetGamma gamma, const SkMatrix44& toXYZD50) { switch (gamma) { case kLinear_RenderTargetGamma: - return SkColorSpace_Base::NewRGB(kLinear_SkGammaNamed, toXYZD50); + return SkColorSpace_Base::MakeRGB(kLinear_SkGammaNamed, toXYZD50); case kSRGB_RenderTargetGamma: - return SkColorSpace_Base::NewRGB(kSRGB_SkGammaNamed, toXYZD50); + return SkColorSpace_Base::MakeRGB(kSRGB_SkGammaNamed, toXYZD50); default: return nullptr; } } -sk_sp<SkColorSpace> SkColorSpace::NewRGB(const SkColorSpaceTransferFn& coeffs, +sk_sp<SkColorSpace> SkColorSpace::MakeRGB(const SkColorSpaceTransferFn& coeffs, const SkMatrix44& toXYZD50) { if (!is_valid_transfer_fn(coeffs)) { return nullptr; } if (is_almost_srgb(coeffs)) { - return SkColorSpace::NewRGB(kSRGB_RenderTargetGamma, toXYZD50); + return SkColorSpace::MakeRGB(kSRGB_RenderTargetGamma, toXYZD50); } if (is_almost_2dot2(coeffs)) { - return SkColorSpace_Base::NewRGB(k2Dot2Curve_SkGammaNamed, toXYZD50); + return SkColorSpace_Base::MakeRGB(k2Dot2Curve_SkGammaNamed, toXYZD50); } void* memory = sk_malloc_throw(sizeof(SkGammas) + sizeof(SkColorSpaceTransferFn)); @@ -228,7 +228,7 @@ static SkColorSpace* gAdobeRGB; static SkColorSpace* gSRGB; static SkColorSpace* gSRGBLinear; -sk_sp<SkColorSpace> SkColorSpace::NewNamed(Named named) { +sk_sp<SkColorSpace> SkColorSpace::MakeNamed(Named named) { static SkOnce sRGBOnce; static SkOnce adobeRGBOnce; static SkOnce sRGBLinearOnce; @@ -478,7 +478,7 @@ sk_sp<SkColorSpace> SkColorSpace::Deserialize(const void* data, size_t length) { data = SkTAddOffset<const void>(data, sizeof(ColorSpaceHeader)); length -= sizeof(ColorSpaceHeader); if (0 == header.fFlags) { - return NewNamed((Named) header.fNamed); + return MakeNamed((Named) header.fNamed); } switch ((SkGammaNamed) header.fGammaNamed) { @@ -491,7 +491,7 @@ sk_sp<SkColorSpace> SkColorSpace::Deserialize(const void* data, size_t length) { SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor); toXYZ.set3x4RowMajorf((const float*) data); - return SkColorSpace_Base::NewRGB((SkGammaNamed) header.fGammaNamed, toXYZ); + return SkColorSpace_Base::MakeRGB((SkGammaNamed) header.fGammaNamed, toXYZ); } default: break; @@ -510,7 +510,7 @@ sk_sp<SkColorSpace> SkColorSpace::Deserialize(const void* data, size_t length) { return nullptr; } - return NewICC(data, profileSize); + return MakeICC(data, profileSize); } case ColorSpaceHeader::kFloatGamma_Flag: { if (length < 15 * sizeof(float)) { @@ -525,7 +525,7 @@ sk_sp<SkColorSpace> SkColorSpace::Deserialize(const void* data, size_t length) { SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor); toXYZ.set3x4RowMajorf((const float*) data); - return SkColorSpace::NewRGB(gammas, toXYZ); + return SkColorSpace::MakeRGB(gammas, toXYZ); } case ColorSpaceHeader::kTransferFn_Flag: { if (length < 19 * sizeof(float)) { @@ -544,7 +544,7 @@ sk_sp<SkColorSpace> SkColorSpace::Deserialize(const void* data, size_t length) { SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor); toXYZ.set3x4RowMajorf((const float*) data); - return SkColorSpace::NewRGB(transferFn, toXYZ); + return SkColorSpace::MakeRGB(transferFn, toXYZ); } default: return nullptr; diff --git a/src/core/SkColorSpace_Base.h b/src/core/SkColorSpace_Base.h index 31edfa28be..76595e9542 100644 --- a/src/core/SkColorSpace_Base.h +++ b/src/core/SkColorSpace_Base.h @@ -214,7 +214,12 @@ private: */ sk_sp<SkData> writeToICC() const; - static sk_sp<SkColorSpace> NewRGB(SkGammaNamed gammaNamed, const SkMatrix44& toXYZD50); + static sk_sp<SkColorSpace> MakeRGB(SkGammaNamed gammaNamed, const SkMatrix44& toXYZD50); +#ifdef SK_SUPPORT_LEGACY_COLOR_SPACE_FACTORIES + static sk_sp<SkColorSpace> NewRGB(SkGammaNamed gammaNamed, const SkMatrix44& toXYZD50) { + return MakeRGB(gammaNamed, toXYZD50); + } +#endif SkColorSpace_Base(SkGammaNamed gammaNamed, const SkMatrix44& toXYZ); diff --git a/src/core/SkColorSpace_ICC.cpp b/src/core/SkColorSpace_ICC.cpp index 6fc3090caf..4a58cd682c 100644 --- a/src/core/SkColorSpace_ICC.cpp +++ b/src/core/SkColorSpace_ICC.cpp @@ -898,7 +898,7 @@ static bool tag_equals(const ICCTag* a, const ICCTag* b, const uint8_t* base) { return !memcmp(a->addr(base), b->addr(base), a->fLength); } -sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* input, size_t len) { +sk_sp<SkColorSpace> SkColorSpace::MakeICC(const void* input, size_t len) { if (!input || len < kICCHeaderSize) { return_null("Data is null or not large enough to contain an ICC profile"); } @@ -1083,7 +1083,7 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* input, size_t len) { mat, std::move(data))); } - return SkColorSpace_Base::NewRGB(gammaNamed, mat); + return SkColorSpace_Base::MakeRGB(gammaNamed, mat); } // Recognize color profile specified by A2B0 tag. diff --git a/src/core/SkColorSpace_XYZ.cpp b/src/core/SkColorSpace_XYZ.cpp index 3570e25b62..35d3d29364 100644 --- a/src/core/SkColorSpace_XYZ.cpp +++ b/src/core/SkColorSpace_XYZ.cpp @@ -60,7 +60,7 @@ sk_sp<SkColorSpace> SkColorSpace_XYZ::makeLinearGamma() { if (this->gammaIsLinear()) { return sk_ref_sp(this); } - return SkColorSpace_Base::NewRGB(kLinear_SkGammaNamed, fToXYZD50); + return SkColorSpace_Base::MakeRGB(kLinear_SkGammaNamed, fToXYZD50); } void SkColorSpace_XYZ::toDstGammaTables(const uint8_t* tables[3], sk_sp<SkData>* storage, diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp index 75c6807d17..db796b308d 100644 --- a/src/core/SkImageInfo.cpp +++ b/src/core/SkImageInfo.cpp @@ -19,7 +19,7 @@ static bool color_type_is_valid(SkColorType colorType) { SkImageInfo SkImageInfo::MakeS32(int width, int height, SkAlphaType at) { return SkImageInfo(width, height, kN32_SkColorType, at, - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); + SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); } static const int kColorTypeMask = 0x0F; diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 6c99b37ad7..96817a0ed1 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -217,7 +217,7 @@ SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc, const SkMatri if (!desc.fColorSpace) { // This happens if we were constructed from SkColors, so our colors are really sRGB - fColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + fColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); } else { // The color space refers to the float colors, so it must be linear gamma SkASSERT(desc.fColorSpace->gammaIsLinear()); @@ -741,12 +741,12 @@ void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap, case GradientBitmapType::kSRGB: info = SkImageInfo::Make(kCache32Count, 1, kRGBA_8888_SkColorType, kPremul_SkAlphaType, - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); + SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named)); break; case GradientBitmapType::kHalfFloat: info = SkImageInfo::Make( kCache32Count, 1, kRGBA_F16_SkColorType, kPremul_SkAlphaType, - SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named)); + SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named)); break; default: SkFAIL("Unexpected bitmap type"); diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp index 5b5428ac0d..3060062653 100644 --- a/src/gpu/GrDrawContext.cpp +++ b/src/gpu/GrDrawContext.cpp @@ -95,7 +95,7 @@ GrDrawContext::GrDrawContext(GrContext* context, { if (fColorSpace) { // sRGB sources are very common (SkColor, etc...), so we cache that gamut transformation - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); fColorXformFromSRGB = GrColorSpaceXform::Make(srgbColorSpace.get(), fColorSpace.get()); } SkDEBUGCODE(this->validate();) diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp index a0a35ccf74..20f92f0bb3 100644 --- a/src/gpu/GrTestUtils.cpp +++ b/src/gpu/GrTestUtils.cpp @@ -299,8 +299,8 @@ sk_sp<SkColorSpace> TestColorSpace(SkRandom* random) { // No color space (legacy mode) gColorSpaces[0] = nullptr; // sRGB or Adobe - gColorSpaces[1] = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); - gColorSpaces[2] = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named); + gColorSpaces[1] = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + gColorSpaces[2] = SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named); } return gColorSpaces[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gColorSpaces)))]; } @@ -310,8 +310,8 @@ sk_sp<GrColorSpaceXform> TestColorXform(SkRandom* random) { static bool gOnce; if (!gOnce) { gOnce = true; - sk_sp<SkColorSpace> srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); - sk_sp<SkColorSpace> adobe = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named); + sk_sp<SkColorSpace> srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> adobe = SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named); // No gamut change gXforms[0] = nullptr; // To larger gamut diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 7d4d67805c..150087828e 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -445,7 +445,7 @@ GrColor4f SkColorToPremulGrColor4f(SkColor c, SkColorSpace* dstColorSpace) { GrColor4f SkColorToUnpremulGrColor4f(SkColor c, SkColorSpace* dstColorSpace) { if (dstColorSpace) { - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); auto gamutXform = GrColorSpaceXform::Make(srgbColorSpace.get(), dstColorSpace); return SkColorToUnpremulGrColor4f(c, true, gamutXform.get()); } else { diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp index d82187a3b6..7ae1263264 100644 --- a/src/views/SkWindow.cpp +++ b/src/views/SkWindow.cpp @@ -354,7 +354,7 @@ sk_sp<SkSurface> SkWindow::makeGpuBackedSurface(const AttachmentInfo& attachment sk_sp<SkColorSpace> colorSpace = grContext->caps()->srgbSupport() && SkImageInfoIsGammaCorrect(info()) - ? SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr; + ? SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named) : nullptr; return SkSurface::MakeFromBackendRenderTarget(grContext, desc, colorSpace, &fSurfaceProps); } diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index 45455b4405..63ab289bd9 100644 --- a/tests/CodecTest.cpp +++ b/tests/CodecTest.cpp @@ -1046,7 +1046,7 @@ static void check_color_xform(skiatest::Reporter* r, const char* path) { const int dstHeight = subsetHeight / opts.fSampleSize; sk_sp<SkData> data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); - sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewICC(data->data(), data->size()); + sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeICC(data->data(), data->size()); SkImageInfo dstInfo = codec->getInfo().makeWH(dstWidth, dstHeight) .makeColorType(kN32_SkColorType) .makeColorSpace(colorSpace); diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp index d0d88050f6..ac4ba04af0 100644 --- a/tests/ColorSpaceTest.cpp +++ b/tests/ColorSpaceTest.cpp @@ -73,7 +73,7 @@ static constexpr float g_sRGB_G[]{ 0.3853f, 0.7170f, 0.0971f }; static constexpr float g_sRGB_B[]{ 0.1430f, 0.0606f, 0.7139f }; DEF_TEST(ColorSpace_sRGB, r) { - test_space(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), + test_space(r, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).get(), g_sRGB_R, g_sRGB_G, g_sRGB_B, kSRGB_SkGammaNamed); } @@ -102,28 +102,28 @@ DEF_TEST(ColorSpaceParseICCProfiles, r) { DEF_TEST(ColorSpaceSRGBCompare, r) { // Create an sRGB color space by name - sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); // Create an sRGB color space by value SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor); srgbToxyzD50.set3x3RowMajorf(g_sRGB_XYZ); sk_sp<SkColorSpace> rgbColorSpace = - SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGamma, srgbToxyzD50); + SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, srgbToxyzD50); REPORTER_ASSERT(r, rgbColorSpace == namedColorSpace); // Change a single value from the sRGB matrix srgbToxyzD50.set(2, 2, 0.5f); sk_sp<SkColorSpace> strangeColorSpace = - SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGamma, srgbToxyzD50); + SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, srgbToxyzD50); REPORTER_ASSERT(r, strangeColorSpace != namedColorSpace); } DEF_TEST(ColorSpaceSRGBLinearCompare, r) { // Create the linear sRGB color space by name - sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); // Create the linear sRGB color space via the sRGB color space's makeLinearGamma() - auto srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + auto srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); auto srgbXYZ = static_cast<SkColorSpace_XYZ*>(srgb.get()); sk_sp<SkColorSpace> viaSrgbColorSpace = srgbXYZ->makeLinearGamma(); REPORTER_ASSERT(r, namedColorSpace == viaSrgbColorSpace); @@ -132,13 +132,13 @@ DEF_TEST(ColorSpaceSRGBLinearCompare, r) { SkMatrix44 srgbToxyzD50(SkMatrix44::kUninitialized_Constructor); srgbToxyzD50.set3x3RowMajorf(g_sRGB_XYZ); sk_sp<SkColorSpace> rgbColorSpace = - SkColorSpace::NewRGB(SkColorSpace::kLinear_RenderTargetGamma, srgbToxyzD50); + SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, srgbToxyzD50); REPORTER_ASSERT(r, rgbColorSpace == namedColorSpace); // Change a single value from the sRGB matrix srgbToxyzD50.set(2, 2, 0.5f); sk_sp<SkColorSpace> strangeColorSpace = - SkColorSpace::NewRGB(SkColorSpace::kLinear_RenderTargetGamma, srgbToxyzD50); + SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, srgbToxyzD50); REPORTER_ASSERT(r, strangeColorSpace != namedColorSpace); } @@ -151,9 +151,9 @@ public: DEF_TEST(ColorSpaceWriteICC, r) { // Test writing a new ICC profile - sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> namedColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); sk_sp<SkData> namedData = ColorSpaceTest::WriteToICC(namedColorSpace.get()); - sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::NewICC(namedData->data(), namedData->size()); + sk_sp<SkColorSpace> iccColorSpace = SkColorSpace::MakeICC(namedData->data(), namedData->size()); test_space(r, iccColorSpace.get(), g_sRGB_R, g_sRGB_G, g_sRGB_B, k2Dot2Curve_SkGammaNamed); // FIXME (msarett): Test disabled. sRGB profiles are written approximately as 2.2f curves. // REPORTER_ASSERT(r, iccColorSpace == namedColorSpace); @@ -165,11 +165,11 @@ DEF_TEST(ColorSpaceWriteICC, r) { if (!monitorData) { return; } - sk_sp<SkColorSpace> monitorSpace = SkColorSpace::NewICC(monitorData->data(), - monitorData->size()); + sk_sp<SkColorSpace> monitorSpace = SkColorSpace::MakeICC(monitorData->data(), + monitorData->size()); sk_sp<SkData> newMonitorData = ColorSpaceTest::WriteToICC(monitorSpace.get()); - sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::NewICC(newMonitorData->data(), - newMonitorData->size()); + sk_sp<SkColorSpace> newMonitorSpace = SkColorSpace::MakeICC(newMonitorData->data(), + newMonitorData->size()); SkASSERT(SkColorSpace_Base::Type::kXYZ == as_CSB(monitorSpace)->type()); SkColorSpace_XYZ* monitorSpaceXYZ = static_cast<SkColorSpace_XYZ*>(monitorSpace.get()); SkASSERT(SkColorSpace_Base::Type::kXYZ == as_CSB(newMonitorSpace)->type()); @@ -190,7 +190,7 @@ DEF_TEST(ColorSpace_Named, r) { }; for (auto rec : recs) { - auto cs = SkColorSpace::NewNamed(rec.fNamed); + auto cs = SkColorSpace::MakeNamed(rec.fNamed); REPORTER_ASSERT(r, cs); if (cs) { SkASSERT(SkColorSpace_Base::Type::kXYZ == as_CSB(cs)->type()); @@ -223,23 +223,23 @@ static void test_serialize(skiatest::Reporter* r, SkColorSpace* space, bool isNa } DEF_TEST(ColorSpace_Serialize, r) { - test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named).get(), true); - test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named).get(), true); - test_serialize(r, SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named).get(), true); + test_serialize(r, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).get(), true); + test_serialize(r, SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named).get(), true); + test_serialize(r, SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named).get(), true); sk_sp<SkData> monitorData = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); - test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->size()).get(), false); + test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); monitorData = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc").c_str()); - test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->size()).get(), false); + test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc").c_str()); - test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->size()).get(), false); + test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str()); - test_serialize(r, SkColorSpace::NewICC(monitorData->data(), monitorData->size()).get(), false); + test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); const float gammas[] = { 1.1f, 1.2f, 1.7f, }; SkMatrix44 toXYZ(SkMatrix44::kIdentity_Constructor); - test_serialize(r, SkColorSpace::NewRGB(gammas, toXYZ).get(), false); + test_serialize(r, SkColorSpace::MakeRGB(gammas, toXYZ).get(), false); SkColorSpaceTransferFn fn; fn.fA = 1.0f; @@ -249,27 +249,27 @@ DEF_TEST(ColorSpace_Serialize, r) { fn.fE = 1.0f; fn.fF = 0.0f; fn.fG = 1.0f; - test_serialize(r, SkColorSpace::NewRGB(fn, toXYZ).get(), false); + test_serialize(r, SkColorSpace::MakeRGB(fn, toXYZ).get(), false); } DEF_TEST(ColorSpace_Equals, r) { - sk_sp<SkColorSpace> srgb = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); - sk_sp<SkColorSpace> adobe = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named); + sk_sp<SkColorSpace> srgb = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> adobe = SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named); sk_sp<SkData> data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); - sk_sp<SkColorSpace> z30 = SkColorSpace::NewICC(data->data(), data->size()); + sk_sp<SkColorSpace> z30 = SkColorSpace::MakeICC(data->data(), data->size()); data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc").c_str()); - sk_sp<SkColorSpace> z32 = SkColorSpace::NewICC(data->data(), data->size()); + sk_sp<SkColorSpace> z32 = SkColorSpace::MakeICC(data->data(), data->size()); data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc").c_str()); - sk_sp<SkColorSpace> upperLeft = SkColorSpace::NewICC(data->data(), data->size()); + sk_sp<SkColorSpace> upperLeft = SkColorSpace::MakeICC(data->data(), data->size()); data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str()); - sk_sp<SkColorSpace> upperRight = SkColorSpace::NewICC(data->data(), data->size()); + sk_sp<SkColorSpace> upperRight = SkColorSpace::MakeICC(data->data(), data->size()); const float gammas1[] = { 1.1f, 1.2f, 1.3f, }; const float gammas2[] = { 1.1f, 1.2f, 1.7f, }; SkMatrix44 toXYZ(SkMatrix44::kIdentity_Constructor); - sk_sp<SkColorSpace> rgb1 = SkColorSpace::NewRGB(gammas1, toXYZ); - sk_sp<SkColorSpace> rgb2 = SkColorSpace::NewRGB(gammas2, toXYZ); - sk_sp<SkColorSpace> rgb3 = SkColorSpace::NewRGB(gammas1, toXYZ); + sk_sp<SkColorSpace> rgb1 = SkColorSpace::MakeRGB(gammas1, toXYZ); + sk_sp<SkColorSpace> rgb2 = SkColorSpace::MakeRGB(gammas2, toXYZ); + sk_sp<SkColorSpace> rgb3 = SkColorSpace::MakeRGB(gammas1, toXYZ); SkColorSpaceTransferFn fn; fn.fA = 1.0f; @@ -279,7 +279,7 @@ DEF_TEST(ColorSpace_Equals, r) { fn.fE = 1.0f; fn.fF = 0.0f; fn.fG = 1.0f; - sk_sp<SkColorSpace> rgb4 = SkColorSpace::NewRGB(fn, toXYZ); + sk_sp<SkColorSpace> rgb4 = SkColorSpace::MakeRGB(fn, toXYZ); REPORTER_ASSERT(r, SkColorSpace::Equals(nullptr, nullptr)); REPORTER_ASSERT(r, SkColorSpace::Equals(srgb.get(), srgb.get())); @@ -321,6 +321,6 @@ DEF_TEST(ColorSpace_Primaries, r) { bool result = primaries.toXYZD50(&toXYZ); REPORTER_ASSERT(r, result); - sk_sp<SkColorSpace> space = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGamma, toXYZ); - REPORTER_ASSERT(r, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) == space); + sk_sp<SkColorSpace> space = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, toXYZ); + REPORTER_ASSERT(r, SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named) == space); } diff --git a/tests/ImageIsOpaqueTest.cpp b/tests/ImageIsOpaqueTest.cpp index 4389a3d892..ab995c8140 100644 --- a/tests/ImageIsOpaqueTest.cpp +++ b/tests/ImageIsOpaqueTest.cpp @@ -40,18 +40,18 @@ static void test_flatten(skiatest::Reporter* reporter, const SkImageInfo& info) DEF_TEST(ImageInfo_flattening, reporter) { sk_sp<SkData> data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); - sk_sp<SkColorSpace> space0 = SkColorSpace::NewICC(data->data(), data->size()); + sk_sp<SkColorSpace> space0 = SkColorSpace::MakeICC(data->data(), data->size()); data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc").c_str()); - sk_sp<SkColorSpace> space1 = SkColorSpace::NewICC(data->data(), data->size()); + sk_sp<SkColorSpace> space1 = SkColorSpace::MakeICC(data->data(), data->size()); data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc").c_str()); - sk_sp<SkColorSpace> space2 = SkColorSpace::NewICC(data->data(), data->size()); + sk_sp<SkColorSpace> space2 = SkColorSpace::MakeICC(data->data(), data->size()); data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str()); - sk_sp<SkColorSpace> space3 = SkColorSpace::NewICC(data->data(), data->size()); + sk_sp<SkColorSpace> space3 = SkColorSpace::MakeICC(data->data(), data->size()); sk_sp<SkColorSpace> spaces[] = { nullptr, - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named), - SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named), + SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named), + SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named), space0, space1, space2, diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp index 9acf82977f..8855c3d15f 100644 --- a/tests/SRGBMipMapTest.cpp +++ b/tests/SRGBMipMapTest.cpp @@ -120,7 +120,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) { SkAutoTUnref<GrTexture> texture(texProvider->createTexture(desc, SkBudgeted::kNo, texData, 0)); // Create two draw contexts (L32 and S32) - sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); sk_sp<GrDrawContext> l32DrawContext = context->makeDrawContext(SkBackingFit::kExact, rtS, rtS, kRGBA_8888_GrPixelConfig, nullptr); diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 180f2d985b..0ccf51f040 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -919,13 +919,13 @@ static void test_surface_creation_and_snapshot_with_color_space( bool f16Support, std::function<sk_sp<SkSurface>(const SkImageInfo&)> surfaceMaker) { - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); - auto adobeColorSpace = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); + auto adobeColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named); const SkMatrix44* srgbMatrix = as_CSB(srgbColorSpace)->toXYZD50(); SkASSERT(srgbMatrix); const float oddGamma[] = { 2.4f, 2.4f, 2.4f }; - auto oddColorSpace = SkColorSpace::NewRGB(oddGamma, *srgbMatrix); - auto linearColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named); + auto oddColorSpace = SkColorSpace::MakeRGB(oddGamma, *srgbMatrix); + auto linearColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named); const struct { SkColorType fColorType; diff --git a/tests/TestConfigParsing.cpp b/tests/TestConfigParsing.cpp index ec6d721908..9675eedbc9 100644 --- a/tests/TestConfigParsing.cpp +++ b/tests/TestConfigParsing.cpp @@ -86,7 +86,7 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) { SkCommandLineConfigArray configs; ParseConfigs(config1, &configs); - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); REPORTER_ASSERT(reporter, configs.count() == config1.count()); for (int i = 0; i < config1.count(); ++i) { diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp index f695bf1578..147f6f0c26 100644 --- a/tools/flags/SkCommonFlagsConfig.cpp +++ b/tools/flags/SkCommonFlagsConfig.cpp @@ -285,8 +285,8 @@ static bool parse_option_gpu_color(const SkString& value, // First, figure out color gamut that we'll work in (default to sRGB) const bool linearGamma = commands[0].equals("f16"); - *outColorSpace = SkColorSpace::NewNamed(linearGamma ? SkColorSpace::kSRGBLinear_Named - : SkColorSpace::kSRGB_Named); + *outColorSpace = SkColorSpace::MakeNamed(linearGamma ? SkColorSpace::kSRGBLinear_Named + : SkColorSpace::kSRGB_Named); if (commands.count() == 2) { if (commands[1].equals("srgb")) { // sRGB gamut (which is our default) @@ -299,10 +299,10 @@ static bool parse_option_gpu_color(const SkString& value, }; SkMatrix44 wideGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor); wideGamutRGBMatrix.set3x3RowMajorf(gWideGamutRGB_toXYZD50); - *outColorSpace = SkColorSpace::NewRGB(linearGamma + *outColorSpace = SkColorSpace::MakeRGB(linearGamma ? SkColorSpace::kLinear_RenderTargetGamma : SkColorSpace::kSRGB_RenderTargetGamma, - wideGamutRGBMatrix); + wideGamutRGBMatrix); } else if (commands[1].equals("narrow")) { // NarrowGamut RGB (an artifically smaller than sRGB gamut) SkColorSpacePrimaries primaries ={ @@ -313,10 +313,10 @@ static bool parse_option_gpu_color(const SkString& value, }; SkMatrix44 narrowGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor); primaries.toXYZD50(&narrowGamutRGBMatrix); - *outColorSpace = SkColorSpace::NewRGB(linearGamma + *outColorSpace = SkColorSpace::MakeRGB(linearGamma ? SkColorSpace::kLinear_RenderTargetGamma : SkColorSpace::kSRGB_RenderTargetGamma, - narrowGamutRGBMatrix); + narrowGamutRGBMatrix); } else { // Unknown color gamut return false; diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp index 453320122b..b252f8da62 100644 --- a/tools/picture_utils.cpp +++ b/tools/picture_utils.cpp @@ -79,7 +79,7 @@ namespace sk_tools { SkAutoTMalloc<uint32_t> rgba(w*h); - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); if (bitmap. colorType() == kN32_SkColorType && bitmap.colorSpace() == srgbColorSpace.get()) { // These are premul sRGB 8-bit pixels in SkPMColor order. diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp index 487da35424..9da9f0f859 100644 --- a/tools/skiaserve/Request.cpp +++ b/tools/skiaserve/Request.cpp @@ -178,8 +178,8 @@ SkSurface* Request::createCPUSurface() { SkIRect bounds = this->getBounds(); ColorAndProfile cap = ColorModes[fColorMode]; auto colorSpace = kRGBA_F16_SkColorType == cap.fColorType - ? SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named) - : SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + ? SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named) + : SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fColorType, kPremul_SkAlphaType, cap.fSRGB ? colorSpace : nullptr); return SkSurface::MakeRaster(info).release(); @@ -190,8 +190,8 @@ SkSurface* Request::createGPUSurface() { SkIRect bounds = this->getBounds(); ColorAndProfile cap = ColorModes[fColorMode]; auto colorSpace = kRGBA_F16_SkColorType == cap.fColorType - ? SkColorSpace::NewNamed(SkColorSpace::kSRGBLinear_Named) - : SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + ? SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named) + : SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fColorType, kPremul_SkAlphaType, cap.fSRGB ? colorSpace: nullptr); SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info).release(); diff --git a/tools/viewer/ImageSlide.cpp b/tools/viewer/ImageSlide.cpp index 78fb17b4b0..e70f618487 100644 --- a/tools/viewer/ImageSlide.cpp +++ b/tools/viewer/ImageSlide.cpp @@ -46,7 +46,7 @@ void ImageSlide::load(SkScalar, SkScalar) { codec->getPixels(codec->getInfo(), fOriginalBitmap.getPixels(), fOriginalBitmap.rowBytes()); SkImageInfo xformedInfo = codec->getInfo().makeColorSpace( - SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named)); + SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named)); fXformedBitmap.allocPixels(xformedInfo); codec->getPixels(xformedInfo, fXformedBitmap.getPixels(), fXformedBitmap.rowBytes()); } diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index cd78676def..739882d7d2 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -164,7 +164,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData) fCommands.addCommand('c', "Modes", "Toggle sRGB color mode", [this]() { DisplayParams params = fWindow->getDisplayParams(); params.fColorSpace = (nullptr == params.fColorSpace) - ? SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr; + ? SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named) : nullptr; fWindow->setDisplayParams(params); this->updateTitle(); fWindow->inval(); diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp index dc93623ade..8ce54f0b56 100644 --- a/tools/viewer/sk_app/VulkanWindowContext.cpp +++ b/tools/viewer/sk_app/VulkanWindowContext.cpp @@ -170,7 +170,7 @@ bool VulkanWindowContext::createSwapchain(int width, int height, // Pick our surface format. For now, just make sure it matches our sRGB request: VkFormat surfaceFormat = VK_FORMAT_UNDEFINED; VkColorSpaceKHR colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); bool wantSRGB = srgbColorSpace == params.fColorSpace; for (uint32_t i = 0; i < surfaceFormatCount; ++i) { GrPixelConfig config; diff --git a/tools/viewer/sk_app/WindowContext.cpp b/tools/viewer/sk_app/WindowContext.cpp index b5039a3970..e8658806e3 100755 --- a/tools/viewer/sk_app/WindowContext.cpp +++ b/tools/viewer/sk_app/WindowContext.cpp @@ -42,7 +42,7 @@ sk_sp<SkSurface> WindowContext::createSurface( fWidth, fHeight, fDisplayParams.fColorType, kPremul_SkAlphaType, - forceSRGB ? SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) + forceSRGB ? SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named) : fDisplayParams.fColorSpace ); if (this->isGpuContext()) { diff --git a/tools/viewer/sk_app/android/GLWindowContext_android.cpp b/tools/viewer/sk_app/android/GLWindowContext_android.cpp index 3348d803e0..9f683968c6 100644 --- a/tools/viewer/sk_app/android/GLWindowContext_android.cpp +++ b/tools/viewer/sk_app/android/GLWindowContext_android.cpp @@ -102,7 +102,7 @@ void GLWindowContext_android::onInitializeContext() { EGL_NONE, }; const EGLint* windowAttribs = nullptr; - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); if (srgbColorSpace == fDisplayParams.fColorSpace && majorVersion == 1 && minorVersion >= 2) { windowAttribs = srgbWindowAttribs; } diff --git a/tools/visualize_color_gamut.cpp b/tools/visualize_color_gamut.cpp index 6d08ba213b..9e9ed96314 100644 --- a/tools/visualize_color_gamut.cpp +++ b/tools/visualize_color_gamut.cpp @@ -140,7 +140,7 @@ int main(int argc, char** argv) { // Draw the sRGB gamut if requested. if (FLAGS_sRGB) { - sk_sp<SkColorSpace> sRGBSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + sk_sp<SkColorSpace> sRGBSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); const SkMatrix44* mat = as_CSB(sRGBSpace)->toXYZD50(); SkASSERT(mat); draw_gamut(&canvas, *mat, "sRGB", 0xFFFF9394, false); @@ -148,7 +148,7 @@ int main(int argc, char** argv) { // Draw the Adobe RGB gamut if requested. if (FLAGS_adobeRGB) { - sk_sp<SkColorSpace> adobeRGBSpace = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named); + sk_sp<SkColorSpace> adobeRGBSpace = SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named); const SkMatrix44* mat = as_CSB(adobeRGBSpace)->toXYZD50(); SkASSERT(mat); draw_gamut(&canvas, *mat, "Adobe RGB", 0xFF31a9e1, false); @@ -158,7 +158,7 @@ int main(int argc, char** argv) { sk_sp<SkColorSpace> colorSpace = sk_ref_sp(codec->getInfo().colorSpace()); if (!colorSpace) { SkDebugf("Image had no embedded color space information. Defaulting to sRGB.\n"); - colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + colorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named); } const SkMatrix44* mat = as_CSB(colorSpace)->toXYZD50(); SkASSERT(mat); |