OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/raster/bitmap_tile_task_worker_pool.h" | 5 #include "cc/raster/bitmap_tile_task_worker_pool.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 const Resource* resource_; | 61 const Resource* resource_; |
62 bool resource_has_previous_content_; | 62 bool resource_has_previous_content_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); | 64 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 // static | 69 // static |
70 std::unique_ptr<TileTaskWorkerPool> BitmapTileTaskWorkerPool::Create( | 70 std::unique_ptr<TileTaskWorkerPool> BitmapTileTaskWorkerPool::Create( |
71 base::SequencedTaskRunner* task_runner, | |
72 TaskGraphRunner* task_graph_runner, | |
73 ResourceProvider* resource_provider) { | 71 ResourceProvider* resource_provider) { |
74 return base::WrapUnique<TileTaskWorkerPool>(new BitmapTileTaskWorkerPool( | 72 return base::WrapUnique<TileTaskWorkerPool>( |
75 task_runner, task_graph_runner, resource_provider)); | 73 new BitmapTileTaskWorkerPool(resource_provider)); |
76 } | 74 } |
77 | 75 |
78 BitmapTileTaskWorkerPool::BitmapTileTaskWorkerPool( | 76 BitmapTileTaskWorkerPool::BitmapTileTaskWorkerPool( |
79 base::SequencedTaskRunner* task_runner, | |
80 TaskGraphRunner* task_graph_runner, | |
81 ResourceProvider* resource_provider) | 77 ResourceProvider* resource_provider) |
82 : task_runner_(task_runner), | 78 : resource_provider_(resource_provider) {} |
83 task_graph_runner_(task_graph_runner), | |
84 namespace_token_(task_graph_runner->GetNamespaceToken()), | |
85 resource_provider_(resource_provider) {} | |
86 | 79 |
87 BitmapTileTaskWorkerPool::~BitmapTileTaskWorkerPool() { | 80 BitmapTileTaskWorkerPool::~BitmapTileTaskWorkerPool() { |
88 } | 81 } |
89 | 82 |
90 void BitmapTileTaskWorkerPool::Shutdown() { | 83 void BitmapTileTaskWorkerPool::BarrierToSyncResources() {} |
91 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::Shutdown"); | |
92 | |
93 TaskGraph empty; | |
94 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | |
95 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); | |
96 } | |
97 | |
98 void BitmapTileTaskWorkerPool::ScheduleTasks(TaskGraph* graph) { | |
99 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::ScheduleTasks"); | |
100 | |
101 ScheduleTasksOnOriginThread(this, graph); | |
102 task_graph_runner_->ScheduleTasks(namespace_token_, graph); | |
103 } | |
104 | |
105 void BitmapTileTaskWorkerPool::CheckForCompletedTasks() { | |
106 TRACE_EVENT0("cc", "BitmapTileTaskWorkerPool::CheckForCompletedTasks"); | |
107 | |
108 task_graph_runner_->CollectCompletedTasks(namespace_token_, | |
109 &completed_tasks_); | |
110 for (Task::Vector::const_iterator it = completed_tasks_.begin(); | |
111 it != completed_tasks_.end(); ++it) { | |
112 TileTask* task = static_cast<TileTask*>(it->get()); | |
113 | |
114 task->WillComplete(); | |
115 task->CompleteOnOriginThread(this); | |
116 task->DidComplete(); | |
117 } | |
118 completed_tasks_.clear(); | |
119 } | |
120 | 84 |
121 ResourceFormat BitmapTileTaskWorkerPool::GetResourceFormat( | 85 ResourceFormat BitmapTileTaskWorkerPool::GetResourceFormat( |
122 bool must_support_alpha) const { | 86 bool must_support_alpha) const { |
123 return resource_provider_->best_texture_format(); | 87 return resource_provider_->best_texture_format(); |
124 } | 88 } |
125 | 89 |
126 bool BitmapTileTaskWorkerPool::GetResourceRequiresSwizzle( | 90 bool BitmapTileTaskWorkerPool::GetResourceRequiresSwizzle( |
127 bool must_support_alpha) const { | 91 bool must_support_alpha) const { |
128 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); | 92 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); |
129 } | 93 } |
130 | 94 |
131 RasterBufferProvider* BitmapTileTaskWorkerPool::AsRasterBufferProvider() { | 95 RasterBufferProvider* BitmapTileTaskWorkerPool::AsRasterBufferProvider() { |
132 return this; | 96 return this; |
133 } | 97 } |
134 | 98 |
135 std::unique_ptr<RasterBuffer> BitmapTileTaskWorkerPool::AcquireBufferForRaster( | 99 std::unique_ptr<RasterBuffer> BitmapTileTaskWorkerPool::AcquireBufferForRaster( |
136 const Resource* resource, | 100 const Resource* resource, |
137 uint64_t resource_content_id, | 101 uint64_t resource_content_id, |
138 uint64_t previous_content_id) { | 102 uint64_t previous_content_id) { |
139 return std::unique_ptr<RasterBuffer>(new RasterBufferImpl( | 103 return std::unique_ptr<RasterBuffer>(new RasterBufferImpl( |
140 resource_provider_, resource, resource_content_id, previous_content_id)); | 104 resource_provider_, resource, resource_content_id, previous_content_id)); |
141 } | 105 } |
142 | 106 |
143 void BitmapTileTaskWorkerPool::ReleaseBufferForRaster( | 107 void BitmapTileTaskWorkerPool::ReleaseBufferForRaster( |
144 std::unique_ptr<RasterBuffer> buffer) { | 108 std::unique_ptr<RasterBuffer> buffer) { |
145 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. | 109 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. |
146 } | 110 } |
147 | 111 |
148 } // namespace cc | 112 } // namespace cc |
OLD | NEW |