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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerPainterTest.cpp

Issue 2498763002: Allow subsequence caching for SVG roots that have PaintLayers. (Closed)
Patch Set: none Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "core/layout/LayoutBoxModelObject.h" 5 #include "core/layout/LayoutBoxModelObject.h"
6 #include "core/layout/compositing/CompositedLayerMapping.h" 6 #include "core/layout/compositing/CompositedLayerMapping.h"
7 #include "core/paint/PaintControllerPaintTest.h" 7 #include "core/paint/PaintControllerPaintTest.h"
8 #include "platform/graphics/GraphicsContext.h" 8 #include "platform/graphics/GraphicsContext.h"
9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
10 10
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 TestDisplayItem(content1, backgroundType), 154 TestDisplayItem(content1, backgroundType),
155 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence), 155 TestDisplayItem(container1Layer, DisplayItem::kEndSubsequence),
156 TestDisplayItem(container2Layer, DisplayItem::kSubsequence), 156 TestDisplayItem(container2Layer, DisplayItem::kSubsequence),
157 TestDisplayItem(container2, backgroundType), 157 TestDisplayItem(container2, backgroundType),
158 TestDisplayItem(content2, backgroundType), 158 TestDisplayItem(content2, backgroundType),
159 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence), 159 TestDisplayItem(container2Layer, DisplayItem::kEndSubsequence),
160 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence)); 160 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence));
161 } 161 }
162 } 162 }
163 163
164 TEST_P(PaintLayerPainterTest, CachedSubsequenceForSVGRoot) {
165 setBodyInnerHTML(
166 "<svg id='svg' style='position: relative'>"
167 " <rect id='rect' x='10' y='10' width='100' height='100' rx='15' "
168 "ry='15'/>"
169 "</svg>"
170 "<div id='div' style='position: relative; width: 50x; height: "
171 "50px'></div>");
172 document().view()->updateAllLifecyclePhases();
173
174 PaintLayer& htmlLayer =
175 *toLayoutBoxModelObject(document().documentElement()->layoutObject())
176 ->layer();
177 LayoutObject& svg = *document().getElementById("svg")->layoutObject();
178 PaintLayer& svgLayer = *toLayoutBoxModelObject(svg).layer();
179 LayoutObject& rect = *document().getElementById("rect")->layoutObject();
180 LayoutObject& div = *document().getElementById("div")->layoutObject();
181
182 DisplayItem::Type clipBoxBegin =
183 DisplayItem::paintPhaseToClipBoxType(PaintPhaseForeground);
184 DisplayItem::Type clipBoxEnd =
185 DisplayItem::clipTypeToEndClipType(clipBoxBegin);
186
187 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
188 // SPv2 slips the clip box (see BoxClipper).
189 EXPECT_DISPLAY_LIST(
190 rootPaintController().getDisplayItemList(), 12,
191 TestDisplayItem(layoutView(),
192 DisplayItem::kClipFrameToVisibleContentRect),
193 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
194 TestDisplayItem(layoutView(), documentBackgroundType),
195 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence),
196 TestDisplayItem(svgLayer, DisplayItem::kSubsequence),
197 TestDisplayItem(svg, DisplayItem::kBeginTransform),
198 TestDisplayItem(rect, foregroundType),
199 TestDisplayItem(svg, DisplayItem::kEndTransform),
200 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence),
201 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence),
202 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence),
203 TestDisplayItem(layoutView(),
204 DisplayItem::clipTypeToEndClipType(
205 DisplayItem::kClipFrameToVisibleContentRect)));
206 } else {
207 EXPECT_DISPLAY_LIST(
208 rootPaintController().getDisplayItemList(), 10,
209 TestDisplayItem(layoutView(), documentBackgroundType),
210 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence),
211 TestDisplayItem(svgLayer, DisplayItem::kSubsequence),
212 TestDisplayItem(svg, clipBoxBegin),
213 TestDisplayItem(svg, DisplayItem::kBeginTransform),
214 TestDisplayItem(rect, foregroundType),
215 TestDisplayItem(svg, DisplayItem::kEndTransform),
216 TestDisplayItem(svg, clipBoxEnd),
217 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence),
218 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence));
219 }
220
221 // Change the color of the div. This should not invalidate the subsequence
222 // for the SVG root.
223 toHTMLElement(div.node())
224 ->setAttribute(HTMLNames::styleAttr,
225 "position: relative; width: 50x; height: 50px; "
226 "background-color: green");
227 document().view()->updateAllLifecyclePhasesExceptPaint();
228 EXPECT_TRUE(paintWithoutCommit());
229
230 // Reuse of SVG and document background. 2 fewer with SPv2 enabled because
231 // clip display items don't appear in SPv2 display lists.
232 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
233 EXPECT_EQ(6, numCachedNewItems());
234 else
235 EXPECT_EQ(8, numCachedNewItems());
236
237 commit();
238
239 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
240 EXPECT_DISPLAY_LIST(
241 rootPaintController().getDisplayItemList(), 13,
242 TestDisplayItem(layoutView(),
243 DisplayItem::kClipFrameToVisibleContentRect),
244 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
245 TestDisplayItem(layoutView(), documentBackgroundType),
246 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence),
247 TestDisplayItem(svgLayer, DisplayItem::kSubsequence),
248 TestDisplayItem(svg, DisplayItem::kBeginTransform),
249 TestDisplayItem(rect, foregroundType),
250 TestDisplayItem(svg, DisplayItem::kEndTransform),
251 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence),
252 TestDisplayItem(div, backgroundType),
253 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence),
254 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence),
255 TestDisplayItem(layoutView(),
256 DisplayItem::clipTypeToEndClipType(
257 DisplayItem::kClipFrameToVisibleContentRect)));
258 } else {
259 EXPECT_DISPLAY_LIST(
260 rootPaintController().getDisplayItemList(), 11,
261 TestDisplayItem(layoutView(), documentBackgroundType),
262 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence),
263 TestDisplayItem(svgLayer, DisplayItem::kSubsequence),
264 TestDisplayItem(svg, clipBoxBegin),
265 TestDisplayItem(svg, DisplayItem::kBeginTransform),
266 TestDisplayItem(rect, foregroundType),
267 TestDisplayItem(svg, DisplayItem::kEndTransform),
268 TestDisplayItem(svg, clipBoxEnd),
269 TestDisplayItem(svgLayer, DisplayItem::kEndSubsequence),
270 TestDisplayItem(div, backgroundType),
271 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence),
272 TestDisplayItem(layoutView(),
273 DisplayItem::clipTypeToEndClipType(
274 DisplayItem::kClipFrameToVisibleContentRect)));
275 }
276 }
277
164 TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange) { 278 TEST_P(PaintLayerPainterTest, CachedSubsequenceOnInterestRectChange) {
165 // TODO(wangxianzhu): SPv2 deals with interest rect differently, so disable 279 // TODO(wangxianzhu): SPv2 deals with interest rect differently, so disable
166 // this test for SPv2 temporarily. 280 // this test for SPv2 temporarily.
167 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 281 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
168 return; 282 return;
169 283
170 setBodyInnerHTML( 284 setBodyInnerHTML(
171 "<div id='container1' style='position: relative; z-index: 1; width: " 285 "<div id='container1' style='position: relative; z-index: 1; width: "
172 "200px; height: 200px; background-color: blue'>" 286 "200px; height: 200px; background-color: blue'>"
173 " <div id='content1' style='position: absolute; width: 100px; height: " 287 " <div id='content1' style='position: absolute; width: 100px; height: "
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 EXPECT_FALSE(layer.needsPaintPhaseDescendantBlockBackgrounds()); 894 EXPECT_FALSE(layer.needsPaintPhaseDescendantBlockBackgrounds());
781 895
782 toHTMLElement(table.node()) 896 toHTMLElement(table.node())
783 ->setAttribute(HTMLNames::styleAttr, 897 ->setAttribute(HTMLNames::styleAttr,
784 "position: relative; border-collapse: collapse"); 898 "position: relative; border-collapse: collapse");
785 document().view()->updateAllLifecyclePhases(); 899 document().view()->updateAllLifecyclePhases();
786 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds()); 900 EXPECT_TRUE(layer.needsPaintPhaseDescendantBlockBackgrounds());
787 } 901 }
788 902
789 } // namespace blink 903 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698