Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/layout/compositing/CompositedLayerMapping.h" | 7 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 8 #include "core/paint/PaintControllerPaintTest.h" | 8 #include "core/paint/PaintControllerPaintTest.h" |
| 9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class PaintLayerPainterTest | 13 class PaintLayerPainterTest |
| 14 : public PaintControllerPaintTest | 14 : public PaintControllerPaintTest |
| 15 , public testing::WithParamInterface<FrameSettingOverrideFunction> { | 15 , public testing::WithParamInterface<FrameSettingOverrideFunction> { |
| 16 WTF_MAKE_FAST_ALLOCATED(PaintLayerPainterTest); | 16 WTF_MAKE_FAST_ALLOCATED(PaintLayerPainterTest); |
| 17 public: | 17 public: |
| 18 FrameSettingOverrideFunction settingOverrider() const override { return GetP aram(); } | 18 FrameSettingOverrideFunction settingOverrider() const override { return GetP aram(); } |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 using PaintLayerPainterTestForSlimmingPaintV2 = PaintControllerPaintTestForSlimm ingPaintV2; | |
|
Xianzhu
2015/10/28 18:10:23
This test suite tests synchronized painting, cover
| |
| 22 | |
| 23 INSTANTIATE_TEST_CASE_P(All, PaintLayerPainterTest, ::testing::Values( | 21 INSTANTIATE_TEST_CASE_P(All, PaintLayerPainterTest, ::testing::Values( |
| 24 nullptr, | 22 nullptr, |
| 25 RootLayerScrollsFrameSettingOverride)); | 23 RootLayerScrollsFrameSettingOverride)); |
| 26 | 24 |
| 27 TEST_P(PaintLayerPainterTest, CachedSubsequence) | 25 TEST_P(PaintLayerPainterTest, CachedSubsequence) |
| 28 { | 26 { |
| 29 RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(true); | 27 RuntimeEnabledFeatures::setSlimmingPaintSynchronizedPaintingEnabled(true); |
| 30 | 28 |
| 31 setBodyInnerHTML( | 29 setBodyInnerHTML( |
| 32 "<div id='container1' style='position: relative; z-index: 1; width: 200p x; height: 200px; background-color: blue'>" | 30 "<div id='container1' style='position: relative; z-index: 1; width: 200p x; height: 200px; background-color: blue'>" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 TestDisplayItem(container1Layer, endSubsequenceType), | 216 TestDisplayItem(container1Layer, endSubsequenceType), |
| 219 TestDisplayItem(container2, backgroundType), | 217 TestDisplayItem(container2, backgroundType), |
| 220 TestDisplayItem(container2Layer, subsequenceType), | 218 TestDisplayItem(container2Layer, subsequenceType), |
| 221 TestDisplayItem(content2a, backgroundType), | 219 TestDisplayItem(content2a, backgroundType), |
| 222 TestDisplayItem(container2Layer, endSubsequenceType), | 220 TestDisplayItem(container2Layer, endSubsequenceType), |
| 223 TestDisplayItem(htmlLayer, endSubsequenceType), | 221 TestDisplayItem(htmlLayer, endSubsequenceType), |
| 224 TestDisplayItem(rootLayer, endSubsequenceType)); | 222 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 225 } | 223 } |
| 226 } | 224 } |
| 227 | 225 |
| 228 TEST_F(PaintLayerPainterTestForSlimmingPaintV2, CachedSubsequence) | |
| 229 { | |
| 230 setBodyInnerHTML( | |
| 231 "<div id='container1' style='position: relative; z-index: 1; width: 200p x; height: 200px; background-color: blue'>" | |
| 232 " <div id='content1' style='position: absolute; width: 100px; height: 1 00px; background-color: red'></div>" | |
| 233 "</div>" | |
| 234 "<div id='container2' style='position: relative; z-index: 1; width: 200p x; height: 200px; background-color: blue'>" | |
| 235 " <div id='content2' style='position: absolute; width: 100px; height: 1 00px; background-color: green'></div>" | |
| 236 "</div>"); | |
| 237 document().view()->updateAllLifecyclePhases(); | |
| 238 | |
| 239 PaintLayer& rootLayer = *layoutView().layer(); | |
| 240 PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement() ->layoutObject())->layer(); | |
| 241 LayoutObject& container1 = *document().getElementById("container1")->layoutO bject(); | |
| 242 PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer(); | |
| 243 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec t(); | |
| 244 LayoutObject& container2 = *document().getElementById("container2")->layoutO bject(); | |
| 245 PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer(); | |
| 246 LayoutObject& content2 = *document().getElementById("content2")->layoutObjec t(); | |
| 247 | |
| 248 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 13, | |
| 249 TestDisplayItem(layoutView(), backgroundType), | |
| 250 TestDisplayItem(rootLayer, subsequenceType), | |
| 251 TestDisplayItem(htmlLayer, subsequenceType), | |
| 252 TestDisplayItem(container1, backgroundType), | |
| 253 TestDisplayItem(container1Layer, subsequenceType), | |
| 254 TestDisplayItem(content1, backgroundType), | |
| 255 TestDisplayItem(container1Layer, endSubsequenceType), | |
| 256 TestDisplayItem(container2, backgroundType), | |
| 257 TestDisplayItem(container2Layer, subsequenceType), | |
| 258 TestDisplayItem(content2, backgroundType), | |
| 259 TestDisplayItem(container2Layer, endSubsequenceType), | |
| 260 TestDisplayItem(htmlLayer, endSubsequenceType), | |
| 261 TestDisplayItem(rootLayer, endSubsequenceType)); | |
| 262 | |
| 263 toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "position : absolute; width: 100px; height: 100px; background-color: green"); | |
| 264 updateLifecyclePhasesToPaintClean(); | |
| 265 | |
| 266 EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 11, | |
| 267 TestDisplayItem(layoutView(), cachedBackgroundType), | |
| 268 TestDisplayItem(rootLayer, subsequenceType), | |
| 269 TestDisplayItem(htmlLayer, subsequenceType), | |
| 270 TestDisplayItem(container1, cachedBackgroundType), | |
| 271 TestDisplayItem(container1Layer, subsequenceType), | |
| 272 TestDisplayItem(content1, backgroundType), | |
| 273 TestDisplayItem(container1Layer, endSubsequenceType), | |
| 274 TestDisplayItem(container2, cachedBackgroundType), | |
| 275 TestDisplayItem(container2Layer, cachedSubsequenceType), | |
| 276 TestDisplayItem(htmlLayer, endSubsequenceType), | |
| 277 TestDisplayItem(rootLayer, endSubsequenceType)); | |
| 278 | |
| 279 compositeForSlimmingPaintV2(); | |
| 280 | |
| 281 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 13, | |
| 282 TestDisplayItem(layoutView(), backgroundType), | |
| 283 TestDisplayItem(rootLayer, subsequenceType), | |
| 284 TestDisplayItem(htmlLayer, subsequenceType), | |
| 285 TestDisplayItem(container1, backgroundType), | |
| 286 TestDisplayItem(container1Layer, subsequenceType), | |
| 287 TestDisplayItem(content1, backgroundType), | |
| 288 TestDisplayItem(container1Layer, endSubsequenceType), | |
| 289 TestDisplayItem(container2, backgroundType), | |
| 290 TestDisplayItem(container2Layer, subsequenceType), | |
| 291 TestDisplayItem(content2, backgroundType), | |
| 292 TestDisplayItem(container2Layer, endSubsequenceType), | |
| 293 TestDisplayItem(htmlLayer, endSubsequenceType), | |
| 294 TestDisplayItem(rootLayer, endSubsequenceType)); | |
| 295 | |
| 296 // Repeated painting should just generate a CachedDisplayItemList item. | |
| 297 updateLifecyclePhasesToPaintClean(); | |
| 298 EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 1, | |
| 299 TestDisplayItem(*rootLayer.compositedLayerMapping(), DisplayItem::Cached DisplayItemList)); | |
| 300 | |
| 301 compositeForSlimmingPaintV2(); | |
| 302 | |
| 303 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 13, | |
| 304 TestDisplayItem(layoutView(), backgroundType), | |
| 305 TestDisplayItem(rootLayer, subsequenceType), | |
| 306 TestDisplayItem(htmlLayer, subsequenceType), | |
| 307 TestDisplayItem(container1, backgroundType), | |
| 308 TestDisplayItem(container1Layer, subsequenceType), | |
| 309 TestDisplayItem(content1, backgroundType), | |
| 310 TestDisplayItem(container1Layer, endSubsequenceType), | |
| 311 TestDisplayItem(container2, backgroundType), | |
| 312 TestDisplayItem(container2Layer, subsequenceType), | |
| 313 TestDisplayItem(content2, backgroundType), | |
| 314 TestDisplayItem(container2Layer, endSubsequenceType), | |
| 315 TestDisplayItem(htmlLayer, endSubsequenceType), | |
| 316 TestDisplayItem(rootLayer, endSubsequenceType)); | |
| 317 } | |
| 318 | |
| 319 TEST_F(PaintLayerPainterTestForSlimmingPaintV2, CachedSubsequenceOnInterestRectC hange) | |
| 320 { | |
| 321 setBodyInnerHTML( | |
| 322 "<div id='container1' style='position: relative; z-index: 1; width: 200p x; height: 200px; background-color: blue'>" | |
| 323 " <div id='content1' style='position: absolute; width: 100px; height: 1 00px; background-color: green'></div>" | |
| 324 "</div>" | |
| 325 "<div id='container2' style='position: relative; z-index: 1; width: 200p x; height: 200px; background-color: blue'>" | |
| 326 " <div id='content2a' style='position: absolute; width: 100px; height: 100px; background-color: green'></div>" | |
| 327 " <div id='content2b' style='position: absolute; top: 200px; width: 100 px; height: 100px; background-color: green'></div>" | |
| 328 "</div>" | |
| 329 "<div id='container3' style='position: absolute; z-index: 2; left: 300px ; top: 0; width: 200px; height: 200px; background-color: blue'>" | |
| 330 " <div id='content3' style='position: absolute; width: 200px; height: 2 00px; background-color: green'></div>" | |
| 331 "</div>"); | |
| 332 rootPaintController().invalidateAll(); | |
| 333 | |
| 334 PaintLayer& rootLayer = *layoutView().layer(); | |
| 335 PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement() ->layoutObject())->layer(); | |
| 336 LayoutObject& container1 = *document().getElementById("container1")->layoutO bject(); | |
| 337 PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer(); | |
| 338 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec t(); | |
| 339 LayoutObject& container2 = *document().getElementById("container2")->layoutO bject(); | |
| 340 PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer(); | |
| 341 LayoutObject& content2a = *document().getElementById("content2a")->layoutObj ect(); | |
| 342 LayoutObject& container3 = *document().getElementById("container3")->layoutO bject(); | |
| 343 PaintLayer& container3Layer = *toLayoutBoxModelObject(container3).layer(); | |
| 344 LayoutObject& content3 = *document().getElementById("content3")->layoutObjec t(); | |
| 345 | |
| 346 LayoutRect interestRect(0, 0, 400, 300); | |
| 347 document().view()->updateAllLifecyclePhases(&interestRect); | |
| 348 | |
| 349 // Container1 is fully in the interest rect; | |
| 350 // Container2 is partly (including its stacking chidren) in the interest rec t; | |
| 351 // Content2b is out of the interest rect and output nothing; | |
| 352 // Container3 is partly in the interest rect. | |
| 353 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 17, | |
| 354 TestDisplayItem(layoutView(), backgroundType), | |
| 355 TestDisplayItem(rootLayer, subsequenceType), | |
| 356 TestDisplayItem(htmlLayer, subsequenceType), | |
| 357 TestDisplayItem(container1, backgroundType), | |
| 358 TestDisplayItem(container1Layer, subsequenceType), | |
| 359 TestDisplayItem(content1, backgroundType), | |
| 360 TestDisplayItem(container1Layer, endSubsequenceType), | |
| 361 TestDisplayItem(container2, backgroundType), | |
| 362 TestDisplayItem(container2Layer, subsequenceType), | |
| 363 TestDisplayItem(content2a, backgroundType), | |
| 364 TestDisplayItem(container2Layer, endSubsequenceType), | |
| 365 TestDisplayItem(container3, backgroundType), | |
| 366 TestDisplayItem(container3Layer, subsequenceType), | |
| 367 TestDisplayItem(content3, backgroundType), | |
| 368 TestDisplayItem(container3Layer, endSubsequenceType), | |
| 369 TestDisplayItem(htmlLayer, endSubsequenceType), | |
| 370 TestDisplayItem(rootLayer, endSubsequenceType)); | |
| 371 | |
| 372 // Container1 becomes partly in the interest rect, but uses cached subsequen ce | |
| 373 // because it was fully painted before; | |
| 374 // Container2's intersection with the interest rect changes; | |
| 375 // Content2b is out of the interest rect and outputs nothing; | |
| 376 // Container3 becomes out of the interest rect and outputs nothing. | |
| 377 LayoutRect newInterestRect(0, 100, 300, 300); | |
| 378 updateLifecyclePhasesToPaintClean(&newInterestRect); | |
| 379 | |
| 380 EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 11, | |
| 381 TestDisplayItem(layoutView(), cachedBackgroundType), | |
| 382 TestDisplayItem(rootLayer, subsequenceType), | |
| 383 TestDisplayItem(htmlLayer, subsequenceType), | |
| 384 TestDisplayItem(container1, cachedBackgroundType), | |
| 385 TestDisplayItem(container1Layer, cachedSubsequenceType), | |
| 386 TestDisplayItem(container2, cachedBackgroundType), | |
| 387 TestDisplayItem(container2Layer, subsequenceType), | |
| 388 TestDisplayItem(content2a, cachedBackgroundType), | |
| 389 TestDisplayItem(container2Layer, endSubsequenceType), | |
| 390 TestDisplayItem(htmlLayer, endSubsequenceType), | |
| 391 TestDisplayItem(rootLayer, endSubsequenceType)); | |
| 392 | |
| 393 compositeForSlimmingPaintV2(); | |
| 394 | |
| 395 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 13, | |
| 396 TestDisplayItem(layoutView(), backgroundType), | |
| 397 TestDisplayItem(rootLayer, subsequenceType), | |
| 398 TestDisplayItem(htmlLayer, subsequenceType), | |
| 399 TestDisplayItem(container1, backgroundType), | |
| 400 TestDisplayItem(container1Layer, subsequenceType), | |
| 401 TestDisplayItem(content1, backgroundType), | |
| 402 TestDisplayItem(container1Layer, endSubsequenceType), | |
| 403 TestDisplayItem(container2, backgroundType), | |
| 404 TestDisplayItem(container2Layer, subsequenceType), | |
| 405 TestDisplayItem(content2a, backgroundType), | |
| 406 TestDisplayItem(container2Layer, endSubsequenceType), | |
| 407 TestDisplayItem(htmlLayer, endSubsequenceType), | |
| 408 TestDisplayItem(rootLayer, endSubsequenceType)); | |
| 409 } | |
| 410 | |
| 411 } // namespace blink | 226 } // namespace blink |
| OLD | NEW |