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

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

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: Clean up comments, fix mac build Created 3 years, 11 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
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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SkPicture* firstPicture = 801 const PaintRecord* firstPicture =
802 static_cast<const DrawingDisplayItem&>( 802 static_cast<const DrawingDisplayItem&>(
803 getPaintController().getDisplayItemList()[0]) 803 getPaintController().getDisplayItemList()[0])
804 .picture(); 804 .picture();
805 const SkPicture* secondPicture = 805 const PaintRecord* secondPicture =
806 static_cast<const DrawingDisplayItem&>( 806 static_cast<const DrawingDisplayItem&>(
807 getPaintController().getDisplayItemList()[1]) 807 getPaintController().getDisplayItemList()[1])
808 .picture(); 808 .picture();
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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 drawRect(context, content, foregroundDrawingType, rect1); 1583 drawRect(context, content, foregroundDrawingType, rect1);
1584 drawRect(context, content, foregroundDrawingType, rect2); 1584 drawRect(context, content, foregroundDrawingType, rect2);
1585 getPaintController().endSkippingCache(); 1585 getPaintController().endSkippingCache();
1586 1586
1587 getPaintController().commitNewDisplayItems(); 1587 getPaintController().commitNewDisplayItems();
1588 1588
1589 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1589 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1590 TestDisplayItem(multicol, backgroundDrawingType), 1590 TestDisplayItem(multicol, backgroundDrawingType),
1591 TestDisplayItem(content, foregroundDrawingType), 1591 TestDisplayItem(content, foregroundDrawingType),
1592 TestDisplayItem(content, foregroundDrawingType)); 1592 TestDisplayItem(content, foregroundDrawingType));
1593 sk_sp<const SkPicture> picture1 = 1593 sk_sp<const PaintRecord> picture1 =
1594 sk_ref_sp(static_cast<const DrawingDisplayItem&>( 1594 sk_ref_sp(static_cast<const DrawingDisplayItem&>(
1595 getPaintController().getDisplayItemList()[1]) 1595 getPaintController().getDisplayItemList()[1])
1596 .picture()); 1596 .picture());
1597 sk_sp<const SkPicture> picture2 = 1597 sk_sp<const PaintRecord> picture2 =
1598 sk_ref_sp(static_cast<const DrawingDisplayItem&>( 1598 sk_ref_sp(static_cast<const DrawingDisplayItem&>(
1599 getPaintController().getDisplayItemList()[2]) 1599 getPaintController().getDisplayItemList()[2])
1600 .picture()); 1600 .picture());
1601 EXPECT_NE(picture1, picture2); 1601 EXPECT_NE(picture1, picture2);
1602 1602
1603 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1603 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1604 EXPECT_EQ(1u, getPaintController().paintChunks().size()); 1604 EXPECT_EQ(1u, getPaintController().paintChunks().size());
1605 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects, 1605 EXPECT_THAT(getPaintController().paintChunks()[0].rasterInvalidationRects,
1606 UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect()))); 1606 UnorderedElementsAre(FloatRect(LayoutRect::infiniteIntRect())));
1607 1607
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 drawRect(context, content, foregroundDrawingType, rect2); 1706 drawRect(context, content, foregroundDrawingType, rect2);
1707 getPaintController().endSkippingCache(); 1707 getPaintController().endSkippingCache();
1708 drawRect(context, content, foregroundDrawingType, rect3); 1708 drawRect(context, content, foregroundDrawingType, rect3);
1709 1709
1710 getPaintController().commitNewDisplayItems(); 1710 getPaintController().commitNewDisplayItems();
1711 1711
1712 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 1712 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
1713 TestDisplayItem(content, backgroundDrawingType), 1713 TestDisplayItem(content, backgroundDrawingType),
1714 TestDisplayItem(content, foregroundDrawingType), 1714 TestDisplayItem(content, foregroundDrawingType),
1715 TestDisplayItem(content, foregroundDrawingType)); 1715 TestDisplayItem(content, foregroundDrawingType));
1716 sk_sp<const SkPicture> picture0 = 1716 sk_sp<const PaintRecord> picture0 =
1717 sk_ref_sp(static_cast<const DrawingDisplayItem&>( 1717 sk_ref_sp(static_cast<const DrawingDisplayItem&>(
1718 getPaintController().getDisplayItemList()[0]) 1718 getPaintController().getDisplayItemList()[0])
1719 .picture()); 1719 .picture());
1720 sk_sp<const SkPicture> picture1 = 1720 sk_sp<const PaintRecord> picture1 =
1721 sk_ref_sp(static_cast<const DrawingDisplayItem&>( 1721 sk_ref_sp(static_cast<const DrawingDisplayItem&>(
1722 getPaintController().getDisplayItemList()[1]) 1722 getPaintController().getDisplayItemList()[1])
1723 .picture()); 1723 .picture());
1724 sk_sp<const SkPicture> picture2 = 1724 sk_sp<const PaintRecord> picture2 =
1725 sk_ref_sp(static_cast<const DrawingDisplayItem&>( 1725 sk_ref_sp(static_cast<const DrawingDisplayItem&>(
1726 getPaintController().getDisplayItemList()[2]) 1726 getPaintController().getDisplayItemList()[2])
1727 .picture()); 1727 .picture());
1728 EXPECT_NE(picture1, picture2); 1728 EXPECT_NE(picture1, picture2);
1729 1729
1730 // Content's cache is invalid because it has display items skipped cache. 1730 // Content's cache is invalid because it has display items skipped cache.
1731 EXPECT_FALSE(getPaintController().clientCacheIsValid(content)); 1731 EXPECT_FALSE(getPaintController().clientCacheIsValid(content));
1732 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason()); 1732 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason());
1733 1733
1734 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1734 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 1857
1858 DrawingRecorder drawingRecorder(context, client, type, 1858 DrawingRecorder drawingRecorder(context, client, type,
1859 FloatRect(0, 0, 100, 100)); 1859 FloatRect(0, 0, 100, 100));
1860 SkPath path; 1860 SkPath path;
1861 path.moveTo(0, 0); 1861 path.moveTo(0, 0);
1862 path.lineTo(0, 100); 1862 path.lineTo(0, 100);
1863 path.lineTo(50, 50); 1863 path.lineTo(50, 50);
1864 path.lineTo(100, 100); 1864 path.lineTo(100, 100);
1865 path.lineTo(100, 0); 1865 path.lineTo(100, 0);
1866 path.close(); 1866 path.close();
1867 SkPaint paint; 1867 PaintFlags paint;
1868 paint.setAntiAlias(true); 1868 paint.setAntiAlias(true);
1869 for (unsigned i = 0; i < count; i++) 1869 for (unsigned i = 0; i < count; i++)
1870 context.drawPath(path, paint); 1870 context.drawPath(path, paint);
1871 } 1871 }
1872 1872
1873 TEST_F(PaintControllerTestBase, IsSuitableForGpuRasterizationSinglePath) { 1873 TEST_F(PaintControllerTestBase, IsSuitableForGpuRasterizationSinglePath) {
1874 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 1874 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
1875 GraphicsContext context(getPaintController()); 1875 GraphicsContext context(getPaintController());
1876 drawPath(context, client, backgroundDrawingType, 1); 1876 drawPath(context, client, backgroundDrawingType, 1);
1877 getPaintController().commitNewDisplayItems(LayoutSize()); 1877 getPaintController().commitNewDisplayItems(LayoutSize());
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 } 2302 }
2303 2303
2304 TEST_F(PaintControllerUnderInvalidationTest, 2304 TEST_F(PaintControllerUnderInvalidationTest,
2305 FoldCompositingDrawingInSubsequence) { 2305 FoldCompositingDrawingInSubsequence) {
2306 testFoldCompositingDrawingInSubsequence(); 2306 testFoldCompositingDrawingInSubsequence();
2307 } 2307 }
2308 2308
2309 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID) 2309 #endif // defined(GTEST_HAS_DEATH_TEST) && !OS(ANDROID)
2310 2310
2311 } // namespace blink 2311 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698