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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp

Issue 2307623002: [SPv2] Defer decision of raster invalidation after paint for changes z-index, transform, etc. (Closed)
Patch Set: Remove duplicated spv2 expectation entries Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6, 261 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 6,
262 TestDisplayItem(second, backgroundDrawingType), 262 TestDisplayItem(second, backgroundDrawingType),
263 TestDisplayItem(second, foregroundDrawingType), 263 TestDisplayItem(second, foregroundDrawingType),
264 TestDisplayItem(first, backgroundDrawingType), 264 TestDisplayItem(first, backgroundDrawingType),
265 TestDisplayItem(first, foregroundDrawingType), 265 TestDisplayItem(first, foregroundDrawingType),
266 TestDisplayItem(unaffected, backgroundDrawingType), 266 TestDisplayItem(unaffected, backgroundDrawingType),
267 TestDisplayItem(unaffected, foregroundDrawingType)); 267 TestDisplayItem(unaffected, foregroundDrawingType));
268 268
269 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 269 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
270 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 270 EXPECT_EQ(1u, getPaintController().paintChunks().size());
271 // TODO(wangxianzhu): In real world we invalidate clients with reordered display items. 271 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
272 // Need to support raster invalidation for recordered display items with out invalidating clients. 272 FloatRect(100, 100, 50, 200))); // Bounds of |second|.
273 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre());
274 } 273 }
275 } 274 }
276 275
277 TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation) 276 TEST_P(PaintControllerTest, UpdateSwapOrderWithInvalidation)
278 { 277 {
279 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); 278 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100));
280 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); 279 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200));
281 FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)) ; 280 FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)) ;
282 GraphicsContext context(getPaintController()); 281 GraphicsContext context(getPaintController());
283 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 282 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 TestDisplayItem(first, backgroundDrawingType), 324 TestDisplayItem(first, backgroundDrawingType),
326 TestDisplayItem(first, foregroundDrawingType), 325 TestDisplayItem(first, foregroundDrawingType),
327 TestDisplayItem(unaffected, backgroundDrawingType), 326 TestDisplayItem(unaffected, backgroundDrawingType),
328 TestDisplayItem(unaffected, foregroundDrawingType)); 327 TestDisplayItem(unaffected, foregroundDrawingType));
329 328
330 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 329 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
331 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 330 EXPECT_EQ(1u, getPaintController().paintChunks().size());
332 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( 331 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
333 FloatRect(100, 100, 100, 100), // Old bounds of |first|. 332 FloatRect(100, 100, 100, 100), // Old bounds of |first|.
334 FloatRect(100, 100, 100, 100))); // New bounds of |first|. 333 FloatRect(100, 100, 100, 100))); // New bounds of |first|.
334 // No need to invalidate raster of |second| because the client (|first|) which swapped order
335 // with it has been invalidated.
335 } 336 }
336 } 337 }
337 338
338 TEST_P(PaintControllerTest, UpdateNewItemInMiddle) 339 TEST_P(PaintControllerTest, UpdateNewItemInMiddle)
339 { 340 {
340 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); 341 FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100));
341 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); 342 FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200));
342 FakeDisplayItemClient third("third", LayoutRect(125, 100, 200, 50)); 343 FakeDisplayItemClient third("third", LayoutRect(125, 100, 200, 50));
343 GraphicsContext context(getPaintController()); 344 GraphicsContext context(getPaintController());
344 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 345 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 if (!RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) 693 if (!RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled())
693 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaint Controller().getDisplayItemList()[1]).picture()); 694 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(getPaint Controller().getDisplayItemList()[1]).picture());
694 EXPECT_TRUE(getPaintController().clientCacheIsValid(first)); 695 EXPECT_TRUE(getPaintController().clientCacheIsValid(first));
695 EXPECT_TRUE(getPaintController().clientCacheIsValid(second)); 696 EXPECT_TRUE(getPaintController().clientCacheIsValid(second));
696 697
697 getPaintController().invalidateAll(); 698 getPaintController().invalidateAll();
698 EXPECT_FALSE(getPaintController().clientCacheIsValid(first)); 699 EXPECT_FALSE(getPaintController().clientCacheIsValid(first));
699 EXPECT_FALSE(getPaintController().clientCacheIsValid(second)); 700 EXPECT_FALSE(getPaintController().clientCacheIsValid(second));
700 } 701 }
701 702
702 TEST_P(PaintControllerTest, ComplexUpdateSwapOrder) 703 TEST_P(PaintControllerTest, UpdateSwapOrderWithChildren)
703 { 704 {
704 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100 )); 705 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100 ));
705 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); 706 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200));
707 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100 ));
708 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
709 GraphicsContext context(getPaintController());
710 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
711 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
712
713 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100));
714 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00));
715 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00));
716 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100));
717 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100));
718 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00));
719 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00));
720 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100));
721 getPaintController().commitNewDisplayItems();
722
723 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8,
724 TestDisplayItem(container1, backgroundDrawingType),
725 TestDisplayItem(content1, backgroundDrawingType),
726 TestDisplayItem(content1, foregroundDrawingType),
727 TestDisplayItem(container1, foregroundDrawingType),
728 TestDisplayItem(container2, backgroundDrawingType),
729 TestDisplayItem(content2, backgroundDrawingType),
730 TestDisplayItem(content2, foregroundDrawingType),
731 TestDisplayItem(container2, foregroundDrawingType));
732
733 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
734 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
735
736 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2,
737 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100));
738 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00));
739 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00));
740 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100));
741 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100));
742 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00));
743 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00));
744 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100));
745 getPaintController().commitNewDisplayItems();
746
747 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8,
748 TestDisplayItem(container2, backgroundDrawingType),
749 TestDisplayItem(content2, backgroundDrawingType),
750 TestDisplayItem(content2, foregroundDrawingType),
751 TestDisplayItem(container2, foregroundDrawingType),
752 TestDisplayItem(container1, backgroundDrawingType),
753 TestDisplayItem(content1, backgroundDrawingType),
754 TestDisplayItem(content1, foregroundDrawingType),
755 TestDisplayItem(container1, foregroundDrawingType));
756
757 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
758 EXPECT_EQ(1u, getPaintController().paintChunks().size());
759 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
760 FloatRect(100, 200, 100, 100), // Bounds of |container2| which was m oved behind |container1|.
761 FloatRect(100, 200, 50, 200))); // Bounds of |content2| which was mo ved along with |container2|.
762 }
763 }
764
765 TEST_P(PaintControllerTest, UpdateSwapOrderWithChildrenAndInvalidation)
766 {
767 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100 ));
768 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200));
706 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100 )); 769 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100 ));
707 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 770 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
708 GraphicsContext context(getPaintController()); 771 GraphicsContext context(getPaintController());
709 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 772 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
710 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 773 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
711 774
712 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100)); 775 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100));
713 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00)); 776 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00));
714 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00)); 777 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00));
715 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100)); 778 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100));
(...skipping 10 matching lines...) Expand all
726 TestDisplayItem(container1, foregroundDrawingType), 789 TestDisplayItem(container1, foregroundDrawingType),
727 TestDisplayItem(container2, backgroundDrawingType), 790 TestDisplayItem(container2, backgroundDrawingType),
728 TestDisplayItem(content2, backgroundDrawingType), 791 TestDisplayItem(content2, backgroundDrawingType),
729 TestDisplayItem(content2, foregroundDrawingType), 792 TestDisplayItem(content2, foregroundDrawingType),
730 TestDisplayItem(container2, foregroundDrawingType)); 793 TestDisplayItem(container2, foregroundDrawingType));
731 794
732 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 795 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
733 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties()); 796 getPaintController().updateCurrentPaintChunkProperties(&m_rootPaintChunk Id, PaintChunkProperties());
734 797
735 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2. 798 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2.
799 // and container1 is invalidated.
736 container1.setDisplayItemsUncached(); 800 container1.setDisplayItemsUncached();
737 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100)); 801 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100));
738 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00)); 802 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00));
739 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00)); 803 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00));
740 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100)); 804 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100));
741 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100)); 805 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100));
742 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00)); 806 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00));
743 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00)); 807 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00));
744 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100)); 808 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100));
745 getPaintController().commitNewDisplayItems(); 809 getPaintController().commitNewDisplayItems();
746 810
747 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8, 811 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 8,
748 TestDisplayItem(container2, backgroundDrawingType), 812 TestDisplayItem(container2, backgroundDrawingType),
749 TestDisplayItem(content2, backgroundDrawingType), 813 TestDisplayItem(content2, backgroundDrawingType),
750 TestDisplayItem(content2, foregroundDrawingType), 814 TestDisplayItem(content2, foregroundDrawingType),
751 TestDisplayItem(container2, foregroundDrawingType), 815 TestDisplayItem(container2, foregroundDrawingType),
752 TestDisplayItem(container1, backgroundDrawingType), 816 TestDisplayItem(container1, backgroundDrawingType),
753 TestDisplayItem(content1, backgroundDrawingType), 817 TestDisplayItem(content1, backgroundDrawingType),
754 TestDisplayItem(content1, foregroundDrawingType), 818 TestDisplayItem(content1, foregroundDrawingType),
755 TestDisplayItem(container1, foregroundDrawingType)); 819 TestDisplayItem(container1, foregroundDrawingType));
756 820
757 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 821 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
758 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 822 EXPECT_EQ(1u, getPaintController().paintChunks().size());
759 // TODO(wangxianzhu): In real world we invalidate clients with reordered display items.
760 // Need to support raster invalidation for recordered display items with out invalidating clients.
761 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre( 823 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
762 FloatRect(100, 100, 100, 100), // Old bounds of |container1|. 824 FloatRect(100, 100, 100, 100), // Old bounds of |container1|.
763 FloatRect(100, 100, 100, 100))); // New bounds of |container1|. 825 FloatRect(100, 100, 100, 100), // New bounds of |container1|.
826 FloatRect(100, 200, 100, 100), // Bounds of |container2| which was m oved behind |container1|.
827 FloatRect(100, 200, 50, 200))); // Bounds of |content2| which was mo ved along with |container2|.
764 } 828 }
765 } 829 }
766 830
767 TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) 831 TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder)
768 { 832 {
769 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100 )); 833 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100 ));
770 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); 834 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200));
771 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100 )); 835 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100 ));
772 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200)); 836 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
773 GraphicsContext context(getPaintController()); 837 GraphicsContext context(getPaintController());
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 954 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
891 EXPECT_EQ(2u, getPaintController().paintChunks().size()); 955 EXPECT_EQ(2u, getPaintController().paintChunks().size());
892 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon troller().paintChunks()[0].id); 956 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon troller().paintChunks()[0].id);
893 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon troller().paintChunks()[1].id); 957 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon troller().paintChunks()[1].id);
894 // Swapping order of chunks should not invalidate anything. 958 // Swapping order of chunks should not invalidate anything.
895 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre()); 959 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre());
896 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre()); 960 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre());
897 } 961 }
898 } 962 }
899 963
964 TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks)
965 {
966 FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100 ));
967 FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200));
968 FakeDisplayItemClient container2("container2", LayoutRect(100, 200, 100, 100 ));
969 FakeDisplayItemClient content2("content2", LayoutRect(100, 200, 50, 200));
970 GraphicsContext context(getPaintController());
971
972 PaintChunkProperties container1Properties;
973 PaintChunkProperties container2Properties;
974
975 {
976 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
977 PaintChunk::Id id(container1, backgroundDrawingType);
978 container1Properties.effect = EffectPaintPropertyNode::create(nullpt r, 0.5);
979 getPaintController().updateCurrentPaintChunkProperties(&id, containe r1Properties);
980 }
981 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100));
982 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 5 0, 200));
983 }
984 {
985 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
986 PaintChunk::Id id(container2, backgroundDrawingType);
987 container2Properties.effect = EffectPaintPropertyNode::create(nullpt r, 0.5);
988 getPaintController().updateCurrentPaintChunkProperties(&id, containe r2Properties);
989 }
990 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100));
991 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 5 0, 200));
992 }
993 getPaintController().commitNewDisplayItems();
994
995 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4,
996 TestDisplayItem(container1, backgroundDrawingType),
997 TestDisplayItem(content1, backgroundDrawingType),
998 TestDisplayItem(container2, backgroundDrawingType),
999 TestDisplayItem(content2, backgroundDrawingType));
1000
1001 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1002 EXPECT_EQ(2u, getPaintController().paintChunks().size());
1003 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon troller().paintChunks()[0].id);
1004 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon troller().paintChunks()[1].id);
1005 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
1006 FloatRect(LayoutRect::infiniteIntRect())));
1007 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre(
1008 FloatRect(LayoutRect::infiniteIntRect())));
1009 }
1010
1011 // Move content2 into container1, without invalidation.
1012 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1013 PaintChunk::Id id(container1, backgroundDrawingType);
1014 getPaintController().updateCurrentPaintChunkProperties(&id, container1Pr operties);
1015 }
1016 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100));
1017 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00));
1018 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00));
1019 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1020 PaintChunk::Id id(container2, backgroundDrawingType);
1021 getPaintController().updateCurrentPaintChunkProperties(&id, container2Pr operties);
1022 }
1023 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100));
1024
1025 EXPECT_EQ(4, numCachedNewItems());
1026 #ifndef NDEBUG
1027 EXPECT_EQ(3, numSequentialMatches());
1028 EXPECT_EQ(1, numOutOfOrderMatches());
1029 EXPECT_EQ(1, numIndexedItems());
1030 #endif
1031
1032 getPaintController().commitNewDisplayItems();
1033
1034 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 4,
1035 TestDisplayItem(container1, backgroundDrawingType),
1036 TestDisplayItem(content1, backgroundDrawingType),
1037 TestDisplayItem(content2, backgroundDrawingType),
1038 TestDisplayItem(container2, backgroundDrawingType));
1039
1040 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1041 EXPECT_EQ(2u, getPaintController().paintChunks().size());
1042 EXPECT_EQ(PaintChunk::Id(container1, backgroundDrawingType), getPaintCon troller().paintChunks()[0].id);
1043 EXPECT_EQ(PaintChunk::Id(container2, backgroundDrawingType), getPaintCon troller().paintChunks()[1].id);
1044 // |content2| is invalidated raster on both the old chunk and the new ch unk.
1045 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRect s, UnorderedElementsAre(
1046 FloatRect(100, 200, 50, 200)));
1047 EXPECT_THAT(getPaintController().paintChunks()[1].rasterInvalidationRect s, UnorderedElementsAre(
1048 FloatRect(100, 200, 50, 200)));
1049 }
1050 }
1051
900 TEST_P(PaintControllerTest, OutOfOrderNoCrash) 1052 TEST_P(PaintControllerTest, OutOfOrderNoCrash)
901 { 1053 {
902 FakeDisplayItemClient client("client"); 1054 FakeDisplayItemClient client("client");
903 GraphicsContext context(getPaintController()); 1055 GraphicsContext context(getPaintController());
904 1056
905 const DisplayItem::Type type1 = DisplayItem::kDrawingFirst; 1057 const DisplayItem::Type type1 = DisplayItem::kDrawingFirst;
906 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem:: kDrawingFirst + 1); 1058 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem:: kDrawingFirst + 1);
907 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem:: kDrawingFirst + 2); 1059 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem:: kDrawingFirst + 2);
908 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem:: kDrawingFirst + 3); 1060 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem:: kDrawingFirst + 3);
909 1061
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 } 1900 }
1749 1901
1750 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence ) 1902 TEST_F(PaintControllerUnderInvalidationTest, FoldCompositingDrawingInSubsequence )
1751 { 1903 {
1752 testFoldCompositingDrawingInSubsequence(); 1904 testFoldCompositingDrawingInSubsequence();
1753 } 1905 }
1754 1906
1755 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 1907 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
1756 1908
1757 } // namespace blink 1909 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698