| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 if (updateType >= CompositingUpdateAfterCompositingInputChange) | 330 if (updateType >= CompositingUpdateAfterCompositingInputChange) |
| 331 CompositingInputsUpdater(rootLayer()).update(); | 331 CompositingInputsUpdater(rootLayer()).update(); |
| 332 | 332 |
| 333 #if DCHECK_IS_ON() | 333 #if DCHECK_IS_ON() |
| 334 CompositingInputsUpdater::assertNeedsCompositingInputsUpdateBitsCleared( | 334 CompositingInputsUpdater::assertNeedsCompositingInputsUpdateBitsCleared( |
| 335 rootLayer()); | 335 rootLayer()); |
| 336 #endif | 336 #endif |
| 337 } | 337 } |
| 338 | 338 |
| 339 static void forceRecomputeVisualRectsIncludingNonCompositingDescendants( | 339 static void forceRecomputeVisualRectsIncludingNonCompositingDescendants( |
| 340 LayoutObject* layoutObject) { | 340 LayoutObject& layoutObject) { |
| 341 // We clear the previous visual rect as it's wrong (paint invalidation | 341 // We clear the previous visual rect as it's wrong (paint invalidation |
| 342 // container changed, ...). Forcing a full invalidation will make us recompute | 342 // container changed, ...). Forcing a full invalidation will make us recompute |
| 343 // it. Also we are not changing the previous position from our paint | 343 // it. Also we are not changing the previous position from our paint |
| 344 // invalidation container, which is fine as we want a full paint invalidation | 344 // invalidation container, which is fine as we want a full paint invalidation |
| 345 // anyway. | 345 // anyway. |
| 346 layoutObject->clearPreviousVisualRects(); | 346 layoutObject.clearPreviousVisualRects(); |
| 347 | 347 |
| 348 for (LayoutObject* child = layoutObject->slowFirstChild(); child; | 348 for (LayoutObject* child = layoutObject.slowFirstChild(); child; |
| 349 child = child->nextSibling()) { | 349 child = child->nextSibling()) { |
| 350 if (!child->isPaintInvalidationContainer()) | 350 if (!child->isPaintInvalidationContainer()) |
| 351 forceRecomputeVisualRectsIncludingNonCompositingDescendants(child); | 351 forceRecomputeVisualRectsIncludingNonCompositingDescendants(*child); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 void PaintLayerCompositor::updateIfNeeded() { | 355 void PaintLayerCompositor::updateIfNeeded() { |
| 356 CompositingUpdateType updateType = m_pendingUpdateType; | 356 CompositingUpdateType updateType = m_pendingUpdateType; |
| 357 m_pendingUpdateType = CompositingUpdateNone; | 357 m_pendingUpdateType = CompositingUpdateNone; |
| 358 | 358 |
| 359 if (!hasAcceleratedCompositing()) { | 359 if (!hasAcceleratedCompositing()) { |
| 360 updateWithoutAcceleratedCompositing(updateType); | 360 updateWithoutAcceleratedCompositing(updateType); |
| 361 return; | 361 return; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // squashing list of its groupedMapping? Need to create a test where a | 527 // squashing list of its groupedMapping? Need to create a test where a |
| 528 // squashed layer pops into compositing. And also to cover all other sorts | 528 // squashed layer pops into compositing. And also to cover all other sorts |
| 529 // of compositingState transitions. | 529 // of compositingState transitions. |
| 530 layer->setLostGroupedMapping(false); | 530 layer->setLostGroupedMapping(false); |
| 531 layer->setGroupedMapping(nullptr, | 531 layer->setGroupedMapping(nullptr, |
| 532 PaintLayer::InvalidateLayerAndRemoveFromMapping); | 532 PaintLayer::InvalidateLayerAndRemoveFromMapping); |
| 533 | 533 |
| 534 layer->ensureCompositedLayerMapping(); | 534 layer->ensureCompositedLayerMapping(); |
| 535 compositedLayerMappingChanged = true; | 535 compositedLayerMappingChanged = true; |
| 536 | 536 |
| 537 restartAnimationOnCompositor(*layer->layoutObject()); | 537 restartAnimationOnCompositor(layer->layoutObject()); |
| 538 | 538 |
| 539 // At this time, the ScrollingCoordinator only supports the top-level | 539 // At this time, the ScrollingCoordinator only supports the top-level |
| 540 // frame. | 540 // frame. |
| 541 if (layer->isRootLayer() && m_layoutView.frame()->isLocalRoot()) { | 541 if (layer->isRootLayer() && m_layoutView.frame()->isLocalRoot()) { |
| 542 if (ScrollingCoordinator* scrollingCoordinator = | 542 if (ScrollingCoordinator* scrollingCoordinator = |
| 543 this->scrollingCoordinator()) | 543 this->scrollingCoordinator()) |
| 544 scrollingCoordinator->frameViewRootLayerDidChange( | 544 scrollingCoordinator->frameViewRootLayerDidChange( |
| 545 m_layoutView.frameView()); | 545 m_layoutView.frameView()); |
| 546 } | 546 } |
| 547 break; | 547 break; |
| 548 case RemoveOwnCompositedLayerMapping: | 548 case RemoveOwnCompositedLayerMapping: |
| 549 // PutInSquashingLayer means you might have to remove the composited layer | 549 // PutInSquashingLayer means you might have to remove the composited layer |
| 550 // mapping first. | 550 // mapping first. |
| 551 case PutInSquashingLayer: | 551 case PutInSquashingLayer: |
| 552 if (layer->hasCompositedLayerMapping()) { | 552 if (layer->hasCompositedLayerMapping()) { |
| 553 layer->clearCompositedLayerMapping(); | 553 layer->clearCompositedLayerMapping(); |
| 554 compositedLayerMappingChanged = true; | 554 compositedLayerMappingChanged = true; |
| 555 } | 555 } |
| 556 | 556 |
| 557 break; | 557 break; |
| 558 case RemoveFromSquashingLayer: | 558 case RemoveFromSquashingLayer: |
| 559 case NoCompositingStateChange: | 559 case NoCompositingStateChange: |
| 560 // Do nothing. | 560 // Do nothing. |
| 561 break; | 561 break; |
| 562 } | 562 } |
| 563 | 563 |
| 564 if (compositedLayerMappingChanged && layer->layoutObject()->isLayoutPart()) { | 564 if (compositedLayerMappingChanged && layer->layoutObject().isLayoutPart()) { |
| 565 PaintLayerCompositor* innerCompositor = | 565 PaintLayerCompositor* innerCompositor = |
| 566 frameContentsCompositor(toLayoutPart(layer->layoutObject())); | 566 frameContentsCompositor(toLayoutPart(layer->layoutObject())); |
| 567 if (innerCompositor && innerCompositor->staleInCompositingMode()) | 567 if (innerCompositor && innerCompositor->staleInCompositingMode()) |
| 568 innerCompositor->updateRootLayerAttachment(); | 568 innerCompositor->updateRootLayerAttachment(); |
| 569 } | 569 } |
| 570 | 570 |
| 571 if (compositedLayerMappingChanged) { | 571 if (compositedLayerMappingChanged) { |
| 572 layer->clipper(PaintLayer::DoNotUseGeometryMapper) | 572 layer->clipper(PaintLayer::DoNotUseGeometryMapper) |
| 573 .clearClipRectsIncludingDescendants(PaintingClipRects); | 573 .clearClipRectsIncludingDescendants(PaintingClipRects); |
| 574 } | 574 } |
| 575 | 575 |
| 576 // If a fixed position layer gained/lost a compositedLayerMapping or the | 576 // If a fixed position layer gained/lost a compositedLayerMapping or the |
| 577 // reason not compositing it changed, the scrolling coordinator needs to | 577 // reason not compositing it changed, the scrolling coordinator needs to |
| 578 // recalculate whether it can do fast scrolling. | 578 // recalculate whether it can do fast scrolling. |
| 579 if (compositedLayerMappingChanged) { | 579 if (compositedLayerMappingChanged) { |
| 580 if (ScrollingCoordinator* scrollingCoordinator = | 580 if (ScrollingCoordinator* scrollingCoordinator = |
| 581 this->scrollingCoordinator()) | 581 this->scrollingCoordinator()) |
| 582 scrollingCoordinator->frameViewFixedObjectsDidChange( | 582 scrollingCoordinator->frameViewFixedObjectsDidChange( |
| 583 m_layoutView.frameView()); | 583 m_layoutView.frameView()); |
| 584 } | 584 } |
| 585 | 585 |
| 586 return compositedLayerMappingChanged; | 586 return compositedLayerMappingChanged; |
| 587 } | 587 } |
| 588 | 588 |
| 589 void PaintLayerCompositor::paintInvalidationOnCompositingChange( | 589 void PaintLayerCompositor::paintInvalidationOnCompositingChange( |
| 590 PaintLayer* layer) { | 590 PaintLayer* layer) { |
| 591 // If the layoutObject is not attached yet, no need to issue paint | 591 // If the layoutObject is not attached yet, no need to issue paint |
| 592 // invalidations. | 592 // invalidations. |
| 593 if (layer->layoutObject() != &m_layoutView && | 593 if (&layer->layoutObject() != &m_layoutView && |
| 594 !layer->layoutObject()->parent()) | 594 !layer->layoutObject().parent()) |
| 595 return; | 595 return; |
| 596 | 596 |
| 597 // For querying Layer::compositingState() | 597 // For querying Layer::compositingState() |
| 598 // Eager invalidation here is correct, since we are invalidating with respect | 598 // Eager invalidation here is correct, since we are invalidating with respect |
| 599 // to the previous frame's compositing state when changing the compositing | 599 // to the previous frame's compositing state when changing the compositing |
| 600 // backing of the layer. | 600 // backing of the layer. |
| 601 DisableCompositingQueryAsserts disabler; | 601 DisableCompositingQueryAsserts disabler; |
| 602 // FIXME: We should not allow paint invalidation out of paint invalidation | 602 // FIXME: We should not allow paint invalidation out of paint invalidation |
| 603 // state. crbug.com/457415 | 603 // state. crbug.com/457415 |
| 604 DisablePaintInvalidationStateAsserts paintInvalidationAssertisabler; | 604 DisablePaintInvalidationStateAsserts paintInvalidationAssertisabler; |
| 605 | 605 |
| 606 ObjectPaintInvalidator(*layer->layoutObject()) | 606 ObjectPaintInvalidator(layer->layoutObject()) |
| 607 .invalidatePaintIncludingNonCompositingDescendants(); | 607 .invalidatePaintIncludingNonCompositingDescendants(); |
| 608 } | 608 } |
| 609 | 609 |
| 610 void PaintLayerCompositor::frameViewDidChangeLocation( | 610 void PaintLayerCompositor::frameViewDidChangeLocation( |
| 611 const IntPoint& contentsOffset) { | 611 const IntPoint& contentsOffset) { |
| 612 if (m_overflowControlsHostLayer) | 612 if (m_overflowControlsHostLayer) |
| 613 m_overflowControlsHostLayer->setPosition(contentsOffset); | 613 m_overflowControlsHostLayer->setPosition(contentsOffset); |
| 614 } | 614 } |
| 615 | 615 |
| 616 void PaintLayerCompositor::updateContainerSizes() { | 616 void PaintLayerCompositor::updateContainerSizes() { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 rootLayer = rootLayer->parent(); | 727 rootLayer = rootLayer->parent(); |
| 728 } else { | 728 } else { |
| 729 rootLayer = rootGraphicsLayer(); | 729 rootLayer = rootGraphicsLayer(); |
| 730 } | 730 } |
| 731 } | 731 } |
| 732 | 732 |
| 733 return rootLayer->layerTreeAsJSON(flags); | 733 return rootLayer->layerTreeAsJSON(flags); |
| 734 } | 734 } |
| 735 | 735 |
| 736 PaintLayerCompositor* PaintLayerCompositor::frameContentsCompositor( | 736 PaintLayerCompositor* PaintLayerCompositor::frameContentsCompositor( |
| 737 LayoutPart* layoutObject) { | 737 LayoutPart& layoutObject) { |
| 738 if (!layoutObject->node()->isFrameOwnerElement()) | 738 if (!layoutObject.node()->isFrameOwnerElement()) |
| 739 return nullptr; | 739 return nullptr; |
| 740 | 740 |
| 741 HTMLFrameOwnerElement* element = | 741 HTMLFrameOwnerElement* element = toHTMLFrameOwnerElement(layoutObject.node()); |
| 742 toHTMLFrameOwnerElement(layoutObject->node()); | |
| 743 if (Document* contentDocument = element->contentDocument()) { | 742 if (Document* contentDocument = element->contentDocument()) { |
| 744 if (LayoutViewItem view = contentDocument->layoutViewItem()) | 743 if (LayoutViewItem view = contentDocument->layoutViewItem()) |
| 745 return view.compositor(); | 744 return view.compositor(); |
| 746 } | 745 } |
| 747 return nullptr; | 746 return nullptr; |
| 748 } | 747 } |
| 749 | 748 |
| 750 bool PaintLayerCompositor::attachFrameContentLayersToIframeLayer( | 749 bool PaintLayerCompositor::attachFrameContentLayersToIframeLayer( |
| 751 LayoutPart* layoutObject) { | 750 LayoutPart& layoutObject) { |
| 752 PaintLayerCompositor* innerCompositor = frameContentsCompositor(layoutObject); | 751 PaintLayerCompositor* innerCompositor = frameContentsCompositor(layoutObject); |
| 753 if (!innerCompositor || !innerCompositor->staleInCompositingMode() || | 752 if (!innerCompositor || !innerCompositor->staleInCompositingMode() || |
| 754 innerCompositor->getRootLayerAttachment() != | 753 innerCompositor->getRootLayerAttachment() != |
| 755 RootLayerAttachedViaEnclosingFrame) | 754 RootLayerAttachedViaEnclosingFrame) |
| 756 return false; | 755 return false; |
| 757 | 756 |
| 758 PaintLayer* layer = layoutObject->layer(); | 757 PaintLayer* layer = layoutObject.layer(); |
| 759 if (!layer->hasCompositedLayerMapping()) | 758 if (!layer->hasCompositedLayerMapping()) |
| 760 return false; | 759 return false; |
| 761 | 760 |
| 762 layer->compositedLayerMapping()->setSublayers( | 761 layer->compositedLayerMapping()->setSublayers( |
| 763 GraphicsLayerVector(1, innerCompositor->rootGraphicsLayer())); | 762 GraphicsLayerVector(1, innerCompositor->rootGraphicsLayer())); |
| 764 return true; | 763 return true; |
| 765 } | 764 } |
| 766 | 765 |
| 767 static void fullyInvalidatePaintRecursive(PaintLayer* layer) { | 766 static void fullyInvalidatePaintRecursive(PaintLayer* layer) { |
| 768 if (layer->compositingState() == PaintsIntoOwnBacking) { | 767 if (layer->compositingState() == PaintsIntoOwnBacking) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 } | 848 } |
| 850 | 849 |
| 851 void PaintLayerCompositor::updatePotentialCompositingReasonsFromStyle( | 850 void PaintLayerCompositor::updatePotentialCompositingReasonsFromStyle( |
| 852 PaintLayer* layer) { | 851 PaintLayer* layer) { |
| 853 layer->setPotentialCompositingReasonsFromStyle( | 852 layer->setPotentialCompositingReasonsFromStyle( |
| 854 m_compositingReasonFinder.potentialCompositingReasonsFromStyle( | 853 m_compositingReasonFinder.potentialCompositingReasonsFromStyle( |
| 855 layer->layoutObject())); | 854 layer->layoutObject())); |
| 856 } | 855 } |
| 857 | 856 |
| 858 bool PaintLayerCompositor::canBeComposited(const PaintLayer* layer) const { | 857 bool PaintLayerCompositor::canBeComposited(const PaintLayer* layer) const { |
| 859 FrameView* frameView = layer->layoutObject()->frameView(); | 858 FrameView* frameView = layer->layoutObject().frameView(); |
| 860 // Elements within an invisible frame must not be composited because they are | 859 // Elements within an invisible frame must not be composited because they are |
| 861 // not drawn. | 860 // not drawn. |
| 862 if (frameView && !frameView->isVisible()) | 861 if (frameView && !frameView->isVisible()) |
| 863 return false; | 862 return false; |
| 864 | 863 |
| 865 const bool hasCompositorAnimation = | 864 const bool hasCompositorAnimation = |
| 866 m_compositingReasonFinder.requiresCompositingForAnimation( | 865 m_compositingReasonFinder.requiresCompositingForAnimation( |
| 867 *layer->layoutObject()->style()); | 866 *layer->layoutObject().style()); |
| 868 return m_hasAcceleratedCompositing && | 867 return m_hasAcceleratedCompositing && |
| 869 (hasCompositorAnimation || !layer->subtreeIsInvisible()) && | 868 (hasCompositorAnimation || !layer->subtreeIsInvisible()) && |
| 870 layer->isSelfPaintingLayer() && | 869 layer->isSelfPaintingLayer() && |
| 871 !layer->layoutObject()->isLayoutFlowThread(); | 870 !layer->layoutObject().isLayoutFlowThread(); |
| 872 } | 871 } |
| 873 | 872 |
| 874 // Return true if the given layer is a stacking context and has compositing | 873 // Return true if the given layer is a stacking context and has compositing |
| 875 // child layers that it needs to clip. In this case we insert a clipping | 874 // child layers that it needs to clip. In this case we insert a clipping |
| 876 // GraphicsLayer into the hierarchy between this layer and its children in the | 875 // GraphicsLayer into the hierarchy between this layer and its children in the |
| 877 // z-order hierarchy. | 876 // z-order hierarchy. |
| 878 bool PaintLayerCompositor::clipsCompositingDescendants( | 877 bool PaintLayerCompositor::clipsCompositingDescendants( |
| 879 const PaintLayer* layer) const { | 878 const PaintLayer* layer) const { |
| 880 return layer->hasCompositingDescendant() && | 879 return layer->hasCompositingDescendant() && |
| 881 layer->layoutObject()->hasClipRelatedProperty(); | 880 layer->layoutObject().hasClipRelatedProperty(); |
| 882 } | 881 } |
| 883 | 882 |
| 884 // If an element has composited negative z-index children, those children paint | 883 // If an element has composited negative z-index children, those children paint |
| 885 // in front of the layer background, so we need an extra 'contents' layer for | 884 // in front of the layer background, so we need an extra 'contents' layer for |
| 886 // the foreground of the layer object. | 885 // the foreground of the layer object. |
| 887 bool PaintLayerCompositor::needsContentsCompositingLayer( | 886 bool PaintLayerCompositor::needsContentsCompositingLayer( |
| 888 const PaintLayer* layer) const { | 887 const PaintLayer* layer) const { |
| 889 if (!layer->hasCompositingDescendant()) | 888 if (!layer->hasCompositingDescendant()) |
| 890 return false; | 889 return false; |
| 891 return layer->stackingNode()->hasNegativeZOrderList(); | 890 return layer->stackingNode()->hasNegativeZOrderList(); |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 } else if (graphicsLayer == m_scrollLayer.get()) { | 1347 } else if (graphicsLayer == m_scrollLayer.get()) { |
| 1349 name = "Frame Scrolling Layer"; | 1348 name = "Frame Scrolling Layer"; |
| 1350 } else { | 1349 } else { |
| 1351 ASSERT_NOT_REACHED(); | 1350 ASSERT_NOT_REACHED(); |
| 1352 } | 1351 } |
| 1353 | 1352 |
| 1354 return name; | 1353 return name; |
| 1355 } | 1354 } |
| 1356 | 1355 |
| 1357 } // namespace blink | 1356 } // namespace blink |
| OLD | NEW |