OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/graphics/paint/PaintController.h" | 5 #include "platform/graphics/paint/PaintController.h" |
6 | 6 |
7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
9 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 9 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
10 #include "platform/graphics/paint/ClipPathRecorder.h" | 10 #include "platform/graphics/paint/ClipPathRecorder.h" |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 FloatRect(100, 100, 150, 150)); | 791 FloatRect(100, 100, 150, 150)); |
792 drawRect(context, second, backgroundDrawingType, | 792 drawRect(context, second, backgroundDrawingType, |
793 FloatRect(100, 100, 150, 150)); | 793 FloatRect(100, 100, 150, 150)); |
794 getPaintController().commitNewDisplayItems(); | 794 getPaintController().commitNewDisplayItems(); |
795 | 795 |
796 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 796 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
797 TestDisplayItem(first, backgroundDrawingType), | 797 TestDisplayItem(first, backgroundDrawingType), |
798 TestDisplayItem(second, backgroundDrawingType)); | 798 TestDisplayItem(second, backgroundDrawingType)); |
799 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); | 799 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); |
800 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); | 800 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); |
801 const PaintRecord* firstPaintRecord = | 801 sk_sp<const PaintRecord> firstPaintRecord = |
danakj
2017/03/16 20:06:17
could be const& if u want
enne (OOO)
2017/03/20 17:14:15
ASAN disagrees: https://build.chromium.org/p/tryse
| |
802 static_cast<const DrawingDisplayItem&>( | 802 static_cast<const DrawingDisplayItem&>( |
803 getPaintController().getDisplayItemList()[0]) | 803 getPaintController().getDisplayItemList()[0]) |
804 .GetPaintRecord(); | 804 .GetPaintRecord(); |
805 const PaintRecord* secondPaintRecord = | 805 sk_sp<const PaintRecord> secondPaintRecord = |
danakj
2017/03/16 20:06:17
same
| |
806 static_cast<const DrawingDisplayItem&>( | 806 static_cast<const DrawingDisplayItem&>( |
807 getPaintController().getDisplayItemList()[1]) | 807 getPaintController().getDisplayItemList()[1]) |
808 .GetPaintRecord(); | 808 .GetPaintRecord(); |
809 | 809 |
810 first.setDisplayItemsUncached(); | 810 first.setDisplayItemsUncached(); |
811 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); | 811 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); |
812 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); | 812 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); |
813 | 813 |
814 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 814 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
815 getPaintController().updateCurrentPaintChunkProperties( | 815 getPaintController().updateCurrentPaintChunkProperties( |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1585 drawRect(context, content, foregroundDrawingType, rect1); | 1585 drawRect(context, content, foregroundDrawingType, rect1); |
1586 drawRect(context, content, foregroundDrawingType, rect2); | 1586 drawRect(context, content, foregroundDrawingType, rect2); |
1587 getPaintController().endSkippingCache(); | 1587 getPaintController().endSkippingCache(); |
1588 | 1588 |
1589 getPaintController().commitNewDisplayItems(); | 1589 getPaintController().commitNewDisplayItems(); |
1590 | 1590 |
1591 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 1591 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
1592 TestDisplayItem(multicol, backgroundDrawingType), | 1592 TestDisplayItem(multicol, backgroundDrawingType), |
1593 TestDisplayItem(content, foregroundDrawingType), | 1593 TestDisplayItem(content, foregroundDrawingType), |
1594 TestDisplayItem(content, foregroundDrawingType)); | 1594 TestDisplayItem(content, foregroundDrawingType)); |
1595 sk_sp<const PaintRecord> record1 = | 1595 sk_sp<const PaintRecord> record1 = |
danakj
2017/03/16 20:06:17
same
| |
1596 sk_ref_sp(static_cast<const DrawingDisplayItem&>( | 1596 static_cast<const DrawingDisplayItem&>( |
1597 getPaintController().getDisplayItemList()[1]) | 1597 getPaintController().getDisplayItemList()[1]) |
1598 .GetPaintRecord()); | 1598 .GetPaintRecord(); |
1599 sk_sp<const PaintRecord> record2 = | 1599 sk_sp<const PaintRecord> record2 = |
1600 sk_ref_sp(static_cast<const DrawingDisplayItem&>( | 1600 static_cast<const DrawingDisplayItem&>( |
1601 getPaintController().getDisplayItemList()[2]) | 1601 getPaintController().getDisplayItemList()[2]) |
1602 .GetPaintRecord()); | 1602 .GetPaintRecord(); |
1603 EXPECT_NE(record1, record2); | 1603 EXPECT_NE(record1, record2); |
1604 | 1604 |
1605 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1605 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
1606 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | 1606 EXPECT_EQ(1u, getPaintController().paintChunks().size()); |
1607 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects, | 1607 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects, |
1608 UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); | 1608 UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); |
1609 | 1609 |
1610 getPaintController().updateCurrentPaintChunkProperties( | 1610 getPaintController().updateCurrentPaintChunkProperties( |
1611 &m_rootPaintChunkId, defaultPaintChunkProperties()); | 1611 &m_rootPaintChunkId, defaultPaintChunkProperties()); |
1612 } | 1612 } |
(...skipping 14 matching lines...) Expand all Loading... | |
1627 EXPECT_EQ(0, numOutOfOrderMatches()); | 1627 EXPECT_EQ(0, numOutOfOrderMatches()); |
1628 EXPECT_EQ(0, numIndexedItems()); | 1628 EXPECT_EQ(0, numIndexedItems()); |
1629 #endif | 1629 #endif |
1630 | 1630 |
1631 getPaintController().commitNewDisplayItems(); | 1631 getPaintController().commitNewDisplayItems(); |
1632 | 1632 |
1633 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 1633 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
1634 TestDisplayItem(multicol, backgroundDrawingType), | 1634 TestDisplayItem(multicol, backgroundDrawingType), |
1635 TestDisplayItem(content, foregroundDrawingType), | 1635 TestDisplayItem(content, foregroundDrawingType), |
1636 TestDisplayItem(content, foregroundDrawingType)); | 1636 TestDisplayItem(content, foregroundDrawingType)); |
1637 EXPECT_NE(record1.get(), static_cast<const DrawingDisplayItem&>( | 1637 EXPECT_NE(record1, static_cast<const DrawingDisplayItem&>( |
1638 getPaintController().getDisplayItemList()[1]) | 1638 getPaintController().getDisplayItemList()[1]) |
1639 .GetPaintRecord()); | 1639 .GetPaintRecord()); |
1640 EXPECT_NE(record2.get(), static_cast<const DrawingDisplayItem&>( | 1640 EXPECT_NE(record2, static_cast<const DrawingDisplayItem&>( |
1641 getPaintController().getDisplayItemList()[2]) | 1641 getPaintController().getDisplayItemList()[2]) |
1642 .GetPaintRecord()); | 1642 .GetPaintRecord()); |
1643 | 1643 |
1644 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1644 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
1645 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | 1645 EXPECT_EQ(1u, getPaintController().paintChunks().size()); |
1646 EXPECT_THAT( | 1646 EXPECT_THAT( |
1647 getPaintController().paintChunks()[0].rasterInvalidationRects, | 1647 getPaintController().paintChunks()[0].rasterInvalidationRects, |
1648 UnorderedElementsAre( | 1648 UnorderedElementsAre( |
1649 FloatRect(100, 100, 100, 100), // Old bounds of |content|. | 1649 FloatRect(100, 100, 100, 100), // Old bounds of |content|. |
1650 FloatRect(100, 100, 100, 100))); // New bounds of |content|. | 1650 FloatRect(100, 100, 100, 100))); // New bounds of |content|. |
1651 | 1651 |
1652 getPaintController().updateCurrentPaintChunkProperties( | 1652 getPaintController().updateCurrentPaintChunkProperties( |
(...skipping 10 matching lines...) Expand all Loading... | |
1663 drawRect(context, content, foregroundDrawingType, rect2); | 1663 drawRect(context, content, foregroundDrawingType, rect2); |
1664 drawRect(context, content, foregroundDrawingType, rect3); | 1664 drawRect(context, content, foregroundDrawingType, rect3); |
1665 getPaintController().endSkippingCache(); | 1665 getPaintController().endSkippingCache(); |
1666 | 1666 |
1667 // We should repaint everything on invalidation of the scope container. | 1667 // We should repaint everything on invalidation of the scope container. |
1668 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4, | 1668 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4, |
1669 TestDisplayItem(multicol, backgroundDrawingType), | 1669 TestDisplayItem(multicol, backgroundDrawingType), |
1670 TestDisplayItem(content, foregroundDrawingType), | 1670 TestDisplayItem(content, foregroundDrawingType), |
1671 TestDisplayItem(content, foregroundDrawingType), | 1671 TestDisplayItem(content, foregroundDrawingType), |
1672 TestDisplayItem(content, foregroundDrawingType)); | 1672 TestDisplayItem(content, foregroundDrawingType)); |
1673 EXPECT_NE(record1.get(), static_cast<const DrawingDisplayItem&>( | 1673 EXPECT_NE(record1, static_cast<const DrawingDisplayItem&>( |
1674 getPaintController().newDisplayItemList()[1]) | 1674 getPaintController().newDisplayItemList()[1]) |
1675 .GetPaintRecord()); | 1675 .GetPaintRecord()); |
1676 EXPECT_NE(record2.get(), static_cast<const DrawingDisplayItem&>( | 1676 EXPECT_NE(record2, static_cast<const DrawingDisplayItem&>( |
1677 getPaintController().newDisplayItemList()[2]) | 1677 getPaintController().newDisplayItemList()[2]) |
1678 .GetPaintRecord()); | 1678 .GetPaintRecord()); |
1679 | 1679 |
1680 getPaintController().commitNewDisplayItems(); | 1680 getPaintController().commitNewDisplayItems(); |
1681 | 1681 |
1682 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1682 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
1683 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | 1683 EXPECT_EQ(1u, getPaintController().paintChunks().size()); |
1684 EXPECT_THAT( | 1684 EXPECT_THAT( |
1685 getPaintController().paintChunks()[0].rasterInvalidationRects, | 1685 getPaintController().paintChunks()[0].rasterInvalidationRects, |
1686 UnorderedElementsAre( | 1686 UnorderedElementsAre( |
1687 FloatRect(100, 100, 200, 200), // Old bounds of |multicol|. | 1687 FloatRect(100, 100, 200, 200), // Old bounds of |multicol|. |
1688 FloatRect(100, 100, 200, 200), // New bounds of |multicol|. | 1688 FloatRect(100, 100, 200, 200), // New bounds of |multicol|. |
(...skipping 19 matching lines...) Expand all Loading... | |
1708 drawRect(context, content, foregroundDrawingType, rect2); | 1708 drawRect(context, content, foregroundDrawingType, rect2); |
1709 getPaintController().endSkippingCache(); | 1709 getPaintController().endSkippingCache(); |
1710 drawRect(context, content, foregroundDrawingType, rect3); | 1710 drawRect(context, content, foregroundDrawingType, rect3); |
1711 | 1711 |
1712 getPaintController().commitNewDisplayItems(); | 1712 getPaintController().commitNewDisplayItems(); |
1713 | 1713 |
1714 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 1714 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
1715 TestDisplayItem(content, backgroundDrawingType), | 1715 TestDisplayItem(content, backgroundDrawingType), |
1716 TestDisplayItem(content, foregroundDrawingType), | 1716 TestDisplayItem(content, foregroundDrawingType), |
1717 TestDisplayItem(content, foregroundDrawingType)); | 1717 TestDisplayItem(content, foregroundDrawingType)); |
1718 sk_sp<const PaintRecord> record0 = | 1718 sk_sp<const PaintRecord> record0 = |
danakj
2017/03/16 20:06:17
same
| |
1719 sk_ref_sp(static_cast<const DrawingDisplayItem&>( | 1719 static_cast<const DrawingDisplayItem&>( |
1720 getPaintController().getDisplayItemList()[0]) | 1720 getPaintController().getDisplayItemList()[0]) |
1721 .GetPaintRecord()); | 1721 .GetPaintRecord(); |
1722 sk_sp<const PaintRecord> record1 = | 1722 sk_sp<const PaintRecord> record1 = |
1723 sk_ref_sp(static_cast<const DrawingDisplayItem&>( | 1723 static_cast<const DrawingDisplayItem&>( |
1724 getPaintController().getDisplayItemList()[1]) | 1724 getPaintController().getDisplayItemList()[1]) |
1725 .GetPaintRecord()); | 1725 .GetPaintRecord(); |
1726 sk_sp<const PaintRecord> record2 = | 1726 sk_sp<const PaintRecord> record2 = |
1727 sk_ref_sp(static_cast<const DrawingDisplayItem&>( | 1727 static_cast<const DrawingDisplayItem&>( |
1728 getPaintController().getDisplayItemList()[2]) | 1728 getPaintController().getDisplayItemList()[2]) |
1729 .GetPaintRecord()); | 1729 .GetPaintRecord(); |
1730 EXPECT_NE(record1, record2); | 1730 EXPECT_NE(record1, record2); |
1731 | 1731 |
1732 // Content's cache is invalid because it has display items skipped cache. | 1732 // Content's cache is invalid because it has display items skipped cache. |
1733 EXPECT_FALSE(getPaintController().clientCacheIsValid(content)); | 1733 EXPECT_FALSE(getPaintController().clientCacheIsValid(content)); |
1734 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason()); | 1734 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason()); |
1735 | 1735 |
1736 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1736 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
1737 getPaintController().updateCurrentPaintChunkProperties( | 1737 getPaintController().updateCurrentPaintChunkProperties( |
1738 &m_rootPaintChunkId, defaultPaintChunkProperties()); | 1738 &m_rootPaintChunkId, defaultPaintChunkProperties()); |
1739 } | 1739 } |
(...skipping 10 matching lines...) Expand all Loading... | |
1750 EXPECT_EQ(0, numOutOfOrderMatches()); | 1750 EXPECT_EQ(0, numOutOfOrderMatches()); |
1751 EXPECT_EQ(0, numIndexedItems()); | 1751 EXPECT_EQ(0, numIndexedItems()); |
1752 #endif | 1752 #endif |
1753 | 1753 |
1754 getPaintController().commitNewDisplayItems(); | 1754 getPaintController().commitNewDisplayItems(); |
1755 | 1755 |
1756 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 1756 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
1757 TestDisplayItem(content, backgroundDrawingType), | 1757 TestDisplayItem(content, backgroundDrawingType), |
1758 TestDisplayItem(content, foregroundDrawingType), | 1758 TestDisplayItem(content, foregroundDrawingType), |
1759 TestDisplayItem(content, foregroundDrawingType)); | 1759 TestDisplayItem(content, foregroundDrawingType)); |
1760 EXPECT_NE(record0.get(), static_cast<const DrawingDisplayItem&>( | 1760 EXPECT_NE(record0, static_cast<const DrawingDisplayItem&>( |
1761 getPaintController().getDisplayItemList()[0]) | 1761 getPaintController().getDisplayItemList()[0]) |
1762 .GetPaintRecord()); | 1762 .GetPaintRecord()); |
1763 EXPECT_NE(record1.get(), static_cast<const DrawingDisplayItem&>( | 1763 EXPECT_NE(record1, static_cast<const DrawingDisplayItem&>( |
1764 getPaintController().getDisplayItemList()[1]) | 1764 getPaintController().getDisplayItemList()[1]) |
1765 .GetPaintRecord()); | 1765 .GetPaintRecord()); |
1766 EXPECT_NE(record2.get(), static_cast<const DrawingDisplayItem&>( | 1766 EXPECT_NE(record2, static_cast<const DrawingDisplayItem&>( |
1767 getPaintController().getDisplayItemList()[2]) | 1767 getPaintController().getDisplayItemList()[2]) |
1768 .GetPaintRecord()); | 1768 .GetPaintRecord()); |
1769 } | 1769 } |
1770 | 1770 |
1771 TEST_F(PaintControllerTestBase, OptimizeNoopPairs) { | 1771 TEST_F(PaintControllerTestBase, OptimizeNoopPairs) { |
1772 FakeDisplayItemClient first("first"); | 1772 FakeDisplayItemClient first("first"); |
1773 FakeDisplayItemClient second("second"); | 1773 FakeDisplayItemClient second("second"); |
1774 FakeDisplayItemClient third("third"); | 1774 FakeDisplayItemClient third("third"); |
1775 | 1775 |
1776 GraphicsContext context(getPaintController()); | 1776 GraphicsContext context(getPaintController()); |
1777 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 1777 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
1778 { | 1778 { |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2304 } | 2304 } |
2305 | 2305 |
2306 TEST_F(PaintControllerUnderInvalidationTest, | 2306 TEST_F(PaintControllerUnderInvalidationTest, |
2307 FoldCompositingDrawingInSubsequence) { | 2307 FoldCompositingDrawingInSubsequence) { |
2308 testFoldCompositingDrawingInSubsequence(); | 2308 testFoldCompositingDrawingInSubsequence(); |
2309 } | 2309 } |
2310 | 2310 |
2311 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 2311 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
2312 | 2312 |
2313 } // namespace blink | 2313 } // namespace blink |
OLD | NEW |