Index: cc/resources/raster_worker_pool.cc |
diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc |
old mode 100644 |
new mode 100755 |
index 06fd18e62e0ec2bdc9d440ee0ae6eb925c867ef4..bee164b028c1bfae08476350687e08bf0b757b56 |
--- a/cc/resources/raster_worker_pool.cc |
+++ b/cc/resources/raster_worker_pool.cc |
@@ -4,9 +4,12 @@ |
#include "cc/resources/raster_worker_pool.h" |
+#include "base/command_line.h" |
#include "base/json/json_writer.h" |
#include "base/metrics/histogram.h" |
#include "base/values.h" |
+#include "base/strings/string_number_conversions.h" |
+#include "cc/base/switches.h" |
#include "cc/debug/devtools_instrumentation.h" |
#include "cc/debug/traced_value.h" |
#include "cc/resources/picture_pile_impl.h" |
@@ -16,6 +19,10 @@ |
namespace cc { |
+const int kMinRasterThreads = 1; |
+const int kMaxRasterThreads = 64; |
+const int kDefaultNumRasterThreads = 1; |
+ |
namespace { |
// Subclass of Allocator that takes a suitably allocated pointer and uses |
@@ -319,7 +326,6 @@ class RasterFinishedWorkerPoolTaskImpl : public internal::WorkerPoolTask { |
DISALLOW_COPY_AND_ASSIGN(RasterFinishedWorkerPoolTaskImpl); |
}; |
-const char* kWorkerThreadNamePrefix = "CompositorRaster"; |
} // namespace |
@@ -461,10 +467,31 @@ RasterWorkerPool::Task RasterWorkerPool::CreateImageDecodeTask( |
reply)); |
} |
-RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider, |
- size_t num_threads) |
- : WorkerPool(num_threads, kWorkerThreadNamePrefix), |
- client_(NULL), |
+// static |
+int RasterWorkerPool::num_raster_threads_ = kDefaultNumRasterThreads; |
reveman
2014/01/06 07:13:12
move this to anonymous namespace above.
sohanjg
2014/01/06 09:57:29
Done.
|
+void RasterWorkerPool::SetNumRasterThreads() { |
reveman
2014/01/06 07:13:12
the logic below should not be here. the idea is to
sohanjg
2014/01/06 09:57:29
Done.
|
+ RasterWorkerPool::num_raster_threads_ = kDefaultNumRasterThreads; |
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
+ if (command_line.HasSwitch(switches::kNumRasterThreads)) { |
+ std::string string_value = |
+ command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
+ int num_threads; |
+ if (base::StringToInt(string_value, &num_threads) && |
+ num_threads >= kMinRasterThreads && num_threads <= kMaxRasterThreads) |
+ RasterWorkerPool::num_raster_threads_ = num_threads; |
+ |
+ LOG(WARNING) << "Failed to parse switch " << |
+ switches::kNumRasterThreads << ": " << string_value; |
+ } |
+} |
+ |
+// static |
+int RasterWorkerPool::GetNumRasterThreads() { |
+ return RasterWorkerPool::num_raster_threads_; |
+} |
+ |
+RasterWorkerPool::RasterWorkerPool(ResourceProvider* resource_provider) |
+ : client_(NULL), |
resource_provider_(resource_provider), |
weak_ptr_factory_(this) { |
} |