aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skpdiff
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-21 11:57:12 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-21 11:57:12 +0000
commit89558c9dcbb5c87628c24489e8481801bf871695 (patch)
tree9066cabbb058192a15777a09edc2d4664099d4a1 /tools/skpdiff
parent29de433b06aa4886d75508c1aa28ee7911737760 (diff)
Fix skpdiff segfault caused by NaN computation.
BUG=skia:2574 R=mtklein@google.com, rmistry@google.com Author: djsollen@google.com Review URL: https://codereview.chromium.org/296033004 git-svn-id: http://skia.googlecode.com/svn/trunk@14818 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/skpdiff')
-rw-r--r--tools/skpdiff/SkPMetric.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/skpdiff/SkPMetric.cpp b/tools/skpdiff/SkPMetric.cpp
index beba4974b7..47880ac291 100644
--- a/tools/skpdiff/SkPMetric.cpp
+++ b/tools/skpdiff/SkPMetric.cpp
@@ -1,4 +1,5 @@
#include <cmath>
+#include <math.h>
#include "SkBitmap.h"
#include "skpdiff_util.h"
@@ -159,10 +160,12 @@ static bool bitmap_to_cielab(const SkBitmap* bitmap, ImageLAB* outImageLAB) {
static float contrast_sensitivity(float cyclesPerDegree, float luminance) {
float a = 440.0f * powf(1.0f + 0.7f / luminance, -0.2f);
float b = 0.3f * powf(1.0f + 100.0f / luminance, 0.15f);
- return a *
- cyclesPerDegree *
- expf(-b * cyclesPerDegree) *
- sqrtf(1.0f + 0.06f * expf(b * cyclesPerDegree));
+ float exp = expf(-b * cyclesPerDegree);
+ float root = sqrtf(1.0f + 0.06f * expf(b * cyclesPerDegree));
+ if (!std::isfinite(exp) || !std::isfinite(root)) {
+ return 0;
+ }
+ return a * cyclesPerDegree * exp * root;
}
#if 0