Commit e61d7832 authored by msarett's avatar msarett Committed by Commit bot

Use UMA to track characteristics of dst color spaces

As far as I can tell, SRGB gamma and 2.2 gamma dst color
spaces are very common, with all other possibilities
being extremely rare.

We'd like to limit our color correct implementations
to approximations of SRGB and 2Dot2 destinations:
(1) Allows software and gpu to stay in sync.
(2) Avoids code bloat caused by supporting any
    arbitrary representation that can be packed into an
    ICC profile.

To be confident in making this decision, we need some
metrics to help verify our assumptions about the dst color
spaces.

BUG=

Review-Url: https://codereview.chromium.org/2177933002
Cr-Commit-Position: refs/heads/master@{#407675}
parent 0bc11b2a
...@@ -30,4 +30,22 @@ void BitmapImageMetrics::countImageOrientation(const ImageOrientationEnum orient ...@@ -30,4 +30,22 @@ void BitmapImageMetrics::countImageOrientation(const ImageOrientationEnum orient
orientationHistogram.count(orientation); orientationHistogram.count(orientation);
} }
void BitmapImageMetrics::countGamma(SkColorSpace* colorSpace)
{
DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, gammaNamedHistogram, new EnumerationHistogram("Blink.ColorSpace.Destination", GammaEnd));
if (colorSpace) {
SkColorSpace::GammaNamed skGamma = colorSpace->gammaNamed();
Gamma gamma =
(SkColorSpace::kLinear_GammaNamed == skGamma) ? GammaLinear :
(SkColorSpace::kSRGB_GammaNamed == skGamma) ? GammaSRGB :
(SkColorSpace::k2Dot2Curve_GammaNamed == skGamma) ? Gamma2Dot2 :
(SkColorSpace::kNonStandard_GammaNamed == skGamma) ? GammaNonStandard :
GammaFail;
gammaNamedHistogram.count(gamma);
} else {
gammaNamedHistogram.count(GammaNull);
}
}
} // namespace blink } // namespace blink
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "platform/PlatformExport.h" #include "platform/PlatformExport.h"
#include "platform/graphics/ImageOrientation.h" #include "platform/graphics/ImageOrientation.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "wtf/Allocator.h" #include "wtf/Allocator.h"
#include "wtf/Forward.h" #include "wtf/Forward.h"
...@@ -27,8 +28,21 @@ public: ...@@ -27,8 +28,21 @@ public:
DecodedImageTypeEnumEnd = ImageBMP + 1 DecodedImageTypeEnumEnd = ImageBMP + 1
}; };
enum Gamma {
// Values synced with 'Gamma' in src/tools/metrics/histograms/histograms.xml
GammaLinear = 0,
GammaSRGB = 1,
Gamma2Dot2 = 2,
GammaNonStandard = 3,
GammaEmpty = 4,
GammaNull = 5,
GammaFail = 6,
GammaEnd = GammaFail + 1,
};
static void countDecodedImageType(const String& type); static void countDecodedImageType(const String& type);
static void countImageOrientation(const ImageOrientationEnum); static void countImageOrientation(const ImageOrientationEnum);
static void countGamma(SkColorSpace*);
}; };
} // namespace blink } // namespace blink
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "platform/image-decoders/ImageDecoder.h" #include "platform/image-decoders/ImageDecoder.h"
#include "platform/PlatformInstrumentation.h" #include "platform/PlatformInstrumentation.h"
#include "platform/graphics/BitmapImageMetrics.h"
#include "platform/image-decoders/bmp/BMPImageDecoder.h" #include "platform/image-decoders/bmp/BMPImageDecoder.h"
#include "platform/image-decoders/gif/GIFImageDecoder.h" #include "platform/image-decoders/gif/GIFImageDecoder.h"
#include "platform/image-decoders/ico/ICOImageDecoder.h" #include "platform/image-decoders/ico/ICOImageDecoder.h"
...@@ -331,6 +332,11 @@ void ImageDecoder::setTargetColorProfile(const WebVector<char>& profile) ...@@ -331,6 +332,11 @@ void ImageDecoder::setTargetColorProfile(const WebVector<char>& profile)
if (gTargetColorProfile) if (gTargetColorProfile)
return; return;
{
sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewICC(profile.data(), profile.size());
BitmapImageMetrics::countGamma(colorSpace.get());
}
// FIXME: Add optional ICCv4 support and support for multiple monitors. // FIXME: Add optional ICCv4 support and support for multiple monitors.
gTargetColorProfile = qcms_profile_from_memory(profile.data(), profile.size()); gTargetColorProfile = qcms_profile_from_memory(profile.data(), profile.size());
if (!gTargetColorProfile) if (!gTargetColorProfile)
......
...@@ -3670,6 +3670,11 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -3670,6 +3670,11 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<summary>Time spent on 2D canvas toDataURL API call.</summary> <summary>Time spent on 2D canvas toDataURL API call.</summary>
</histogram> </histogram>
<histogram name="Blink.ColorSpace.Destination" enum="Gamma">
<owner>msarett@chromium.org</owner>
<summary>Gamma properties of destination color space.</summary>
</histogram>
<histogram name="Blink.Compositing.UpdateTime" units="microseconds"> <histogram name="Blink.Compositing.UpdateTime" units="microseconds">
<owner>paint-dev@chromium.org</owner> <owner>paint-dev@chromium.org</owner>
<summary> <summary>
...@@ -78269,6 +78274,15 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -78269,6 +78274,15 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<int value="8" label="Overflow"/> <int value="8" label="Overflow"/>
</enum> </enum>
<enum name="Gamma" type="int">
<int value="0" label="kLinear_Gamma"/>
<int value="1" label="kSRGB_Gamma"/>
<int value="2" label="k2Dot2Curve_Gamma"/>
<int value="3" label="kNonStandard_Gamma"/>
<int value="4" label="kNull_Gamma"/>
<int value="5" label="kFail_Gamma"/>
</enum>
<enum name="GATTCharacteristicHash" type="int"> <enum name="GATTCharacteristicHash" type="int">
<!-- Hash values can be produced using tool: bluetooth_metrics_hash (Only built via GN, not GYP) --> <!-- Hash values can be produced using tool: bluetooth_metrics_hash (Only built via GN, not GYP) -->
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment