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

Side by Side Diff: Source/core/paint/LayoutObjectDrawingRecorderTest.cpp

Issue 1193433004: Blink-side contiguous allocation of display items. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add ListContainer::AllocateAndConstructWithArguments and a TODO in DisplayItemList::findMatchingIte… Created 5 years, 5 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 "core/paint/LayoutObjectDrawingRecorder.h" 6 #include "core/paint/LayoutObjectDrawingRecorder.h"
7 7
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/paint/DeprecatedPaintLayer.h" 10 #include "core/paint/DeprecatedPaintLayer.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 void drawRect(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase , const FloatRect& bound) 62 void drawRect(GraphicsContext& context, LayoutView& layoutView, PaintPhase phase , const FloatRect& bound)
63 { 63 {
64 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun d); 64 LayoutObjectDrawingRecorder drawingRecorder(context, layoutView, phase, boun d);
65 if (drawingRecorder.canUseCachedDrawing()) 65 if (drawingRecorder.canUseCachedDrawing())
66 return; 66 return;
67 IntRect rect(0, 0, 10, 10); 67 IntRect rect(0, 0, 10, 10);
68 context.drawRect(rect); 68 context.drawRect(rect);
69 } 69 }
70 70
71 bool isDrawing(const DisplayItems::ItemHandle& item) 71 bool isDrawing(const DisplayItem& item)
72 { 72 {
73 return DisplayItem::isDrawingType(item.type()); 73 return DisplayItem::isDrawingType(item.type());
74 } 74 }
75 75
76 bool isCached(const DisplayItems::ItemHandle& item) 76 bool isCached(const DisplayItem& item)
77 { 77 {
78 return DisplayItem::isCachedType(item.type()); 78 return DisplayItem::isCachedType(item.type());
79 } 79 }
80 80
81 TEST_F(LayoutObjectDrawingRecorderTest, Nothing) 81 TEST_F(LayoutObjectDrawingRecorderTest, Nothing)
82 { 82 {
83 GraphicsContext context(&rootDisplayItemList()); 83 GraphicsContext context(&rootDisplayItemList());
84 FloatRect bound = layoutView().viewRect(); 84 FloatRect bound = layoutView().viewRect();
85 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size()); 85 EXPECT_EQ((size_t)0, rootDisplayItemList().displayItems().size());
86 86
87 drawNothing(context, layoutView(), PaintPhaseForeground, bound); 87 drawNothing(context, layoutView(), PaintPhaseForeground, bound);
88 rootDisplayItemList().commitNewDisplayItems(); 88 rootDisplayItemList().commitNewDisplayItems();
89 EXPECT_EQ((size_t)1, rootDisplayItemList().displayItems().size()); 89 EXPECT_EQ((size_t)1, rootDisplayItemList().displayItems().size());
90 const auto& item = rootDisplayItemList().displayItems()[0]; 90 const auto& item = *rootDisplayItemList().displayItems().elementAt(0);
91 ASSERT_TRUE(isDrawing(item)); 91 ASSERT_TRUE(isDrawing(item));
92 EXPECT_FALSE(item.picture()); 92 EXPECT_FALSE(static_cast<const DrawingDisplayItem&>(item).picture());
93 } 93 }
94 94
95 TEST_F(LayoutObjectDrawingRecorderTest, Rect) 95 TEST_F(LayoutObjectDrawingRecorderTest, Rect)
96 { 96 {
97 GraphicsContext context(&rootDisplayItemList()); 97 GraphicsContext context(&rootDisplayItemList());
98 FloatRect bound = layoutView().viewRect(); 98 FloatRect bound = layoutView().viewRect();
99 drawRect(context, layoutView(), PaintPhaseForeground, bound); 99 drawRect(context, layoutView(), PaintPhaseForeground, bound);
100 rootDisplayItemList().commitNewDisplayItems(); 100 rootDisplayItemList().commitNewDisplayItems();
101 EXPECT_EQ((size_t)1, rootDisplayItemList().displayItems().size()); 101 EXPECT_EQ((size_t)1, rootDisplayItemList().displayItems().size());
102 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0])); 102 EXPECT_TRUE(isDrawing(*rootDisplayItemList().displayItems().elementAt(0)));
103 } 103 }
104 104
105 TEST_F(LayoutObjectDrawingRecorderTest, Cached) 105 TEST_F(LayoutObjectDrawingRecorderTest, Cached)
106 { 106 {
107 GraphicsContext context(&rootDisplayItemList()); 107 GraphicsContext context(&rootDisplayItemList());
108 FloatRect bound = layoutView().viewRect(); 108 FloatRect bound = layoutView().viewRect();
109 drawNothing(context, layoutView(), PaintPhaseBlockBackground, bound); 109 drawNothing(context, layoutView(), PaintPhaseBlockBackground, bound);
110 drawRect(context, layoutView(), PaintPhaseForeground, bound); 110 drawRect(context, layoutView(), PaintPhaseForeground, bound);
111 rootDisplayItemList().commitNewDisplayItems(); 111 rootDisplayItemList().commitNewDisplayItems();
112 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size()); 112 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size());
113 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0])); 113 EXPECT_TRUE(isDrawing(*rootDisplayItemList().displayItems().elementAt(0)));
114 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[1])); 114 EXPECT_TRUE(isDrawing(*rootDisplayItemList().displayItems().elementAt(1)));
115 115
116 drawNothing(context, layoutView(), PaintPhaseBlockBackground, bound); 116 drawNothing(context, layoutView(), PaintPhaseBlockBackground, bound);
117 drawRect(context, layoutView(), PaintPhaseForeground, bound); 117 drawRect(context, layoutView(), PaintPhaseForeground, bound);
118 EXPECT_EQ((size_t)2, newDisplayItemsBeforeUpdate().size()); 118 EXPECT_EQ((size_t)2, newDisplayItemsBeforeUpdate().size());
119 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[0])); 119 EXPECT_TRUE(isCached(*newDisplayItemsBeforeUpdate().elementAt(0)));
120 EXPECT_TRUE(isCached(newDisplayItemsBeforeUpdate()[1])); 120 EXPECT_TRUE(isCached(*newDisplayItemsBeforeUpdate().elementAt(1)));
121 rootDisplayItemList().commitNewDisplayItems(); 121 rootDisplayItemList().commitNewDisplayItems();
122 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size()); 122 EXPECT_EQ((size_t)2, rootDisplayItemList().displayItems().size());
123 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[0])); 123 EXPECT_TRUE(isDrawing(*rootDisplayItemList().displayItems().elementAt(0)));
124 EXPECT_TRUE(isDrawing(rootDisplayItemList().displayItems()[1])); 124 EXPECT_TRUE(isDrawing(*rootDisplayItemList().displayItems().elementAt(1)));
125 } 125 }
126 126
127 } // namespace 127 } // namespace
128 } // namespace blink 128 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/LayerFixedPositionRecorder.cpp ('k') | Source/core/paint/RoundedInnerRectClipper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698