| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 void PaintLayerCompositor::enableCompositingModeIfNeeded() { | 124 void PaintLayerCompositor::enableCompositingModeIfNeeded() { |
| 125 if (!m_rootShouldAlwaysCompositeDirty) | 125 if (!m_rootShouldAlwaysCompositeDirty) |
| 126 return; | 126 return; |
| 127 | 127 |
| 128 m_rootShouldAlwaysCompositeDirty = false; | 128 m_rootShouldAlwaysCompositeDirty = false; |
| 129 if (m_compositing) | 129 if (m_compositing) |
| 130 return; | 130 return; |
| 131 | 131 |
| 132 if (rootShouldAlwaysComposite()) { | 132 if (rootShouldAlwaysComposite()) { |
| 133 // FIXME: Is this needed? It was added in https://bugs.webkit.org/show_bug.c
gi?id=26651. | 133 // FIXME: Is this needed? It was added in |
| 134 // https://bugs.webkit.org/show_bug.cgi?id=26651. |
| 134 // No tests fail if it's deleted. | 135 // No tests fail if it's deleted. |
| 135 setNeedsCompositingUpdate(CompositingUpdateRebuildTree); | 136 setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
| 136 setCompositingModeEnabled(true); | 137 setCompositingModeEnabled(true); |
| 137 } | 138 } |
| 138 } | 139 } |
| 139 | 140 |
| 140 bool PaintLayerCompositor::rootShouldAlwaysComposite() const { | 141 bool PaintLayerCompositor::rootShouldAlwaysComposite() const { |
| 141 if (!m_hasAcceleratedCompositing) | 142 if (!m_hasAcceleratedCompositing) |
| 142 return false; | 143 return false; |
| 143 return m_layoutView.frame()->isLocalRoot() || | 144 return m_layoutView.frame()->isLocalRoot() || |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 Fullscreen::currentFullScreenElementFrom(*contentDocument); | 178 Fullscreen::currentFullScreenElementFrom(*contentDocument); |
| 178 if (!isHTMLVideoElement(fullscreenElement)) | 179 if (!isHTMLVideoElement(fullscreenElement)) |
| 179 return nullptr; | 180 return nullptr; |
| 180 LayoutObject* layoutObject = fullscreenElement->layoutObject(); | 181 LayoutObject* layoutObject = fullscreenElement->layoutObject(); |
| 181 if (!layoutObject) | 182 if (!layoutObject) |
| 182 return nullptr; | 183 return nullptr; |
| 183 return toLayoutVideo(layoutObject); | 184 return toLayoutVideo(layoutObject); |
| 184 } | 185 } |
| 185 | 186 |
| 186 // The descendant-dependent flags system is badly broken because we clean dirty | 187 // The descendant-dependent flags system is badly broken because we clean dirty |
| 187 // bits in upward tree walks, which means we need to call updateDescendantDepend
entFlags | 188 // bits in upward tree walks, which means we need to call |
| 188 // at every node in the tree to fully clean all the dirty bits. While we'll in | 189 // updateDescendantDependentFlags at every node in the tree to fully clean all |
| 189 // the process of fixing this issue, updateDescendantDependentFlagsForEntireSubt
ree | 190 // the dirty bits. While we'll in the process of fixing this issue, |
| 190 // provides a big hammer for actually cleaning all the dirty bits in a subtree. | 191 // updateDescendantDependentFlagsForEntireSubtree provides a big hammer for |
| 192 // actually cleaning all the dirty bits in a subtree. |
| 191 // | 193 // |
| 192 // FIXME: Remove this function once the descendant-dependent flags system keeps | 194 // FIXME: Remove this function once the descendant-dependent flags system keeps |
| 193 // its dirty bits scoped to subtrees. | 195 // its dirty bits scoped to subtrees. |
| 194 void updateDescendantDependentFlagsForEntireSubtree(PaintLayer& layer) { | 196 void updateDescendantDependentFlagsForEntireSubtree(PaintLayer& layer) { |
| 195 layer.updateDescendantDependentFlags(); | 197 layer.updateDescendantDependentFlags(); |
| 196 | 198 |
| 197 for (PaintLayer* child = layer.firstChild(); child; | 199 for (PaintLayer* child = layer.firstChild(); child; |
| 198 child = child->nextSibling()) | 200 child = child->nextSibling()) |
| 199 updateDescendantDependentFlagsForEntireSubtree(*child); | 201 updateDescendantDependentFlagsForEntireSubtree(*child); |
| 200 } | 202 } |
| 201 | 203 |
| 202 void PaintLayerCompositor::updateIfNeededRecursive() { | 204 void PaintLayerCompositor::updateIfNeededRecursive() { |
| 203 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Compositing.UpdateTime"); | 205 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Compositing.UpdateTime"); |
| 204 updateIfNeededRecursiveInternal(); | 206 updateIfNeededRecursiveInternal(); |
| 205 } | 207 } |
| 206 | 208 |
| 207 void PaintLayerCompositor::updateIfNeededRecursiveInternal() { | 209 void PaintLayerCompositor::updateIfNeededRecursiveInternal() { |
| 208 FrameView* view = m_layoutView.frameView(); | 210 FrameView* view = m_layoutView.frameView(); |
| 209 if (view->shouldThrottleRendering()) | 211 if (view->shouldThrottleRendering()) |
| 210 return; | 212 return; |
| 211 | 213 |
| 212 for (Frame* child = m_layoutView.frameView()->frame().tree().firstChild(); | 214 for (Frame* child = m_layoutView.frameView()->frame().tree().firstChild(); |
| 213 child; child = child->tree().nextSibling()) { | 215 child; child = child->tree().nextSibling()) { |
| 214 if (!child->isLocalFrame()) | 216 if (!child->isLocalFrame()) |
| 215 continue; | 217 continue; |
| 216 LocalFrame* localFrame = toLocalFrame(child); | 218 LocalFrame* localFrame = toLocalFrame(child); |
| 217 // It's possible for trusted Pepper plugins to force hit testing in situatio
ns where | 219 // It's possible for trusted Pepper plugins to force hit testing in |
| 218 // the frame tree is in an inconsistent state, such as in the middle of fram
e detach. | 220 // situations where the frame tree is in an inconsistent state, such as in |
| 221 // the middle of frame detach. |
| 219 // TODO(bbudge) Remove this check when trusted Pepper plugins are gone. | 222 // TODO(bbudge) Remove this check when trusted Pepper plugins are gone. |
| 220 if (localFrame->document()->isActive() && | 223 if (localFrame->document()->isActive() && |
| 221 !localFrame->contentLayoutItem().isNull()) | 224 !localFrame->contentLayoutItem().isNull()) |
| 222 localFrame->contentLayoutItem() | 225 localFrame->contentLayoutItem() |
| 223 .compositor() | 226 .compositor() |
| 224 ->updateIfNeededRecursiveInternal(); | 227 ->updateIfNeededRecursiveInternal(); |
| 225 } | 228 } |
| 226 | 229 |
| 227 TRACE_EVENT0("blink", "PaintLayerCompositor::updateIfNeededRecursive"); | 230 TRACE_EVENT0("blink", "PaintLayerCompositor::updateIfNeededRecursive"); |
| 228 | 231 |
| 229 ASSERT(!m_layoutView.needsLayout()); | 232 ASSERT(!m_layoutView.needsLayout()); |
| 230 | 233 |
| 231 ScriptForbiddenScope forbidScript; | 234 ScriptForbiddenScope forbidScript; |
| 232 | 235 |
| 233 // FIXME: enableCompositingModeIfNeeded can trigger a CompositingUpdateRebuild
Tree, | 236 // FIXME: enableCompositingModeIfNeeded can trigger a |
| 234 // which asserts that it's not InCompositingUpdate. | 237 // CompositingUpdateRebuildTree, which asserts that it's not |
| 238 // InCompositingUpdate. |
| 235 enableCompositingModeIfNeeded(); | 239 enableCompositingModeIfNeeded(); |
| 236 | 240 |
| 237 if (m_needsUpdateDescendantDependentFlags) { | 241 if (m_needsUpdateDescendantDependentFlags) { |
| 238 updateDescendantDependentFlagsForEntireSubtree(*rootLayer()); | 242 updateDescendantDependentFlagsForEntireSubtree(*rootLayer()); |
| 239 m_needsUpdateDescendantDependentFlags = false; | 243 m_needsUpdateDescendantDependentFlags = false; |
| 240 } | 244 } |
| 241 | 245 |
| 242 m_layoutView.commitPendingSelection(); | 246 m_layoutView.commitPendingSelection(); |
| 243 | 247 |
| 244 lifecycle().advanceTo(DocumentLifecycle::InCompositingUpdate); | 248 lifecycle().advanceTo(DocumentLifecycle::InCompositingUpdate); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer(); | 319 GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer(); |
| 316 if (backgroundLayer && !backgroundLayer->parent()) | 320 if (backgroundLayer && !backgroundLayer->parent()) |
| 317 rootFixedBackgroundsChanged(); | 321 rootFixedBackgroundsChanged(); |
| 318 } | 322 } |
| 319 return; | 323 return; |
| 320 } | 324 } |
| 321 | 325 |
| 322 GraphicsLayer* videoLayer = | 326 GraphicsLayer* videoLayer = |
| 323 video->layer()->compositedLayerMapping()->mainGraphicsLayer(); | 327 video->layer()->compositedLayerMapping()->mainGraphicsLayer(); |
| 324 | 328 |
| 325 // The fullscreen video has layer position equal to its enclosing frame's scro
ll position because fullscreen container is fixed-positioned. | 329 // The fullscreen video has layer position equal to its enclosing frame's |
| 326 // We should reset layer position here since we are going to reattach the laye
r at the very top level. | 330 // scroll position because fullscreen container is fixed-positioned. |
| 331 // We should reset layer position here since we are going to reattach the |
| 332 // layer at the very top level. |
| 327 videoLayer->setPosition(IntPoint()); | 333 videoLayer->setPosition(IntPoint()); |
| 328 | 334 |
| 329 // Only steal fullscreen video layer and clear all other layers if we are the
main frame. | 335 // Only steal fullscreen video layer and clear all other layers if we are the |
| 336 // main frame. |
| 330 if (!isLocalRoot) | 337 if (!isLocalRoot) |
| 331 return; | 338 return; |
| 332 | 339 |
| 333 m_rootContentLayer->removeAllChildren(); | 340 m_rootContentLayer->removeAllChildren(); |
| 334 m_overflowControlsHostLayer->addChild(videoLayer); | 341 m_overflowControlsHostLayer->addChild(videoLayer); |
| 335 if (GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer()) | 342 if (GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer()) |
| 336 backgroundLayer->removeFromParent(); | 343 backgroundLayer->removeFromParent(); |
| 337 m_inOverlayFullscreenVideo = true; | 344 m_inOverlayFullscreenVideo = true; |
| 338 } | 345 } |
| 339 | 346 |
| 340 void PaintLayerCompositor::updateWithoutAcceleratedCompositing( | 347 void PaintLayerCompositor::updateWithoutAcceleratedCompositing( |
| 341 CompositingUpdateType updateType) { | 348 CompositingUpdateType updateType) { |
| 342 ASSERT(!hasAcceleratedCompositing()); | 349 ASSERT(!hasAcceleratedCompositing()); |
| 343 | 350 |
| 344 if (updateType >= CompositingUpdateAfterCompositingInputChange) | 351 if (updateType >= CompositingUpdateAfterCompositingInputChange) |
| 345 CompositingInputsUpdater(rootLayer()).update(); | 352 CompositingInputsUpdater(rootLayer()).update(); |
| 346 | 353 |
| 347 #if ENABLE(ASSERT) | 354 #if ENABLE(ASSERT) |
| 348 CompositingInputsUpdater::assertNeedsCompositingInputsUpdateBitsCleared( | 355 CompositingInputsUpdater::assertNeedsCompositingInputsUpdateBitsCleared( |
| 349 rootLayer()); | 356 rootLayer()); |
| 350 #endif | 357 #endif |
| 351 } | 358 } |
| 352 | 359 |
| 353 static void | 360 static void |
| 354 forceRecomputePaintInvalidationRectsIncludingNonCompositingDescendants( | 361 forceRecomputePaintInvalidationRectsIncludingNonCompositingDescendants( |
| 355 LayoutObject* layoutObject) { | 362 LayoutObject* layoutObject) { |
| 356 // We clear the previous paint invalidation rect as it's wrong (paint invalida
tion container | 363 // We clear the previous paint invalidation rect as it's wrong (paint |
| 357 // changed, ...). Forcing a full invalidation will make us recompute it. Also
we are not | 364 // invalidation container changed, ...). Forcing a full invalidation will make |
| 358 // changing the previous position from our paint invalidation container, which
is fine as | 365 // us recompute it. Also we are not changing the previous position from our |
| 359 // we want a full paint invalidation anyway. | 366 // paint invalidation container, which is fine as we want a full paint |
| 367 // invalidation anyway. |
| 360 layoutObject->clearPreviousPaintInvalidationRects(); | 368 layoutObject->clearPreviousPaintInvalidationRects(); |
| 361 | 369 |
| 362 for (LayoutObject* child = layoutObject->slowFirstChild(); child; | 370 for (LayoutObject* child = layoutObject->slowFirstChild(); child; |
| 363 child = child->nextSibling()) { | 371 child = child->nextSibling()) { |
| 364 if (!child->isPaintInvalidationContainer()) | 372 if (!child->isPaintInvalidationContainer()) |
| 365 forceRecomputePaintInvalidationRectsIncludingNonCompositingDescendants( | 373 forceRecomputePaintInvalidationRectsIncludingNonCompositingDescendants( |
| 366 child); | 374 child); |
| 367 } | 375 } |
| 368 } | 376 } |
| 369 | 377 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 if (elementAnimations) | 526 if (elementAnimations) |
| 519 elementAnimations->restartAnimationOnCompositor(); | 527 elementAnimations->restartAnimationOnCompositor(); |
| 520 } | 528 } |
| 521 | 529 |
| 522 bool PaintLayerCompositor::allocateOrClearCompositedLayerMapping( | 530 bool PaintLayerCompositor::allocateOrClearCompositedLayerMapping( |
| 523 PaintLayer* layer, | 531 PaintLayer* layer, |
| 524 const CompositingStateTransitionType compositedLayerUpdate) { | 532 const CompositingStateTransitionType compositedLayerUpdate) { |
| 525 bool compositedLayerMappingChanged = false; | 533 bool compositedLayerMappingChanged = false; |
| 526 | 534 |
| 527 // FIXME: It would be nice to directly use the layer's compositing reason, | 535 // FIXME: It would be nice to directly use the layer's compositing reason, |
| 528 // but allocateOrClearCompositedLayerMapping also gets called without having u
pdated compositing | 536 // but allocateOrClearCompositedLayerMapping also gets called without having |
| 529 // requirements fully. | 537 // updated compositing requirements fully. |
| 530 switch (compositedLayerUpdate) { | 538 switch (compositedLayerUpdate) { |
| 531 case AllocateOwnCompositedLayerMapping: | 539 case AllocateOwnCompositedLayerMapping: |
| 532 ASSERT(!layer->hasCompositedLayerMapping()); | 540 ASSERT(!layer->hasCompositedLayerMapping()); |
| 533 setCompositingModeEnabled(true); | 541 setCompositingModeEnabled(true); |
| 534 | 542 |
| 535 // If we need to issue paint invalidations, do so before allocating the co
mpositedLayerMapping and clearing out the groupedMapping. | 543 // If we need to issue paint invalidations, do so before allocating the |
| 544 // compositedLayerMapping and clearing out the groupedMapping. |
| 536 paintInvalidationOnCompositingChange(layer); | 545 paintInvalidationOnCompositingChange(layer); |
| 537 | 546 |
| 538 // If this layer was previously squashed, we need to remove its reference
to a groupedMapping right away, so | 547 // If this layer was previously squashed, we need to remove its reference |
| 539 // that computing paint invalidation rects will know the layer's correct c
ompositingState. | 548 // to a groupedMapping right away, so that computing paint invalidation |
| 540 // FIXME: do we need to also remove the layer from it's location in the sq
uashing list of its groupedMapping? | 549 // rects will know the layer's correct compositingState. |
| 541 // Need to create a test where a squashed layer pops into compositing. And
also to cover all other | 550 // FIXME: do we need to also remove the layer from it's location in the |
| 542 // sorts of compositingState transitions. | 551 // squashing list of its groupedMapping? Need to create a test where a |
| 552 // squashed layer pops into compositing. And also to cover all other sorts |
| 553 // of compositingState transitions. |
| 543 layer->setLostGroupedMapping(false); | 554 layer->setLostGroupedMapping(false); |
| 544 layer->setGroupedMapping(nullptr, | 555 layer->setGroupedMapping(nullptr, |
| 545 PaintLayer::InvalidateLayerAndRemoveFromMapping); | 556 PaintLayer::InvalidateLayerAndRemoveFromMapping); |
| 546 | 557 |
| 547 layer->ensureCompositedLayerMapping(); | 558 layer->ensureCompositedLayerMapping(); |
| 548 compositedLayerMappingChanged = true; | 559 compositedLayerMappingChanged = true; |
| 549 | 560 |
| 550 restartAnimationOnCompositor(*layer->layoutObject()); | 561 restartAnimationOnCompositor(*layer->layoutObject()); |
| 551 | 562 |
| 552 // At this time, the ScrollingCoordinator only supports the top-level fram
e. | 563 // At this time, the ScrollingCoordinator only supports the top-level |
| 564 // frame. |
| 553 if (layer->isRootLayer() && m_layoutView.frame()->isLocalRoot()) { | 565 if (layer->isRootLayer() && m_layoutView.frame()->isLocalRoot()) { |
| 554 if (ScrollingCoordinator* scrollingCoordinator = | 566 if (ScrollingCoordinator* scrollingCoordinator = |
| 555 this->scrollingCoordinator()) | 567 this->scrollingCoordinator()) |
| 556 scrollingCoordinator->frameViewRootLayerDidChange( | 568 scrollingCoordinator->frameViewRootLayerDidChange( |
| 557 m_layoutView.frameView()); | 569 m_layoutView.frameView()); |
| 558 } | 570 } |
| 559 break; | 571 break; |
| 560 case RemoveOwnCompositedLayerMapping: | 572 case RemoveOwnCompositedLayerMapping: |
| 561 // PutInSquashingLayer means you might have to remove the composited layer m
apping first. | 573 // PutInSquashingLayer means you might have to remove the composited layer |
| 574 // mapping first. |
| 562 case PutInSquashingLayer: | 575 case PutInSquashingLayer: |
| 563 if (layer->hasCompositedLayerMapping()) { | 576 if (layer->hasCompositedLayerMapping()) { |
| 564 layer->clearCompositedLayerMapping(); | 577 layer->clearCompositedLayerMapping(); |
| 565 compositedLayerMappingChanged = true; | 578 compositedLayerMappingChanged = true; |
| 566 } | 579 } |
| 567 | 580 |
| 568 break; | 581 break; |
| 569 case RemoveFromSquashingLayer: | 582 case RemoveFromSquashingLayer: |
| 570 case NoCompositingStateChange: | 583 case NoCompositingStateChange: |
| 571 // Do nothing. | 584 // Do nothing. |
| 572 break; | 585 break; |
| 573 } | 586 } |
| 574 | 587 |
| 575 if (compositedLayerMappingChanged && layer->layoutObject()->isLayoutPart()) { | 588 if (compositedLayerMappingChanged && layer->layoutObject()->isLayoutPart()) { |
| 576 PaintLayerCompositor* innerCompositor = | 589 PaintLayerCompositor* innerCompositor = |
| 577 frameContentsCompositor(toLayoutPart(layer->layoutObject())); | 590 frameContentsCompositor(toLayoutPart(layer->layoutObject())); |
| 578 if (innerCompositor && innerCompositor->staleInCompositingMode()) | 591 if (innerCompositor && innerCompositor->staleInCompositingMode()) |
| 579 innerCompositor->updateRootLayerAttachment(); | 592 innerCompositor->updateRootLayerAttachment(); |
| 580 } | 593 } |
| 581 | 594 |
| 582 if (compositedLayerMappingChanged) | 595 if (compositedLayerMappingChanged) |
| 583 layer->clipper().clearClipRectsIncludingDescendants(PaintingClipRects); | 596 layer->clipper().clearClipRectsIncludingDescendants(PaintingClipRects); |
| 584 | 597 |
| 585 // If a fixed position layer gained/lost a compositedLayerMapping or the reaso
n not compositing it changed, | 598 // If a fixed position layer gained/lost a compositedLayerMapping or the |
| 586 // the scrolling coordinator needs to recalculate whether it can do fast scrol
ling. | 599 // reason not compositing it changed, the scrolling coordinator needs to |
| 600 // recalculate whether it can do fast scrolling. |
| 587 if (compositedLayerMappingChanged) { | 601 if (compositedLayerMappingChanged) { |
| 588 if (ScrollingCoordinator* scrollingCoordinator = | 602 if (ScrollingCoordinator* scrollingCoordinator = |
| 589 this->scrollingCoordinator()) | 603 this->scrollingCoordinator()) |
| 590 scrollingCoordinator->frameViewFixedObjectsDidChange( | 604 scrollingCoordinator->frameViewFixedObjectsDidChange( |
| 591 m_layoutView.frameView()); | 605 m_layoutView.frameView()); |
| 592 } | 606 } |
| 593 | 607 |
| 594 return compositedLayerMappingChanged; | 608 return compositedLayerMappingChanged; |
| 595 } | 609 } |
| 596 | 610 |
| 597 void PaintLayerCompositor::paintInvalidationOnCompositingChange( | 611 void PaintLayerCompositor::paintInvalidationOnCompositingChange( |
| 598 PaintLayer* layer) { | 612 PaintLayer* layer) { |
| 599 // If the layoutObject is not attached yet, no need to issue paint invalidatio
ns. | 613 // If the layoutObject is not attached yet, no need to issue paint |
| 614 // invalidations. |
| 600 if (layer->layoutObject() != &m_layoutView && | 615 if (layer->layoutObject() != &m_layoutView && |
| 601 !layer->layoutObject()->parent()) | 616 !layer->layoutObject()->parent()) |
| 602 return; | 617 return; |
| 603 | 618 |
| 604 // For querying Layer::compositingState() | 619 // For querying Layer::compositingState() |
| 605 // Eager invalidation here is correct, since we are invalidating with respect
to the previous frame's | 620 // Eager invalidation here is correct, since we are invalidating with respect |
| 606 // compositing state when changing the compositing backing of the layer. | 621 // to the previous frame's compositing state when changing the compositing |
| 622 // backing of the layer. |
| 607 DisableCompositingQueryAsserts disabler; | 623 DisableCompositingQueryAsserts disabler; |
| 608 // FIXME: We should not allow paint invalidation out of paint invalidation sta
te. crbug.com/457415 | 624 // FIXME: We should not allow paint invalidation out of paint invalidation |
| 625 // state. crbug.com/457415 |
| 609 DisablePaintInvalidationStateAsserts paintInvalidationAssertisabler; | 626 DisablePaintInvalidationStateAsserts paintInvalidationAssertisabler; |
| 610 | 627 |
| 611 ObjectPaintInvalidator(*layer->layoutObject()) | 628 ObjectPaintInvalidator(*layer->layoutObject()) |
| 612 .invalidatePaintIncludingNonCompositingDescendants(); | 629 .invalidatePaintIncludingNonCompositingDescendants(); |
| 613 } | 630 } |
| 614 | 631 |
| 615 void PaintLayerCompositor::frameViewDidChangeLocation( | 632 void PaintLayerCompositor::frameViewDidChangeLocation( |
| 616 const IntPoint& contentsOffset) { | 633 const IntPoint& contentsOffset) { |
| 617 if (m_overflowControlsHostLayer) | 634 if (m_overflowControlsHostLayer) |
| 618 m_overflowControlsHostLayer->setPosition(contentsOffset); | 635 m_overflowControlsHostLayer->setPosition(contentsOffset); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 // stay put, we position it in the layer tree as follows: | 695 // stay put, we position it in the layer tree as follows: |
| 679 // | 696 // |
| 680 // + Overflow controls host | 697 // + Overflow controls host |
| 681 // + LocalFrame clip | 698 // + LocalFrame clip |
| 682 // + (Fixed root background) <-- Here. | 699 // + (Fixed root background) <-- Here. |
| 683 // + LocalFrame scroll | 700 // + LocalFrame scroll |
| 684 // + Root content layer | 701 // + Root content layer |
| 685 // + Scrollbars | 702 // + Scrollbars |
| 686 // | 703 // |
| 687 // That is, it needs to be the first child of the frame clip, the sibling of | 704 // That is, it needs to be the first child of the frame clip, the sibling of |
| 688 // the frame scroll layer. The compositor does not own the background layer, i
t | 705 // the frame scroll layer. The compositor does not own the background layer, |
| 689 // just positions it (like the foreground layer). | 706 // it just positions it (like the foreground layer). |
| 690 if (GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer()) | 707 if (GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer()) |
| 691 m_containerLayer->addChildBelow(backgroundLayer, m_scrollLayer.get()); | 708 m_containerLayer->addChildBelow(backgroundLayer, m_scrollLayer.get()); |
| 692 } | 709 } |
| 693 | 710 |
| 694 bool PaintLayerCompositor::scrollingLayerDidChange(PaintLayer* layer) { | 711 bool PaintLayerCompositor::scrollingLayerDidChange(PaintLayer* layer) { |
| 695 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) | 712 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator()) |
| 696 return scrollingCoordinator->scrollableAreaScrollLayerDidChange( | 713 return scrollingCoordinator->scrollableAreaScrollLayerDidChange( |
| 697 layer->getScrollableArea()); | 714 layer->getScrollableArea()); |
| 698 return false; | 715 return false; |
| 699 } | 716 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 layer->layoutObject())); | 852 layer->layoutObject())); |
| 836 } | 853 } |
| 837 | 854 |
| 838 void PaintLayerCompositor::updateDirectCompositingReasons(PaintLayer* layer) { | 855 void PaintLayerCompositor::updateDirectCompositingReasons(PaintLayer* layer) { |
| 839 layer->setCompositingReasons(m_compositingReasonFinder.directReasons(layer), | 856 layer->setCompositingReasons(m_compositingReasonFinder.directReasons(layer), |
| 840 CompositingReasonComboAllDirectReasons); | 857 CompositingReasonComboAllDirectReasons); |
| 841 } | 858 } |
| 842 | 859 |
| 843 bool PaintLayerCompositor::canBeComposited(const PaintLayer* layer) const { | 860 bool PaintLayerCompositor::canBeComposited(const PaintLayer* layer) const { |
| 844 FrameView* frameView = layer->layoutObject()->frameView(); | 861 FrameView* frameView = layer->layoutObject()->frameView(); |
| 845 // Elements within an invisible frame must not be composited because they are
not drawn. | 862 // Elements within an invisible frame must not be composited because they are |
| 863 // not drawn. |
| 846 if (frameView && !frameView->isVisible()) | 864 if (frameView && !frameView->isVisible()) |
| 847 return false; | 865 return false; |
| 848 | 866 |
| 849 const bool hasCompositorAnimation = | 867 const bool hasCompositorAnimation = |
| 850 m_compositingReasonFinder.requiresCompositingForAnimation( | 868 m_compositingReasonFinder.requiresCompositingForAnimation( |
| 851 *layer->layoutObject()->style()); | 869 *layer->layoutObject()->style()); |
| 852 return m_hasAcceleratedCompositing && | 870 return m_hasAcceleratedCompositing && |
| 853 (hasCompositorAnimation || !layer->subtreeIsInvisible()) && | 871 (hasCompositorAnimation || !layer->subtreeIsInvisible()) && |
| 854 layer->isSelfPaintingLayer() && | 872 layer->isSelfPaintingLayer() && |
| 855 !layer->layoutObject()->isLayoutFlowThread(); | 873 !layer->layoutObject()->isLayoutFlowThread(); |
| 856 } | 874 } |
| 857 | 875 |
| 858 // Return true if the given layer is a stacking context and has compositing chil
d | 876 // Return true if the given layer is a stacking context and has compositing |
| 859 // layers that it needs to clip. In this case we insert a clipping GraphicsLayer | 877 // child layers that it needs to clip. In this case we insert a clipping |
| 860 // into the hierarchy between this layer and its children in the z-order hierarc
hy. | 878 // GraphicsLayer into the hierarchy between this layer and its children in the |
| 879 // z-order hierarchy. |
| 861 bool PaintLayerCompositor::clipsCompositingDescendants( | 880 bool PaintLayerCompositor::clipsCompositingDescendants( |
| 862 const PaintLayer* layer) const { | 881 const PaintLayer* layer) const { |
| 863 return layer->hasCompositingDescendant() && | 882 return layer->hasCompositingDescendant() && |
| 864 layer->layoutObject()->hasClipRelatedProperty(); | 883 layer->layoutObject()->hasClipRelatedProperty(); |
| 865 } | 884 } |
| 866 | 885 |
| 867 // If an element has composited negative z-index children, those children paint
in front of the | 886 // If an element has composited negative z-index children, those children paint |
| 868 // layer background, so we need an extra 'contents' layer for the foreground of
the layer | 887 // in front of the layer background, so we need an extra 'contents' layer for |
| 869 // object. | 888 // the foreground of the layer object. |
| 870 bool PaintLayerCompositor::needsContentsCompositingLayer( | 889 bool PaintLayerCompositor::needsContentsCompositingLayer( |
| 871 const PaintLayer* layer) const { | 890 const PaintLayer* layer) const { |
| 872 if (!layer->hasCompositingDescendant()) | 891 if (!layer->hasCompositingDescendant()) |
| 873 return false; | 892 return false; |
| 874 return layer->stackingNode()->hasNegativeZOrderList(); | 893 return layer->stackingNode()->hasNegativeZOrderList(); |
| 875 } | 894 } |
| 876 | 895 |
| 877 static void paintScrollbar(const GraphicsLayer* graphicsLayer, | 896 static void paintScrollbar(const GraphicsLayer* graphicsLayer, |
| 878 const Scrollbar* scrollbar, | 897 const Scrollbar* scrollbar, |
| 879 GraphicsContext& context, | 898 GraphicsContext& context, |
| 880 const IntRect& clip) { | 899 const IntRect& clip) { |
| 881 // Frame scrollbars are painted in the space of the containing frame, not the
local space of the scrollbar. | 900 // Frame scrollbars are painted in the space of the containing frame, not the |
| 901 // local space of the scrollbar. |
| 882 const IntPoint& paintOffset = scrollbar->frameRect().location(); | 902 const IntPoint& paintOffset = scrollbar->frameRect().location(); |
| 883 IntRect transformedClip = clip; | 903 IntRect transformedClip = clip; |
| 884 transformedClip.moveBy(paintOffset); | 904 transformedClip.moveBy(paintOffset); |
| 885 | 905 |
| 886 AffineTransform translation; | 906 AffineTransform translation; |
| 887 translation.translate(-paintOffset.x(), -paintOffset.y()); | 907 translation.translate(-paintOffset.x(), -paintOffset.y()); |
| 888 TransformRecorder transformRecorder(context, *scrollbar, translation); | 908 TransformRecorder transformRecorder(context, *scrollbar, translation); |
| 889 scrollbar->paint(context, CullRect(transformedClip)); | 909 scrollbar->paint(context, CullRect(transformedClip)); |
| 890 } | 910 } |
| 891 | 911 |
| 892 IntRect PaintLayerCompositor::computeInterestRect( | 912 IntRect PaintLayerCompositor::computeInterestRect( |
| 893 const GraphicsLayer* graphicsLayer, | 913 const GraphicsLayer* graphicsLayer, |
| 894 const IntRect&) const { | 914 const IntRect&) const { |
| 895 return enclosingIntRect(FloatRect(FloatPoint(), graphicsLayer->size())); | 915 return enclosingIntRect(FloatRect(FloatPoint(), graphicsLayer->size())); |
| 896 } | 916 } |
| 897 | 917 |
| 898 void PaintLayerCompositor::paintContents(const GraphicsLayer* graphicsLayer, | 918 void PaintLayerCompositor::paintContents(const GraphicsLayer* graphicsLayer, |
| 899 GraphicsContext& context, | 919 GraphicsContext& context, |
| 900 GraphicsLayerPaintingPhase, | 920 GraphicsLayerPaintingPhase, |
| 901 const IntRect& interestRect) const { | 921 const IntRect& interestRect) const { |
| 902 // Note the composited scrollable area painted below is always associated with
a frame. For | 922 // Note the composited scrollable area painted below is always associated with |
| 903 // painting non-frame ScrollableAreas, see CompositedLayerMapping::paintScroll
ableArea. | 923 // a frame. For painting non-frame ScrollableAreas, see |
| 924 // CompositedLayerMapping::paintScrollableArea. |
| 904 | 925 |
| 905 const Scrollbar* scrollbar = graphicsLayerToScrollbar(graphicsLayer); | 926 const Scrollbar* scrollbar = graphicsLayerToScrollbar(graphicsLayer); |
| 906 if (!scrollbar && graphicsLayer != layerForScrollCorner()) | 927 if (!scrollbar && graphicsLayer != layerForScrollCorner()) |
| 907 return; | 928 return; |
| 908 | 929 |
| 909 if (DrawingRecorder::useCachedDrawingIfPossible( | 930 if (DrawingRecorder::useCachedDrawingIfPossible( |
| 910 context, *graphicsLayer, DisplayItem::kScrollbarCompositedScrollbar)) | 931 context, *graphicsLayer, DisplayItem::kScrollbarCompositedScrollbar)) |
| 911 return; | 932 return; |
| 912 | 933 |
| 913 FloatRect layerBounds(FloatPoint(), graphicsLayer->size()); | 934 FloatRect layerBounds(FloatPoint(), graphicsLayer->size()); |
| 914 SkPictureBuilder pictureBuilder(layerBounds, nullptr, &context); | 935 SkPictureBuilder pictureBuilder(layerBounds, nullptr, &context); |
| 915 | 936 |
| 916 if (scrollbar) | 937 if (scrollbar) |
| 917 paintScrollbar(graphicsLayer, scrollbar, pictureBuilder.context(), | 938 paintScrollbar(graphicsLayer, scrollbar, pictureBuilder.context(), |
| 918 interestRect); | 939 interestRect); |
| 919 else | 940 else |
| 920 FramePainter(*m_layoutView.frameView()) | 941 FramePainter(*m_layoutView.frameView()) |
| 921 .paintScrollCorner(pictureBuilder.context(), interestRect); | 942 .paintScrollCorner(pictureBuilder.context(), interestRect); |
| 922 | 943 |
| 923 // Replay the painted scrollbar content with the GraphicsLayer backing as the
DisplayItemClient | 944 // Replay the painted scrollbar content with the GraphicsLayer backing as the |
| 924 // in order for the resulting DrawingDisplayItem to produce the correct visual
Rect (i.e., the | 945 // DisplayItemClient in order for the resulting DrawingDisplayItem to produce |
| 925 // bounds of the involved GraphicsLayer). | 946 // the correct visualRect (i.e., the bounds of the involved GraphicsLayer). |
| 926 DrawingRecorder drawingRecorder(context, *graphicsLayer, | 947 DrawingRecorder drawingRecorder(context, *graphicsLayer, |
| 927 DisplayItem::kScrollbarCompositedScrollbar, | 948 DisplayItem::kScrollbarCompositedScrollbar, |
| 928 layerBounds); | 949 layerBounds); |
| 929 pictureBuilder.endRecording()->playback(context.canvas()); | 950 pictureBuilder.endRecording()->playback(context.canvas()); |
| 930 } | 951 } |
| 931 | 952 |
| 932 Scrollbar* PaintLayerCompositor::graphicsLayerToScrollbar( | 953 Scrollbar* PaintLayerCompositor::graphicsLayerToScrollbar( |
| 933 const GraphicsLayer* graphicsLayer) const { | 954 const GraphicsLayer* graphicsLayer) const { |
| 934 if (graphicsLayer == layerForHorizontalScrollbar()) { | 955 if (graphicsLayer == layerForHorizontalScrollbar()) { |
| 935 return m_layoutView.frameView()->horizontalScrollbar(); | 956 return m_layoutView.frameView()->horizontalScrollbar(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 949 bool PaintLayerCompositor::needsFixedRootBackgroundLayer( | 970 bool PaintLayerCompositor::needsFixedRootBackgroundLayer( |
| 950 const PaintLayer* layer) const { | 971 const PaintLayer* layer) const { |
| 951 if (layer != m_layoutView.layer()) | 972 if (layer != m_layoutView.layer()) |
| 952 return false; | 973 return false; |
| 953 | 974 |
| 954 return supportsFixedRootBackgroundCompositing() && | 975 return supportsFixedRootBackgroundCompositing() && |
| 955 m_layoutView.rootBackgroundIsEntirelyFixed(); | 976 m_layoutView.rootBackgroundIsEntirelyFixed(); |
| 956 } | 977 } |
| 957 | 978 |
| 958 GraphicsLayer* PaintLayerCompositor::fixedRootBackgroundLayer() const { | 979 GraphicsLayer* PaintLayerCompositor::fixedRootBackgroundLayer() const { |
| 959 // Get the fixed root background from the LayoutView layer's compositedLayerMa
pping. | 980 // Get the fixed root background from the LayoutView layer's |
| 981 // compositedLayerMapping. |
| 960 PaintLayer* viewLayer = m_layoutView.layer(); | 982 PaintLayer* viewLayer = m_layoutView.layer(); |
| 961 if (!viewLayer) | 983 if (!viewLayer) |
| 962 return nullptr; | 984 return nullptr; |
| 963 | 985 |
| 964 if (viewLayer->compositingState() == PaintsIntoOwnBacking && | 986 if (viewLayer->compositingState() == PaintsIntoOwnBacking && |
| 965 viewLayer->compositedLayerMapping() | 987 viewLayer->compositedLayerMapping() |
| 966 ->backgroundLayerPaintsFixedRootBackground()) | 988 ->backgroundLayerPaintsFixedRootBackground()) |
| 967 return viewLayer->compositedLayerMapping()->backgroundLayer(); | 989 return viewLayer->compositedLayerMapping()->backgroundLayer(); |
| 968 | 990 |
| 969 return nullptr; | 991 return nullptr; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 bool PaintLayerCompositor::requiresVerticalScrollbarLayer() const { | 1038 bool PaintLayerCompositor::requiresVerticalScrollbarLayer() const { |
| 1017 return m_layoutView.frameView()->verticalScrollbar(); | 1039 return m_layoutView.frameView()->verticalScrollbar(); |
| 1018 } | 1040 } |
| 1019 | 1041 |
| 1020 bool PaintLayerCompositor::requiresScrollCornerLayer() const { | 1042 bool PaintLayerCompositor::requiresScrollCornerLayer() const { |
| 1021 return m_layoutView.frameView()->isScrollCornerVisible(); | 1043 return m_layoutView.frameView()->isScrollCornerVisible(); |
| 1022 } | 1044 } |
| 1023 | 1045 |
| 1024 void PaintLayerCompositor::updateOverflowControlsLayers() { | 1046 void PaintLayerCompositor::updateOverflowControlsLayers() { |
| 1025 GraphicsLayer* controlsParent = m_overflowControlsHostLayer.get(); | 1047 GraphicsLayer* controlsParent = m_overflowControlsHostLayer.get(); |
| 1026 // Main frame scrollbars should always be stuck to the sides of the screen (in
overscroll and in pinch-zoom), so | 1048 // Main frame scrollbars should always be stuck to the sides of the screen (in |
| 1027 // make the parent for the scrollbars be the viewport container layer. | 1049 // overscroll and in pinch-zoom), so make the parent for the scrollbars be the |
| 1050 // viewport container layer. |
| 1028 if (m_layoutView.frame()->isMainFrame()) { | 1051 if (m_layoutView.frame()->isMainFrame()) { |
| 1029 VisualViewport& visualViewport = | 1052 VisualViewport& visualViewport = |
| 1030 m_layoutView.frameView()->page()->frameHost().visualViewport(); | 1053 m_layoutView.frameView()->page()->frameHost().visualViewport(); |
| 1031 controlsParent = visualViewport.containerLayer(); | 1054 controlsParent = visualViewport.containerLayer(); |
| 1032 } | 1055 } |
| 1033 | 1056 |
| 1034 if (requiresHorizontalScrollbarLayer()) { | 1057 if (requiresHorizontalScrollbarLayer()) { |
| 1035 if (!m_layerForHorizontalScrollbar) { | 1058 if (!m_layerForHorizontalScrollbar) { |
| 1036 m_layerForHorizontalScrollbar = GraphicsLayer::create(this); | 1059 m_layerForHorizontalScrollbar = GraphicsLayer::create(this); |
| 1037 } | 1060 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 Page* page = frame.page(); | 1229 Page* page = frame.page(); |
| 1207 if (!page) | 1230 if (!page) |
| 1208 return; | 1231 return; |
| 1209 page->chromeClient().attachRootGraphicsLayer(rootGraphicsLayer(), &frame); | 1232 page->chromeClient().attachRootGraphicsLayer(rootGraphicsLayer(), &frame); |
| 1210 break; | 1233 break; |
| 1211 } | 1234 } |
| 1212 case RootLayerAttachedViaEnclosingFrame: { | 1235 case RootLayerAttachedViaEnclosingFrame: { |
| 1213 HTMLFrameOwnerElement* ownerElement = | 1236 HTMLFrameOwnerElement* ownerElement = |
| 1214 m_layoutView.document().localOwner(); | 1237 m_layoutView.document().localOwner(); |
| 1215 ASSERT(ownerElement); | 1238 ASSERT(ownerElement); |
| 1216 // The layer will get hooked up via CompositedLayerMapping::updateGraphics
LayerConfiguration() | 1239 // The layer will get hooked up via |
| 1217 // for the frame's layoutObject in the parent document. | 1240 // CompositedLayerMapping::updateGraphicsLayerConfiguration() for the |
| 1241 // frame's layoutObject in the parent document. |
| 1218 ownerElement->setNeedsCompositingUpdate(); | 1242 ownerElement->setNeedsCompositingUpdate(); |
| 1219 break; | 1243 break; |
| 1220 } | 1244 } |
| 1221 } | 1245 } |
| 1222 | 1246 |
| 1223 m_rootLayerAttachment = attachment; | 1247 m_rootLayerAttachment = attachment; |
| 1224 } | 1248 } |
| 1225 | 1249 |
| 1226 void PaintLayerCompositor::detachRootLayer() { | 1250 void PaintLayerCompositor::detachRootLayer() { |
| 1227 if (!m_rootContentLayer || m_rootLayerAttachment == RootLayerUnattached) | 1251 if (!m_rootContentLayer || m_rootLayerAttachment == RootLayerUnattached) |
| 1228 return; | 1252 return; |
| 1229 | 1253 |
| 1230 switch (m_rootLayerAttachment) { | 1254 switch (m_rootLayerAttachment) { |
| 1231 case RootLayerAttachedViaEnclosingFrame: { | 1255 case RootLayerAttachedViaEnclosingFrame: { |
| 1232 // The layer will get unhooked up via CompositedLayerMapping::updateGraphi
csLayerConfiguration() | 1256 // The layer will get unhooked up via |
| 1233 // for the frame's layoutObject in the parent document. | 1257 // CompositedLayerMapping::updateGraphicsLayerConfiguration() for the |
| 1258 // frame's layoutObject in the parent document. |
| 1234 if (m_overflowControlsHostLayer) | 1259 if (m_overflowControlsHostLayer) |
| 1235 m_overflowControlsHostLayer->removeFromParent(); | 1260 m_overflowControlsHostLayer->removeFromParent(); |
| 1236 else | 1261 else |
| 1237 m_rootContentLayer->removeFromParent(); | 1262 m_rootContentLayer->removeFromParent(); |
| 1238 | 1263 |
| 1239 if (HTMLFrameOwnerElement* ownerElement = | 1264 if (HTMLFrameOwnerElement* ownerElement = |
| 1240 m_layoutView.document().localOwner()) | 1265 m_layoutView.document().localOwner()) |
| 1241 ownerElement->setNeedsCompositingUpdate(); | 1266 ownerElement->setNeedsCompositingUpdate(); |
| 1242 break; | 1267 break; |
| 1243 } | 1268 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 } else if (graphicsLayer == m_scrollLayer.get()) { | 1346 } else if (graphicsLayer == m_scrollLayer.get()) { |
| 1322 name = "Frame Scrolling Layer"; | 1347 name = "Frame Scrolling Layer"; |
| 1323 } else { | 1348 } else { |
| 1324 ASSERT_NOT_REACHED(); | 1349 ASSERT_NOT_REACHED(); |
| 1325 } | 1350 } |
| 1326 | 1351 |
| 1327 return name; | 1352 return name; |
| 1328 } | 1353 } |
| 1329 | 1354 |
| 1330 } // namespace blink | 1355 } // namespace blink |
| OLD | NEW |