OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/surfaces/surface_aggregator.h" | 5 #include "cc/surfaces/surface_aggregator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 LocalFrameId grandchild_local_frame_id = allocator_.GenerateId(); | 954 LocalFrameId grandchild_local_frame_id = allocator_.GenerateId(); |
955 SurfaceId grandchild_surface_id(grandchild_factory.frame_sink_id(), | 955 SurfaceId grandchild_surface_id(grandchild_factory.frame_sink_id(), |
956 grandchild_local_frame_id); | 956 grandchild_local_frame_id); |
957 grandchild_factory.SubmitCompositorFrame(grandchild_local_frame_id, | 957 grandchild_factory.SubmitCompositorFrame(grandchild_local_frame_id, |
958 CompositorFrame(), | 958 CompositorFrame(), |
959 SurfaceFactory::DrawCallback()); | 959 SurfaceFactory::DrawCallback()); |
960 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); | 960 std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create(); |
961 gfx::Rect output_rect(SurfaceSize()); | 961 gfx::Rect output_rect(SurfaceSize()); |
962 gfx::Rect damage_rect(SurfaceSize()); | 962 gfx::Rect damage_rect(SurfaceSize()); |
963 gfx::Transform transform_to_root_target; | 963 gfx::Transform transform_to_root_target; |
964 grandchild_pass->SetNew( | 964 grandchild_pass->SetNew(pass_id, output_rect, damage_rect, |
965 pass_id, output_rect, damage_rect, transform_to_root_target); | 965 transform_to_root_target); |
966 AddSolidColorQuadWithBlendMode( | 966 AddSolidColorQuadWithBlendMode( |
967 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); | 967 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); |
968 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_frame_id, | 968 QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_frame_id, |
969 &grandchild_factory); | 969 &grandchild_factory); |
970 | 970 |
971 LocalFrameId child_one_local_frame_id = allocator_.GenerateId(); | 971 LocalFrameId child_one_local_frame_id = allocator_.GenerateId(); |
972 SurfaceId child_one_surface_id(child_one_factory.frame_sink_id(), | 972 SurfaceId child_one_surface_id(child_one_factory.frame_sink_id(), |
973 child_one_local_frame_id); | 973 child_one_local_frame_id); |
974 child_one_factory.SubmitCompositorFrame(child_one_local_frame_id, | 974 child_one_factory.SubmitCompositorFrame(child_one_local_frame_id, |
975 CompositorFrame(), | 975 CompositorFrame(), |
976 SurfaceFactory::DrawCallback()); | 976 SurfaceFactory::DrawCallback()); |
977 | 977 |
978 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); | 978 std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create(); |
979 child_one_pass->SetNew( | 979 child_one_pass->SetNew(pass_id, output_rect, damage_rect, |
980 pass_id, output_rect, damage_rect, transform_to_root_target); | 980 transform_to_root_target); |
981 AddSolidColorQuadWithBlendMode( | 981 AddSolidColorQuadWithBlendMode( |
982 SurfaceSize(), child_one_pass.get(), blend_modes[1]); | 982 SurfaceSize(), child_one_pass.get(), blend_modes[1]); |
983 SurfaceDrawQuad* grandchild_surface_quad = | 983 SurfaceDrawQuad* grandchild_surface_quad = |
984 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 984 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
985 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), | 985 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), |
986 gfx::Rect(SurfaceSize()), | 986 gfx::Rect(SurfaceSize()), |
987 gfx::Rect(SurfaceSize()), | 987 gfx::Rect(SurfaceSize()), |
988 grandchild_surface_id); | 988 grandchild_surface_id); |
989 AddSolidColorQuadWithBlendMode( | 989 AddSolidColorQuadWithBlendMode( |
990 SurfaceSize(), child_one_pass.get(), blend_modes[3]); | 990 SurfaceSize(), child_one_pass.get(), blend_modes[3]); |
991 QueuePassAsFrame(std::move(child_one_pass), child_one_local_frame_id, | 991 QueuePassAsFrame(std::move(child_one_pass), child_one_local_frame_id, |
992 &child_one_factory); | 992 &child_one_factory); |
993 | 993 |
994 LocalFrameId child_two_local_frame_id = allocator_.GenerateId(); | 994 LocalFrameId child_two_local_frame_id = allocator_.GenerateId(); |
995 SurfaceId child_two_surface_id(child_two_factory.frame_sink_id(), | 995 SurfaceId child_two_surface_id(child_two_factory.frame_sink_id(), |
996 child_two_local_frame_id); | 996 child_two_local_frame_id); |
997 child_two_factory.SubmitCompositorFrame(child_two_local_frame_id, | 997 child_two_factory.SubmitCompositorFrame(child_two_local_frame_id, |
998 CompositorFrame(), | 998 CompositorFrame(), |
999 SurfaceFactory::DrawCallback()); | 999 SurfaceFactory::DrawCallback()); |
1000 | 1000 |
1001 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); | 1001 std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create(); |
1002 child_two_pass->SetNew( | 1002 child_two_pass->SetNew(pass_id, output_rect, damage_rect, |
1003 pass_id, output_rect, damage_rect, transform_to_root_target); | 1003 transform_to_root_target); |
1004 AddSolidColorQuadWithBlendMode( | 1004 AddSolidColorQuadWithBlendMode( |
1005 SurfaceSize(), child_two_pass.get(), blend_modes[5]); | 1005 SurfaceSize(), child_two_pass.get(), blend_modes[5]); |
1006 QueuePassAsFrame(std::move(child_two_pass), child_two_local_frame_id, | 1006 QueuePassAsFrame(std::move(child_two_pass), child_two_local_frame_id, |
1007 &child_two_factory); | 1007 &child_two_factory); |
1008 | 1008 |
1009 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); | 1009 std::unique_ptr<RenderPass> root_pass = RenderPass::Create(); |
1010 root_pass->SetNew( | 1010 root_pass->SetNew(pass_id, output_rect, damage_rect, |
1011 pass_id, output_rect, damage_rect, transform_to_root_target); | 1011 transform_to_root_target); |
1012 | 1012 |
1013 AddSolidColorQuadWithBlendMode( | 1013 AddSolidColorQuadWithBlendMode( |
1014 SurfaceSize(), root_pass.get(), blend_modes[0]); | 1014 SurfaceSize(), root_pass.get(), blend_modes[0]); |
1015 SurfaceDrawQuad* child_one_surface_quad = | 1015 SurfaceDrawQuad* child_one_surface_quad = |
1016 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 1016 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
1017 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 1017 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
1018 gfx::Rect(SurfaceSize()), | 1018 gfx::Rect(SurfaceSize()), |
1019 gfx::Rect(SurfaceSize()), | 1019 gfx::Rect(SurfaceSize()), |
1020 child_one_surface_id); | 1020 child_one_surface_id); |
1021 AddSolidColorQuadWithBlendMode( | 1021 AddSolidColorQuadWithBlendMode( |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1671 const RenderPassList& aggregated_pass_list = | 1671 const RenderPassList& aggregated_pass_list = |
1672 aggregated_frame.render_pass_list; | 1672 aggregated_frame.render_pass_list; |
1673 // There were no changes since last aggregation, so output should be empty | 1673 // There were no changes since last aggregation, so output should be empty |
1674 // and have no damage. | 1674 // and have no damage. |
1675 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1675 ASSERT_EQ(1u, aggregated_pass_list.size()); |
1676 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); | 1676 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); |
1677 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); | 1677 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); |
1678 } | 1678 } |
1679 | 1679 |
1680 // Root surface has smaller damage rect, but filter on render pass means all | 1680 // Root surface has smaller damage rect, but filter on render pass means all |
1681 // of it should be aggregated. | 1681 // of it and its descendant passes should be aggregated. |
1682 { | 1682 { |
1683 int root_pass_ids[] = {1, 2}; | 1683 int root_pass_ids[] = {1, 2, 3}; |
1684 test::Quad root_quads1[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1684 test::Quad root_quads1[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1685 test::Quad root_quads2[] = {test::Quad::RenderPassQuad(root_pass_ids[0])}; | 1685 test::Quad root_quads2[] = {test::Quad::RenderPassQuad(root_pass_ids[0])}; |
| 1686 test::Quad root_quads3[] = {test::Quad::RenderPassQuad(root_pass_ids[1])}; |
1686 test::Pass root_passes[] = { | 1687 test::Pass root_passes[] = { |
1687 test::Pass(root_quads1, arraysize(root_quads1), root_pass_ids[0]), | 1688 test::Pass(root_quads1, arraysize(root_quads1), root_pass_ids[0]), |
1688 test::Pass(root_quads2, arraysize(root_quads2), root_pass_ids[1])}; | 1689 test::Pass(root_quads2, arraysize(root_quads2), root_pass_ids[1]), |
| 1690 test::Pass(root_quads3, arraysize(root_quads3), root_pass_ids[2])}; |
1689 | 1691 |
1690 RenderPassList root_pass_list; | 1692 RenderPassList root_pass_list; |
1691 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1693 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
1692 arraysize(root_passes)); | 1694 arraysize(root_passes)); |
1693 | 1695 |
1694 RenderPass* pass = root_pass_list[0].get(); | 1696 RenderPass* filter_pass = root_pass_list[1].get(); |
1695 pass->shared_quad_state_list.front()->quad_to_target_transform.Translate( | 1697 filter_pass->shared_quad_state_list.front() |
1696 10, 10); | 1698 ->quad_to_target_transform.Translate(10, 10); |
1697 RenderPass* root_pass = root_pass_list[1].get(); | 1699 RenderPass* root_pass = root_pass_list[2].get(); |
1698 RenderPassDrawQuad* quad = | 1700 filter_pass->filters.Append(FilterOperation::CreateBlurFilter(2)); |
1699 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); | |
1700 quad->filters.Append(FilterOperation::CreateBlurFilter(2)); | |
1701 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1701 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
1702 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list); | 1702 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list); |
1703 } | 1703 } |
1704 | 1704 |
1705 { | 1705 { |
1706 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1706 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
1707 | 1707 |
1708 const RenderPassList& aggregated_pass_list = | 1708 const RenderPassList& aggregated_pass_list = |
1709 aggregated_frame.render_pass_list; | 1709 aggregated_frame.render_pass_list; |
1710 | 1710 |
1711 ASSERT_EQ(3u, aggregated_pass_list.size()); | 1711 ASSERT_EQ(4u, aggregated_pass_list.size()); |
1712 | 1712 |
1713 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); | 1713 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); |
1714 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); | 1714 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect); |
1715 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect); | 1715 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect); |
| 1716 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[3]->damage_rect); |
1716 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); | 1717 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); |
1717 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); | 1718 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); |
| 1719 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); |
1718 // First render pass draw quad is outside damage rect, so shouldn't be | 1720 // First render pass draw quad is outside damage rect, so shouldn't be |
1719 // drawn. | 1721 // drawn. |
1720 EXPECT_EQ(0u, aggregated_pass_list[2]->quad_list.size()); | 1722 EXPECT_EQ(0u, aggregated_pass_list[3]->quad_list.size()); |
1721 } | 1723 } |
1722 | 1724 |
1723 // Root surface has smaller damage rect. Background filter on render pass | 1725 // Root surface has smaller damage rect. Background filter on render pass |
1724 // means Surface | 1726 // means Surface |
1725 // quad under it should be aggregated. | 1727 // quad under it should be aggregated. |
1726 { | 1728 { |
1727 int root_pass_ids[] = {1, 2}; | 1729 int root_pass_ids[] = {1, 2}; |
1728 test::Quad root_quads1[] = { | 1730 test::Quad root_quads1[] = { |
1729 test::Quad::SolidColorQuad(1), | 1731 test::Quad::SolidColorQuad(1), |
1730 }; | 1732 }; |
1731 test::Quad root_quads2[] = {test::Quad::RenderPassQuad(root_pass_ids[0]), | 1733 test::Quad root_quads2[] = {test::Quad::RenderPassQuad(root_pass_ids[0]), |
1732 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1734 test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
1733 test::Pass root_passes[] = { | 1735 test::Pass root_passes[] = { |
1734 test::Pass(root_quads1, arraysize(root_quads1), root_pass_ids[0]), | 1736 test::Pass(root_quads1, arraysize(root_quads1), root_pass_ids[0]), |
1735 test::Pass(root_quads2, arraysize(root_quads2), root_pass_ids[1])}; | 1737 test::Pass(root_quads2, arraysize(root_quads2), root_pass_ids[1])}; |
1736 | 1738 |
1737 RenderPassList root_pass_list; | 1739 RenderPassList root_pass_list; |
1738 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1740 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
1739 arraysize(root_passes)); | 1741 arraysize(root_passes)); |
1740 | 1742 |
| 1743 RenderPass* pass = root_pass_list[0].get(); |
1741 RenderPass* root_pass = root_pass_list[1].get(); | 1744 RenderPass* root_pass = root_pass_list[1].get(); |
1742 root_pass->shared_quad_state_list.ElementAt(1) | 1745 root_pass->shared_quad_state_list.ElementAt(1) |
1743 ->quad_to_target_transform.Translate(10, 10); | 1746 ->quad_to_target_transform.Translate(10, 10); |
1744 RenderPassDrawQuad* quad = | 1747 pass->background_filters.Append(FilterOperation::CreateBlurFilter(2)); |
1745 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front()); | |
1746 quad->background_filters.Append(FilterOperation::CreateBlurFilter(2)); | |
1747 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); | 1748 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2); |
1748 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list); | 1749 SubmitPassListAsFrame(&factory_, root_local_frame_id_, &root_pass_list); |
1749 } | 1750 } |
1750 | 1751 |
1751 { | 1752 { |
1752 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1753 CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
1753 | 1754 |
1754 const RenderPassList& aggregated_pass_list = | 1755 const RenderPassList& aggregated_pass_list = |
1755 aggregated_frame.render_pass_list; | 1756 aggregated_frame.render_pass_list; |
1756 | 1757 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2077 // Output is insecure, so texture should be drawn. | 2078 // Output is insecure, so texture should be drawn. |
2078 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2079 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
2079 | 2080 |
2080 factory1.EvictSurface(); | 2081 factory1.EvictSurface(); |
2081 factory2.EvictSurface(); | 2082 factory2.EvictSurface(); |
2082 } | 2083 } |
2083 | 2084 |
2084 } // namespace | 2085 } // namespace |
2085 } // namespace cc | 2086 } // namespace cc |
2086 | 2087 |
OLD | NEW |