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

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

Issue 73923003: Shared Raster Worker Threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase for Commit Created 6 years, 11 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
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/debug/trace_event_synthetic_delay.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 void RunOnOriginThread() const { 366 void RunOnOriginThread() const {
367 on_raster_finished_callback_.Run(this); 367 on_raster_finished_callback_.Run(this);
368 } 368 }
369 369
370 scoped_refptr<base::MessageLoopProxy> origin_loop_; 370 scoped_refptr<base::MessageLoopProxy> origin_loop_;
371 const Callback on_raster_finished_callback_; 371 const Callback on_raster_finished_callback_;
372 372
373 DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl); 373 DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl);
374 }; 374 };
375 375
376 const int kDefaultNumRasterThreads = 1;
377
378 int g_num_raster_threads = 0;
379
376 class RasterRequiredForActivationFinishedWorkerPoolTaskImpl 380 class RasterRequiredForActivationFinishedWorkerPoolTaskImpl
377 : public RasterFinishedWorkerPoolTaskImpl { 381 : public RasterFinishedWorkerPoolTaskImpl {
378 public: 382 public:
379 RasterRequiredForActivationFinishedWorkerPoolTaskImpl( 383 RasterRequiredForActivationFinishedWorkerPoolTaskImpl(
380 const Callback& on_raster_finished_callback, 384 const Callback& on_raster_finished_callback,
381 size_t tasks_required_for_activation_count) 385 size_t tasks_required_for_activation_count)
382 : RasterFinishedWorkerPoolTaskImpl(on_raster_finished_callback), 386 : RasterFinishedWorkerPoolTaskImpl(on_raster_finished_callback),
383 tasks_required_for_activation_count_( 387 tasks_required_for_activation_count_(
384 tasks_required_for_activation_count) { 388 tasks_required_for_activation_count) {
385 if (tasks_required_for_activation_count_) { 389 if (tasks_required_for_activation_count_) {
(...skipping 17 matching lines...) Expand all
403 private: 407 private:
404 virtual ~RasterRequiredForActivationFinishedWorkerPoolTaskImpl() {} 408 virtual ~RasterRequiredForActivationFinishedWorkerPoolTaskImpl() {}
405 409
406 base::TimeTicks activation_delay_end_time_; 410 base::TimeTicks activation_delay_end_time_;
407 const size_t tasks_required_for_activation_count_; 411 const size_t tasks_required_for_activation_count_;
408 412
409 DISALLOW_COPY_AND_ASSIGN( 413 DISALLOW_COPY_AND_ASSIGN(
410 RasterRequiredForActivationFinishedWorkerPoolTaskImpl); 414 RasterRequiredForActivationFinishedWorkerPoolTaskImpl);
411 }; 415 };
412 416
413 const char* kWorkerThreadNamePrefix = "CompositorRaster";
414 417
415 } // namespace 418 } // namespace
416 419
417 namespace internal { 420 namespace internal {
418 421
419 RasterWorkerPoolTask::RasterWorkerPoolTask(const Resource* resource, 422 RasterWorkerPoolTask::RasterWorkerPoolTask(const Resource* resource,
420 TaskVector* dependencies, 423 TaskVector* dependencies,
421 bool use_gpu_rasterization) 424 bool use_gpu_rasterization)
422 : did_run_(false), 425 : did_run_(false),
423 did_complete_(false), 426 did_complete_(false),
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 SkPixelRef* pixel_ref, 552 SkPixelRef* pixel_ref,
550 int layer_id, 553 int layer_id,
551 RenderingStatsInstrumentation* stats_instrumentation, 554 RenderingStatsInstrumentation* stats_instrumentation,
552 const Task::Reply& reply) { 555 const Task::Reply& reply) {
553 return Task(new ImageDecodeWorkerPoolTaskImpl(pixel_ref, 556 return Task(new ImageDecodeWorkerPoolTaskImpl(pixel_ref,
554 layer_id, 557 layer_id,
555 stats_instrumentation, 558 stats_instrumentation,
556 reply)); 559 reply));
557 } 560 }
558 561
562 // static
563 void RasterWorkerPool::SetNumRasterThreads(int num_threads) {
564 DCHECK_LT(0, num_threads);
565 DCHECK_EQ(0, g_num_raster_threads);
566
567 g_num_raster_threads = num_threads;
568 }
569
570 // static
571 int WorkerPool::GetNumRasterThreads() {
572 if (!g_num_raster_threads)
573 g_num_raster_threads = kDefaultNumRasterThreads;
574
575 return g_num_raster_threads;
576 }
577
559 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider, 578 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider,
560 ContextProvider* context_provider, 579 ContextProvider* context_provider)
561 size_t num_threads) 580 : client_(NULL),
562 : WorkerPool(num_threads, kWorkerThreadNamePrefix),
563 client_(NULL),
564 resource_provider_(resource_provider), 581 resource_provider_(resource_provider),
565 context_provider_(context_provider), 582 context_provider_(context_provider),
566 weak_ptr_factory_(this) { 583 weak_ptr_factory_(this) {
567 } 584 }
568 585
569 RasterWorkerPool::~RasterWorkerPool() { 586 RasterWorkerPool::~RasterWorkerPool() {
570 } 587 }
571 588
572 void RasterWorkerPool::SetClient(RasterWorkerPoolClient* client) { 589 void RasterWorkerPool::SetClient(RasterWorkerPoolClient* client) {
573 client_ = client; 590 client_ = client;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 747
731 internal::GraphNode* decode_node = CreateGraphNodeForTask( 748 internal::GraphNode* decode_node = CreateGraphNodeForTask(
732 decode_task, priority, graph); 749 decode_task, priority, graph);
733 decode_node->add_dependent(raster_node); 750 decode_node->add_dependent(raster_node);
734 } 751 }
735 752
736 return raster_node; 753 return raster_node;
737 } 754 }
738 755
739 } // namespace cc 756 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698