Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / cc / output / direct_renderer.cc
index 0eb2dcb..ad39f1a 100644 (file)
@@ -14,8 +14,7 @@
 #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/geometry/rect_conversions.h"
 #include "ui/gfx/transform.h"
 
 static gfx::Transform OrthoProjectionMatrix(float left,
@@ -58,10 +57,8 @@ static gfx::Transform window_matrix(int x, int y, int width, int height) {
 namespace cc {
 
 DirectRenderer::DrawingFrame::DrawingFrame()
-    : root_render_pass(NULL),
-      current_render_pass(NULL),
-      current_texture(NULL),
-      offscreen_context_provider(NULL) {}
+    : root_render_pass(NULL), current_render_pass(NULL), current_texture(NULL) {
+}
 
 DirectRenderer::DrawingFrame::~DrawingFrame() {}
 
@@ -118,8 +115,8 @@ void DirectRenderer::InitializeViewport(DrawingFrame* frame,
 }
 
 gfx::Rect DirectRenderer::MoveFromDrawToWindowSpace(
-    const gfx::RectF& draw_rect) const {
-  gfx::Rect window_rect = gfx::ToEnclosingRect(draw_rect);
+    const gfx::Rect& draw_rect) const {
+  gfx::Rect window_rect = draw_rect;
   window_rect -= current_draw_rect_.OffsetFromOrigin();
   window_rect += current_viewport_rect_.OffsetFromOrigin();
   if (FlippedFramebuffer())
@@ -141,8 +138,6 @@ DirectRenderer::DirectRenderer(RendererClient* client,
 
 DirectRenderer::~DirectRenderer() {}
 
-bool DirectRenderer::CanReadPixels() const { return true; }
-
 void DirectRenderer::SetEnlargePassTextureAmountForTesting(
     const gfx::Vector2d& amount) {
   enlarge_pass_texture_amount_ = amount;
@@ -153,19 +148,19 @@ void DirectRenderer::DecideRenderPassAllocationsForFrame(
   if (!resource_provider_)
     return;
 
-  base::hash_map<RenderPass::Id, gfx::Size> render_passes_in_frame;
+  base::hash_map<RenderPassId, gfx::Size> render_passes_in_frame;
   for (size_t i = 0; i < render_passes_in_draw_order.size(); ++i)
-    render_passes_in_frame.insert(std::pair<RenderPass::Id, gfx::Size>(
+    render_passes_in_frame.insert(std::pair<RenderPassId, gfx::Size>(
         render_passes_in_draw_order[i]->id,
         RenderPassTextureSize(render_passes_in_draw_order[i])));
 
-  std::vector<RenderPass::Id> passes_to_delete;
-  base::ScopedPtrHashMap<RenderPass::Id, ScopedResource>::const_iterator
+  std::vector<RenderPassId> passes_to_delete;
+  base::ScopedPtrHashMap<RenderPassId, ScopedResource>::const_iterator
       pass_iter;
   for (pass_iter = render_pass_textures_.begin();
        pass_iter != render_pass_textures_.end();
        ++pass_iter) {
-    base::hash_map<RenderPass::Id, gfx::Size>::const_iterator it =
+    base::hash_map<RenderPassId, gfx::Size>::const_iterator it =
         render_passes_in_frame.find(pass_iter->first);
     if (it == render_passes_in_frame.end()) {
       passes_to_delete.push_back(pass_iter->first);
@@ -198,7 +193,6 @@ void DirectRenderer::DecideRenderPassAllocationsForFrame(
 }
 
 void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
-                               ContextProvider* offscreen_context_provider,
                                float device_scale_factor,
                                const gfx::Rect& device_viewport_rect,
                                const gfx::Rect& device_clip_rect,
@@ -211,6 +205,7 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
   DCHECK(root_render_pass);
 
   DrawingFrame frame;
+  frame.render_passes_in_draw_order = render_passes_in_draw_order;
   frame.root_render_pass = root_render_pass;
   frame.root_damage_rect = Capabilities().using_partial_swap
                                ? root_render_pass->damage_rect
@@ -218,7 +213,6 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
   frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_rect.size()));
   frame.device_viewport_rect = device_viewport_rect;
   frame.device_clip_rect = device_clip_rect;
-  frame.offscreen_context_provider = offscreen_context_provider;
   frame.disable_picture_quad_image_filtering =
       disable_picture_quad_image_filtering;
 
@@ -254,9 +248,9 @@ void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order,
   render_passes_in_draw_order->clear();
 }
 
-gfx::RectF DirectRenderer::ComputeScissorRectForRenderPass(
+gfx::Rect DirectRenderer::ComputeScissorRectForRenderPass(
     const DrawingFrame* frame) {
-  gfx::RectF render_pass_scissor = frame->current_render_pass->output_rect;
+  gfx::Rect render_pass_scissor = frame->current_render_pass->output_rect;
 
   if (frame->root_damage_rect == frame->root_render_pass->output_rect ||
       !frame->current_render_pass->copy_requests.empty())
@@ -266,9 +260,9 @@ gfx::RectF DirectRenderer::ComputeScissorRectForRenderPass(
   if (frame->current_render_pass->transform_to_root_target.GetInverse(
           &inverse_transform)) {
     // Only intersect inverse-projected damage if the transform is invertible.
-    gfx::RectF damage_rect_in_render_pass_space =
-        MathUtil::ProjectClippedRect(inverse_transform,
-                                     frame->root_damage_rect);
+    gfx::Rect damage_rect_in_render_pass_space =
+        MathUtil::ProjectEnclosingClippedRect(inverse_transform,
+                                              frame->root_damage_rect);
     render_pass_scissor.Intersect(damage_rect_in_render_pass_space);
   }
 
@@ -308,9 +302,9 @@ void DirectRenderer::SetScissorStateForQuad(const DrawingFrame* frame,
 void DirectRenderer::SetScissorStateForQuadWithRenderPassScissor(
     const DrawingFrame* frame,
     const DrawQuad& quad,
-    const gfx::RectF& render_pass_scissor,
+    const gfx::Rect& render_pass_scissor,
     bool* should_skip_quad) {
-  gfx::RectF quad_scissor_rect = render_pass_scissor;
+  gfx::Rect quad_scissor_rect = render_pass_scissor;
 
   if (quad.isClipped())
     quad_scissor_rect.Intersect(quad.clipRect());
@@ -326,7 +320,7 @@ void DirectRenderer::SetScissorStateForQuadWithRenderPassScissor(
 
 void DirectRenderer::SetScissorTestRectInDrawSpace(
     const DrawingFrame* frame,
-    const gfx::RectF& draw_space_rect) {
+    const gfx::Rect& draw_space_rect) {
   gfx::Rect window_space_rect = MoveFromDrawToWindowSpace(draw_space_rect);
   if (NeedDeviceClip(frame))
     window_space_rect.Intersect(DeviceClipRectInWindowSpace(frame));
@@ -342,7 +336,7 @@ void DirectRenderer::DrawRenderPass(DrawingFrame* frame,
     return;
 
   bool using_scissor_as_optimization = Capabilities().using_partial_swap;
-  gfx::RectF render_pass_scissor;
+  gfx::Rect render_pass_scissor;
   bool draw_rect_covers_full_surface = true;
   if (frame->current_render_pass == frame->root_render_pass &&
       !frame->device_viewport_rect.Contains(
@@ -377,7 +371,7 @@ void DirectRenderer::DrawRenderPass(DrawingFrame* frame,
   for (QuadList::ConstBackToFrontIterator it = quad_list.BackToFrontBegin();
        it != quad_list.BackToFrontEnd();
        ++it) {
-    const DrawQuad& quad = *(*it);
+    const DrawQuad& quad = *it;
     bool should_skip_quad = false;
 
     if (using_scissor_as_optimization) {
@@ -388,7 +382,7 @@ void DirectRenderer::DrawRenderPass(DrawingFrame* frame,
     }
 
     if (!should_skip_quad)
-      DoDrawQuad(frame, *it);
+      DoDrawQuad(frame, &quad);
   }
   FinishDrawingQuadList();
 }
@@ -415,43 +409,13 @@ bool DirectRenderer::UseRenderPass(DrawingFrame* frame,
                enlarge_pass_texture_amount_.y());
   if (!texture->id())
     texture->Allocate(
-        size, ResourceProvider::TextureUsageFramebuffer, RGBA_8888);
+        size, ResourceProvider::TextureHintImmutableFramebuffer, RGBA_8888);
   DCHECK(texture->id());
 
   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->ScheduleTasks(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 {
+bool DirectRenderer::HasAllocatedResourcesForTesting(RenderPassId id) const {
   ScopedResource* texture = render_pass_textures_.get(id);
   return texture && texture->id();
 }