Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: third_party/WebKit/Source/platform/graphics/ColorBehavior.cpp

Issue 2715453002: Add UMAs for numerical approximation of table-based transfer functions. (Closed)
Patch Set: Fix error computation Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | ui/gfx/color_space_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..05ccbf2ce30dddb71552305003e136d9f69e2c53 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,68 @@ 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.RawData",
+ 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];
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ "Blink.ColorSpace.Destination.TableSize", channel->fCount, 0,
+ 1023, 32);
+
+ if (channel->fCount < 0)
msarett1 2017/02/22 19:53:18 Instead you could say: DCHECK(channel->fCount >= 2
ccameron 2017/02/22 22:10:48 Done.
+ continue;
+ const float* data = reinterpret_cast<const float*>(
msarett1 2017/02/22 19:53:18 I see that my "convenience" helpers red(), green()
ccameron 2017/02/22 22:10:48 Yeah, index is better, cause I'll be iterating ove
+ 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, 255,
+ 256);
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Blink.ColorSpace.Destination.tMax",
+ static_cast<int>(tMax * 255), 0, 255,
+ 256);
+ bool nonlinearFitConverged = false;
+ bool linearFitSucceeded = false;
+ float error = 0;
+ gfx::SkApproximateTransferFn(x.data(), t.data(), x.size(), &fn,
+ &error, &nonlinearFitConverged,
+ &linearFitSucceeded);
+
+ // 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 (this includes nonlinear fits and
+ // linear fits).
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Blink.ColorSpace.Destination.FitError",
+ static_cast<int>(error * 255), 0, 255,
+ 256);
+ }
+ }
+ }
}
}
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | ui/gfx/color_space_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698