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

Side by Side Diff: cc/resources/raster_worker_pool.cc

Issue 83183005: Add synthetic delay points for latency testing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clarify effects of race condition. Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/trees/thread_proxy.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/resources/raster_worker_pool.h" 5 #include "cc/resources/raster_worker_pool.h"
6 6
7 #include "base/debug/trace_event_synthetic_delay.h"
7 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
8 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "cc/debug/devtools_instrumentation.h" 11 #include "cc/debug/devtools_instrumentation.h"
11 #include "cc/debug/traced_value.h" 12 #include "cc/debug/traced_value.h"
12 #include "cc/resources/picture_pile_impl.h" 13 #include "cc/resources/picture_pile_impl.h"
13 #include "skia/ext/lazy_pixel_ref.h" 14 #include "skia/ext/lazy_pixel_ref.h"
14 #include "skia/ext/paint_simplifier.h" 15 #include "skia/ext/paint_simplifier.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
16 17
17 namespace cc { 18 namespace cc {
18 19
19 namespace { 20 namespace {
20 21
22 // Synthetic delay for raster tasks that are required for activation. Global to
23 // avoid static initializer on critical path.
24 base::debug::TraceEventSyntheticDelay* g_raster_required_for_activation_delay;
25
21 // Subclass of Allocator that takes a suitably allocated pointer and uses 26 // Subclass of Allocator that takes a suitably allocated pointer and uses
22 // it as the pixel memory for the bitmap. 27 // it as the pixel memory for the bitmap.
23 class IdentityAllocator : public SkBitmap::Allocator { 28 class IdentityAllocator : public SkBitmap::Allocator {
24 public: 29 public:
25 explicit IdentityAllocator(void* buffer) : buffer_(buffer) {} 30 explicit IdentityAllocator(void* buffer) : buffer_(buffer) {}
26 virtual bool allocPixelRef(SkBitmap* dst, SkColorTable*) OVERRIDE { 31 virtual bool allocPixelRef(SkBitmap* dst, SkColorTable*) OVERRIDE {
27 dst->setPixels(buffer_); 32 dst->setPixels(buffer_);
28 return true; 33 return true;
29 } 34 }
30 private: 35 private:
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 rendering_stats_->impl_thread_rendering_stats().rasterize_time; 189 rendering_stats_->impl_thread_rendering_stats().rasterize_time;
185 HISTOGRAM_CUSTOM_COUNTS( 190 HISTOGRAM_CUSTOM_COUNTS(
186 "Renderer4.PictureRasterTimeUS", 191 "Renderer4.PictureRasterTimeUS",
187 (current_rasterize_time - prev_rasterize_time).InMicroseconds(), 192 (current_rasterize_time - prev_rasterize_time).InMicroseconds(),
188 0, 193 0,
189 100000, 194 100000,
190 100); 195 100);
191 } 196 }
192 197
193 ChangeBitmapConfigIfNeeded(bitmap, buffer); 198 ChangeBitmapConfigIfNeeded(bitmap, buffer);
199 g_raster_required_for_activation_delay->End();
194 200
195 return true; 201 return true;
196 } 202 }
197 203
198 // Overridden from internal::RasterWorkerPoolTask: 204 // Overridden from internal::RasterWorkerPoolTask:
199 virtual bool RunOnWorkerThread(unsigned thread_index, 205 virtual bool RunOnWorkerThread(unsigned thread_index,
200 void* buffer, 206 void* buffer,
201 gfx::Size size, 207 gfx::Size size,
202 int stride) 208 int stride)
203 OVERRIDE { 209 OVERRIDE {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 stats_instrumentation, 465 stats_instrumentation,
460 reply)); 466 reply));
461 } 467 }
462 468
463 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider, 469 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider,
464 size_t num_threads) 470 size_t num_threads)
465 : WorkerPool(num_threads, kWorkerThreadNamePrefix), 471 : WorkerPool(num_threads, kWorkerThreadNamePrefix),
466 client_(NULL), 472 client_(NULL),
467 resource_provider_(resource_provider), 473 resource_provider_(resource_provider),
468 weak_ptr_factory_(this) { 474 weak_ptr_factory_(this) {
475 g_raster_required_for_activation_delay =
476 base::debug::TraceEventSyntheticDelay::Lookup(
477 "cc.RasterRequiredForActivation");
reveman 2013/12/12 19:29:43 what if this is done on two threads at the same ti
469 } 478 }
470 479
471 RasterWorkerPool::~RasterWorkerPool() { 480 RasterWorkerPool::~RasterWorkerPool() {
472 } 481 }
473 482
474 void RasterWorkerPool::SetClient(RasterWorkerPoolClient* client) { 483 void RasterWorkerPool::SetClient(RasterWorkerPoolClient* client) {
475 client_ = client; 484 client_ = client;
476 } 485 }
477 486
478 void RasterWorkerPool::Shutdown() { 487 void RasterWorkerPool::Shutdown() {
479 raster_tasks_.clear(); 488 raster_tasks_.clear();
480 TaskGraph empty; 489 TaskGraph empty;
481 SetTaskGraph(&empty); 490 SetTaskGraph(&empty);
482 WorkerPool::Shutdown(); 491 WorkerPool::Shutdown();
483 weak_ptr_factory_.InvalidateWeakPtrs(); 492 weak_ptr_factory_.InvalidateWeakPtrs();
484 } 493 }
485 494
486 void RasterWorkerPool::SetRasterTasks(RasterTask::Queue* queue) { 495 void RasterWorkerPool::SetRasterTasks(RasterTask::Queue* queue) {
487 raster_tasks_.swap(queue->tasks_); 496 raster_tasks_.swap(queue->tasks_);
488 raster_tasks_required_for_activation_.swap( 497 raster_tasks_required_for_activation_.swap(
489 queue->tasks_required_for_activation_); 498 queue->tasks_required_for_activation_);
499 // Note: a raster task from the previous task set may call End() even after
500 // this reset. When this happens, the synthetic delay will get activated
501 // early, increasing the total activation delay the length of one raster
502 // task. Because tasks from the old set may still be needed to activate the
503 // new tree, we can't entirely discount them. This is therefore a compromise
504 // to ensure the activation delay is always at least as long as configured.
505 g_raster_required_for_activation_delay->ResetAndBeginMultiple(
506 raster_tasks_required_for_activation_.size());
reveman 2013/12/12 19:29:43 This seems a bit too flaky to me. Could we do this
490 } 507 }
491 508
492 bool RasterWorkerPool::IsRasterTaskRequiredForActivation( 509 bool RasterWorkerPool::IsRasterTaskRequiredForActivation(
493 internal::RasterWorkerPoolTask* task) const { 510 internal::RasterWorkerPoolTask* task) const {
494 return 511 return
495 raster_tasks_required_for_activation_.find(task) != 512 raster_tasks_required_for_activation_.find(task) !=
496 raster_tasks_required_for_activation_.end(); 513 raster_tasks_required_for_activation_.end();
497 } 514 }
498 515
499 scoped_refptr<internal::WorkerPoolTask> 516 scoped_refptr<internal::WorkerPoolTask>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 603
587 internal::GraphNode* decode_node = CreateGraphNodeForTask( 604 internal::GraphNode* decode_node = CreateGraphNodeForTask(
588 decode_task, priority, graph); 605 decode_task, priority, graph);
589 decode_node->add_dependent(raster_node); 606 decode_node->add_dependent(raster_node);
590 } 607 }
591 608
592 return raster_node; 609 return raster_node;
593 } 610 }
594 611
595 } // namespace cc 612 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/trees/thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698