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 |
| 11 #include "base/optional.h" |
11 #include "cc/cc_export.h" | 12 #include "cc/cc_export.h" |
12 #include "cc/paint/image_id.h" | 13 #include "cc/paint/image_id.h" |
13 #include "cc/tiles/image_controller.h" | 14 #include "cc/tiles/image_controller.h" |
14 #include "third_party/skia/include/core/SkImage.h" | 15 #include "third_party/skia/include/core/SkImage.h" |
15 | 16 |
16 namespace cc { | 17 namespace cc { |
17 | 18 |
18 class CC_EXPORT CheckerImageTrackerClient { | 19 class CC_EXPORT CheckerImageTrackerClient { |
19 public: | 20 public: |
20 virtual ~CheckerImageTrackerClient() = default; | 21 virtual ~CheckerImageTrackerClient() = default; |
(...skipping 11 matching lines...) Expand all Loading... |
32 // sync tree until the previous tree is activated. | 33 // sync tree until the previous tree is activated. |
33 class CC_EXPORT CheckerImageTracker { | 34 class CC_EXPORT CheckerImageTracker { |
34 public: | 35 public: |
35 CheckerImageTracker(ImageController* image_controller, | 36 CheckerImageTracker(ImageController* image_controller, |
36 CheckerImageTrackerClient* client, | 37 CheckerImageTrackerClient* client, |
37 bool enable_checker_imaging); | 38 bool enable_checker_imaging); |
38 ~CheckerImageTracker(); | 39 ~CheckerImageTracker(); |
39 | 40 |
40 // Returns true if the decode for |image| will be deferred to the image decode | 41 // Returns true if the decode for |image| will be deferred to the image decode |
41 // service and it should be be skipped during raster. | 42 // service and it should be be skipped during raster. |
42 bool ShouldCheckerImage(const sk_sp<const SkImage>& image, WhichTree tree); | 43 bool ShouldCheckerImage(const PaintImage& image, WhichTree tree); |
43 | 44 |
44 using ImageDecodeQueue = std::vector<sk_sp<const SkImage>>; | 45 using ImageDecodeQueue = std::vector<PaintImage>; |
45 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue); | 46 void ScheduleImageDecodeQueue(ImageDecodeQueue image_decode_queue); |
46 | 47 |
47 // Returns the set of images to invalidate on the sync tree. | 48 // Returns the set of images to invalidate on the sync tree. |
48 const ImageIdFlatSet& TakeImagesToInvalidateOnSyncTree(); | 49 const PaintImageIdFlatSet& TakeImagesToInvalidateOnSyncTree(); |
49 | 50 |
50 // Called when the sync tree is activated. Each call to | 51 // Called when the sync tree is activated. Each call to |
51 // TakeImagesToInvalidateOnSyncTree() must be followed by this when the | 52 // TakeImagesToInvalidateOnSyncTree() must be followed by this when the |
52 // invalidated sync tree is activated. | 53 // invalidated sync tree is activated. |
53 void DidActivateSyncTree(); | 54 void DidActivateSyncTree(); |
54 | 55 |
55 // Called to reset the tracker state on navigation. This will release all | 56 // Called to reset the tracker state on navigation. This will release all |
56 // cached images. Setting |can_clear_decode_policy_tracking| will also result | 57 // cached images. Setting |can_clear_decode_policy_tracking| will also result |
57 // in re-checkering any images already decoded by the tracker. | 58 // in re-checkering any images already decoded by the tracker. |
58 void ClearTracker(bool can_clear_decode_policy_tracking); | 59 void ClearTracker(bool can_clear_decode_policy_tracking); |
(...skipping 20 matching lines...) Expand all Loading... |
79 : controller_(controller), request_id_(request_id) {} | 80 : controller_(controller), request_id_(request_id) {} |
80 ~ScopedDecodeHolder() { controller_->UnlockImageDecode(request_id_); } | 81 ~ScopedDecodeHolder() { controller_->UnlockImageDecode(request_id_); } |
81 | 82 |
82 private: | 83 private: |
83 ImageController* controller_; | 84 ImageController* controller_; |
84 ImageController::ImageDecodeRequestId request_id_; | 85 ImageController::ImageDecodeRequestId request_id_; |
85 | 86 |
86 DISALLOW_COPY_AND_ASSIGN(ScopedDecodeHolder); | 87 DISALLOW_COPY_AND_ASSIGN(ScopedDecodeHolder); |
87 }; | 88 }; |
88 | 89 |
89 void DidFinishImageDecode(ImageId image_id, | 90 void DidFinishImageDecode(PaintImage::Id image_id, |
90 ImageController::ImageDecodeRequestId request_id, | 91 ImageController::ImageDecodeRequestId request_id, |
91 ImageController::ImageDecodeResult result); | 92 ImageController::ImageDecodeResult result); |
92 | 93 |
93 // Called when the next request in the |image_decode_queue_| should be | 94 // Called when the next request in the |image_decode_queue_| should be |
94 // scheduled with the image decode service. | 95 // scheduled with the image decode service. |
95 void ScheduleNextImageDecode(); | 96 void ScheduleNextImageDecode(); |
96 | 97 |
97 ImageController* image_controller_; | 98 ImageController* image_controller_; |
98 CheckerImageTrackerClient* client_; | 99 CheckerImageTrackerClient* client_; |
99 const bool enable_checker_imaging_; | 100 const bool enable_checker_imaging_; |
100 | 101 |
101 // A set of images which have been decoded and are pending invalidation for | 102 // A set of images which have been decoded and are pending invalidation for |
102 // raster on the checkered tiles. | 103 // raster on the checkered tiles. |
103 ImageIdFlatSet images_pending_invalidation_; | 104 PaintImageIdFlatSet images_pending_invalidation_; |
104 | 105 |
105 // A set of images which were invalidated on the current sync tree. | 106 // A set of images which were invalidated on the current sync tree. |
106 ImageIdFlatSet invalidated_images_on_current_sync_tree_; | 107 PaintImageIdFlatSet invalidated_images_on_current_sync_tree_; |
107 | 108 |
108 // The queue of images pending decode. We maintain a queue to ensure that the | 109 // The queue of images pending decode. We maintain a queue to ensure that the |
109 // order in which images are decoded is aligned with the priority of the tiles | 110 // order in which images are decoded is aligned with the priority of the tiles |
110 // dependent on these images. | 111 // dependent on these images. |
111 ImageDecodeQueue image_decode_queue_; | 112 ImageDecodeQueue image_decode_queue_; |
112 | 113 |
113 // The currently outstanding image decode that has been scheduled with the | 114 // The currently outstanding image decode that has been scheduled with the |
114 // decode service. There can be only one outstanding decode at a time. | 115 // decode service. There can be only one outstanding decode at a time. |
115 sk_sp<const SkImage> outstanding_image_decode_; | 116 base::Optional<PaintImage> outstanding_image_decode_; |
116 | 117 |
117 // A map of ImageId to its DecodePolicy. | 118 // A map of ImageId to its DecodePolicy. |
118 std::unordered_map<ImageId, DecodePolicy> image_async_decode_state_; | 119 std::unordered_map<PaintImage::Id, DecodePolicy> image_async_decode_state_; |
119 | 120 |
120 // A map of image id to image decode request id for images to be unlocked. | 121 // A map of image id to image decode request id for images to be unlocked. |
121 std::unordered_map<ImageId, std::unique_ptr<ScopedDecodeHolder>> | 122 std::unordered_map<PaintImage::Id, std::unique_ptr<ScopedDecodeHolder>> |
122 image_id_to_decode_; | 123 image_id_to_decode_; |
123 | 124 |
124 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; | 125 base::WeakPtrFactory<CheckerImageTracker> weak_factory_; |
125 }; | 126 }; |
126 | 127 |
127 } // namespace cc | 128 } // namespace cc |
128 | 129 |
129 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ | 130 #endif // CC_TILES_CHECKER_IMAGE_TRACKER_H_ |
OLD | NEW |