From 802acec1876bb647aaab1bbcfd97748bba54da8f Mon Sep 17 00:00:00 2001 From: egdaniel Date: Fri, 17 Jun 2016 15:11:45 -0700 Subject: [PATCH] Revert of More removal of SkColorProfileType... (patchset #2 id:20001 of https://codereview.chromium.org/2071393002/ ) Reason for revert: This was still used in chrome Original issue's description: > More removal of SkColorProfileType... > > Scrub GMs. Remove the gDefaultProfile thing (it's unused now), along with > the command line flag that was setting it in DM and nanobench. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2071393002 > > Committed: https://skia.googlesource.com/skia/+/944876f2745a62a839e49275daf93a0329372e67 TBR=msarett@google.com,reed@google.com,bsalomon@google.com,brianosman@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review-Url: https://codereview.chromium.org/2074103004 --- bench/nanobench.cpp | 6 ++++++ dm/DM.cpp | 6 ++++++ gm/SkLinearBitmapPipelineGM.cpp | 5 ++++- gm/all_bitmap_configs.cpp | 12 ++++-------- gm/color4f.cpp | 9 +++------ gm/dftext.cpp | 5 ++--- gm/gamma.cpp | 8 ++++---- gm/surface.cpp | 2 +- gm/textblobgeometrychange.cpp | 3 +-- gm/textblobmixedsizes.cpp | 6 ++---- gm/textblobrandomfont.cpp | 4 ++-- gm/xfermodes3.cpp | 2 +- gyp/core.gypi | 1 + include/core/SkBitmap.h | 3 +++ include/private/SkImageInfoPriv.h | 14 ++++++++++++++ src/core/SkCanvas.cpp | 3 +-- src/core/SkImageInfo.cpp | 9 +++++++++ src/gpu/GrContext.cpp | 4 ++-- src/gpu/GrSurface.cpp | 7 ++++--- src/gpu/SkGr.cpp | 18 +++++++++--------- src/gpu/SkGrPriv.h | 2 +- tools/flags/SkCommonFlags.cpp | 2 ++ tools/flags/SkCommonFlags.h | 1 + 23 files changed, 83 insertions(+), 49 deletions(-) create mode 100644 include/private/SkImageInfoPriv.h diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index cb28231adb..94402cc770 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -1025,6 +1025,8 @@ static void start_keepalive() { intentionallyLeaked->start(); } +extern bool gDefaultProfileIsSRGB; + int nanobench_main(); int nanobench_main() { SetupCrashHandler(); @@ -1036,6 +1038,10 @@ int nanobench_main() { gGrFactory.reset(new GrContextFactory(grContextOpts)); #endif + if (FLAGS_forceSRGB) { + gDefaultProfileIsSRGB = true; + } + if (FLAGS_veryVerbose) { FLAGS_verbose = true; } diff --git a/dm/DM.cpp b/dm/DM.cpp index 0eb679adee..69044080b5 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -1248,6 +1248,8 @@ static sk_sp create_from_name(const char familyName[], SkFontStyle s extern sk_sp (*gCreateTypefaceDelegate)(const char [], SkFontStyle ); +extern bool gDefaultProfileIsSRGB; + int dm_main(); int dm_main() { setbuf(stdout, nullptr); @@ -1260,6 +1262,10 @@ int dm_main() { gVLog = freopen(SkOSPath::Join(FLAGS_writePath[0], "verbose.log").c_str(), "w", stderr); } + if (FLAGS_forceSRGB) { + gDefaultProfileIsSRGB = true; + } + JsonWriter::DumpJson(); // It's handy for the bots to assume this is ~never missing. SkAutoGraphics ag; SkTaskGroup::Enabler enabled(FLAGS_threads); diff --git a/gm/SkLinearBitmapPipelineGM.cpp b/gm/SkLinearBitmapPipelineGM.cpp index c78bc74e23..777f825780 100644 --- a/gm/SkLinearBitmapPipelineGM.cpp +++ b/gm/SkLinearBitmapPipelineGM.cpp @@ -55,7 +55,7 @@ static void draw_rect_orig(SkCanvas* canvas, const SkRect& r, SkColor c, const S SkPixmap pmdst; bmdst.peekPixels(&pmdst); - SkImageInfo info = SkImageInfo::MakeN32Premul(ir.width(), ir.height()); + SkImageInfo info = SkImageInfo::MakeN32Premul(ir.width(), ir.height(), kLinear_SkColorProfileType); sk_sp image(SkImage::MakeRasterCopy(SkPixmap(info, pmsrc.addr32(), pmsrc.rowBytes()))); SkPaint paint; @@ -113,6 +113,9 @@ static void draw_rect_fp(SkCanvas* canvas, const SkRect& r, SkColor c, const SkM } uint32_t flags = 0; + //if (kSRGB_SkColorProfileType == profile) { + //flags |= SkXfermode::kDstIsSRGB_PM4fFlag; + //} auto procN = SkXfermode::GetD32Proc(nullptr, flags); SkLinearBitmapPipeline pipeline{ diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp index b657f4fa7c..7ea17466d9 100644 --- a/gm/all_bitmap_configs.cpp +++ b/gm/all_bitmap_configs.cpp @@ -246,13 +246,13 @@ static uint32_t make_pixel(int x, int y, SkAlphaType alphaType) { static void make_color_test_bitmap_variant( SkColorType colorType, SkAlphaType alphaType, - sk_sp colorSpace, + SkColorProfileType profile, SkBitmap* bm) { SkASSERT(colorType == kRGBA_8888_SkColorType || colorType == kBGRA_8888_SkColorType); SkASSERT(alphaType == kPremul_SkAlphaType || alphaType == kUnpremul_SkAlphaType); bm->allocPixels( - SkImageInfo::Make(SCALE, SCALE, colorType, alphaType, colorSpace)); + SkImageInfo::Make(SCALE, SCALE, colorType, alphaType, profile)); SkPixmap pm; bm->peekPixels(&pm); for (int y = 0; y < bm->height(); y++) { @@ -265,17 +265,13 @@ static void make_color_test_bitmap_variant( 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 colorSpaces[] { - nullptr, - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) - }; - for (auto colorSpace : colorSpaces) { + for (auto profile : {kSRGB_SkColorProfileType, kLinear_SkColorProfileType}) { canvas->save(); for (auto alphaType : {kPremul_SkAlphaType, kUnpremul_SkAlphaType}) { canvas->save(); for (auto colorType : {kRGBA_8888_SkColorType, kBGRA_8888_SkColorType}) { SkBitmap bm; - make_color_test_bitmap_variant(colorType, alphaType, colorSpace, &bm); + make_color_test_bitmap_variant(colorType, alphaType, profile, &bm); canvas->drawBitmap(bm, 0.0f, 0.0f); canvas->translate(SCALE + 10, 0.0f); } diff --git a/gm/color4f.cpp b/gm/color4f.cpp index 5a516a569b..33d837786a 100644 --- a/gm/color4f.cpp +++ b/gm/color4f.cpp @@ -73,13 +73,10 @@ DEF_SIMPLE_GM(color4f, canvas, 1024, 260) { // even if it holds sRGB values. bg.setColor(0xFFFFFFFF); - sk_sp colorSpaces[]{ - nullptr, - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) - }; - for (auto colorSpace : colorSpaces) { + SkColorProfileType const profiles[] { kLinear_SkColorProfileType, kSRGB_SkColorProfileType }; + for (auto profile : profiles) { const SkImageInfo info = SkImageInfo::Make(1024, 100, kN32_SkColorType, kPremul_SkAlphaType, - colorSpace); + profile); auto surface(SkSurface::MakeRaster(info)); surface->getCanvas()->drawPaint(bg); draw_into_canvas(surface->getCanvas()); diff --git a/gm/dftext.cpp b/gm/dftext.cpp index 42d650ed2f..05aef4c9d6 100644 --- a/gm/dftext.cpp +++ b/gm/dftext.cpp @@ -48,9 +48,8 @@ protected: // set up offscreen rendering with distance field text #if SK_SUPPORT_GPU GrContext* ctx = inputCanvas->getGrContext(); - SkISize size = onISize(); - SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType, - sk_ref_sp(inputCanvas->imageInfo().colorSpace())); + SkImageInfo info = SkImageInfo::MakeN32Premul(onISize(), + inputCanvas->imageInfo().profileType()); SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); uint32_t gammaCorrect = inputCanvas->getProps(&canvasProps) ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0; diff --git a/gm/gamma.cpp b/gm/gamma.cpp index eb4c7607fe..c9fa28be10 100644 --- a/gm/gamma.cpp +++ b/gm/gamma.cpp @@ -18,7 +18,6 @@ DEF_SIMPLE_GM(gamma, canvas, 560, 200) { const SkScalar tx = sz + 5.0f; const SkRect r = SkRect::MakeXYWH(0, 0, sz, sz); SkShader::TileMode rpt = SkShader::kRepeat_TileMode; - auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); SkBitmap ditherBmp; ditherBmp.allocN32Pixels(2, 2); @@ -27,20 +26,21 @@ DEF_SIMPLE_GM(gamma, canvas, 560, 200) { pixels[1] = pixels[2] = SkPackARGB32(0xFF, 0, 0, 0); SkBitmap linearGreyBmp; - SkImageInfo linearGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlphaType, nullptr); + SkImageInfo linearGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlphaType, + kLinear_SkColorProfileType); linearGreyBmp.allocPixels(linearGreyInfo); linearGreyBmp.eraseARGB(0xFF, 0x7F, 0x7F, 0x7F); SkBitmap srgbGreyBmp; SkImageInfo srgbGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlphaType, - srgbColorSpace); + kSRGB_SkColorProfileType); srgbGreyBmp.allocPixels(srgbGreyInfo); // 0xBC = 255 * linear_to_srgb(0.5f) srgbGreyBmp.eraseARGB(0xFF, 0xBC, 0xBC, 0xBC); SkBitmap mipmapBmp; SkImageInfo mipmapInfo = SkImageInfo::Make(2, 2, kN32_SkColorType, kOpaque_SkAlphaType, - srgbColorSpace); + SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)); mipmapBmp.allocPixels(mipmapInfo); SkPMColor* mipmapPixels = reinterpret_cast(mipmapBmp.getPixels()); unsigned s25 = 0x89; // 255 * linear_to_srgb(0.25f) diff --git a/gm/surface.cpp b/gm/surface.cpp index bae77c5594..15d362efd5 100644 --- a/gm/surface.cpp +++ b/gm/surface.cpp @@ -78,7 +78,7 @@ protected: // must be opaque to have a hope of testing LCD text const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType, - sk_ref_sp(canvas->imageInfo().colorSpace())); + canvas->imageInfo().profileType()); SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); bool gammaCorrect = canvas->getProps(&canvasProps) && canvasProps.isGammaCorrect(); diff --git a/gm/textblobgeometrychange.cpp b/gm/textblobgeometrychange.cpp index a241c5c7ba..87c432f5b7 100644 --- a/gm/textblobgeometrychange.cpp +++ b/gm/textblobgeometrychange.cpp @@ -42,8 +42,7 @@ protected: SkAutoTUnref blob(builder.build()); - SkImageInfo info = SkImageInfo::MakeN32(200, 200, kPremul_SkAlphaType, - sk_ref_sp(canvas->imageInfo().colorSpace())); + SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200, canvas->imageInfo().profileType()); SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); uint32_t gammaCorrect = canvas->getProps(&canvasProps) ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0; diff --git a/gm/textblobmixedsizes.cpp b/gm/textblobmixedsizes.cpp index 8fdf558206..8f5dc85e48 100644 --- a/gm/textblobmixedsizes.cpp +++ b/gm/textblobmixedsizes.cpp @@ -102,10 +102,8 @@ protected: #if SK_SUPPORT_GPU // Create a new Canvas to enable DFT GrContext* ctx = inputCanvas->getGrContext(); - SkISize size = onISize(); - sk_sp colorSpace = sk_ref_sp(inputCanvas->imageInfo().colorSpace()); - SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), - kPremul_SkAlphaType, colorSpace); + SkImageInfo info = SkImageInfo::MakeN32Premul(onISize(), + inputCanvas->imageInfo().profileType()); SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); uint32_t gammaCorrect = inputCanvas->getProps(&canvasProps) ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0; diff --git a/gm/textblobrandomfont.cpp b/gm/textblobrandomfont.cpp index 58f0dc6bd6..2a6fc8e832 100644 --- a/gm/textblobrandomfont.cpp +++ b/gm/textblobrandomfont.cpp @@ -97,8 +97,8 @@ protected: canvas->drawColor(sk_tool_utils::color_to_565(SK_ColorWHITE)); - SkImageInfo info = SkImageInfo::MakeN32(kWidth, kHeight, kPremul_SkAlphaType, - sk_ref_sp(canvas->imageInfo().colorSpace())); + SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight, + canvas->imageInfo().profileType()); SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); uint32_t gammaCorrect = canvas->getProps(&canvasProps) ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0; diff --git a/gm/xfermodes3.cpp b/gm/xfermodes3.cpp index 642175e5a1..2b554b6c11 100644 --- a/gm/xfermodes3.cpp +++ b/gm/xfermodes3.cpp @@ -126,7 +126,7 @@ private: GrContext* context = baseCanvas->getGrContext(); SkImageInfo baseInfo = baseCanvas->imageInfo(); SkImageInfo info = SkImageInfo::Make(w, h, baseInfo.colorType(), baseInfo.alphaType(), - sk_ref_sp(baseInfo.colorSpace())); + baseInfo.profileType()); SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); baseCanvas->getProps(&canvasProps); return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, &canvasProps); diff --git a/gyp/core.gypi b/gyp/core.gypi index 516faf3095..d3102e4f92 100644 --- a/gyp/core.gypi +++ b/gyp/core.gypi @@ -421,6 +421,7 @@ '<(skia_include_path)/private/SkFloatBits.h', '<(skia_include_path)/private/SkFloatingPoint.h', '<(skia_include_path)/private/SkGpuFenceSync.h', + '<(skia_include_path)/private/SkImageInfoPriv.h', '<(skia_include_path)/private/SkMiniRecorder.h', '<(skia_include_path)/private/SkMutex.h', '<(skia_include_path)/private/SkOnce.h', diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index 5406f94328..8b499097e9 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -86,6 +86,9 @@ public: SkColorType colorType() const { return fInfo.colorType(); } SkAlphaType alphaType() const { return fInfo.alphaType(); } SkColorSpace* colorSpace() const { return fInfo.colorSpace(); } +#ifdef SK_SUPPORT_LEGACY_COLORPROFILETYPE + SkColorProfileType profileType() const { return fInfo.profileType(); } +#endif /** * Return the number of bytes per pixel based on the colortype. If the colortype is diff --git a/include/private/SkImageInfoPriv.h b/include/private/SkImageInfoPriv.h new file mode 100644 index 0000000000..89e6e20340 --- /dev/null +++ b/include/private/SkImageInfoPriv.h @@ -0,0 +1,14 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef SkImageInfoPriv_DEFINED +#define SkImageInfoPriv_DEFINED + +#include "SkImageInfo.h" + +SK_API SkColorProfileType SkDefaultColorProfile(); + +#endif // SkImageInfoPriv_DEFINED diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 1a5c4c4d11..4150a9a55b 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1177,7 +1177,6 @@ static SkImageInfo make_layer_info(const SkImageInfo& prev, int w, int h, bool i const SkPaint* paint) { // need to force L32 for now if we have an image filter. Once filters support other colortypes // e.g. sRGB or F16, we can remove this check - // SRGBTODO: Can we remove this check now? const bool hasImageFilter = paint && paint->getImageFilter(); SkAlphaType alphaType = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; @@ -1186,7 +1185,7 @@ static SkImageInfo make_layer_info(const SkImageInfo& prev, int w, int h, bool i return SkImageInfo::MakeN32(w, h, alphaType); } else { // keep the same characteristics as the prev - return SkImageInfo::Make(w, h, prev.colorType(), alphaType, sk_ref_sp(prev.colorSpace())); + return SkImageInfo::Make(w, h, prev.colorType(), alphaType, prev.profileType()); } } diff --git a/src/core/SkImageInfo.cpp b/src/core/SkImageInfo.cpp index ee169239ef..9485754823 100644 --- a/src/core/SkImageInfo.cpp +++ b/src/core/SkImageInfo.cpp @@ -6,6 +6,7 @@ */ #include "SkImageInfo.h" +#include "SkImageInfoPriv.h" #include "SkReadBuffer.h" #include "SkWriteBuffer.h" @@ -60,6 +61,14 @@ SkColorProfileType SkImageInfo::profileType() const { } #endif +// Indicate how images and gradients should interpret colors by default. +bool gDefaultProfileIsSRGB; + +SkColorProfileType SkDefaultColorProfile() { + return gDefaultProfileIsSRGB ? kSRGB_SkColorProfileType + : kLinear_SkColorProfileType; +} + static bool alpha_type_is_valid(SkAlphaType alphaType) { return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); } diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 970f75c7b8..a9c6089728 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -244,7 +244,7 @@ void GrContext::flush(int flagsBitfield) { bool sw_convert_to_premul(GrPixelConfig srcConfig, int width, int height, size_t inRowBytes, const void* inPixels, size_t outRowBytes, void* outPixels) { SkSrcPixelInfo srcPI; - if (!GrPixelConfigToColorAndColorSpace(srcConfig, &srcPI.fColorType, nullptr)) { + if (!GrPixelConfig2ColorAndProfileType(srcConfig, &srcPI.fColorType, nullptr)) { return false; } srcPI.fAlphaType = kUnpremul_SkAlphaType; @@ -511,7 +511,7 @@ bool GrContext::readSurfacePixels(GrSurface* src, // Perform umpremul conversion if we weren't able to perform it as a draw. if (unpremul) { SkDstPixelInfo dstPI; - if (!GrPixelConfigToColorAndColorSpace(dstConfig, &dstPI.fColorType, nullptr)) { + if (!GrPixelConfig2ColorAndProfileType(dstConfig, &dstPI.fColorType, nullptr)) { return false; } dstPI.fAlphaType = kUnpremul_SkAlphaType; diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp index 47fa394788..886945c710 100644 --- a/src/gpu/GrSurface.cpp +++ b/src/gpu/GrSurface.cpp @@ -118,11 +118,12 @@ bool GrSurface::readPixels(int left, int top, int width, int height, SkImageInfo GrSurface::info(SkAlphaType alphaType) const { SkColorType colorType; - sk_sp colorSpace; - if (!GrPixelConfigToColorAndColorSpace(this->config(), &colorType, &colorSpace)) { + SkColorProfileType profileType; + if (!GrPixelConfig2ColorAndProfileType(this->config(), &colorType, &profileType)) { sk_throw(); } - return SkImageInfo::Make(this->width(), this->height(), colorType, alphaType, colorSpace); + return SkImageInfo::Make(this->width(), this->height(), colorType, alphaType, + profileType); } // TODO: This should probably be a non-member helper function. It might only be needed in diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index f937b16d55..60fcdd5139 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -453,10 +453,10 @@ GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, const SkCol return kUnknown_GrPixelConfig; } -bool GrPixelConfigToColorAndColorSpace(GrPixelConfig config, SkColorType* ctOut, - sk_sp* csOut) { +bool GrPixelConfig2ColorAndProfileType(GrPixelConfig config, SkColorType* ctOut, + SkColorProfileType* ptOut) { SkColorType ct; - sk_sp cs = nullptr; + SkColorProfileType pt = kLinear_SkColorProfileType; switch (config) { case kAlpha_8_GrPixelConfig: ct = kAlpha_8_SkColorType; @@ -478,11 +478,11 @@ bool GrPixelConfigToColorAndColorSpace(GrPixelConfig config, SkColorType* ctOut, break; case kSRGBA_8888_GrPixelConfig: ct = kRGBA_8888_SkColorType; - cs = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + pt = kSRGB_SkColorProfileType; break; case kSBGRA_8888_GrPixelConfig: ct = kBGRA_8888_SkColorType; - cs = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + pt = kSRGB_SkColorProfileType; break; case kRGBA_half_GrPixelConfig: ct = kRGBA_F16_SkColorType; @@ -493,8 +493,8 @@ bool GrPixelConfigToColorAndColorSpace(GrPixelConfig config, SkColorType* ctOut, if (ctOut) { *ctOut = ct; } - if (csOut) { - *csOut = cs; + if (ptOut) { + *ptOut = pt; } return true; } @@ -724,9 +724,9 @@ SkImageInfo GrMakeInfoFromTexture(GrTexture* tex, int w, int h, bool isOpaque) { SkASSERT(h <= desc.fHeight); #endif const GrPixelConfig config = tex->config(); - SkColorType ct = kUnknown_SkColorType; + SkColorType ct; SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; - if (!GrPixelConfigToColorAndColorSpace(config, &ct, nullptr)) { + if (!GrPixelConfig2ColorAndProfileType(config, &ct, nullptr)) { ct = kUnknown_SkColorType; } return SkImageInfo::Make(w, h, ct, at); diff --git a/src/gpu/SkGrPriv.h b/src/gpu/SkGrPriv.h index ab77dc1e79..266cfff61c 100644 --- a/src/gpu/SkGrPriv.h +++ b/src/gpu/SkGrPriv.h @@ -102,7 +102,7 @@ bool SkPaintToGrPaintWithTexture(GrContext* context, GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&, const GrCaps&); -bool GrPixelConfigToColorAndColorSpace(GrPixelConfig, SkColorType*, sk_sp*); +bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfileType*); /** * If the compressed data in the SkData is supported (as a texture format, this returns diff --git a/tools/flags/SkCommonFlags.cpp b/tools/flags/SkCommonFlags.cpp index 1caffd54d6..3da5efebc5 100644 --- a/tools/flags/SkCommonFlags.cpp +++ b/tools/flags/SkCommonFlags.cpp @@ -13,6 +13,8 @@ DEFINE_bool(cpu, true, "master switch for running CPU-bound work."); DEFINE_bool(dryRun, false, "just print the tests that would be run, without actually running them."); +DEFINE_bool(forceSRGB, false, "Force SRGB for imageinfos"); + DEFINE_bool(gpu, true, "master switch for running GPU-bound work."); DEFINE_string(images, "", "List of images and/or directories to decode. A directory with no images" diff --git a/tools/flags/SkCommonFlags.h b/tools/flags/SkCommonFlags.h index ddd0fc89e0..b7eaca4eba 100644 --- a/tools/flags/SkCommonFlags.h +++ b/tools/flags/SkCommonFlags.h @@ -14,6 +14,7 @@ DECLARE_bool(cpu); DECLARE_bool(dryRun); +DECLARE_bool(forceSRGB); DECLARE_bool(gpu); DECLARE_string(images); DECLARE_string(colorImages);