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

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

Issue 697543002: First implementation of the paint slimming update algorithm (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
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 19 matching lines...) Expand all
30 30
31 RenderingTest::SetUp(); 31 RenderingTest::SetUp();
32 32
33 m_renderView = document().view()->renderView(); 33 m_renderView = document().view()->renderView();
34 ASSERT_TRUE(m_renderView); 34 ASSERT_TRUE(m_renderView);
35 } 35 }
36 36
37 RenderView* m_renderView; 37 RenderView* m_renderView;
38 }; 38 };
39 39
40 void drawRect(GraphicsContext* context, RenderView* renderer, PaintPhase phase, const FloatRect& bound) 40 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound)
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* renderer, PaintPhase 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(renderer->compositor()->rootRenderLayer(), context , DisplayItem::ClipLayerForeground, clipRect); 51 ClipRecorder clipRecorder(renderView->compositor()->rootRenderLayer(), conte xt, DisplayItem::ClipLayerForeground, clipRect);
52 drawRect(context, renderer, 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());
62 62
63 // TODO(schenney): Check that the IDs are what we expect. 63 // TODO(schenney): Check that the IDs are what we expect.
64 } 64 }
65 65
66 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
67 {
68 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
69 RenderObject* first = document().body()->firstChild()->renderer();
70 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
71 GraphicsContext* context = new GraphicsContext(nullptr);
72
73 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300));
74 drawRect(context, second, PaintPhaseChildBlockBackground, FloatRect(100, 100 , 200, 200));
75 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
76
77 EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size());
78
79 renderView()->viewDisplayList().invalidate(second);
80 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300));
81 drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
82 EXPECT_EQ((size_t)2, renderView()->viewDisplayList().paintList().size());
66 } 83 }
84
85 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
86 {
87 setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaf fected'></div>");
88 RenderObject* first = document().body()->firstChild()->renderer();
89 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
90 RenderObject* unaffected = document().body()->firstChild()->nextSibling()->r enderer();
91 GraphicsContext* context = new GraphicsContext(nullptr);
92
93 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
94 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
95 drawRect(context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10));
96
97 const PaintList& firstList = renderView()->viewDisplayList().paintList();
98 EXPECT_EQ((size_t)3, firstList.size());
99 EXPECT_EQ(first, firstList[0]->renderer());
100 EXPECT_EQ(second, firstList[1]->renderer());
101 EXPECT_EQ(unaffected, firstList[2]->renderer());
102
103 renderView()->viewDisplayList().invalidate(second);
104 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
105 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
106
107 const PaintList& secondList = renderView()->viewDisplayList().paintList();
108 EXPECT_EQ((size_t)3, secondList.size());
109 EXPECT_EQ(second, secondList[0]->renderer());
110 EXPECT_EQ(first, secondList[1]->renderer());
111 EXPECT_EQ(unaffected, secondList[2]->renderer());
67 } 112 }
113
114 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
115 {
116 setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></d iv></div>");
117 RenderObject* first = document().body()->firstChild()->renderer();
118 RenderObject* second = document().body()->firstChild()->firstChild()->render er();
119 RenderObject* third = document().body()->firstChild()->firstChild()->firstCh ild()->renderer();
120 GraphicsContext* context = new GraphicsContext(nullptr);
121
122 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
123 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
124
125 const PaintList& firstList = renderView()->viewDisplayList().paintList();
126 EXPECT_EQ((size_t)2, firstList.size());
127 EXPECT_EQ(first, firstList[0]->renderer());
128 EXPECT_EQ(second, firstList[1]->renderer());
129
130 renderView()->viewDisplayList().invalidate(third);
131 drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
132 drawRect(context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200, 50));
133 drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
134
135 const PaintList& secondList = renderView()->viewDisplayList().paintList();
136 EXPECT_EQ((size_t)3, secondList.size());
137 EXPECT_EQ(first, secondList[0]->renderer());
138 EXPECT_EQ(third, secondList[1]->renderer());
139 EXPECT_EQ(second, secondList[2]->renderer());
140 }
141
142 }
143
144 }
OLDNEW
« Source/core/paint/ViewDisplayList.cpp ('K') | « Source/core/paint/ViewDisplayList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698