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

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

Issue 2869513002: cc: Clear checker-image tracking on navigation and visibility changes. (Closed)
Patch Set: comment 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
« no previous file with comments | « no previous file | cc/tiles/checker_image_tracker.cc » ('j') | cc/trees/layer_tree_host_impl.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 29 matching lines...) Expand all
40 // Returns true if the decode for |image| will be deferred to the image decode 40 // Returns true if the decode for |image| will be deferred to the image decode
41 // service and it should be be skipped during raster. 41 // service and it should be be skipped during raster.
42 bool ShouldCheckerImage(const sk_sp<const SkImage>& image, WhichTree tree); 42 bool ShouldCheckerImage(const sk_sp<const SkImage>& image, WhichTree tree);
43 43
44 using ImageDecodeQueue = std::vector<sk_sp<const SkImage>>; 44 using ImageDecodeQueue = std::vector<sk_sp<const SkImage>>;
45 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue); 45 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue);
46 46
47 // Returns the set of images to invalidate on the sync tree. 47 // Returns the set of images to invalidate on the sync tree.
48 const ImageIdFlatSet& TakeImagesToInvalidateOnSyncTree(); 48 const ImageIdFlatSet& TakeImagesToInvalidateOnSyncTree();
49 49
50 // Called when the sync tree is activated. Each call to
51 // TakeImagesToInvalidateOnSyncTree() must be followed by this when the
52 // invalidated sync tree is activated.
50 void DidActivateSyncTree(); 53 void DidActivateSyncTree();
51 54
55 // Called to reset the tracker state on navigation or when going invisible.
56 void ClearTracker();
57
52 private: 58 private:
53 enum class DecodePolicy { 59 enum class DecodePolicy {
54 // The image can be decoded asynchronously from raster. When set, the image 60 // The image can be decoded asynchronously from raster. When set, the image
55 // is always skipped during rasterization of content that includes this 61 // is always skipped during rasterization of content that includes this
56 // image until it has been decoded using the decode service. 62 // image until it has been decoded using the decode service.
57 ASYNC, 63 ASYNC,
58 // The image has been decoded asynchronously once and should now be 64 // The image has been decoded asynchronously once and should now be
59 // synchronously rasterized with the content. 65 // synchronously rasterized with the content.
60 SYNC_DECODED_ONCE, 66 SYNC_DECODED_ONCE,
61 // The image has been permanently vetoed from being decoded async. 67 // The image has been permanently vetoed from being decoded async.
62 SYNC_PERMANENT, 68 SYNC_PERMANENT,
63 }; 69 };
64 70
71 class ScopedDecodeHolder {
vmpstr 2017/05/09 22:06:21 ScopedDecodeUnlocker maybe? Can you also drop a cl
Khushal 2017/05/10 22:47:09 Done.
72 public:
73 ScopedDecodeHolder(ImageController* controller,
74 ImageController::ImageDecodeRequestId request_id)
75 : controller_(controller), request_id_(request_id) {}
76 ~ScopedDecodeHolder() { controller_->UnlockImageDecode(request_id_); }
77
78 private:
79 ImageController* controller_;
80 ImageController::ImageDecodeRequestId request_id_;
81
82 DISALLOW_COPY_AND_ASSIGN(ScopedDecodeHolder);
83 };
84
65 void DidFinishImageDecode(ImageId image_id, 85 void DidFinishImageDecode(ImageId image_id,
66 ImageController::ImageDecodeRequestId request_id, 86 ImageController::ImageDecodeRequestId request_id,
67 ImageController::ImageDecodeResult result); 87 ImageController::ImageDecodeResult result);
68 88
69 // Called when the next request in the |image_decode_queue_| should be 89 // Called when the next request in the |image_decode_queue_| should be
70 // scheduled with the image decode service. 90 // scheduled with the image decode service.
71 void ScheduleNextImageDecode(); 91 void ScheduleNextImageDecode();
72 92
73 ImageController* image_controller_; 93 ImageController* image_controller_;
74 CheckerImageTrackerClient* client_; 94 CheckerImageTrackerClient* client_;
75 const bool enable_checker_imaging_; 95 const bool enable_checker_imaging_;
76 96
77 // A set of images which have been decoded and are pending invalidation for 97 // A set of images which have been decoded and are pending invalidation for
78 // raster on the checkered tiles. 98 // raster on the checkered tiles.
79 ImageIdFlatSet images_pending_invalidation_; 99 ImageIdFlatSet images_pending_invalidation_;
80 100
81 // A set of images which were invalidated on the current sync tree. 101 // A set of images which were invalidated on the current sync tree.
82 ImageIdFlatSet invalidated_images_on_current_sync_tree_; 102 ImageIdFlatSet invalidated_images_on_current_sync_tree_;
83 103
84 // The queue of images pending decode. We maintain a queue to ensure that the 104 // The queue of images pending decode. We maintain a queue to ensure that the
85 // order in which images are decoded is aligned with the priority of the tiles 105 // order in which images are decoded is aligned with the priority of the tiles
86 // dependent on these images. 106 // dependent on these images.
87 ImageDecodeQueue image_decode_queue_; 107 ImageDecodeQueue image_decode_queue_;
88 108
89 // The currently outstanding image decode that has been scheduled with the 109 // The currently outstanding image decode that has been scheduled with the
90 // decode service. There can be only one outstanding decode at a time. 110 // decode service. There can be only one outstanding decode at a time.
91 sk_sp<const SkImage> outstanding_image_decode_; 111 sk_sp<const SkImage> outstanding_image_decode_;
92 112
93 // A map of ImageId to its DecodePolicy. 113 // A map of ImageId to its DecodePolicy.
94 // TODO(khushalsagar): Limit the size of this set.
95 // TODO(khushalsagar): Plumb navigation changes here to reset this. See
96 // crbug.com/693228.
97 std::unordered_map<ImageId, DecodePolicy> image_async_decode_state_; 114 std::unordered_map<ImageId, DecodePolicy> image_async_decode_state_;
98 115
99 // A map of image id to image decode request id for images to be unlocked. 116 // A map of image id to image decode request id for images to be unlocked.
100 std::unordered_map<ImageId, ImageController::ImageDecodeRequestId> 117 std::unordered_map<ImageId, std::unique_ptr<ScopedDecodeHolder>>
101 image_id_to_decode_request_id_; 118 image_id_to_decode_;
102 119
103 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; 120 base::WeakPtrFactory<CheckerImageTracker> weak_factory_;
104 }; 121 };
105 122
106 } // namespace cc 123 } // namespace cc
107 124
108 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ 125 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/tiles/checker_image_tracker.cc » ('j') | cc/trees/layer_tree_host_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698