diff options
-rw-r--r-- | src/effects/SkHighContrastFilter.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/effects/SkHighContrastFilter.cpp b/src/effects/SkHighContrastFilter.cpp index b1900f0567..9df04c110b 100644 --- a/src/effects/SkHighContrastFilter.cpp +++ b/src/effects/SkHighContrastFilter.cpp @@ -298,10 +298,13 @@ void GLHighContrastFilterEffect::emitCode(EmitArgs& args) { fragBuilder->codeAppendf(" s = l > 0.5 ?"); fragBuilder->codeAppendf(" d / (2 - fmax - fmin) :"); fragBuilder->codeAppendf(" d / (fmax + fmin);"); - fragBuilder->codeAppendf(" if (fmax == color.r) {"); + // We'd like to just write "if (color.r == fmax) { ... }". On many GPUs, running the + // angle_d3d9_es2 config, that failed. It seems that max(x, y) is not necessarily equal + // to either x or y. Tried several ways to fix it, but this was the only reasonable fix. + fragBuilder->codeAppendf(" if (color.r >= color.g && color.r >= color.b) {"); fragBuilder->codeAppendf(" h = (color.g - color.b) / d + "); fragBuilder->codeAppendf(" (color.g < color.b ? 6 : 0);"); - fragBuilder->codeAppendf(" } else if (fmax == color.g) {"); + fragBuilder->codeAppendf(" } else if (color.g >= color.b) {"); fragBuilder->codeAppendf(" h = (color.b - color.r) / d + 2;"); fragBuilder->codeAppendf(" } else {"); fragBuilder->codeAppendf(" h = (color.r - color.g) / d + 4;"); |