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

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

Issue 362073002: cc: Remove all traces of SkPicture cloning. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/raster_worker_pool.h ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/atomic_sequence_num.h"
10 #include "base/debug/trace_event_synthetic_delay.h" 9 #include "base/debug/trace_event_synthetic_delay.h"
11 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
12 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
13 #include "base/threading/simple_thread.h" 12 #include "base/threading/simple_thread.h"
14 #include "base/threading/thread_local.h"
15 #include "cc/base/scoped_ptr_deque.h" 13 #include "cc/base/scoped_ptr_deque.h"
16 14
17 namespace cc { 15 namespace cc {
18 namespace { 16 namespace {
19 17
20 // Synthetic delay for raster tasks that are required for activation. Global to 18 // Synthetic delay for raster tasks that are required for activation. Global to
21 // avoid static initializer on critical path. 19 // avoid static initializer on critical path.
22 struct RasterRequiredForActivationSyntheticDelayInitializer { 20 struct RasterRequiredForActivationSyntheticDelayInitializer {
23 RasterRequiredForActivationSyntheticDelayInitializer() 21 RasterRequiredForActivationSyntheticDelayInitializer()
24 : delay(base::debug::TraceEventSyntheticDelay::Lookup( 22 : delay(base::debug::TraceEventSyntheticDelay::Lookup(
(...skipping 18 matching lines...) Expand all
43 worker->Start(); 41 worker->Start();
44 #if defined(OS_ANDROID) || defined(OS_LINUX) 42 #if defined(OS_ANDROID) || defined(OS_LINUX)
45 worker->SetThreadPriority(base::kThreadPriority_Background); 43 worker->SetThreadPriority(base::kThreadPriority_Background);
46 #endif 44 #endif
47 workers_.push_back(worker.Pass()); 45 workers_.push_back(worker.Pass());
48 } 46 }
49 } 47 }
50 48
51 virtual ~RasterTaskGraphRunner() { NOTREACHED(); } 49 virtual ~RasterTaskGraphRunner() { NOTREACHED(); }
52 50
53 size_t GetPictureCloneIndexForCurrentThread() {
54 // Use index 0 if called on non-raster thread.
55 ThreadLocalState* thread_local_state = current_tls_.Get();
56 return thread_local_state ? current_tls_.Get()->picture_clone_index : 0;
57 }
58
59 private: 51 private:
60 struct ThreadLocalState {
61 explicit ThreadLocalState(size_t picture_clone_index)
62 : picture_clone_index(picture_clone_index) {}
63
64 size_t picture_clone_index;
65 };
66
67 // Overridden from base::DelegateSimpleThread::Delegate: 52 // Overridden from base::DelegateSimpleThread::Delegate:
68 virtual void Run() OVERRIDE { 53 virtual void Run() OVERRIDE {
69 // Use picture clone index 0..num_threads.
70 int picture_clone_index = picture_clone_index_sequence_.GetNext();
71 DCHECK_LE(0, picture_clone_index);
72 DCHECK_GT(RasterWorkerPool::GetNumRasterThreads(), picture_clone_index);
73 current_tls_.Set(new ThreadLocalState(picture_clone_index));
74
75 TaskGraphRunner::Run(); 54 TaskGraphRunner::Run();
76 } 55 }
77 56
78 ScopedPtrDeque<base::DelegateSimpleThread> workers_; 57 ScopedPtrDeque<base::DelegateSimpleThread> workers_;
79 base::AtomicSequenceNumber picture_clone_index_sequence_;
80 base::ThreadLocalPointer<ThreadLocalState> current_tls_;
81 }; 58 };
82 59
83 base::LazyInstance<RasterTaskGraphRunner>::Leaky g_task_graph_runner = 60 base::LazyInstance<RasterTaskGraphRunner>::Leaky g_task_graph_runner =
84 LAZY_INSTANCE_INITIALIZER; 61 LAZY_INSTANCE_INITIALIZER;
85 62
86 const int kDefaultNumRasterThreads = 1; 63 const int kDefaultNumRasterThreads = 1;
87 64
88 int g_num_raster_threads = 0; 65 int g_num_raster_threads = 0;
89 66
90 class RasterFinishedTaskImpl : public RasterizerTask { 67 class RasterFinishedTaskImpl : public RasterizerTask {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 168
192 return g_num_raster_threads; 169 return g_num_raster_threads;
193 } 170 }
194 171
195 // static 172 // static
196 TaskGraphRunner* RasterWorkerPool::GetTaskGraphRunner() { 173 TaskGraphRunner* RasterWorkerPool::GetTaskGraphRunner() {
197 return g_task_graph_runner.Pointer(); 174 return g_task_graph_runner.Pointer();
198 } 175 }
199 176
200 // static 177 // static
201 size_t RasterWorkerPool::GetPictureCloneIndexForCurrentThread() {
202 return g_task_graph_runner.Pointer()->GetPictureCloneIndexForCurrentThread();
203 }
204
205 // static
206 scoped_refptr<RasterizerTask> RasterWorkerPool::CreateRasterFinishedTask( 178 scoped_refptr<RasterizerTask> RasterWorkerPool::CreateRasterFinishedTask(
207 base::SequencedTaskRunner* task_runner, 179 base::SequencedTaskRunner* task_runner,
208 const base::Closure& on_raster_finished_callback) { 180 const base::Closure& on_raster_finished_callback) {
209 return make_scoped_refptr( 181 return make_scoped_refptr(
210 new RasterFinishedTaskImpl(task_runner, on_raster_finished_callback)); 182 new RasterFinishedTaskImpl(task_runner, on_raster_finished_callback));
211 } 183 }
212 184
213 // static 185 // static
214 scoped_refptr<RasterizerTask> 186 scoped_refptr<RasterizerTask>
215 RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask( 187 RasterWorkerPool::CreateRasterRequiredForActivationFinishedTask(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (decode_it == graph->nodes.end()) 253 if (decode_it == graph->nodes.end())
282 InsertNodeForTask(graph, decode_task, priority, 0u); 254 InsertNodeForTask(graph, decode_task, priority, 0u);
283 255
284 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); 256 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task));
285 } 257 }
286 258
287 InsertNodeForTask(graph, raster_task, priority, dependencies); 259 InsertNodeForTask(graph, raster_task, priority, dependencies);
288 } 260 }
289 261
290 } // namespace cc 262 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/raster_worker_pool.h ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698