aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkColorLookUpTable.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-04-11 09:26:24 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-11 14:03:48 +0000
commit3fbca26e9c0e6e3c27c9dd437c9f790a31f20675 (patch)
treeee66c03f5b0499ab188ddf44776330dfb601fe30 /src/core/SkColorLookUpTable.cpp
parent31f99ce7d2f3c2b61742d07ab92b6dac6a928ef9 (diff)
Make sure NaNs clamp to 0 in color look up tables
This operation assumes 0-1 input and guarantees 0-1 output. The old clamp was poorly written, causing the possibility for NaNs to not be set to 0. BUG=709941 Change-Id: I691f0494a562a329967f5b0149a1ba04cbeb8464 Reviewed-on: https://skia-review.googlesource.com/13134 Commit-Queue: Matt Sarett <msarett@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkColorLookUpTable.cpp')
-rw-r--r--src/core/SkColorLookUpTable.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/core/SkColorLookUpTable.cpp b/src/core/SkColorLookUpTable.cpp
index 8a550182f7..b8bb346123 100644
--- a/src/core/SkColorLookUpTable.cpp
+++ b/src/core/SkColorLookUpTable.cpp
@@ -6,6 +6,7 @@
*/
#include "SkColorLookUpTable.h"
+#include "SkColorSpaceXformPriv.h"
#include "SkFloatingPoint.h"
void SkColorLookUpTable::interp(float* dst, const float* src) const {
@@ -114,11 +115,7 @@ void SkColorLookUpTable::interp3D(float* dst, const float* src) const {
// look up tables, we don't check for it.
// And for arbitrary, non-increasing tables, it is easy to see how
// the output might not be 0-1. So we clamp here.
- if (dst[i] > 1.f) {
- dst[i] = 1.f;
- } else if (dst[i] < 0.f) {
- dst[i] = 0.f;
- }
+ dst[i] = clamp_0_1(dst[i]);
// Increment the table ptr in order to handle the next component.
// Note that this is the how table is designed: all of nXXX
@@ -158,5 +155,5 @@ float SkColorLookUpTable::interpDimension(const float* src, int inputDimension,
// and recursively LERP all sub-dimensions with the current dimension fixed to the high point
const float hi = interpDimension(src, inputDimension - 1, outputDimension, index);
// then LERP the results based on the current dimension
- return (1 - diff) * lo + diff * hi;
+ return clamp_0_1((1 - diff) * lo + diff * hi);
}