Commit 71d2d460 authored by Andres Calderon Jaramillo's avatar Andres Calderon Jaramillo Committed by Commit Bot

Blink: move RecordJpegImageArea() to BitmapImageMetrics.

This CL moves RecordJpegImageArea() from JpegImageDecoder to
BitmapImageMetrics to centralize the recording of UMAs for JPEGs and to
be consistent with the color space UMA. The method is renamed to
CountJpegArea() to be consistent with other methods in
BitmapImageMetrics.

Bug: 886914
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Idd0dc443a7e742065a158ee19adeb242479a245f
Reviewed-on: https://chromium-review.googlesource.com/1249399
Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: default avatarFlorin Malita <fmalita@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595680}
parent bf08f95f
......@@ -4,6 +4,9 @@
#include "third_party/blink/renderer/platform/graphics/bitmap_image_metrics.h"
#include "base/metrics/histogram_base.h"
#include "base/numerics/safe_conversions.h"
#include "third_party/blink/renderer/platform/geometry/int_size.h"
#include "third_party/blink/renderer/platform/graphics/color_space_gamut.h"
#include "third_party/blink/renderer/platform/histogram.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
......@@ -79,6 +82,17 @@ void BitmapImageMetrics::CountImageGammaAndGamut(
static_cast<int>(ColorSpaceUtilities::GetColorSpaceGamut(color_profile)));
}
void BitmapImageMetrics::CountJpegArea(const IntSize& size) {
DEFINE_THREAD_SAFE_STATIC_LOCAL(
CustomCountHistogram, image_area_histogram,
("Blink.ImageDecoders.Jpeg.Area", 1 /* min */, 8192 * 8192 /* max */,
100 /* bucket_count */));
// A base::HistogramBase::Sample may not fit |size.Area()|. Hence the use of
// saturated_cast.
image_area_histogram.Count(
base::saturated_cast<base::HistogramBase::Sample>(size.Area()));
}
void BitmapImageMetrics::CountJpegColorSpace(JpegColorSpace color_space) {
DEFINE_THREAD_SAFE_STATIC_LOCAL(
EnumerationHistogram, color_space_histogram,
......
......@@ -14,6 +14,8 @@ struct skcms_ICCProfile;
namespace blink {
class IntSize;
class PLATFORM_EXPORT BitmapImageMetrics {
STATIC_ONLY(BitmapImageMetrics);
......@@ -77,6 +79,7 @@ class PLATFORM_EXPORT BitmapImageMetrics {
static void CountImageJpegDensity(int image_min_side,
int64_t density_centi_bpp);
static void CountImageGammaAndGamut(const skcms_ICCProfile*);
static void CountJpegArea(const IntSize& size);
static void CountJpegColorSpace(JpegColorSpace color_space);
private:
......
......@@ -7,7 +7,6 @@ include_rules = [
# Dependencies.
"+cc/paint/image_animation_count.h",
"+third_party/blink/renderer/platform/histogram.h",
"+third_party/blink/renderer/platform/geometry",
"+third_party/blink/renderer/platform/graphics",
"+third_party/blink/renderer/platform/histogram.h",
......
......@@ -38,11 +38,8 @@
#include "third_party/blink/renderer/platform/image-decoders/jpeg/jpeg_image_decoder.h"
#include <memory>
#include "base/numerics/safe_conversions.h"
#include "build/build_config.h"
#include "third_party/blink/renderer/platform/geometry/int_size.h"
#include "third_party/blink/renderer/platform/graphics/bitmap_image_metrics.h"
#include "third_party/blink/renderer/platform/histogram.h"
#include "third_party/blink/renderer/platform/instrumentation/platform_instrumentation.h"
extern "C" {
......@@ -83,24 +80,6 @@ const int exifMarker = JPEG_APP0 + 1;
// JPEG only supports a denominator of 8.
const unsigned g_scale_denomiator = 8;
// Configuration for the JPEG image area histogram. See RecordJpegImageArea().
const char* kImageAreaHistogramName = "Blink.ImageDecoders.Jpeg.Area";
constexpr base::HistogramBase::Sample kImageAreaHistogramMin = 1;
constexpr base::HistogramBase::Sample kImageAreaHistogramMax = 8192 * 8192;
constexpr int32_t kImageAreaHistogramBucketCount = 100;
// Records the area (total number of pixels) of a JPEG image as a UMA.
void RecordJpegImageArea(const blink::IntSize& size) {
DEFINE_THREAD_SAFE_STATIC_LOCAL(
blink::CustomCountHistogram, image_area_histogram,
(kImageAreaHistogramName, kImageAreaHistogramMin, kImageAreaHistogramMax,
kImageAreaHistogramBucketCount));
// A base::HistogramBase::Sample may not fit |size.Area()|. Hence the use of
// saturated_cast.
image_area_histogram.Count(
base::saturated_cast<base::HistogramBase::Sample>(size.Area()));
}
// Extracts the JPEG color space of an image for UMA purposes given |info| which
// is assumed to have gone through a jpeg_read_header(). When the color space is
// YCbCr, we also extract the chroma subsampling. The caveat is that the
......@@ -711,7 +690,7 @@ class JPEGImageReader final {
case JPEG_DONE:
// Finish decompression.
RecordJpegImageArea(decoder_->Size());
BitmapImageMetrics::CountJpegArea(decoder_->Size());
BitmapImageMetrics::CountJpegColorSpace(
ExtractUMAJpegColorSpace(info_));
return jpeg_finish_decompress(&info_);
......
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