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 <memory> | 7 #include <memory> |
8 #include "platform/RuntimeEnabledFeatures.h" | 8 #include "platform/RuntimeEnabledFeatures.h" |
9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
10 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 10 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 : DisplayItem(client, type, sizeof(*this)) {} | 67 : DisplayItem(client, type, sizeof(*this)) {} |
68 | 68 |
69 void replay(GraphicsContext&) const final { ASSERT_NOT_REACHED(); } | 69 void replay(GraphicsContext&) const final { ASSERT_NOT_REACHED(); } |
70 void appendToWebDisplayItemList(const IntRect&, | 70 void appendToWebDisplayItemList(const IntRect&, |
71 WebDisplayItemList*) const final { | 71 WebDisplayItemList*) const final { |
72 ASSERT_NOT_REACHED(); | 72 ASSERT_NOT_REACHED(); |
73 } | 73 } |
74 }; | 74 }; |
75 | 75 |
76 #ifndef NDEBUG | 76 #ifndef NDEBUG |
77 #define TRACE_DISPLAY_ITEMS(i, expected, actual) \ | 77 #define TRACE_DISPLAY_ITEMS(i, expected, actual) \ |
78 String trace = String::format("%d: ", (int)i) + "Expected: " + \ | 78 String trace = String::format("%d: ", (int)i) + \ |
79 (expected).asDebugString() + " Actual: " + \ | 79 "Expected: " + (expected).asDebugString() + \ |
80 (actual).asDebugString(); \ | 80 " Actual: " + (actual).asDebugString(); \ |
81 SCOPED_TRACE(trace.utf8().data()); | 81 SCOPED_TRACE(trace.utf8().data()); |
82 #else | 82 #else |
83 #define TRACE_DISPLAY_ITEMS(i, expected, actual) | 83 #define TRACE_DISPLAY_ITEMS(i, expected, actual) |
84 #endif | 84 #endif |
85 | 85 |
86 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) \ | 86 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) \ |
87 do { \ | 87 do { \ |
88 EXPECT_EQ((size_t)expectedSize, actual.size()); \ | 88 EXPECT_EQ((size_t)expectedSize, actual.size()); \ |
89 if (expectedSize != actual.size()) \ | 89 if (expectedSize != actual.size()) \ |
90 break; \ | 90 break; \ |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 drawRect(context, first, backgroundDrawingType, | 818 drawRect(context, first, backgroundDrawingType, |
819 FloatRect(100, 100, 150, 150)); | 819 FloatRect(100, 100, 150, 150)); |
820 drawRect(context, second, backgroundDrawingType, | 820 drawRect(context, second, backgroundDrawingType, |
821 FloatRect(100, 100, 150, 150)); | 821 FloatRect(100, 100, 150, 150)); |
822 getPaintController().commitNewDisplayItems(); | 822 getPaintController().commitNewDisplayItems(); |
823 | 823 |
824 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, | 824 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 2, |
825 TestDisplayItem(first, backgroundDrawingType), | 825 TestDisplayItem(first, backgroundDrawingType), |
826 TestDisplayItem(second, backgroundDrawingType)); | 826 TestDisplayItem(second, backgroundDrawingType)); |
827 // The first display item should be updated. | 827 // The first display item should be updated. |
828 EXPECT_NE(firstPaintRecord, static_cast<const DrawingDisplayItem&>( | 828 EXPECT_NE(firstPaintRecord, |
829 getPaintController().getDisplayItemList()[0]) | 829 static_cast<const DrawingDisplayItem&>( |
830 .GetPaintRecord()); | 830 getPaintController().getDisplayItemList()[0]) |
| 831 .GetPaintRecord()); |
831 // The second display item should be cached. | 832 // The second display item should be cached. |
832 if (!RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { | 833 if (!RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { |
833 EXPECT_EQ(secondPaintRecord, | 834 EXPECT_EQ(secondPaintRecord, |
834 static_cast<const DrawingDisplayItem&>( | 835 static_cast<const DrawingDisplayItem&>( |
835 getPaintController().getDisplayItemList()[1]) | 836 getPaintController().getDisplayItemList()[1]) |
836 .GetPaintRecord()); | 837 .GetPaintRecord()); |
837 } | 838 } |
838 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); | 839 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); |
839 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); | 840 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); |
840 | 841 |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 EXPECT_EQ(0, numOutOfOrderMatches()); | 1628 EXPECT_EQ(0, numOutOfOrderMatches()); |
1628 EXPECT_EQ(0, numIndexedItems()); | 1629 EXPECT_EQ(0, numIndexedItems()); |
1629 #endif | 1630 #endif |
1630 | 1631 |
1631 getPaintController().commitNewDisplayItems(); | 1632 getPaintController().commitNewDisplayItems(); |
1632 | 1633 |
1633 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 1634 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
1634 TestDisplayItem(multicol, backgroundDrawingType), | 1635 TestDisplayItem(multicol, backgroundDrawingType), |
1635 TestDisplayItem(content, foregroundDrawingType), | 1636 TestDisplayItem(content, foregroundDrawingType), |
1636 TestDisplayItem(content, foregroundDrawingType)); | 1637 TestDisplayItem(content, foregroundDrawingType)); |
1637 EXPECT_NE(record1.get(), static_cast<const DrawingDisplayItem&>( | 1638 EXPECT_NE(record1.get(), |
1638 getPaintController().getDisplayItemList()[1]) | 1639 static_cast<const DrawingDisplayItem&>( |
1639 .GetPaintRecord()); | 1640 getPaintController().getDisplayItemList()[1]) |
1640 EXPECT_NE(record2.get(), static_cast<const DrawingDisplayItem&>( | 1641 .GetPaintRecord()); |
1641 getPaintController().getDisplayItemList()[2]) | 1642 EXPECT_NE(record2.get(), |
1642 .GetPaintRecord()); | 1643 static_cast<const DrawingDisplayItem&>( |
| 1644 getPaintController().getDisplayItemList()[2]) |
| 1645 .GetPaintRecord()); |
1643 | 1646 |
1644 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1647 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
1645 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | 1648 EXPECT_EQ(1u, getPaintController().paintChunks().size()); |
1646 EXPECT_THAT( | 1649 EXPECT_THAT( |
1647 getPaintController().paintChunks()[0].rasterInvalidationRects, | 1650 getPaintController().paintChunks()[0].rasterInvalidationRects, |
1648 UnorderedElementsAre( | 1651 UnorderedElementsAre( |
1649 FloatRect(100, 100, 100, 100), // Old bounds of |content|. | 1652 FloatRect(100, 100, 100, 100), // Old bounds of |content|. |
1650 FloatRect(100, 100, 100, 100))); // New bounds of |content|. | 1653 FloatRect(100, 100, 100, 100))); // New bounds of |content|. |
1651 | 1654 |
1652 getPaintController().updateCurrentPaintChunkProperties( | 1655 getPaintController().updateCurrentPaintChunkProperties( |
(...skipping 10 matching lines...) Expand all Loading... |
1663 drawRect(context, content, foregroundDrawingType, rect2); | 1666 drawRect(context, content, foregroundDrawingType, rect2); |
1664 drawRect(context, content, foregroundDrawingType, rect3); | 1667 drawRect(context, content, foregroundDrawingType, rect3); |
1665 getPaintController().endSkippingCache(); | 1668 getPaintController().endSkippingCache(); |
1666 | 1669 |
1667 // We should repaint everything on invalidation of the scope container. | 1670 // We should repaint everything on invalidation of the scope container. |
1668 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4, | 1671 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4, |
1669 TestDisplayItem(multicol, backgroundDrawingType), | 1672 TestDisplayItem(multicol, backgroundDrawingType), |
1670 TestDisplayItem(content, foregroundDrawingType), | 1673 TestDisplayItem(content, foregroundDrawingType), |
1671 TestDisplayItem(content, foregroundDrawingType), | 1674 TestDisplayItem(content, foregroundDrawingType), |
1672 TestDisplayItem(content, foregroundDrawingType)); | 1675 TestDisplayItem(content, foregroundDrawingType)); |
1673 EXPECT_NE(record1.get(), static_cast<const DrawingDisplayItem&>( | 1676 EXPECT_NE(record1.get(), |
1674 getPaintController().newDisplayItemList()[1]) | 1677 static_cast<const DrawingDisplayItem&>( |
1675 .GetPaintRecord()); | 1678 getPaintController().newDisplayItemList()[1]) |
1676 EXPECT_NE(record2.get(), static_cast<const DrawingDisplayItem&>( | 1679 .GetPaintRecord()); |
1677 getPaintController().newDisplayItemList()[2]) | 1680 EXPECT_NE(record2.get(), |
1678 .GetPaintRecord()); | 1681 static_cast<const DrawingDisplayItem&>( |
| 1682 getPaintController().newDisplayItemList()[2]) |
| 1683 .GetPaintRecord()); |
1679 | 1684 |
1680 getPaintController().commitNewDisplayItems(); | 1685 getPaintController().commitNewDisplayItems(); |
1681 | 1686 |
1682 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1687 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
1683 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | 1688 EXPECT_EQ(1u, getPaintController().paintChunks().size()); |
1684 EXPECT_THAT( | 1689 EXPECT_THAT( |
1685 getPaintController().paintChunks()[0].rasterInvalidationRects, | 1690 getPaintController().paintChunks()[0].rasterInvalidationRects, |
1686 UnorderedElementsAre( | 1691 UnorderedElementsAre( |
1687 FloatRect(100, 100, 200, 200), // Old bounds of |multicol|. | 1692 FloatRect(100, 100, 200, 200), // Old bounds of |multicol|. |
1688 FloatRect(100, 100, 200, 200), // New bounds of |multicol|. | 1693 FloatRect(100, 100, 200, 200), // New bounds of |multicol|. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 EXPECT_EQ(0, numOutOfOrderMatches()); | 1755 EXPECT_EQ(0, numOutOfOrderMatches()); |
1751 EXPECT_EQ(0, numIndexedItems()); | 1756 EXPECT_EQ(0, numIndexedItems()); |
1752 #endif | 1757 #endif |
1753 | 1758 |
1754 getPaintController().commitNewDisplayItems(); | 1759 getPaintController().commitNewDisplayItems(); |
1755 | 1760 |
1756 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | 1761 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
1757 TestDisplayItem(content, backgroundDrawingType), | 1762 TestDisplayItem(content, backgroundDrawingType), |
1758 TestDisplayItem(content, foregroundDrawingType), | 1763 TestDisplayItem(content, foregroundDrawingType), |
1759 TestDisplayItem(content, foregroundDrawingType)); | 1764 TestDisplayItem(content, foregroundDrawingType)); |
1760 EXPECT_NE(record0.get(), static_cast<const DrawingDisplayItem&>( | 1765 EXPECT_NE(record0.get(), |
1761 getPaintController().getDisplayItemList()[0]) | 1766 static_cast<const DrawingDisplayItem&>( |
1762 .GetPaintRecord()); | 1767 getPaintController().getDisplayItemList()[0]) |
1763 EXPECT_NE(record1.get(), static_cast<const DrawingDisplayItem&>( | 1768 .GetPaintRecord()); |
1764 getPaintController().getDisplayItemList()[1]) | 1769 EXPECT_NE(record1.get(), |
1765 .GetPaintRecord()); | 1770 static_cast<const DrawingDisplayItem&>( |
1766 EXPECT_NE(record2.get(), static_cast<const DrawingDisplayItem&>( | 1771 getPaintController().getDisplayItemList()[1]) |
1767 getPaintController().getDisplayItemList()[2]) | 1772 .GetPaintRecord()); |
1768 .GetPaintRecord()); | 1773 EXPECT_NE(record2.get(), |
| 1774 static_cast<const DrawingDisplayItem&>( |
| 1775 getPaintController().getDisplayItemList()[2]) |
| 1776 .GetPaintRecord()); |
1769 } | 1777 } |
1770 | 1778 |
1771 TEST_F(PaintControllerTestBase, OptimizeNoopPairs) { | 1779 TEST_F(PaintControllerTestBase, OptimizeNoopPairs) { |
1772 FakeDisplayItemClient first("first"); | 1780 FakeDisplayItemClient first("first"); |
1773 FakeDisplayItemClient second("second"); | 1781 FakeDisplayItemClient second("second"); |
1774 FakeDisplayItemClient third("third"); | 1782 FakeDisplayItemClient third("third"); |
1775 | 1783 |
1776 GraphicsContext context(getPaintController()); | 1784 GraphicsContext context(getPaintController()); |
1777 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 1785 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
1778 { | 1786 { |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 } | 2312 } |
2305 | 2313 |
2306 TEST_F(PaintControllerUnderInvalidationTest, | 2314 TEST_F(PaintControllerUnderInvalidationTest, |
2307 FoldCompositingDrawingInSubsequence) { | 2315 FoldCompositingDrawingInSubsequence) { |
2308 testFoldCompositingDrawingInSubsequence(); | 2316 testFoldCompositingDrawingInSubsequence(); |
2309 } | 2317 } |
2310 | 2318 |
2311 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 2319 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
2312 | 2320 |
2313 } // namespace blink | 2321 } // namespace blink |
OLD | NEW |