| 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 | 45 |
| 43 class TestDisplayItemClient { | 46 class TestDisplayItemClient { |
| 44 public: | 47 public: |
| 45 TestDisplayItemClient(const String& name) | 48 TestDisplayItemClient(const String& name) |
| 46 : m_name(name) | 49 : m_name(name) |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 } | 764 } |
| 762 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 765 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 763 displayItemList().commitNewDisplayItems(); | 766 displayItemList().commitNewDisplayItems(); |
| 764 | 767 |
| 765 // Empty clips should have been optimized out. | 768 // Empty clips should have been optimized out. |
| 766 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, | 769 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, |
| 767 TestDisplayItem(first, backgroundDrawingType), | 770 TestDisplayItem(first, backgroundDrawingType), |
| 768 TestDisplayItem(third, backgroundDrawingType)); | 771 TestDisplayItem(third, backgroundDrawingType)); |
| 769 } | 772 } |
| 770 | 773 |
| 774 TEST_F(DisplayItemListTest, SmallDisplayItemListHasOnePaintChunk) |
| 775 { |
| 776 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
| 777 TestDisplayItemClient client("test client"); |
| 778 |
| 779 GraphicsContext context(&displayItemList()); |
| 780 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
| 781 |
| 782 displayItemList().commitNewDisplayItems(); |
| 783 const auto& paintChunks = displayItemList().paintChunks(); |
| 784 ASSERT_EQ(1u, paintChunks.size()); |
| 785 EXPECT_EQ(0u, paintChunks[0].beginIndex); |
| 786 EXPECT_EQ(1u, paintChunks[0].endIndex); |
| 787 } |
| 788 |
| 771 } // namespace blink | 789 } // namespace blink |
| OLD | NEW |