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

Side by Side Diff: cc/layer_tree_host_unittest.cc

Issue 11583005: cc: Make occlusion tracker always work in target space. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/layer_tree_host.h" 5 #include "cc/layer_tree_host.h"
6 6
7 #include "base/synchronization/lock.h" 7 #include "base/synchronization/lock.h"
8 #include "cc/content_layer.h" 8 #include "cc/content_layer.h"
9 #include "cc/content_layer_client.h" 9 #include "cc/content_layer_client.h"
10 #include "cc/layer_impl.h" 10 #include "cc/layer_impl.h"
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 } 1620 }
1621 1621
1622 class TestLayer : public Layer { 1622 class TestLayer : public Layer {
1623 public: 1623 public:
1624 static scoped_refptr<TestLayer> create() { return make_scoped_refptr(new Tes tLayer()); } 1624 static scoped_refptr<TestLayer> create() { return make_scoped_refptr(new Tes tLayer()); }
1625 1625
1626 virtual void update(ResourceUpdateQueue&, const OcclusionTracker* occlusion, RenderingStats&) OVERRIDE 1626 virtual void update(ResourceUpdateQueue&, const OcclusionTracker* occlusion, RenderingStats&) OVERRIDE
1627 { 1627 {
1628 // Gain access to internals of the OcclusionTracker. 1628 // Gain access to internals of the OcclusionTracker.
1629 const TestOcclusionTracker* testOcclusion = static_cast<const TestOcclus ionTracker*>(occlusion); 1629 const TestOcclusionTracker* testOcclusion = static_cast<const TestOcclus ionTracker*>(occlusion);
1630 m_occludedScreenSpace = testOcclusion ? testOcclusion->occlusionInScreen Space() : Region(); 1630 if (!testOcclusion) {
1631 m_occlusion.Clear();
1632 return;
1633 }
1634 m_occlusion = UnionRegions(testOcclusion->occlusionFromInsideTarget(), t estOcclusion->occlusionFromOutsideTarget());
1631 } 1635 }
1632 1636
1633 virtual bool drawsContent() const OVERRIDE { return true; } 1637 virtual bool drawsContent() const OVERRIDE { return true; }
1634 1638
1635 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; } 1639 const Region& occlusion() const { return m_occlusion; }
1636 void clearOccludedScreenSpace() { m_occludedScreenSpace.Clear(); } 1640 void clearOcclusion() { m_occlusion.Clear(); }
1637 1641
1638 private: 1642 private:
1639 TestLayer() : Layer() { } 1643 TestLayer() : Layer() { }
1640 virtual ~TestLayer() { } 1644 virtual ~TestLayer() { }
1641 1645
1642 Region m_occludedScreenSpace; 1646 Region m_occlusion;
1643 }; 1647 };
1644 1648
1645 static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, co nst gfx::Transform& transform, const gfx::PointF& anchor, const gfx::PointF& pos ition, const gfx::Size& bounds, bool opaque) 1649 static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, co nst gfx::Transform& transform, const gfx::PointF& anchor, const gfx::PointF& pos ition, const gfx::Size& bounds, bool opaque)
1646 { 1650 {
1647 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou nds, opaque); 1651 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou nds, opaque);
1648 layer->clearOccludedScreenSpace(); 1652 layer->clearOcclusion();
1649 } 1653 }
1650 1654
1651 class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest { 1655 class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest {
1652 public: 1656 public:
1653 LayerTreeHostTestLayerOcclusion() { } 1657 LayerTreeHostTestLayerOcclusion() { }
1654 1658
1655 virtual void beginTest() OVERRIDE 1659 virtual void beginTest() OVERRIDE
1656 { 1660 {
1657 scoped_refptr<TestLayer> rootLayer = TestLayer::create(); 1661 scoped_refptr<TestLayer> rootLayer = TestLayer::create();
1658 scoped_refptr<TestLayer> child = TestLayer::create(); 1662 scoped_refptr<TestLayer> child = TestLayer::create();
1659 scoped_refptr<TestLayer> child2 = TestLayer::create(); 1663 scoped_refptr<TestLayer> child2 = TestLayer::create();
1660 scoped_refptr<TestLayer> grandChild = TestLayer::create(); 1664 scoped_refptr<TestLayer> grandChild = TestLayer::create();
1661 scoped_refptr<TestLayer> mask = TestLayer::create(); 1665 scoped_refptr<TestLayer> mask = TestLayer::create();
1662 1666
1663 gfx::Transform identityMatrix; 1667 gfx::Transform identityMatrix;
1664 gfx::Transform childTransform;
1665 childTransform.Translate(250, 250);
1666 childTransform.Rotate(90);
1667 childTransform.Translate(-250, -250);
1668 1668
1669 child->setMasksToBounds(true); 1669 child->setMasksToBounds(true);
1670 child->setForceRenderSurface(true);
1670 1671
1671 // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedS urface for a nice visual of these layers and how they end up 1672 // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedS urface for a nice visual of these layers and how they end up
1672 // positioned on the screen. 1673 // positioned on the screen.
1673 1674
1674 // The child layer is rotated and the grandChild is opaque, but clipped to the child and rootLayer 1675 // The child layer is a surface and the grandChild is opaque, but clippe d to the child and rootLayer
1675 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1676 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1676 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), false); 1677 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), false);
1677 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); 1678 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
1678 1679
1679 m_layerTreeHost->setRootLayer(rootLayer); 1680 m_layerTreeHost->setRootLayer(rootLayer);
1680 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1681 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1681 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); 1682 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
1682 ResourceUpdateQueue queue; 1683 ResourceUpdateQueue queue;
1683 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1684 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1684 m_layerTreeHost->commitComplete(); 1685 m_layerTreeHost->commitComplete();
1685 1686
1686 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt ring()); 1687 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString());
1687 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS pace().ToString()); 1688 EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToStri ng());
1688 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), rootLayer->occludedScr eenSpace().ToString()); 1689 EXPECT_EQ(gfx::Rect(10, 10, 10, 190).ToString(), rootLayer->occlusion(). ToString());
1689 1690
1690 // If the child layer is opaque, then it adds to the occlusion seen by t he rootLayer. 1691 // If the child layer is opaque, then it adds to the occlusion seen by t he rootLayer.
1691 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1692 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1692 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor m, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); 1693 setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatri x, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
1693 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); 1694 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
1694 1695
1695 m_layerTreeHost->setRootLayer(rootLayer); 1696 m_layerTreeHost->setRootLayer(rootLayer);
1696 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1697 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1697 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1698 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1698 m_layerTreeHost->commitComplete(); 1699 m_layerTreeHost->commitComplete();
1699 1700
1700 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt ring()); 1701 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString());
1701 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS pace().ToString()); 1702 EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToStri ng());
1702 EXPECT_EQ(gfx::Rect(30, 30, 170, 170).ToString(), rootLayer->occludedScr eenSpace().ToString()); 1703 EXPECT_EQ(gfx::Rect(10, 10, 190, 190).ToString(), rootLayer->occlusion() .ToString());
1703 1704
1704 // Add a second child to the root layer and the regions should merge 1705 // Add a second child to the root layer and the regions should merge
1705 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1706 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1706 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(70, 20), gfx::Size(500, 500), true); 1707 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), false);
1707 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); 1708 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
1708 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); 1709 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true);
1709 1710
1710 m_layerTreeHost->setRootLayer(rootLayer); 1711 m_layerTreeHost->setRootLayer(rootLayer);
1711 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1712 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1712 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1713 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1713 m_layerTreeHost->commitComplete(); 1714 m_layerTreeHost->commitComplete();
1714 1715
1715 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt ring()); 1716 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
1716 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS pace().ToString()); 1717 EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion(). ToString());
1717 EXPECT_EQ(gfx::Rect(30, 30, 170, 170).ToString(), child2->occludedScreen Space().ToString()); 1718 EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToStri ng());
1718 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 170, 170), gfx::Rect(70, 20, 13 0, 180)).ToString(), rootLayer->occludedScreenSpace().ToString()); 1719 EXPECT_EQ(gfx::Rect(10, 10, 20, 190).ToString(), rootLayer->occlusion(). ToString());
1719
1720 // Move the second child to be sure.
1721 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1722 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true);
1723 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true);
1724 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
1725
1726 m_layerTreeHost->setRootLayer(rootLayer);
1727 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1728 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1729 m_layerTreeHost->commitComplete();
1730
1731 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt ring());
1732 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS pace().ToString());
1733 EXPECT_EQ(gfx::Rect(30, 30, 170, 170).ToString(), child2->occludedScreen Space().ToString());
1734 EXPECT_EQ(UnionRegions(gfx::Rect(10, 70, 190, 130), gfx::Rect(30, 30, 17 0, 170)).ToString(), rootLayer->occludedScreenSpace().ToString());
1735 1720
1736 // If the child layer has a mask on it, then it shouldn't contribute to occlusion on stuff below it 1721 // If the child layer has a mask on it, then it shouldn't contribute to occlusion on stuff below it
1737 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1722 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1738 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); 1723 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
1739 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor m, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); 1724 setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatri x, gfx::PointF(0, 0), gfx::PointF(20, 20), gfx::Size(500, 500), true);
1740 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); 1725 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(500, 500), true);
1741 1726
1742 child->setMaskLayer(mask.get()); 1727 child->setMaskLayer(mask.get());
1743 1728
1744 m_layerTreeHost->setRootLayer(rootLayer); 1729 m_layerTreeHost->setRootLayer(rootLayer);
1745 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1730 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1746 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1731 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1747 m_layerTreeHost->commitComplete(); 1732 m_layerTreeHost->commitComplete();
1748 1733
1749 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt ring()); 1734 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString());
1750 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS pace().ToString()); 1735 EXPECT_EQ(gfx::Rect(0, 0, 180, 180).ToString(), child->occlusion().ToStr ing());
1751 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString ()); 1736 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
1752 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScr eenSpace().ToString()); 1737 EXPECT_EQ(gfx::Rect(10, 10, 190, 190).ToString(), rootLayer->occlusion() .ToString());
1753 1738
1754 // If the child layer with a mask is below child2, then child2 should co ntribute to occlusion on everything, and child shouldn't contribute to the rootL ayer 1739 // If the child layer with a mask is below child2, then child2 should co ntribute to occlusion on everything, and child shouldn't contribute to the rootL ayer
1755 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1740 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1756 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor m, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); 1741 setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatri x, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
1757 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); 1742 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
1758 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); 1743 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true);
1759 1744
1760 child->setMaskLayer(mask.get()); 1745 child->setMaskLayer(mask.get());
1761 1746
1762 m_layerTreeHost->setRootLayer(rootLayer); 1747 m_layerTreeHost->setRootLayer(rootLayer);
1763 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1748 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1764 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1749 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1765 m_layerTreeHost->commitComplete(); 1750 m_layerTreeHost->commitComplete();
1766 1751
1767 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString ()); 1752 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
1768 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), grandChild->occludedSc reenSpace().ToString()); 1753 EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion(). ToString());
1769 EXPECT_EQ(UnionRegions(gfx::Rect(30, 40, 170, 160), gfx::Rect(10, 70, 19 0, 130)).ToString(), child->occludedScreenSpace().ToString()); 1754 EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToStri ng());
1770 EXPECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpace()) ; 1755 EXPECT_EQ(gfx::Rect(20, 10, 10, 190), rootLayer->occlusion());
1771 1756
1772 // If the child layer has a non-opaque drawOpacity, then it shouldn't co ntribute to occlusion on stuff below it 1757 // If the child layer has a non-opaque drawOpacity, then it shouldn't co ntribute to occlusion on stuff below it
1773 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1758 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1774 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); 1759 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true);
1775 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); 1760 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
1776 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); 1761 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
1777 1762
1778 child->setMaskLayer(0); 1763 child->setMaskLayer(0);
1779 child->setOpacity(0.5); 1764 child->setOpacity(0.5);
1780 1765
1781 m_layerTreeHost->setRootLayer(rootLayer); 1766 m_layerTreeHost->setRootLayer(rootLayer);
1782 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1767 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1783 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1768 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1784 m_layerTreeHost->commitComplete(); 1769 m_layerTreeHost->commitComplete();
1785 1770
1786 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt ring()); 1771 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString());
1787 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS pace().ToString()); 1772 EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToStri ng());
1788 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString ()); 1773 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
1789 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScr eenSpace().ToString()); 1774 EXPECT_EQ(gfx::Rect(20, 10, 10, 190).ToString(), rootLayer->occlusion(). ToString());
1790 1775
1791 // If the child layer with non-opaque drawOpacity is below child2, then child2 should contribute to occlusion on everything, and child shouldn't contrib ute to the rootLayer 1776 // If the child layer with non-opaque drawOpacity is below child2, then child2 should contribute to occlusion on everything, and child shouldn't contrib ute to the rootLayer
1792 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1777 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1793 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); 1778 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
1794 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); 1779 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true);
1795 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); 1780 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true);
1796 1781
1797 child->setMaskLayer(0); 1782 child->setMaskLayer(0);
1798 child->setOpacity(0.5); 1783 child->setOpacity(0.5);
1799 1784
1800 m_layerTreeHost->setRootLayer(rootLayer); 1785 m_layerTreeHost->setRootLayer(rootLayer);
1801 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1786 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1802 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1787 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1803 m_layerTreeHost->commitComplete(); 1788 m_layerTreeHost->commitComplete();
1804 1789
1805 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString ()); 1790 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
1806 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), grandChild->occludedSc reenSpace().ToString()); 1791 EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion(). ToString());
1807 EXPECT_EQ(UnionRegions(gfx::Rect(30, 40, 170, 160), gfx::Rect(10, 70, 19 0, 130)).ToString(), child->occludedScreenSpace().ToString()); 1792 EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToStri ng());
1808 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScr eenSpace().ToString()); 1793 EXPECT_EQ(gfx::Rect(20, 10, 10, 190).ToString(), rootLayer->occlusion(). ToString());
1809 1794
1810 // Kill the layerTreeHost immediately. 1795 // Kill the layerTreeHost immediately.
1811 m_layerTreeHost->setRootLayer(0); 1796 m_layerTreeHost->setRootLayer(0);
1812 m_layerTreeHost.reset(); 1797 m_layerTreeHost.reset();
1813 1798
1814 endTest(); 1799 endTest();
1815 } 1800 }
1816 1801
1817 virtual void afterTest() OVERRIDE 1802 virtual void afterTest() OVERRIDE
1818 { 1803 {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 child->setFilters(filters); 1839 child->setFilters(filters);
1855 } 1840 }
1856 1841
1857 m_layerTreeHost->setRootLayer(rootLayer); 1842 m_layerTreeHost->setRootLayer(rootLayer);
1858 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1843 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1859 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); 1844 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
1860 ResourceUpdateQueue queue; 1845 ResourceUpdateQueue queue;
1861 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1846 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1862 m_layerTreeHost->commitComplete(); 1847 m_layerTreeHost->commitComplete();
1863 1848
1864 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString ()); 1849 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
1865 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), grandChild->occludedSc reenSpace().ToString()); 1850 EXPECT_EQ(gfx::Rect(40, 330, 130, 190).ToString(), grandChild->occlusion ().ToString());
1866 EXPECT_EQ(UnionRegions(gfx::Rect(30, 40, 170, 30), gfx::Rect(10, 70, 190 , 130)).ToString(), child->occludedScreenSpace().ToString()); 1851 EXPECT_EQ(UnionRegions(gfx::Rect(10, 330, 160, 170), gfx::Rect(40, 500, 130, 20)).ToString(), child->occlusion().ToString());
1867 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScr eenSpace().ToString()); 1852 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occlusion() .ToString());
1868 1853
1869 // If the child layer has a filter that moves pixels/changes alpha, and is below child2, then child should not inherit occlusion from outside its subtre e, 1854 // If the child layer has a filter that moves pixels/changes alpha, and is below child2, then child should not inherit occlusion from outside its subtre e,
1870 // and should not contribute to the rootLayer 1855 // and should not contribute to the rootLayer
1871 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1856 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1872 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); 1857 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true);
1873 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); 1858 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
1874 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); 1859 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true);
1875 1860
1876 { 1861 {
1877 WebFilterOperations filters; 1862 WebFilterOperations filters;
1878 filters.append(WebFilterOperation::createBlurFilter(10)); 1863 filters.append(WebFilterOperation::createBlurFilter(10));
1879 child->setFilters(filters); 1864 child->setFilters(filters);
1880 } 1865 }
1881 1866
1882 m_layerTreeHost->setRootLayer(rootLayer); 1867 m_layerTreeHost->setRootLayer(rootLayer);
1883 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( )); 1868 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds( ));
1884 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1869 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1885 m_layerTreeHost->commitComplete(); 1870 m_layerTreeHost->commitComplete();
1886 1871
1887 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString ()); 1872 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString());
1888 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt ring()); 1873 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString());
1889 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS pace().ToString()); 1874 EXPECT_EQ(gfx::Rect(10, 330, 160, 170).ToString(), child->occlusion().To String());
1890 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScr eenSpace().ToString()); 1875 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occlusion() .ToString());
1891 1876
1892 // Kill the layerTreeHost immediately. 1877 // Kill the layerTreeHost immediately.
1893 m_layerTreeHost->setRootLayer(0); 1878 m_layerTreeHost->setRootLayer(0);
1894 m_layerTreeHost.reset(); 1879 m_layerTreeHost.reset();
1895 1880
1896 LayerTreeHost::setNeedsFilterContext(false); 1881 LayerTreeHost::setNeedsFilterContext(false);
1897 endTest(); 1882 endTest();
1898 } 1883 }
1899 1884
1900 virtual void afterTest() OVERRIDE 1885 virtual void afterTest() OVERRIDE
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 } 1921 }
1937 1922
1938 m_layerTreeHost->setRootLayer(layers[0].get()); 1923 m_layerTreeHost->setRootLayer(layers[0].get());
1939 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds( )); 1924 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds( ));
1940 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); 1925 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded());
1941 ResourceUpdateQueue queue; 1926 ResourceUpdateQueue queue;
1942 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ; 1927 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max()) ;
1943 m_layerTreeHost->commitComplete(); 1928 m_layerTreeHost->commitComplete();
1944 1929
1945 for (int i = 0; i < numSurfaces-1; ++i) { 1930 for (int i = 0; i < numSurfaces-1; ++i) {
1946 gfx::Rect expectedOcclusion(i+1, i+1, 200-i-1, 200-i-1); 1931 gfx::Rect expectedOcclusion(1, 1, 200-i-1, 200-i-1);
1947 EXPECT_EQ(expectedOcclusion.ToString(), layers[i]->occludedScreenSpa ce().ToString()); 1932 EXPECT_EQ(expectedOcclusion.ToString(), layers[i]->occlusion().ToStr ing());
1948 } 1933 }
1949 1934
1950 // Kill the layerTreeHost immediately. 1935 // Kill the layerTreeHost immediately.
1951 m_layerTreeHost->setRootLayer(0); 1936 m_layerTreeHost->setRootLayer(0);
1952 m_layerTreeHost.reset(); 1937 m_layerTreeHost.reset();
1953 1938
1954 endTest(); 1939 endTest();
1955 } 1940 }
1956 1941
1957 virtual void afterTest() OVERRIDE 1942 virtual void afterTest() OVERRIDE
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
3379 LayerTreeSettings settings; 3364 LayerTreeSettings settings;
3380 settings.maxPartialTextureUpdates = 4; 3365 settings.maxPartialTextureUpdates = 4;
3381 3366
3382 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>()); 3367 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>());
3383 EXPECT_TRUE(host->initializeRendererIfNeeded()); 3368 EXPECT_TRUE(host->initializeRendererIfNeeded());
3384 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); 3369 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates);
3385 } 3370 }
3386 3371
3387 } // namespace 3372 } // namespace
3388 } // namespace cc 3373 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698