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/paint_simplifier.h" | 14 #include "skia/ext/paint_simplifier.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
15 #include "third_party/skia/include/core/SkPixelRef.h" | 16 #include "third_party/skia/include/core/SkPixelRef.h" |
16 #include "third_party/skia/include/gpu/GrContext.h" | 17 #include "third_party/skia/include/gpu/GrContext.h" |
(...skipping 14 matching lines...) Expand all Loading... |
31 return true; | 32 return true; |
32 } | 33 } |
33 private: | 34 private: |
34 void* buffer_; | 35 void* buffer_; |
35 }; | 36 }; |
36 | 37 |
37 // Flag to indicate whether we should try and detect that | 38 // Flag to indicate whether we should try and detect that |
38 // a tile is of solid color. | 39 // a tile is of solid color. |
39 const bool kUseColorEstimator = true; | 40 const bool kUseColorEstimator = true; |
40 | 41 |
| 42 // Synthetic delay for raster tasks that are required for activation. Global to |
| 43 // avoid static initializer on critical path. |
| 44 struct RasterRequiredForActivationSyntheticDelayInitializer { |
| 45 RasterRequiredForActivationSyntheticDelayInitializer() |
| 46 : delay(base::debug::TraceEventSyntheticDelay::Lookup( |
| 47 "cc.RasterRequiredForActivation")) {} |
| 48 base::debug::TraceEventSyntheticDelay* delay; |
| 49 }; |
| 50 static base::LazyInstance<RasterRequiredForActivationSyntheticDelayInitializer> |
| 51 g_raster_required_for_activation_delay = LAZY_INSTANCE_INITIALIZER; |
| 52 |
41 class DisableLCDTextFilter : public SkDrawFilter { | 53 class DisableLCDTextFilter : public SkDrawFilter { |
42 public: | 54 public: |
43 // SkDrawFilter interface. | 55 // SkDrawFilter interface. |
44 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { | 56 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { |
45 if (type != SkDrawFilter::kText_Type) | 57 if (type != SkDrawFilter::kText_Type) |
46 return true; | 58 return true; |
47 | 59 |
48 paint->setLCDRenderText(false); | 60 paint->setLCDRenderText(false); |
49 return true; | 61 return true; |
50 } | 62 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // Overridden from internal::WorkerPoolTask: | 353 // Overridden from internal::WorkerPoolTask: |
342 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { | 354 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { |
343 TRACE_EVENT0("cc", "RasterFinishedWorkerPoolTaskImpl::RunOnWorkerThread"); | 355 TRACE_EVENT0("cc", "RasterFinishedWorkerPoolTaskImpl::RunOnWorkerThread"); |
344 origin_loop_->PostTask( | 356 origin_loop_->PostTask( |
345 FROM_HERE, | 357 FROM_HERE, |
346 base::Bind(&RasterFinishedWorkerPoolTaskImpl::RunOnOriginThread, | 358 base::Bind(&RasterFinishedWorkerPoolTaskImpl::RunOnOriginThread, |
347 this)); | 359 this)); |
348 } | 360 } |
349 virtual void CompleteOnOriginThread() OVERRIDE {} | 361 virtual void CompleteOnOriginThread() OVERRIDE {} |
350 | 362 |
351 private: | 363 protected: |
352 virtual ~RasterFinishedWorkerPoolTaskImpl() {} | 364 virtual ~RasterFinishedWorkerPoolTaskImpl() {} |
353 | 365 |
| 366 private: |
354 void RunOnOriginThread() const { | 367 void RunOnOriginThread() const { |
355 on_raster_finished_callback_.Run(this); | 368 on_raster_finished_callback_.Run(this); |
356 } | 369 } |
357 | 370 |
358 scoped_refptr<base::MessageLoopProxy> origin_loop_; | 371 scoped_refptr<base::MessageLoopProxy> origin_loop_; |
359 const Callback on_raster_finished_callback_; | 372 const Callback on_raster_finished_callback_; |
360 | 373 |
361 DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl); | 374 DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl); |
362 }; | 375 }; |
363 | 376 |
| 377 class RasterRequiredForActivationFinishedWorkerPoolTaskImpl |
| 378 : public RasterFinishedWorkerPoolTaskImpl { |
| 379 public: |
| 380 RasterRequiredForActivationFinishedWorkerPoolTaskImpl( |
| 381 const Callback& on_raster_finished_callback, |
| 382 size_t tasks_required_for_activation_count) |
| 383 : RasterFinishedWorkerPoolTaskImpl(on_raster_finished_callback), |
| 384 tasks_required_for_activation_count_( |
| 385 tasks_required_for_activation_count) { |
| 386 if (tasks_required_for_activation_count_) { |
| 387 g_raster_required_for_activation_delay.Get().delay->BeginParallel( |
| 388 &activation_delay_end_time_); |
| 389 } |
| 390 } |
| 391 |
| 392 // Overridden from RasterFinishedWorkerPoolTaskImpl: |
| 393 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { |
| 394 TRACE_EVENT0("cc", |
| 395 "RasterRequiredForActivationFinishedWorkerPoolTaskImpl::" |
| 396 "RunOnWorkerThread"); |
| 397 if (tasks_required_for_activation_count_) { |
| 398 g_raster_required_for_activation_delay.Get().delay->EndParallel( |
| 399 activation_delay_end_time_); |
| 400 } |
| 401 RasterFinishedWorkerPoolTaskImpl::RunOnWorkerThread(thread_index); |
| 402 } |
| 403 |
| 404 private: |
| 405 virtual ~RasterRequiredForActivationFinishedWorkerPoolTaskImpl() {} |
| 406 |
| 407 base::TimeTicks activation_delay_end_time_; |
| 408 const size_t tasks_required_for_activation_count_; |
| 409 |
| 410 DISALLOW_COPY_AND_ASSIGN( |
| 411 RasterRequiredForActivationFinishedWorkerPoolTaskImpl); |
| 412 }; |
| 413 |
364 const char* kWorkerThreadNamePrefix = "CompositorRaster"; | 414 const char* kWorkerThreadNamePrefix = "CompositorRaster"; |
365 | 415 |
366 } // namespace | 416 } // namespace |
367 | 417 |
368 namespace internal { | 418 namespace internal { |
369 | 419 |
370 RasterWorkerPoolTask::RasterWorkerPoolTask(const Resource* resource, | 420 RasterWorkerPoolTask::RasterWorkerPoolTask(const Resource* resource, |
371 TaskVector* dependencies, | 421 TaskVector* dependencies, |
372 bool use_gpu_rasterization) | 422 bool use_gpu_rasterization) |
373 : did_run_(false), | 423 : did_run_(false), |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 641 |
592 scoped_refptr<internal::WorkerPoolTask> | 642 scoped_refptr<internal::WorkerPoolTask> |
593 RasterWorkerPool::CreateRasterFinishedTask() { | 643 RasterWorkerPool::CreateRasterFinishedTask() { |
594 return make_scoped_refptr( | 644 return make_scoped_refptr( |
595 new RasterFinishedWorkerPoolTaskImpl( | 645 new RasterFinishedWorkerPoolTaskImpl( |
596 base::Bind(&RasterWorkerPool::OnRasterFinished, | 646 base::Bind(&RasterWorkerPool::OnRasterFinished, |
597 weak_ptr_factory_.GetWeakPtr()))); | 647 weak_ptr_factory_.GetWeakPtr()))); |
598 } | 648 } |
599 | 649 |
600 scoped_refptr<internal::WorkerPoolTask> | 650 scoped_refptr<internal::WorkerPoolTask> |
601 RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask() { | 651 RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask( |
| 652 size_t tasks_required_for_activation_count) { |
602 return make_scoped_refptr( | 653 return make_scoped_refptr( |
603 new RasterFinishedWorkerPoolTaskImpl( | 654 new RasterRequiredForActivationFinishedWorkerPoolTaskImpl( |
604 base::Bind(&RasterWorkerPool::OnRasterRequiredForActivationFinished, | 655 base::Bind(&RasterWorkerPool::OnRasterRequiredForActivationFinished, |
605 weak_ptr_factory_.GetWeakPtr()))); | 656 weak_ptr_factory_.GetWeakPtr()), |
| 657 tasks_required_for_activation_count)); |
606 } | 658 } |
607 | 659 |
608 void RasterWorkerPool::OnRasterFinished( | 660 void RasterWorkerPool::OnRasterFinished( |
609 const internal::WorkerPoolTask* source) { | 661 const internal::WorkerPoolTask* source) { |
610 TRACE_EVENT0("cc", "RasterWorkerPool::OnRasterFinished"); | 662 TRACE_EVENT0("cc", "RasterWorkerPool::OnRasterFinished"); |
611 | 663 |
612 // Early out if current |raster_finished_task_| is not the source. | 664 // Early out if current |raster_finished_task_| is not the source. |
613 if (source != raster_finished_task_.get()) | 665 if (source != raster_finished_task_.get()) |
614 return; | 666 return; |
615 | 667 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 | 731 |
680 internal::GraphNode* decode_node = CreateGraphNodeForTask( | 732 internal::GraphNode* decode_node = CreateGraphNodeForTask( |
681 decode_task, priority, graph); | 733 decode_task, priority, graph); |
682 decode_node->add_dependent(raster_node); | 734 decode_node->add_dependent(raster_node); |
683 } | 735 } |
684 | 736 |
685 return raster_node; | 737 return raster_node; |
686 } | 738 } |
687 | 739 |
688 } // namespace cc | 740 } // namespace cc |
OLD | NEW |