OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/output/direct_renderer.h" | 5 #include "cc/output/direct_renderer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 enlarge_pass_texture_amount_.y()); | 409 enlarge_pass_texture_amount_.y()); |
410 if (!texture->id()) | 410 if (!texture->id()) |
411 texture->Allocate( | 411 texture->Allocate( |
412 size, ResourceProvider::TextureUsageFramebuffer, RGBA_8888); | 412 size, ResourceProvider::TextureUsageFramebuffer, RGBA_8888); |
413 DCHECK(texture->id()); | 413 DCHECK(texture->id()); |
414 | 414 |
415 return BindFramebufferToTexture(frame, texture, render_pass->output_rect); | 415 return BindFramebufferToTexture(frame, texture, render_pass->output_rect); |
416 } | 416 } |
417 | 417 |
418 void DirectRenderer::RunOnDemandRasterTask(Task* on_demand_raster_task) { | 418 void DirectRenderer::RunOnDemandRasterTask(Task* on_demand_raster_task) { |
419 TaskGraphRunner* task_graph_runner = RasterWorkerPool::GetTaskGraphRunner(); | 419 client_->RunOnDemandRasterTask(on_demand_raster_task); |
420 DCHECK(task_graph_runner); | |
421 | |
422 // Make sure we have a unique task namespace token. | |
423 if (!on_demand_task_namespace_.IsValid()) | |
424 on_demand_task_namespace_ = task_graph_runner->GetNamespaceToken(); | |
425 | |
426 // Construct a task graph that contains this single raster task. | |
427 TaskGraph graph; | |
428 graph.nodes.push_back( | |
429 TaskGraph::Node(on_demand_raster_task, | |
430 RasterWorkerPool::kOnDemandRasterTaskPriority, | |
431 0u)); | |
432 | |
433 // Schedule task and wait for task graph runner to finish running it. | |
434 task_graph_runner->ScheduleTasks(on_demand_task_namespace_, &graph); | |
435 task_graph_runner->WaitForTasksToFinishRunning(on_demand_task_namespace_); | |
436 | |
437 // Collect task now that it has finished running. | |
438 Task::Vector completed_tasks; | |
439 task_graph_runner->CollectCompletedTasks(on_demand_task_namespace_, | |
440 &completed_tasks); | |
441 DCHECK_EQ(1u, completed_tasks.size()); | |
442 DCHECK_EQ(completed_tasks[0], on_demand_raster_task); | |
443 } | 420 } |
444 | 421 |
445 bool DirectRenderer::HasAllocatedResourcesForTesting(RenderPass::Id id) | 422 bool DirectRenderer::HasAllocatedResourcesForTesting(RenderPass::Id id) |
446 const { | 423 const { |
447 ScopedResource* texture = render_pass_textures_.get(id); | 424 ScopedResource* texture = render_pass_textures_.get(id); |
448 return texture && texture->id(); | 425 return texture && texture->id(); |
449 } | 426 } |
450 | 427 |
451 // static | 428 // static |
452 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 429 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
453 return render_pass->output_rect.size(); | 430 return render_pass->output_rect.size(); |
454 } | 431 } |
455 | 432 |
456 } // namespace cc | 433 } // namespace cc |
OLD | NEW |