Chromium Code Reviews| 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 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 28 return true; | 29 return true; |
| 29 } | 30 } |
| 30 private: | 31 private: |
| 31 void* buffer_; | 32 void* buffer_; |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 // Flag to indicate whether we should try and detect that | 35 // Flag to indicate whether we should try and detect that |
| 35 // a tile is of solid color. | 36 // a tile is of solid color. |
| 36 const bool kUseColorEstimator = true; | 37 const bool kUseColorEstimator = true; |
| 37 | 38 |
| 39 // Synthetic delay for raster tasks that are required for activation. Global to | |
| 40 // avoid static initializer on critical path. | |
| 41 struct RasterRequiredForActivationSyntheticDelayInitializer { | |
| 42 RasterRequiredForActivationSyntheticDelayInitializer() | |
| 43 : delay(base::debug::TraceEventSyntheticDelay::Lookup( | |
| 44 "cc.RasterRequiredForActivation")) {} | |
| 45 base::debug::TraceEventSyntheticDelay* delay; | |
| 46 }; | |
| 47 static base::LazyInstance<RasterRequiredForActivationSyntheticDelayInitializer> | |
| 48 g_raster_required_for_activation_delay = LAZY_INSTANCE_INITIALIZER; | |
| 49 | |
| 38 class DisableLCDTextFilter : public SkDrawFilter { | 50 class DisableLCDTextFilter : public SkDrawFilter { |
| 39 public: | 51 public: |
| 40 // SkDrawFilter interface. | 52 // SkDrawFilter interface. |
| 41 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { | 53 virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE { |
| 42 if (type != SkDrawFilter::kText_Type) | 54 if (type != SkDrawFilter::kText_Type) |
| 43 return true; | 55 return true; |
| 44 | 56 |
| 45 paint->setLCDRenderText(false); | 57 paint->setLCDRenderText(false); |
| 46 return true; | 58 return true; |
| 47 } | 59 } |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 // Overridden from internal::WorkerPoolTask: | 311 // Overridden from internal::WorkerPoolTask: |
| 300 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { | 312 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { |
| 301 TRACE_EVENT0("cc", "RasterFinishedWorkerPoolTaskImpl::RunOnWorkerThread"); | 313 TRACE_EVENT0("cc", "RasterFinishedWorkerPoolTaskImpl::RunOnWorkerThread"); |
| 302 origin_loop_->PostTask( | 314 origin_loop_->PostTask( |
| 303 FROM_HERE, | 315 FROM_HERE, |
| 304 base::Bind(&RasterFinishedWorkerPoolTaskImpl::RunOnOriginThread, | 316 base::Bind(&RasterFinishedWorkerPoolTaskImpl::RunOnOriginThread, |
| 305 this)); | 317 this)); |
| 306 } | 318 } |
| 307 virtual void CompleteOnOriginThread() OVERRIDE {} | 319 virtual void CompleteOnOriginThread() OVERRIDE {} |
| 308 | 320 |
| 309 private: | 321 protected: |
| 310 virtual ~RasterFinishedWorkerPoolTaskImpl() {} | 322 virtual ~RasterFinishedWorkerPoolTaskImpl() {} |
| 311 | 323 |
| 324 private: | |
| 312 void RunOnOriginThread() const { | 325 void RunOnOriginThread() const { |
| 313 on_raster_finished_callback_.Run(this); | 326 on_raster_finished_callback_.Run(this); |
| 314 } | 327 } |
| 315 | 328 |
| 316 scoped_refptr<base::MessageLoopProxy> origin_loop_; | 329 scoped_refptr<base::MessageLoopProxy> origin_loop_; |
| 317 const Callback on_raster_finished_callback_; | 330 const Callback on_raster_finished_callback_; |
| 318 | 331 |
| 319 DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl); | 332 DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl); |
| 320 }; | 333 }; |
| 321 | 334 |
| 335 class RasterRequiredForActivationFinishedWorkerPoolTaskImpl | |
| 336 : public RasterFinishedWorkerPoolTaskImpl { | |
| 337 public: | |
| 338 RasterRequiredForActivationFinishedWorkerPoolTaskImpl( | |
| 339 const Callback& on_raster_finished_callback, | |
| 340 bool has_tasks_required_for_activation) | |
| 341 : RasterFinishedWorkerPoolTaskImpl(on_raster_finished_callback), | |
| 342 has_tasks_required_for_activation_(has_tasks_required_for_activation) { | |
| 343 if (has_tasks_required_for_activation_) { | |
| 344 g_raster_required_for_activation_delay.Get().delay->BeginParallel( | |
| 345 &activation_delay_end_time_); | |
| 346 } | |
| 347 } | |
| 348 | |
| 349 // Overridden from RasterFinishedWorkerPoolTaskImpl | |
|
reveman
2013/12/19 19:02:23
nit: add a ":" at the end of this line
| |
| 350 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { | |
| 351 TRACE_EVENT0("cc", | |
| 352 "RasterRequiredForActivationFinishedWorkerPoolTaskImpl::" | |
| 353 "RunOnWorkerThread"); | |
| 354 if (has_tasks_required_for_activation_) { | |
| 355 g_raster_required_for_activation_delay.Get().delay->EndParallel( | |
| 356 activation_delay_end_time_); | |
| 357 } | |
| 358 RasterFinishedWorkerPoolTaskImpl::RunOnWorkerThread(thread_index); | |
| 359 } | |
| 360 | |
| 361 private: | |
| 362 virtual ~RasterRequiredForActivationFinishedWorkerPoolTaskImpl() {} | |
| 363 | |
| 364 base::TimeTicks activation_delay_end_time_; | |
| 365 const bool has_tasks_required_for_activation_; | |
|
reveman
2013/12/19 19:02:23
nit: "size_t tasks_required_for_activation_count_"
| |
| 366 | |
| 367 DISALLOW_COPY_AND_ASSIGN( | |
| 368 RasterRequiredForActivationFinishedWorkerPoolTaskImpl); | |
| 369 }; | |
| 370 | |
| 322 const char* kWorkerThreadNamePrefix = "CompositorRaster"; | 371 const char* kWorkerThreadNamePrefix = "CompositorRaster"; |
| 323 | 372 |
| 324 } // namespace | 373 } // namespace |
| 325 | 374 |
| 326 namespace internal { | 375 namespace internal { |
| 327 | 376 |
| 328 RasterWorkerPoolTask::RasterWorkerPoolTask( | 377 RasterWorkerPoolTask::RasterWorkerPoolTask( |
| 329 const Resource* resource, TaskVector* dependencies) | 378 const Resource* resource, TaskVector* dependencies) |
| 330 : did_run_(false), | 379 : did_run_(false), |
| 331 did_complete_(false), | 380 did_complete_(false), |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 | 548 |
| 500 scoped_refptr<internal::WorkerPoolTask> | 549 scoped_refptr<internal::WorkerPoolTask> |
| 501 RasterWorkerPool::CreateRasterFinishedTask() { | 550 RasterWorkerPool::CreateRasterFinishedTask() { |
| 502 return make_scoped_refptr( | 551 return make_scoped_refptr( |
| 503 new RasterFinishedWorkerPoolTaskImpl( | 552 new RasterFinishedWorkerPoolTaskImpl( |
| 504 base::Bind(&RasterWorkerPool::OnRasterFinished, | 553 base::Bind(&RasterWorkerPool::OnRasterFinished, |
| 505 weak_ptr_factory_.GetWeakPtr()))); | 554 weak_ptr_factory_.GetWeakPtr()))); |
| 506 } | 555 } |
| 507 | 556 |
| 508 scoped_refptr<internal::WorkerPoolTask> | 557 scoped_refptr<internal::WorkerPoolTask> |
| 509 RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask() { | 558 RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask( |
| 559 size_t tasks_required_for_activation_count) { | |
| 510 return make_scoped_refptr( | 560 return make_scoped_refptr( |
| 511 new RasterFinishedWorkerPoolTaskImpl( | 561 new RasterRequiredForActivationFinishedWorkerPoolTaskImpl( |
| 512 base::Bind(&RasterWorkerPool::OnRasterRequiredForActivationFinished, | 562 base::Bind(&RasterWorkerPool::OnRasterRequiredForActivationFinished, |
| 513 weak_ptr_factory_.GetWeakPtr()))); | 563 weak_ptr_factory_.GetWeakPtr()), |
| 564 tasks_required_for_activation_count > 0u)); | |
| 514 } | 565 } |
| 515 | 566 |
| 516 void RasterWorkerPool::OnRasterFinished( | 567 void RasterWorkerPool::OnRasterFinished( |
| 517 const internal::WorkerPoolTask* source) { | 568 const internal::WorkerPoolTask* source) { |
| 518 TRACE_EVENT0("cc", "RasterWorkerPool::OnRasterFinished"); | 569 TRACE_EVENT0("cc", "RasterWorkerPool::OnRasterFinished"); |
| 519 | 570 |
| 520 // Early out if current |raster_finished_task_| is not the source. | 571 // Early out if current |raster_finished_task_| is not the source. |
| 521 if (source != raster_finished_task_.get()) | 572 if (source != raster_finished_task_.get()) |
| 522 return; | 573 return; |
| 523 | 574 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 | 638 |
| 588 internal::GraphNode* decode_node = CreateGraphNodeForTask( | 639 internal::GraphNode* decode_node = CreateGraphNodeForTask( |
| 589 decode_task, priority, graph); | 640 decode_task, priority, graph); |
| 590 decode_node->add_dependent(raster_node); | 641 decode_node->add_dependent(raster_node); |
| 591 } | 642 } |
| 592 | 643 |
| 593 return raster_node; | 644 return raster_node; |
| 594 } | 645 } |
| 595 | 646 |
| 596 } // namespace cc | 647 } // namespace cc |
| OLD | NEW |