OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_CHECKER_IMAGE_TRACKER_H_ | 5 #ifndef CC_TILES_CHECKER_IMAGE_TRACKER_H_ |
6 #define CC_TILES_CHECKER_IMAGE_TRACKER_H_ | 6 #define CC_TILES_CHECKER_IMAGE_TRACKER_H_ |
7 | 7 |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... | |
26 // CheckerImageTracker is used to track the set of images in a frame which are | 26 // CheckerImageTracker is used to track the set of images in a frame which are |
27 // decoded asynchronously, using the ImageDecodeService, from the rasterization | 27 // decoded asynchronously, using the ImageDecodeService, from the rasterization |
28 // of tiles which depend on them. Once decoded, these images are stored for | 28 // of tiles which depend on them. Once decoded, these images are stored for |
29 // invalidation on the next sync tree. TakeImagesToInvalidateOnSyncTree will | 29 // invalidation on the next sync tree. TakeImagesToInvalidateOnSyncTree will |
30 // return this set and maintain a copy to keeps these images locked until the | 30 // return this set and maintain a copy to keeps these images locked until the |
31 // sync tree is activated. | 31 // sync tree is activated. |
32 // Note: It is illegal to call TakeImagesToInvalidateOnSyncTree for the next | 32 // Note: It is illegal to call TakeImagesToInvalidateOnSyncTree for the next |
33 // sync tree until the previous tree is activated. | 33 // sync tree until the previous tree is activated. |
34 class CC_EXPORT CheckerImageTracker { | 34 class CC_EXPORT CheckerImageTracker { |
35 public: | 35 public: |
36 enum class DecodeType : uint16_t { | |
37 // Highest priority. Used to disable scheduling any decode work. | |
38 kNone, | |
vmpstr
2017/06/20 18:41:01
This is an awkward name. Just from looking at this
Khushal
2017/06/21 23:45:28
I just made it all internal so we wouldn't need to
| |
39 // Priority for images on tiles being rasterized (visible or pre-paint). | |
40 kRaster, | |
41 // Lowest priority for images on tiles in pre-decode region. These are tiles | |
42 // which are beyond the pre-paint region, but have their images decoded. | |
43 kPreDecode | |
44 }; | |
45 | |
46 struct ImageDecodeRequest { | |
47 ImageDecodeRequest(PaintImage paint_image, DecodeType type); | |
48 PaintImage paint_image; | |
49 DecodeType type; | |
50 }; | |
51 | |
36 CheckerImageTracker(ImageController* image_controller, | 52 CheckerImageTracker(ImageController* image_controller, |
37 CheckerImageTrackerClient* client, | 53 CheckerImageTrackerClient* client, |
38 bool enable_checker_imaging); | 54 bool enable_checker_imaging); |
39 ~CheckerImageTracker(); | 55 ~CheckerImageTracker(); |
40 | 56 |
41 // Returns true if the decode for |image| will be deferred to the image decode | 57 // Returns true if the decode for |image| will be deferred to the image decode |
42 // service and it should be be skipped during raster. | 58 // service and it should be be skipped during raster. |
43 bool ShouldCheckerImage(const DrawImage& image, WhichTree tree); | 59 bool ShouldCheckerImage(const DrawImage& image, WhichTree tree); |
44 | 60 |
45 using ImageDecodeQueue = std::vector<PaintImage>; | 61 // Provides a prioritized queue of images to decode. |
62 using ImageDecodeQueue = std::vector<ImageDecodeRequest>; | |
46 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue); | 63 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue); |
47 | 64 |
65 // The max decode priority type that is allowed to run. | |
vmpstr
2017/06/20 18:41:01
Can you use the word "max" or "limit" in the funct
Khushal
2017/06/21 03:35:57
Done.
| |
66 void SetCanScheduleDecodeType(DecodeType decode_type); | |
67 | |
48 // Returns the set of images to invalidate on the sync tree. | 68 // Returns the set of images to invalidate on the sync tree. |
49 const PaintImageIdFlatSet& TakeImagesToInvalidateOnSyncTree(); | 69 const PaintImageIdFlatSet& TakeImagesToInvalidateOnSyncTree(); |
50 | 70 |
51 // Called when the sync tree is activated. Each call to | 71 // Called when the sync tree is activated. Each call to |
52 // TakeImagesToInvalidateOnSyncTree() must be followed by this when the | 72 // TakeImagesToInvalidateOnSyncTree() must be followed by this when the |
53 // invalidated sync tree is activated. | 73 // invalidated sync tree is activated. |
54 void DidActivateSyncTree(); | 74 void DidActivateSyncTree(); |
55 | 75 |
56 // Called to reset the tracker state on navigation. This will release all | 76 // Called to reset the tracker state on navigation. This will release all |
57 // cached images. Setting |can_clear_decode_policy_tracking| will also result | 77 // cached images. Setting |can_clear_decode_policy_tracking| will also result |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 PaintImageIdFlatSet images_pending_invalidation_; | 143 PaintImageIdFlatSet images_pending_invalidation_; |
124 | 144 |
125 // A set of images which were invalidated on the current sync tree. | 145 // A set of images which were invalidated on the current sync tree. |
126 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_; | 146 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_; |
127 | 147 |
128 // The queue of images pending decode. We maintain a queue to ensure that the | 148 // The queue of images pending decode. We maintain a queue to ensure that the |
129 // order in which images are decoded is aligned with the priority of the tiles | 149 // order in which images are decoded is aligned with the priority of the tiles |
130 // dependent on these images. | 150 // dependent on these images. |
131 ImageDecodeQueue image_decode_queue_; | 151 ImageDecodeQueue image_decode_queue_; |
132 | 152 |
153 // The max decode type that is allowed to run. | |
154 DecodeType decode_type_allowed_; | |
155 | |
133 // The currently outstanding image decode that has been scheduled with the | 156 // The currently outstanding image decode that has been scheduled with the |
134 // decode service. There can be only one outstanding decode at a time. | 157 // decode service. There can be only one outstanding decode at a time. |
135 base::Optional<PaintImage> outstanding_image_decode_; | 158 base::Optional<PaintImage> outstanding_image_decode_; |
136 | 159 |
137 // A map of ImageId to its DecodePolicy. | 160 // A map of ImageId to its DecodePolicy. |
138 std::unordered_map<PaintImage::Id, DecodeState> image_async_decode_state_; | 161 std::unordered_map<PaintImage::Id, DecodeState> image_async_decode_state_; |
139 | 162 |
140 // A map of image id to image decode request id for images to be unlocked. | 163 // A map of image id to image decode request id for images to be unlocked. |
141 std::unordered_map<PaintImage::Id, std::unique_ptr<ScopedDecodeHolder>> | 164 std::unordered_map<PaintImage::Id, std::unique_ptr<ScopedDecodeHolder>> |
142 image_id_to_decode_; | 165 image_id_to_decode_; |
143 | 166 |
144 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; | 167 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; |
145 | 168 |
146 DISALLOW_COPY_AND_ASSIGN(CheckerImageTracker); | 169 DISALLOW_COPY_AND_ASSIGN(CheckerImageTracker); |
147 }; | 170 }; |
148 | 171 |
149 } // namespace cc | 172 } // namespace cc |
150 | 173 |
151 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ | 174 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ |
OLD | NEW |