| 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/CachedDisplayItem.h" | 9 #include "platform/graphics/paint/CachedDisplayItem.h" |
| 10 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 10 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 TestDisplayItem(content2, foregroundDrawingType), | 495 TestDisplayItem(content2, foregroundDrawingType), |
| 496 TestDisplayItem(container2, foregroundDrawingType), | 496 TestDisplayItem(container2, foregroundDrawingType), |
| 497 TestDisplayItem(container2, DisplayItem::EndSubsequence), | 497 TestDisplayItem(container2, DisplayItem::EndSubsequence), |
| 498 | 498 |
| 499 TestDisplayItem(container1, DisplayItem::Subsequence), | 499 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 500 TestDisplayItem(container1, backgroundDrawingType), | 500 TestDisplayItem(container1, backgroundDrawingType), |
| 501 TestDisplayItem(content1, backgroundDrawingType), | 501 TestDisplayItem(content1, backgroundDrawingType), |
| 502 TestDisplayItem(content1, foregroundDrawingType), | 502 TestDisplayItem(content1, foregroundDrawingType), |
| 503 TestDisplayItem(container1, foregroundDrawingType), | 503 TestDisplayItem(container1, foregroundDrawingType), |
| 504 TestDisplayItem(container1, DisplayItem::EndSubsequence)); | 504 TestDisplayItem(container1, DisplayItem::EndSubsequence)); |
| 505 |
| 506 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 507 DisplayItemClient::endShouldKeepAliveAllClients(); |
| 508 #endif |
| 505 } | 509 } |
| 506 | 510 |
| 507 TEST_F(PaintControllerTest, OutOfOrderNoCrash) | 511 TEST_F(PaintControllerTest, OutOfOrderNoCrash) |
| 508 { | 512 { |
| 509 FakeDisplayItemClient client("client"); | 513 FakeDisplayItemClient client("client"); |
| 510 GraphicsContext context(getPaintController()); | 514 GraphicsContext context(getPaintController()); |
| 511 | 515 |
| 512 const DisplayItem::Type type1 = DisplayItem::DrawingFirst; | 516 const DisplayItem::Type type1 = DisplayItem::DrawingFirst; |
| 513 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem::
DrawingFirst + 1); | 517 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem::
DrawingFirst + 1); |
| 514 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem::
DrawingFirst + 2); | 518 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem::
DrawingFirst + 2); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 TestDisplayItem(content2, foregroundDrawingType), | 617 TestDisplayItem(content2, foregroundDrawingType), |
| 614 TestDisplayItem(content2, DisplayItem::EndSubsequence), | 618 TestDisplayItem(content2, DisplayItem::EndSubsequence), |
| 615 | 619 |
| 616 TestDisplayItem(container1, DisplayItem::Subsequence), | 620 TestDisplayItem(container1, DisplayItem::Subsequence), |
| 617 TestDisplayItem(content1, DisplayItem::Subsequence), | 621 TestDisplayItem(content1, DisplayItem::Subsequence), |
| 618 TestDisplayItem(content1, backgroundDrawingType), | 622 TestDisplayItem(content1, backgroundDrawingType), |
| 619 TestDisplayItem(content1, foregroundDrawingType), | 623 TestDisplayItem(content1, foregroundDrawingType), |
| 620 TestDisplayItem(content1, DisplayItem::EndSubsequence), | 624 TestDisplayItem(content1, DisplayItem::EndSubsequence), |
| 621 TestDisplayItem(container1, foregroundDrawingType), | 625 TestDisplayItem(container1, foregroundDrawingType), |
| 622 TestDisplayItem(container1, DisplayItem::EndSubsequence)); | 626 TestDisplayItem(container1, DisplayItem::EndSubsequence)); |
| 627 |
| 628 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 629 DisplayItemClient::endShouldKeepAliveAllClients(); |
| 630 #endif |
| 623 } | 631 } |
| 624 | 632 |
| 625 TEST_F(PaintControllerTest, SkipCache) | 633 TEST_F(PaintControllerTest, SkipCache) |
| 626 { | 634 { |
| 627 FakeDisplayItemClient multicol("multicol"); | 635 FakeDisplayItemClient multicol("multicol"); |
| 628 FakeDisplayItemClient content("content"); | 636 FakeDisplayItemClient content("content"); |
| 629 GraphicsContext context(getPaintController()); | 637 GraphicsContext context(getPaintController()); |
| 630 | 638 |
| 631 FloatRect rect1(100, 100, 50, 50); | 639 FloatRect rect1(100, 100, 50, 50); |
| 632 FloatRect rect2(150, 100, 50, 50); | 640 FloatRect rect2(150, 100, 50, 50); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 { | 894 { |
| 887 SubsequenceRecorder subsequenceRecorder(context, container); | 895 SubsequenceRecorder subsequenceRecorder(context, container); |
| 888 drawPath(context, client, backgroundDrawingType, 50); | 896 drawPath(context, client, backgroundDrawingType, 50); |
| 889 } | 897 } |
| 890 getPaintController().commitNewDisplayItems(LayoutSize()); | 898 getPaintController().commitNewDisplayItems(LayoutSize()); |
| 891 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat
ion()); | 899 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat
ion()); |
| 892 | 900 |
| 893 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con
tainer)); | 901 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con
tainer)); |
| 894 getPaintController().commitNewDisplayItems(LayoutSize()); | 902 getPaintController().commitNewDisplayItems(LayoutSize()); |
| 895 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat
ion()); | 903 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat
ion()); |
| 904 |
| 905 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 906 DisplayItemClient::endShouldKeepAliveAllClients(); |
| 907 #endif |
| 896 } | 908 } |
| 897 | 909 |
| 898 // Temporarily disabled (pref regressions due to GPU veto stickiness: http://crb
ug.com/603969). | 910 // Temporarily disabled (pref regressions due to GPU veto stickiness: http://crb
ug.com/603969). |
| 899 TEST_F(PaintControllerTest, DISABLED_IsNotSuitableForGpuRasterizationConcaveClip
Path) | 911 TEST_F(PaintControllerTest, DISABLED_IsNotSuitableForGpuRasterizationConcaveClip
Path) |
| 900 { | 912 { |
| 901 Path path; | 913 Path path; |
| 902 path.addLineTo(FloatPoint(50, 50)); | 914 path.addLineTo(FloatPoint(50, 50)); |
| 903 path.addLineTo(FloatPoint(100, 0)); | 915 path.addLineTo(FloatPoint(100, 0)); |
| 904 path.addLineTo(FloatPoint(50, 100)); | 916 path.addLineTo(FloatPoint(50, 100)); |
| 905 path.closeSubpath(); | 917 path.closeSubpath(); |
| 906 | 918 |
| 907 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); | 919 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); |
| 908 GraphicsContext context(getPaintController()); | 920 GraphicsContext context(getPaintController()); |
| 909 | 921 |
| 910 // Run twice for empty/non-empty m_currentPaintArtifact coverage. | 922 // Run twice for empty/non-empty m_currentPaintArtifact coverage. |
| 911 for (int i = 0; i < 2; ++i) { | 923 for (int i = 0; i < 2; ++i) { |
| 912 for (int j = 0; j < 50; ++j) | 924 for (int j = 0; j < 50; ++j) |
| 913 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien
t, path); | 925 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien
t, path); |
| 914 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10
0)); | 926 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10
0)); |
| 915 for (int j = 0; j < 50; ++j) | 927 for (int j = 0; j < 50; ++j) |
| 916 getPaintController().createAndAppend<EndClipPathDisplayItem>(client)
; | 928 getPaintController().createAndAppend<EndClipPathDisplayItem>(client)
; |
| 917 getPaintController().commitNewDisplayItems(LayoutSize()); | 929 getPaintController().commitNewDisplayItems(LayoutSize()); |
| 918 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster
ization()); | 930 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster
ization()); |
| 919 } | 931 } |
| 920 } | 932 } |
| 921 | 933 |
| 922 } // namespace blink | 934 } // namespace blink |
| OLD | NEW |