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

Side by Side Diff: cc/raster/raster_buffer_provider_perftest.cc

Issue 1910213005: cc: Refactor TileTaskWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@task_states
Patch Set: feedback Created 4 years, 7 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
« no previous file with comments | « cc/raster/raster_buffer_provider.cc ('k') | cc/raster/raster_buffer_provider_unittest.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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "cc/debug/lap_timer.h" 12 #include "cc/debug/lap_timer.h"
13 #include "cc/output/context_provider.h" 13 #include "cc/output/context_provider.h"
14 #include "cc/raster/bitmap_tile_task_worker_pool.h" 14 #include "cc/raster/bitmap_raster_buffer_provider.h"
15 #include "cc/raster/gpu_raster_buffer_provider.h"
15 #include "cc/raster/gpu_rasterizer.h" 16 #include "cc/raster/gpu_rasterizer.h"
16 #include "cc/raster/gpu_tile_task_worker_pool.h" 17 #include "cc/raster/one_copy_raster_buffer_provider.h"
17 #include "cc/raster/one_copy_tile_task_worker_pool.h" 18 #include "cc/raster/raster_buffer_provider.h"
18 #include "cc/raster/synchronous_task_graph_runner.h" 19 #include "cc/raster/synchronous_task_graph_runner.h"
19 #include "cc/raster/tile_task_worker_pool.h" 20 #include "cc/raster/zero_copy_raster_buffer_provider.h"
20 #include "cc/raster/zero_copy_tile_task_worker_pool.h"
21 #include "cc/resources/resource_pool.h" 21 #include "cc/resources/resource_pool.h"
22 #include "cc/resources/resource_provider.h" 22 #include "cc/resources/resource_provider.h"
23 #include "cc/resources/scoped_resource.h" 23 #include "cc/resources/scoped_resource.h"
24 #include "cc/test/fake_output_surface.h" 24 #include "cc/test/fake_output_surface.h"
25 #include "cc/test/fake_output_surface_client.h" 25 #include "cc/test/fake_output_surface_client.h"
26 #include "cc/test/fake_resource_provider.h" 26 #include "cc/test/fake_resource_provider.h"
27 #include "cc/test/test_context_support.h" 27 #include "cc/test/test_context_support.h"
28 #include "cc/test/test_gpu_memory_buffer_manager.h" 28 #include "cc/test/test_gpu_memory_buffer_manager.h"
29 #include "cc/test/test_shared_bitmap_manager.h" 29 #include "cc/test/test_shared_bitmap_manager.h"
30 #include "cc/test/test_web_graphics_context_3d.h" 30 #include "cc/test/test_web_graphics_context_3d.h"
31 #include "cc/tiles/tile_task_manager.h"
31 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
32 #include "testing/perf/perf_test.h" 33 #include "testing/perf/perf_test.h"
33 #include "third_party/khronos/GLES2/gl2.h" 34 #include "third_party/khronos/GLES2/gl2.h"
34 #include "third_party/skia/include/gpu/GrContext.h" 35 #include "third_party/skia/include/gpu/GrContext.h"
35 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" 36 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
36 37
37 namespace cc { 38 namespace cc {
38 namespace { 39 namespace {
39 40
40 class PerfGLES2Interface : public gpu::gles2::GLES2InterfaceStub { 41 class PerfGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 104
104 private: 105 private:
105 ~PerfContextProvider() override {} 106 ~PerfContextProvider() override {}
106 107
107 std::unique_ptr<PerfGLES2Interface> context_gl_; 108 std::unique_ptr<PerfGLES2Interface> context_gl_;
108 sk_sp<class GrContext> gr_context_; 109 sk_sp<class GrContext> gr_context_;
109 TestContextSupport support_; 110 TestContextSupport support_;
110 base::Lock context_lock_; 111 base::Lock context_lock_;
111 }; 112 };
112 113
113 enum TileTaskWorkerPoolType { 114 enum RasterBufferProviderType {
114 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, 115 RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY,
115 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, 116 RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY,
116 TILE_TASK_WORKER_POOL_TYPE_GPU, 117 RASTER_BUFFER_PROVIDER_TYPE_GPU,
117 TILE_TASK_WORKER_POOL_TYPE_BITMAP 118 RASTER_BUFFER_PROVIDER_TYPE_BITMAP
118 }; 119 };
119 120
120 static const int kTimeLimitMillis = 2000; 121 static const int kTimeLimitMillis = 2000;
121 static const int kWarmupRuns = 5; 122 static const int kWarmupRuns = 5;
122 static const int kTimeCheckInterval = 10; 123 static const int kTimeCheckInterval = 10;
123 124
124 class PerfImageDecodeTaskImpl : public TileTask { 125 class PerfImageDecodeTaskImpl : public TileTask {
125 public: 126 public:
126 PerfImageDecodeTaskImpl() : TileTask(true) {} 127 PerfImageDecodeTaskImpl() : TileTask(true) {}
127 128
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 protected: 174 protected:
174 ~PerfRasterTaskImpl() override {} 175 ~PerfRasterTaskImpl() override {}
175 176
176 private: 177 private:
177 std::unique_ptr<ScopedResource> resource_; 178 std::unique_ptr<ScopedResource> resource_;
178 std::unique_ptr<RasterBuffer> raster_buffer_; 179 std::unique_ptr<RasterBuffer> raster_buffer_;
179 180
180 DISALLOW_COPY_AND_ASSIGN(PerfRasterTaskImpl); 181 DISALLOW_COPY_AND_ASSIGN(PerfRasterTaskImpl);
181 }; 182 };
182 183
183 class TileTaskWorkerPoolPerfTestBase { 184 class RasterBufferProviderPerfTestBase {
184 public: 185 public:
185 typedef std::vector<scoped_refptr<TileTask>> RasterTaskVector; 186 typedef std::vector<scoped_refptr<TileTask>> RasterTaskVector;
186 187
187 enum NamedTaskSet { REQUIRED_FOR_ACTIVATION, REQUIRED_FOR_DRAW, ALL }; 188 enum NamedTaskSet { REQUIRED_FOR_ACTIVATION, REQUIRED_FOR_DRAW, ALL };
188 189
189 TileTaskWorkerPoolPerfTestBase() 190 RasterBufferProviderPerfTestBase()
190 : context_provider_(make_scoped_refptr(new PerfContextProvider)), 191 : context_provider_(make_scoped_refptr(new PerfContextProvider)),
191 task_runner_(new base::TestSimpleTaskRunner), 192 task_runner_(new base::TestSimpleTaskRunner),
192 task_graph_runner_(new SynchronousTaskGraphRunner), 193 task_graph_runner_(new SynchronousTaskGraphRunner),
193 timer_(kWarmupRuns, 194 timer_(kWarmupRuns,
194 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), 195 base::TimeDelta::FromMilliseconds(kTimeLimitMillis),
195 kTimeCheckInterval) {} 196 kTimeCheckInterval) {}
196 197
197 void CreateImageDecodeTasks(unsigned num_image_decode_tasks, 198 void CreateImageDecodeTasks(unsigned num_image_decode_tasks,
198 TileTask::Vector* image_decode_tasks) { 199 TileTask::Vector* image_decode_tasks) {
199 for (unsigned i = 0; i < num_image_decode_tasks; ++i) 200 for (unsigned i = 0; i < num_image_decode_tasks; ++i)
200 image_decode_tasks->push_back(new PerfImageDecodeTaskImpl); 201 image_decode_tasks->push_back(new PerfImageDecodeTaskImpl);
201 } 202 }
202 203
203 void CreateRasterTasks(unsigned num_raster_tasks, 204 void CreateRasterTasks(unsigned num_raster_tasks,
204 unsigned num_image_decode_tasks, 205 const TileTask::Vector& image_decode_tasks,
205 RasterTaskVector* raster_tasks) { 206 RasterTaskVector* raster_tasks) {
206 const gfx::Size size(1, 1); 207 const gfx::Size size(1, 1);
207 208
208 for (unsigned i = 0; i < num_raster_tasks; ++i) { 209 for (unsigned i = 0; i < num_raster_tasks; ++i) {
209 TileTask::Vector image_decode_tasks;
210 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks);
211 std::unique_ptr<ScopedResource> resource( 210 std::unique_ptr<ScopedResource> resource(
212 ScopedResource::Create(resource_provider_.get())); 211 ScopedResource::Create(resource_provider_.get()));
213 resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, 212 resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE,
214 RGBA_8888); 213 RGBA_8888);
215 214
215 TileTask::Vector dependencies = image_decode_tasks;
216 raster_tasks->push_back( 216 raster_tasks->push_back(
217 new PerfRasterTaskImpl(std::move(resource), &image_decode_tasks)); 217 new PerfRasterTaskImpl(std::move(resource), &dependencies));
218 } 218 }
219 } 219 }
220 220
221 void BuildTileTaskGraph(TaskGraph* graph, 221 void BuildTileTaskGraph(TaskGraph* graph,
222 const RasterTaskVector& raster_tasks) { 222 const RasterTaskVector& raster_tasks) {
223 uint16_t priority = 0; 223 uint16_t priority = 0;
224 224
225 for (auto& raster_task : raster_tasks) { 225 for (auto& raster_task : raster_tasks) {
226 priority++; 226 priority++;
227 227
228 for (auto& decode_task : raster_task->dependencies()) { 228 for (auto& decode_task : raster_task->dependencies()) {
229 graph->nodes.push_back( 229 // Add decode task if it doesn't already exist in graph.
230 TaskGraph::Node(decode_task.get(), 0u /* group */, priority, 0u)); 230 TaskGraph::Node::Vector::iterator decode_it =
231 std::find_if(graph->nodes.begin(), graph->nodes.end(),
232 [decode_task](const TaskGraph::Node& node) {
233 return node.task == decode_task;
234 });
235
236 if (decode_it == graph->nodes.end()) {
237 graph->nodes.push_back(
238 TaskGraph::Node(decode_task.get(), 0u /* group */, priority, 0u));
239 }
240
231 graph->edges.push_back( 241 graph->edges.push_back(
232 TaskGraph::Edge(raster_task.get(), decode_task.get())); 242 TaskGraph::Edge(decode_task.get(), raster_task.get()));
233 } 243 }
234 244
235 graph->nodes.push_back(TaskGraph::Node( 245 graph->nodes.push_back(TaskGraph::Node(
236 raster_task.get(), 0u /* group */, priority, 246 raster_task.get(), 0u /* group */, priority,
237 static_cast<uint32_t>(raster_task->dependencies().size()))); 247 static_cast<uint32_t>(raster_task->dependencies().size())));
238 } 248 }
239 } 249 }
240 250
241 protected: 251 protected:
242 scoped_refptr<ContextProvider> context_provider_; 252 scoped_refptr<ContextProvider> context_provider_;
243 FakeOutputSurfaceClient output_surface_client_; 253 FakeOutputSurfaceClient output_surface_client_;
244 std::unique_ptr<FakeOutputSurface> output_surface_; 254 std::unique_ptr<FakeOutputSurface> output_surface_;
245 std::unique_ptr<ResourceProvider> resource_provider_; 255 std::unique_ptr<ResourceProvider> resource_provider_;
246 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 256 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
247 std::unique_ptr<SynchronousTaskGraphRunner> task_graph_runner_; 257 std::unique_ptr<SynchronousTaskGraphRunner> task_graph_runner_;
248 LapTimer timer_; 258 LapTimer timer_;
249 }; 259 };
250 260
251 class TileTaskWorkerPoolPerfTest 261 class RasterBufferProviderPerfTest
252 : public TileTaskWorkerPoolPerfTestBase, 262 : public RasterBufferProviderPerfTestBase,
253 public testing::TestWithParam<TileTaskWorkerPoolType> { 263 public testing::TestWithParam<RasterBufferProviderType> {
254 public: 264 public:
255 // Overridden from testing::Test: 265 // Overridden from testing::Test:
256 void SetUp() override { 266 void SetUp() override {
267 std::unique_ptr<RasterBufferProvider> raster_buffer_provider;
257 switch (GetParam()) { 268 switch (GetParam()) {
258 case TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY: 269 case RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY:
259 Create3dOutputSurfaceAndResourceProvider(); 270 Create3dOutputSurfaceAndResourceProvider();
260 tile_task_worker_pool_ = ZeroCopyTileTaskWorkerPool::Create( 271 raster_buffer_provider = ZeroCopyRasterBufferProvider::Create(
261 task_runner_.get(), task_graph_runner_.get(),
262 resource_provider_.get(), PlatformColor::BestTextureFormat()); 272 resource_provider_.get(), PlatformColor::BestTextureFormat());
263 break; 273 break;
264 case TILE_TASK_WORKER_POOL_TYPE_ONE_COPY: 274 case RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY:
265 Create3dOutputSurfaceAndResourceProvider(); 275 Create3dOutputSurfaceAndResourceProvider();
266 tile_task_worker_pool_ = OneCopyTileTaskWorkerPool::Create( 276 raster_buffer_provider = OneCopyRasterBufferProvider::Create(
267 task_runner_.get(), task_graph_runner_.get(), 277 task_runner_.get(), context_provider_.get(),
268 context_provider_.get(), resource_provider_.get(), 278 resource_provider_.get(), std::numeric_limits<int>::max(), false,
269 std::numeric_limits<int>::max(), false,
270 std::numeric_limits<int>::max(), 279 std::numeric_limits<int>::max(),
271 PlatformColor::BestTextureFormat()); 280 PlatformColor::BestTextureFormat());
272 break; 281 break;
273 case TILE_TASK_WORKER_POOL_TYPE_GPU: 282 case RASTER_BUFFER_PROVIDER_TYPE_GPU:
274 Create3dOutputSurfaceAndResourceProvider(); 283 Create3dOutputSurfaceAndResourceProvider();
275 tile_task_worker_pool_ = GpuTileTaskWorkerPool::Create( 284 raster_buffer_provider = GpuRasterBufferProvider::Create(
276 task_runner_.get(), task_graph_runner_.get(),
277 context_provider_.get(), resource_provider_.get(), false, 0); 285 context_provider_.get(), resource_provider_.get(), false, 0);
278 break; 286 break;
279 case TILE_TASK_WORKER_POOL_TYPE_BITMAP: 287 case RASTER_BUFFER_PROVIDER_TYPE_BITMAP:
280 CreateSoftwareOutputSurfaceAndResourceProvider(); 288 CreateSoftwareOutputSurfaceAndResourceProvider();
281 tile_task_worker_pool_ = BitmapTileTaskWorkerPool::Create( 289 raster_buffer_provider =
282 task_runner_.get(), task_graph_runner_.get(), 290 BitmapRasterBufferProvider::Create(resource_provider_.get());
283 resource_provider_.get());
284 break; 291 break;
285 } 292 }
286 293
287 DCHECK(tile_task_worker_pool_); 294 DCHECK(raster_buffer_provider);
295
296 tile_task_manager_ = TileTaskManagerImpl::Create(
297 std::move(raster_buffer_provider), task_graph_runner_.get());
288 } 298 }
289 void TearDown() override { 299 void TearDown() override {
290 tile_task_worker_pool_->Shutdown(); 300 tile_task_manager_->Shutdown();
291 tile_task_worker_pool_->CheckForCompletedTasks(); 301 tile_task_manager_->CheckForCompletedTasks();
292 } 302 }
293 303
294 void RunMessageLoopUntilAllTasksHaveCompleted() { 304 void RunMessageLoopUntilAllTasksHaveCompleted() {
295 task_graph_runner_->RunUntilIdle(); 305 task_graph_runner_->RunUntilIdle();
296 task_runner_->RunUntilIdle(); 306 task_runner_->RunUntilIdle();
297 } 307 }
298 308
299 void RunScheduleTasksTest(const std::string& test_name, 309 void RunScheduleTasksTest(const std::string& test_name,
300 unsigned num_raster_tasks, 310 unsigned num_raster_tasks,
301 unsigned num_image_decode_tasks) { 311 unsigned num_image_decode_tasks) {
312 TileTask::Vector image_decode_tasks;
302 RasterTaskVector raster_tasks; 313 RasterTaskVector raster_tasks;
303 CreateRasterTasks(num_raster_tasks, num_image_decode_tasks, &raster_tasks); 314 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks);
315 CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks);
304 316
305 // Avoid unnecessary heap allocations by reusing the same graph. 317 // Avoid unnecessary heap allocations by reusing the same graph.
306 TaskGraph graph; 318 TaskGraph graph;
307 319
308 timer_.Reset(); 320 timer_.Reset();
309 do { 321 do {
310 graph.Reset(); 322 graph.Reset();
311 BuildTileTaskGraph(&graph, raster_tasks); 323 BuildTileTaskGraph(&graph, raster_tasks);
312 tile_task_worker_pool_->ScheduleTasks(&graph); 324 tile_task_manager_->ScheduleTasks(&graph);
313 tile_task_worker_pool_->CheckForCompletedTasks(); 325 tile_task_manager_->CheckForCompletedTasks();
314 timer_.NextLap(); 326 timer_.NextLap();
315 } while (!timer_.HasTimeLimitExpired()); 327 } while (!timer_.HasTimeLimitExpired());
316 328
317 TaskGraph empty; 329 TaskGraph empty;
318 tile_task_worker_pool_->ScheduleTasks(&empty); 330 tile_task_manager_->ScheduleTasks(&empty);
319 RunMessageLoopUntilAllTasksHaveCompleted(); 331 RunMessageLoopUntilAllTasksHaveCompleted();
320 332
321 perf_test::PrintResult("schedule_tasks", TestModifierString(), test_name, 333 perf_test::PrintResult("schedule_tasks", TestModifierString(), test_name,
322 timer_.LapsPerSecond(), "runs/s", true); 334 timer_.LapsPerSecond(), "runs/s", true);
323 } 335 }
324 336
325 void RunScheduleAlternateTasksTest(const std::string& test_name, 337 void RunScheduleAlternateTasksTest(const std::string& test_name,
326 unsigned num_raster_tasks, 338 unsigned num_raster_tasks,
327 unsigned num_image_decode_tasks) { 339 unsigned num_image_decode_tasks) {
328 const size_t kNumVersions = 2; 340 const size_t kNumVersions = 2;
341 TileTask::Vector image_decode_tasks[kNumVersions];
329 RasterTaskVector raster_tasks[kNumVersions]; 342 RasterTaskVector raster_tasks[kNumVersions];
330 for (size_t i = 0; i < kNumVersions; ++i) { 343 for (size_t i = 0; i < kNumVersions; ++i) {
331 CreateRasterTasks(num_raster_tasks, num_image_decode_tasks, 344 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks[i]);
345 CreateRasterTasks(num_raster_tasks, image_decode_tasks[i],
332 &raster_tasks[i]); 346 &raster_tasks[i]);
333 } 347 }
334 348
335 // Avoid unnecessary heap allocations by reusing the same graph. 349 // Avoid unnecessary heap allocations by reusing the same graph.
336 TaskGraph graph; 350 TaskGraph graph;
337 351
338 size_t count = 0; 352 size_t count = 0;
339 timer_.Reset(); 353 timer_.Reset();
340 do { 354 do {
341 graph.Reset(); 355 graph.Reset();
342 BuildTileTaskGraph(&graph, raster_tasks[count % kNumVersions]); 356 BuildTileTaskGraph(&graph, raster_tasks[count % kNumVersions]);
343 tile_task_worker_pool_->ScheduleTasks(&graph); 357 tile_task_manager_->ScheduleTasks(&graph);
344 tile_task_worker_pool_->CheckForCompletedTasks(); 358 tile_task_manager_->CheckForCompletedTasks();
345 ++count; 359 ++count;
346 timer_.NextLap(); 360 timer_.NextLap();
347 } while (!timer_.HasTimeLimitExpired()); 361 } while (!timer_.HasTimeLimitExpired());
348 362
349 TaskGraph empty; 363 TaskGraph empty;
350 tile_task_worker_pool_->ScheduleTasks(&empty); 364 tile_task_manager_->ScheduleTasks(&empty);
351 RunMessageLoopUntilAllTasksHaveCompleted(); 365 RunMessageLoopUntilAllTasksHaveCompleted();
352 366
353 perf_test::PrintResult("schedule_alternate_tasks", TestModifierString(), 367 perf_test::PrintResult("schedule_alternate_tasks", TestModifierString(),
354 test_name, timer_.LapsPerSecond(), "runs/s", true); 368 test_name, timer_.LapsPerSecond(), "runs/s", true);
355 } 369 }
356 370
357 void RunScheduleAndExecuteTasksTest(const std::string& test_name, 371 void RunScheduleAndExecuteTasksTest(const std::string& test_name,
358 unsigned num_raster_tasks, 372 unsigned num_raster_tasks,
359 unsigned num_image_decode_tasks) { 373 unsigned num_image_decode_tasks) {
374 TileTask::Vector image_decode_tasks;
360 RasterTaskVector raster_tasks; 375 RasterTaskVector raster_tasks;
361 CreateRasterTasks(num_raster_tasks, num_image_decode_tasks, &raster_tasks); 376 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks);
377 CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks);
362 378
363 // Avoid unnecessary heap allocations by reusing the same graph. 379 // Avoid unnecessary heap allocations by reusing the same graph.
364 TaskGraph graph; 380 TaskGraph graph;
365 381
366 timer_.Reset(); 382 timer_.Reset();
367 do { 383 do {
368 graph.Reset(); 384 graph.Reset();
369 BuildTileTaskGraph(&graph, raster_tasks); 385 BuildTileTaskGraph(&graph, raster_tasks);
370 tile_task_worker_pool_->ScheduleTasks(&graph); 386 tile_task_manager_->ScheduleTasks(&graph);
371 RunMessageLoopUntilAllTasksHaveCompleted(); 387 RunMessageLoopUntilAllTasksHaveCompleted();
372 timer_.NextLap(); 388 timer_.NextLap();
373 } while (!timer_.HasTimeLimitExpired()); 389 } while (!timer_.HasTimeLimitExpired());
374 390
375 TaskGraph empty; 391 TaskGraph empty;
376 tile_task_worker_pool_->ScheduleTasks(&empty); 392 tile_task_manager_->ScheduleTasks(&empty);
377 RunMessageLoopUntilAllTasksHaveCompleted(); 393 RunMessageLoopUntilAllTasksHaveCompleted();
378 394
379 perf_test::PrintResult("schedule_and_execute_tasks", TestModifierString(), 395 perf_test::PrintResult("schedule_and_execute_tasks", TestModifierString(),
380 test_name, timer_.LapsPerSecond(), "runs/s", true); 396 test_name, timer_.LapsPerSecond(), "runs/s", true);
381 } 397 }
382 398
383 private: 399 private:
384 void Create3dOutputSurfaceAndResourceProvider() { 400 void Create3dOutputSurfaceAndResourceProvider() {
385 output_surface_ = FakeOutputSurface::Create3d(context_provider_); 401 output_surface_ = FakeOutputSurface::Create3d(context_provider_);
386 CHECK(output_surface_->BindToClient(&output_surface_client_)); 402 CHECK(output_surface_->BindToClient(&output_surface_client_));
387 resource_provider_ = FakeResourceProvider::Create( 403 resource_provider_ = FakeResourceProvider::Create(
388 output_surface_.get(), nullptr, &gpu_memory_buffer_manager_); 404 output_surface_.get(), nullptr, &gpu_memory_buffer_manager_);
389 } 405 }
390 406
391 void CreateSoftwareOutputSurfaceAndResourceProvider() { 407 void CreateSoftwareOutputSurfaceAndResourceProvider() {
392 output_surface_ = FakeOutputSurface::CreateSoftware( 408 output_surface_ = FakeOutputSurface::CreateSoftware(
393 base::WrapUnique(new SoftwareOutputDevice)); 409 base::WrapUnique(new SoftwareOutputDevice));
394 CHECK(output_surface_->BindToClient(&output_surface_client_)); 410 CHECK(output_surface_->BindToClient(&output_surface_client_));
395 resource_provider_ = FakeResourceProvider::Create( 411 resource_provider_ = FakeResourceProvider::Create(
396 output_surface_.get(), &shared_bitmap_manager_, nullptr); 412 output_surface_.get(), &shared_bitmap_manager_, nullptr);
397 } 413 }
398 414
399 std::string TestModifierString() const { 415 std::string TestModifierString() const {
400 switch (GetParam()) { 416 switch (GetParam()) {
401 case TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY: 417 case RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY:
402 return std::string("_zero_copy_tile_task_worker_pool"); 418 return std::string("_zero_copy_raster_buffer_provider");
403 case TILE_TASK_WORKER_POOL_TYPE_ONE_COPY: 419 case RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY:
404 return std::string("_one_copy_tile_task_worker_pool"); 420 return std::string("_one_copy_raster_buffer_provider");
405 case TILE_TASK_WORKER_POOL_TYPE_GPU: 421 case RASTER_BUFFER_PROVIDER_TYPE_GPU:
406 return std::string("_gpu_tile_task_worker_pool"); 422 return std::string("_gpu_raster_buffer_provider");
407 case TILE_TASK_WORKER_POOL_TYPE_BITMAP: 423 case RASTER_BUFFER_PROVIDER_TYPE_BITMAP:
408 return std::string("_bitmap_tile_task_worker_pool"); 424 return std::string("_bitmap_raster_buffer_provider");
409 } 425 }
410 NOTREACHED(); 426 NOTREACHED();
411 return std::string(); 427 return std::string();
412 } 428 }
413 429
414 std::unique_ptr<TileTaskWorkerPool> tile_task_worker_pool_; 430 std::unique_ptr<TileTaskManager> tile_task_manager_;
415 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; 431 TestGpuMemoryBufferManager gpu_memory_buffer_manager_;
416 TestSharedBitmapManager shared_bitmap_manager_; 432 TestSharedBitmapManager shared_bitmap_manager_;
417 }; 433 };
418 434
419 TEST_P(TileTaskWorkerPoolPerfTest, ScheduleTasks) { 435 TEST_P(RasterBufferProviderPerfTest, ScheduleTasks) {
420 RunScheduleTasksTest("1_0", 1, 0); 436 RunScheduleTasksTest("1_0", 1, 0);
421 RunScheduleTasksTest("32_0", 32, 0); 437 RunScheduleTasksTest("32_0", 32, 0);
422 RunScheduleTasksTest("1_1", 1, 1); 438 RunScheduleTasksTest("1_1", 1, 1);
423 RunScheduleTasksTest("32_1", 32, 1); 439 RunScheduleTasksTest("32_1", 32, 1);
424 RunScheduleTasksTest("1_4", 1, 4); 440 RunScheduleTasksTest("1_4", 1, 4);
425 RunScheduleTasksTest("32_4", 32, 4); 441 RunScheduleTasksTest("32_4", 32, 4);
426 } 442 }
427 443
428 TEST_P(TileTaskWorkerPoolPerfTest, ScheduleAlternateTasks) { 444 TEST_P(RasterBufferProviderPerfTest, ScheduleAlternateTasks) {
429 RunScheduleAlternateTasksTest("1_0", 1, 0); 445 RunScheduleAlternateTasksTest("1_0", 1, 0);
430 RunScheduleAlternateTasksTest("32_0", 32, 0); 446 RunScheduleAlternateTasksTest("32_0", 32, 0);
431 RunScheduleAlternateTasksTest("1_1", 1, 1); 447 RunScheduleAlternateTasksTest("1_1", 1, 1);
432 RunScheduleAlternateTasksTest("32_1", 32, 1); 448 RunScheduleAlternateTasksTest("32_1", 32, 1);
433 RunScheduleAlternateTasksTest("1_4", 1, 4); 449 RunScheduleAlternateTasksTest("1_4", 1, 4);
434 RunScheduleAlternateTasksTest("32_4", 32, 4); 450 RunScheduleAlternateTasksTest("32_4", 32, 4);
435 } 451 }
436 452
437 TEST_P(TileTaskWorkerPoolPerfTest, ScheduleAndExecuteTasks) { 453 TEST_P(RasterBufferProviderPerfTest, ScheduleAndExecuteTasks) {
438 RunScheduleAndExecuteTasksTest("1_0", 1, 0); 454 RunScheduleAndExecuteTasksTest("1_0", 1, 0);
439 RunScheduleAndExecuteTasksTest("32_0", 32, 0); 455 RunScheduleAndExecuteTasksTest("32_0", 32, 0);
440 RunScheduleAndExecuteTasksTest("1_1", 1, 1); 456 RunScheduleAndExecuteTasksTest("1_1", 1, 1);
441 RunScheduleAndExecuteTasksTest("32_1", 32, 1); 457 RunScheduleAndExecuteTasksTest("32_1", 32, 1);
442 RunScheduleAndExecuteTasksTest("1_4", 1, 4); 458 RunScheduleAndExecuteTasksTest("1_4", 1, 4);
443 RunScheduleAndExecuteTasksTest("32_4", 32, 4); 459 RunScheduleAndExecuteTasksTest("32_4", 32, 4);
444 } 460 }
445 461
446 INSTANTIATE_TEST_CASE_P(TileTaskWorkerPoolPerfTests, 462 INSTANTIATE_TEST_CASE_P(RasterBufferProviderPerfTests,
447 TileTaskWorkerPoolPerfTest, 463 RasterBufferProviderPerfTest,
448 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, 464 ::testing::Values(RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY,
449 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, 465 RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY,
450 TILE_TASK_WORKER_POOL_TYPE_GPU, 466 RASTER_BUFFER_PROVIDER_TYPE_GPU,
451 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); 467 RASTER_BUFFER_PROVIDER_TYPE_BITMAP));
452 468
453 class TileTaskWorkerPoolCommonPerfTest : public TileTaskWorkerPoolPerfTestBase, 469 class RasterBufferProviderCommonPerfTest
454 public testing::Test { 470 : public RasterBufferProviderPerfTestBase,
471 public testing::Test {
455 public: 472 public:
456 // Overridden from testing::Test: 473 // Overridden from testing::Test:
457 void SetUp() override { 474 void SetUp() override {
458 output_surface_ = FakeOutputSurface::Create3d(context_provider_); 475 output_surface_ = FakeOutputSurface::Create3d(context_provider_);
459 CHECK(output_surface_->BindToClient(&output_surface_client_)); 476 CHECK(output_surface_->BindToClient(&output_surface_client_));
460 resource_provider_ = 477 resource_provider_ =
461 FakeResourceProvider::Create(output_surface_.get(), nullptr); 478 FakeResourceProvider::Create(output_surface_.get(), nullptr);
462 } 479 }
463 480
464 void RunBuildTileTaskGraphTest(const std::string& test_name, 481 void RunBuildTileTaskGraphTest(const std::string& test_name,
465 unsigned num_raster_tasks, 482 unsigned num_raster_tasks,
466 unsigned num_image_decode_tasks) { 483 unsigned num_image_decode_tasks) {
484 TileTask::Vector image_decode_tasks;
467 RasterTaskVector raster_tasks; 485 RasterTaskVector raster_tasks;
468 CreateRasterTasks(num_raster_tasks, num_image_decode_tasks, &raster_tasks); 486 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks);
487 CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks);
469 488
470 // Avoid unnecessary heap allocations by reusing the same graph. 489 // Avoid unnecessary heap allocations by reusing the same graph.
471 TaskGraph graph; 490 TaskGraph graph;
472 491
473 timer_.Reset(); 492 timer_.Reset();
474 do { 493 do {
475 graph.Reset(); 494 graph.Reset();
476 BuildTileTaskGraph(&graph, raster_tasks); 495 BuildTileTaskGraph(&graph, raster_tasks);
477 timer_.NextLap(); 496 timer_.NextLap();
478 } while (!timer_.HasTimeLimitExpired()); 497 } while (!timer_.HasTimeLimitExpired());
479 498
480 perf_test::PrintResult("build_raster_task_graph", "", test_name, 499 perf_test::PrintResult("build_raster_task_graph", "", test_name,
481 timer_.LapsPerSecond(), "runs/s", true); 500 timer_.LapsPerSecond(), "runs/s", true);
482 } 501 }
483 }; 502 };
484 503
485 TEST_F(TileTaskWorkerPoolCommonPerfTest, BuildTileTaskGraph) { 504 TEST_F(RasterBufferProviderCommonPerfTest, BuildTileTaskGraph) {
486 RunBuildTileTaskGraphTest("1_0", 1, 0); 505 RunBuildTileTaskGraphTest("1_0", 1, 0);
487 RunBuildTileTaskGraphTest("32_0", 32, 0); 506 RunBuildTileTaskGraphTest("32_0", 32, 0);
488 RunBuildTileTaskGraphTest("1_1", 1, 1); 507 RunBuildTileTaskGraphTest("1_1", 1, 1);
489 RunBuildTileTaskGraphTest("32_1", 32, 1); 508 RunBuildTileTaskGraphTest("32_1", 32, 1);
490 RunBuildTileTaskGraphTest("1_4", 1, 4); 509 RunBuildTileTaskGraphTest("1_4", 1, 4);
491 RunBuildTileTaskGraphTest("32_4", 32, 4); 510 RunBuildTileTaskGraphTest("32_4", 32, 4);
492 } 511 }
493 512
494 } // namespace 513 } // namespace
495 } // namespace cc 514 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/raster_buffer_provider.cc ('k') | cc/raster/raster_buffer_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698