| OLD | NEW |
| 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 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 } | 1636 } |
| 1637 | 1637 |
| 1638 class TestLayer : public Layer { | 1638 class TestLayer : public Layer { |
| 1639 public: | 1639 public: |
| 1640 static scoped_refptr<TestLayer> create() { return make_scoped_refptr(new Tes
tLayer()); } | 1640 static scoped_refptr<TestLayer> create() { return make_scoped_refptr(new Tes
tLayer()); } |
| 1641 | 1641 |
| 1642 virtual void update(ResourceUpdateQueue&, const OcclusionTracker* occlusion,
RenderingStats&) OVERRIDE | 1642 virtual void update(ResourceUpdateQueue&, const OcclusionTracker* occlusion,
RenderingStats&) OVERRIDE |
| 1643 { | 1643 { |
| 1644 // Gain access to internals of the OcclusionTracker. | 1644 // Gain access to internals of the OcclusionTracker. |
| 1645 const TestOcclusionTracker* testOcclusion = static_cast<const TestOcclus
ionTracker*>(occlusion); | 1645 const TestOcclusionTracker* testOcclusion = static_cast<const TestOcclus
ionTracker*>(occlusion); |
| 1646 m_occludedScreenSpace = testOcclusion ? testOcclusion->occlusionInScreen
Space() : Region(); | 1646 if (!testOcclusion) { |
| 1647 m_occlusion.Clear(); |
| 1648 return; |
| 1649 } |
| 1650 m_occlusion = UnionRegions(testOcclusion->occlusionFromInsideTarget(), t
estOcclusion->occlusionFromOutsideTarget()); |
| 1647 } | 1651 } |
| 1648 | 1652 |
| 1649 virtual bool drawsContent() const OVERRIDE { return true; } | 1653 virtual bool drawsContent() const OVERRIDE { return true; } |
| 1650 | 1654 |
| 1651 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; } | 1655 const Region& occlusion() const { return m_occlusion; } |
| 1652 void clearOccludedScreenSpace() { m_occludedScreenSpace.Clear(); } | 1656 void clearOcclusion() { m_occlusion.Clear(); } |
| 1653 | 1657 |
| 1654 private: | 1658 private: |
| 1655 TestLayer() : Layer() { } | 1659 TestLayer() : Layer() { } |
| 1656 virtual ~TestLayer() { } | 1660 virtual ~TestLayer() { } |
| 1657 | 1661 |
| 1658 Region m_occludedScreenSpace; | 1662 Region m_occlusion; |
| 1659 }; | 1663 }; |
| 1660 | 1664 |
| 1661 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) | 1665 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) |
| 1662 { | 1666 { |
| 1663 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou
nds, opaque); | 1667 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou
nds, opaque); |
| 1664 layer->clearOccludedScreenSpace(); | 1668 layer->clearOcclusion(); |
| 1665 } | 1669 } |
| 1666 | 1670 |
| 1667 class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest { | 1671 class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest { |
| 1668 public: | 1672 public: |
| 1669 LayerTreeHostTestLayerOcclusion() { } | 1673 LayerTreeHostTestLayerOcclusion() { } |
| 1670 | 1674 |
| 1671 virtual void beginTest() OVERRIDE | 1675 virtual void beginTest() OVERRIDE |
| 1672 { | 1676 { |
| 1673 scoped_refptr<TestLayer> rootLayer = TestLayer::create(); | 1677 scoped_refptr<TestLayer> rootLayer = TestLayer::create(); |
| 1674 scoped_refptr<TestLayer> child = TestLayer::create(); | 1678 scoped_refptr<TestLayer> child = TestLayer::create(); |
| 1675 scoped_refptr<TestLayer> child2 = TestLayer::create(); | 1679 scoped_refptr<TestLayer> child2 = TestLayer::create(); |
| 1676 scoped_refptr<TestLayer> grandChild = TestLayer::create(); | 1680 scoped_refptr<TestLayer> grandChild = TestLayer::create(); |
| 1677 scoped_refptr<TestLayer> mask = TestLayer::create(); | 1681 scoped_refptr<TestLayer> mask = TestLayer::create(); |
| 1678 | 1682 |
| 1679 gfx::Transform identityMatrix; | 1683 gfx::Transform identityMatrix; |
| 1680 gfx::Transform childTransform; | |
| 1681 childTransform.Translate(250, 250); | |
| 1682 childTransform.Rotate(90); | |
| 1683 childTransform.Translate(-250, -250); | |
| 1684 | 1684 |
| 1685 child->setMasksToBounds(true); | 1685 child->setMasksToBounds(true); |
| 1686 child->setForceRenderSurface(true); |
| 1686 | 1687 |
| 1687 // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedS
urface for a nice visual of these layers and how they end up | 1688 // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedS
urface for a nice visual of these layers and how they end up |
| 1688 // positioned on the screen. | 1689 // positioned on the screen. |
| 1689 | 1690 |
| 1690 // The child layer is rotated and the grandChild is opaque, but clipped
to the child and rootLayer | 1691 // The child layer is a surface and the grandChild is opaque, but clippe
d to the child and rootLayer |
| 1691 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | 1692 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
| 1692 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), false); | 1693 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM
atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), false); |
| 1693 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | 1694 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, 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 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | 1698 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
| 1698 ResourceUpdateQueue queue; | 1699 ResourceUpdateQueue queue; |
| 1699 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1700 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
| 1700 m_layerTreeHost->commitComplete(); | 1701 m_layerTreeHost->commitComplete(); |
| 1701 | 1702 |
| 1702 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt
ring()); | 1703 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString()); |
| 1703 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS
pace().ToString()); | 1704 EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToStri
ng()); |
| 1704 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), rootLayer->occludedScr
eenSpace().ToString()); | 1705 EXPECT_EQ(gfx::Rect(10, 10, 10, 190).ToString(), rootLayer->occlusion().
ToString()); |
| 1705 | 1706 |
| 1706 // If the child layer is opaque, then it adds to the occlusion seen by t
he rootLayer. | 1707 // If the child layer is opaque, then it adds to the occlusion seen by t
he rootLayer. |
| 1707 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | 1708 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
| 1708 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor
m, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); | 1709 setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatri
x, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
| 1709 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | 1710 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true); |
| 1710 | 1711 |
| 1711 m_layerTreeHost->setRootLayer(rootLayer); | 1712 m_layerTreeHost->setRootLayer(rootLayer); |
| 1712 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1713 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
| 1713 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1714 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
| 1714 m_layerTreeHost->commitComplete(); | 1715 m_layerTreeHost->commitComplete(); |
| 1715 | 1716 |
| 1716 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt
ring()); | 1717 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString()); |
| 1717 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS
pace().ToString()); | 1718 EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToStri
ng()); |
| 1718 EXPECT_EQ(gfx::Rect(30, 30, 170, 170).ToString(), rootLayer->occludedScr
eenSpace().ToString()); | 1719 EXPECT_EQ(gfx::Rect(10, 10, 190, 190).ToString(), rootLayer->occlusion()
.ToString()); |
| 1719 | 1720 |
| 1720 // Add a second child to the root layer and the regions should merge | 1721 // Add a second child to the root layer and the regions should merge |
| 1721 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | 1722 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(70, 20), gfx::Size(500, 500), true); | 1723 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM
atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), false); |
| 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(20, 500), true); |
| 1724 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | 1725 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true); |
| 1725 | 1726 |
| 1726 m_layerTreeHost->setRootLayer(rootLayer); | 1727 m_layerTreeHost->setRootLayer(rootLayer); |
| 1727 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1728 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
| 1728 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1729 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
| 1729 m_layerTreeHost->commitComplete(); | 1730 m_layerTreeHost->commitComplete(); |
| 1730 | 1731 |
| 1731 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt
ring()); | 1732 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); |
| 1732 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS
pace().ToString()); | 1733 EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion().
ToString()); |
| 1733 EXPECT_EQ(gfx::Rect(30, 30, 170, 170).ToString(), child2->occludedScreen
Space().ToString()); | 1734 EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToStri
ng()); |
| 1734 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 170, 170), gfx::Rect(70, 20, 13
0, 180)).ToString(), rootLayer->occludedScreenSpace().ToString()); | 1735 EXPECT_EQ(gfx::Rect(10, 10, 20, 190).ToString(), rootLayer->occlusion().
ToString()); |
| 1735 | |
| 1736 // Move the second child to be sure. | |
| 1737 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | |
| 1738 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); | |
| 1739 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); | |
| 1740 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | |
| 1741 | |
| 1742 m_layerTreeHost->setRootLayer(rootLayer); | |
| 1743 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | |
| 1744 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | |
| 1745 m_layerTreeHost->commitComplete(); | |
| 1746 | |
| 1747 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt
ring()); | |
| 1748 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS
pace().ToString()); | |
| 1749 EXPECT_EQ(gfx::Rect(30, 30, 170, 170).ToString(), child2->occludedScreen
Space().ToString()); | |
| 1750 EXPECT_EQ(UnionRegions(gfx::Rect(10, 70, 190, 130), gfx::Rect(30, 30, 17
0, 170)).ToString(), rootLayer->occludedScreenSpace().ToString()); | |
| 1751 | 1736 |
| 1752 // If the child layer has a mask on it, then it shouldn't contribute to
occlusion on stuff below it | 1737 // If the child layer has a mask on it, then it shouldn't contribute to
occlusion on stuff below it |
| 1753 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | 1738 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
| 1754 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); | 1739 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
| 1755 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor
m, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); | 1740 setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatri
x, gfx::PointF(0, 0), gfx::PointF(20, 20), gfx::Size(500, 500), true); |
| 1756 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | 1741 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(500, 500), true); |
| 1757 | 1742 |
| 1758 child->setMaskLayer(mask.get()); | 1743 child->setMaskLayer(mask.get()); |
| 1759 | 1744 |
| 1760 m_layerTreeHost->setRootLayer(rootLayer); | 1745 m_layerTreeHost->setRootLayer(rootLayer); |
| 1761 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1746 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
| 1762 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1747 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
| 1763 m_layerTreeHost->commitComplete(); | 1748 m_layerTreeHost->commitComplete(); |
| 1764 | 1749 |
| 1765 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt
ring()); | 1750 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString()); |
| 1766 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS
pace().ToString()); | 1751 EXPECT_EQ(gfx::Rect(0, 0, 180, 180).ToString(), child->occlusion().ToStr
ing()); |
| 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(), rootLayer->occludedScr
eenSpace().ToString()); | 1753 EXPECT_EQ(gfx::Rect(10, 10, 190, 190).ToString(), rootLayer->occlusion()
.ToString()); |
| 1769 | 1754 |
| 1770 // 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 // 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 |
| 1771 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | 1756 setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx::Po
intF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
| 1772 setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransfor
m, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); | 1757 setLayerPropertiesForTesting(child.get(), rootLayer.get(), identityMatri
x, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
| 1773 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | 1758 setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true); |
| 1774 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); | 1759 setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatr
ix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true); |
| 1775 | 1760 |
| 1776 child->setMaskLayer(mask.get()); | 1761 child->setMaskLayer(mask.get()); |
| 1777 | 1762 |
| 1778 m_layerTreeHost->setRootLayer(rootLayer); | 1763 m_layerTreeHost->setRootLayer(rootLayer); |
| 1779 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1764 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
| 1780 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1765 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
| 1781 m_layerTreeHost->commitComplete(); | 1766 m_layerTreeHost->commitComplete(); |
| 1782 | 1767 |
| 1783 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString
()); | 1768 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); |
| 1784 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), grandChild->occludedSc
reenSpace().ToString()); | 1769 EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion().
ToString()); |
| 1785 EXPECT_EQ(UnionRegions(gfx::Rect(30, 40, 170, 160), gfx::Rect(10, 70, 19
0, 130)).ToString(), child->occludedScreenSpace().ToString()); | 1770 EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToStri
ng()); |
| 1786 EXPECT_EQ(gfx::Rect(10, 70, 190, 130), rootLayer->occludedScreenSpace())
; | 1771 EXPECT_EQ(gfx::Rect(20, 10, 10, 190), rootLayer->occlusion()); |
| 1787 | 1772 |
| 1788 // If the child layer has a non-opaque drawOpacity, then it shouldn't co
ntribute to occlusion on stuff below it | 1773 // If the child layer has a non-opaque drawOpacity, then it shouldn't co
ntribute to occlusion on stuff below it |
| 1789 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | 1774 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
| 1790 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); | 1775 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true); |
| 1791 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); | 1776 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM
atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
| 1792 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | 1777 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true); |
| 1793 | 1778 |
| 1794 child->setMaskLayer(0); | 1779 child->setMaskLayer(0); |
| 1795 child->setOpacity(0.5); | 1780 child->setOpacity(0.5); |
| 1796 | 1781 |
| 1797 m_layerTreeHost->setRootLayer(rootLayer); | 1782 m_layerTreeHost->setRootLayer(rootLayer); |
| 1798 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1783 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
| 1799 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1784 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
| 1800 m_layerTreeHost->commitComplete(); | 1785 m_layerTreeHost->commitComplete(); |
| 1801 | 1786 |
| 1802 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt
ring()); | 1787 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString()); |
| 1803 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS
pace().ToString()); | 1788 EXPECT_EQ(gfx::Rect(0, 0, 10, 190).ToString(), child->occlusion().ToStri
ng()); |
| 1804 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString
()); | 1789 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); |
| 1805 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScr
eenSpace().ToString()); | 1790 EXPECT_EQ(gfx::Rect(20, 10, 10, 190).ToString(), rootLayer->occlusion().
ToString()); |
| 1806 | 1791 |
| 1807 // 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 // 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 |
| 1808 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | 1793 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
| 1809 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); | 1794 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), identityM
atrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
| 1810 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | 1795 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(-10, -10), gfx::Size(20, 500), true); |
| 1811 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); | 1796 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(20, 10), gfx::Size(10, 500), true); |
| 1812 | 1797 |
| 1813 child->setMaskLayer(0); | 1798 child->setMaskLayer(0); |
| 1814 child->setOpacity(0.5); | 1799 child->setOpacity(0.5); |
| 1815 | 1800 |
| 1816 m_layerTreeHost->setRootLayer(rootLayer); | 1801 m_layerTreeHost->setRootLayer(rootLayer); |
| 1817 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1802 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
| 1818 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1803 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
| 1819 m_layerTreeHost->commitComplete(); | 1804 m_layerTreeHost->commitComplete(); |
| 1820 | 1805 |
| 1821 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString
()); | 1806 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); |
| 1822 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), grandChild->occludedSc
reenSpace().ToString()); | 1807 EXPECT_EQ(gfx::Rect(10, 0, 10, 190).ToString(), grandChild->occlusion().
ToString()); |
| 1823 EXPECT_EQ(UnionRegions(gfx::Rect(30, 40, 170, 160), gfx::Rect(10, 70, 19
0, 130)).ToString(), child->occludedScreenSpace().ToString()); | 1808 EXPECT_EQ(gfx::Rect(0, 0, 20, 190).ToString(), child->occlusion().ToStri
ng()); |
| 1824 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScr
eenSpace().ToString()); | 1809 EXPECT_EQ(gfx::Rect(20, 10, 10, 190).ToString(), rootLayer->occlusion().
ToString()); |
| 1825 | 1810 |
| 1826 // Kill the layerTreeHost immediately. | 1811 // Kill the layerTreeHost immediately. |
| 1827 m_layerTreeHost->setRootLayer(0); | 1812 m_layerTreeHost->setRootLayer(0); |
| 1828 m_layerTreeHost.reset(); | 1813 m_layerTreeHost.reset(); |
| 1829 | 1814 |
| 1830 endTest(); | 1815 endTest(); |
| 1831 } | 1816 } |
| 1832 | 1817 |
| 1833 virtual void afterTest() OVERRIDE | 1818 virtual void afterTest() OVERRIDE |
| 1834 { | 1819 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 child->setFilters(filters); | 1855 child->setFilters(filters); |
| 1871 } | 1856 } |
| 1872 | 1857 |
| 1873 m_layerTreeHost->setRootLayer(rootLayer); | 1858 m_layerTreeHost->setRootLayer(rootLayer); |
| 1874 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1859 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
| 1875 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | 1860 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
| 1876 ResourceUpdateQueue queue; | 1861 ResourceUpdateQueue queue; |
| 1877 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1862 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
| 1878 m_layerTreeHost->commitComplete(); | 1863 m_layerTreeHost->commitComplete(); |
| 1879 | 1864 |
| 1880 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString
()); | 1865 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); |
| 1881 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), grandChild->occludedSc
reenSpace().ToString()); | 1866 EXPECT_EQ(gfx::Rect(40, 330, 130, 190).ToString(), grandChild->occlusion
().ToString()); |
| 1882 EXPECT_EQ(UnionRegions(gfx::Rect(30, 40, 170, 30), gfx::Rect(10, 70, 190
, 130)).ToString(), child->occludedScreenSpace().ToString()); | 1867 EXPECT_EQ(UnionRegions(gfx::Rect(10, 330, 160, 170), gfx::Rect(40, 500,
130, 20)).ToString(), child->occlusion().ToString()); |
| 1883 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScr
eenSpace().ToString()); | 1868 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occlusion()
.ToString()); |
| 1884 | 1869 |
| 1885 // 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 // 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, |
| 1886 // and should not contribute to the rootLayer | 1871 // and should not contribute to the rootLayer |
| 1887 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); | 1872 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx
::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); |
| 1888 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); | 1873 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran
sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); |
| 1889 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); | 1874 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); |
| 1890 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); | 1875 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity
Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); |
| 1891 | 1876 |
| 1892 { | 1877 { |
| 1893 WebKit::WebFilterOperations filters; | 1878 WebKit::WebFilterOperations filters; |
| 1894 filters.append(WebKit::WebFilterOperation::createBlurFilter(10)); | 1879 filters.append(WebKit::WebFilterOperation::createBlurFilter(10)); |
| 1895 child->setFilters(filters); | 1880 child->setFilters(filters); |
| 1896 } | 1881 } |
| 1897 | 1882 |
| 1898 m_layerTreeHost->setRootLayer(rootLayer); | 1883 m_layerTreeHost->setRootLayer(rootLayer); |
| 1899 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); | 1884 m_layerTreeHost->setViewportSize(rootLayer->bounds(), rootLayer->bounds(
)); |
| 1900 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1885 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
| 1901 m_layerTreeHost->commitComplete(); | 1886 m_layerTreeHost->commitComplete(); |
| 1902 | 1887 |
| 1903 EXPECT_EQ(gfx::Rect().ToString(), child2->occludedScreenSpace().ToString
()); | 1888 EXPECT_EQ(gfx::Rect().ToString(), child2->occlusion().ToString()); |
| 1904 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occludedScreenSpace().ToSt
ring()); | 1889 EXPECT_EQ(gfx::Rect().ToString(), grandChild->occlusion().ToString()); |
| 1905 EXPECT_EQ(gfx::Rect(30, 40, 170, 160).ToString(), child->occludedScreenS
pace().ToString()); | 1890 EXPECT_EQ(gfx::Rect(10, 330, 160, 170).ToString(), child->occlusion().To
String()); |
| 1906 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occludedScr
eenSpace().ToString()); | 1891 EXPECT_EQ(gfx::Rect(10, 70, 190, 130).ToString(), rootLayer->occlusion()
.ToString()); |
| 1907 | 1892 |
| 1908 // Kill the layerTreeHost immediately. | 1893 // Kill the layerTreeHost immediately. |
| 1909 m_layerTreeHost->setRootLayer(0); | 1894 m_layerTreeHost->setRootLayer(0); |
| 1910 m_layerTreeHost.reset(); | 1895 m_layerTreeHost.reset(); |
| 1911 | 1896 |
| 1912 LayerTreeHost::setNeedsFilterContext(false); | 1897 LayerTreeHost::setNeedsFilterContext(false); |
| 1913 endTest(); | 1898 endTest(); |
| 1914 } | 1899 } |
| 1915 | 1900 |
| 1916 virtual void afterTest() OVERRIDE | 1901 virtual void afterTest() OVERRIDE |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 } | 1937 } |
| 1953 | 1938 |
| 1954 m_layerTreeHost->setRootLayer(layers[0].get()); | 1939 m_layerTreeHost->setRootLayer(layers[0].get()); |
| 1955 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds(
)); | 1940 m_layerTreeHost->setViewportSize(layers[0]->bounds(), layers[0]->bounds(
)); |
| 1956 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); | 1941 ASSERT_TRUE(m_layerTreeHost->initializeRendererIfNeeded()); |
| 1957 ResourceUpdateQueue queue; | 1942 ResourceUpdateQueue queue; |
| 1958 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; | 1943 m_layerTreeHost->updateLayers(queue, std::numeric_limits<size_t>::max())
; |
| 1959 m_layerTreeHost->commitComplete(); | 1944 m_layerTreeHost->commitComplete(); |
| 1960 | 1945 |
| 1961 for (int i = 0; i < numSurfaces-1; ++i) { | 1946 for (int i = 0; i < numSurfaces-1; ++i) { |
| 1962 gfx::Rect expectedOcclusion(i+1, i+1, 200-i-1, 200-i-1); | 1947 gfx::Rect expectedOcclusion(1, 1, 200-i-1, 200-i-1); |
| 1963 EXPECT_EQ(expectedOcclusion.ToString(), layers[i]->occludedScreenSpa
ce().ToString()); | 1948 EXPECT_EQ(expectedOcclusion.ToString(), layers[i]->occlusion().ToStr
ing()); |
| 1964 } | 1949 } |
| 1965 | 1950 |
| 1966 // Kill the layerTreeHost immediately. | 1951 // Kill the layerTreeHost immediately. |
| 1967 m_layerTreeHost->setRootLayer(0); | 1952 m_layerTreeHost->setRootLayer(0); |
| 1968 m_layerTreeHost.reset(); | 1953 m_layerTreeHost.reset(); |
| 1969 | 1954 |
| 1970 endTest(); | 1955 endTest(); |
| 1971 } | 1956 } |
| 1972 | 1957 |
| 1973 virtual void afterTest() OVERRIDE | 1958 virtual void afterTest() OVERRIDE |
| (...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3395 LayerTreeSettings settings; | 3380 LayerTreeSettings settings; |
| 3396 settings.maxPartialTextureUpdates = 4; | 3381 settings.maxPartialTextureUpdates = 4; |
| 3397 | 3382 |
| 3398 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); | 3383 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc
oped_ptr<Thread>()); |
| 3399 EXPECT_TRUE(host->initializeRendererIfNeeded()); | 3384 EXPECT_TRUE(host->initializeRendererIfNeeded()); |
| 3400 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); | 3385 EXPECT_EQ(0u, host->settings().maxPartialTextureUpdates); |
| 3401 } | 3386 } |
| 3402 | 3387 |
| 3403 } // namespace | 3388 } // namespace |
| 3404 } // namespace cc | 3389 } // namespace cc |
| OLD | NEW |