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

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

Issue 2924233002: cc: Move pre-decodes to background worker. (Closed)
Patch Set: flake is flaky. T_T Created 3 years, 5 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') | cc/tiles/checker_image_tracker_unittest.cc » ('j') | 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/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 21 matching lines...) Expand all
32 str << "paint_image_id[" << paint_image_id << "] sk_image_id[" << sk_image_id 32 str << "paint_image_id[" << paint_image_id << "] sk_image_id[" << sk_image_id
33 << "] complete[" << complete << "] static[" << static_image 33 << "] complete[" << complete << "] static[" << static_image
34 << "], fits_size_constraints[" << fits_size_constraints << "], size[" 34 << "], fits_size_constraints[" << fits_size_constraints << "], size["
35 << size << "]" 35 << size << "]"
36 << " is_multipart[" << is_multipart << "]"; 36 << " is_multipart[" << is_multipart << "]";
37 return str.str(); 37 return str.str();
38 } 38 }
39 39
40 } // namespace 40 } // namespace
41 41
42 // static
43 const int CheckerImageTracker::kNoDecodeAllowedPriority = -1;
44
45 CheckerImageTracker::ImageDecodeRequest::ImageDecodeRequest(
46 PaintImage paint_image,
47 DecodeType type)
48 : paint_image(std::move(paint_image)), type(type) {}
49
42 CheckerImageTracker::CheckerImageTracker(ImageController* image_controller, 50 CheckerImageTracker::CheckerImageTracker(ImageController* image_controller,
43 CheckerImageTrackerClient* client, 51 CheckerImageTrackerClient* client,
44 bool enable_checker_imaging) 52 bool enable_checker_imaging)
45 : image_controller_(image_controller), 53 : image_controller_(image_controller),
46 client_(client), 54 client_(client),
47 enable_checker_imaging_(enable_checker_imaging), 55 enable_checker_imaging_(enable_checker_imaging),
48 weak_factory_(this) {} 56 weak_factory_(this) {}
49 57
50 CheckerImageTracker::~CheckerImageTracker() = default; 58 CheckerImageTracker::~CheckerImageTracker() = default;
51 59
60 void CheckerImageTracker::SetNoDecodesAllowed() {
61 decode_priority_allowed_ = kNoDecodeAllowedPriority;
62 }
63
64 void CheckerImageTracker::SetMaxDecodePriorityAllowed(DecodeType decode_type) {
65 DCHECK_GT(decode_type, kNoDecodeAllowedPriority);
66 DCHECK_GE(decode_type, decode_priority_allowed_);
67 DCHECK_LE(decode_type, DecodeType::kLast);
68
69 if (decode_priority_allowed_ == decode_type)
70 return;
71 decode_priority_allowed_ = decode_type;
72
73 // This will start the next decode if applicable.
74 ScheduleNextImageDecode();
75 }
76
52 void CheckerImageTracker::ScheduleImageDecodeQueue( 77 void CheckerImageTracker::ScheduleImageDecodeQueue(
53 ImageDecodeQueue image_decode_queue) { 78 ImageDecodeQueue image_decode_queue) {
54 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 79 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
55 "CheckerImageTracker::ScheduleImageDecodeQueue"); 80 "CheckerImageTracker::ScheduleImageDecodeQueue");
56 // Only checker-imaged (async updated) images are decoded using the image 81 // Only checker-imaged (async updated) images are decoded using the image
57 // decode service. If |enable_checker_imaging_| is false, no image should 82 // decode service. If |enable_checker_imaging_| is false, no image should
58 // be checkered. 83 // be checkered.
59 DCHECK(image_decode_queue.empty() || enable_checker_imaging_); 84 DCHECK(image_decode_queue.empty() || enable_checker_imaging_);
60 85
86 #if DCHECK_IS_ON()
87 // The decodes in the queue should be prioritized correctly.
88 DecodeType type = DecodeType::kRaster;
89 for (const auto& image_request : image_decode_queue) {
90 DCHECK_GE(image_request.type, type);
91 type = image_request.type;
92 }
93 #endif
94
61 image_decode_queue_ = std::move(image_decode_queue); 95 image_decode_queue_ = std::move(image_decode_queue);
62 ScheduleNextImageDecode(); 96 ScheduleNextImageDecode();
63 } 97 }
64 98
65 const PaintImageIdFlatSet& 99 const PaintImageIdFlatSet&
66 CheckerImageTracker::TakeImagesToInvalidateOnSyncTree() { 100 CheckerImageTracker::TakeImagesToInvalidateOnSyncTree() {
67 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 101 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
68 "CheckerImageTracker::TakeImagesToInvalidateOnSyncTree"); 102 "CheckerImageTracker::TakeImagesToInvalidateOnSyncTree");
69 DCHECK_EQ(invalidated_images_on_current_sync_tree_.size(), 0u) 103 DCHECK_EQ(invalidated_images_on_current_sync_tree_.size(), 0u)
70 << "Sync tree can not be invalidated more than once"; 104 << "Sync tree can not be invalidated more than once";
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 277 }
244 278
245 void CheckerImageTracker::ScheduleNextImageDecode() { 279 void CheckerImageTracker::ScheduleNextImageDecode() {
246 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 280 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
247 "CheckerImageTracker::ScheduleNextImageDecode"); 281 "CheckerImageTracker::ScheduleNextImageDecode");
248 // We can have only one outstanding decode pending completion with the decode 282 // We can have only one outstanding decode pending completion with the decode
249 // service. We'll come back here when it is completed. 283 // service. We'll come back here when it is completed.
250 if (outstanding_image_decode_.has_value()) 284 if (outstanding_image_decode_.has_value())
251 return; 285 return;
252 286
287 if (image_decode_queue_.empty())
288 return;
289
290 // If scheduling decodes for this priority is not allowed right now, don't
291 // schedule them. We will come back here when the allowed priority changes.
292 if (image_decode_queue_.front().type > decode_priority_allowed_)
293 return;
294
253 DrawImage draw_image; 295 DrawImage draw_image;
254 while (!image_decode_queue_.empty()) { 296 while (!image_decode_queue_.empty()) {
255 auto candidate = std::move(image_decode_queue_.front()); 297 auto candidate = std::move(image_decode_queue_.front().paint_image);
256 image_decode_queue_.erase(image_decode_queue_.begin()); 298 image_decode_queue_.erase(image_decode_queue_.begin());
257 299
258 // Once an image has been decoded, it can still be present in the decode 300 // Once an image has been decoded, it can still be present in the decode
259 // queue (duplicate entries), or while an image is still being skipped on 301 // queue (duplicate entries), or while an image is still being skipped on
260 // the active tree. Check if the image is still ASYNC to see if a decode is 302 // the active tree. Check if the image is still ASYNC to see if a decode is
261 // needed. 303 // needed.
262 PaintImage::Id image_id = candidate.stable_id(); 304 PaintImage::Id image_id = candidate.stable_id();
263 auto it = image_async_decode_state_.find(image_id); 305 auto it = image_async_decode_state_.find(image_id);
264 DCHECK(it != image_async_decode_state_.end()); 306 DCHECK(it != image_async_decode_state_.end());
265 if (it->second.policy != DecodePolicy::ASYNC) 307 if (it->second.policy != DecodePolicy::ASYNC)
(...skipping 22 matching lines...) Expand all
288 ImageController::ImageDecodeRequestId request_id = 330 ImageController::ImageDecodeRequestId request_id =
289 image_controller_->QueueImageDecode( 331 image_controller_->QueueImageDecode(
290 draw_image, base::Bind(&CheckerImageTracker::DidFinishImageDecode, 332 draw_image, base::Bind(&CheckerImageTracker::DidFinishImageDecode,
291 weak_factory_.GetWeakPtr(), image_id)); 333 weak_factory_.GetWeakPtr(), image_id));
292 334
293 image_id_to_decode_.emplace(image_id, base::MakeUnique<ScopedDecodeHolder>( 335 image_id_to_decode_.emplace(image_id, base::MakeUnique<ScopedDecodeHolder>(
294 image_controller_, request_id)); 336 image_controller_, request_id));
295 } 337 }
296 338
297 } // namespace cc 339 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/checker_image_tracker.h ('k') | cc/tiles/checker_image_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698