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

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

Issue 719353004: [Slimming Paint] Track clip renderers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address reviewer comments Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/ViewDisplayList.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ViewDisplayList.h" 6 #include "core/paint/ViewDisplayList.h"
7 7
8 #include "core/paint/ClipRecorder.h" 8 #include "core/paint/ClipRecorder.h"
9 #include "core/paint/DrawingRecorder.h" 9 #include "core/paint/DrawingRecorder.h"
10 #include "core/rendering/RenderView.h" 10 #include "core/rendering/RenderView.h"
(...skipping 30 matching lines...) Expand all
41 { 41 {
42 DrawingRecorder drawingRecorder(context, renderer, phase, bound); 42 DrawingRecorder drawingRecorder(context, renderer, phase, bound);
43 IntRect rect(0, 0, 10, 10); 43 IntRect rect(0, 0, 10, 10);
44 context->drawRect(rect); 44 context->drawRect(rect);
45 } 45 }
46 46
47 void drawClippedRect(GraphicsContext* context, RenderView* renderView, PaintPhas e phase, const FloatRect& bound) 47 void drawClippedRect(GraphicsContext* context, RenderView* renderView, PaintPhas e phase, const FloatRect& bound)
48 { 48 {
49 IntRect rect(1, 1, 9, 9); 49 IntRect rect(1, 1, 9, 9);
50 ClipRect clipRect(rect); 50 ClipRect clipRect(rect);
51 ClipRecorder clipRecorder(renderView->compositor()->rootRenderLayer(), conte xt, DisplayItem::ClipLayerForeground, clipRect); 51 ClipRecorder clipRecorder(renderView->compositor()->rootRenderLayer()->rende rer(), context, DisplayItem::ClipLayerForeground, clipRect);
52 drawRect(context, renderView, phase, bound); 52 drawRect(context, renderView, phase, bound);
53 } 53 }
54 54
55 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) 55 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
56 { 56 {
57 GraphicsContext* context = new GraphicsContext(nullptr); 57 GraphicsContext* context = new GraphicsContext(nullptr);
58 FloatRect bound = renderView()->viewRect(); 58 FloatRect bound = renderView()->viewRect();
59 59
60 drawClippedRect(context, renderView(), PaintPhaseForeground, bound); 60 drawClippedRect(context, renderView(), PaintPhaseForeground, bound);
61 EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size()); 61 EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 renderView()->viewDisplayList().invalidate(second); 328 renderView()->viewDisplayList().invalidate(second);
329 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 329 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
330 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); 330 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150));
331 331
332 const PaintList& thirdList = renderView()->viewDisplayList().paintList(); 332 const PaintList& thirdList = renderView()->viewDisplayList().paintList();
333 EXPECT_EQ((size_t)2, thirdList.size()); 333 EXPECT_EQ((size_t)2, thirdList.size());
334 EXPECT_EQ(first, thirdList[0]->renderer()); 334 EXPECT_EQ(first, thirdList[0]->renderer());
335 EXPECT_EQ(first, thirdList[1]->renderer()); 335 EXPECT_EQ(first, thirdList[1]->renderer());
336 } 336 }
337 337
338 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip)
339 {
340 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
341 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document(). body()->firstChild()->renderer());
342 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document() .body()->firstChild()->firstChild()->renderer());
343 GraphicsContext* context = new GraphicsContext(nullptr);
344
345 ClipRect firstClipRect(IntRect(1, 1, 2, 2));
346 {
347 ClipRecorder clipRecorder(firstRenderer, context, DisplayItem::ClipLayer Foreground, firstClipRect);
348 drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(10 0, 100, 150, 150));
349 drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(1 00, 100, 150, 150));
350 }
351
352 const PaintList& firstList = renderView()->viewDisplayList().paintList();
353 EXPECT_EQ((size_t)4, firstList.size());
chrishtr 2014/11/13 18:42:46 This is tedious and hard to read. Add some helper
354 EXPECT_EQ(DisplayItem::ClipLayerForeground, firstList[0]->type());
355 EXPECT_EQ(firstRenderer, firstList[1]->renderer());
356 EXPECT_EQ(DisplayItem::DrawingPaintPhaseBlockBackground, firstList[1]->type( ));
357 EXPECT_EQ(secondRenderer, firstList[2]->renderer());
358 EXPECT_EQ(DisplayItem::DrawingPaintPhaseBlockBackground, firstList[2]->type( ));
359 EXPECT_EQ(DisplayItem::EndClip, firstList[3]->type());
360
361 renderView()->viewDisplayList().invalidate(firstRenderer);
362 drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 1 00, 150, 150));
363 drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
364
365 const PaintList& secondList = renderView()->viewDisplayList().paintList();
366 EXPECT_EQ((size_t)2, secondList.size());
367 EXPECT_EQ(DisplayItem::DrawingPaintPhaseBlockBackground, secondList[0]->type ());
368 EXPECT_EQ(DisplayItem::DrawingPaintPhaseBlockBackground, secondList[1]->type ());
369
370 renderView()->viewDisplayList().invalidate(secondRenderer);
371 drawRect(context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 1 00, 150, 150));
372 ClipRect secondClipRect(IntRect(1, 1, 2, 2));
373 {
374 ClipRecorder clipRecorder(secondRenderer, context, DisplayItem::ClipLaye rForeground, secondClipRect);
375 drawRect(context, secondRenderer, PaintPhaseBlockBackground, FloatRect(1 00, 100, 150, 150));
376 }
377
378 const PaintList& thirdList = renderView()->viewDisplayList().paintList();
379 EXPECT_EQ((size_t)4, thirdList.size());
380 EXPECT_EQ(firstRenderer, thirdList[0]->renderer());
381 EXPECT_EQ(DisplayItem::DrawingPaintPhaseBlockBackground, thirdList[0]->type( ));
382 EXPECT_EQ(DisplayItem::ClipLayerForeground, thirdList[1]->type());
383 EXPECT_EQ(secondRenderer, thirdList[1]->renderer());
384 EXPECT_EQ(secondRenderer, thirdList[2]->renderer());
385 EXPECT_EQ(DisplayItem::DrawingPaintPhaseBlockBackground, thirdList[2]->type( ));
386 EXPECT_EQ(DisplayItem::EndClip, thirdList[3]->type());
387 }
388
338 } 389 }
339 390
340 } 391 }
OLDNEW
« no previous file with comments | « Source/core/paint/ViewDisplayList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698