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

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: 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
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] = AsyncDecodeVetoState::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 if (image_async_decode_state_.find(image_id) ==
133 images_decoded_once_.end()) { 129 image_async_decode_state_.end()) {
134 return false; 130 image_async_decode_state_[image_id] =
131 SafeSizeOfImage(image.get()) >= kMinImageSizeToCheckerBytes
132 ? AsyncDecodeVetoState::ASYNC
133 : AsyncDecodeVetoState::SYNC_PERMANENT;
135 } 134 }
136 135
137 return SafeSizeOfImage(image.get()) >= kMinImageSizeToCheckerBytes; 136 return image_async_decode_state_[image_id] == AsyncDecodeVetoState::ASYNC;
vmpstr 2017/04/11 18:42:55 Erm, in lines 128-136 you do 3 finds on the same i
Khushal 2017/04/12 20:31:17 Done.
138 } 137 }
139 138
140 void CheckerImageTracker::ScheduleImageDecodeIfNecessary( 139 void CheckerImageTracker::ScheduleImageDecodeIfNecessary(
141 const sk_sp<const SkImage>& image) { 140 const sk_sp<const SkImage>& image) {
142 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 141 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
143 "CheckerImageTracker::ScheduleImageDecodeIfNecessary"); 142 "CheckerImageTracker::ScheduleImageDecodeIfNecessary");
144 ImageId image_id = image->uniqueID(); 143 ImageId image_id = image->uniqueID();
145 144
146 // If the image has already been decoded, or a decode request is pending, we 145 // The image might have already been decoded, in which case we don't need to
vmpstr 2017/04/11 18:42:55 Can you reword the comment to take into account th
Khushal 2017/04/12 20:31:17 Done.
147 // don't need to schedule another decode. 146 // request another decode.
148 if (images_decoded_once_.count(image_id) != 0 || 147 DCHECK_NE(image_async_decode_state_.count(image_id), 0u);
149 pending_image_decodes_.count(image_id) != 0) { 148 if (image_async_decode_state_[image_id] != AsyncDecodeVetoState::ASYNC)
149 return;
150
151 // If a decode request is pending, we don't need to schedule another decode.
152 if (pending_image_decodes_.count(image_id) != 0) {
150 return; 153 return;
151 } 154 }
152 155
153 TRACE_EVENT_ASYNC_BEGIN0("cc", "CheckerImageTracker::DeferImageDecode", 156 TRACE_EVENT_ASYNC_BEGIN0("cc", "CheckerImageTracker::DeferImageDecode",
154 image_id); 157 image_id);
155 DCHECK_EQ(image_id_to_decode_request_id_.count(image_id), 0U); 158 DCHECK_EQ(image_id_to_decode_request_id_.count(image_id), 0U);
156 159
157 image_id_to_decode_request_id_[image_id] = 160 image_id_to_decode_request_id_[image_id] =
158 image_controller_->QueueImageDecode( 161 image_controller_->QueueImageDecode(
159 image, base::Bind(&CheckerImageTracker::DidFinishImageDecode, 162 image, base::Bind(&CheckerImageTracker::DidFinishImageDecode,
160 weak_factory_.GetWeakPtr(), image_id)); 163 weak_factory_.GetWeakPtr(), image_id));
161 pending_image_decodes_.insert(image_id); 164 pending_image_decodes_.insert(image_id);
162 } 165 }
163 166
164 } // namespace cc 167 } // namespace cc
OLDNEW
« cc/tiles/checker_image_tracker.h ('K') | « cc/tiles/checker_image_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698