[go: nahoru, domu]

cc: Record mip levels used for downscaling images in the renderer.

Bug: 729183
Change-Id: I4e5b3251048d57d592bb82e933d23adab146a31d
Reviewed-on: https://chromium-review.googlesource.com/568662
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Reviewed-by: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487221}
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 3a68d81..29f538f 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -345,6 +345,7 @@
     "tiles/gpu_image_decode_cache.h",
     "tiles/image_controller.cc",
     "tiles/image_controller.h",
+    "tiles/image_decode_cache.cc",
     "tiles/image_decode_cache.h",
     "tiles/mipmap_util.cc",
     "tiles/mipmap_util.h",
diff --git a/cc/tiles/gpu_image_decode_cache.cc b/cc/tiles/gpu_image_decode_cache.cc
index 4235494..41511d2c 100644
--- a/cc/tiles/gpu_image_decode_cache.cc
+++ b/cc/tiles/gpu_image_decode_cache.cc
@@ -1146,6 +1146,7 @@
   }
 
   TRACE_EVENT0("cc", "GpuImageDecodeCache::DecodeImage");
+  RecordImageMipLevelUMA(image_data->upload_params.fPreScaleMipLevel);
 
   image_data->decode.ResetData();
   std::unique_ptr<base::DiscardableMemory> backing_memory;
diff --git a/cc/tiles/image_decode_cache.cc b/cc/tiles/image_decode_cache.cc
new file mode 100644
index 0000000..680264da
--- /dev/null
+++ b/cc/tiles/image_decode_cache.cc
@@ -0,0 +1,18 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/tiles/image_decode_cache.h"
+
+#include "base/metrics/histogram_macros.h"
+
+namespace cc {
+
+void ImageDecodeCache::RecordImageMipLevelUMA(int mip_level) {
+  DCHECK_GE(mip_level, 0);
+  DCHECK_LT(mip_level, 32);
+  UMA_HISTOGRAM_EXACT_LINEAR("Renderer4.ImageDecodeMipLevel", mip_level + 1,
+                             33);
+}
+
+}  // namespace cc
diff --git a/cc/tiles/image_decode_cache.h b/cc/tiles/image_decode_cache.h
index 25ed140..1a67b9f 100644
--- a/cc/tiles/image_decode_cache.h
+++ b/cc/tiles/image_decode_cache.h
@@ -130,6 +130,9 @@
   // image is locked, then the cache can do its best to clean it
   // up later.
   virtual void NotifyImageUnused(uint32_t skimage_id) = 0;
+
+ protected:
+  void RecordImageMipLevelUMA(int mip_level);
 };
 
 }  // namespace cc
diff --git a/cc/tiles/software_image_decode_cache.cc b/cc/tiles/software_image_decode_cache.cc
index 8a0ee43..5486a718 100644
--- a/cc/tiles/software_image_decode_cache.cc
+++ b/cc/tiles/software_image_decode_cache.cc
@@ -430,6 +430,9 @@
   if (task_type == DecodeTaskType::USE_OUT_OF_RASTER_TASKS)
     decoded_image->mark_out_of_raster();
 
+  RecordImageMipLevelUMA(
+      MipMapUtil::GetLevelForSize(key.src_rect().size(), key.target_size()));
+
   decoded_images_.Put(key, std::move(decoded_image));
 }
 
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index f7fb043..193ad09 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -61920,6 +61920,17 @@
   </summary>
 </histogram>
 
+<histogram name="Renderer4.ImageDecodeMipLevel" units="mip level">
+  <owner>khushalsagar@chromium.org</owner>
+  <summary>
+    The mip level at which images are decoded for rasterization in the renderer.
+    This value is recorded each time an image is decoded in the compositor and
+    records the mip level used for the decode. Note that the mip levels recorded
+    lie between [1, 32], with the value of 1 indicating the use of the original
+    image.
+  </summary>
+</histogram>
+
 <histogram name="Renderer4.ImageDecodeTaskDurationUs" units="microseconds">
   <owner>vmpstr@chromium.org</owner>
   <summary>