Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/ColorBehavior.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/ColorBehavior.cpp b/third_party/WebKit/Source/platform/graphics/ColorBehavior.cpp |
| index 54c4afb4c80e9349d99d459a68b7e3b1c2ef8735..3e6a51f03ab8a0c4c875c57bf9ed558badea4457 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/ColorBehavior.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/ColorBehavior.cpp |
| @@ -8,6 +8,7 @@ |
| #include "platform/graphics/BitmapImageMetrics.h" |
| #include "third_party/skia/include/core/SkICC.h" |
| #include "ui/gfx/icc_profile.h" |
| +#include "ui/gfx/skia_color_space_util.h" |
| #include "wtf/SpinLock.h" |
| namespace blink { |
| @@ -47,6 +48,67 @@ void ColorBehavior::setGlobalTargetColorProfile( |
| bool isNumericalTransferFnResult = skICC->isNumericalTransferFn(&fn); |
| UMA_HISTOGRAM_BOOLEAN("Blink.ColorSpace.Destination.Numerical", |
| isNumericalTransferFnResult); |
| + |
| + // Analyze the numerical approximation of table-based transfer functions. |
| + if (!isNumericalTransferFnResult) { |
| + SkICC::Tables tables; |
| + bool rawTransferFnResult = skICC->rawTransferFnData(&tables); |
| + UMA_HISTOGRAM_BOOLEAN("Blink.ColorSpace.Destination.ExtractedRawData", |
| + rawTransferFnResult); |
| + if (rawTransferFnResult) { |
| + SkICC::Channel* channels[3] = {&tables.fRed, &tables.fGreen, |
| + &tables.fBlue}; |
| + for (size_t c = 0; c < 3; ++c) { |
| + SkICC::Channel* channel = channels[c]; |
| + DCHECK_GE(channel->fCount, 2); |
| + const float* data = reinterpret_cast<const float*>( |
| + tables.fStorage->bytes() + channel->fOffset); |
| + std::vector<float> x; |
| + std::vector<float> t; |
| + float tMin = data[0]; |
| + float tMax = data[0]; |
| + for (int i = 0; i < channel->fCount; ++i) { |
| + float xi = i / (channel->fCount - 1.f); |
| + float ti = data[i]; |
| + x.push_back(xi); |
| + t.push_back(ti); |
| + tMin = std::min(tMin, ti); |
| + tMax = std::max(tMax, ti); |
| + } |
| + |
| + // Record the range of the table-based transfer function. If it is |
| + // found that almost all ranges are from 0 to 1, then we will bake |
| + // the assumption that the range is 0 to 1 into the numerical |
| + // approximation code (which will improve stability). |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("Blink.ColorSpace.Destination.TMin", |
| + static_cast<int>(tMin * 255), 0, 31, 8); |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( |
| + "Blink.ColorSpace.Destination.OneMinusTMax", |
| + static_cast<int>((1.f - tMax) * 255), 0, 31, 8); |
| + bool nonlinearFitConverged = false; |
| + float error = 0; |
| + gfx::SkApproximateTransferFn(x.data(), t.data(), x.size(), &fn, |
| + &error, &nonlinearFitConverged); |
| + |
| + // Record if the numerical fit converged, or if it didn't. |
| + UMA_HISTOGRAM_BOOLEAN( |
| + "Blink.ColorSpace.Destination.NonlinearFitConverged", |
| + nonlinearFitConverged); |
| + |
| + // Record the accuracy of the fit, separating out by nonlinear and |
| + // linear fits. |
| + if (nonlinearFitConverged) { |
|
pdr.
2017/02/23 21:24:57
These counters are in what looks like an expensive
ccameron
2017/02/23 23:18:51
Yes -- this should only happen once in a renderer'
|
| + UMA_HISTOGRAM_CUSTOM_COUNTS( |
| + "Blink.ColorSpace.Destination.NonlinearFitError", |
| + static_cast<int>(error * 255), 0, 127, 16); |
| + } else { |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( |
| + "Blink.ColorSpace.Destination.LinearFitError", |
| + static_cast<int>(error * 255), 0, 127, 16); |
| + } |
| + } |
| + } |
| + } |
| } |
| } |