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 #include "cc/tiles/checker_image_tracker.h" | 5 #include "cc/tiles/checker_image_tracker.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 // they should be accompanied with an invalidation during paint. | 81 // they should be accompanied with an invalidation during paint. |
82 image_id_to_decode_.clear(); | 82 image_id_to_decode_.clear(); |
83 | 83 |
84 if (can_clear_decode_policy_tracking) { | 84 if (can_clear_decode_policy_tracking) { |
85 image_async_decode_state_.clear(); | 85 image_async_decode_state_.clear(); |
86 } else { | 86 } else { |
87 // If we can't clear the decode policy, we need to make sure we still | 87 // If we can't clear the decode policy, we need to make sure we still |
88 // re-decode and checker images that were pending invalidation. | 88 // re-decode and checker images that were pending invalidation. |
89 for (auto image_id : images_pending_invalidation_) { | 89 for (auto image_id : images_pending_invalidation_) { |
90 auto it = image_async_decode_state_.find(image_id); | 90 auto it = image_async_decode_state_.find(image_id); |
91 DCHECK(it != image_async_decode_state_.end()); | |
91 | 92 |
92 DCHECK(it != image_async_decode_state_.end()); | 93 // We might have disallowed checkering for this image while it was pending |
94 // invalidation. Ensure that we keep this information. | |
95 if (it->second == DecodePolicy::SYNC_PERMANENT) | |
96 continue; | |
97 | |
93 DCHECK_EQ(it->second, DecodePolicy::SYNC_DECODED_ONCE); | 98 DCHECK_EQ(it->second, DecodePolicy::SYNC_DECODED_ONCE); |
94 | |
95 it->second = DecodePolicy::ASYNC; | 99 it->second = DecodePolicy::ASYNC; |
96 } | 100 } |
97 } | 101 } |
98 images_pending_invalidation_.clear(); | 102 images_pending_invalidation_.clear(); |
99 } | 103 } |
100 | 104 |
105 void CheckerImageTracker::DisallowCheckeringForImage(const PaintImage& image) { | |
106 image_async_decode_state_[image.stable_id()] = DecodePolicy::SYNC_PERMANENT; | |
Khushal
2017/06/07 00:47:21
I think if the image was already seen by the track
vmpstr
2017/06/07 17:05:35
Makes sense. I've added a separate container for t
| |
107 } | |
108 | |
101 void CheckerImageTracker::DidFinishImageDecode( | 109 void CheckerImageTracker::DidFinishImageDecode( |
102 PaintImage::Id image_id, | 110 PaintImage::Id image_id, |
103 ImageController::ImageDecodeRequestId request_id, | 111 ImageController::ImageDecodeRequestId request_id, |
104 ImageController::ImageDecodeResult result) { | 112 ImageController::ImageDecodeResult result) { |
105 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 113 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
106 "CheckerImageTracker::DidFinishImageDecode"); | 114 "CheckerImageTracker::DidFinishImageDecode"); |
107 TRACE_EVENT_ASYNC_END0("cc", "CheckerImageTracker::DeferImageDecode", | 115 TRACE_EVENT_ASYNC_END0("cc", "CheckerImageTracker::DeferImageDecode", |
108 image_id); | 116 image_id); |
109 | 117 |
110 DCHECK_NE(ImageController::ImageDecodeResult::DECODE_NOT_REQUIRED, result); | 118 DCHECK_NE(ImageController::ImageDecodeResult::DECODE_NOT_REQUIRED, result); |
111 DCHECK_EQ(outstanding_image_decode_.value().stable_id(), image_id); | 119 DCHECK_EQ(outstanding_image_decode_.value().stable_id(), image_id); |
112 outstanding_image_decode_.reset(); | 120 outstanding_image_decode_.reset(); |
113 | 121 |
114 // The async decode state may have been cleared if the tracker was cleared | 122 // The async decode state may have been cleared if the tracker was cleared |
115 // before this decode could be finished. | 123 // before this decode could be finished. |
116 auto it = image_async_decode_state_.find(image_id); | 124 auto it = image_async_decode_state_.find(image_id); |
117 if (it == image_async_decode_state_.end()) { | 125 if (it == image_async_decode_state_.end()) { |
118 DCHECK_EQ(image_id_to_decode_.count(image_id), 0u); | 126 DCHECK_EQ(image_id_to_decode_.count(image_id), 0u); |
119 return; | 127 return; |
120 } | 128 } |
121 | 129 |
122 it->second = DecodePolicy::SYNC_DECODED_ONCE; | 130 // We might have disallowed checkering for this image while it was being |
131 // processed. Ensure that the stronger condition is recorded. | |
132 if (it->second != DecodePolicy::SYNC_PERMANENT) | |
133 it->second = DecodePolicy::SYNC_DECODED_ONCE; | |
123 images_pending_invalidation_.insert(image_id); | 134 images_pending_invalidation_.insert(image_id); |
124 ScheduleNextImageDecode(); | 135 ScheduleNextImageDecode(); |
125 client_->NeedsInvalidationForCheckerImagedTiles(); | 136 client_->NeedsInvalidationForCheckerImagedTiles(); |
126 } | 137 } |
127 | 138 |
128 bool CheckerImageTracker::ShouldCheckerImage(const PaintImage& image, | 139 bool CheckerImageTracker::ShouldCheckerImage(const PaintImage& image, |
129 WhichTree tree) { | 140 WhichTree tree) { |
130 TRACE_EVENT1("cc", "CheckerImageTracker::ShouldCheckerImage", "image_id", | 141 TRACE_EVENT1("cc", "CheckerImageTracker::ShouldCheckerImage", "image_id", |
131 image.stable_id()); | 142 image.stable_id()); |
132 | 143 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 image_controller_->QueueImageDecode( | 222 image_controller_->QueueImageDecode( |
212 outstanding_image_decode_.value().sk_image(), | 223 outstanding_image_decode_.value().sk_image(), |
213 base::Bind(&CheckerImageTracker::DidFinishImageDecode, | 224 base::Bind(&CheckerImageTracker::DidFinishImageDecode, |
214 weak_factory_.GetWeakPtr(), image_id)); | 225 weak_factory_.GetWeakPtr(), image_id)); |
215 | 226 |
216 image_id_to_decode_.emplace(image_id, base::MakeUnique<ScopedDecodeHolder>( | 227 image_id_to_decode_.emplace(image_id, base::MakeUnique<ScopedDecodeHolder>( |
217 image_controller_, request_id)); | 228 image_controller_, request_id)); |
218 } | 229 } |
219 | 230 |
220 } // namespace cc | 231 } // namespace cc |
OLD | NEW |