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

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

Issue 1379883003: Create PaintChunk and begin writing code to build paint chunks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: correct comment Created 5 years, 2 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 "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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } 767 }
765 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 768 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100));
766 displayItemList().commitNewDisplayItems(); 769 displayItemList().commitNewDisplayItems();
767 770
768 // Empty clips should have been optimized out. 771 // Empty clips should have been optimized out.
769 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 772 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2,
770 TestDisplayItem(first, backgroundDrawingType), 773 TestDisplayItem(first, backgroundDrawingType),
771 TestDisplayItem(third, backgroundDrawingType)); 774 TestDisplayItem(third, backgroundDrawingType));
772 } 775 }
773 776
777 TEST_F(DisplayItemListTest, SmallDisplayItemListHasOnePaintChunk)
778 {
779 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
780 TestDisplayItemClient client("test client");
781
782 GraphicsContext context(&displayItemList());
783 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100));
784
785 displayItemList().commitNewDisplayItems();
786 const auto& paintChunks = displayItemList().paintChunks();
787 ASSERT_EQ(1u, paintChunks.size());
788 EXPECT_EQ(0u, paintChunks[0].beginIndex);
789 EXPECT_EQ(1u, paintChunks[0].endIndex);
790 }
791
774 } // namespace blink 792 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698