| 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, | 269 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, |
| 270 TestDisplayItem(second, backgroundDrawingType), | 270 TestDisplayItem(second, backgroundDrawingType), |
| 271 TestDisplayItem(second, foregroundDrawingType), | 271 TestDisplayItem(second, foregroundDrawingType), |
| 272 TestDisplayItem(first, backgroundDrawingType), | 272 TestDisplayItem(first, backgroundDrawingType), |
| 273 TestDisplayItem(first, foregroundDrawingType), | 273 TestDisplayItem(first, foregroundDrawingType), |
| 274 TestDisplayItem(unaffected, backgroundDrawingType), | 274 TestDisplayItem(unaffected, backgroundDrawingType), |
| 275 TestDisplayItem(unaffected, foregroundDrawingType)); | 275 TestDisplayItem(unaffected, foregroundDrawingType)); |
| 276 | 276 |
| 277 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 277 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 278 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | 278 EXPECT_EQ(1u, getPaintController().paintChunks().size()); |
| 279 // TODO(wangxianzhu): In real world we invalidate clients with reordered
display items. | 279 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre( |
| 280 // Need to support raster invalidation for recordered display items with
out invalidating clients. | 280 FloatRect(100, 100, 50, 200))); // Bounds of |second|. |
| 281 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre()); | |
| 282 } | 281 } |
| 283 } | 282 } |
| 284 | 283 |
| 285 TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) | 284 TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) |
| 286 { | 285 { |
| 287 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); | 286 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); |
| 288 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); | 287 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); |
| 289 FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10))
; | 288 FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10))
; |
| 290 GraphicsContext context(getPaintController()); | 289 GraphicsContext context(getPaintController()); |
| 291 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 290 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 TestDisplayItem(first, backgroundDrawingType), | 332 TestDisplayItem(first, backgroundDrawingType), |
| 334 TestDisplayItem(first, foregroundDrawingType), | 333 TestDisplayItem(first, foregroundDrawingType), |
| 335 TestDisplayItem(unaffected, backgroundDrawingType), | 334 TestDisplayItem(unaffected, backgroundDrawingType), |
| 336 TestDisplayItem(unaffected, foregroundDrawingType)); | 335 TestDisplayItem(unaffected, foregroundDrawingType)); |
| 337 | 336 |
| 338 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 337 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 339 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | 338 EXPECT_EQ(1u, getPaintController().paintChunks().size()); |
| 340 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre( | 339 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre( |
| 341 FloatRect(100, 100, 100, 100), // Old bounds of |first|. | 340 FloatRect(100, 100, 100, 100), // Old bounds of |first|. |
| 342 FloatRect(100, 100, 100, 100))); // New bounds of |first|. | 341 FloatRect(100, 100, 100, 100))); // New bounds of |first|. |
| 342 // No need to invalidate raster of |second| because the client (|first|)
which swapped order |
| 343 // with it has been invalidated. |
| 343 } | 344 } |
| 344 } | 345 } |
| 345 | 346 |
| 346 TEST_P(PaintControllerTest, UpdateNewItemInMiddle) | 347 TEST_P(PaintControllerTest, UpdateNewItemInMiddle) |
| 347 { | 348 { |
| 348 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); | 349 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); |
| 349 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); | 350 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); |
| 350 FakeDisplayItemClient third("third", LayoutRect(125, 100, 200, 50)); | 351 FakeDisplayItemClient third("third", LayoutRect(125, 100, 200, 50)); |
| 351 GraphicsContext context(getPaintController()); | 352 GraphicsContext context(getPaintController()); |
| 352 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 353 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 if (!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()
) | 701 if (!RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()
) |
| 701 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaint
Controller().getDisplayItemList()[1]).picture()); | 702 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaint
Controller().getDisplayItemList()[1]).picture()); |
| 702 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); | 703 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); |
| 703 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); | 704 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); |
| 704 | 705 |
| 705 getPaintController().invalidateAll(); | 706 getPaintController().invalidateAll(); |
| 706 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); | 707 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); |
| 707 EXPECT_FALSE(getPaintController().clientCacheIsValid(second)); | 708 EXPECT_FALSE(getPaintController().clientCacheIsValid(second)); |
| 708 } | 709 } |
| 709 | 710 |
| 710 TEST_P(PaintControllerTest, ComplexUpdateSwapOrder) | 711 TEST_P(PaintControllerTest, UpdateSwapOrderWithChildren) |
| 711 { | 712 { |
| 712 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100
)); | 713 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100
)); |
| 713 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); | 714 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); |
| 715 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100
)); |
| 716 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 717 GraphicsContext context(getPaintController()); |
| 718 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 719 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk
Id, PaintChunkProperties()); |
| 720 |
| 721 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 722 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 723 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 724 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 725 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 726 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 727 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 728 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 729 getPaintController().commitNewDisplayItems(); |
| 730 |
| 731 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, |
| 732 TestDisplayItem(container1, backgroundDrawingType), |
| 733 TestDisplayItem(content1, backgroundDrawingType), |
| 734 TestDisplayItem(content1, foregroundDrawingType), |
| 735 TestDisplayItem(container1, foregroundDrawingType), |
| 736 TestDisplayItem(container2, backgroundDrawingType), |
| 737 TestDisplayItem(content2, backgroundDrawingType), |
| 738 TestDisplayItem(content2, foregroundDrawingType), |
| 739 TestDisplayItem(container2, foregroundDrawingType)); |
| 740 |
| 741 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 742 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk
Id, PaintChunkProperties()); |
| 743 |
| 744 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2, |
| 745 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 746 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 747 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 748 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 749 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 750 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 751 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 752 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 753 getPaintController().commitNewDisplayItems(); |
| 754 |
| 755 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, |
| 756 TestDisplayItem(container2, backgroundDrawingType), |
| 757 TestDisplayItem(content2, backgroundDrawingType), |
| 758 TestDisplayItem(content2, foregroundDrawingType), |
| 759 TestDisplayItem(container2, foregroundDrawingType), |
| 760 TestDisplayItem(container1, backgroundDrawingType), |
| 761 TestDisplayItem(content1, backgroundDrawingType), |
| 762 TestDisplayItem(content1, foregroundDrawingType), |
| 763 TestDisplayItem(container1, foregroundDrawingType)); |
| 764 |
| 765 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 766 EXPECT_EQ(1u, getPaintController().paintChunks().size()); |
| 767 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre( |
| 768 FloatRect(100, 200, 100, 100), // Bounds of |container2| which was m
oved behind |container1|. |
| 769 FloatRect(100, 200, 50, 200))); // Bounds of |content2| which was mo
ved along with |container2|. |
| 770 } |
| 771 } |
| 772 |
| 773 TEST_P(PaintControllerTest, UpdateSwapOrderWithChildrenAndInvalidation) |
| 774 { |
| 775 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100
)); |
| 776 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); |
| 714 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100
)); | 777 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100
)); |
| 715 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); | 778 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 716 GraphicsContext context(getPaintController()); | 779 GraphicsContext context(getPaintController()); |
| 717 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 780 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 718 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk
Id, PaintChunkProperties()); | 781 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk
Id, PaintChunkProperties()); |
| 719 | 782 |
| 720 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); | 783 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 721 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); | 784 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 722 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2
00)); | 785 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 723 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100
, 100)); | 786 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 734 TestDisplayItem(container1, foregroundDrawingType), | 797 TestDisplayItem(container1, foregroundDrawingType), |
| 735 TestDisplayItem(container2, backgroundDrawingType), | 798 TestDisplayItem(container2, backgroundDrawingType), |
| 736 TestDisplayItem(content2, backgroundDrawingType), | 799 TestDisplayItem(content2, backgroundDrawingType), |
| 737 TestDisplayItem(content2, foregroundDrawingType), | 800 TestDisplayItem(content2, foregroundDrawingType), |
| 738 TestDisplayItem(container2, foregroundDrawingType)); | 801 TestDisplayItem(container2, foregroundDrawingType)); |
| 739 | 802 |
| 740 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 803 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 741 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk
Id, PaintChunkProperties()); | 804 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk
Id, PaintChunkProperties()); |
| 742 | 805 |
| 743 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. | 806 // Simulate the situation when container1 e.g. gets a z-index that is now gr
eater than container2. |
| 807 // and container1 is invalidated. |
| 744 container1.setDisplayItemsUncached(); | 808 container1.setDisplayItemsUncached(); |
| 745 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100
, 100)); | 809 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 746 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2
00)); | 810 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 747 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2
00)); | 811 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 748 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100
, 100)); | 812 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 749 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); | 813 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 750 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); | 814 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 751 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2
00)); | 815 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 752 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100
, 100)); | 816 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 753 getPaintController().commitNewDisplayItems(); | 817 getPaintController().commitNewDisplayItems(); |
| 754 | 818 |
| 755 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, | 819 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, |
| 756 TestDisplayItem(container2, backgroundDrawingType), | 820 TestDisplayItem(container2, backgroundDrawingType), |
| 757 TestDisplayItem(content2, backgroundDrawingType), | 821 TestDisplayItem(content2, backgroundDrawingType), |
| 758 TestDisplayItem(content2, foregroundDrawingType), | 822 TestDisplayItem(content2, foregroundDrawingType), |
| 759 TestDisplayItem(container2, foregroundDrawingType), | 823 TestDisplayItem(container2, foregroundDrawingType), |
| 760 TestDisplayItem(container1, backgroundDrawingType), | 824 TestDisplayItem(container1, backgroundDrawingType), |
| 761 TestDisplayItem(content1, backgroundDrawingType), | 825 TestDisplayItem(content1, backgroundDrawingType), |
| 762 TestDisplayItem(content1, foregroundDrawingType), | 826 TestDisplayItem(content1, foregroundDrawingType), |
| 763 TestDisplayItem(container1, foregroundDrawingType)); | 827 TestDisplayItem(container1, foregroundDrawingType)); |
| 764 | 828 |
| 765 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 829 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 766 EXPECT_EQ(1u, getPaintController().paintChunks().size()); | 830 EXPECT_EQ(1u, getPaintController().paintChunks().size()); |
| 767 // TODO(wangxianzhu): In real world we invalidate clients with reordered
display items. | |
| 768 // Need to support raster invalidation for recordered display items with
out invalidating clients. | |
| 769 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre( | 831 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre( |
| 770 FloatRect(100, 100, 100, 100), // Old bounds of |container1|. | 832 FloatRect(100, 100, 100, 100), // Old bounds of |container1|. |
| 771 FloatRect(100, 100, 100, 100))); // New bounds of |container1|. | 833 FloatRect(100, 100, 100, 100), // New bounds of |container1|. |
| 834 FloatRect(100, 200, 100, 100), // Bounds of |container2| which was m
oved behind |container1|. |
| 835 FloatRect(100, 200, 50, 200))); // Bounds of |content2| which was mo
ved along with |container2|. |
| 772 } | 836 } |
| 773 } | 837 } |
| 774 | 838 |
| 775 TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) | 839 TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) |
| 776 { | 840 { |
| 777 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100
)); | 841 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100
)); |
| 778 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); | 842 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); |
| 779 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100
)); | 843 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100
)); |
| 780 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); | 844 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 781 GraphicsContext context(getPaintController()); | 845 GraphicsContext context(getPaintController()); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 962 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 899 EXPECT_EQ(2u, getPaintController().paintChunks().size()); | 963 EXPECT_EQ(2u, getPaintController().paintChunks().size()); |
| 900 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon
troller().paintChunks()[0].id); | 964 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon
troller().paintChunks()[0].id); |
| 901 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon
troller().paintChunks()[1].id); | 965 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon
troller().paintChunks()[1].id); |
| 902 // Swapping order of chunks should not invalidate anything. | 966 // Swapping order of chunks should not invalidate anything. |
| 903 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre()); | 967 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre()); |
| 904 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect
s, UnorderedElementsAre()); | 968 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect
s, UnorderedElementsAre()); |
| 905 } | 969 } |
| 906 } | 970 } |
| 907 | 971 |
| 972 TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks) |
| 973 { |
| 974 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100
)); |
| 975 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); |
| 976 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100
)); |
| 977 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); |
| 978 GraphicsContext context(getPaintController()); |
| 979 |
| 980 PaintChunkProperties container1Properties; |
| 981 PaintChunkProperties container2Properties; |
| 982 |
| 983 { |
| 984 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 985 PaintChunk::Id id(container1, backgroundDrawingType); |
| 986 container1Properties.effect = EffectPaintPropertyNode::create(nullpt
r, 0.5); |
| 987 getPaintController().updateCurrentPaintChunkProperties(&id, containe
r1Properties); |
| 988 } |
| 989 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100,
100, 100)); |
| 990 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 5
0, 200)); |
| 991 } |
| 992 { |
| 993 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 994 PaintChunk::Id id(container2, backgroundDrawingType); |
| 995 container2Properties.effect = EffectPaintPropertyNode::create(nullpt
r, 0.5); |
| 996 getPaintController().updateCurrentPaintChunkProperties(&id, containe
r2Properties); |
| 997 } |
| 998 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200,
100, 100)); |
| 999 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 5
0, 200)); |
| 1000 } |
| 1001 getPaintController().commitNewDisplayItems(); |
| 1002 |
| 1003 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
| 1004 TestDisplayItem(container1, backgroundDrawingType), |
| 1005 TestDisplayItem(content1, backgroundDrawingType), |
| 1006 TestDisplayItem(container2, backgroundDrawingType), |
| 1007 TestDisplayItem(content2, backgroundDrawingType)); |
| 1008 |
| 1009 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1010 EXPECT_EQ(2u, getPaintController().paintChunks().size()); |
| 1011 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon
troller().paintChunks()[0].id); |
| 1012 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon
troller().paintChunks()[1].id); |
| 1013 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre( |
| 1014 FloatRect(LayoutRect::infiniteIntRect()))); |
| 1015 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect
s, UnorderedElementsAre( |
| 1016 FloatRect(LayoutRect::infiniteIntRect()))); |
| 1017 } |
| 1018 |
| 1019 // Move content2 into container1, without invalidation. |
| 1020 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1021 PaintChunk::Id id(container1, backgroundDrawingType); |
| 1022 getPaintController().updateCurrentPaintChunkProperties(&id, container1Pr
operties); |
| 1023 } |
| 1024 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100
, 100)); |
| 1025 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2
00)); |
| 1026 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2
00)); |
| 1027 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1028 PaintChunk::Id id(container2, backgroundDrawingType); |
| 1029 getPaintController().updateCurrentPaintChunkProperties(&id, container2Pr
operties); |
| 1030 } |
| 1031 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100
, 100)); |
| 1032 |
| 1033 EXPECT_EQ(4, numCachedNewItems()); |
| 1034 #if DCHECK_IS_ON() |
| 1035 EXPECT_EQ(3, numSequentialMatches()); |
| 1036 EXPECT_EQ(1, numOutOfOrderMatches()); |
| 1037 EXPECT_EQ(1, numIndexedItems()); |
| 1038 #endif |
| 1039 |
| 1040 getPaintController().commitNewDisplayItems(); |
| 1041 |
| 1042 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4, |
| 1043 TestDisplayItem(container1, backgroundDrawingType), |
| 1044 TestDisplayItem(content1, backgroundDrawingType), |
| 1045 TestDisplayItem(content2, backgroundDrawingType), |
| 1046 TestDisplayItem(container2, backgroundDrawingType)); |
| 1047 |
| 1048 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1049 EXPECT_EQ(2u, getPaintController().paintChunks().size()); |
| 1050 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon
troller().paintChunks()[0].id); |
| 1051 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon
troller().paintChunks()[1].id); |
| 1052 // |content2| is invalidated raster on both the old chunk and the new ch
unk. |
| 1053 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect
s, UnorderedElementsAre( |
| 1054 FloatRect(100, 200, 50, 200))); |
| 1055 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect
s, UnorderedElementsAre( |
| 1056 FloatRect(100, 200, 50, 200))); |
| 1057 } |
| 1058 } |
| 1059 |
| 908 TEST_P(PaintControllerTest, OutOfOrderNoCrash) | 1060 TEST_P(PaintControllerTest, OutOfOrderNoCrash) |
| 909 { | 1061 { |
| 910 FakeDisplayItemClient client("client"); | 1062 FakeDisplayItemClient client("client"); |
| 911 GraphicsContext context(getPaintController()); | 1063 GraphicsContext context(getPaintController()); |
| 912 | 1064 |
| 913 const DisplayItem::Type type1 = DisplayItem::kDrawingFirst; | 1065 const DisplayItem::Type type1 = DisplayItem::kDrawingFirst; |
| 914 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem::
kDrawingFirst + 1); | 1066 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem::
kDrawingFirst + 1); |
| 915 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem::
kDrawingFirst + 2); | 1067 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem::
kDrawingFirst + 2); |
| 916 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem::
kDrawingFirst + 3); | 1068 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem::
kDrawingFirst + 3); |
| 917 | 1069 |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 } | 1909 } |
| 1758 | 1910 |
| 1759 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence
) | 1911 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence
) |
| 1760 { | 1912 { |
| 1761 testFoldCompositingDrawingInSubsequence(); | 1913 testFoldCompositingDrawingInSubsequence(); |
| 1762 } | 1914 } |
| 1763 | 1915 |
| 1764 #endif // DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) | 1916 #endif // DCHECK_IS_ON() && defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) |
| 1765 | 1917 |
| 1766 } // namespace blink | 1918 } // namespace blink |
| OLD | NEW |