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 "config.h" | 5 #include "config.h" |
6 #include "platform/graphics/paint/DisplayItemList.h" | 6 #include "platform/graphics/paint/DisplayItemList.h" |
7 | 7 |
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/CachedDisplayItem.h" | 10 #include "platform/graphics/paint/CachedDisplayItem.h" |
11 #include "platform/graphics/paint/ClipPathRecorder.h" | 11 #include "platform/graphics/paint/ClipPathRecorder.h" |
12 #include "platform/graphics/paint/ClipRecorder.h" | 12 #include "platform/graphics/paint/ClipRecorder.h" |
13 #include "platform/graphics/paint/DrawingDisplayItem.h" | 13 #include "platform/graphics/paint/DrawingDisplayItem.h" |
14 #include "platform/graphics/paint/DrawingRecorder.h" | 14 #include "platform/graphics/paint/DrawingRecorder.h" |
15 #include "platform/graphics/paint/SubsequenceRecorder.h" | 15 #include "platform/graphics/paint/SubsequenceRecorder.h" |
16 #include <gtest/gtest.h> | 16 #include <gtest/gtest.h> |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 class DisplayItemListTest : public ::testing::Test { | 20 class DisplayItemListTest : public ::testing::Test { |
21 public: | 21 public: |
22 DisplayItemListTest() | 22 DisplayItemListTest() |
23 : m_displayItemList(DisplayItemList::create()) | 23 : m_displayItemList(DisplayItemList::create()) |
24 , m_originalSlimmingPaintSubsequenceCachingEnabled(RuntimeEnabledFeature
s::slimmingPaintSubsequenceCachingEnabled()) { } | 24 , m_originalSlimmingPaintSubsequenceCachingEnabled(RuntimeEnabledFeature
s::slimmingPaintSubsequenceCachingEnabled()) |
| 25 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } |
25 | 26 |
26 protected: | 27 protected: |
27 DisplayItemList& displayItemList() { return *m_displayItemList; } | 28 DisplayItemList& displayItemList() { return *m_displayItemList; } |
28 | 29 |
29 private: | 30 private: |
30 void TearDown() override | 31 void TearDown() override |
31 { | 32 { |
32 RuntimeEnabledFeatures::setSlimmingPaintSubsequenceCachingEnabled(m_orig
inalSlimmingPaintSubsequenceCachingEnabled); | 33 RuntimeEnabledFeatures::setSlimmingPaintSubsequenceCachingEnabled(m_orig
inalSlimmingPaintSubsequenceCachingEnabled); |
| 34 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); |
33 } | 35 } |
34 | 36 |
35 OwnPtr<DisplayItemList> m_displayItemList; | 37 OwnPtr<DisplayItemList> m_displayItemList; |
36 bool m_originalSlimmingPaintSubsequenceCachingEnabled; | 38 bool m_originalSlimmingPaintSubsequenceCachingEnabled; |
| 39 bool m_originalSlimmingPaintV2Enabled; |
37 }; | 40 }; |
38 | 41 |
39 const DisplayItem::Type foregroundDrawingType = static_cast<DisplayItem::Type>(D
isplayItem::DrawingPaintPhaseFirst + 4); | 42 const DisplayItem::Type foregroundDrawingType = static_cast<DisplayItem::Type>(D
isplayItem::DrawingPaintPhaseFirst + 4); |
40 const DisplayItem::Type backgroundDrawingType = DisplayItem::DrawingPaintPhaseFi
rst; | 43 const DisplayItem::Type backgroundDrawingType = DisplayItem::DrawingPaintPhaseFi
rst; |
41 const DisplayItem::Type clipType = DisplayItem::ClipFirst; | 44 const DisplayItem::Type clipType = DisplayItem::ClipFirst; |
42 const DisplayItem::Type subsequenceType = DisplayItem::SubsequenceNormalFlowAndP
ositiveZOrder; | 45 const DisplayItem::Type subsequenceType = DisplayItem::SubsequenceNormalFlowAndP
ositiveZOrder; |
43 const DisplayItem::Type endSubsequenceType = DisplayItem::subsequenceTypeToEndSu
bsequenceType(subsequenceType); | 46 const DisplayItem::Type endSubsequenceType = DisplayItem::subsequenceTypeToEndSu
bsequenceType(subsequenceType); |
44 const DisplayItem::Type cachedSubsequenceType = DisplayItem::subsequenceTypeToCa
chedSubsequenceType(subsequenceType); | 47 const DisplayItem::Type cachedSubsequenceType = DisplayItem::subsequenceTypeToCa
chedSubsequenceType(subsequenceType); |
45 | 48 |
46 class TestDisplayItemClient { | 49 class TestDisplayItemClient { |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 } | 768 } |
766 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 769 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
767 displayItemList().commitNewDisplayItems(); | 770 displayItemList().commitNewDisplayItems(); |
768 | 771 |
769 // Empty clips should have been optimized out. | 772 // Empty clips should have been optimized out. |
770 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, | 773 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, |
771 TestDisplayItem(first, backgroundDrawingType), | 774 TestDisplayItem(first, backgroundDrawingType), |
772 TestDisplayItem(third, backgroundDrawingType)); | 775 TestDisplayItem(third, backgroundDrawingType)); |
773 } | 776 } |
774 | 777 |
| 778 TEST_F(DisplayItemListTest, SmallDisplayItemListHasOnePaintChunk) |
| 779 { |
| 780 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
| 781 TestDisplayItemClient client("test client"); |
| 782 |
| 783 GraphicsContext context(&displayItemList()); |
| 784 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 785 |
| 786 displayItemList().commitNewDisplayItems(); |
| 787 const auto& paintChunks = displayItemList().paintChunks(); |
| 788 ASSERT_EQ(1u, paintChunks.size()); |
| 789 EXPECT_EQ(0u, paintChunks[0].beginIndex); |
| 790 EXPECT_EQ(1u, paintChunks[0].endIndex); |
| 791 } |
| 792 |
775 } // namespace blink | 793 } // namespace blink |
OLD | NEW |