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

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

Issue 2726343004: cc: Optimize decode scheduling for checker-images. (Closed)
Patch Set: .. Created 3 years, 9 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 19 matching lines...) Expand all
30 // sync tree is activated. 30 // sync tree is activated.
31 // Note: It is illegal to call TakeImagesToInvalidateOnSyncTree for the next 31 // Note: It is illegal to call TakeImagesToInvalidateOnSyncTree for the next
32 // sync tree until the previous tree is activated. 32 // sync tree until the previous tree is activated.
33 class CC_EXPORT CheckerImageTracker { 33 class CC_EXPORT CheckerImageTracker {
34 public: 34 public:
35 CheckerImageTracker(ImageController* image_controller, 35 CheckerImageTracker(ImageController* image_controller,
36 CheckerImageTrackerClient* client, 36 CheckerImageTrackerClient* client,
37 bool enable_checker_imaging); 37 bool enable_checker_imaging);
38 ~CheckerImageTracker(); 38 ~CheckerImageTracker();
39 39
40 // Given the |images| for a tile, filters the images which will be deferred 40 // Returns true if the decode for |image| will be deferred to the image decode
41 // asynchronously using the image decoded service, eliminating them from 41 // service and it should be be skipped during raster.
42 // |images| adds them to the |checkered_images| set, so they can be skipped 42 bool ShouldCheckerImage(const sk_sp<const SkImage>& image,
43 // during the rasterization of this tile. 43 WhichTree tree) const;
44 // The entries remaining in |images| are for images for which a cached decode 44
45 // from the image decode service is available, or which must be decoded before 45 using ImageDecodeQueue = std::vector<sk_sp<const SkImage>>;
46 // before this tile can be rasterized. 46 void SetImageDecodeQueue(ImageDecodeQueue image_decode_queue);
47 void FilterImagesForCheckeringForTile(std::vector<DrawImage>* images,
48 ImageIdFlatSet* checkered_images,
49 WhichTree tree);
50 47
51 // Returns the set of images to invalidate on the sync tree. 48 // Returns the set of images to invalidate on the sync tree.
52 const ImageIdFlatSet& TakeImagesToInvalidateOnSyncTree(); 49 const ImageIdFlatSet& TakeImagesToInvalidateOnSyncTree();
53 50
54 void DidActivateSyncTree(); 51 void DidActivateSyncTree();
55 52
56 private: 53 private:
57 void DidFinishImageDecode(ImageId image_id, 54 void DidFinishImageDecode(ImageId image_id,
58 ImageController::ImageDecodeRequestId request_id, 55 ImageController::ImageDecodeRequestId request_id,
59 ImageController::ImageDecodeResult result); 56 ImageController::ImageDecodeResult result);
60 57
61 // Returns true if the decode for |image| will be deferred to the image decode 58 // Called when the next request in the |image_decode_queue_| should be
62 // service and it should be be skipped during raster. 59 // scheduled with the image decode service.
63 bool ShouldCheckerImage(const sk_sp<const SkImage>& image, 60 void ScheduleNextImageDecode();
64 WhichTree tree) const;
65
66 void ScheduleImageDecodeIfNecessary(const sk_sp<const SkImage>& image);
67 61
68 ImageController* image_controller_; 62 ImageController* image_controller_;
69 CheckerImageTrackerClient* client_; 63 CheckerImageTrackerClient* client_;
70 const bool enable_checker_imaging_; 64 const bool enable_checker_imaging_;
71 65
72 // A set of images which have been decoded and are pending invalidation for 66 // A set of images which have been decoded and are pending invalidation for
73 // raster on the checkered tiles. 67 // raster on the checkered tiles.
74 ImageIdFlatSet images_pending_invalidation_; 68 ImageIdFlatSet images_pending_invalidation_;
75 69
76 // A set of images which were invalidated on the current sync tree. 70 // A set of images which were invalidated on the current sync tree.
77 ImageIdFlatSet invalidated_images_on_current_sync_tree_; 71 ImageIdFlatSet invalidated_images_on_current_sync_tree_;
78 72
79 // A set of images which are currently pending decode from the image decode 73 // The queue of images pending decode. We maintain a queue to ensure that the
80 // service. 74 // order in which images are decoded is aligned with the priority of the tiles
81 // TODO(khushalsagar): This should be a queue that gets re-built each time we 75 // dependent on these images.
82 // do a PrepareTiles? See crbug.com/689184. 76 ImageDecodeQueue image_decode_queue_;
83 ImageIdFlatSet pending_image_decodes_; 77 size_t next_image_to_decode_ = 0;
vmpstr 2017/03/17 18:32:13 next_image_index? Or what is this? size_t is certa
Khushal 2017/03/27 13:57:33 Done.
78
79 // The currently outstanding image decode that has been scheduled with the
80 // decode service.
81 sk_sp<const SkImage> outstanding_image_decode_;
84 82
85 // A set of images which have been decoded at least once from the 83 // A set of images which have been decoded at least once from the
86 // ImageDecodeService and should not be checkered again. 84 // ImageDecodeService and should not be checkered again.
87 // TODO(khushalsagar): Limit the size of this set. 85 // TODO(khushalsagar): Limit the size of this set.
88 // TODO(khushalsagar): Plumb navigation changes here to reset this. See 86 // TODO(khushalsagar): Plumb navigation changes here to reset this. See
89 // crbug.com/693228. 87 // crbug.com/693228.
90 std::unordered_set<ImageId> images_decoded_once_; 88 std::unordered_set<ImageId> images_decoded_once_;
91 89
92 // A map of image id to image decode request id for images to be unlocked. 90 // A map of image id to image decode request id for images to be unlocked.
93 std::unordered_map<ImageId, ImageController::ImageDecodeRequestId> 91 std::unordered_map<ImageId, ImageController::ImageDecodeRequestId>
94 image_id_to_decode_request_id_; 92 image_id_to_decode_request_id_;
95 93
96 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; 94 base::WeakPtrFactory<CheckerImageTracker> weak_factory_;
97 }; 95 };
98 96
99 } // namespace cc 97 } // namespace cc
100 98
101 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ 99 #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