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

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

Issue 2817473002: cc: Use an enum for tracking images vetoed for async decodes. (Closed)
Patch Set: addressed comments 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/tiles/checker_image_tracker.h ('k') | no next file » | 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 #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/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 ImageId image_id, 85 ImageId image_id,
86 ImageController::ImageDecodeRequestId request_id, 86 ImageController::ImageDecodeRequestId request_id,
87 ImageController::ImageDecodeResult result) { 87 ImageController::ImageDecodeResult result) {
88 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 88 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
89 "CheckerImageTracker::DidFinishImageDecode"); 89 "CheckerImageTracker::DidFinishImageDecode");
90 TRACE_EVENT_ASYNC_END0("cc", "CheckerImageTracker::DeferImageDecode", 90 TRACE_EVENT_ASYNC_END0("cc", "CheckerImageTracker::DeferImageDecode",
91 image_id); 91 image_id);
92 92
93 DCHECK_NE(result, ImageController::ImageDecodeResult::DECODE_NOT_REQUIRED); 93 DCHECK_NE(result, ImageController::ImageDecodeResult::DECODE_NOT_REQUIRED);
94 DCHECK_NE(pending_image_decodes_.count(image_id), 0u); 94 DCHECK_NE(pending_image_decodes_.count(image_id), 0u);
95 DCHECK_NE(image_async_decode_state_.count(image_id), 0u);
96
95 pending_image_decodes_.erase(image_id); 97 pending_image_decodes_.erase(image_id);
96 98
97 images_decoded_once_.insert(image_id); 99 image_async_decode_state_[image_id] = DecodePolicy::SYNC_DECODED_ONCE;
98 images_pending_invalidation_.insert(image_id); 100 images_pending_invalidation_.insert(image_id);
99 client_->NeedsInvalidationForCheckerImagedTiles(); 101 client_->NeedsInvalidationForCheckerImagedTiles();
100 } 102 }
101 103
102 bool CheckerImageTracker::ShouldCheckerImage(const sk_sp<const SkImage>& image, 104 bool CheckerImageTracker::ShouldCheckerImage(const sk_sp<const SkImage>& image,
103 WhichTree tree) const { 105 WhichTree tree) {
104 TRACE_EVENT1("cc", "CheckerImageTracker::ShouldCheckerImage", "image_id", 106 TRACE_EVENT1("cc", "CheckerImageTracker::ShouldCheckerImage", "image_id",
105 image->uniqueID()); 107 image->uniqueID());
106 108
107 if (!enable_checker_imaging_) 109 if (!enable_checker_imaging_)
108 return false; 110 return false;
109 111
110 // If the image was invalidated on the current sync tree and the tile is 112 // If the image was invalidated on the current sync tree and the tile is
111 // for the active tree, continue checkering it on the active tree to ensure 113 // for the active tree, continue checkering it on the active tree to ensure
112 // the image update is atomic for the frame. 114 // the image update is atomic for the frame.
113 if (invalidated_images_on_current_sync_tree_.count(image->uniqueID()) != 0 && 115 if (invalidated_images_on_current_sync_tree_.count(image->uniqueID()) != 0 &&
114 tree == WhichTree::ACTIVE_TREE) { 116 tree == WhichTree::ACTIVE_TREE) {
115 return true; 117 return true;
116 } 118 }
117 119
118 // If a decode request is pending for this image, continue checkering it.
119 if (pending_image_decodes_.find(image->uniqueID()) !=
120 pending_image_decodes_.end()) {
121 return true;
122 }
123
124 // If the image is pending invalidation, continue checkering it. All tiles 120 // If the image is pending invalidation, continue checkering it. All tiles
125 // for these images will be invalidated on the next pending tree. 121 // for these images will be invalidated on the next pending tree.
126 if (images_pending_invalidation_.find(image->uniqueID()) != 122 if (images_pending_invalidation_.find(image->uniqueID()) !=
127 images_pending_invalidation_.end()) { 123 images_pending_invalidation_.end()) {
128 return true; 124 return true;
129 } 125 }
130 126
131 // If the image has been decoded once before, don't checker it again. 127 ImageId image_id = image->uniqueID();
132 if (images_decoded_once_.find(image->uniqueID()) != 128 DecodePolicy policy;
133 images_decoded_once_.end()) { 129
134 return false; 130 auto it = image_async_decode_state_.find(image_id);
vmpstr 2017/04/13 18:28:12 nit: Call ::insert() on it so you always get an it
Khushal 2017/04/14 01:06:42 Done.
131 if (it == image_async_decode_state_.end()) {
132 policy = SafeSizeOfImage(image.get()) >= kMinImageSizeToCheckerBytes
133 ? DecodePolicy::ASYNC
134 : DecodePolicy::SYNC_PERMANENT;
135 image_async_decode_state_[image_id] = policy;
136 } else {
137 policy = it->second;
135 } 138 }
136 139
137 return SafeSizeOfImage(image.get()) >= kMinImageSizeToCheckerBytes; 140 return policy == DecodePolicy::ASYNC;
138 } 141 }
139 142
140 void CheckerImageTracker::ScheduleImageDecodeIfNecessary( 143 void CheckerImageTracker::ScheduleImageDecodeIfNecessary(
141 const sk_sp<const SkImage>& image) { 144 const sk_sp<const SkImage>& image) {
142 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 145 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
143 "CheckerImageTracker::ScheduleImageDecodeIfNecessary"); 146 "CheckerImageTracker::ScheduleImageDecodeIfNecessary");
144 ImageId image_id = image->uniqueID(); 147 ImageId image_id = image->uniqueID();
145 148
146 // If the image has already been decoded, or a decode request is pending, we 149 // Once an image has been decoded, they can still be present in the decode
147 // don't need to schedule another decode. 150 // queue (duplicate entries), or while an image is still being skipped on the
148 if (images_decoded_once_.count(image_id) != 0 || 151 // active tree. Check if the image is still ASYNC to see if a decode is
149 pending_image_decodes_.count(image_id) != 0) { 152 // needed.
153 DCHECK_NE(image_async_decode_state_.count(image_id), 0u);
vmpstr 2017/04/13 18:28:12 just do a find, then use the iterator for both the
Khushal 2017/04/14 01:06:42 Done.
154 if (image_async_decode_state_[image_id] != DecodePolicy::ASYNC)
155 return;
156
157 // If a decode request is pending, we don't need to schedule another decode.
158 if (pending_image_decodes_.count(image_id) != 0) {
150 return; 159 return;
151 } 160 }
152 161
153 TRACE_EVENT_ASYNC_BEGIN0("cc", "CheckerImageTracker::DeferImageDecode", 162 TRACE_EVENT_ASYNC_BEGIN0("cc", "CheckerImageTracker::DeferImageDecode",
154 image_id); 163 image_id);
155 DCHECK_EQ(image_id_to_decode_request_id_.count(image_id), 0U); 164 DCHECK_EQ(image_id_to_decode_request_id_.count(image_id), 0U);
156 165
157 image_id_to_decode_request_id_[image_id] = 166 image_id_to_decode_request_id_[image_id] =
158 image_controller_->QueueImageDecode( 167 image_controller_->QueueImageDecode(
159 image, base::Bind(&CheckerImageTracker::DidFinishImageDecode, 168 image, base::Bind(&CheckerImageTracker::DidFinishImageDecode,
160 weak_factory_.GetWeakPtr(), image_id)); 169 weak_factory_.GetWeakPtr(), image_id));
161 pending_image_decodes_.insert(image_id); 170 pending_image_decodes_.insert(image_id);
162 } 171 }
163 172
164 } // namespace cc 173 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/checker_image_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698