Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Side by Side Diff: cc/surfaces/surface_aggregator_unittest.cc

Issue 1963693003: Revert of Correctly handle damage involving filters in SurfaceAggregator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/surfaces/surface_aggregator.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 namespace cc { 37 namespace cc {
38 namespace { 38 namespace {
39 39
40 SurfaceId InvalidSurfaceId() { 40 SurfaceId InvalidSurfaceId() {
41 static SurfaceId invalid; 41 static SurfaceId invalid;
42 invalid.id = static_cast<uint64_t>(-1); 42 invalid.id = static_cast<uint64_t>(-1);
43 return invalid; 43 return invalid;
44 } 44 }
45 45
46 gfx::Size SurfaceSize() { 46 gfx::Size SurfaceSize() {
47 static gfx::Size size(100, 100); 47 static gfx::Size size(5, 5);
48 return size; 48 return size;
49 } 49 }
50 50
51 class EmptySurfaceFactoryClient : public SurfaceFactoryClient { 51 class EmptySurfaceFactoryClient : public SurfaceFactoryClient {
52 public: 52 public:
53 void ReturnResources(const ReturnedResourceArray& resources) override {} 53 void ReturnResources(const ReturnedResourceArray& resources) override {}
54 54
55 void WillDrawSurface(SurfaceId id, const gfx::Rect& damage_rect) override { 55 void WillDrawSurface(SurfaceId id, const gfx::Rect& damage_rect) override {
56 last_surface_id_ = id; 56 last_surface_id_ = id;
57 last_damage_rect_ = damage_rect; 57 last_damage_rect_ = damage_rect;
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 ASSERT_TRUE(aggregated_frame); 1519 ASSERT_TRUE(aggregated_frame);
1520 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 1520 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
1521 1521
1522 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 1522 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
1523 1523
1524 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 1524 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1525 1525
1526 ASSERT_EQ(3u, aggregated_pass_list.size()); 1526 ASSERT_EQ(3u, aggregated_pass_list.size());
1527 1527
1528 // Damage rect for first aggregation should contain entire root surface. 1528 // Damage rect for first aggregation should contain entire root surface.
1529 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[2]->damage_rect); 1529 EXPECT_EQ(gfx::Rect(0, 0, 15, 15), aggregated_pass_list[2]->damage_rect);
1530 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); 1530 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size());
1531 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); 1531 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
1532 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); 1532 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size());
1533 1533
1534 // Create a root surface with a smaller damage rect. 1534 // Create a root surface with a smaller damage rect.
1535 { 1535 {
1536 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; 1536 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)};
1537 1537
1538 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; 1538 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
1539 1539
(...skipping 28 matching lines...) Expand all
1568 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); 1568 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size());
1569 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); 1569 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
1570 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), 1570 EXPECT_EQ(gfx::Rect(0, 0, 2, 2),
1571 aggregated_pass_list[1]->quad_list.back()->visible_rect); 1571 aggregated_pass_list[1]->quad_list.back()->visible_rect);
1572 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); 1572 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size());
1573 } 1573 }
1574 1574
1575 // New child frame has same content and no damage, but has a 1575 // New child frame has same content and no damage, but has a
1576 // CopyOutputRequest. 1576 // CopyOutputRequest.
1577 { 1577 {
1578 RenderPassId child_pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2)}; 1578 RenderPassId child_pass_id = RenderPassId(1, 1);
1579 test::Quad child_quads1[] = {test::Quad::SolidColorQuad(1)}; 1579 test::Quad child_quads1[] = {test::Quad::RenderPassQuad(child_pass_id)};
1580 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_ids[0])}; 1580 test::Quad child_quads2[] = {test::Quad::RenderPassQuad(child_pass_id)};
1581 test::Pass child_passes[] = { 1581 test::Pass child_passes[] = {
1582 test::Pass(child_quads1, arraysize(child_quads1), child_pass_ids[0]), 1582 test::Pass(child_quads1, arraysize(child_quads1), child_pass_id),
1583 test::Pass(child_quads2, arraysize(child_quads2), child_pass_ids[1])}; 1583 test::Pass(child_quads2, arraysize(child_quads2), child_pass_id)};
1584 1584
1585 RenderPassList child_pass_list; 1585 RenderPassList child_pass_list;
1586 AddPasses(&child_pass_list, gfx::Rect(SurfaceSize()), child_passes, 1586 AddPasses(&child_pass_list, gfx::Rect(SurfaceSize()), child_passes,
1587 arraysize(child_passes)); 1587 arraysize(child_passes));
1588 1588
1589 child_pass_list[0]->quad_list.ElementAt(0)->visible_rect = 1589 child_pass_list[0]->quad_list.ElementAt(0)->visible_rect =
1590 gfx::Rect(1, 1, 2, 2); 1590 gfx::Rect(1, 1, 2, 2);
1591 SharedQuadState* child_sqs = 1591 SharedQuadState* child_sqs =
1592 child_pass_list[0]->shared_quad_state_list.ElementAt(0u); 1592 child_pass_list[0]->shared_quad_state_list.ElementAt(0u);
1593 child_sqs->quad_to_target_transform.Translate(1, 1); 1593 child_sqs->quad_to_target_transform.Translate(1, 1);
(...skipping 18 matching lines...) Expand all
1612 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 1612 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
1613 1613
1614 DelegatedFrameData* frame_data = 1614 DelegatedFrameData* frame_data =
1615 aggregated_frame->delegated_frame_data.get(); 1615 aggregated_frame->delegated_frame_data.get();
1616 1616
1617 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 1617 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1618 1618
1619 // Output frame should have no damage, but all quads included. 1619 // Output frame should have no damage, but all quads included.
1620 ASSERT_EQ(3u, aggregated_pass_list.size()); 1620 ASSERT_EQ(3u, aggregated_pass_list.size());
1621 1621
1622 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect); 1622 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.IsEmpty());
1623 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect);
1624 EXPECT_TRUE(aggregated_pass_list[2]->damage_rect.IsEmpty());
1625 ASSERT_EQ(1u, aggregated_pass_list[0]->quad_list.size()); 1623 ASSERT_EQ(1u, aggregated_pass_list[0]->quad_list.size());
1626 ASSERT_EQ(1u, aggregated_pass_list[1]->quad_list.size()); 1624 ASSERT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
1627 EXPECT_EQ(gfx::Rect(1, 1, 2, 2), 1625 EXPECT_EQ(gfx::Rect(1, 1, 2, 2),
1628 aggregated_pass_list[0]->quad_list.ElementAt(0)->visible_rect); 1626 aggregated_pass_list[0]->quad_list.ElementAt(0)->visible_rect);
1629 EXPECT_EQ(gfx::Rect(0, 0, 2, 2), 1627 EXPECT_EQ(gfx::Rect(0, 0, 2, 2),
1630 aggregated_pass_list[1]->quad_list.ElementAt(0)->visible_rect); 1628 aggregated_pass_list[1]->quad_list.ElementAt(0)->visible_rect);
1631 ASSERT_EQ(1u, aggregated_pass_list[2]->quad_list.size()); 1629 ASSERT_EQ(1u, aggregated_pass_list[2]->quad_list.size());
1632 } 1630 }
1633 1631
1634 { 1632 {
1635 std::unique_ptr<CompositorFrame> aggregated_frame = 1633 std::unique_ptr<CompositorFrame> aggregated_frame =
1636 aggregator_.Aggregate(root_surface_id_); 1634 aggregator_.Aggregate(root_surface_id_);
1637 1635
1638 ASSERT_TRUE(aggregated_frame); 1636 ASSERT_TRUE(aggregated_frame);
1639 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 1637 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
1640 1638
1641 DelegatedFrameData* frame_data = 1639 DelegatedFrameData* frame_data =
1642 aggregated_frame->delegated_frame_data.get(); 1640 aggregated_frame->delegated_frame_data.get();
1643 1641
1644 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 1642 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1645 // There were no changes since last aggregation, so output should be empty 1643 // There were no changes since last aggregation, so output should be empty
1646 // and have no damage. 1644 // and have no damage.
1647 ASSERT_EQ(1u, aggregated_pass_list.size()); 1645 ASSERT_EQ(1u, aggregated_pass_list.size());
1648 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty()); 1646 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty());
1649 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size()); 1647 ASSERT_EQ(0u, aggregated_pass_list[0]->quad_list.size());
1650 } 1648 }
1651 1649
1652 // Root surface has smaller damage rect, but filter on render pass means all
1653 // of it should be aggregated.
1654 {
1655 RenderPassId root_pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2)};
1656 test::Quad root_quads1[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)};
1657 test::Quad root_quads2[] = {test::Quad::RenderPassQuad(root_pass_ids[0])};
1658 test::Pass root_passes[] = {
1659 test::Pass(root_quads1, arraysize(root_quads1), root_pass_ids[0]),
1660 test::Pass(root_quads2, arraysize(root_quads2), root_pass_ids[1])};
1661
1662 RenderPassList root_pass_list;
1663 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes,
1664 arraysize(root_passes));
1665
1666 RenderPass* pass = root_pass_list[0].get();
1667 pass->shared_quad_state_list.front()->quad_to_target_transform.Translate(
1668 10, 10);
1669 RenderPass* root_pass = root_pass_list[1].get();
1670 RenderPassDrawQuad* quad =
1671 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front());
1672 quad->filters.Append(FilterOperation::CreateBlurFilter(2));
1673 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2);
1674 SubmitPassListAsFrame(root_surface_id_, &root_pass_list);
1675 }
1676
1677 {
1678 std::unique_ptr<CompositorFrame> aggregated_frame =
1679 aggregator_.Aggregate(root_surface_id_);
1680
1681 ASSERT_TRUE(aggregated_frame);
1682 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
1683
1684 DelegatedFrameData* frame_data =
1685 aggregated_frame->delegated_frame_data.get();
1686
1687 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1688
1689 ASSERT_EQ(3u, aggregated_pass_list.size());
1690
1691 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[0]->damage_rect);
1692 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect);
1693 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect);
1694 EXPECT_EQ(1u, aggregated_pass_list[0]->quad_list.size());
1695 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
1696 // First render pass draw quad is outside damage rect, so shouldn't be
1697 // drawn.
1698 EXPECT_EQ(0u, aggregated_pass_list[2]->quad_list.size());
1699 }
1700
1701 // Root surface has smaller damage rect. Background filter on render pass
1702 // means Surface
1703 // quad under it should be aggregated.
1704 {
1705 RenderPassId root_pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2)};
1706 test::Quad root_quads1[] = {
1707 test::Quad::SolidColorQuad(1),
1708 };
1709 test::Quad root_quads2[] = {test::Quad::RenderPassQuad(root_pass_ids[0]),
1710 test::Quad::SurfaceQuad(child_surface_id, 1.f)};
1711 test::Pass root_passes[] = {
1712 test::Pass(root_quads1, arraysize(root_quads1), root_pass_ids[0]),
1713 test::Pass(root_quads2, arraysize(root_quads2), root_pass_ids[1])};
1714
1715 RenderPassList root_pass_list;
1716 AddPasses(&root_pass_list, gfx::Rect(SurfaceSize()), root_passes,
1717 arraysize(root_passes));
1718
1719 RenderPass* root_pass = root_pass_list[1].get();
1720 root_pass->shared_quad_state_list.ElementAt(1)
1721 ->quad_to_target_transform.Translate(10, 10);
1722 RenderPassDrawQuad* quad =
1723 static_cast<RenderPassDrawQuad*>(root_pass->quad_list.front());
1724 quad->background_filters.Append(FilterOperation::CreateBlurFilter(2));
1725 root_pass->damage_rect = gfx::Rect(10, 10, 2, 2);
1726 SubmitPassListAsFrame(root_surface_id_, &root_pass_list);
1727 }
1728
1729 {
1730 std::unique_ptr<CompositorFrame> aggregated_frame =
1731 aggregator_.Aggregate(root_surface_id_);
1732
1733 ASSERT_TRUE(aggregated_frame);
1734 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
1735
1736 DelegatedFrameData* frame_data =
1737 aggregated_frame->delegated_frame_data.get();
1738
1739 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
1740
1741 ASSERT_EQ(3u, aggregated_pass_list.size());
1742
1743 // Pass 0 is solid color quad from root, but outside damage rect.
1744 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[0]->damage_rect);
1745 EXPECT_EQ(0u, aggregated_pass_list[0]->quad_list.size());
1746 EXPECT_EQ(gfx::Rect(SurfaceSize()), aggregated_pass_list[1]->damage_rect);
1747 EXPECT_EQ(1u, aggregated_pass_list[1]->quad_list.size());
1748
1749 // First render pass draw quad is outside damage rect, so shouldn't be
1750 // drawn. SurfaceDrawQuad is after background filter, so corresponding
1751 // RenderPassDrawQuad should be drawn.
1752 EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect);
1753 EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size());
1754 }
1755
1756 factory_.Destroy(child_surface_id); 1650 factory_.Destroy(child_surface_id);
1757 } 1651 }
1758 1652
1759 class SurfaceAggregatorWithResourcesTest : public testing::Test { 1653 class SurfaceAggregatorWithResourcesTest : public testing::Test {
1760 public: 1654 public:
1761 void SetUp() override { 1655 void SetUp() override {
1762 output_surface_ = FakeOutputSurface::CreateSoftware( 1656 output_surface_ = FakeOutputSurface::CreateSoftware(
1763 base::WrapUnique(new SoftwareOutputDevice)); 1657 base::WrapUnique(new SoftwareOutputDevice));
1764 output_surface_->BindToClient(&output_surface_client_); 1658 output_surface_->BindToClient(&output_surface_client_);
1765 shared_bitmap_manager_.reset(new TestSharedBitmapManager); 1659 shared_bitmap_manager_.reset(new TestSharedBitmapManager);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); 1893 EXPECT_EQ(9u, pass_list->back()->quad_list.size());
2000 1894
2001 factory.Destroy(root_surface_id); 1895 factory.Destroy(root_surface_id);
2002 factory.Destroy(child_surface_id); 1896 factory.Destroy(child_surface_id);
2003 factory.Destroy(middle_surface_id); 1897 factory.Destroy(middle_surface_id);
2004 } 1898 }
2005 1899
2006 } // namespace 1900 } // namespace
2007 } // namespace cc 1901 } // namespace cc
2008 1902
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator.cc ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698