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

Side by Side Diff: cc/tiles/image_decode_cache.h

Issue 2904743002: cc: Add UMA for tracking decode duration for out of raster decodes. (Closed)
Patch Set: addressed comments Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_TILES_IMAGE_DECODE_CACHE_H_ 5 #ifndef CC_TILES_IMAGE_DECODE_CACHE_H_
6 #define CC_TILES_IMAGE_DECODE_CACHE_H_ 6 #define CC_TILES_IMAGE_DECODE_CACHE_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "cc/base/devtools_instrumentation.h"
9 #include "cc/paint/draw_image.h" 10 #include "cc/paint/draw_image.h"
10 #include "cc/tiles/decoded_draw_image.h" 11 #include "cc/tiles/decoded_draw_image.h"
11 #include "cc/tiles/tile_priority.h" 12 #include "cc/tiles/tile_priority.h"
12 13
13 namespace cc { 14 namespace cc {
14 15
15 class TileTask; 16 class TileTask;
16 17
17 // ImageDecodeCache is responsible for generating decode tasks, decoding 18 // ImageDecodeCache is responsible for generating decode tasks, decoding
18 // images, storing images in cache, and being able to return the decoded images 19 // images, storing images in cache, and being able to return the decoded images
19 // when requested. 20 // when requested.
20 21
21 // ImageDecodeCache is responsible for the following things: 22 // ImageDecodeCache is responsible for the following things:
22 // 1. Given a DrawImage, it can return an TileTask which when run will 23 // 1. Given a DrawImage, it can return an TileTask which when run will
23 // decode and cache the resulting image. If the image does not need a task to 24 // decode and cache the resulting image. If the image does not need a task to
24 // be decoded, then nullptr will be returned. The return value of the 25 // be decoded, then nullptr will be returned. The return value of the
25 // function indicates whether the image was or is going to be locked, so an 26 // function indicates whether the image was or is going to be locked, so an
26 // unlock will be required. 27 // unlock will be required.
27 // 2. Given a cache key and a DrawImage, it can decode the image and store it in 28 // 2. Given a cache key and a DrawImage, it can decode the image and store it in
28 // the cache. Note that it is important that this function is only accessed 29 // the cache. Note that it is important that this function is only accessed
29 // via an image decode task. 30 // via an image decode task.
30 // 3. Given a DrawImage, it can return a DecodedDrawImage, which represented the 31 // 3. Given a DrawImage, it can return a DecodedDrawImage, which represented the
31 // decoded version of the image. Note that if the image is not in the cache 32 // decoded version of the image. Note that if the image is not in the cache
32 // and it needs to be scaled/decoded, then this decode will happen as part of 33 // and it needs to be scaled/decoded, then this decode will happen as part of
33 // getting the image. As such, this should only be accessed from a raster 34 // getting the image. As such, this should only be accessed from a raster
34 // thread. 35 // thread.
35 class CC_EXPORT ImageDecodeCache { 36 class CC_EXPORT ImageDecodeCache {
36 public: 37 public:
38 enum class TaskType { kInRaster, kOutOfRaster };
39
37 // This information should be used strictly in tracing, UMA, and any other 40 // This information should be used strictly in tracing, UMA, and any other
38 // reporting systems. 41 // reporting systems.
39 struct TracingInfo { 42 struct TracingInfo {
40 TracingInfo(uint64_t prepare_tiles_id, 43 TracingInfo(uint64_t prepare_tiles_id,
41 TilePriority::PriorityBin requesting_tile_bin) 44 TilePriority::PriorityBin requesting_tile_bin,
45 TaskType task_type)
42 : prepare_tiles_id(prepare_tiles_id), 46 : prepare_tiles_id(prepare_tiles_id),
43 requesting_tile_bin(requesting_tile_bin) {} 47 requesting_tile_bin(requesting_tile_bin),
44 TracingInfo() : TracingInfo(0, TilePriority::NOW) {} 48 task_type(task_type) {}
49 TracingInfo() : TracingInfo(0, TilePriority::NOW, TaskType::kInRaster) {}
vmpstr 2017/06/01 21:40:56 While here, can you just = default this and put th
Khushal 2017/06/01 23:45:09 Done.
45 50
46 // ID for the current prepare tiles call. 51 // ID for the current prepare tiles call.
47 const uint64_t prepare_tiles_id; 52 const uint64_t prepare_tiles_id;
48 53
49 // The bin of the tile that caused this image to be requested. 54 // The bin of the tile that caused this image to be requested.
50 const TilePriority::PriorityBin requesting_tile_bin; 55 const TilePriority::PriorityBin requesting_tile_bin;
56
57 // Whether the decode is requested as a part of tile rasterization.
58 const TaskType task_type;
51 }; 59 };
52 60
61 static devtools_instrumentation::ScopedImageDecodeTask::TaskType
62 ToScopedTaskType(TaskType task_type) {
63 using ScopedTaskType =
64 devtools_instrumentation::ScopedImageDecodeTask::TaskType;
65 switch (task_type) {
66 case TaskType::kInRaster:
67 return ScopedTaskType::kInRaster;
68 case TaskType::kOutOfRaster:
69 return ScopedTaskType::kOutOfRaster;
70 }
71 NOTREACHED();
72 return ScopedTaskType::kInRaster;
73 }
74
53 virtual ~ImageDecodeCache() {} 75 virtual ~ImageDecodeCache() {}
54 76
55 // Fill in an TileTask which will decode the given image when run. In 77 // Fill in an TileTask which will decode the given image when run. In
56 // case the image is already cached, fills in nullptr. Returns true if the 78 // case the image is already cached, fills in nullptr. Returns true if the
57 // image needs to be unreffed when the caller is finished with it. 79 // image needs to be unreffed when the caller is finished with it.
58 // 80 //
59 // This is called by the tile manager (on the compositor thread) when creating 81 // This is called by the tile manager (on the compositor thread) when creating
60 // a raster task. 82 // a raster task.
61 virtual bool GetTaskForImageAndRef(const DrawImage& image, 83 virtual bool GetTaskForImageAndRef(const DrawImage& image,
62 const TracingInfo& tracing_info, 84 const TracingInfo& tracing_info,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // Returns the maximum amount of memory we would be able to lock. This ignores 122 // Returns the maximum amount of memory we would be able to lock. This ignores
101 // any temporary states, such as throttled, and return the maximum possible 123 // any temporary states, such as throttled, and return the maximum possible
102 // memory. It is used as an esimate of whether an image can fit into the 124 // memory. It is used as an esimate of whether an image can fit into the
103 // locked budget before creating a task. 125 // locked budget before creating a task.
104 virtual size_t GetMaximumMemoryLimitBytes() const = 0; 126 virtual size_t GetMaximumMemoryLimitBytes() const = 0;
105 }; 127 };
106 128
107 } // namespace cc 129 } // namespace cc
108 130
109 #endif // CC_TILES_IMAGE_DECODE_CACHE_H_ 131 #endif // CC_TILES_IMAGE_DECODE_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698