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

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

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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/tile_task_worker_pool.h" 5 #include "cc/resources/tile_task_worker_pool.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/threading/simple_thread.h" 12 #include "base/threading/simple_thread.h"
13 #include "cc/base/scoped_ptr_deque.h" 13 #include "cc/base/scoped_ptr_deque.h"
14 #include "cc/resources/raster_source.h" 14 #include "cc/resources/raster_source.h"
15 #include "skia/ext/refptr.h" 15 #include "skia/ext/refptr.h"
16 #include "third_party/skia/include/core/SkCanvas.h" 16 #include "third_party/skia/include/core/SkCanvas.h"
17 #include "third_party/skia/include/core/SkSurface.h" 17 #include "third_party/skia/include/core/SkSurface.h"
18 18
19 namespace cc { 19 namespace cc {
20 namespace { 20 namespace {
21 21
22 base::ThreadPriority g_worker_thread_priority = base::kThreadPriority_Normal;
23
22 class TileTaskGraphRunner : public TaskGraphRunner, 24 class TileTaskGraphRunner : public TaskGraphRunner,
23 public base::DelegateSimpleThread::Delegate { 25 public base::DelegateSimpleThread::Delegate {
24 public: 26 public:
25 TileTaskGraphRunner() { 27 TileTaskGraphRunner() {
26 size_t num_threads = TileTaskWorkerPool::GetNumWorkerThreads(); 28 size_t num_threads = TileTaskWorkerPool::GetNumWorkerThreads();
27 while (workers_.size() < num_threads) { 29 while (workers_.size() < num_threads) {
28 scoped_ptr<base::DelegateSimpleThread> worker = 30 scoped_ptr<base::DelegateSimpleThread> worker =
29 make_scoped_ptr(new base::DelegateSimpleThread( 31 make_scoped_ptr(new base::DelegateSimpleThread(
30 this, base::StringPrintf( 32 this, base::StringPrintf(
31 "CompositorTileWorker%u", 33 "CompositorTileWorker%u",
32 static_cast<unsigned>(workers_.size() + 1)).c_str())); 34 static_cast<unsigned>(workers_.size() + 1)).c_str()));
33 worker->Start(); 35 worker->Start();
34 #if defined(OS_ANDROID) || defined(OS_LINUX) 36 worker->SetThreadPriority(g_worker_thread_priority);
35 worker->SetThreadPriority(base::kThreadPriority_Background);
36 #endif
37 workers_.push_back(worker.Pass()); 37 workers_.push_back(worker.Pass());
38 } 38 }
39 } 39 }
40 40
41 ~TileTaskGraphRunner() override { NOTREACHED(); } 41 ~TileTaskGraphRunner() override { NOTREACHED(); }
42 42
43 private: 43 private:
44 // Overridden from base::DelegateSimpleThread::Delegate: 44 // Overridden from base::DelegateSimpleThread::Delegate:
45 void Run() override { TaskGraphRunner::Run(); } 45 void Run() override { TaskGraphRunner::Run(); }
46 46
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 // static 114 // static
115 int TileTaskWorkerPool::GetNumWorkerThreads() { 115 int TileTaskWorkerPool::GetNumWorkerThreads() {
116 if (!g_num_worker_threads) 116 if (!g_num_worker_threads)
117 g_num_worker_threads = kDefaultNumWorkerThreads; 117 g_num_worker_threads = kDefaultNumWorkerThreads;
118 118
119 return g_num_worker_threads; 119 return g_num_worker_threads;
120 } 120 }
121 121
122 // static 122 // static
123 void TileTaskWorkerPool::SetWorkerThreadPriority(
124 base::ThreadPriority priority) {
125 g_worker_thread_priority = priority;
126 }
127
128 // static
123 TaskGraphRunner* TileTaskWorkerPool::GetTaskGraphRunner() { 129 TaskGraphRunner* TileTaskWorkerPool::GetTaskGraphRunner() {
124 return g_task_graph_runner.Pointer(); 130 return g_task_graph_runner.Pointer();
125 } 131 }
126 132
127 // static 133 // static
128 scoped_refptr<TileTask> TileTaskWorkerPool::CreateTaskSetFinishedTask( 134 scoped_refptr<TileTask> TileTaskWorkerPool::CreateTaskSetFinishedTask(
129 base::SequencedTaskRunner* task_runner, 135 base::SequencedTaskRunner* task_runner,
130 const base::Closure& on_task_set_finished_callback) { 136 const base::Closure& on_task_set_finished_callback) {
131 return make_scoped_refptr( 137 return make_scoped_refptr(
132 new TaskSetFinishedTaskImpl(task_runner, on_task_set_finished_callback)); 138 new TaskSetFinishedTaskImpl(task_runner, on_task_set_finished_callback));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 260 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
255 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 261 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728
256 // is fixed. 262 // is fixed.
257 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); 263 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes());
258 DCHECK_EQ(0u, dst_row_bytes % 4); 264 DCHECK_EQ(0u, dst_row_bytes % 4);
259 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); 265 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0);
260 DCHECK_EQ(true, success); 266 DCHECK_EQ(true, success);
261 } 267 }
262 268
263 } // namespace cc 269 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698