aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-11-09 10:27:55 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-09 15:49:34 +0000
commitfdab576a75c636dbcd5ff44c3f5f57205cc26a6f (patch)
tree4feaa501086f8d838b0ac7543a5668fbd9ec9f25
parent7eb960eaac785a12cfcf88771e46013345e39085 (diff)
Allow changing the transfer function in xform canvas mode
Used this to test out some theories for different color correction approaches. Bug: skia: Change-Id: I072130733eaea736c9aa129af74887b028f035b4 Reviewed-on: https://skia-review.googlesource.com/69221 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
-rw-r--r--tools/viewer/Viewer.cpp18
-rw-r--r--tools/viewer/Viewer.h1
2 files changed, 18 insertions, 1 deletions
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 220a482805..297501454f 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -17,6 +17,7 @@
#include "SkATrace.h"
#include "SkCanvas.h"
#include "SkColorSpace_Base.h"
+#include "SkColorSpacePriv.h"
#include "SkColorSpaceXformCanvas.h"
#include "SkCommandLineFlags.h"
#include "SkCommonFlagsGpuThreads.h"
@@ -270,6 +271,8 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
, fBackendType(sk_app::Window::kNativeGL_BackendType)
, fColorMode(ColorMode::kLegacy)
, fColorSpacePrimaries(gSrgbPrimaries)
+ // Our UI can only tweak gamma (currently), so start out gamma-only
+ , fColorSpaceTransferFn(g2Dot2_TransferFn)
, fZoomLevel(0.0f)
, fGestureDevice(GestureDevice::kNone)
{
@@ -620,6 +623,10 @@ void Viewer::updateTitle() {
}
}
title.appendf(" %s", curPrimaries >= 0 ? gNamedPrimaries[curPrimaries].fName : "Custom");
+
+ if (ColorMode::kColorManagedSRGB8888_NonLinearBlending == fColorMode) {
+ title.appendf(" Gamma %f", fColorSpaceTransferFn.fG);
+ }
}
if (fDisplayStats) {
@@ -812,7 +819,11 @@ void Viewer::drawSlide(SkCanvas* canvas) {
? SkColorSpace::kLinear_RenderTargetGamma : SkColorSpace::kSRGB_RenderTargetGamma;
SkMatrix44 toXYZ(SkMatrix44::kIdentity_Constructor);
SkAssertResult(fColorSpacePrimaries.toXYZD50(&toXYZ));
- cs = SkColorSpace::MakeRGB(transferFn, toXYZ);
+ if (ColorMode::kColorManagedSRGB8888_NonLinearBlending == fColorMode) {
+ cs = SkColorSpace::MakeRGB(fColorSpaceTransferFn, toXYZ);
+ } else {
+ cs = SkColorSpace::MakeRGB(transferFn, toXYZ);
+ }
}
// If we're in F16, or we're zooming, or we're in color correct 8888 and the gamut isn't sRGB,
@@ -1237,6 +1248,11 @@ void Viewer::drawImGui(SkCanvas* canvas) {
}
}
+ // When we're in xform canvas mode, we can alter the transfer function, too
+ if (ColorMode::kColorManagedSRGB8888_NonLinearBlending == fColorMode) {
+ ImGui::SliderFloat("Gamma", &fColorSpaceTransferFn.fG, 0.5f, 3.5f);
+ }
+
if (ImGui::Combo("Primaries", &primariesIdx,
"sRGB\0AdobeRGB\0P3\0Rec. 2020\0Custom\0\0")) {
if (primariesIdx >= 0 && primariesIdx <= 3) {
diff --git a/tools/viewer/Viewer.h b/tools/viewer/Viewer.h
index e37a945b7e..8f248320d5 100644
--- a/tools/viewer/Viewer.h
+++ b/tools/viewer/Viewer.h
@@ -88,6 +88,7 @@ private:
// Color properties for slide rendering
ColorMode fColorMode;
SkColorSpacePrimaries fColorSpacePrimaries;
+ SkColorSpaceTransferFn fColorSpaceTransferFn;
// transform data
SkScalar fZoomLevel;