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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/debug/trace_event_synthetic_delay.h" | 10 #include "base/debug/trace_event_synthetic_delay.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 this, | 39 this, |
40 base::StringPrintf("CompositorRasterWorker%u", | 40 base::StringPrintf("CompositorRasterWorker%u", |
41 static_cast<unsigned>(workers_.size() + 1)) | 41 static_cast<unsigned>(workers_.size() + 1)) |
42 .c_str())); | 42 .c_str())); |
43 worker->Start(); | 43 worker->Start(); |
44 #if defined(OS_ANDROID) || defined(OS_LINUX) | 44 #if defined(OS_ANDROID) || defined(OS_LINUX) |
45 worker->SetThreadPriority(base::kThreadPriority_Background); | 45 worker->SetThreadPriority(base::kThreadPriority_Background); |
46 #endif | 46 #endif |
47 workers_.push_back(worker.Pass()); | 47 workers_.push_back(worker.Pass()); |
48 } | 48 } |
49 | |
50 // Use index 0 for origin thread. | |
51 current_tls_.Set(new ThreadLocalState(0)); | |
52 } | 49 } |
53 | 50 |
54 virtual ~RasterTaskGraphRunner() { NOTREACHED(); } | 51 virtual ~RasterTaskGraphRunner() { NOTREACHED(); } |
55 | 52 |
56 size_t GetPictureCloneIndexForCurrentThread() { | 53 size_t GetPictureCloneIndexForCurrentThread() { |
57 return current_tls_.Get()->picture_clone_index; | 54 // Use index 0 for origin thread and any unknown threads. |
reveman
2014/06/20 18:44:19
nit: "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; | |
58 } | 57 } |
59 | 58 |
60 private: | 59 private: |
61 struct ThreadLocalState { | 60 struct ThreadLocalState { |
62 explicit ThreadLocalState(size_t picture_clone_index) | 61 explicit ThreadLocalState(size_t picture_clone_index) |
63 : picture_clone_index(picture_clone_index) {} | 62 : picture_clone_index(picture_clone_index) {} |
64 | 63 |
65 size_t picture_clone_index; | 64 size_t picture_clone_index; |
66 }; | 65 }; |
67 | 66 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 if (decode_it == graph->nodes.end()) | 281 if (decode_it == graph->nodes.end()) |
283 InsertNodeForTask(graph, decode_task, priority, 0u); | 282 InsertNodeForTask(graph, decode_task, priority, 0u); |
284 | 283 |
285 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); | 284 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); |
286 } | 285 } |
287 | 286 |
288 InsertNodeForTask(graph, raster_task, priority, dependencies); | 287 InsertNodeForTask(graph, raster_task, priority, dependencies); |
289 } | 288 } |
290 | 289 |
291 } // namespace cc | 290 } // namespace cc |
OLD | NEW |