#include "cc/base/math_util.h"
#include "cc/output/copy_output_request.h"
#include "cc/quads/draw_quad.h"
+#include "cc/resources/raster_worker_pool.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/transform.h"
void DirectRenderer::InitializeViewport(DrawingFrame* frame,
const gfx::Rect& draw_rect,
const gfx::Rect& viewport_rect,
- gfx::Size surface_size) {
+ const gfx::Size& surface_size) {
bool flip_y = FlippedFramebuffer();
DCHECK_GE(viewport_rect.x(), 0);
bool DirectRenderer::CanReadPixels() const { return true; }
void DirectRenderer::SetEnlargePassTextureAmountForTesting(
- gfx::Vector2d amount) {
+ const gfx::Vector2d& amount) {
enlarge_pass_texture_amount_ = amount;
}
const DrawingFrame* frame) {
gfx::RectF render_pass_scissor = frame->current_render_pass->output_rect;
- if (frame->root_damage_rect == frame->root_render_pass->output_rect)
+ if (frame->root_damage_rect == frame->root_render_pass->output_rect ||
+ !frame->current_render_pass->copy_requests.empty())
return render_pass_scissor;
gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization);
return BindFramebufferToTexture(frame, texture, render_pass->output_rect);
}
+void DirectRenderer::RunOnDemandRasterTask(
+ internal::Task* on_demand_raster_task) {
+ internal::TaskGraphRunner* task_graph_runner =
+ RasterWorkerPool::GetTaskGraphRunner();
+ DCHECK(task_graph_runner);
+
+ // Make sure we have a unique task namespace token.
+ if (!on_demand_task_namespace_.IsValid())
+ on_demand_task_namespace_ = task_graph_runner->GetNamespaceToken();
+
+ // Construct a task graph that contains this single raster task.
+ internal::TaskGraph graph;
+ graph.nodes.push_back(
+ internal::TaskGraph::Node(on_demand_raster_task,
+ RasterWorkerPool::kOnDemandRasterTaskPriority,
+ 0u));
+
+ // Schedule task and wait for task graph runner to finish running it.
+ task_graph_runner->SetTaskGraph(on_demand_task_namespace_, &graph);
+ task_graph_runner->WaitForTasksToFinishRunning(on_demand_task_namespace_);
+
+ // Collect task now that it has finished running.
+ internal::Task::Vector completed_tasks;
+ task_graph_runner->CollectCompletedTasks(on_demand_task_namespace_,
+ &completed_tasks);
+ DCHECK_EQ(1u, completed_tasks.size());
+ DCHECK_EQ(completed_tasks[0], on_demand_raster_task);
+}
+
bool DirectRenderer::HasAllocatedResourcesForTesting(RenderPass::Id id)
const {
ScopedResource* texture = render_pass_textures_.get(id);