diff options
author | brianosman <brianosman@google.com> | 2016-06-16 13:03:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-16 13:03:24 -0700 |
commit | b109b8c5ec40a7dd85a0a2951a1f98fa63b805aa (patch) | |
tree | fe94e12159f2b7b07ed9ed23316fade5b0ff8d37 /tools | |
parent | 8811e40850ac3310c17fe8cdaffe72817a5e317d (diff) |
Lots of progress on switching to SkColorSpace rather than SkColorProfileType
Fixed a bunch of code in Ganesh, as well as usage of SkColorProfileType in most of our tools (DM, SampleApp, Viewer, nanobench, skiaserve, HelloWorld).
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2069173002
Committed: https://skia.googlesource.com/skia/+/6a61a875467646f8dbc37cfecf49e12d1f475170
Review-Url: https://codereview.chromium.org/2069173002
Diffstat (limited to 'tools')
-rw-r--r-- | tools/flags/SkCommonFlagsConfig.cpp | 18 | ||||
-rw-r--r-- | tools/flags/SkCommonFlagsConfig.h | 6 | ||||
-rw-r--r-- | tools/picture_utils.cpp | 5 | ||||
-rw-r--r-- | tools/skiaserve/Request.cpp | 14 | ||||
-rw-r--r-- | tools/viewer/Viewer.cpp | 8 | ||||
-rw-r--r-- | tools/viewer/sk_app/DisplayParams.h | 10 | ||||
-rw-r--r-- | tools/viewer/sk_app/GLWindowContext.cpp | 4 | ||||
-rw-r--r-- | tools/viewer/sk_app/VulkanWindowContext.cpp | 3 | ||||
-rwxr-xr-x | tools/viewer/sk_app/WindowContext.cpp | 4 | ||||
-rw-r--r-- | tools/viewer/sk_app/android/GLWindowContext_android.cpp | 3 | ||||
-rw-r--r-- | tools/viewer/sk_app/android/RasterWindowContext_android.cpp | 2 |
11 files changed, 42 insertions, 35 deletions
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp index 1c7920eb55..d5c7a1d5bf 100644 --- a/tools/flags/SkCommonFlagsConfig.cpp +++ b/tools/flags/SkCommonFlagsConfig.cpp @@ -192,14 +192,14 @@ SkCommandLineConfig::~SkCommandLineConfig() { SkCommandLineConfigGpu::SkCommandLineConfigGpu( const SkString& tag, const SkTArray<SkString>& viaParts, ContextType contextType, bool useNVPR, bool useDIText, int samples, - SkColorType colorType, SkColorProfileType profileType) + SkColorType colorType, sk_sp<SkColorSpace> colorSpace) : SkCommandLineConfig(tag, SkString("gpu"), viaParts) , fContextType(contextType) , fUseNVPR(useNVPR) , fUseDIText(useDIText) , fSamples(samples) , fColorType(colorType) - , fProfileType(profileType) { + , fColorSpace(std::move(colorSpace)) { } static bool parse_option_int(const SkString& value, int* outInt) { if (value.isEmpty()) { @@ -276,20 +276,20 @@ static bool parse_option_gpu_api(const SkString& value, } static bool parse_option_gpu_color(const SkString& value, SkColorType* outColorType, - SkColorProfileType* outProfileType) { + sk_sp<SkColorSpace>* outColorSpace) { if (value.equals("8888")) { *outColorType = kN32_SkColorType; - *outProfileType = kLinear_SkColorProfileType; + *outColorSpace = nullptr; return true; } if (value.equals("f16")) { *outColorType = kRGBA_F16_SkColorType; - *outProfileType = kLinear_SkColorProfileType; + *outColorSpace = nullptr; return true; } if (value.equals("srgb")) { *outColorType = kN32_SkColorType; - *outProfileType = kSRGB_SkColorProfileType; + *outColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); return true; } return false; @@ -309,7 +309,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, int samples = 0; bool seenColor = false; SkColorType colorType = kN32_SkColorType; - SkColorProfileType profileType = kLinear_SkColorProfileType; + sk_sp<SkColorSpace> colorSpace = nullptr; SkTArray<SkString> optionParts; SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts); @@ -335,7 +335,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, valueOk = parse_option_int(value, &samples); seenSamples = true; } else if (key.equals("color") && !seenColor) { - valueOk = parse_option_gpu_color(value, &colorType, &profileType); + valueOk = parse_option_gpu_color(value, &colorType, &colorSpace); seenColor = true; } if (!valueOk) { @@ -343,7 +343,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, } } return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText, samples, - colorType, profileType); + colorType, colorSpace); } #endif diff --git a/tools/flags/SkCommonFlagsConfig.h b/tools/flags/SkCommonFlagsConfig.h index 5d95ef186a..dc38977cb8 100644 --- a/tools/flags/SkCommonFlagsConfig.h +++ b/tools/flags/SkCommonFlagsConfig.h @@ -53,14 +53,14 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig { typedef sk_gpu_test::GrContextFactory::ContextType ContextType; SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts, ContextType contextType, bool useNVPR, bool useDIText, int samples, - SkColorType colorType, SkColorProfileType profileType); + SkColorType colorType, sk_sp<SkColorSpace> colorSpace); const SkCommandLineConfigGpu* asConfigGpu() const override { return this; } ContextType getContextType() const { return fContextType; } bool getUseNVPR() const { return fUseNVPR; } bool getUseDIText() const { return fUseDIText; } int getSamples() const { return fSamples; } SkColorType getColorType() const { return fColorType; } - SkColorProfileType getProfileType() const { return fProfileType; } + SkColorSpace* getColorSpace() const { return fColorSpace.get(); } private: ContextType fContextType; @@ -68,7 +68,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig { bool fUseDIText; int fSamples; SkColorType fColorType; - SkColorProfileType fProfileType; + sk_sp<SkColorSpace> fColorSpace; }; #endif diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp index 63a48ce3e1..a6803c67db 100644 --- a/tools/picture_utils.cpp +++ b/tools/picture_utils.cpp @@ -80,8 +80,9 @@ namespace sk_tools { SkAutoTMalloc<uint32_t> rgba(w*h); - if (bitmap. colorType() == kN32_SkColorType && - bitmap.profileType() == kSRGB_SkColorProfileType) { + auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + if (bitmap. colorType() == kN32_SkColorType && + bitmap.colorSpace() == srgbColorSpace.get()) { // These are premul sRGB 8-bit pixels in SkPMColor order. // We want unpremul sRGB 8-bit pixels in RGBA order. We'll get there via floats. bitmap.lockPixels(); diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp index c3eaaff387..756f70e24d 100644 --- a/tools/skiaserve/Request.cpp +++ b/tools/skiaserve/Request.cpp @@ -159,14 +159,14 @@ namespace { struct ColorAndProfile { SkColorType fColorType; - SkColorProfileType fProfileType; + bool fSRGB; bool fGammaCorrect; }; ColorAndProfile ColorModes[] = { - { kN32_SkColorType, kLinear_SkColorProfileType, false }, - { kN32_SkColorType, kSRGB_SkColorProfileType, true }, - { kRGBA_F16_SkColorType, kLinear_SkColorProfileType, true }, + { kN32_SkColorType, false, false }, + { kN32_SkColorType, true, true }, + { kRGBA_F16_SkColorType, false, true }, }; } @@ -174,8 +174,9 @@ ColorAndProfile ColorModes[] = { SkSurface* Request::createCPUSurface() { SkIRect bounds = this->getBounds(); ColorAndProfile cap = ColorModes[fColorMode]; + auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fColorType, - kPremul_SkAlphaType, cap.fProfileType); + kPremul_SkAlphaType, cap.fSRGB ? srgbColorSpace : nullptr); uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0; SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); return SkSurface::MakeRaster(info, &props).release(); @@ -185,8 +186,9 @@ SkSurface* Request::createGPUSurface() { GrContext* context = this->getContext(); SkIRect bounds = this->getBounds(); ColorAndProfile cap = ColorModes[fColorMode]; + auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fColorType, - kPremul_SkAlphaType, cap.fProfileType); + kPremul_SkAlphaType, cap.fSRGB ? srgbColorSpace : nullptr); uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0; SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index 43697f88b8..9aec01f3ec 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -122,8 +122,8 @@ Viewer::Viewer(int argc, char** argv, void* platformData) }); fCommands.addCommand('c', "Modes", "Toggle sRGB color mode", [this]() { DisplayParams params = fWindow->getDisplayParams(); - params.fProfileType = (kLinear_SkColorProfileType == params.fProfileType) - ? kSRGB_SkColorProfileType : kLinear_SkColorProfileType; + params.fColorSpace = (nullptr == params.fColorSpace) + ? SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr; fWindow->setDisplayParams(params); this->updateTitle(); fWindow->inval(); @@ -266,7 +266,9 @@ Viewer::~Viewer() { void Viewer::updateTitle() { SkString title("Viewer: "); title.append(fSlides[fCurrentSlide]->getName()); - if (kSRGB_SkColorProfileType == fWindow->getDisplayParams().fProfileType) { + + // TODO: For now, any color-space on the window means sRGB + if (fWindow->getDisplayParams().fColorSpace) { title.append(" sRGB"); } title.append(kBackendTypeStrings[fBackendType]); diff --git a/tools/viewer/sk_app/DisplayParams.h b/tools/viewer/sk_app/DisplayParams.h index 8756ff0aac..b9a23f322d 100644 --- a/tools/viewer/sk_app/DisplayParams.h +++ b/tools/viewer/sk_app/DisplayParams.h @@ -14,14 +14,14 @@ namespace sk_app { struct DisplayParams { DisplayParams() : fColorType(kN32_SkColorType) - , fProfileType(kLinear_SkColorProfileType) + , fColorSpace(nullptr) , fMSAASampleCount(0) , fDeepColor(false) {} - SkColorType fColorType; - SkColorProfileType fProfileType; - int fMSAASampleCount; - bool fDeepColor; + SkColorType fColorType; + sk_sp<SkColorSpace> fColorSpace; + int fMSAASampleCount; + bool fDeepColor; }; } // namespace sk_app diff --git a/tools/viewer/sk_app/GLWindowContext.cpp b/tools/viewer/sk_app/GLWindowContext.cpp index a491321a2a..b960da4824 100644 --- a/tools/viewer/sk_app/GLWindowContext.cpp +++ b/tools/viewer/sk_app/GLWindowContext.cpp @@ -47,8 +47,8 @@ void GLWindowContext::initializeContext(void* platformData, const DisplayParams& // ... and, if we're using a 10-bit/channel FB0, it doesn't do sRGB conversion on write, // so pretend that it's non-sRGB 8888: fPixelConfig = fContext->caps()->srgbSupport() && - SkColorAndProfileAreGammaCorrect(fDisplayParams.fColorType, - fDisplayParams.fProfileType) && + SkColorAndColorSpaceAreGammaCorrect(fDisplayParams.fColorType, + fDisplayParams.fColorSpace.get()) && (fColorBits != 30) ? kSkiaGamma8888_GrPixelConfig : kSkia8888_GrPixelConfig; } diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp index 9bcf6ca25d..d892cd4783 100644 --- a/tools/viewer/sk_app/VulkanWindowContext.cpp +++ b/tools/viewer/sk_app/VulkanWindowContext.cpp @@ -173,7 +173,8 @@ bool VulkanWindowContext::createSwapchain(uint32_t width, uint32_t 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; - bool wantSRGB = kSRGB_SkColorProfileType == params.fProfileType; + auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + bool wantSRGB = srgbColorSpace == params.fColorSpace; for (uint32_t i = 0; i < surfaceFormatCount; ++i) { GrPixelConfig config; if (GrVkFormatToPixelConfig(surfaceFormats[i].format, &config) && diff --git a/tools/viewer/sk_app/WindowContext.cpp b/tools/viewer/sk_app/WindowContext.cpp index 41bbd14576..ecac2cc004 100755 --- a/tools/viewer/sk_app/WindowContext.cpp +++ b/tools/viewer/sk_app/WindowContext.cpp @@ -36,7 +36,7 @@ sk_sp<SkSurface> WindowContext::createRenderSurface(sk_sp<GrRenderTarget> rt, in SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, fDisplayParams.fColorType, kUnknown_SkAlphaType, - fDisplayParams.fProfileType); + fDisplayParams.fColorSpace); return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info, fDisplayParams.fMSAASampleCount, &props); } else { @@ -52,7 +52,7 @@ void WindowContext::presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<G SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, fDisplayParams.fColorType, kUnknown_SkAlphaType, - fDisplayParams.fProfileType); + fDisplayParams.fColorSpace); SkBitmap bm; bm.allocPixels(info); renderSurface->getCanvas()->readPixels(&bm, 0, 0); diff --git a/tools/viewer/sk_app/android/GLWindowContext_android.cpp b/tools/viewer/sk_app/android/GLWindowContext_android.cpp index 79425b4115..be62ab2b68 100644 --- a/tools/viewer/sk_app/android/GLWindowContext_android.cpp +++ b/tools/viewer/sk_app/android/GLWindowContext_android.cpp @@ -99,7 +99,8 @@ void GLWindowContext_android::onInitializeContext(void* platformData, const Disp EGL_NONE, }; const EGLint* windowAttribs = nullptr; - if (kSRGB_SkColorProfileType == params.fProfileType && majorVersion == 1 && minorVersion >= 2) { + auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); + if (srgbColorSpace == params.fColorSpace && majorVersion == 1 && minorVersion >= 2) { windowAttribs = srgbWindowAttribs; } diff --git a/tools/viewer/sk_app/android/RasterWindowContext_android.cpp b/tools/viewer/sk_app/android/RasterWindowContext_android.cpp index 5e1e351b9a..a5f9a657fe 100644 --- a/tools/viewer/sk_app/android/RasterWindowContext_android.cpp +++ b/tools/viewer/sk_app/android/RasterWindowContext_android.cpp @@ -68,7 +68,7 @@ sk_sp<SkSurface> RasterWindowContext_android::getBackbufferSurface() { SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, fDisplayParams.fColorType, kOpaque_SkAlphaType, - fDisplayParams.fProfileType); + fDisplayParams.fColorSpace); fBackbufferSurface = SkSurface::MakeRasterDirect( info, fBuffer.bits, fBuffer.stride * bytePerPixel, nullptr); } |