OLD | NEW |
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 Loading... |
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 Loading... |
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"); |
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 if (!raster_tasks_required_for_activation_.empty()) { |
| 500 g_raster_required_for_activation_delay->ResetAndBeginMultiple( |
| 501 raster_tasks_required_for_activation_.size()); |
| 502 } |
490 } | 503 } |
491 | 504 |
492 bool RasterWorkerPool::IsRasterTaskRequiredForActivation( | 505 bool RasterWorkerPool::IsRasterTaskRequiredForActivation( |
493 internal::RasterWorkerPoolTask* task) const { | 506 internal::RasterWorkerPoolTask* task) const { |
494 return | 507 return |
495 raster_tasks_required_for_activation_.find(task) != | 508 raster_tasks_required_for_activation_.find(task) != |
496 raster_tasks_required_for_activation_.end(); | 509 raster_tasks_required_for_activation_.end(); |
497 } | 510 } |
498 | 511 |
499 scoped_refptr<internal::WorkerPoolTask> | 512 scoped_refptr<internal::WorkerPoolTask> |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 | 599 |
587 internal::GraphNode* decode_node = CreateGraphNodeForTask( | 600 internal::GraphNode* decode_node = CreateGraphNodeForTask( |
588 decode_task, priority, graph); | 601 decode_task, priority, graph); |
589 decode_node->add_dependent(raster_node); | 602 decode_node->add_dependent(raster_node); |
590 } | 603 } |
591 | 604 |
592 return raster_node; | 605 return raster_node; |
593 } | 606 } |
594 | 607 |
595 } // namespace cc | 608 } // namespace cc |
OLD | NEW |