| OLD | NEW |
| 1 | 1 |
| 2 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 #include "components/viz/service/display/surface_aggregator.h" | 6 #include "components/viz/service/display/surface_aggregator.h" |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; | 1598 Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; |
| 1599 | 1599 |
| 1600 cc::CompositorFrame root_frame = cc::test::MakeEmptyCompositorFrame(); | 1600 cc::CompositorFrame root_frame = cc::test::MakeEmptyCompositorFrame(); |
| 1601 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, | 1601 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, |
| 1602 arraysize(root_passes)); | 1602 arraysize(root_passes)); |
| 1603 | 1603 |
| 1604 root_frame.render_pass_list[0] | 1604 root_frame.render_pass_list[0] |
| 1605 ->shared_quad_state_list.front() | 1605 ->shared_quad_state_list.front() |
| 1606 ->quad_to_target_transform.Translate(0, 10); | 1606 ->quad_to_target_transform.Translate(0, 10); |
| 1607 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10); | 1607 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10); |
| 1608 root_frame.render_pass_list[0]->cache_render_surface = true; |
| 1608 root_frame.render_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100); | 1609 root_frame.render_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100); |
| 1609 | 1610 |
| 1610 support_->SubmitCompositorFrame(root_local_surface_id_, | 1611 support_->SubmitCompositorFrame(root_local_surface_id_, |
| 1611 std::move(root_frame)); | 1612 std::move(root_frame)); |
| 1612 | 1613 |
| 1613 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); | 1614 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); |
| 1614 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); | 1615 cc::CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id); |
| 1615 | 1616 |
| 1616 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | 1617 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; |
| 1617 | 1618 |
| 1618 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1619 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1619 | 1620 |
| 1621 // First aggregation shold be true. |
| 1622 EXPECT_TRUE(aggregated_pass_list[0]->has_damage_from_contributing_content); |
| 1620 // Damage rect for first aggregation should contain entire root surface. | 1623 // Damage rect for first aggregation should contain entire root surface. |
| 1621 EXPECT_TRUE( | 1624 EXPECT_TRUE( |
| 1622 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); | 1625 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); |
| 1623 | 1626 |
| 1624 { | 1627 { |
| 1625 cc::CompositorFrame child_frame = cc::test::MakeEmptyCompositorFrame(); | 1628 cc::CompositorFrame child_frame = cc::test::MakeEmptyCompositorFrame(); |
| 1626 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1629 AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1627 child_passes, arraysize(child_passes)); | 1630 child_passes, arraysize(child_passes)); |
| 1628 | 1631 |
| 1629 auto* child_root_pass = child_frame.render_pass_list[0].get(); | 1632 auto* child_root_pass = child_frame.render_pass_list[0].get(); |
| 1630 auto* child_root_pass_sqs = child_root_pass->shared_quad_state_list.front(); | 1633 auto* child_root_pass_sqs = child_root_pass->shared_quad_state_list.front(); |
| 1631 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); | 1634 child_root_pass_sqs->quad_to_target_transform.Translate(8, 0); |
| 1632 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 1635 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
| 1633 | 1636 |
| 1634 child_support_->SubmitCompositorFrame(child_local_surface_id, | 1637 child_support_->SubmitCompositorFrame(child_local_surface_id, |
| 1635 std::move(child_frame)); | 1638 std::move(child_frame)); |
| 1636 | 1639 |
| 1637 SurfaceId root_surface_id(support_->frame_sink_id(), | 1640 SurfaceId root_surface_id(support_->frame_sink_id(), |
| 1638 root_local_surface_id_); | 1641 root_local_surface_id_); |
| 1639 cc::CompositorFrame aggregated_frame = | 1642 cc::CompositorFrame aggregated_frame = |
| 1640 aggregator_.Aggregate(root_surface_id); | 1643 aggregator_.Aggregate(root_surface_id); |
| 1641 | 1644 |
| 1642 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | 1645 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; |
| 1643 | 1646 |
| 1644 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1647 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1645 | 1648 |
| 1649 // True for new frame. |
| 1650 EXPECT_TRUE(aggregated_pass_list[0]->has_damage_from_contributing_content); |
| 1646 // Outer surface didn't change, so transformed inner damage rect should be | 1651 // Outer surface didn't change, so transformed inner damage rect should be |
| 1647 // used. | 1652 // used. |
| 1648 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(), | 1653 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(), |
| 1649 aggregated_pass_list[1]->damage_rect.ToString()); | 1654 aggregated_pass_list[1]->damage_rect.ToString()); |
| 1650 } | 1655 } |
| 1651 | 1656 |
| 1652 { | 1657 { |
| 1653 cc::CompositorFrame root_frame = cc::test::MakeEmptyCompositorFrame(); | 1658 cc::CompositorFrame root_frame = cc::test::MakeEmptyCompositorFrame(); |
| 1654 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1659 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1655 root_passes, arraysize(root_passes)); | 1660 root_passes, arraysize(root_passes)); |
| 1656 | 1661 |
| 1657 root_frame.render_pass_list[0] | 1662 root_frame.render_pass_list[0] |
| 1658 ->shared_quad_state_list.front() | 1663 ->shared_quad_state_list.front() |
| 1659 ->quad_to_target_transform.Translate(0, 10); | 1664 ->quad_to_target_transform.Translate(0, 10); |
| 1660 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1); | 1665 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1); |
| 1661 | 1666 |
| 1662 support_->SubmitCompositorFrame(root_local_surface_id_, | 1667 support_->SubmitCompositorFrame(root_local_surface_id_, |
| 1663 std::move(root_frame)); | 1668 std::move(root_frame)); |
| 1664 } | 1669 } |
| 1665 | 1670 |
| 1666 { | 1671 { |
| 1667 cc::CompositorFrame root_frame = cc::test::MakeEmptyCompositorFrame(); | 1672 cc::CompositorFrame root_frame = cc::test::MakeEmptyCompositorFrame(); |
| 1668 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), | 1673 AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), |
| 1669 root_passes, arraysize(root_passes)); | 1674 root_passes, arraysize(root_passes)); |
| 1670 | 1675 |
| 1671 root_frame.render_pass_list[0] | 1676 root_frame.render_pass_list[0] |
| 1672 ->shared_quad_state_list.front() | 1677 ->shared_quad_state_list.front() |
| 1673 ->quad_to_target_transform.Translate(0, 10); | 1678 ->quad_to_target_transform.Translate(0, 10); |
| 1674 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1); | 1679 root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1); |
| 1680 root_frame.render_pass_list[0]->cache_render_surface = true; |
| 1675 | 1681 |
| 1676 support_->SubmitCompositorFrame(root_local_surface_id_, | 1682 support_->SubmitCompositorFrame(root_local_surface_id_, |
| 1677 std::move(root_frame)); | 1683 std::move(root_frame)); |
| 1678 | 1684 |
| 1679 SurfaceId root_surface_id(support_->frame_sink_id(), | 1685 SurfaceId root_surface_id(support_->frame_sink_id(), |
| 1680 root_local_surface_id_); | 1686 root_local_surface_id_); |
| 1681 cc::CompositorFrame aggregated_frame = | 1687 cc::CompositorFrame aggregated_frame = |
| 1682 aggregator_.Aggregate(root_surface_id); | 1688 aggregator_.Aggregate(root_surface_id); |
| 1683 | 1689 |
| 1684 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | 1690 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; |
| 1685 | 1691 |
| 1686 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1692 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1687 | 1693 |
| 1694 // False when the child frame has no change. |
| 1695 EXPECT_FALSE(aggregated_pass_list[0]->has_damage_from_contributing_content); |
| 1688 // The root surface was enqueued without being aggregated once, so it should | 1696 // The root surface was enqueued without being aggregated once, so it should |
| 1689 // be treated as completely damaged. | 1697 // be treated as completely damaged. |
| 1690 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1698 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
| 1691 gfx::Rect(SurfaceSize()))); | 1699 gfx::Rect(SurfaceSize()))); |
| 1692 } | 1700 } |
| 1693 | 1701 |
| 1694 // No Surface changed, so no damage should be given. | 1702 // No Surface changed, so no damage should be given. |
| 1695 { | 1703 { |
| 1696 SurfaceId root_surface_id(support_->frame_sink_id(), | 1704 SurfaceId root_surface_id(support_->frame_sink_id(), |
| 1697 root_local_surface_id_); | 1705 root_local_surface_id_); |
| 1698 cc::CompositorFrame aggregated_frame = | 1706 cc::CompositorFrame aggregated_frame = |
| 1699 aggregator_.Aggregate(root_surface_id); | 1707 aggregator_.Aggregate(root_surface_id); |
| 1700 | 1708 |
| 1701 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; | 1709 const auto& aggregated_pass_list = aggregated_frame.render_pass_list; |
| 1702 | 1710 |
| 1703 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1711 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1704 | 1712 |
| 1713 // False when the child frame has no change. |
| 1714 EXPECT_FALSE(aggregated_pass_list[0]->has_damage_from_contributing_content); |
| 1705 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); | 1715 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty()); |
| 1706 } | 1716 } |
| 1707 | 1717 |
| 1708 // SetFullDamageRectForSurface should cause the entire output to be | 1718 // SetFullDamageRectForSurface should cause the entire output to be |
| 1709 // marked as damaged. | 1719 // marked as damaged. |
| 1710 { | 1720 { |
| 1711 aggregator_.SetFullDamageForSurface(root_surface_id); | 1721 aggregator_.SetFullDamageForSurface(root_surface_id); |
| 1712 cc::CompositorFrame aggregated_frame = | 1722 cc::CompositorFrame aggregated_frame = |
| 1713 aggregator_.Aggregate(root_surface_id); | 1723 aggregator_.Aggregate(root_surface_id); |
| 1714 | 1724 |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2452 aggregator_.SetOutputColorSpace(color_space1, color_space3); | 2462 aggregator_.SetOutputColorSpace(color_space1, color_space3); |
| 2453 aggregated_frame = aggregator_.Aggregate(surface_id); | 2463 aggregated_frame = aggregator_.Aggregate(surface_id); |
| 2454 EXPECT_EQ(3u, aggregated_frame.render_pass_list.size()); | 2464 EXPECT_EQ(3u, aggregated_frame.render_pass_list.size()); |
| 2455 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); | 2465 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); |
| 2456 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); | 2466 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); |
| 2457 EXPECT_EQ(color_space3, aggregated_frame.render_pass_list[2]->color_space); | 2467 EXPECT_EQ(color_space3, aggregated_frame.render_pass_list[2]->color_space); |
| 2458 } | 2468 } |
| 2459 | 2469 |
| 2460 } // namespace | 2470 } // namespace |
| 2461 } // namespace viz | 2471 } // namespace viz |
| OLD | NEW |