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

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

Issue 523243002: cc: Generalize raster task notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renaming Created 6 years, 3 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
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 <limits> 7 #include <limits>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/cancelable_callback.h" 10 #include "base/cancelable_callback.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 : public testing::TestWithParam<RasterWorkerPoolType>, 102 : public testing::TestWithParam<RasterWorkerPoolType>,
103 public RasterizerClient { 103 public RasterizerClient {
104 public: 104 public:
105 struct RasterTaskResult { 105 struct RasterTaskResult {
106 unsigned id; 106 unsigned id;
107 bool canceled; 107 bool canceled;
108 }; 108 };
109 109
110 typedef std::vector<scoped_refptr<RasterTask> > RasterTaskVector; 110 typedef std::vector<scoped_refptr<RasterTask> > RasterTaskVector;
111 111
112 enum NamedTaskSet {
113 HIGH_RESOLUTION_IN_NOW_BIN_ON_ACTIVE_TREE = 0,
114 REQUIRED_FOR_ACTIVATION = 1,
115 ALL = 2
116 };
117
112 RasterWorkerPoolTest() 118 RasterWorkerPoolTest()
113 : context_provider_(TestContextProvider::Create()), 119 : context_provider_(TestContextProvider::Create()),
114 timeout_seconds_(5), 120 timeout_seconds_(5),
115 timed_out_(false) { 121 timed_out_(false) {
116 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); 122 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass();
117 CHECK(output_surface_->BindToClient(&output_surface_client_)); 123 CHECK(output_surface_->BindToClient(&output_surface_client_));
118 124
119 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 125 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
120 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 126 resource_provider_ = ResourceProvider::Create(output_surface_.get(),
121 shared_bitmap_manager_.get(), 127 shared_bitmap_manager_.get(),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 resource_provider_.reset(); 172 resource_provider_.reset();
167 } 173 }
168 174
169 // Overridden from testing::Test: 175 // Overridden from testing::Test:
170 virtual void TearDown() OVERRIDE { 176 virtual void TearDown() OVERRIDE {
171 raster_worker_pool_->AsRasterizer()->Shutdown(); 177 raster_worker_pool_->AsRasterizer()->Shutdown();
172 raster_worker_pool_->AsRasterizer()->CheckForCompletedTasks(); 178 raster_worker_pool_->AsRasterizer()->CheckForCompletedTasks();
173 } 179 }
174 180
175 // Overriden from RasterWorkerPoolClient: 181 // Overriden from RasterWorkerPoolClient:
176 virtual bool ShouldForceTasksRequiredForActivationToComplete() const 182 virtual void DidFinishRunningTasks(TaskSet task_set) OVERRIDE {
177 OVERRIDE { 183 if (task_set == ALL) {
178 return false; 184 raster_worker_pool_->AsRasterizer()->CheckForCompletedTasks();
185 base::MessageLoop::current()->Quit();
186 }
179 } 187 }
180 virtual void DidFinishRunningTasks() OVERRIDE { 188 virtual TaskSetCollection TasksThatShouldBeForcedToComplete() const OVERRIDE {
181 raster_worker_pool_->AsRasterizer()->CheckForCompletedTasks(); 189 return TaskSetCollection();
182 base::MessageLoop::current()->Quit();
183 } 190 }
184 virtual void DidFinishRunningTasksRequiredForActivation() OVERRIDE {} 191 virtual base::debug::TraceEventSyntheticDelay* SyntheticDelayForTasks(
192 TaskSet task_set) const OVERRIDE {
193 return NULL;
194 }
185 195
186 void RunMessageLoopUntilAllTasksHaveCompleted() { 196 void RunMessageLoopUntilAllTasksHaveCompleted() {
187 if (timeout_seconds_) { 197 if (timeout_seconds_) {
188 timeout_.Reset( 198 timeout_.Reset(
189 base::Bind(&RasterWorkerPoolTest::OnTimeout, base::Unretained(this))); 199 base::Bind(&RasterWorkerPoolTest::OnTimeout, base::Unretained(this)));
190 base::MessageLoopProxy::current()->PostDelayedTask( 200 base::MessageLoopProxy::current()->PostDelayedTask(
191 FROM_HERE, 201 FROM_HERE,
192 timeout_.callback(), 202 timeout_.callback(),
193 base::TimeDelta::FromSeconds(timeout_seconds_)); 203 base::TimeDelta::FromSeconds(timeout_seconds_));
194 } 204 }
195 205
196 base::MessageLoop::current()->Run(); 206 base::MessageLoop::current()->Run();
197 207
198 timeout_.Cancel(); 208 timeout_.Cancel();
199 209
200 ASSERT_FALSE(timed_out_) << "Test timed out"; 210 ASSERT_FALSE(timed_out_) << "Test timed out";
201 } 211 }
202 212
203 void ScheduleTasks() { 213 void ScheduleTasks() {
204 RasterTaskQueue queue; 214 RasterTaskQueue queue;
205 215
206 for (RasterTaskVector::const_iterator it = tasks_.begin(); 216 for (RasterTaskVector::const_iterator it = tasks_.begin();
207 it != tasks_.end(); 217 it != tasks_.end();
208 ++it) 218 ++it) {
209 queue.items.push_back(RasterTaskQueue::Item(it->get(), false)); 219 TaskSetCollection task_set_collection;
220 task_set_collection[ALL] = true;
221 queue.items.push_back(
222 RasterTaskQueue::Item(it->get(), task_set_collection));
223 }
210 224
211 raster_worker_pool_->AsRasterizer()->ScheduleTasks(&queue); 225 raster_worker_pool_->AsRasterizer()->ScheduleTasks(&queue);
212 } 226 }
213 227
214 void AppendTask(unsigned id, const gfx::Size& size) { 228 void AppendTask(unsigned id, const gfx::Size& size) {
215 scoped_ptr<ScopedResource> resource( 229 scoped_ptr<ScopedResource> resource(
216 ScopedResource::Create(resource_provider_.get())); 230 ScopedResource::Create(resource_provider_.get()));
217 resource->Allocate(size, ResourceProvider::TextureHintImmutable, RGBA_8888); 231 resource->Allocate(size, ResourceProvider::TextureHintImmutable, RGBA_8888);
218 const Resource* const_resource = resource.get(); 232 const Resource* const_resource = resource.get();
219 233
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 369
356 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, 370 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests,
357 RasterWorkerPoolTest, 371 RasterWorkerPoolTest,
358 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, 372 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER,
359 RASTER_WORKER_POOL_TYPE_IMAGE, 373 RASTER_WORKER_POOL_TYPE_IMAGE,
360 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, 374 RASTER_WORKER_POOL_TYPE_IMAGE_COPY,
361 RASTER_WORKER_POOL_TYPE_GPU)); 375 RASTER_WORKER_POOL_TYPE_GPU));
362 376
363 } // namespace 377 } // namespace
364 } // namespace cc 378 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698