1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_BITMAP_IMAGE_METRICS_H_
6 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_BITMAP_IMAGE_METRICS_H_
7 
8 #include "third_party/blink/renderer/platform/graphics/image_orientation.h"
9 #include "third_party/blink/renderer/platform/platform_export.h"
10 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
11 #include "third_party/blink/renderer/platform/wtf/forward.h"
12 
13 namespace blink {
14 
15 class IntSize;
16 
17 class PLATFORM_EXPORT BitmapImageMetrics {
18   STATIC_ONLY(BitmapImageMetrics);
19 
20  public:
21   // Values synced with 'DecodedImageType' in
22   // src/tools/metrics/histograms/enums.xml. These values are persisted to logs.
23   // Entries should not be renumbered and numeric values should never be reused.
24   enum DecodedImageType {
25     kImageUnknown = 0,
26     kImageJPEG = 1,
27     kImagePNG = 2,
28     kImageGIF = 3,
29     kImageWebP = 4,
30     kImageICO = 5,
31     kImageBMP = 6,
32     kDecodedImageTypeEnumEnd = kImageBMP + 1
33   };
34 
35   // Values synced with 'Gamma' in src/tools/metrics/histograms/enums.xml. These
36   // values are persisted to logs. Entries should not be renumbered and numeric
37   // values should never be reused.
38   enum Gamma {
39     kGammaLinear = 0,
40     kGammaSRGB = 1,
41     kGamma2Dot2 = 2,
42     kGammaNonStandard = 3,
43     kGammaNull = 4,
44     kGammaFail = 5,
45     kGammaInvalid = 6,
46     kGammaExponent = 7,
47     kGammaTable = 8,
48     kGammaParametric = 9,
49     kGammaNamed = 10,
50     kGammaEnd = kGammaNamed + 1,
51   };
52 
53   // Categories for the JPEG color space histogram. Synced with 'JpegColorSpace'
54   // in src/tools/metrics/histograms/enums.xml. These values are persisted to
55   // logs. Entries should not be renumbered and numeric values should never be
56   // reused.
57   enum JpegColorSpace {
58     kUnknown = 0,
59     kGrayscale = 1,
60     kRGB = 2,
61     kCMYK = 3,
62     kYCCK = 4,
63     kYCbCr410 = 5,
64     kYCbCr411 = 6,
65     kYCbCr420 = 7,
66     kYCbCr422 = 8,
67     kYCbCr440 = 9,
68     kYCbCr444 = 10,
69     kYCbCrOther = 11,
70     kMaxValue = kYCbCrOther,
71   };
72 
73   static void CountDecodedImageType(const String& type);
74   static void CountImageOrientation(const ImageOrientationEnum);
75   // Report the JPEG compression density in 0.01 bits per pixel for an image
76   // with a smallest side (width or length) of |image_min_side| and total size
77   // in bytes |image_size_bytes|.
78   static void CountImageJpegDensity(int image_min_side,
79                                     uint64_t density_centi_bpp,
80                                     size_t image_size_bytes);
81   static void CountJpegArea(const IntSize& size);
82   static void CountJpegColorSpace(JpegColorSpace color_space);
83 };
84 
85 }  // namespace blink
86 
87 #endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_BITMAP_IMAGE_METRICS_H_
88