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/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "cc/debug/devtools_instrumentation.h" | 10 #include "cc/debug/devtools_instrumentation.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 void RunOnOriginThread() const { | 312 void RunOnOriginThread() const { |
313 on_raster_finished_callback_.Run(this); | 313 on_raster_finished_callback_.Run(this); |
314 } | 314 } |
315 | 315 |
316 scoped_refptr<base::MessageLoopProxy> origin_loop_; | 316 scoped_refptr<base::MessageLoopProxy> origin_loop_; |
317 const Callback on_raster_finished_callback_; | 317 const Callback on_raster_finished_callback_; |
318 | 318 |
319 DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl); | 319 DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl); |
320 }; | 320 }; |
321 | 321 |
322 const char* kWorkerThreadNamePrefix = "CompositorRaster"; | 322 const int kDefaultNumRasterThreads = 1; |
| 323 |
| 324 int g_num_raster_threads = 0; |
323 | 325 |
324 } // namespace | 326 } // namespace |
325 | 327 |
326 namespace internal { | 328 namespace internal { |
327 | 329 |
328 RasterWorkerPoolTask::RasterWorkerPoolTask( | 330 RasterWorkerPoolTask::RasterWorkerPoolTask( |
329 const Resource* resource, TaskVector* dependencies) | 331 const Resource* resource, TaskVector* dependencies) |
330 : did_run_(false), | 332 : did_run_(false), |
331 did_complete_(false), | 333 did_complete_(false), |
332 was_canceled_(false), | 334 was_canceled_(false), |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 skia::LazyPixelRef* pixel_ref, | 456 skia::LazyPixelRef* pixel_ref, |
455 int layer_id, | 457 int layer_id, |
456 RenderingStatsInstrumentation* stats_instrumentation, | 458 RenderingStatsInstrumentation* stats_instrumentation, |
457 const Task::Reply& reply) { | 459 const Task::Reply& reply) { |
458 return Task(new ImageDecodeWorkerPoolTaskImpl(pixel_ref, | 460 return Task(new ImageDecodeWorkerPoolTaskImpl(pixel_ref, |
459 layer_id, | 461 layer_id, |
460 stats_instrumentation, | 462 stats_instrumentation, |
461 reply)); | 463 reply)); |
462 } | 464 } |
463 | 465 |
464 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider, | 466 // static |
465 size_t num_threads) | 467 void RasterWorkerPool::SetNumRasterThreads(int num_threads) { |
466 : WorkerPool(num_threads, kWorkerThreadNamePrefix), | 468 DCHECK_LT(0, num_threads); |
467 client_(NULL), | 469 DCHECK_EQ(0, g_num_raster_threads); |
| 470 |
| 471 g_num_raster_threads = num_threads; |
| 472 } |
| 473 |
| 474 // static |
| 475 int WorkerPool::GetNumRasterThreads() { |
| 476 if (!g_num_raster_threads) |
| 477 g_num_raster_threads = kDefaultNumRasterThreads; |
| 478 |
| 479 return g_num_raster_threads; |
| 480 } |
| 481 |
| 482 RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider) |
| 483 : client_(NULL), |
468 resource_provider_(resource_provider), | 484 resource_provider_(resource_provider), |
469 weak_ptr_factory_(this) { | 485 weak_ptr_factory_(this) { |
470 } | 486 } |
471 | 487 |
472 RasterWorkerPool::~RasterWorkerPool() { | 488 RasterWorkerPool::~RasterWorkerPool() { |
473 } | 489 } |
474 | 490 |
475 void RasterWorkerPool::SetClient(RasterWorkerPoolClient* client) { | 491 void RasterWorkerPool::SetClient(RasterWorkerPoolClient* client) { |
476 client_ = client; | 492 client_ = client; |
477 } | 493 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 | 603 |
588 internal::GraphNode* decode_node = CreateGraphNodeForTask( | 604 internal::GraphNode* decode_node = CreateGraphNodeForTask( |
589 decode_task, priority, graph); | 605 decode_task, priority, graph); |
590 decode_node->add_dependent(raster_node); | 606 decode_node->add_dependent(raster_node); |
591 } | 607 } |
592 | 608 |
593 return raster_node; | 609 return raster_node; |
594 } | 610 } |
595 | 611 |
596 } // namespace cc | 612 } // namespace cc |
OLD | NEW |