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/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/numerics/safe_conversions.h" | 13 #include "base/numerics/safe_conversions.h" |
14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
15 #include "cc/base/math_util.h" | 15 #include "cc/base/math_util.h" |
16 #include "cc/output/bsp_tree.h" | 16 #include "cc/output/bsp_tree.h" |
17 #include "cc/output/bsp_walk_action.h" | 17 #include "cc/output/bsp_walk_action.h" |
18 #include "cc/output/copy_output_request.h" | 18 #include "cc/output/copy_output_request.h" |
19 #include "cc/quads/draw_quad.h" | 19 #include "cc/quads/draw_quad.h" |
| 20 #include "ui/gfx/geometry/quad_f.h" |
20 #include "ui/gfx/geometry/rect_conversions.h" | 21 #include "ui/gfx/geometry/rect_conversions.h" |
21 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
22 | 23 |
23 static gfx::Transform OrthoProjectionMatrix(float left, | 24 static gfx::Transform OrthoProjectionMatrix(float left, |
24 float right, | 25 float right, |
25 float bottom, | 26 float bottom, |
26 float top) { | 27 float top) { |
27 // Use the standard formula to map the clipping frustum to the cube from | 28 // Use the standard formula to map the clipping frustum to the cube from |
28 // [-1, -1, -1] to [1, 1, 1]. | 29 // [-1, -1, -1] to [1, 1, 1]. |
29 float delta_x = right - left; | 30 float delta_x = right - left; |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 MoveFromDrawToWindowSpace(frame, render_pass_scissor_in_draw_space)); | 439 MoveFromDrawToWindowSpace(frame, render_pass_scissor_in_draw_space)); |
439 | 440 |
440 const QuadList& quad_list = render_pass->quad_list; | 441 const QuadList& quad_list = render_pass->quad_list; |
441 ScopedPtrDeque<DrawPolygon> poly_list; | 442 ScopedPtrDeque<DrawPolygon> poly_list; |
442 | 443 |
443 int next_polygon_id = 0; | 444 int next_polygon_id = 0; |
444 int last_sorting_context_id = 0; | 445 int last_sorting_context_id = 0; |
445 for (auto it = quad_list.BackToFrontBegin(); it != quad_list.BackToFrontEnd(); | 446 for (auto it = quad_list.BackToFrontBegin(); it != quad_list.BackToFrontEnd(); |
446 ++it) { | 447 ++it) { |
447 const DrawQuad& quad = **it; | 448 const DrawQuad& quad = **it; |
448 gfx::QuadF send_quad(quad.visible_rect); | 449 gfx::QuadF send_quad(gfx::RectF(quad.visible_rect)); |
449 | 450 |
450 if (render_pass_is_clipped && | 451 if (render_pass_is_clipped && |
451 ShouldSkipQuad(quad, render_pass_scissor_in_draw_space)) { | 452 ShouldSkipQuad(quad, render_pass_scissor_in_draw_space)) { |
452 continue; | 453 continue; |
453 } | 454 } |
454 | 455 |
455 if (last_sorting_context_id != quad.shared_quad_state->sorting_context_id) { | 456 if (last_sorting_context_id != quad.shared_quad_state->sorting_context_id) { |
456 last_sorting_context_id = quad.shared_quad_state->sorting_context_id; | 457 last_sorting_context_id = quad.shared_quad_state->sorting_context_id; |
457 FlushPolygons(&poly_list, frame, render_pass_scissor_in_draw_space, | 458 FlushPolygons(&poly_list, frame, render_pass_scissor_in_draw_space, |
458 render_pass_is_clipped); | 459 render_pass_is_clipped); |
459 } | 460 } |
460 | 461 |
461 // This layer is in a 3D sorting context so we add it to the list of | 462 // This layer is in a 3D sorting context so we add it to the list of |
462 // polygons to go into the BSP tree. | 463 // polygons to go into the BSP tree. |
463 if (quad.shared_quad_state->sorting_context_id != 0) { | 464 if (quad.shared_quad_state->sorting_context_id != 0) { |
464 scoped_ptr<DrawPolygon> new_polygon(new DrawPolygon( | 465 scoped_ptr<DrawPolygon> new_polygon(new DrawPolygon( |
465 *it, quad.visible_rect, | 466 *it, gfx::RectF(quad.visible_rect), |
466 quad.shared_quad_state->quad_to_target_transform, next_polygon_id++)); | 467 quad.shared_quad_state->quad_to_target_transform, next_polygon_id++)); |
467 if (new_polygon->points().size() > 2u) { | 468 if (new_polygon->points().size() > 2u) { |
468 poly_list.push_back(new_polygon.Pass()); | 469 poly_list.push_back(new_polygon.Pass()); |
469 } | 470 } |
470 continue; | 471 continue; |
471 } | 472 } |
472 | 473 |
473 // We are not in a 3d sorting context, so we should draw the quad normally. | 474 // We are not in a 3d sorting context, so we should draw the quad normally. |
474 SetScissorStateForQuad(frame, quad, render_pass_scissor_in_draw_space, | 475 SetScissorStateForQuad(frame, quad, render_pass_scissor_in_draw_space, |
475 render_pass_is_clipped); | 476 render_pass_is_clipped); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 ScopedResource* texture = render_pass_textures_.get(id); | 521 ScopedResource* texture = render_pass_textures_.get(id); |
521 return texture && texture->id(); | 522 return texture && texture->id(); |
522 } | 523 } |
523 | 524 |
524 // static | 525 // static |
525 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { | 526 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { |
526 return render_pass->output_rect.size(); | 527 return render_pass->output_rect.size(); |
527 } | 528 } |
528 | 529 |
529 } // namespace cc | 530 } // namespace cc |
OLD | NEW |