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

Unified 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 side-by-side diff with in-line comments
Download patch
« cc/tiles/checker_image_tracker.h ('K') | « cc/tiles/checker_image_tracker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/checker_image_tracker.cc
diff --git a/cc/tiles/checker_image_tracker.cc b/cc/tiles/checker_image_tracker.cc
index 8bbcbebe839fa490a47fe1e2d405598781a43ffb..8aa2a290b2527f1ec86f231a4a55b24df209fb1d 100644
--- a/cc/tiles/checker_image_tracker.cc
+++ b/cc/tiles/checker_image_tracker.cc
@@ -92,15 +92,17 @@ void CheckerImageTracker::DidFinishImageDecode(
DCHECK_NE(result, ImageController::ImageDecodeResult::DECODE_NOT_REQUIRED);
DCHECK_NE(pending_image_decodes_.count(image_id), 0u);
+ DCHECK_NE(image_async_decode_state_.count(image_id), 0u);
+
pending_image_decodes_.erase(image_id);
- images_decoded_once_.insert(image_id);
+ image_async_decode_state_[image_id] = AsyncDecodeVetoState::SYNC_DECODED_ONCE;
images_pending_invalidation_.insert(image_id);
client_->NeedsInvalidationForCheckerImagedTiles();
}
bool CheckerImageTracker::ShouldCheckerImage(const sk_sp<const SkImage>& image,
- WhichTree tree) const {
+ WhichTree tree) {
TRACE_EVENT1("cc", "CheckerImageTracker::ShouldCheckerImage", "image_id",
image->uniqueID());
@@ -115,12 +117,6 @@ bool CheckerImageTracker::ShouldCheckerImage(const sk_sp<const SkImage>& image,
return true;
}
- // If a decode request is pending for this image, continue checkering it.
- if (pending_image_decodes_.find(image->uniqueID()) !=
- pending_image_decodes_.end()) {
- return true;
- }
-
// If the image is pending invalidation, continue checkering it. All tiles
// for these images will be invalidated on the next pending tree.
if (images_pending_invalidation_.find(image->uniqueID()) !=
@@ -128,13 +124,16 @@ bool CheckerImageTracker::ShouldCheckerImage(const sk_sp<const SkImage>& image,
return true;
}
- // If the image has been decoded once before, don't checker it again.
- if (images_decoded_once_.find(image->uniqueID()) !=
- images_decoded_once_.end()) {
- return false;
+ ImageId image_id = image->uniqueID();
+ if (image_async_decode_state_.find(image_id) ==
+ image_async_decode_state_.end()) {
+ image_async_decode_state_[image_id] =
+ SafeSizeOfImage(image.get()) >= kMinImageSizeToCheckerBytes
+ ? AsyncDecodeVetoState::ASYNC
+ : AsyncDecodeVetoState::SYNC_PERMANENT;
}
- return SafeSizeOfImage(image.get()) >= kMinImageSizeToCheckerBytes;
+ 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.
}
void CheckerImageTracker::ScheduleImageDecodeIfNecessary(
@@ -143,10 +142,14 @@ void CheckerImageTracker::ScheduleImageDecodeIfNecessary(
"CheckerImageTracker::ScheduleImageDecodeIfNecessary");
ImageId image_id = image->uniqueID();
- // If the image has already been decoded, or a decode request is pending, we
- // don't need to schedule another decode.
- if (images_decoded_once_.count(image_id) != 0 ||
- pending_image_decodes_.count(image_id) != 0) {
+ // 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.
+ // request another decode.
+ DCHECK_NE(image_async_decode_state_.count(image_id), 0u);
+ if (image_async_decode_state_[image_id] != AsyncDecodeVetoState::ASYNC)
+ return;
+
+ // If a decode request is pending, we don't need to schedule another decode.
+ if (pending_image_decodes_.count(image_id) != 0) {
return;
}
« 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