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

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

Issue 1401363003: Rename DisplayItemList to PaintController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/PaintController.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 PaintControllerTest : public ::testing::Test {
21 public: 21 public:
22 DisplayItemListTest() 22 PaintControllerTest()
23 : m_displayItemList(DisplayItemList::create()) 23 : m_paintController(PaintController::create())
24 , m_originalSlimmingPaintSubsequenceCachingEnabled(RuntimeEnabledFeature s::slimmingPaintSubsequenceCachingEnabled()) 24 , m_originalSlimmingPaintSubsequenceCachingEnabled(RuntimeEnabledFeature s::slimmingPaintSubsequenceCachingEnabled())
25 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { } 25 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { }
26 26
27 protected: 27 protected:
28 DisplayItemList& displayItemList() { return *m_displayItemList; } 28 PaintController& paintController() { return *m_paintController; }
29 29
30 private: 30 private:
31 void TearDown() override 31 void TearDown() override
32 { 32 {
33 RuntimeEnabledFeatures::setSlimmingPaintSubsequenceCachingEnabled(m_orig inalSlimmingPaintSubsequenceCachingEnabled); 33 RuntimeEnabledFeatures::setSlimmingPaintSubsequenceCachingEnabled(m_orig inalSlimmingPaintSubsequenceCachingEnabled);
34 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain tV2Enabled); 34 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain tV2Enabled);
35 } 35 }
36 36
37 OwnPtr<DisplayItemList> m_displayItemList; 37 OwnPtr<PaintController> m_paintController;
38 bool m_originalSlimmingPaintSubsequenceCachingEnabled; 38 bool m_originalSlimmingPaintSubsequenceCachingEnabled;
39 bool m_originalSlimmingPaintV2Enabled; 39 bool m_originalSlimmingPaintV2Enabled;
40 }; 40 };
41 41
42 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);
43 const DisplayItem::Type backgroundDrawingType = DisplayItem::DrawingPaintPhaseFi rst; 43 const DisplayItem::Type backgroundDrawingType = DisplayItem::DrawingPaintPhaseFi rst;
44 const DisplayItem::Type clipType = DisplayItem::ClipFirst; 44 const DisplayItem::Type clipType = DisplayItem::ClipFirst;
45 const DisplayItem::Type subsequenceType = DisplayItem::SubsequenceNormalFlowAndP ositiveZOrder; 45 const DisplayItem::Type subsequenceType = DisplayItem::SubsequenceNormalFlowAndP ositiveZOrder;
46 const DisplayItem::Type endSubsequenceType = DisplayItem::subsequenceTypeToEndSu bsequenceType(subsequenceType); 46 const DisplayItem::Type endSubsequenceType = DisplayItem::subsequenceTypeToEndSu bsequenceType(subsequenceType);
47 const DisplayItem::Type cachedSubsequenceType = DisplayItem::subsequenceTypeToCa chedSubsequenceType(subsequenceType); 47 const DisplayItem::Type cachedSubsequenceType = DisplayItem::subsequenceTypeToCa chedSubsequenceType(subsequenceType);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 IntRect rect(0, 0, 10, 10); 96 IntRect rect(0, 0, 10, 10);
97 context.drawRect(rect); 97 context.drawRect(rect);
98 } 98 }
99 99
100 void drawClippedRect(GraphicsContext& context, const TestDisplayItemClient& clie nt, DisplayItem::Type clipType, DisplayItem::Type drawingType, const FloatRect& bound) 100 void drawClippedRect(GraphicsContext& context, const TestDisplayItemClient& clie nt, DisplayItem::Type clipType, DisplayItem::Type drawingType, const FloatRect& bound)
101 { 101 {
102 ClipRecorder clipRecorder(context, client, clipType, LayoutRect(1, 1, 9, 9)) ; 102 ClipRecorder clipRecorder(context, client, clipType, LayoutRect(1, 1, 9, 9)) ;
103 drawRect(context, client, drawingType, bound); 103 drawRect(context, client, drawingType, bound);
104 } 104 }
105 105
106 TEST_F(DisplayItemListTest, NestedRecorders) 106 TEST_F(PaintControllerTest, NestedRecorders)
107 { 107 {
108 GraphicsContext context(&displayItemList()); 108 GraphicsContext context(&paintController());
109 109
110 TestDisplayItemClient client("client"); 110 TestDisplayItemClient client("client");
111 111
112 drawClippedRect(context, client, clipType, backgroundDrawingType, FloatRect( 100, 100, 200, 200)); 112 drawClippedRect(context, client, clipType, backgroundDrawingType, FloatRect( 100, 100, 200, 200));
113 displayItemList().commitNewDisplayItems(); 113 paintController().commitNewDisplayItems();
114 114
115 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 3, 115 EXPECT_DISPLAY_LIST(paintController().displayItems(), 3,
116 TestDisplayItem(client, clipType), 116 TestDisplayItem(client, clipType),
117 TestDisplayItem(client, backgroundDrawingType), 117 TestDisplayItem(client, backgroundDrawingType),
118 TestDisplayItem(client, DisplayItem::clipTypeToEndClipType(clipType))); 118 TestDisplayItem(client, DisplayItem::clipTypeToEndClipType(clipType)));
119 } 119 }
120 120
121 TEST_F(DisplayItemListTest, UpdateBasic) 121 TEST_F(PaintControllerTest, UpdateBasic)
122 { 122 {
123 TestDisplayItemClient first("first"); 123 TestDisplayItemClient first("first");
124 TestDisplayItemClient second("second"); 124 TestDisplayItemClient second("second");
125 GraphicsContext context(&displayItemList()); 125 GraphicsContext context(&paintController());
126 126
127 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 )); 127 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 ));
128 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20 0)); 128 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 200, 20 0));
129 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 )); 129 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 ));
130 displayItemList().commitNewDisplayItems(); 130 paintController().commitNewDisplayItems();
131 131
132 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 3, 132 EXPECT_DISPLAY_LIST(paintController().displayItems(), 3,
133 TestDisplayItem(first, backgroundDrawingType), 133 TestDisplayItem(first, backgroundDrawingType),
134 TestDisplayItem(second, backgroundDrawingType), 134 TestDisplayItem(second, backgroundDrawingType),
135 TestDisplayItem(first, foregroundDrawingType)); 135 TestDisplayItem(first, foregroundDrawingType));
136 136
137 displayItemList().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct()); 137 paintController().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct());
138 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 )); 138 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 300, 300 ));
139 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 )); 139 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 300, 300 ));
140 displayItemList().commitNewDisplayItems(); 140 paintController().commitNewDisplayItems();
141 141
142 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 142 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
143 TestDisplayItem(first, backgroundDrawingType), 143 TestDisplayItem(first, backgroundDrawingType),
144 TestDisplayItem(first, foregroundDrawingType)); 144 TestDisplayItem(first, foregroundDrawingType));
145 } 145 }
146 146
147 TEST_F(DisplayItemListTest, UpdateSwapOrder) 147 TEST_F(PaintControllerTest, UpdateSwapOrder)
148 { 148 {
149 TestDisplayItemClient first("first"); 149 TestDisplayItemClient first("first");
150 TestDisplayItemClient second("second"); 150 TestDisplayItemClient second("second");
151 TestDisplayItemClient unaffected("unaffected"); 151 TestDisplayItemClient unaffected("unaffected");
152 GraphicsContext context(&displayItemList()); 152 GraphicsContext context(&paintController());
153 153
154 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 154 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
155 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 155 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
156 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10)); 156 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10));
157 displayItemList().commitNewDisplayItems(); 157 paintController().commitNewDisplayItems();
158 158
159 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 3, 159 EXPECT_DISPLAY_LIST(paintController().displayItems(), 3,
160 TestDisplayItem(first, backgroundDrawingType), 160 TestDisplayItem(first, backgroundDrawingType),
161 TestDisplayItem(second, backgroundDrawingType), 161 TestDisplayItem(second, backgroundDrawingType),
162 TestDisplayItem(unaffected, backgroundDrawingType)); 162 TestDisplayItem(unaffected, backgroundDrawingType));
163 163
164 displayItemList().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct()); 164 paintController().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct());
165 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 165 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
166 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 166 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
167 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10)); 167 drawRect(context, unaffected, backgroundDrawingType, FloatRect(300, 300, 10, 10));
168 displayItemList().commitNewDisplayItems(); 168 paintController().commitNewDisplayItems();
169 169
170 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 3, 170 EXPECT_DISPLAY_LIST(paintController().displayItems(), 3,
171 TestDisplayItem(second, backgroundDrawingType), 171 TestDisplayItem(second, backgroundDrawingType),
172 TestDisplayItem(first, backgroundDrawingType), 172 TestDisplayItem(first, backgroundDrawingType),
173 TestDisplayItem(unaffected, backgroundDrawingType)); 173 TestDisplayItem(unaffected, backgroundDrawingType));
174 } 174 }
175 175
176 TEST_F(DisplayItemListTest, UpdateNewItemInMiddle) 176 TEST_F(PaintControllerTest, UpdateNewItemInMiddle)
177 { 177 {
178 TestDisplayItemClient first("first"); 178 TestDisplayItemClient first("first");
179 TestDisplayItemClient second("second"); 179 TestDisplayItemClient second("second");
180 TestDisplayItemClient third("third"); 180 TestDisplayItemClient third("third");
181 GraphicsContext context(&displayItemList()); 181 GraphicsContext context(&paintController());
182 182
183 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 183 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
184 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 184 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
185 displayItemList().commitNewDisplayItems(); 185 paintController().commitNewDisplayItems();
186 186
187 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 187 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
188 TestDisplayItem(first, backgroundDrawingType), 188 TestDisplayItem(first, backgroundDrawingType),
189 TestDisplayItem(second, backgroundDrawingType)); 189 TestDisplayItem(second, backgroundDrawingType));
190 190
191 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 191 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
192 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50) ); 192 drawRect(context, third, backgroundDrawingType, FloatRect(125, 100, 200, 50) );
193 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 193 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
194 displayItemList().commitNewDisplayItems(); 194 paintController().commitNewDisplayItems();
195 195
196 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 3, 196 EXPECT_DISPLAY_LIST(paintController().displayItems(), 3,
197 TestDisplayItem(first, backgroundDrawingType), 197 TestDisplayItem(first, backgroundDrawingType),
198 TestDisplayItem(third, backgroundDrawingType), 198 TestDisplayItem(third, backgroundDrawingType),
199 TestDisplayItem(second, backgroundDrawingType)); 199 TestDisplayItem(second, backgroundDrawingType));
200 } 200 }
201 201
202 TEST_F(DisplayItemListTest, UpdateInvalidationWithPhases) 202 TEST_F(PaintControllerTest, UpdateInvalidationWithPhases)
203 { 203 {
204 TestDisplayItemClient first("first"); 204 TestDisplayItemClient first("first");
205 TestDisplayItemClient second("second"); 205 TestDisplayItemClient second("second");
206 TestDisplayItemClient third("third"); 206 TestDisplayItemClient third("third");
207 GraphicsContext context(&displayItemList()); 207 GraphicsContext context(&paintController());
208 208
209 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 209 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
210 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 210 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
211 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ; 211 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ;
212 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); 212 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 ));
213 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); 213 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 ));
214 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)) ; 214 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)) ;
215 displayItemList().commitNewDisplayItems(); 215 paintController().commitNewDisplayItems();
216 216
217 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 6, 217 EXPECT_DISPLAY_LIST(paintController().displayItems(), 6,
218 TestDisplayItem(first, backgroundDrawingType), 218 TestDisplayItem(first, backgroundDrawingType),
219 TestDisplayItem(second, backgroundDrawingType), 219 TestDisplayItem(second, backgroundDrawingType),
220 TestDisplayItem(third, backgroundDrawingType), 220 TestDisplayItem(third, backgroundDrawingType),
221 TestDisplayItem(first, foregroundDrawingType), 221 TestDisplayItem(first, foregroundDrawingType),
222 TestDisplayItem(second, foregroundDrawingType), 222 TestDisplayItem(second, foregroundDrawingType),
223 TestDisplayItem(third, foregroundDrawingType)); 223 TestDisplayItem(third, foregroundDrawingType));
224 224
225 displayItemList().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct()); 225 paintController().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct());
226 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 )); 226 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 100, 100 ));
227 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 )); 227 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 50, 200 ));
228 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ; 228 drawRect(context, third, backgroundDrawingType, FloatRect(300, 100, 50, 50)) ;
229 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 )); 229 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 100, 100 ));
230 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 )); 230 drawRect(context, second, foregroundDrawingType, FloatRect(100, 100, 50, 200 ));
231 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)) ; 231 drawRect(context, third, foregroundDrawingType, FloatRect(300, 100, 50, 50)) ;
232 displayItemList().commitNewDisplayItems(); 232 paintController().commitNewDisplayItems();
233 233
234 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 6, 234 EXPECT_DISPLAY_LIST(paintController().displayItems(), 6,
235 TestDisplayItem(first, backgroundDrawingType), 235 TestDisplayItem(first, backgroundDrawingType),
236 TestDisplayItem(second, backgroundDrawingType), 236 TestDisplayItem(second, backgroundDrawingType),
237 TestDisplayItem(third, backgroundDrawingType), 237 TestDisplayItem(third, backgroundDrawingType),
238 TestDisplayItem(first, foregroundDrawingType), 238 TestDisplayItem(first, foregroundDrawingType),
239 TestDisplayItem(second, foregroundDrawingType), 239 TestDisplayItem(second, foregroundDrawingType),
240 TestDisplayItem(third, foregroundDrawingType)); 240 TestDisplayItem(third, foregroundDrawingType));
241 } 241 }
242 242
243 TEST_F(DisplayItemListTest, UpdateAddFirstOverlap) 243 TEST_F(PaintControllerTest, UpdateAddFirstOverlap)
244 { 244 {
245 TestDisplayItemClient first("first"); 245 TestDisplayItemClient first("first");
246 TestDisplayItemClient second("second"); 246 TestDisplayItemClient second("second");
247 GraphicsContext context(&displayItemList()); 247 GraphicsContext context(&paintController());
248 248
249 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); 249 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) );
250 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); 250 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) );
251 displayItemList().commitNewDisplayItems(); 251 paintController().commitNewDisplayItems();
252 252
253 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 253 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
254 TestDisplayItem(second, backgroundDrawingType), 254 TestDisplayItem(second, backgroundDrawingType),
255 TestDisplayItem(second, foregroundDrawingType)); 255 TestDisplayItem(second, foregroundDrawingType));
256 256
257 displayItemList().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t()); 257 paintController().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t());
258 displayItemList().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct()); 258 paintController().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct());
259 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 259 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
260 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); 260 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 ));
261 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); 261 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) );
262 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); 262 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) );
263 displayItemList().commitNewDisplayItems(); 263 paintController().commitNewDisplayItems();
264 264
265 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 4, 265 EXPECT_DISPLAY_LIST(paintController().displayItems(), 4,
266 TestDisplayItem(first, backgroundDrawingType), 266 TestDisplayItem(first, backgroundDrawingType),
267 TestDisplayItem(first, foregroundDrawingType), 267 TestDisplayItem(first, foregroundDrawingType),
268 TestDisplayItem(second, backgroundDrawingType), 268 TestDisplayItem(second, backgroundDrawingType),
269 TestDisplayItem(second, foregroundDrawingType)); 269 TestDisplayItem(second, foregroundDrawingType));
270 270
271 displayItemList().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t()); 271 paintController().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t());
272 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); 272 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) );
273 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); 273 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) );
274 displayItemList().commitNewDisplayItems(); 274 paintController().commitNewDisplayItems();
275 275
276 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 276 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
277 TestDisplayItem(second, backgroundDrawingType), 277 TestDisplayItem(second, backgroundDrawingType),
278 TestDisplayItem(second, foregroundDrawingType)); 278 TestDisplayItem(second, foregroundDrawingType));
279 } 279 }
280 280
281 TEST_F(DisplayItemListTest, UpdateAddLastOverlap) 281 TEST_F(PaintControllerTest, UpdateAddLastOverlap)
282 { 282 {
283 TestDisplayItemClient first("first"); 283 TestDisplayItemClient first("first");
284 TestDisplayItemClient second("second"); 284 TestDisplayItemClient second("second");
285 GraphicsContext context(&displayItemList()); 285 GraphicsContext context(&paintController());
286 286
287 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 287 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
288 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); 288 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 ));
289 displayItemList().commitNewDisplayItems(); 289 paintController().commitNewDisplayItems();
290 290
291 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 291 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
292 TestDisplayItem(first, backgroundDrawingType), 292 TestDisplayItem(first, backgroundDrawingType),
293 TestDisplayItem(first, foregroundDrawingType)); 293 TestDisplayItem(first, foregroundDrawingType));
294 294
295 displayItemList().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t()); 295 paintController().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t());
296 displayItemList().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct()); 296 paintController().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct());
297 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 297 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
298 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); 298 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 ));
299 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) ); 299 drawRect(context, second, backgroundDrawingType, FloatRect(200, 200, 50, 50) );
300 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) ); 300 drawRect(context, second, foregroundDrawingType, FloatRect(200, 200, 50, 50) );
301 displayItemList().commitNewDisplayItems(); 301 paintController().commitNewDisplayItems();
302 302
303 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 4, 303 EXPECT_DISPLAY_LIST(paintController().displayItems(), 4,
304 TestDisplayItem(first, backgroundDrawingType), 304 TestDisplayItem(first, backgroundDrawingType),
305 TestDisplayItem(first, foregroundDrawingType), 305 TestDisplayItem(first, foregroundDrawingType),
306 TestDisplayItem(second, backgroundDrawingType), 306 TestDisplayItem(second, backgroundDrawingType),
307 TestDisplayItem(second, foregroundDrawingType)); 307 TestDisplayItem(second, foregroundDrawingType));
308 308
309 displayItemList().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t()); 309 paintController().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t());
310 displayItemList().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct()); 310 paintController().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct());
311 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 311 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
312 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 )); 312 drawRect(context, first, foregroundDrawingType, FloatRect(100, 100, 150, 150 ));
313 displayItemList().commitNewDisplayItems(); 313 paintController().commitNewDisplayItems();
314 314
315 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 315 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
316 TestDisplayItem(first, backgroundDrawingType), 316 TestDisplayItem(first, backgroundDrawingType),
317 TestDisplayItem(first, foregroundDrawingType)); 317 TestDisplayItem(first, foregroundDrawingType));
318 } 318 }
319 319
320 TEST_F(DisplayItemListTest, UpdateClip) 320 TEST_F(PaintControllerTest, UpdateClip)
321 { 321 {
322 TestDisplayItemClient first("first"); 322 TestDisplayItemClient first("first");
323 TestDisplayItemClient second("second"); 323 TestDisplayItemClient second("second");
324 GraphicsContext context(&displayItemList()); 324 GraphicsContext context(&paintController());
325 325
326 { 326 {
327 ClipRecorder clipRecorder(context, first, clipType, LayoutRect(1, 1, 2, 2)); 327 ClipRecorder clipRecorder(context, first, clipType, LayoutRect(1, 1, 2, 2));
328 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150)); 328 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150));
329 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150 , 150)); 329 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150 , 150));
330 } 330 }
331 displayItemList().commitNewDisplayItems(); 331 paintController().commitNewDisplayItems();
332 332
333 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 4, 333 EXPECT_DISPLAY_LIST(paintController().displayItems(), 4,
334 TestDisplayItem(first, clipType), 334 TestDisplayItem(first, clipType),
335 TestDisplayItem(first, backgroundDrawingType), 335 TestDisplayItem(first, backgroundDrawingType),
336 TestDisplayItem(second, backgroundDrawingType), 336 TestDisplayItem(second, backgroundDrawingType),
337 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType))); 337 TestDisplayItem(first, DisplayItem::clipTypeToEndClipType(clipType)));
338 338
339 displayItemList().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t()); 339 paintController().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t());
340 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 340 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
341 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0)); 341 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0));
342 displayItemList().commitNewDisplayItems(); 342 paintController().commitNewDisplayItems();
343 343
344 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 344 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
345 TestDisplayItem(first, backgroundDrawingType), 345 TestDisplayItem(first, backgroundDrawingType),
346 TestDisplayItem(second, backgroundDrawingType)); 346 TestDisplayItem(second, backgroundDrawingType));
347 347
348 displayItemList().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct()); 348 paintController().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct());
349 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 349 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
350 { 350 {
351 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2, 2)); 351 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2, 2));
352 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150 , 150)); 352 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150 , 150));
353 } 353 }
354 displayItemList().commitNewDisplayItems(); 354 paintController().commitNewDisplayItems();
355 355
356 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 4, 356 EXPECT_DISPLAY_LIST(paintController().displayItems(), 4,
357 TestDisplayItem(first, backgroundDrawingType), 357 TestDisplayItem(first, backgroundDrawingType),
358 TestDisplayItem(second, clipType), 358 TestDisplayItem(second, clipType),
359 TestDisplayItem(second, backgroundDrawingType), 359 TestDisplayItem(second, backgroundDrawingType),
360 TestDisplayItem(second, DisplayItem::clipTypeToEndClipType(clipType))); 360 TestDisplayItem(second, DisplayItem::clipTypeToEndClipType(clipType)));
361 } 361 }
362 362
363 TEST_F(DisplayItemListTest, CachedDisplayItems) 363 TEST_F(PaintControllerTest, CachedDisplayItems)
364 { 364 {
365 TestDisplayItemClient first("first"); 365 TestDisplayItemClient first("first");
366 TestDisplayItemClient second("second"); 366 TestDisplayItemClient second("second");
367 GraphicsContext context(&displayItemList()); 367 GraphicsContext context(&paintController());
368 368
369 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 369 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
370 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0)); 370 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0));
371 displayItemList().commitNewDisplayItems(); 371 paintController().commitNewDisplayItems();
372 372
373 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 373 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
374 TestDisplayItem(first, backgroundDrawingType), 374 TestDisplayItem(first, backgroundDrawingType),
375 TestDisplayItem(second, backgroundDrawingType)); 375 TestDisplayItem(second, backgroundDrawingType));
376 EXPECT_TRUE(displayItemList().clientCacheIsValid(first.displayItemClient())) ; 376 EXPECT_TRUE(paintController().clientCacheIsValid(first.displayItemClient())) ;
377 EXPECT_TRUE(displayItemList().clientCacheIsValid(second.displayItemClient()) ); 377 EXPECT_TRUE(paintController().clientCacheIsValid(second.displayItemClient()) );
378 const SkPicture* firstPicture = static_cast<const DrawingDisplayItem&>(displ ayItemList().displayItems()[0]).picture(); 378 const SkPicture* firstPicture = static_cast<const DrawingDisplayItem&>(paint Controller().displayItems()[0]).picture();
379 const SkPicture* secondPicture = static_cast<const DrawingDisplayItem&>(disp layItemList().displayItems()[1]).picture(); 379 const SkPicture* secondPicture = static_cast<const DrawingDisplayItem&>(pain tController().displayItems()[1]).picture();
380 380
381 displayItemList().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t()); 381 paintController().invalidate(first, PaintInvalidationFull, IntRect(), IntRec t());
382 EXPECT_FALSE(displayItemList().clientCacheIsValid(first.displayItemClient()) ); 382 EXPECT_FALSE(paintController().clientCacheIsValid(first.displayItemClient()) );
383 EXPECT_TRUE(displayItemList().clientCacheIsValid(second.displayItemClient()) ); 383 EXPECT_TRUE(paintController().clientCacheIsValid(second.displayItemClient()) );
384 384
385 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 )); 385 drawRect(context, first, backgroundDrawingType, FloatRect(100, 100, 150, 150 ));
386 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0)); 386 drawRect(context, second, backgroundDrawingType, FloatRect(100, 100, 150, 15 0));
387 displayItemList().commitNewDisplayItems(); 387 paintController().commitNewDisplayItems();
388 388
389 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 389 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
390 TestDisplayItem(first, backgroundDrawingType), 390 TestDisplayItem(first, backgroundDrawingType),
391 TestDisplayItem(second, backgroundDrawingType)); 391 TestDisplayItem(second, backgroundDrawingType));
392 // The first display item should be updated. 392 // The first display item should be updated.
393 EXPECT_NE(firstPicture, static_cast<const DrawingDisplayItem&>(displayItemLi st().displayItems()[0]).picture()); 393 EXPECT_NE(firstPicture, static_cast<const DrawingDisplayItem&>(paintControll er().displayItems()[0]).picture());
394 // The second display item should be cached. 394 // The second display item should be cached.
395 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(displayItemL ist().displayItems()[1]).picture()); 395 EXPECT_EQ(secondPicture, static_cast<const DrawingDisplayItem&>(paintControl ler().displayItems()[1]).picture());
396 EXPECT_TRUE(displayItemList().clientCacheIsValid(first.displayItemClient())) ; 396 EXPECT_TRUE(paintController().clientCacheIsValid(first.displayItemClient())) ;
397 EXPECT_TRUE(displayItemList().clientCacheIsValid(second.displayItemClient()) ); 397 EXPECT_TRUE(paintController().clientCacheIsValid(second.displayItemClient()) );
398 398
399 displayItemList().invalidateAll(); 399 paintController().invalidateAll();
400 EXPECT_FALSE(displayItemList().clientCacheIsValid(first.displayItemClient()) ); 400 EXPECT_FALSE(paintController().clientCacheIsValid(first.displayItemClient()) );
401 EXPECT_FALSE(displayItemList().clientCacheIsValid(second.displayItemClient() )); 401 EXPECT_FALSE(paintController().clientCacheIsValid(second.displayItemClient() ));
402 } 402 }
403 403
404 TEST_F(DisplayItemListTest, ComplexUpdateSwapOrder) 404 TEST_F(PaintControllerTest, ComplexUpdateSwapOrder)
405 { 405 {
406 TestDisplayItemClient container1("container1"); 406 TestDisplayItemClient container1("container1");
407 TestDisplayItemClient content1("content1"); 407 TestDisplayItemClient content1("content1");
408 TestDisplayItemClient container2("container2"); 408 TestDisplayItemClient container2("container2");
409 TestDisplayItemClient content2("content2"); 409 TestDisplayItemClient content2("content2");
410 GraphicsContext context(&displayItemList()); 410 GraphicsContext context(&paintController());
411 411
412 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100)); 412 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100));
413 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00)); 413 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00));
414 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00)); 414 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00));
415 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100)); 415 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100));
416 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100)); 416 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100));
417 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00)); 417 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00));
418 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00)); 418 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00));
419 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100)); 419 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100));
420 displayItemList().commitNewDisplayItems(); 420 paintController().commitNewDisplayItems();
421 421
422 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 8, 422 EXPECT_DISPLAY_LIST(paintController().displayItems(), 8,
423 TestDisplayItem(container1, backgroundDrawingType), 423 TestDisplayItem(container1, backgroundDrawingType),
424 TestDisplayItem(content1, backgroundDrawingType), 424 TestDisplayItem(content1, backgroundDrawingType),
425 TestDisplayItem(content1, foregroundDrawingType), 425 TestDisplayItem(content1, foregroundDrawingType),
426 TestDisplayItem(container1, foregroundDrawingType), 426 TestDisplayItem(container1, foregroundDrawingType),
427 TestDisplayItem(container2, backgroundDrawingType), 427 TestDisplayItem(container2, backgroundDrawingType),
428 TestDisplayItem(content2, backgroundDrawingType), 428 TestDisplayItem(content2, backgroundDrawingType),
429 TestDisplayItem(content2, foregroundDrawingType), 429 TestDisplayItem(content2, foregroundDrawingType),
430 TestDisplayItem(container2, foregroundDrawingType)); 430 TestDisplayItem(container2, foregroundDrawingType));
431 431
432 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2. 432 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2.
433 displayItemList().invalidate(container1, PaintInvalidationFull, IntRect(), I ntRect()); 433 paintController().invalidate(container1, PaintInvalidationFull, IntRect(), I ntRect());
434 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100)); 434 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100 , 100));
435 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00)); 435 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 50, 2 00));
436 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00)); 436 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 50, 2 00));
437 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100)); 437 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100 , 100));
438 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100)); 438 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100 , 100));
439 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00)); 439 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 50, 2 00));
440 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00)); 440 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 50, 2 00));
441 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100)); 441 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100 , 100));
442 displayItemList().commitNewDisplayItems(); 442 paintController().commitNewDisplayItems();
443 443
444 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 8, 444 EXPECT_DISPLAY_LIST(paintController().displayItems(), 8,
445 TestDisplayItem(container2, backgroundDrawingType), 445 TestDisplayItem(container2, backgroundDrawingType),
446 TestDisplayItem(content2, backgroundDrawingType), 446 TestDisplayItem(content2, backgroundDrawingType),
447 TestDisplayItem(content2, foregroundDrawingType), 447 TestDisplayItem(content2, foregroundDrawingType),
448 TestDisplayItem(container2, foregroundDrawingType), 448 TestDisplayItem(container2, foregroundDrawingType),
449 TestDisplayItem(container1, backgroundDrawingType), 449 TestDisplayItem(container1, backgroundDrawingType),
450 TestDisplayItem(content1, backgroundDrawingType), 450 TestDisplayItem(content1, backgroundDrawingType),
451 TestDisplayItem(content1, foregroundDrawingType), 451 TestDisplayItem(content1, foregroundDrawingType),
452 TestDisplayItem(container1, foregroundDrawingType)); 452 TestDisplayItem(container1, foregroundDrawingType));
453 } 453 }
454 454
455 TEST_F(DisplayItemListTest, CachedSubsequenceSwapOrder) 455 TEST_F(PaintControllerTest, CachedSubsequenceSwapOrder)
456 { 456 {
457 RuntimeEnabledFeatures::setSlimmingPaintSubsequenceCachingEnabled(true); 457 RuntimeEnabledFeatures::setSlimmingPaintSubsequenceCachingEnabled(true);
458 458
459 TestDisplayItemClient container1("container1"); 459 TestDisplayItemClient container1("container1");
460 TestDisplayItemClient content1("content1"); 460 TestDisplayItemClient content1("content1");
461 TestDisplayItemClient container2("container2"); 461 TestDisplayItemClient container2("container2");
462 TestDisplayItemClient content2("content2"); 462 TestDisplayItemClient content2("content2");
463 GraphicsContext context(&displayItemList()); 463 GraphicsContext context(&paintController());
464 464
465 { 465 {
466 SubsequenceRecorder r(context, container1, subsequenceType); 466 SubsequenceRecorder r(context, container1, subsequenceType);
467 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); 467 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100));
468 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 5 0, 200)); 468 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 100, 5 0, 200));
469 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 5 0, 200)); 469 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 100, 5 0, 200));
470 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); 470 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100));
471 } 471 }
472 { 472 {
473 SubsequenceRecorder r(context, container2, subsequenceType); 473 SubsequenceRecorder r(context, container2, subsequenceType);
474 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100)); 474 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100));
475 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 5 0, 200)); 475 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 200, 5 0, 200));
476 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200)); 476 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200));
477 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100, 100)); 477 drawRect(context, container2, foregroundDrawingType, FloatRect(100, 200, 100, 100));
478 } 478 }
479 displayItemList().commitNewDisplayItems(); 479 paintController().commitNewDisplayItems();
480 480
481 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 12, 481 EXPECT_DISPLAY_LIST(paintController().displayItems(), 12,
482 TestDisplayItem(container1, subsequenceType), 482 TestDisplayItem(container1, subsequenceType),
483 TestDisplayItem(container1, backgroundDrawingType), 483 TestDisplayItem(container1, backgroundDrawingType),
484 TestDisplayItem(content1, backgroundDrawingType), 484 TestDisplayItem(content1, backgroundDrawingType),
485 TestDisplayItem(content1, foregroundDrawingType), 485 TestDisplayItem(content1, foregroundDrawingType),
486 TestDisplayItem(container1, foregroundDrawingType), 486 TestDisplayItem(container1, foregroundDrawingType),
487 TestDisplayItem(container1, endSubsequenceType), 487 TestDisplayItem(container1, endSubsequenceType),
488 488
489 TestDisplayItem(container2, subsequenceType), 489 TestDisplayItem(container2, subsequenceType),
490 TestDisplayItem(container2, backgroundDrawingType), 490 TestDisplayItem(container2, backgroundDrawingType),
491 TestDisplayItem(content2, backgroundDrawingType), 491 TestDisplayItem(content2, backgroundDrawingType),
492 TestDisplayItem(content2, foregroundDrawingType), 492 TestDisplayItem(content2, foregroundDrawingType),
493 TestDisplayItem(container2, foregroundDrawingType), 493 TestDisplayItem(container2, foregroundDrawingType),
494 TestDisplayItem(container2, endSubsequenceType)); 494 TestDisplayItem(container2, endSubsequenceType));
495 495
496 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2. 496 // Simulate the situation when container1 e.g. gets a z-index that is now gr eater than container2.
497 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer2, subsequenceType)); 497 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer2, subsequenceType));
498 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer1, subsequenceType)); 498 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, con tainer1, subsequenceType));
499 499
500 EXPECT_DISPLAY_LIST(displayItemList().newDisplayItems(), 2, 500 EXPECT_DISPLAY_LIST(paintController().newDisplayItems(), 2,
501 TestDisplayItem(container2, cachedSubsequenceType), 501 TestDisplayItem(container2, cachedSubsequenceType),
502 TestDisplayItem(container1, cachedSubsequenceType)); 502 TestDisplayItem(container1, cachedSubsequenceType));
503 503
504 displayItemList().commitNewDisplayItems(); 504 paintController().commitNewDisplayItems();
505 505
506 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 12, 506 EXPECT_DISPLAY_LIST(paintController().displayItems(), 12,
507 TestDisplayItem(container2, subsequenceType), 507 TestDisplayItem(container2, subsequenceType),
508 TestDisplayItem(container2, backgroundDrawingType), 508 TestDisplayItem(container2, backgroundDrawingType),
509 TestDisplayItem(content2, backgroundDrawingType), 509 TestDisplayItem(content2, backgroundDrawingType),
510 TestDisplayItem(content2, foregroundDrawingType), 510 TestDisplayItem(content2, foregroundDrawingType),
511 TestDisplayItem(container2, foregroundDrawingType), 511 TestDisplayItem(container2, foregroundDrawingType),
512 TestDisplayItem(container2, endSubsequenceType), 512 TestDisplayItem(container2, endSubsequenceType),
513 513
514 TestDisplayItem(container1, subsequenceType), 514 TestDisplayItem(container1, subsequenceType),
515 TestDisplayItem(container1, backgroundDrawingType), 515 TestDisplayItem(container1, backgroundDrawingType),
516 TestDisplayItem(content1, backgroundDrawingType), 516 TestDisplayItem(content1, backgroundDrawingType),
517 TestDisplayItem(content1, foregroundDrawingType), 517 TestDisplayItem(content1, foregroundDrawingType),
518 TestDisplayItem(container1, foregroundDrawingType), 518 TestDisplayItem(container1, foregroundDrawingType),
519 TestDisplayItem(container1, endSubsequenceType)); 519 TestDisplayItem(container1, endSubsequenceType));
520 } 520 }
521 521
522 TEST_F(DisplayItemListTest, OutOfOrderNoCrash) 522 TEST_F(PaintControllerTest, OutOfOrderNoCrash)
523 { 523 {
524 TestDisplayItemClient client("client"); 524 TestDisplayItemClient client("client");
525 GraphicsContext context(&displayItemList()); 525 GraphicsContext context(&paintController());
526 526
527 const DisplayItem::Type type1 = DisplayItem::DrawingFirst; 527 const DisplayItem::Type type1 = DisplayItem::DrawingFirst;
528 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 1); 528 const DisplayItem::Type type2 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 1);
529 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 2); 529 const DisplayItem::Type type3 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 2);
530 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 3); 530 const DisplayItem::Type type4 = static_cast<DisplayItem::Type>(DisplayItem:: DrawingFirst + 3);
531 531
532 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); 532 drawRect(context, client, type1, FloatRect(100, 100, 100, 100));
533 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); 533 drawRect(context, client, type2, FloatRect(100, 100, 50, 200));
534 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); 534 drawRect(context, client, type3, FloatRect(100, 100, 50, 200));
535 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); 535 drawRect(context, client, type4, FloatRect(100, 100, 100, 100));
536 536
537 displayItemList().commitNewDisplayItems(); 537 paintController().commitNewDisplayItems();
538 538
539 drawRect(context, client, type2, FloatRect(100, 100, 50, 200)); 539 drawRect(context, client, type2, FloatRect(100, 100, 50, 200));
540 drawRect(context, client, type3, FloatRect(100, 100, 50, 200)); 540 drawRect(context, client, type3, FloatRect(100, 100, 50, 200));
541 drawRect(context, client, type1, FloatRect(100, 100, 100, 100)); 541 drawRect(context, client, type1, FloatRect(100, 100, 100, 100));
542 drawRect(context, client, type4, FloatRect(100, 100, 100, 100)); 542 drawRect(context, client, type4, FloatRect(100, 100, 100, 100));
543 543
544 displayItemList().commitNewDisplayItems(); 544 paintController().commitNewDisplayItems();
545 } 545 }
546 546
547 TEST_F(DisplayItemListTest, CachedNestedSubsequenceUpdate) 547 TEST_F(PaintControllerTest, CachedNestedSubsequenceUpdate)
548 { 548 {
549 RuntimeEnabledFeatures::setSlimmingPaintSubsequenceCachingEnabled(true); 549 RuntimeEnabledFeatures::setSlimmingPaintSubsequenceCachingEnabled(true);
550 550
551 TestDisplayItemClient container1("container1"); 551 TestDisplayItemClient container1("container1");
552 TestDisplayItemClient content1("content1"); 552 TestDisplayItemClient content1("content1");
553 TestDisplayItemClient container2("container2"); 553 TestDisplayItemClient container2("container2");
554 TestDisplayItemClient content2("content2"); 554 TestDisplayItemClient content2("content2");
555 GraphicsContext context(&displayItemList()); 555 GraphicsContext context(&paintController());
556 556
557 { 557 {
558 SubsequenceRecorder r(context, container1, subsequenceType); 558 SubsequenceRecorder r(context, container1, subsequenceType);
559 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100)); 559 drawRect(context, container1, backgroundDrawingType, FloatRect(100, 100, 100, 100));
560 { 560 {
561 SubsequenceRecorder r(context, content1, subsequenceType); 561 SubsequenceRecorder r(context, content1, subsequenceType);
562 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200)); 562 drawRect(context, content1, backgroundDrawingType, FloatRect(100, 10 0, 50, 200));
563 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200)); 563 drawRect(context, content1, foregroundDrawingType, FloatRect(100, 10 0, 50, 200));
564 } 564 }
565 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); 565 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100));
566 } 566 }
567 { 567 {
568 SubsequenceRecorder r(context, container2, subsequenceType); 568 SubsequenceRecorder r(context, container2, subsequenceType);
569 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100)); 569 drawRect(context, container2, backgroundDrawingType, FloatRect(100, 200, 100, 100));
570 { 570 {
571 SubsequenceRecorder r(context, content2, subsequenceType); 571 SubsequenceRecorder r(context, content2, subsequenceType);
572 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 20 0, 50, 200)); 572 drawRect(context, content2, backgroundDrawingType, FloatRect(100, 20 0, 50, 200));
573 } 573 }
574 } 574 }
575 displayItemList().commitNewDisplayItems(); 575 paintController().commitNewDisplayItems();
576 576
577 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 14, 577 EXPECT_DISPLAY_LIST(paintController().displayItems(), 14,
578 TestDisplayItem(container1, subsequenceType), 578 TestDisplayItem(container1, subsequenceType),
579 TestDisplayItem(container1, backgroundDrawingType), 579 TestDisplayItem(container1, backgroundDrawingType),
580 TestDisplayItem(content1, subsequenceType), 580 TestDisplayItem(content1, subsequenceType),
581 TestDisplayItem(content1, backgroundDrawingType), 581 TestDisplayItem(content1, backgroundDrawingType),
582 TestDisplayItem(content1, foregroundDrawingType), 582 TestDisplayItem(content1, foregroundDrawingType),
583 TestDisplayItem(content1, endSubsequenceType), 583 TestDisplayItem(content1, endSubsequenceType),
584 TestDisplayItem(container1, foregroundDrawingType), 584 TestDisplayItem(container1, foregroundDrawingType),
585 TestDisplayItem(container1, endSubsequenceType), 585 TestDisplayItem(container1, endSubsequenceType),
586 586
587 TestDisplayItem(container2, subsequenceType), 587 TestDisplayItem(container2, subsequenceType),
588 TestDisplayItem(container2, backgroundDrawingType), 588 TestDisplayItem(container2, backgroundDrawingType),
589 TestDisplayItem(content2, subsequenceType), 589 TestDisplayItem(content2, subsequenceType),
590 TestDisplayItem(content2, backgroundDrawingType), 590 TestDisplayItem(content2, backgroundDrawingType),
591 TestDisplayItem(content2, endSubsequenceType), 591 TestDisplayItem(content2, endSubsequenceType),
592 TestDisplayItem(container2, endSubsequenceType)); 592 TestDisplayItem(container2, endSubsequenceType));
593 593
594 // Invalidate container1 but not content1. 594 // Invalidate container1 but not content1.
595 displayItemList().invalidate(container1, PaintInvalidationFull, IntRect(), I ntRect()); 595 paintController().invalidate(container1, PaintInvalidationFull, IntRect(), I ntRect());
596 596
597 // Container2 itself now becomes empty (but still has the 'content2' child), 597 // Container2 itself now becomes empty (but still has the 'content2' child),
598 // and chooses not to output subsequence info. 598 // and chooses not to output subsequence info.
599 599
600 displayItemList().invalidate(container2, PaintInvalidationFull, IntRect(), I ntRect()); 600 paintController().invalidate(container2, PaintInvalidationFull, IntRect(), I ntRect());
601 displayItemList().invalidate(content2, PaintInvalidationFull, IntRect(), Int Rect()); 601 paintController().invalidate(content2, PaintInvalidationFull, IntRect(), Int Rect());
602 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co ntainer2, subsequenceType)); 602 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co ntainer2, subsequenceType));
603 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co ntent2, subsequenceType)); 603 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, co ntent2, subsequenceType));
604 // Content2 now outputs foreground only. 604 // Content2 now outputs foreground only.
605 { 605 {
606 SubsequenceRecorder r(context, content2, subsequenceType); 606 SubsequenceRecorder r(context, content2, subsequenceType);
607 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200)); 607 drawRect(context, content2, foregroundDrawingType, FloatRect(100, 200, 5 0, 200));
608 } 608 }
609 // Repaint container1 with foreground only. 609 // Repaint container1 with foreground only.
610 { 610 {
611 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1, subsequenceType)); 611 EXPECT_FALSE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context , container1, subsequenceType));
612 SubsequenceRecorder r(context, container1, subsequenceType); 612 SubsequenceRecorder r(context, container1, subsequenceType);
613 // Use cached subsequence of content1. 613 // Use cached subsequence of content1.
614 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, content1, subsequenceType)); 614 EXPECT_TRUE(SubsequenceRecorder::useCachedSubsequenceIfPossible(context, content1, subsequenceType));
615 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100)); 615 drawRect(context, container1, foregroundDrawingType, FloatRect(100, 100, 100, 100));
616 } 616 }
617 EXPECT_DISPLAY_LIST(displayItemList().newDisplayItems(), 7, 617 EXPECT_DISPLAY_LIST(paintController().newDisplayItems(), 7,
618 TestDisplayItem(content2, subsequenceType), 618 TestDisplayItem(content2, subsequenceType),
619 TestDisplayItem(content2, foregroundDrawingType), 619 TestDisplayItem(content2, foregroundDrawingType),
620 TestDisplayItem(content2, endSubsequenceType), 620 TestDisplayItem(content2, endSubsequenceType),
621 TestDisplayItem(container1, subsequenceType), 621 TestDisplayItem(container1, subsequenceType),
622 TestDisplayItem(content1, cachedSubsequenceType), 622 TestDisplayItem(content1, cachedSubsequenceType),
623 TestDisplayItem(container1, foregroundDrawingType), 623 TestDisplayItem(container1, foregroundDrawingType),
624 TestDisplayItem(container1, endSubsequenceType)); 624 TestDisplayItem(container1, endSubsequenceType));
625 625
626 displayItemList().commitNewDisplayItems(); 626 paintController().commitNewDisplayItems();
627 627
628 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 10, 628 EXPECT_DISPLAY_LIST(paintController().displayItems(), 10,
629 TestDisplayItem(content2, subsequenceType), 629 TestDisplayItem(content2, subsequenceType),
630 TestDisplayItem(content2, foregroundDrawingType), 630 TestDisplayItem(content2, foregroundDrawingType),
631 TestDisplayItem(content2, endSubsequenceType), 631 TestDisplayItem(content2, endSubsequenceType),
632 632
633 TestDisplayItem(container1, subsequenceType), 633 TestDisplayItem(container1, subsequenceType),
634 TestDisplayItem(content1, subsequenceType), 634 TestDisplayItem(content1, subsequenceType),
635 TestDisplayItem(content1, backgroundDrawingType), 635 TestDisplayItem(content1, backgroundDrawingType),
636 TestDisplayItem(content1, foregroundDrawingType), 636 TestDisplayItem(content1, foregroundDrawingType),
637 TestDisplayItem(content1, endSubsequenceType), 637 TestDisplayItem(content1, endSubsequenceType),
638 TestDisplayItem(container1, foregroundDrawingType), 638 TestDisplayItem(container1, foregroundDrawingType),
639 TestDisplayItem(container1, endSubsequenceType)); 639 TestDisplayItem(container1, endSubsequenceType));
640 } 640 }
641 641
642 TEST_F(DisplayItemListTest, Scope) 642 TEST_F(PaintControllerTest, Scope)
643 { 643 {
644 TestDisplayItemClient multicol("multicol"); 644 TestDisplayItemClient multicol("multicol");
645 TestDisplayItemClient content("content"); 645 TestDisplayItemClient content("content");
646 GraphicsContext context(&displayItemList()); 646 GraphicsContext context(&paintController());
647 647
648 FloatRect rect1(100, 100, 50, 50); 648 FloatRect rect1(100, 100, 50, 50);
649 FloatRect rect2(150, 100, 50, 50); 649 FloatRect rect2(150, 100, 50, 50);
650 FloatRect rect3(200, 100, 50, 50); 650 FloatRect rect3(200, 100, 50, 50);
651 651
652 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); 652 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100));
653 653
654 displayItemList().beginScope(); 654 paintController().beginScope();
655 drawRect(context, content, foregroundDrawingType, rect1); 655 drawRect(context, content, foregroundDrawingType, rect1);
656 displayItemList().endScope(); 656 paintController().endScope();
657 657
658 displayItemList().beginScope(); 658 paintController().beginScope();
659 drawRect(context, content, foregroundDrawingType, rect2); 659 drawRect(context, content, foregroundDrawingType, rect2);
660 displayItemList().endScope(); 660 paintController().endScope();
661 displayItemList().commitNewDisplayItems(); 661 paintController().commitNewDisplayItems();
662 662
663 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 3, 663 EXPECT_DISPLAY_LIST(paintController().displayItems(), 3,
664 TestDisplayItem(multicol, backgroundDrawingType), 664 TestDisplayItem(multicol, backgroundDrawingType),
665 TestDisplayItem(content, foregroundDrawingType), 665 TestDisplayItem(content, foregroundDrawingType),
666 TestDisplayItem(content, foregroundDrawingType)); 666 TestDisplayItem(content, foregroundDrawingType));
667 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(di splayItemList().displayItems()[1]).picture(); 667 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(pa intController().displayItems()[1]).picture();
668 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(di splayItemList().displayItems()[2]).picture(); 668 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(pa intController().displayItems()[2]).picture();
669 EXPECT_NE(picture1, picture2); 669 EXPECT_NE(picture1, picture2);
670 670
671 // Draw again with nothing invalidated. 671 // Draw again with nothing invalidated.
672 EXPECT_TRUE(displayItemList().clientCacheIsValid(multicol.displayItemClient( ))); 672 EXPECT_TRUE(paintController().clientCacheIsValid(multicol.displayItemClient( )));
673 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); 673 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100));
674 displayItemList().beginScope(); 674 paintController().beginScope();
675 drawRect(context, content, foregroundDrawingType, rect1); 675 drawRect(context, content, foregroundDrawingType, rect1);
676 displayItemList().endScope(); 676 paintController().endScope();
677 677
678 displayItemList().beginScope(); 678 paintController().beginScope();
679 drawRect(context, content, foregroundDrawingType, rect2); 679 drawRect(context, content, foregroundDrawingType, rect2);
680 displayItemList().endScope(); 680 paintController().endScope();
681 681
682 EXPECT_DISPLAY_LIST(displayItemList().newDisplayItems(), 3, 682 EXPECT_DISPLAY_LIST(paintController().newDisplayItems(), 3,
683 TestDisplayItem(multicol, DisplayItem::drawingTypeToCachedDrawingType(ba ckgroundDrawingType)), 683 TestDisplayItem(multicol, DisplayItem::drawingTypeToCachedDrawingType(ba ckgroundDrawingType)),
684 TestDisplayItem(content, foregroundDrawingType), 684 TestDisplayItem(content, foregroundDrawingType),
685 TestDisplayItem(content, foregroundDrawingType)); 685 TestDisplayItem(content, foregroundDrawingType));
686 686
687 displayItemList().commitNewDisplayItems(); 687 paintController().commitNewDisplayItems();
688 688
689 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 3, 689 EXPECT_DISPLAY_LIST(paintController().displayItems(), 3,
690 TestDisplayItem(multicol, backgroundDrawingType), 690 TestDisplayItem(multicol, backgroundDrawingType),
691 TestDisplayItem(content, foregroundDrawingType), 691 TestDisplayItem(content, foregroundDrawingType),
692 TestDisplayItem(content, foregroundDrawingType)); 692 TestDisplayItem(content, foregroundDrawingType));
693 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(displayItemList() .displayItems()[1]).picture()); 693 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(paintController() .displayItems()[1]).picture());
694 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(displayItemList() .displayItems()[2]).picture()); 694 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(paintController() .displayItems()[2]).picture());
695 695
696 // Now the multicol becomes 3 columns and repaints. 696 // Now the multicol becomes 3 columns and repaints.
697 displayItemList().invalidate(multicol, PaintInvalidationFull, IntRect(), Int Rect()); 697 paintController().invalidate(multicol, PaintInvalidationFull, IntRect(), Int Rect());
698 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100, 100)); 698 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100, 100));
699 699
700 displayItemList().beginScope(); 700 paintController().beginScope();
701 drawRect(context, content, foregroundDrawingType, rect1); 701 drawRect(context, content, foregroundDrawingType, rect1);
702 displayItemList().endScope(); 702 paintController().endScope();
703 703
704 displayItemList().beginScope(); 704 paintController().beginScope();
705 drawRect(context, content, foregroundDrawingType, rect2); 705 drawRect(context, content, foregroundDrawingType, rect2);
706 displayItemList().endScope(); 706 paintController().endScope();
707 707
708 displayItemList().beginScope(); 708 paintController().beginScope();
709 drawRect(context, content, foregroundDrawingType, rect3); 709 drawRect(context, content, foregroundDrawingType, rect3);
710 displayItemList().endScope(); 710 paintController().endScope();
711 711
712 // We should repaint everything on invalidation of the scope container. 712 // We should repaint everything on invalidation of the scope container.
713 EXPECT_DISPLAY_LIST(displayItemList().newDisplayItems(), 4, 713 EXPECT_DISPLAY_LIST(paintController().newDisplayItems(), 4,
714 TestDisplayItem(multicol, backgroundDrawingType), 714 TestDisplayItem(multicol, backgroundDrawingType),
715 TestDisplayItem(content, foregroundDrawingType), 715 TestDisplayItem(content, foregroundDrawingType),
716 TestDisplayItem(content, foregroundDrawingType), 716 TestDisplayItem(content, foregroundDrawingType),
717 TestDisplayItem(content, foregroundDrawingType)); 717 TestDisplayItem(content, foregroundDrawingType));
718 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(displayItemList() .newDisplayItems()[1]).picture()); 718 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(paintController() .newDisplayItems()[1]).picture());
719 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(displayItemList() .newDisplayItems()[2]).picture()); 719 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(paintController() .newDisplayItems()[2]).picture());
720 720
721 displayItemList().commitNewDisplayItems(); 721 paintController().commitNewDisplayItems();
722 } 722 }
723 723
724 TEST_F(DisplayItemListTest, OptimizeNoopPairs) 724 TEST_F(PaintControllerTest, OptimizeNoopPairs)
725 { 725 {
726 TestDisplayItemClient first("first"); 726 TestDisplayItemClient first("first");
727 TestDisplayItemClient second("second"); 727 TestDisplayItemClient second("second");
728 TestDisplayItemClient third("third"); 728 TestDisplayItemClient third("third");
729 729
730 GraphicsContext context(&displayItemList()); 730 GraphicsContext context(&paintController());
731 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 731 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100));
732 { 732 {
733 ClipPathRecorder clipRecorder(context, second, Path()); 733 ClipPathRecorder clipRecorder(context, second, Path());
734 drawRect(context, second, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); 734 drawRect(context, second, backgroundDrawingType, FloatRect(0, 0, 100, 10 0));
735 } 735 }
736 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 736 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100));
737 737
738 displayItemList().commitNewDisplayItems(); 738 paintController().commitNewDisplayItems();
739 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 5, 739 EXPECT_DISPLAY_LIST(paintController().displayItems(), 5,
740 TestDisplayItem(first, backgroundDrawingType), 740 TestDisplayItem(first, backgroundDrawingType),
741 TestDisplayItem(second, DisplayItem::BeginClipPath), 741 TestDisplayItem(second, DisplayItem::BeginClipPath),
742 TestDisplayItem(second, backgroundDrawingType), 742 TestDisplayItem(second, backgroundDrawingType),
743 TestDisplayItem(second, DisplayItem::EndClipPath), 743 TestDisplayItem(second, DisplayItem::EndClipPath),
744 TestDisplayItem(third, backgroundDrawingType)); 744 TestDisplayItem(third, backgroundDrawingType));
745 745
746 displayItemList().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct()); 746 paintController().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct());
747 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 747 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100));
748 { 748 {
749 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2, 2)); 749 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2, 2));
750 // Do not draw anything for second. 750 // Do not draw anything for second.
751 } 751 }
752 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 752 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100));
753 displayItemList().commitNewDisplayItems(); 753 paintController().commitNewDisplayItems();
754 754
755 // Empty clips should have been optimized out. 755 // Empty clips should have been optimized out.
756 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 756 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
757 TestDisplayItem(first, backgroundDrawingType), 757 TestDisplayItem(first, backgroundDrawingType),
758 TestDisplayItem(third, backgroundDrawingType)); 758 TestDisplayItem(third, backgroundDrawingType));
759 759
760 displayItemList().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct()); 760 paintController().invalidate(second, PaintInvalidationFull, IntRect(), IntRe ct());
761 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 761 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100));
762 { 762 {
763 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2, 2)); 763 ClipRecorder clipRecorder(context, second, clipType, LayoutRect(1, 1, 2, 2));
764 { 764 {
765 ClipPathRecorder clipPathRecorder(context, second, Path()); 765 ClipPathRecorder clipPathRecorder(context, second, Path());
766 // Do not draw anything for second. 766 // Do not draw anything for second.
767 } 767 }
768 } 768 }
769 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 769 drawRect(context, third, backgroundDrawingType, FloatRect(0, 0, 100, 100));
770 displayItemList().commitNewDisplayItems(); 770 paintController().commitNewDisplayItems();
771 771
772 // Empty clips should have been optimized out. 772 // Empty clips should have been optimized out.
773 EXPECT_DISPLAY_LIST(displayItemList().displayItems(), 2, 773 EXPECT_DISPLAY_LIST(paintController().displayItems(), 2,
774 TestDisplayItem(first, backgroundDrawingType), 774 TestDisplayItem(first, backgroundDrawingType),
775 TestDisplayItem(third, backgroundDrawingType)); 775 TestDisplayItem(third, backgroundDrawingType));
776 } 776 }
777 777
778 TEST_F(DisplayItemListTest, SmallDisplayItemListHasOnePaintChunk) 778 TEST_F(PaintControllerTest, SmallPaintControllerHasOnePaintChunk)
779 { 779 {
780 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 780 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
781 TestDisplayItemClient client("test client"); 781 TestDisplayItemClient client("test client");
782 782
783 GraphicsContext context(&displayItemList()); 783 GraphicsContext context(&paintController());
784 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100)); 784 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 100));
785 785
786 displayItemList().commitNewDisplayItems(); 786 paintController().commitNewDisplayItems();
787 const auto& paintChunks = displayItemList().paintChunks(); 787 const auto& paintChunks = paintController().paintChunks();
788 ASSERT_EQ(1u, paintChunks.size()); 788 ASSERT_EQ(1u, paintChunks.size());
789 EXPECT_EQ(0u, paintChunks[0].beginIndex); 789 EXPECT_EQ(0u, paintChunks[0].beginIndex);
790 EXPECT_EQ(1u, paintChunks[0].endIndex); 790 EXPECT_EQ(1u, paintChunks[0].endIndex);
791 } 791 }
792 792
793 } // namespace blink 793 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698