| 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" |
| 11 #include "base/containers/scoped_ptr_hash_map.h" | 11 #include "base/containers/scoped_ptr_hash_map.h" |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "cc/base/math_util.h" | 14 #include "cc/base/math_util.h" |
| 15 #include "cc/output/copy_output_request.h" | 15 #include "cc/output/copy_output_request.h" |
| 16 #include "cc/quads/draw_quad.h" | 16 #include "cc/quads/draw_quad.h" |
| 17 #include "cc/quads/texture_draw_quad.h" |
| 17 #include "ui/gfx/geometry/rect_conversions.h" | 18 #include "ui/gfx/geometry/rect_conversions.h" |
| 18 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 19 | 20 |
| 20 static gfx::Transform OrthoProjectionMatrix(float left, | 21 static gfx::Transform OrthoProjectionMatrix(float left, |
| 21 float right, | 22 float right, |
| 22 float bottom, | 23 float bottom, |
| 23 float top) { | 24 float top) { |
| 24 // Use the standard formula to map the clipping frustum to the cube from | 25 // Use the standard formula to map the clipping frustum to the cube from |
| 25 // [-1, -1, -1] to [1, 1, 1]. | 26 // [-1, -1, -1] to [1, 1, 1]. |
| 26 float delta_x = right - left; | 27 float delta_x = right - left; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 127 |
| 127 DirectRenderer::DirectRenderer(RendererClient* client, | 128 DirectRenderer::DirectRenderer(RendererClient* client, |
| 128 const LayerTreeSettings* settings, | 129 const LayerTreeSettings* settings, |
| 129 OutputSurface* output_surface, | 130 OutputSurface* output_surface, |
| 130 ResourceProvider* resource_provider) | 131 ResourceProvider* resource_provider) |
| 131 : Renderer(client, settings), | 132 : Renderer(client, settings), |
| 132 output_surface_(output_surface), | 133 output_surface_(output_surface), |
| 133 resource_provider_(resource_provider), | 134 resource_provider_(resource_provider), |
| 134 overlay_processor_( | 135 overlay_processor_( |
| 135 new OverlayProcessor(output_surface, resource_provider)) { | 136 new OverlayProcessor(output_surface, resource_provider)) { |
| 137 //printf("DirectRenderer %p\n", this); |
| 136 overlay_processor_->Initialize(); | 138 overlay_processor_->Initialize(); |
| 137 } | 139 } |
| 138 | 140 |
| 139 DirectRenderer::~DirectRenderer() {} | 141 DirectRenderer::~DirectRenderer() {} |
| 140 | 142 |
| 141 void DirectRenderer::SetEnlargePassTextureAmountForTesting( | 143 void DirectRenderer::SetEnlargePassTextureAmountForTesting( |
| 142 const gfx::Vector2d& amount) { | 144 const gfx::Vector2d& amount) { |
| 143 enlarge_pass_texture_amount_ = amount; | 145 enlarge_pass_texture_amount_ = amount; |
| 144 } | 146 } |
| 145 | 147 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 texture.Pass()); | 192 texture.Pass()); |
| 191 } | 193 } |
| 192 } | 194 } |
| 193 } | 195 } |
| 194 | 196 |
| 195 void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, | 197 void DirectRenderer::DrawFrame(RenderPassList* render_passes_in_draw_order, |
| 196 float device_scale_factor, | 198 float device_scale_factor, |
| 197 const gfx::Rect& device_viewport_rect, | 199 const gfx::Rect& device_viewport_rect, |
| 198 const gfx::Rect& device_clip_rect, | 200 const gfx::Rect& device_clip_rect, |
| 199 bool disable_picture_quad_image_filtering) { | 201 bool disable_picture_quad_image_filtering) { |
| 202 /*for (auto* render_pass : *render_passes_in_draw_order) { |
| 203 for (auto& quad : render_pass->quad_list) { |
| 204 if (quad.material == DrawQuad::TEXTURE_CONTENT) { |
| 205 TextureDrawQuad& tq = static_cast<TextureDrawQuad&>(quad); |
| 206 printf("DirectRenderer::DrawFrame texture quad %d %d\n", tq.nearest_neig
hbor, tq.resource_id); |
| 207 } |
| 208 } |
| 209 }*/ |
| 200 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame"); | 210 TRACE_EVENT0("cc", "DirectRenderer::DrawFrame"); |
| 201 UMA_HISTOGRAM_COUNTS("Renderer4.renderPassCount", | 211 UMA_HISTOGRAM_COUNTS("Renderer4.renderPassCount", |
| 202 render_passes_in_draw_order->size()); | 212 render_passes_in_draw_order->size()); |
| 203 | 213 |
| 204 const RenderPass* root_render_pass = render_passes_in_draw_order->back(); | 214 const RenderPass* root_render_pass = render_passes_in_draw_order->back(); |
| 205 DCHECK(root_render_pass); | 215 DCHECK(root_render_pass); |
| 206 | 216 |
| 207 DrawingFrame frame; | 217 DrawingFrame frame; |
| 208 frame.render_passes_in_draw_order = render_passes_in_draw_order; | 218 frame.render_passes_in_draw_order = render_passes_in_draw_order; |
| 209 frame.root_render_pass = root_render_pass; | 219 frame.root_render_pass = root_render_pass; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 const DrawQuad& quad = *it; | 384 const DrawQuad& quad = *it; |
| 375 bool should_skip_quad = false; | 385 bool should_skip_quad = false; |
| 376 | 386 |
| 377 if (using_scissor_as_optimization) { | 387 if (using_scissor_as_optimization) { |
| 378 SetScissorStateForQuadWithRenderPassScissor( | 388 SetScissorStateForQuadWithRenderPassScissor( |
| 379 frame, quad, render_pass_scissor, &should_skip_quad); | 389 frame, quad, render_pass_scissor, &should_skip_quad); |
| 380 } else { | 390 } else { |
| 381 SetScissorStateForQuad(frame, quad); | 391 SetScissorStateForQuad(frame, quad); |
| 382 } | 392 } |
| 383 | 393 |
| 394 /*if (quad.material == DrawQuad::TEXTURE_CONTENT) { |
| 395 const TextureDrawQuad& tquad = static_cast<const TextureDrawQuad&>(quad); |
| 396 printf("DirectRenderer::DrawRenderPass %d %d\n", tquad.nearest_neighbor, t
quad.resource_id); |
| 397 }*/ |
| 384 if (!should_skip_quad) | 398 if (!should_skip_quad) |
| 385 DoDrawQuad(frame, &quad); | 399 DoDrawQuad(frame, &quad); |
| 386 } | 400 } |
| 387 FinishDrawingQuadList(); | 401 FinishDrawingQuadList(); |
| 388 } | 402 } |
| 389 | 403 |
| 390 bool DirectRenderer::UseRenderPass(DrawingFrame* frame, | 404 bool DirectRenderer::UseRenderPass(DrawingFrame* frame, |
| 391 const RenderPass* render_pass) { | 405 const RenderPass* render_pass) { |
| 392 frame->current_render_pass = render_pass; | 406 frame->current_render_pass = render_pass; |
| 393 frame->current_texture = NULL; | 407 frame->current_texture = NULL; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 419 ScopedResource* texture = render_pass_textures_.get(id); | 433 ScopedResource* texture = render_pass_textures_.get(id); |
| 420 return texture && texture->id(); | 434 return texture && texture->id(); |
| 421 } | 435 } |
| 422 | 436 |
| 423 // static | 437 // static |
| 424 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 438 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
| 425 return render_pass->output_rect.size(); | 439 return render_pass->output_rect.size(); |
| 426 } | 440 } |
| 427 | 441 |
| 428 } // namespace cc | 442 } // namespace cc |
| OLD | NEW |