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

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

Issue 2652313004: Implement color-gamut media query (Closed)
Patch Set: fix windows build Created 3 years, 11 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
Index: third_party/WebKit/Source/platform/graphics/BitmapImageMetrics.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/BitmapImageMetrics.cpp b/third_party/WebKit/Source/platform/graphics/BitmapImageMetrics.cpp
index 568c41443b53d6196f5f1db2f8ce9c141cff4ddf..0061d5dcbd8a22f521f8bb7ad8e509726b20da7d 100644
--- a/third_party/WebKit/Source/platform/graphics/BitmapImageMetrics.cpp
+++ b/third_party/WebKit/Source/platform/graphics/BitmapImageMetrics.cpp
@@ -5,7 +5,7 @@
#include "platform/graphics/BitmapImageMetrics.h"
#include "platform/Histogram.h"
-#include "third_party/skia/include/core/SkColorSpaceXform.h"
+#include "platform/graphics/ColorSpace.h"
#include "wtf/Threading.h"
#include "wtf/text/WTFString.h"
@@ -51,8 +51,10 @@ void BitmapImageMetrics::countImageGammaAndGamut(SkColorSpace* colorSpace) {
DEFINE_THREAD_SAFE_STATIC_LOCAL(
EnumerationHistogram, gamutNamedHistogram,
- new EnumerationHistogram("Blink.ColorGamut.Source", GamutEnd));
- gamutNamedHistogram.count(getColorSpaceGamut(colorSpace));
+ new EnumerationHistogram("Blink.ColorGamut.Source",
+ static_cast<int>(ColorSpaceGamut::End)));
+ gamutNamedHistogram.count(
+ static_cast<int>(ColorSpaceUtilities::getColorSpaceGamut(colorSpace)));
}
void BitmapImageMetrics::countOutputGammaAndGamut(SkColorSpace* colorSpace) {
@@ -63,8 +65,10 @@ void BitmapImageMetrics::countOutputGammaAndGamut(SkColorSpace* colorSpace) {
DEFINE_THREAD_SAFE_STATIC_LOCAL(
EnumerationHistogram, gamutNamedHistogram,
- new EnumerationHistogram("Blink.ColorGamut.Destination", GamutEnd));
- gamutNamedHistogram.count(getColorSpaceGamut(colorSpace));
+ new EnumerationHistogram("Blink.ColorGamut.Destination",
+ static_cast<int>(ColorSpaceGamut::End)));
+ gamutNamedHistogram.count(
+ static_cast<int>(ColorSpaceUtilities::getColorSpaceGamut(colorSpace)));
}
BitmapImageMetrics::Gamma BitmapImageMetrics::getColorSpaceGamma(
@@ -82,49 +86,4 @@ BitmapImageMetrics::Gamma BitmapImageMetrics::getColorSpaceGamma(
return gamma;
}
-BitmapImageMetrics::Gamut BitmapImageMetrics::getColorSpaceGamut(
- SkColorSpace* colorSpace) {
- sk_sp<SkColorSpace> scRGB(
- SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named));
- std::unique_ptr<SkColorSpaceXform> transform(
- SkColorSpaceXform::New(colorSpace, scRGB.get()));
-
- if (!transform)
- return GamutUnknown;
-
- unsigned char in[3][4];
- float out[3][4];
- memset(in, 0, sizeof(in));
- in[0][0] = 255;
- in[1][1] = 255;
- in[2][2] = 255;
- in[0][3] = 255;
- in[1][3] = 255;
- in[2][3] = 255;
- transform->apply(SkColorSpaceXform::kRGBA_F32_ColorFormat, out,
- SkColorSpaceXform::kRGBA_8888_ColorFormat, in, 3,
- kOpaque_SkAlphaType);
- float score = out[0][0] * out[1][1] * out[2][2];
-
- if (score < 0.9)
- return GamutLessThanNTSC;
- if (score < 0.95)
- return GamutNTSC; // actual score 0.912839
- if (score < 1.1)
- return GamutSRGB; // actual score 1.0
- if (score < 1.3)
- return GamutAlmostP3;
- if (score < 1.425)
- return GamutP3; // actual score 1.401899
- if (score < 1.5)
- return GamutAdobeRGB; // actual score 1.458385
- if (score < 2.0)
- return GamutWide;
- if (score < 2.2)
- return GamutBT2020; // actual score 2.104520
- if (score < 2.7)
- return GamutProPhoto; // actual score 2.913247
- return GamutUltraWide;
-}
-
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698