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

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

Issue 2726343004: cc: Optimize decode scheduling for checker-images. (Closed)
Patch Set: rebase Created 3 years, 8 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 | « cc/test/test_layer_tree_host_base.cc ('k') | cc/tiles/checker_image_tracker.cc » ('j') | no next file with comments »
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, WhichTree tree);
43 // during the rasterization of this tile. 43
44 // The entries remaining in |images| are for images for which a cached decode 44 using ImageDecodeQueue = std::vector<sk_sp<const SkImage>>;
45 // from the image decode service is available, or which must be decoded before 45 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue);
46 // before this tile can be rasterized.
47 void FilterImagesForCheckeringForTile(std::vector<DrawImage>* images,
48 ImageIdFlatSet* checkered_images,
49 WhichTree tree);
50 46
51 // Returns the set of images to invalidate on the sync tree. 47 // Returns the set of images to invalidate on the sync tree.
52 const ImageIdFlatSet& TakeImagesToInvalidateOnSyncTree(); 48 const ImageIdFlatSet& TakeImagesToInvalidateOnSyncTree();
53 49
54 void DidActivateSyncTree(); 50 void DidActivateSyncTree();
55 51
56 private: 52 private:
57 enum class DecodePolicy { 53 enum class DecodePolicy {
58 // The image can be decoded asynchronously from raster. When set, the image 54 // The image can be decoded asynchronously from raster. When set, the image
59 // is always skipped during rasterization of content that includes this 55 // is always skipped during rasterization of content that includes this
60 // image until it has been decoded using the decode service. 56 // image until it has been decoded using the decode service.
61 ASYNC, 57 ASYNC,
62 // The image has been decoded asynchronously once and should now be 58 // The image has been decoded asynchronously once and should now be
63 // synchronously rasterized with the content. 59 // synchronously rasterized with the content.
64 SYNC_DECODED_ONCE, 60 SYNC_DECODED_ONCE,
65 // The image has been permanently vetoed from being decoded async. 61 // The image has been permanently vetoed from being decoded async.
66 SYNC_PERMANENT, 62 SYNC_PERMANENT,
67 }; 63 };
68 64
69 void DidFinishImageDecode(ImageId image_id, 65 void DidFinishImageDecode(ImageId image_id,
70 ImageController::ImageDecodeRequestId request_id, 66 ImageController::ImageDecodeRequestId request_id,
71 ImageController::ImageDecodeResult result); 67 ImageController::ImageDecodeResult result);
72 68
73 // Returns true if the decode for |image| will be deferred to the image decode 69 // Called when the next request in the |image_decode_queue_| should be
74 // service and it should be be skipped during raster. 70 // scheduled with the image decode service.
75 bool ShouldCheckerImage(const sk_sp<const SkImage>& image, WhichTree tree); 71 void ScheduleNextImageDecode();
76
77 void ScheduleImageDecodeIfNecessary(const sk_sp<const SkImage>& image);
78 72
79 ImageController* image_controller_; 73 ImageController* image_controller_;
80 CheckerImageTrackerClient* client_; 74 CheckerImageTrackerClient* client_;
81 const bool enable_checker_imaging_; 75 const bool enable_checker_imaging_;
82 76
83 // A set of images which have been decoded and are pending invalidation for 77 // A set of images which have been decoded and are pending invalidation for
84 // raster on the checkered tiles. 78 // raster on the checkered tiles.
85 ImageIdFlatSet images_pending_invalidation_; 79 ImageIdFlatSet images_pending_invalidation_;
86 80
87 // A set of images which were invalidated on the current sync tree. 81 // A set of images which were invalidated on the current sync tree.
88 ImageIdFlatSet invalidated_images_on_current_sync_tree_; 82 ImageIdFlatSet invalidated_images_on_current_sync_tree_;
89 83
90 // A set of images which are currently pending decode from the image decode 84 // The queue of images pending decode. We maintain a queue to ensure that the
91 // service. 85 // order in which images are decoded is aligned with the priority of the tiles
92 // TODO(khushalsagar): This should be a queue that gets re-built each time we 86 // dependent on these images.
93 // do a PrepareTiles? See crbug.com/689184. 87 ImageDecodeQueue image_decode_queue_;
94 ImageIdFlatSet pending_image_decodes_; 88
89 // The currently outstanding image decode that has been scheduled with the
90 // decode service. There can be only one outstanding decode at a time.
91 sk_sp<const SkImage> outstanding_image_decode_;
95 92
96 // A map of ImageId to its DecodePolicy. 93 // A map of ImageId to its DecodePolicy.
97 // TODO(khushalsagar): Limit the size of this set. 94 // TODO(khushalsagar): Limit the size of this set.
98 // TODO(khushalsagar): Plumb navigation changes here to reset this. See 95 // TODO(khushalsagar): Plumb navigation changes here to reset this. See
99 // crbug.com/693228. 96 // crbug.com/693228.
100 std::unordered_map<ImageId, DecodePolicy> image_async_decode_state_; 97 std::unordered_map<ImageId, DecodePolicy> image_async_decode_state_;
101 98
102 // A map of image id to image decode request id for images to be unlocked. 99 // A map of image id to image decode request id for images to be unlocked.
103 std::unordered_map<ImageId, ImageController::ImageDecodeRequestId> 100 std::unordered_map<ImageId, ImageController::ImageDecodeRequestId>
104 image_id_to_decode_request_id_; 101 image_id_to_decode_request_id_;
105 102
106 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; 103 base::WeakPtrFactory<CheckerImageTracker> weak_factory_;
107 }; 104 };
108 105
109 } // namespace cc 106 } // namespace cc
110 107
111 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ 108 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_
OLDNEW
« no previous file with comments | « cc/test/test_layer_tree_host_base.cc ('k') | cc/tiles/checker_image_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698