| 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 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 bool rootLayerScrolls = document().frame()->settings()->rootLayerScrolls(); | 131 bool rootLayerScrolls = document().frame()->settings()->rootLayerScrolls(); |
| 132 PaintLayer& rootLayer = *layoutView().layer(); | 132 PaintLayer& rootLayer = *layoutView().layer(); |
| 133 PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()
->layoutObject())->layer(); | 133 PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()
->layoutObject())->layer(); |
| 134 LayoutObject& container1 = *document().getElementById("container1")->layoutO
bject(); | 134 LayoutObject& container1 = *document().getElementById("container1")->layoutO
bject(); |
| 135 PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer(); | 135 PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer(); |
| 136 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec
t(); | 136 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec
t(); |
| 137 LayoutObject& container2 = *document().getElementById("container2")->layoutO
bject(); | 137 LayoutObject& container2 = *document().getElementById("container2")->layoutO
bject(); |
| 138 PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer(); | 138 PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer(); |
| 139 LayoutObject& content2a = *document().getElementById("content2a")->layoutObj
ect(); | 139 LayoutObject& content2a = *document().getElementById("content2a")->layoutObj
ect(); |
| 140 LayoutObject& content2b = *document().getElementById("content2b")->layoutObj
ect(); |
| 140 LayoutObject& container3 = *document().getElementById("container3")->layoutO
bject(); | 141 LayoutObject& container3 = *document().getElementById("container3")->layoutO
bject(); |
| 141 PaintLayer& container3Layer = *toLayoutBoxModelObject(container3).layer(); | 142 PaintLayer& container3Layer = *toLayoutBoxModelObject(container3).layer(); |
| 142 LayoutObject& content3 = *document().getElementById("content3")->layoutObjec
t(); | 143 LayoutObject& content3 = *document().getElementById("content3")->layoutObjec
t(); |
| 143 | 144 |
| 144 LayoutRect interestRect(0, 0, 400, 300); | 145 IntRect interestRect(0, 0, 400, 300); |
| 145 document().view()->updateAllLifecyclePhases(&interestRect); | 146 document().view()->updateAllLifecyclePhases(&interestRect); |
| 146 | 147 |
| 147 // Container1 is fully in the interest rect; | 148 // Container1 is fully in the interest rect; |
| 148 // Container2 is partly (including its stacking chidren) in the interest rec
t; | 149 // Container2 is partly (including its stacking chidren) in the interest rec
t; |
| 149 // Content2b is out of the interest rect and output nothing; | 150 // Content2b is out of the interest rect and output nothing; |
| 150 // Container3 is partly in the interest rect. | 151 // Container3 is partly in the interest rect. |
| 151 if (rootLayerScrolls) { | 152 if (rootLayerScrolls) { |
| 152 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 15, | 153 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 15, |
| 153 TestDisplayItem(layoutView(), backgroundType), | 154 TestDisplayItem(layoutView(), backgroundType), |
| 154 TestDisplayItem(rootLayer, subsequenceType), | 155 TestDisplayItem(rootLayer, subsequenceType), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 179 TestDisplayItem(content2a, backgroundType), | 180 TestDisplayItem(content2a, backgroundType), |
| 180 TestDisplayItem(container2Layer, endSubsequenceType), | 181 TestDisplayItem(container2Layer, endSubsequenceType), |
| 181 TestDisplayItem(container3, backgroundType), | 182 TestDisplayItem(container3, backgroundType), |
| 182 TestDisplayItem(container3Layer, subsequenceType), | 183 TestDisplayItem(container3Layer, subsequenceType), |
| 183 TestDisplayItem(content3, backgroundType), | 184 TestDisplayItem(content3, backgroundType), |
| 184 TestDisplayItem(container3Layer, endSubsequenceType), | 185 TestDisplayItem(container3Layer, endSubsequenceType), |
| 185 TestDisplayItem(htmlLayer, endSubsequenceType), | 186 TestDisplayItem(htmlLayer, endSubsequenceType), |
| 186 TestDisplayItem(rootLayer, endSubsequenceType)); | 187 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 187 } | 188 } |
| 188 | 189 |
| 189 LayoutRect newInterestRect(0, 100, 300, 300); | 190 IntRect newInterestRect(0, 100, 300, 1000); |
| 190 document().view()->updateAllLifecyclePhases(&newInterestRect); | 191 document().view()->updateAllLifecyclePhases(&newInterestRect); |
| 191 | 192 |
| 192 // Container1 becomes partly in the interest rect, but uses cached subsequen
ce | 193 // Container1 becomes partly in the interest rect, but uses cached subsequen
ce |
| 193 // because it was fully painted before; | 194 // because it was fully painted before; |
| 194 // Container2's intersection with the interest rect changes; | 195 // Container2's intersection with the interest rect changes; |
| 195 // Content2b is out of the interest rect and outputs nothing; | 196 // Content2b is out of the interest rect and outputs nothing; |
| 196 // Container3 becomes out of the interest rect and outputs nothing. | 197 // Container3 becomes out of the interest rect and outputs nothing. |
| 197 if (rootLayerScrolls) { | 198 if (rootLayerScrolls) { |
| 198 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 11, | 199 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 12, |
| 199 TestDisplayItem(layoutView(), backgroundType), | 200 TestDisplayItem(layoutView(), backgroundType), |
| 200 TestDisplayItem(rootLayer, subsequenceType), | 201 TestDisplayItem(rootLayer, subsequenceType), |
| 201 TestDisplayItem(container1, backgroundType), | 202 TestDisplayItem(container1, backgroundType), |
| 202 TestDisplayItem(container1Layer, subsequenceType), | 203 TestDisplayItem(container1Layer, subsequenceType), |
| 203 TestDisplayItem(content1, backgroundType), | 204 TestDisplayItem(content1, backgroundType), |
| 204 TestDisplayItem(container1Layer, endSubsequenceType), | 205 TestDisplayItem(container1Layer, endSubsequenceType), |
| 205 TestDisplayItem(container2, backgroundType), | 206 TestDisplayItem(container2, backgroundType), |
| 206 TestDisplayItem(container2Layer, subsequenceType), | 207 TestDisplayItem(container2Layer, subsequenceType), |
| 207 TestDisplayItem(content2a, backgroundType), | 208 TestDisplayItem(content2a, backgroundType), |
| 209 TestDisplayItem(content2b, backgroundType), |
| 208 TestDisplayItem(container2Layer, endSubsequenceType), | 210 TestDisplayItem(container2Layer, endSubsequenceType), |
| 209 TestDisplayItem(rootLayer, endSubsequenceType)); | 211 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 210 } else { | 212 } else { |
| 211 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 13, | 213 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 14, |
| 212 TestDisplayItem(layoutView(), backgroundType), | 214 TestDisplayItem(layoutView(), backgroundType), |
| 213 TestDisplayItem(rootLayer, subsequenceType), | 215 TestDisplayItem(rootLayer, subsequenceType), |
| 214 TestDisplayItem(htmlLayer, subsequenceType), | 216 TestDisplayItem(htmlLayer, subsequenceType), |
| 215 TestDisplayItem(container1, backgroundType), | 217 TestDisplayItem(container1, backgroundType), |
| 216 TestDisplayItem(container1Layer, subsequenceType), | 218 TestDisplayItem(container1Layer, subsequenceType), |
| 217 TestDisplayItem(content1, backgroundType), | 219 TestDisplayItem(content1, backgroundType), |
| 218 TestDisplayItem(container1Layer, endSubsequenceType), | 220 TestDisplayItem(container1Layer, endSubsequenceType), |
| 219 TestDisplayItem(container2, backgroundType), | 221 TestDisplayItem(container2, backgroundType), |
| 220 TestDisplayItem(container2Layer, subsequenceType), | 222 TestDisplayItem(container2Layer, subsequenceType), |
| 221 TestDisplayItem(content2a, backgroundType), | 223 TestDisplayItem(content2a, backgroundType), |
| 224 TestDisplayItem(content2b, backgroundType), |
| 222 TestDisplayItem(container2Layer, endSubsequenceType), | 225 TestDisplayItem(container2Layer, endSubsequenceType), |
| 223 TestDisplayItem(htmlLayer, endSubsequenceType), | 226 TestDisplayItem(htmlLayer, endSubsequenceType), |
| 224 TestDisplayItem(rootLayer, endSubsequenceType)); | 227 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 225 } | 228 } |
| 226 } | 229 } |
| 227 | 230 |
| 228 TEST_F(PaintLayerPainterTestForSlimmingPaintV2, CachedSubsequence) | 231 TEST_F(PaintLayerPainterTestForSlimmingPaintV2, CachedSubsequence) |
| 229 { | 232 { |
| 230 setBodyInnerHTML( | 233 setBodyInnerHTML( |
| 231 "<div id='container1' style='position: relative; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" | 234 "<div id='container1' style='position: relative; z-index: 1; width: 200p
x; height: 200px; background-color: blue'>" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 TestDisplayItem(container1Layer, endSubsequenceType), | 291 TestDisplayItem(container1Layer, endSubsequenceType), |
| 289 TestDisplayItem(container2, backgroundType), | 292 TestDisplayItem(container2, backgroundType), |
| 290 TestDisplayItem(container2Layer, subsequenceType), | 293 TestDisplayItem(container2Layer, subsequenceType), |
| 291 TestDisplayItem(content2, backgroundType), | 294 TestDisplayItem(content2, backgroundType), |
| 292 TestDisplayItem(container2Layer, endSubsequenceType), | 295 TestDisplayItem(container2Layer, endSubsequenceType), |
| 293 TestDisplayItem(htmlLayer, endSubsequenceType), | 296 TestDisplayItem(htmlLayer, endSubsequenceType), |
| 294 TestDisplayItem(rootLayer, endSubsequenceType)); | 297 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 295 | 298 |
| 296 // Repeated painting should just generate a CachedDisplayItemList item. | 299 // Repeated painting should just generate a CachedDisplayItemList item. |
| 297 updateLifecyclePhasesToPaintClean(); | 300 updateLifecyclePhasesToPaintClean(); |
| 301 |
| 298 EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 1, | 302 EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 1, |
| 299 TestDisplayItem(*rootLayer.compositedLayerMapping(), DisplayItem::Cached
DisplayItemList)); | 303 TestDisplayItem(*rootLayer.compositedLayerMapping(), DisplayItem::Cached
DisplayItemList)); |
| 300 | 304 |
| 301 compositeForSlimmingPaintV2(); | 305 compositeForSlimmingPaintV2(); |
| 302 | 306 |
| 303 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 13, | 307 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 13, |
| 304 TestDisplayItem(layoutView(), backgroundType), | 308 TestDisplayItem(layoutView(), backgroundType), |
| 305 TestDisplayItem(rootLayer, subsequenceType), | 309 TestDisplayItem(rootLayer, subsequenceType), |
| 306 TestDisplayItem(htmlLayer, subsequenceType), | 310 TestDisplayItem(htmlLayer, subsequenceType), |
| 307 TestDisplayItem(container1, backgroundType), | 311 TestDisplayItem(container1, backgroundType), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 332 rootPaintController().invalidateAll(); | 336 rootPaintController().invalidateAll(); |
| 333 | 337 |
| 334 PaintLayer& rootLayer = *layoutView().layer(); | 338 PaintLayer& rootLayer = *layoutView().layer(); |
| 335 PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()
->layoutObject())->layer(); | 339 PaintLayer& htmlLayer = *toLayoutBoxModelObject(document().documentElement()
->layoutObject())->layer(); |
| 336 LayoutObject& container1 = *document().getElementById("container1")->layoutO
bject(); | 340 LayoutObject& container1 = *document().getElementById("container1")->layoutO
bject(); |
| 337 PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer(); | 341 PaintLayer& container1Layer = *toLayoutBoxModelObject(container1).layer(); |
| 338 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec
t(); | 342 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec
t(); |
| 339 LayoutObject& container2 = *document().getElementById("container2")->layoutO
bject(); | 343 LayoutObject& container2 = *document().getElementById("container2")->layoutO
bject(); |
| 340 PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer(); | 344 PaintLayer& container2Layer = *toLayoutBoxModelObject(container2).layer(); |
| 341 LayoutObject& content2a = *document().getElementById("content2a")->layoutObj
ect(); | 345 LayoutObject& content2a = *document().getElementById("content2a")->layoutObj
ect(); |
| 346 LayoutObject& content2b = *document().getElementById("content2b")->layoutObj
ect(); |
| 342 LayoutObject& container3 = *document().getElementById("container3")->layoutO
bject(); | 347 LayoutObject& container3 = *document().getElementById("container3")->layoutO
bject(); |
| 343 PaintLayer& container3Layer = *toLayoutBoxModelObject(container3).layer(); | 348 PaintLayer& container3Layer = *toLayoutBoxModelObject(container3).layer(); |
| 344 LayoutObject& content3 = *document().getElementById("content3")->layoutObjec
t(); | 349 LayoutObject& content3 = *document().getElementById("content3")->layoutObjec
t(); |
| 345 | 350 |
| 346 LayoutRect interestRect(0, 0, 400, 300); | 351 IntRect interestRect(0, 0, 400, 300); |
| 347 document().view()->updateAllLifecyclePhases(&interestRect); | 352 document().view()->updateAllLifecyclePhases(&interestRect); |
| 348 | 353 |
| 349 // Container1 is fully in the interest rect; | 354 // Container1 is fully in the interest rect; |
| 350 // Container2 is partly (including its stacking chidren) in the interest rec
t; | 355 // Container2 is partly (including its stacking chidren) in the interest rec
t; |
| 351 // Content2b is out of the interest rect and output nothing; | 356 // Content2b is out of the interest rect and output nothing; |
| 352 // Container3 is partly in the interest rect. | 357 // Container3 is partly in the interest rect. |
| 353 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 17, | 358 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 17, |
| 354 TestDisplayItem(layoutView(), backgroundType), | 359 TestDisplayItem(layoutView(), backgroundType), |
| 355 TestDisplayItem(rootLayer, subsequenceType), | 360 TestDisplayItem(rootLayer, subsequenceType), |
| 356 TestDisplayItem(htmlLayer, subsequenceType), | 361 TestDisplayItem(htmlLayer, subsequenceType), |
| 357 TestDisplayItem(container1, backgroundType), | 362 TestDisplayItem(container1, backgroundType), |
| 358 TestDisplayItem(container1Layer, subsequenceType), | 363 TestDisplayItem(container1Layer, subsequenceType), |
| 359 TestDisplayItem(content1, backgroundType), | 364 TestDisplayItem(content1, backgroundType), |
| 360 TestDisplayItem(container1Layer, endSubsequenceType), | 365 TestDisplayItem(container1Layer, endSubsequenceType), |
| 361 TestDisplayItem(container2, backgroundType), | 366 TestDisplayItem(container2, backgroundType), |
| 362 TestDisplayItem(container2Layer, subsequenceType), | 367 TestDisplayItem(container2Layer, subsequenceType), |
| 363 TestDisplayItem(content2a, backgroundType), | 368 TestDisplayItem(content2a, backgroundType), |
| 364 TestDisplayItem(container2Layer, endSubsequenceType), | 369 TestDisplayItem(container2Layer, endSubsequenceType), |
| 365 TestDisplayItem(container3, backgroundType), | 370 TestDisplayItem(container3, backgroundType), |
| 366 TestDisplayItem(container3Layer, subsequenceType), | 371 TestDisplayItem(container3Layer, subsequenceType), |
| 367 TestDisplayItem(content3, backgroundType), | 372 TestDisplayItem(content3, backgroundType), |
| 368 TestDisplayItem(container3Layer, endSubsequenceType), | 373 TestDisplayItem(container3Layer, endSubsequenceType), |
| 369 TestDisplayItem(htmlLayer, endSubsequenceType), | 374 TestDisplayItem(htmlLayer, endSubsequenceType), |
| 370 TestDisplayItem(rootLayer, endSubsequenceType)); | 375 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 371 | 376 |
| 372 // Container1 becomes partly in the interest rect, but uses cached subsequen
ce | 377 // Container1 becomes partly in the interest rect, but uses cached subsequen
ce |
| 373 // because it was fully painted before; | 378 // because it was fully painted before; |
| 374 // Container2's intersection with the interest rect changes; | 379 // Container2's intersection with the interest rect changes; |
| 375 // Content2b is out of the interest rect and outputs nothing; | 380 // Content2b is in the interest rect; |
| 376 // Container3 becomes out of the interest rect and outputs nothing. | 381 // Container3 becomes out of the interest rect and outputs nothing. |
| 377 LayoutRect newInterestRect(0, 100, 300, 300); | 382 IntRect newInterestRect(0, 100, 300, 1000); |
| 378 updateLifecyclePhasesToPaintClean(&newInterestRect); | 383 updateLifecyclePhasesToPaintClean(&newInterestRect); |
| 379 | 384 |
| 380 EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 11, | 385 EXPECT_DISPLAY_LIST(rootPaintController().newDisplayItemList(), 12, |
| 381 TestDisplayItem(layoutView(), cachedBackgroundType), | 386 TestDisplayItem(layoutView(), cachedBackgroundType), |
| 382 TestDisplayItem(rootLayer, subsequenceType), | 387 TestDisplayItem(rootLayer, subsequenceType), |
| 383 TestDisplayItem(htmlLayer, subsequenceType), | 388 TestDisplayItem(htmlLayer, subsequenceType), |
| 384 TestDisplayItem(container1, cachedBackgroundType), | 389 TestDisplayItem(container1, cachedBackgroundType), |
| 385 TestDisplayItem(container1Layer, cachedSubsequenceType), | 390 TestDisplayItem(container1Layer, cachedSubsequenceType), |
| 386 TestDisplayItem(container2, cachedBackgroundType), | 391 TestDisplayItem(container2, cachedBackgroundType), |
| 387 TestDisplayItem(container2Layer, subsequenceType), | 392 TestDisplayItem(container2Layer, subsequenceType), |
| 388 TestDisplayItem(content2a, cachedBackgroundType), | 393 TestDisplayItem(content2a, cachedBackgroundType), |
| 394 TestDisplayItem(content2b, backgroundType), |
| 389 TestDisplayItem(container2Layer, endSubsequenceType), | 395 TestDisplayItem(container2Layer, endSubsequenceType), |
| 390 TestDisplayItem(htmlLayer, endSubsequenceType), | 396 TestDisplayItem(htmlLayer, endSubsequenceType), |
| 391 TestDisplayItem(rootLayer, endSubsequenceType)); | 397 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 392 | 398 |
| 393 compositeForSlimmingPaintV2(); | 399 compositeForSlimmingPaintV2(); |
| 394 | 400 |
| 395 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 13, | 401 EXPECT_DISPLAY_LIST(rootPaintController().displayItemList(), 14, |
| 396 TestDisplayItem(layoutView(), backgroundType), | 402 TestDisplayItem(layoutView(), backgroundType), |
| 397 TestDisplayItem(rootLayer, subsequenceType), | 403 TestDisplayItem(rootLayer, subsequenceType), |
| 398 TestDisplayItem(htmlLayer, subsequenceType), | 404 TestDisplayItem(htmlLayer, subsequenceType), |
| 399 TestDisplayItem(container1, backgroundType), | 405 TestDisplayItem(container1, backgroundType), |
| 400 TestDisplayItem(container1Layer, subsequenceType), | 406 TestDisplayItem(container1Layer, subsequenceType), |
| 401 TestDisplayItem(content1, backgroundType), | 407 TestDisplayItem(content1, backgroundType), |
| 402 TestDisplayItem(container1Layer, endSubsequenceType), | 408 TestDisplayItem(container1Layer, endSubsequenceType), |
| 403 TestDisplayItem(container2, backgroundType), | 409 TestDisplayItem(container2, backgroundType), |
| 404 TestDisplayItem(container2Layer, subsequenceType), | 410 TestDisplayItem(container2Layer, subsequenceType), |
| 405 TestDisplayItem(content2a, backgroundType), | 411 TestDisplayItem(content2a, backgroundType), |
| 412 TestDisplayItem(content2b, backgroundType), |
| 406 TestDisplayItem(container2Layer, endSubsequenceType), | 413 TestDisplayItem(container2Layer, endSubsequenceType), |
| 407 TestDisplayItem(htmlLayer, endSubsequenceType), | 414 TestDisplayItem(htmlLayer, endSubsequenceType), |
| 408 TestDisplayItem(rootLayer, endSubsequenceType)); | 415 TestDisplayItem(rootLayer, endSubsequenceType)); |
| 409 } | 416 } |
| 410 | 417 |
| 411 } // namespace blink | 418 } // namespace blink |
| OLD | NEW |