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

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: .. Created 3 years, 7 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 ImageDecodeType { kInRaster, kCheckerImaging, kJSDecode };
vmpstr 2017/05/30 20:15:12 I think we should be consistent wrt to what we cal
Khushal 2017/05/31 18:21:20 Done.
39
40 static devtools_instrumentation::ScopedImageDecodeTask::DecodeTaskType
41 ToScopedDecodeTaskType(ImageDecodeType decode_type) {
42 using ScopedTaskType =
43 devtools_instrumentation::ScopedImageDecodeTask::DecodeTaskType;
44 switch (decode_type) {
45 case ImageDecodeType::kInRaster:
46 return ScopedTaskType::kInRaster;
47 case ImageDecodeType::kCheckerImaging:
48 return ScopedTaskType::kCheckerImaging;
49 case ImageDecodeType::kJSDecode:
50 return ScopedTaskType::kJSDecode;
51 }
52 NOTREACHED();
53 return ScopedTaskType::kInRaster;
54 }
55
37 // This information should be used strictly in tracing, UMA, and any other 56 // This information should be used strictly in tracing, UMA, and any other
38 // reporting systems. 57 // reporting systems.
39 struct TracingInfo { 58 struct TracingInfo {
40 TracingInfo(uint64_t prepare_tiles_id, 59 TracingInfo(uint64_t prepare_tiles_id,
41 TilePriority::PriorityBin requesting_tile_bin) 60 TilePriority::PriorityBin requesting_tile_bin,
61 ImageDecodeType type)
42 : prepare_tiles_id(prepare_tiles_id), 62 : prepare_tiles_id(prepare_tiles_id),
43 requesting_tile_bin(requesting_tile_bin) {} 63 requesting_tile_bin(requesting_tile_bin),
44 TracingInfo() : TracingInfo(0, TilePriority::NOW) {} 64 type(type) {}
65 TracingInfo()
66 : TracingInfo(0, TilePriority::NOW, ImageDecodeType::kInRaster) {}
45 67
46 // ID for the current prepare tiles call. 68 // ID for the current prepare tiles call.
47 const uint64_t prepare_tiles_id; 69 const uint64_t prepare_tiles_id;
48 70
49 // The bin of the tile that caused this image to be requested. 71 // The bin of the tile that caused this image to be requested.
50 const TilePriority::PriorityBin requesting_tile_bin; 72 const TilePriority::PriorityBin requesting_tile_bin;
73
74 // The task type for in-raster and out of raster decode tasks.
75 const ImageDecodeType type;
51 }; 76 };
52 77
53 virtual ~ImageDecodeCache() {} 78 virtual ~ImageDecodeCache() {}
54 79
55 // Fill in an TileTask which will decode the given image when run. In 80 // 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 81 // 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. 82 // image needs to be unreffed when the caller is finished with it.
58 // 83 //
59 // This is called by the tile manager (on the compositor thread) when creating 84 // This is called by the tile manager (on the compositor thread) when creating
60 // a raster task. 85 // a raster task.
61 virtual bool GetTaskForImageAndRef(const DrawImage& image, 86 virtual bool GetTaskForImageAndRef(const DrawImage& image,
62 const TracingInfo& tracing_info, 87 const TracingInfo& tracing_info,
63 scoped_refptr<TileTask>* task) = 0; 88 scoped_refptr<TileTask>* task) = 0;
64 // Similar to GetTaskForImageAndRef, except that it returns tasks that are not 89 // Similar to GetTaskForImageAndRef, except that it returns tasks that are not
65 // meant to be run as part of raster. That is, this is part of a predecode 90 // meant to be run as part of raster. That is, this is part of a predecode
66 // API. Note that this should only return a task responsible for decoding (and 91 // API. Note that this should only return a task responsible for decoding (and
67 // not uploading), since it will be run on a worker thread which may not have 92 // not uploading), since it will be run on a worker thread which may not have
68 // the right GPU context for upload. 93 // the right GPU context for upload.
69 virtual bool GetOutOfRasterDecodeTaskForImageAndRef( 94 virtual bool GetOutOfRasterDecodeTaskForImageAndRef(
70 const DrawImage& image, 95 const DrawImage& image,
96 ImageDecodeType decode_type,
71 scoped_refptr<TileTask>* task) = 0; 97 scoped_refptr<TileTask>* task) = 0;
72 98
73 // Unrefs an image. When the tile is finished, this should be called for every 99 // Unrefs an image. When the tile is finished, this should be called for every
74 // GetTaskForImageAndRef call that returned true. 100 // GetTaskForImageAndRef call that returned true.
75 virtual void UnrefImage(const DrawImage& image) = 0; 101 virtual void UnrefImage(const DrawImage& image) = 0;
76 102
77 // Returns a decoded draw image. This may cause a decode if the image was not 103 // Returns a decoded draw image. This may cause a decode if the image was not
78 // predecoded. 104 // predecoded.
79 // 105 //
80 // This is called by a raster task (on a worker thread) when an image is 106 // This is called by a raster task (on a worker thread) when an image is
(...skipping 19 matching lines...) Expand all
100 // Returns the maximum amount of memory we would be able to lock. This ignores 126 // 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 127 // 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 128 // memory. It is used as an esimate of whether an image can fit into the
103 // locked budget before creating a task. 129 // locked budget before creating a task.
104 virtual size_t GetMaximumMemoryLimitBytes() const = 0; 130 virtual size_t GetMaximumMemoryLimitBytes() const = 0;
105 }; 131 };
106 132
107 } // namespace cc 133 } // namespace cc
108 134
109 #endif // CC_TILES_IMAGE_DECODE_CACHE_H_ 135 #endif // CC_TILES_IMAGE_DECODE_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698