aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-05-06 23:52:28 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-07 04:19:10 +0000
commitbc63fd45d4937d91977de07a23d384f61a0e57dd (patch)
tree09768ce32618d22444a34ee075a029e30dba7977
parentf484ac692f034a4ee69ca9e1d363b07dbed63ca7 (diff)
bug fix in hsl GM reference impls
As written the "constants" in clip() and channel() change as we update each channel... duh. Thankfully this ought to make most GMs look good. Change-Id: I904e20e8e5114c827233dd1a93c0c59f7e7790fa Reviewed-on: https://skia-review.googlesource.com/15680 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
-rw-r--r--gm/hsl.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/gm/hsl.cpp b/gm/hsl.cpp
index 120eebffe4..db604c02b9 100644
--- a/gm/hsl.cpp
+++ b/gm/hsl.cpp
@@ -46,9 +46,9 @@ static float lum(float r, float g, float b) { return r*0.30f + g*0.59f + b*0.11f
// Both map the minimum channel to 0, maximum to s, and scale the middle proportionately.
// The KHR version has done a better job at simplifying its math, so we use it here.
static void set_sat(float* r, float* g, float* b, float s) {
- auto channel = [&](float c) {
- float mn = min(*r,*g,*b),
- mx = max(*r,*g,*b);
+ float mn = min(*r,*g,*b),
+ mx = max(*r,*g,*b);
+ auto channel = [=](float c) {
return mx == mn ? 0
: (c - mn) * s / (mx - mn);
};
@@ -66,10 +66,10 @@ static void set_lum(float* r, float* g, float* b, float l) {
}
static void clip_color_web(float* r, float* g, float* b) {
- auto clip = [&](float c) {
- float l = lum(*r,*g,*b),
- mn = min(*r,*g,*b),
- mx = max(*r,*g,*b);
+ float l = lum(*r,*g,*b),
+ mn = min(*r,*g,*b),
+ mx = max(*r,*g,*b);
+ auto clip = [=](float c) {
if (mn < 0) { c = l + (c - l) * ( l) / (l - mn); }
if (mx > 1) { c = l + (c - l) * (1 - l) / (mx - l); } // <--- notice "1-l"
//SkASSERT(0 <= c); // This may end up very slightly negative...
@@ -81,10 +81,10 @@ static void clip_color_web(float* r, float* g, float* b) {
*b = clip(*b);
}
static void clip_color_KHR(float* r, float* g, float* b) {
- auto clip = [&](float c) {
- float l = lum(*r,*g,*b),
- mn = min(*r,*g,*b),
- mx = max(*r,*g,*b);
+ float l = lum(*r,*g,*b),
+ mn = min(*r,*g,*b),
+ mx = max(*r,*g,*b);
+ auto clip = [=](float c) {
if (mn < 0) { c = l + (c - l) * l / (l - mn); }
if (mx > 1) { c = l + (c - l) * l / (mx - l); } // <--- notice "l"
//SkASSERT(0 <= c); // This may end up very slightly negative...