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 <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
| 11 #include "cc/resources/direct_raster_worker_pool.h" |
11 #include "cc/resources/image_raster_worker_pool.h" | 12 #include "cc/resources/image_raster_worker_pool.h" |
12 #include "cc/resources/picture_pile.h" | 13 #include "cc/resources/picture_pile.h" |
13 #include "cc/resources/picture_pile_impl.h" | 14 #include "cc/resources/picture_pile_impl.h" |
14 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 15 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
15 #include "cc/resources/resource_provider.h" | 16 #include "cc/resources/resource_provider.h" |
16 #include "cc/resources/scoped_resource.h" | 17 #include "cc/resources/scoped_resource.h" |
17 #include "cc/test/fake_output_surface.h" | 18 #include "cc/test/fake_output_surface.h" |
18 #include "cc/test/fake_output_surface_client.h" | 19 #include "cc/test/fake_output_surface_client.h" |
19 #include "cc/test/test_web_graphics_context_3d.h" | 20 #include "cc/test/test_web_graphics_context_3d.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace cc { | 23 namespace cc { |
23 namespace { | 24 namespace { |
24 | 25 |
25 enum RasterThread { | 26 enum RasterThread { |
26 RASTER_THREAD_NONE, | 27 RASTER_THREAD_NONE, |
27 RASTER_THREAD_ORIGIN, | 28 RASTER_THREAD_ORIGIN, |
28 RASTER_THREAD_WORKER | 29 RASTER_THREAD_WORKER |
29 }; | 30 }; |
30 | 31 |
31 enum RasterWorkerPoolType { | 32 enum RasterWorkerPoolType { |
32 RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 33 RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
33 RASTER_WORKER_POOL_TYPE_IMAGE | 34 RASTER_WORKER_POOL_TYPE_IMAGE, |
| 35 RASTER_WORKER_POOL_TYPE_DIRECT |
34 }; | 36 }; |
35 | 37 |
36 class TestRasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask { | 38 class TestRasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask { |
37 public: | 39 public: |
38 typedef base::Callback<void(const PicturePileImpl::Analysis& analysis, | 40 typedef base::Callback<void(const PicturePileImpl::Analysis& analysis, |
39 bool was_canceled, | 41 bool was_canceled, |
40 RasterThread raster_thread)> Reply; | 42 RasterThread raster_thread)> Reply; |
41 | 43 |
42 TestRasterWorkerPoolTaskImpl(const Resource* resource, | 44 TestRasterWorkerPoolTaskImpl(const Resource* resource, |
43 const Reply& reply, | 45 const Reply& reply, |
44 internal::Task::Vector* dependencies, | 46 internal::WorkerPoolTask::Vector* dependencies) |
45 bool use_gpu_rasterization) | 47 : internal::RasterWorkerPoolTask(resource, dependencies), |
46 : internal::RasterWorkerPoolTask(resource, | |
47 dependencies, | |
48 use_gpu_rasterization), | |
49 reply_(reply), | 48 reply_(reply), |
50 raster_thread_(RASTER_THREAD_NONE) {} | 49 raster_thread_(RASTER_THREAD_NONE) {} |
51 | 50 |
52 // Overridden from internal::Task: | 51 // Overridden from internal::Task: |
53 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { | 52 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { |
54 raster_thread_ = RASTER_THREAD_WORKER; | 53 raster_thread_ = RASTER_THREAD_WORKER; |
55 } | 54 } |
56 | 55 |
57 // Overridden from internal::WorkerPoolTask: | 56 // Overridden from internal::WorkerPoolTask: |
58 virtual void ScheduleOnOriginThread(internal::WorkerPoolTaskClient* client) | 57 virtual void ScheduleOnOriginThread(internal::WorkerPoolTaskClient* client) |
59 OVERRIDE { | 58 OVERRIDE { |
60 client->AcquireCanvasForRaster(this); | 59 client->AcquireCanvasForRaster(this); |
61 } | 60 } |
| 61 virtual void RunOnOriginThread() OVERRIDE { |
| 62 raster_thread_ = RASTER_THREAD_ORIGIN; |
| 63 } |
62 virtual void CompleteOnOriginThread(internal::WorkerPoolTaskClient* client) | 64 virtual void CompleteOnOriginThread(internal::WorkerPoolTaskClient* client) |
63 OVERRIDE { | 65 OVERRIDE { |
64 client->OnRasterCompleted(this, PicturePileImpl::Analysis()); | 66 client->OnRasterCompleted(this, PicturePileImpl::Analysis()); |
65 } | 67 } |
66 virtual void RunReplyOnOriginThread() OVERRIDE { | 68 virtual void RunReplyOnOriginThread() OVERRIDE { |
67 reply_.Run( | 69 reply_.Run( |
68 PicturePileImpl::Analysis(), !HasFinishedRunning(), raster_thread_); | 70 PicturePileImpl::Analysis(), !HasFinishedRunning(), raster_thread_); |
69 } | 71 } |
70 | 72 |
71 // Overridden from internal::RasterWorkerPoolTask: | |
72 virtual void RunOnOriginThread(ResourceProvider* resource_provider, | |
73 ContextProvider* context_provider) OVERRIDE { | |
74 raster_thread_ = RASTER_THREAD_ORIGIN; | |
75 } | |
76 | |
77 protected: | 73 protected: |
78 virtual ~TestRasterWorkerPoolTaskImpl() {} | 74 virtual ~TestRasterWorkerPoolTaskImpl() {} |
79 | 75 |
80 private: | 76 private: |
81 const Reply reply_; | 77 const Reply reply_; |
82 RasterThread raster_thread_; | 78 RasterThread raster_thread_; |
83 | 79 |
84 DISALLOW_COPY_AND_ASSIGN(TestRasterWorkerPoolTaskImpl); | 80 DISALLOW_COPY_AND_ASSIGN(TestRasterWorkerPoolTaskImpl); |
85 }; | 81 }; |
86 | 82 |
87 class BlockingTestRasterWorkerPoolTaskImpl | 83 class BlockingTestRasterWorkerPoolTaskImpl |
88 : public TestRasterWorkerPoolTaskImpl { | 84 : public TestRasterWorkerPoolTaskImpl { |
89 public: | 85 public: |
90 BlockingTestRasterWorkerPoolTaskImpl(const Resource* resource, | 86 BlockingTestRasterWorkerPoolTaskImpl( |
91 const Reply& reply, | 87 const Resource* resource, |
92 base::Lock* lock, | 88 const Reply& reply, |
93 internal::Task::Vector* dependencies, | 89 base::Lock* lock, |
94 bool use_gpu_rasterization) | 90 internal::WorkerPoolTask::Vector* dependencies) |
95 : TestRasterWorkerPoolTaskImpl(resource, | 91 : TestRasterWorkerPoolTaskImpl(resource, reply, dependencies), |
96 reply, | |
97 dependencies, | |
98 use_gpu_rasterization), | |
99 lock_(lock) {} | 92 lock_(lock) {} |
100 | 93 |
101 // Overridden from internal::Task: | 94 // Overridden from internal::Task: |
102 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { | 95 virtual void RunOnWorkerThread(unsigned thread_index) OVERRIDE { |
103 base::AutoLock lock(*lock_); | 96 base::AutoLock lock(*lock_); |
104 TestRasterWorkerPoolTaskImpl::RunOnWorkerThread(thread_index); | 97 TestRasterWorkerPoolTaskImpl::RunOnWorkerThread(thread_index); |
105 } | 98 } |
106 | 99 |
107 // Overridden from internal::WorkerPoolTask: | 100 // Overridden from internal::WorkerPoolTask: |
108 virtual void RunReplyOnOriginThread() OVERRIDE {} | 101 virtual void RunReplyOnOriginThread() OVERRIDE {} |
109 | 102 |
110 protected: | 103 protected: |
111 virtual ~BlockingTestRasterWorkerPoolTaskImpl() {} | 104 virtual ~BlockingTestRasterWorkerPoolTaskImpl() {} |
112 | 105 |
113 private: | 106 private: |
114 base::Lock* lock_; | 107 base::Lock* lock_; |
115 | 108 |
116 DISALLOW_COPY_AND_ASSIGN(BlockingTestRasterWorkerPoolTaskImpl); | 109 DISALLOW_COPY_AND_ASSIGN(BlockingTestRasterWorkerPoolTaskImpl); |
117 }; | 110 }; |
118 | 111 |
119 class RasterWorkerPoolTest | 112 class RasterWorkerPoolTest |
120 : public testing::TestWithParam<RasterWorkerPoolType>, | 113 : public testing::TestWithParam<RasterWorkerPoolType>, |
121 public RasterWorkerPoolClient { | 114 public RasterWorkerPoolClient { |
122 public: | 115 public: |
123 class RasterTask : public RasterWorkerPool::RasterTask { | |
124 public: | |
125 typedef std::vector<RasterTask> Vector; | |
126 | |
127 static RasterTask Create(const Resource* resource, | |
128 const TestRasterWorkerPoolTaskImpl::Reply& reply, | |
129 bool use_gpu_rasterization) { | |
130 internal::Task::Vector dependencies; | |
131 return RasterTask(new TestRasterWorkerPoolTaskImpl( | |
132 resource, reply, &dependencies, use_gpu_rasterization)); | |
133 } | |
134 | |
135 static RasterTask CreateBlocking( | |
136 const Resource* resource, | |
137 const TestRasterWorkerPoolTaskImpl::Reply& reply, | |
138 base::Lock* lock, | |
139 bool use_gpu_rasterization) { | |
140 internal::Task::Vector dependencies; | |
141 return RasterTask(new BlockingTestRasterWorkerPoolTaskImpl( | |
142 resource, reply, lock, &dependencies, use_gpu_rasterization)); | |
143 } | |
144 | |
145 private: | |
146 friend class RasterWorkerPoolTest; | |
147 | |
148 explicit RasterTask(internal::RasterWorkerPoolTask* task) | |
149 : RasterWorkerPool::RasterTask(task) {} | |
150 }; | |
151 | |
152 struct RasterTaskResult { | 116 struct RasterTaskResult { |
153 unsigned id; | 117 unsigned id; |
154 bool canceled; | 118 bool canceled; |
155 RasterThread raster_thread; | 119 RasterThread raster_thread; |
156 }; | 120 }; |
157 | 121 |
| 122 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > |
| 123 RasterTaskVector; |
| 124 |
158 RasterWorkerPoolTest() | 125 RasterWorkerPoolTest() |
159 : context_provider_(TestContextProvider::Create()), | 126 : context_provider_(TestContextProvider::Create()), |
160 timeout_seconds_(5), | 127 timeout_seconds_(5), |
161 timed_out_(false) { | 128 timed_out_(false) { |
162 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 129 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
163 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 130 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
164 | 131 |
165 resource_provider_ = ResourceProvider::Create( | 132 resource_provider_ = ResourceProvider::Create( |
166 output_surface_.get(), NULL, 0, false, 1).Pass(); | 133 output_surface_.get(), NULL, 0, false, 1).Pass(); |
167 | 134 |
168 switch (GetParam()) { | 135 switch (GetParam()) { |
169 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: | 136 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: |
170 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( | 137 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( |
171 resource_provider_.get(), | 138 resource_provider_.get(), |
172 context_provider_.get(), | |
173 std::numeric_limits<size_t>::max()); | 139 std::numeric_limits<size_t>::max()); |
174 break; | 140 break; |
175 case RASTER_WORKER_POOL_TYPE_IMAGE: | 141 case RASTER_WORKER_POOL_TYPE_IMAGE: |
176 raster_worker_pool_ = ImageRasterWorkerPool::Create( | 142 raster_worker_pool_ = ImageRasterWorkerPool::Create( |
177 resource_provider_.get(), context_provider_.get(), GL_TEXTURE_2D); | 143 resource_provider_.get(), GL_TEXTURE_2D); |
| 144 break; |
| 145 case RASTER_WORKER_POOL_TYPE_DIRECT: |
| 146 raster_worker_pool_ = DirectRasterWorkerPool::Create( |
| 147 resource_provider_.get(), context_provider_.get()); |
178 break; | 148 break; |
179 } | 149 } |
180 | 150 |
181 DCHECK(raster_worker_pool_); | 151 DCHECK(raster_worker_pool_); |
182 raster_worker_pool_->SetClient(this); | 152 raster_worker_pool_->SetClient(this); |
183 } | 153 } |
184 virtual ~RasterWorkerPoolTest() { resource_provider_.reset(); } | 154 virtual ~RasterWorkerPoolTest() { resource_provider_.reset(); } |
185 | 155 |
186 // Overridden from testing::Test: | 156 // Overridden from testing::Test: |
187 virtual void TearDown() OVERRIDE { | 157 virtual void TearDown() OVERRIDE { |
(...skipping 23 matching lines...) Expand all Loading... |
211 } | 181 } |
212 | 182 |
213 base::MessageLoop::current()->Run(); | 183 base::MessageLoop::current()->Run(); |
214 | 184 |
215 timeout_.Cancel(); | 185 timeout_.Cancel(); |
216 | 186 |
217 ASSERT_FALSE(timed_out_) << "Test timed out"; | 187 ASSERT_FALSE(timed_out_) << "Test timed out"; |
218 } | 188 } |
219 | 189 |
220 void ScheduleTasks() { | 190 void ScheduleTasks() { |
221 RasterWorkerPool::RasterTask::Queue tasks; | 191 RasterTaskQueue queue; |
222 | 192 |
223 for (RasterTask::Vector::iterator it = tasks_.begin(); it != tasks_.end(); | 193 for (RasterTaskVector::const_iterator it = tasks_.begin(); |
| 194 it != tasks_.end(); |
224 ++it) | 195 ++it) |
225 tasks.Append(*it, false); | 196 queue.tasks.push_back(RasterTaskQueue::Task(*it, false)); |
226 | 197 |
227 raster_worker_pool_->ScheduleTasks(&tasks); | 198 raster_worker_pool_->ScheduleTasks(&queue); |
228 } | 199 } |
229 | 200 |
230 void AppendTask(unsigned id, bool use_gpu_rasterization) { | 201 void AppendTask(unsigned id) { |
231 const gfx::Size size(1, 1); | 202 const gfx::Size size(1, 1); |
232 | 203 |
233 scoped_ptr<ScopedResource> resource( | 204 scoped_ptr<ScopedResource> resource( |
234 ScopedResource::Create(resource_provider_.get())); | 205 ScopedResource::Create(resource_provider_.get())); |
235 resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888); | 206 resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888); |
236 const Resource* const_resource = resource.get(); | 207 const Resource* const_resource = resource.get(); |
237 | 208 |
238 tasks_.push_back( | 209 internal::WorkerPoolTask::Vector empty; |
239 RasterTask::Create(const_resource, | 210 tasks_.push_back(new TestRasterWorkerPoolTaskImpl( |
240 base::Bind(&RasterWorkerPoolTest::OnTaskCompleted, | 211 const_resource, |
241 base::Unretained(this), | 212 base::Bind(&RasterWorkerPoolTest::OnTaskCompleted, |
242 base::Passed(&resource), | 213 base::Unretained(this), |
243 id), | 214 base::Passed(&resource), |
244 use_gpu_rasterization)); | 215 id), |
| 216 &empty)); |
245 } | 217 } |
246 | 218 |
247 void AppendBlockingTask(unsigned id, base::Lock* lock) { | 219 void AppendBlockingTask(unsigned id, base::Lock* lock) { |
248 const gfx::Size size(1, 1); | 220 const gfx::Size size(1, 1); |
249 | 221 |
250 scoped_ptr<ScopedResource> resource( | 222 scoped_ptr<ScopedResource> resource( |
251 ScopedResource::Create(resource_provider_.get())); | 223 ScopedResource::Create(resource_provider_.get())); |
252 resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888); | 224 resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888); |
253 const Resource* const_resource = resource.get(); | 225 const Resource* const_resource = resource.get(); |
254 | 226 |
255 tasks_.push_back(RasterTask::CreateBlocking( | 227 internal::WorkerPoolTask::Vector empty; |
| 228 tasks_.push_back(new BlockingTestRasterWorkerPoolTaskImpl( |
256 const_resource, | 229 const_resource, |
257 base::Bind(&RasterWorkerPoolTest::OnTaskCompleted, | 230 base::Bind(&RasterWorkerPoolTest::OnTaskCompleted, |
258 base::Unretained(this), | 231 base::Unretained(this), |
259 base::Passed(&resource), | 232 base::Passed(&resource), |
260 id), | 233 id), |
261 lock, | 234 lock, |
262 false)); | 235 &empty)); |
263 } | 236 } |
264 | 237 |
265 const std::vector<RasterTaskResult>& completed_tasks() const { | 238 const std::vector<RasterTaskResult>& completed_tasks() const { |
266 return completed_tasks_; | 239 return completed_tasks_; |
267 } | 240 } |
268 | 241 |
269 private: | 242 private: |
270 void OnTaskCompleted(scoped_ptr<ScopedResource> resource, | 243 void OnTaskCompleted(scoped_ptr<ScopedResource> resource, |
271 unsigned id, | 244 unsigned id, |
272 const PicturePileImpl::Analysis& analysis, | 245 const PicturePileImpl::Analysis& analysis, |
(...skipping 13 matching lines...) Expand all Loading... |
286 | 259 |
287 protected: | 260 protected: |
288 scoped_refptr<TestContextProvider> context_provider_; | 261 scoped_refptr<TestContextProvider> context_provider_; |
289 FakeOutputSurfaceClient output_surface_client_; | 262 FakeOutputSurfaceClient output_surface_client_; |
290 scoped_ptr<FakeOutputSurface> output_surface_; | 263 scoped_ptr<FakeOutputSurface> output_surface_; |
291 scoped_ptr<ResourceProvider> resource_provider_; | 264 scoped_ptr<ResourceProvider> resource_provider_; |
292 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 265 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
293 base::CancelableClosure timeout_; | 266 base::CancelableClosure timeout_; |
294 int timeout_seconds_; | 267 int timeout_seconds_; |
295 bool timed_out_; | 268 bool timed_out_; |
296 std::vector<RasterTask> tasks_; | 269 RasterTaskVector tasks_; |
297 std::vector<RasterTaskResult> completed_tasks_; | 270 std::vector<RasterTaskResult> completed_tasks_; |
298 }; | 271 }; |
299 | 272 |
300 TEST_P(RasterWorkerPoolTest, Basic) { | 273 TEST_P(RasterWorkerPoolTest, Basic) { |
301 AppendTask(0u, false); | 274 AppendTask(0u); |
302 AppendTask(1u, false); | 275 AppendTask(1u); |
303 ScheduleTasks(); | 276 ScheduleTasks(); |
304 | 277 |
305 RunMessageLoopUntilAllTasksHaveCompleted(); | 278 RunMessageLoopUntilAllTasksHaveCompleted(); |
306 | 279 |
307 ASSERT_EQ(2u, completed_tasks().size()); | 280 ASSERT_EQ(2u, completed_tasks().size()); |
308 EXPECT_FALSE(completed_tasks()[0].canceled); | 281 EXPECT_FALSE(completed_tasks()[0].canceled); |
309 EXPECT_FALSE(completed_tasks()[1].canceled); | 282 EXPECT_FALSE(completed_tasks()[1].canceled); |
310 EXPECT_EQ(RASTER_THREAD_WORKER, completed_tasks()[0].raster_thread); | 283 EXPECT_NE(RASTER_THREAD_NONE, completed_tasks()[0].raster_thread); |
311 EXPECT_EQ(RASTER_THREAD_WORKER, completed_tasks()[1].raster_thread); | 284 EXPECT_NE(RASTER_THREAD_NONE, completed_tasks()[1].raster_thread); |
312 } | |
313 | |
314 TEST_P(RasterWorkerPoolTest, GpuRaster) { | |
315 AppendTask(0u, true); // GPU raster. | |
316 ScheduleTasks(); | |
317 | |
318 RunMessageLoopUntilAllTasksHaveCompleted(); | |
319 | |
320 ASSERT_EQ(1u, completed_tasks().size()); | |
321 EXPECT_EQ(0u, completed_tasks()[0].id); | |
322 EXPECT_FALSE(completed_tasks()[0].canceled); | |
323 EXPECT_EQ(RASTER_THREAD_ORIGIN, completed_tasks()[0].raster_thread); | |
324 } | |
325 | |
326 TEST_P(RasterWorkerPoolTest, HybridRaster) { | |
327 AppendTask(0u, false); // Software raster. | |
328 AppendTask(1u, true); // GPU raster. | |
329 ScheduleTasks(); | |
330 | |
331 RunMessageLoopUntilAllTasksHaveCompleted(); | |
332 | |
333 ASSERT_EQ(2u, completed_tasks().size()); | |
334 for (int i = 0; i < 2; ++i) { | |
335 EXPECT_FALSE(completed_tasks()[i].canceled); | |
336 switch (completed_tasks()[i].id) { | |
337 case 0u: | |
338 EXPECT_EQ(RASTER_THREAD_WORKER, completed_tasks()[i].raster_thread); | |
339 break; | |
340 case 1u: | |
341 EXPECT_EQ(RASTER_THREAD_ORIGIN, completed_tasks()[i].raster_thread); | |
342 break; | |
343 default: | |
344 NOTREACHED(); | |
345 } | |
346 } | |
347 } | 285 } |
348 | 286 |
349 TEST_P(RasterWorkerPoolTest, FailedMapResource) { | 287 TEST_P(RasterWorkerPoolTest, FailedMapResource) { |
350 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); | 288 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); |
351 context3d->set_times_map_image_chromium_succeeds(0); | 289 context3d->set_times_map_image_chromium_succeeds(0); |
352 context3d->set_times_map_buffer_chromium_succeeds(0); | 290 context3d->set_times_map_buffer_chromium_succeeds(0); |
353 AppendTask(0u, false); | 291 AppendTask(0u); |
354 ScheduleTasks(); | 292 ScheduleTasks(); |
355 | 293 |
356 RunMessageLoopUntilAllTasksHaveCompleted(); | 294 RunMessageLoopUntilAllTasksHaveCompleted(); |
357 | 295 |
358 ASSERT_EQ(1u, completed_tasks().size()); | 296 ASSERT_EQ(1u, completed_tasks().size()); |
359 EXPECT_FALSE(completed_tasks()[0].canceled); | 297 EXPECT_FALSE(completed_tasks()[0].canceled); |
360 EXPECT_EQ(RASTER_THREAD_WORKER, completed_tasks()[0].raster_thread); | 298 EXPECT_NE(RASTER_THREAD_NONE, completed_tasks()[0].raster_thread); |
361 } | 299 } |
362 | 300 |
363 // This test checks that replacing a pending raster task with another does | 301 // This test checks that replacing a pending raster task with another does |
364 // not prevent the DidFinishRunningTasks notification from being sent. | 302 // not prevent the DidFinishRunningTasks notification from being sent. |
365 TEST_P(RasterWorkerPoolTest, FalseThrottling) { | 303 TEST_P(RasterWorkerPoolTest, FalseThrottling) { |
366 base::Lock lock; | 304 base::Lock lock; |
367 | 305 |
368 // Schedule a task that is prevented from completing with a lock. | 306 // Schedule a task that is prevented from completing with a lock. |
369 lock.Acquire(); | 307 lock.Acquire(); |
370 AppendBlockingTask(0u, &lock); | 308 AppendBlockingTask(0u, &lock); |
371 ScheduleTasks(); | 309 ScheduleTasks(); |
372 | 310 |
373 // Schedule another task to replace the still-pending task. Because the old | 311 // Schedule another task to replace the still-pending task. Because the old |
374 // task is not a throttled task in the new task set, it should not prevent | 312 // task is not a throttled task in the new task set, it should not prevent |
375 // DidFinishRunningTasks from getting signaled. | 313 // DidFinishRunningTasks from getting signaled. |
376 tasks_.clear(); | 314 tasks_.clear(); |
377 AppendTask(1u, false); | 315 AppendTask(1u); |
378 ScheduleTasks(); | 316 ScheduleTasks(); |
379 | 317 |
380 // Unblock the first task to allow the second task to complete. | 318 // Unblock the first task to allow the second task to complete. |
381 lock.Release(); | 319 lock.Release(); |
382 | 320 |
383 RunMessageLoopUntilAllTasksHaveCompleted(); | 321 RunMessageLoopUntilAllTasksHaveCompleted(); |
384 } | 322 } |
385 | 323 |
386 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, | 324 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, |
387 RasterWorkerPoolTest, | 325 RasterWorkerPoolTest, |
388 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 326 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
389 RASTER_WORKER_POOL_TYPE_IMAGE)); | 327 RASTER_WORKER_POOL_TYPE_IMAGE, |
| 328 RASTER_WORKER_POOL_TYPE_DIRECT)); |
390 | 329 |
391 } // namespace | 330 } // namespace |
392 } // namespace cc | 331 } // namespace cc |
OLD | NEW |