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

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

Issue 2924233002: cc: Move pre-decodes to background worker. (Closed)
Patch Set: .. 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
« no previous file with comments | « no previous file | cc/tiles/checker_image_tracker.cc » ('j') | cc/tiles/checker_image_tracker.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 { kRaster, kPreDecode };
vmpstr 2017/06/12 21:45:30 Comment please
Khushal 2017/06/14 00:29:19 Done.
37
38 struct ImageDecodeRequest {
39 ImageDecodeRequest(PaintImage paint_image, DecodeType type);
40 PaintImage paint_image;
41 DecodeType type;
42 };
43
36 CheckerImageTracker(ImageController* image_controller, 44 CheckerImageTracker(ImageController* image_controller,
37 CheckerImageTrackerClient* client, 45 CheckerImageTrackerClient* client,
38 bool enable_checker_imaging); 46 bool enable_checker_imaging);
39 ~CheckerImageTracker(); 47 ~CheckerImageTracker();
40 48
41 // Returns true if the decode for |image| will be deferred to the image decode 49 // Returns true if the decode for |image| will be deferred to the image decode
42 // service and it should be be skipped during raster. 50 // service and it should be be skipped during raster.
43 bool ShouldCheckerImage(const DrawImage& image, WhichTree tree); 51 bool ShouldCheckerImage(const DrawImage& image, WhichTree tree);
44 52
45 using ImageDecodeQueue = std::vector<PaintImage>; 53 // Provides a prioritized queue of images to decode.
54 using ImageDecodeQueue = std::vector<ImageDecodeRequest>;
46 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue); 55 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue);
47 56
57 // Sets whether decode work should be scheduled for pre-decode tiles.
58 void SetCanSchedulePredecodeImages(bool can_schedule_predecode_images);
59
48 // Returns the set of images to invalidate on the sync tree. 60 // Returns the set of images to invalidate on the sync tree.
49 const PaintImageIdFlatSet& TakeImagesToInvalidateOnSyncTree(); 61 const PaintImageIdFlatSet& TakeImagesToInvalidateOnSyncTree();
50 62
51 // Called when the sync tree is activated. Each call to 63 // Called when the sync tree is activated. Each call to
52 // TakeImagesToInvalidateOnSyncTree() must be followed by this when the 64 // TakeImagesToInvalidateOnSyncTree() must be followed by this when the
53 // invalidated sync tree is activated. 65 // invalidated sync tree is activated.
54 void DidActivateSyncTree(); 66 void DidActivateSyncTree();
55 67
56 // Called to reset the tracker state on navigation. This will release all 68 // Called to reset the tracker state on navigation. This will release all
57 // cached images. Setting |can_clear_decode_policy_tracking| will also result 69 // cached images. Setting |can_clear_decode_policy_tracking| will also result
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 PaintImageIdFlatSet images_pending_invalidation_; 135 PaintImageIdFlatSet images_pending_invalidation_;
124 136
125 // A set of images which were invalidated on the current sync tree. 137 // A set of images which were invalidated on the current sync tree.
126 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_; 138 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_;
127 139
128 // The queue of images pending decode. We maintain a queue to ensure that the 140 // 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 141 // order in which images are decoded is aligned with the priority of the tiles
130 // dependent on these images. 142 // dependent on these images.
131 ImageDecodeQueue image_decode_queue_; 143 ImageDecodeQueue image_decode_queue_;
132 144
145 // Whether we can schedule decodes for pre-decoded images.
146 bool can_schedule_predecode_images_ = false;
147
133 // The currently outstanding image decode that has been scheduled with the 148 // The currently outstanding image decode that has been scheduled with the
134 // decode service. There can be only one outstanding decode at a time. 149 // decode service. There can be only one outstanding decode at a time.
135 base::Optional<PaintImage> outstanding_image_decode_; 150 base::Optional<PaintImage> outstanding_image_decode_;
136 151
137 // A map of ImageId to its DecodePolicy. 152 // A map of ImageId to its DecodePolicy.
138 std::unordered_map<PaintImage::Id, DecodeState> image_async_decode_state_; 153 std::unordered_map<PaintImage::Id, DecodeState> image_async_decode_state_;
139 154
140 // A map of image id to image decode request id for images to be unlocked. 155 // 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>> 156 std::unordered_map<PaintImage::Id, std::unique_ptr<ScopedDecodeHolder>>
142 image_id_to_decode_; 157 image_id_to_decode_;
143 158
144 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; 159 base::WeakPtrFactory<CheckerImageTracker> weak_factory_;
145 160
146 DISALLOW_COPY_AND_ASSIGN(CheckerImageTracker); 161 DISALLOW_COPY_AND_ASSIGN(CheckerImageTracker);
147 }; 162 };
148 163
149 } // namespace cc 164 } // namespace cc
150 165
151 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ 166 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/tiles/checker_image_tracker.cc » ('j') | cc/tiles/checker_image_tracker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698