| 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 if (needsToUpdateScrollingCoordinator && isMainFrame() && scrollingCoordinat
or() && inCompositingMode()) | 493 if (needsToUpdateScrollingCoordinator && isMainFrame() && scrollingCoordinat
or() && inCompositingMode()) |
| 494 scrollingCoordinator()->updateAfterCompositingChange(); | 494 scrollingCoordinator()->updateAfterCompositingChange(); |
| 495 | 495 |
| 496 // Inform the inspector that the layer tree has changed. | 496 // Inform the inspector that the layer tree has changed. |
| 497 if (isMainFrame()) | 497 if (isMainFrame()) |
| 498 InspectorInstrumentation::layerTreeDidChange(page()); | 498 InspectorInstrumentation::layerTreeDidChange(page()); |
| 499 } | 499 } |
| 500 | 500 |
| 501 static bool requiresCompositing(CompositingReasons reasons) | 501 static bool requiresCompositing(CompositingReasons reasons) |
| 502 { | 502 { |
| 503 // Any reasons other than overlap or assumed overlap will require the layer
to be separately compositing. |
| 504 return reasons & ~CompositingReasonComboAllOverlapReasons; |
| 505 } |
| 506 |
| 507 static bool requiresSquashing(CompositingReasons reasons) |
| 508 { |
| 509 // If the layer has overlap or assumed overlap, but no other reasons, then i
t should be squashed. |
| 510 return !requiresCompositing(reasons) && (reasons & CompositingReasonComboAll
OverlapReasons); |
| 511 } |
| 512 |
| 513 static bool requiresCompositingOrSquashing(CompositingReasons reasons) |
| 514 { |
| 515 #ifndef NDEBUG |
| 516 bool fastAnswer = reasons != CompositingReasonNone; |
| 517 bool slowAnswer = requiresCompositing(reasons) || requiresSquashing(reasons)
; |
| 518 ASSERT(fastAnswer == slowAnswer); |
| 519 #endif |
| 503 return reasons != CompositingReasonNone; | 520 return reasons != CompositingReasonNone; |
| 504 } | 521 } |
| 505 | 522 |
| 506 void RenderLayerCompositor::addOutOfFlowPositionedLayer(RenderLayer* layer) | 523 void RenderLayerCompositor::addOutOfFlowPositionedLayer(RenderLayer* layer) |
| 507 { | 524 { |
| 508 m_outOfFlowPositionedLayers.add(layer); | 525 m_outOfFlowPositionedLayers.add(layer); |
| 509 } | 526 } |
| 510 | 527 |
| 511 void RenderLayerCompositor::removeOutOfFlowPositionedLayer(RenderLayer* layer) | 528 void RenderLayerCompositor::removeOutOfFlowPositionedLayer(RenderLayer* layer) |
| 512 { | 529 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 531 | 548 |
| 532 layer->ensureCompositedLayerMapping(); | 549 layer->ensureCompositedLayerMapping(); |
| 533 compositedLayerMappingChanged = true; | 550 compositedLayerMappingChanged = true; |
| 534 | 551 |
| 535 // At this time, the ScrollingCooridnator only supports the top-leve
l frame. | 552 // At this time, the ScrollingCooridnator only supports the top-leve
l frame. |
| 536 if (layer->isRootLayer() && isMainFrame()) { | 553 if (layer->isRootLayer() && isMainFrame()) { |
| 537 if (ScrollingCoordinator* scrollingCoordinator = this->scrolling
Coordinator()) | 554 if (ScrollingCoordinator* scrollingCoordinator = this->scrolling
Coordinator()) |
| 538 scrollingCoordinator->frameViewRootLayerDidChange(m_renderVi
ew->frameView()); | 555 scrollingCoordinator->frameViewRootLayerDidChange(m_renderVi
ew->frameView()); |
| 539 } | 556 } |
| 540 | 557 |
| 558 // If this layer was previously squashed, we need to remove its refe
rence to a groupedMapping right away, so |
| 559 // that computing repaint rects will know the layer's correct compos
itingState. |
| 560 // FIXME: do we need to also remove the layer from it's location in
the squashing list of its groupedMapping? |
| 561 // Need to create a test where a squashed layer pops into compositin
g. And also to cover all other |
| 562 // sorts of compositingState transitions. |
| 563 layer->setGroupedMapping(0); |
| 564 |
| 565 // FIXME: it seems premature to compute this before all compositing
state has been updated? |
| 541 // This layer and all of its descendants have cached repaints rects
that are relative to | 566 // This layer and all of its descendants have cached repaints rects
that are relative to |
| 542 // the repaint container, so change when compositing changes; we nee
d to update them here. | 567 // the repaint container, so change when compositing changes; we nee
d to update them here. |
| 543 if (layer->parent()) | 568 if (layer->parent()) |
| 544 layer->repainter().computeRepaintRectsIncludingDescendants(); | 569 layer->repainter().computeRepaintRectsIncludingDescendants(); |
| 545 } | 570 } |
| 546 | 571 |
| 547 if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForInt
rinsicReasons()) | 572 if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForInt
rinsicReasons()) |
| 548 compositedLayerMappingChanged = true; | 573 compositedLayerMappingChanged = true; |
| 549 } else { | 574 } else { |
| 550 if (layer->hasCompositedLayerMapping()) { | 575 if (layer->hasCompositedLayerMapping()) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 } | 622 } |
| 598 | 623 |
| 599 return compositedLayerMappingChanged || nonCompositedReasonChanged; | 624 return compositedLayerMappingChanged || nonCompositedReasonChanged; |
| 600 } | 625 } |
| 601 | 626 |
| 602 bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer) | 627 bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer) |
| 603 { | 628 { |
| 604 updateDirectCompositingReasons(layer); | 629 updateDirectCompositingReasons(layer); |
| 605 bool layerChanged = allocateOrClearCompositedLayerMapping(layer); | 630 bool layerChanged = allocateOrClearCompositedLayerMapping(layer); |
| 606 | 631 |
| 632 if (isLayerSquashingEnabled()) { |
| 633 // FIXME: this is not correct... info may be out of date and squashing r
eturning true doesn't indicate that the layer changed |
| 634 layerChanged = requiresSquashing(layer->compositingReasons()); |
| 635 } |
| 636 |
| 607 // See if we need content or clipping layers. Methods called here should ass
ume | 637 // See if we need content or clipping layers. Methods called here should ass
ume |
| 608 // that the compositing state of descendant layers has not been updated yet. | 638 // that the compositing state of descendant layers has not been updated yet. |
| 609 if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->u
pdateGraphicsLayerConfiguration()) | 639 if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->u
pdateGraphicsLayerConfiguration()) |
| 610 layerChanged = true; | 640 layerChanged = true; |
| 611 | 641 |
| 612 return layerChanged; | 642 return layerChanged; |
| 613 } | 643 } |
| 614 | 644 |
| 615 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer) | 645 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer) |
| 616 { | 646 { |
| 617 // If the renderer is not attached yet, no need to repaint. | 647 // If the renderer is not attached yet, no need to repaint. |
| 618 if (layer->renderer() != m_renderView && !layer->renderer()->parent()) | 648 if (layer->renderer() != m_renderView && !layer->renderer()->parent()) |
| 619 return; | 649 return; |
| 620 | 650 |
| 621 RenderLayerModelObject* repaintContainer = layer->renderer()->containerForRe
paint(); | 651 RenderLayerModelObject* repaintContainer = layer->renderer()->containerForRe
paint(); |
| 622 if (!repaintContainer) | 652 if (!repaintContainer) |
| 623 repaintContainer = m_renderView; | 653 repaintContainer = m_renderView; |
| 624 | 654 |
| 625 layer->repainter().repaintIncludingNonCompositingDescendants(repaintContaine
r); | 655 layer->repainter().repaintIncludingNonCompositingDescendants(repaintContaine
r); |
| 626 } | 656 } |
| 627 | 657 |
| 628 // This method assumes that layout is up-to-date, unlike repaintOnCompositingCha
nge(). | 658 // This method assumes that layout is up-to-date, unlike repaintOnCompositingCha
nge(). |
| 629 void RenderLayerCompositor::repaintInCompositedAncestor(RenderLayer* layer, cons
t LayoutRect& rect) | 659 void RenderLayerCompositor::repaintInCompositedAncestor(RenderLayer* layer, cons
t LayoutRect& rect) |
| 630 { | 660 { |
| 631 RenderLayer* compositedAncestor = layer->enclosingCompositingLayerForRepaint
(false /*exclude self*/); | 661 RenderLayer* compositedAncestor = layer->enclosingCompositingLayerForRepaint
(false /*exclude self*/); |
| 632 if (compositedAncestor) { | 662 if (compositedAncestor) { |
| 633 ASSERT(compositedAncestor->compositingState() == PaintsIntoOwnBacking); | 663 // FIXME: make sure repaintRect is computed correctly for squashed scena
rio |
| 634 | |
| 635 LayoutPoint offset; | 664 LayoutPoint offset; |
| 636 layer->convertToLayerCoords(compositedAncestor, offset); | 665 layer->convertToLayerCoords(compositedAncestor, offset); |
| 637 | 666 |
| 638 LayoutRect repaintRect = rect; | 667 LayoutRect repaintRect = rect; |
| 639 repaintRect.moveBy(offset); | 668 repaintRect.moveBy(offset); |
| 640 | 669 |
| 641 compositedAncestor->repainter().setBackingNeedsRepaintInRect(repaintRect
); | 670 if (compositedAncestor->compositingState() == PaintsIntoOwnBacking) { |
| 671 compositedAncestor->repainter().setBackingNeedsRepaintInRect(repaint
Rect); |
| 672 } else if (compositedAncestor->compositingState() == PaintsIntoGroupedBa
cking) { |
| 673 // FIXME: Need to perform the correct coordinate conversion for repa
intRect here, including transforms |
| 674 compositedAncestor->groupedMapping()->squashingLayer()->setNeedsDisp
layInRect(repaintRect); |
| 675 } else { |
| 676 ASSERT_NOT_REACHED(); |
| 677 } |
| 642 } | 678 } |
| 643 } | 679 } |
| 644 | 680 |
| 645 // The bounds of the GraphicsLayer created for a compositing layer is the union
of the bounds of all the descendant | 681 // The bounds of the GraphicsLayer created for a compositing layer is the union
of the bounds of all the descendant |
| 646 // RenderLayers that are rendered by the composited RenderLayer. | 682 // RenderLayers that are rendered by the composited RenderLayer. |
| 647 IntRect RenderLayerCompositor::calculateCompositedBounds(const RenderLayer* laye
r, const RenderLayer* ancestorLayer) const | 683 IntRect RenderLayerCompositor::calculateCompositedBounds(const RenderLayer* laye
r, const RenderLayer* ancestorLayer) const |
| 648 { | 684 { |
| 649 if (!canBeComposited(layer)) | 685 if (!canBeComposited(layer)) |
| 650 return IntRect(); | 686 return IntRect(); |
| 651 | 687 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 for (size_t i = 0; i < unclippedDescendantsToRemove.size(); i++) | 830 for (size_t i = 0; i < unclippedDescendantsToRemove.size(); i++) |
| 795 unclippedDescendants.remove(unclippedDescendantsToRemove.at(unclippe
dDescendantsToRemove.size() - i - 1)); | 831 unclippedDescendants.remove(unclippedDescendantsToRemove.at(unclippe
dDescendantsToRemove.size() - i - 1)); |
| 796 | 832 |
| 797 if (reasonsToComposite & CompositingReasonOutOfFlowClipping) | 833 if (reasonsToComposite & CompositingReasonOutOfFlowClipping) |
| 798 unclippedDescendants.append(layer); | 834 unclippedDescendants.append(layer); |
| 799 } | 835 } |
| 800 | 836 |
| 801 bool haveComputedBounds = false; | 837 bool haveComputedBounds = false; |
| 802 IntRect absBounds; | 838 IntRect absBounds; |
| 803 // If we know for sure the layer is going to be composited, don't bother loo
king it up in the overlap map. | 839 // If we know for sure the layer is going to be composited, don't bother loo
king it up in the overlap map. |
| 804 if (overlapMap && !overlapMap->isEmpty() && currentRecursionData.m_testingOv
erlap && !requiresCompositing(directReasons)) { | 840 if (overlapMap && !overlapMap->isEmpty() && currentRecursionData.m_testingOv
erlap && !requiresCompositingOrSquashing(directReasons)) { |
| 805 // If we're testing for overlap, we only need to composite if we overlap
something that is already composited. | 841 // If we're testing for overlap, we only need to composite if we overlap
something that is already composited. |
| 806 absBounds = enclosingIntRect(overlapMap->geometryMap().absoluteRect(laye
r->overlapBounds())); | 842 absBounds = enclosingIntRect(overlapMap->geometryMap().absoluteRect(laye
r->overlapBounds())); |
| 807 | 843 |
| 808 // Empty rects never intersect, but we need them to for the purposes of
overlap testing. | 844 // Empty rects never intersect, but we need them to for the purposes of
overlap testing. |
| 809 if (absBounds.isEmpty()) | 845 if (absBounds.isEmpty()) |
| 810 absBounds.setSize(IntSize(1, 1)); | 846 absBounds.setSize(IntSize(1, 1)); |
| 811 haveComputedBounds = true; | 847 haveComputedBounds = true; |
| 812 overlapCompositingReason = overlapMap->overlapsLayers(absBounds) ? Compo
sitingReasonOverlap : CompositingReasonNone; | 848 overlapCompositingReason = overlapMap->overlapsLayers(absBounds) ? Compo
sitingReasonOverlap : CompositingReasonNone; |
| 813 } | 849 } |
| 814 | 850 |
| 815 reasonsToComposite |= overlapCompositingReason; | 851 reasonsToComposite |= overlapCompositingReason; |
| 816 | 852 |
| 817 // The children of this layer don't need to composite, unless there is | 853 // The children of this layer don't need to composite, unless there is |
| 818 // a compositing layer among them, so start by inheriting the compositing | 854 // a compositing layer among them, so start by inheriting the compositing |
| 819 // ancestor with m_subtreeIsCompositing set to false. | 855 // ancestor with m_subtreeIsCompositing set to false. |
| 820 CompositingRecursionData childRecursionData(currentRecursionData); | 856 CompositingRecursionData childRecursionData(currentRecursionData); |
| 821 childRecursionData.m_subtreeIsCompositing = false; | 857 childRecursionData.m_subtreeIsCompositing = false; |
| 822 | 858 |
| 823 bool willBeComposited = canBeComposited(layer) && requiresCompositing(reason
sToComposite); | 859 bool willBeComposited = canBeComposited(layer) && requiresCompositingOrSquas
hing(reasonsToComposite); |
| 824 if (willBeComposited) { | 860 if (willBeComposited) { |
| 825 // Tell the parent it has compositing descendants. | 861 // Tell the parent it has compositing descendants. |
| 826 currentRecursionData.m_subtreeIsCompositing = true; | 862 currentRecursionData.m_subtreeIsCompositing = true; |
| 827 // This layer now acts as the ancestor for kids. | 863 // This layer now acts as the ancestor for kids. |
| 828 childRecursionData.m_compositingAncestor = layer; | 864 childRecursionData.m_compositingAncestor = layer; |
| 829 | 865 |
| 830 // Here we know that all children and the layer's own contents can blind
ly paint into | 866 // Here we know that all children and the layer's own contents can blind
ly paint into |
| 831 // this layer's backing, until a descendant is composited. So, we don't
need to check | 867 // this layer's backing, until a descendant is composited. So, we don't
need to check |
| 832 // for overlap with anything behind this layer. | 868 // for overlap with anything behind this layer. |
| 833 if (overlapMap) | 869 if (overlapMap) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 if (layer->stackingNode()->isStackingContext()) { | 948 if (layer->stackingNode()->isStackingContext()) { |
| 913 layer->setShouldIsolateCompositedDescendants(childRecursionData.m_hasUni
solatedCompositedBlendingDescendant); | 949 layer->setShouldIsolateCompositedDescendants(childRecursionData.m_hasUni
solatedCompositedBlendingDescendant); |
| 914 } else { | 950 } else { |
| 915 layer->setShouldIsolateCompositedDescendants(false); | 951 layer->setShouldIsolateCompositedDescendants(false); |
| 916 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = child
RecursionData.m_hasUnisolatedCompositedBlendingDescendant; | 952 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = child
RecursionData.m_hasUnisolatedCompositedBlendingDescendant; |
| 917 } | 953 } |
| 918 | 954 |
| 919 // Now check for reasons to become composited that depend on the state of de
scendant layers. | 955 // Now check for reasons to become composited that depend on the state of de
scendant layers. |
| 920 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing(
layer->renderer(), childRecursionData.m_subtreeIsCompositing, anyDescendantHas3D
Transform); | 956 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing(
layer->renderer(), childRecursionData.m_subtreeIsCompositing, anyDescendantHas3D
Transform); |
| 921 reasonsToComposite |= subtreeCompositingReasons; | 957 reasonsToComposite |= subtreeCompositingReasons; |
| 922 if (!willBeComposited && canBeComposited(layer) && requiresCompositing(subtr
eeCompositingReasons)) { | 958 if (!willBeComposited && canBeComposited(layer) && requiresCompositingOrSqua
shing(subtreeCompositingReasons)) { |
| 923 childRecursionData.m_compositingAncestor = layer; | 959 childRecursionData.m_compositingAncestor = layer; |
| 924 if (overlapMap) { | 960 if (overlapMap) { |
| 925 // FIXME: this context push is effectively a no-op but needs to exis
t for | 961 // FIXME: this context push is effectively a no-op but needs to exis
t for |
| 926 // now, because the code is designed to push overlap information to
the | 962 // now, because the code is designed to push overlap information to
the |
| 927 // second-from-top context of the stack. | 963 // second-from-top context of the stack. |
| 928 overlapMap->beginNewOverlapTestingContext(); | 964 overlapMap->beginNewOverlapTestingContext(); |
| 929 addToOverlapMapRecursive(*overlapMap, layer); | 965 addToOverlapMapRecursive(*overlapMap, layer); |
| 930 } | 966 } |
| 931 willBeComposited = true; | 967 willBeComposited = true; |
| 932 } | 968 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 954 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi
te & CompositingReasonClipsCompositingDescendants); | 990 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi
te & CompositingReasonClipsCompositingDescendants); |
| 955 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) ||
isRunningAcceleratedTransformAnimation(layer->renderer())) | 991 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) ||
isRunningAcceleratedTransformAnimation(layer->renderer())) |
| 956 currentRecursionData.m_testingOverlap = false; | 992 currentRecursionData.m_testingOverlap = false; |
| 957 | 993 |
| 958 if (overlapMap && childRecursionData.m_compositingAncestor == layer && !laye
r->isRootLayer()) | 994 if (overlapMap && childRecursionData.m_compositingAncestor == layer && !laye
r->isRootLayer()) |
| 959 overlapMap->finishCurrentOverlapTestingContext(); | 995 overlapMap->finishCurrentOverlapTestingContext(); |
| 960 | 996 |
| 961 if (layer->isRootLayer()) { | 997 if (layer->isRootLayer()) { |
| 962 // The root layer needs to be composited if anything else in the tree is
composited. | 998 // The root layer needs to be composited if anything else in the tree is
composited. |
| 963 // Otherwise, we can disable compositing entirely. | 999 // Otherwise, we can disable compositing entirely. |
| 964 if (childRecursionData.m_subtreeIsCompositing || requiresCompositing(rea
sonsToComposite) || m_forceCompositingMode) { | 1000 if (childRecursionData.m_subtreeIsCompositing || requiresCompositingOrSq
uashing(reasonsToComposite) || m_forceCompositingMode) { |
| 965 willBeComposited = true; | 1001 willBeComposited = true; |
| 966 reasonsToComposite |= CompositingReasonRoot; | 1002 reasonsToComposite |= CompositingReasonRoot; |
| 967 } else { | 1003 } else { |
| 968 enableCompositingMode(false); | 1004 enableCompositingMode(false); |
| 969 willBeComposited = false; | 1005 willBeComposited = false; |
| 970 reasonsToComposite = CompositingReasonNone; | 1006 reasonsToComposite = CompositingReasonNone; |
| 971 } | 1007 } |
| 972 } | 1008 } |
| 973 | 1009 |
| 974 // At this point we have finished collecting all reasons to composite this l
ayer. | 1010 // At this point we have finished collecting all reasons to composite this l
ayer. |
| 975 layer->setCompositingReasons(reasonsToComposite); | 1011 layer->setCompositingReasons(reasonsToComposite); |
| 976 | 1012 |
| 977 if (!willBeComposited && layer->parent()) | 1013 if (!willBeComposited && layer->parent()) |
| 978 layer->parent()->setHasNonCompositedChild(true); | 1014 layer->parent()->setHasNonCompositedChild(true); |
| 979 | 1015 |
| 980 descendantHas3DTransform |= anyDescendantHas3DTransform || layer->has3DTrans
form(); | 1016 descendantHas3DTransform |= anyDescendantHas3DTransform || layer->has3DTrans
form(); |
| 981 | 1017 |
| 982 if (overlapMap) | 1018 if (overlapMap) |
| 983 overlapMap->geometryMap().popMappingsToAncestor(ancestorLayer); | 1019 overlapMap->geometryMap().popMappingsToAncestor(ancestorLayer); |
| 984 } | 1020 } |
| 985 | 1021 |
| 986 void RenderLayerCompositor::assignLayersToBackings(RenderLayer* layer, bool& lay
ersChanged) | 1022 void RenderLayerCompositor::SquashingState::updateSquashingStateForNewMapping(Co
mpositedLayerMappingPtr newCompositedLayerMapping, bool hasNewCompositedLayerMap
ping, IntPoint newOffsetFromAbsolute) |
| 987 { | 1023 { |
| 988 // FIXME: squashing state will be added internally here. | 1024 // The most recent backing is done accumulating any more squashing layers. |
| 989 assignLayersToBackingsInternal(layer, layersChanged); | 1025 if (hasMostRecentMapping) |
| 1026 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn
dex); |
| 1027 |
| 1028 nextSquashedLayerIndex = 0; |
| 1029 mostRecentMapping = newCompositedLayerMapping; |
| 1030 hasMostRecentMapping = hasNewCompositedLayerMapping; |
| 1031 offsetFromAbsolute = newOffsetFromAbsolute; |
| 990 } | 1032 } |
| 991 | 1033 |
| 992 void RenderLayerCompositor::assignLayersToBackingsInternal(RenderLayer* layer, b
ool& layersChanged) | 1034 static IntPoint computeOffsetFromAbsolute(RenderLayer* layer) |
| 1035 { |
| 1036 TransformState transformState(TransformState::ApplyTransformDirection, Float
Point()); |
| 1037 layer->renderer()->mapLocalToContainer(0, transformState, ApplyContainerFlip
); |
| 1038 transformState.flatten(); |
| 1039 return roundedIntPoint(transformState.lastPlanarPoint()); |
| 1040 } |
| 1041 |
| 1042 void RenderLayerCompositor::assignLayersToBackings(RenderLayer* updateRoot, bool
& layersChanged) |
| 1043 { |
| 1044 SquashingState squashingState; |
| 1045 assignLayersToBackingsInternal(updateRoot, squashingState, layersChanged); |
| 1046 if (squashingState.hasMostRecentMapping) |
| 1047 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa
shingState.nextSquashedLayerIndex); |
| 1048 } |
| 1049 |
| 1050 void RenderLayerCompositor::assignLayersToBackingsInternal(RenderLayer* layer, S
quashingState& squashingState, bool& layersChanged) |
| 993 { | 1051 { |
| 994 if (allocateOrClearCompositedLayerMapping(layer)) | 1052 if (allocateOrClearCompositedLayerMapping(layer)) |
| 995 layersChanged = true; | 1053 layersChanged = true; |
| 996 | 1054 |
| 997 if (layer->reflectionInfo() && updateLayerCompositingState(layer->reflection
Info()->reflectionLayer())) | 1055 if (layer->reflectionInfo() && updateLayerCompositingState(layer->reflection
Info()->reflectionLayer())) |
| 998 layersChanged = true; | 1056 layersChanged = true; |
| 999 | 1057 |
| 1000 // FIXME: squashing code here: if a layer requiresSquashing(), then assign t
his layer to the most recent | 1058 // Add this layer to a squashing backing if needed. |
| 1001 // squashing layer and update recursion state of this function. | 1059 if (isLayerSquashingEnabled()) { |
| 1060 // NOTE: In the future as we generalize this, the background of this lay
er may need to be assigned to a different backing than |
| 1061 // the layer's own primary contents. This would happen when we have a co
mposited negative z-index element that needs to |
| 1062 // paint on top of the background, but below the layer's main contents.
For now, because we always composite layers |
| 1063 // when they have a composited negative z-index child, such layers will
never need squashing so it is not yet an issue. |
| 1064 if (requiresSquashing(layer->compositingReasons())) { |
| 1065 // A layer that is squashed with other layers cannot have its own Co
mpositedLayerMapping. |
| 1066 ASSERT(!layer->hasCompositedLayerMapping()); |
| 1067 ASSERT(squashingState.hasMostRecentMapping); |
| 1068 |
| 1069 IntPoint offsetFromAbsolute = computeOffsetFromAbsolute(layer); |
| 1070 |
| 1071 // FIXME: see if we can refactor this to be clearer |
| 1072 IntSize offsetFromTargetBacking(offsetFromAbsolute.x() - squashingSt
ate.offsetFromAbsolute.x(), |
| 1073 offsetFromAbsolute.y() - squashingState.offsetFromAbsolute.y()); |
| 1074 |
| 1075 squashingState.mostRecentMapping->addRenderLayerToSquashingGraphicsL
ayer(layer, offsetFromTargetBacking, squashingState.nextSquashedLayerIndex); |
| 1076 squashingState.nextSquashedLayerIndex++; |
| 1077 |
| 1078 // FIXME: does this need to be true here? Do we need more logic to d
ecide when it should be true? |
| 1079 layersChanged = true; |
| 1080 |
| 1081 // FIXME: this should be conditioned on whether this layer actually
changed status |
| 1082 layer->clipper().clearClipRectsIncludingDescendants(); |
| 1083 } |
| 1084 } |
| 1002 | 1085 |
| 1003 if (layer->stackingNode()->isStackingContainer()) { | 1086 if (layer->stackingNode()->isStackingContainer()) { |
| 1004 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ
eZOrderChildren); | 1087 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ
eZOrderChildren); |
| 1005 while (RenderLayerStackingNode* curNode = iterator.next()) | 1088 while (RenderLayerStackingNode* curNode = iterator.next()) |
| 1006 assignLayersToBackings(curNode->layer(), layersChanged); | 1089 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay
ersChanged); |
| 1007 } | 1090 } |
| 1008 | 1091 |
| 1009 // FIXME: squashing code here: if this layer actually becomes separately com
posited, then we need to update the | 1092 if (isLayerSquashingEnabled()) { |
| 1010 // squashing layer that subsequent overlapping layers will contribute to. | 1093 // At this point, if the layer is to be "separately" composited, then it
s backing becomes the most recent in paint-order. |
| 1094 if (layer->compositingState() == PaintsIntoOwnBacking || layer->composit
ingState() == HasOwnBackingButPaintsIntoAncestor) { |
| 1095 ASSERT(!requiresSquashing(layer->compositingReasons())); |
| 1096 IntPoint offsetFromAbsolute = computeOffsetFromAbsolute(layer); |
| 1097 squashingState.updateSquashingStateForNewMapping(layer->compositedLa
yerMapping(), layer->hasCompositedLayerMapping(), offsetFromAbsolute); |
| 1098 } |
| 1099 } |
| 1011 | 1100 |
| 1012 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); | 1101 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC
hildren | PositiveZOrderChildren); |
| 1013 while (RenderLayerStackingNode* curNode = iterator.next()) | 1102 while (RenderLayerStackingNode* curNode = iterator.next()) |
| 1014 assignLayersToBackings(curNode->layer(), layersChanged); | 1103 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersC
hanged); |
| 1015 } | 1104 } |
| 1016 | 1105 |
| 1017 void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render
Layer* parentLayer) | 1106 void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render
Layer* parentLayer) |
| 1018 { | 1107 { |
| 1019 ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer
); | 1108 ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer
); |
| 1020 ASSERT(childLayer->hasCompositedLayerMapping()); | 1109 ASSERT(childLayer->hasCompositedLayerMapping()); |
| 1021 | 1110 |
| 1022 // It's possible to be called with a parent that isn't yet composited when w
e're doing | 1111 // It's possible to be called with a parent that isn't yet composited when w
e're doing |
| 1023 // partial updates as required by painting or hit testing. Just bail in that
case; | 1112 // partial updates as required by painting or hit testing. Just bail in that
case; |
| 1024 // we'll do a full layer update soon. | 1113 // we'll do a full layer update soon. |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 layerReasons &= ~CompositingReasonComboAllDirectReasons; | 1592 layerReasons &= ~CompositingReasonComboAllDirectReasons; |
| 1504 layerReasons |= directReasonsForCompositing(layer); | 1593 layerReasons |= directReasonsForCompositing(layer); |
| 1505 layer->setCompositingReasons(layerReasons); | 1594 layer->setCompositingReasons(layerReasons); |
| 1506 } | 1595 } |
| 1507 | 1596 |
| 1508 bool RenderLayerCompositor::needsOwnBacking(const RenderLayer* layer) const | 1597 bool RenderLayerCompositor::needsOwnBacking(const RenderLayer* layer) const |
| 1509 { | 1598 { |
| 1510 if (!canBeComposited(layer)) | 1599 if (!canBeComposited(layer)) |
| 1511 return false; | 1600 return false; |
| 1512 | 1601 |
| 1513 return requiresCompositing(layer->compositingReasons()) || (inCompositingMod
e() && layer->isRootLayer()); | 1602 // If squashing is disabled, then layers that would have been squashed shoul
d just be separately composited. |
| 1603 bool needsOwnBackingForDisabledSquashing = !isLayerSquashingEnabled() && req
uiresSquashing(layer->compositingReasons()); |
| 1604 |
| 1605 return requiresCompositing(layer->compositingReasons()) || needsOwnBackingFo
rDisabledSquashing || (inCompositingMode() && layer->isRootLayer()); |
| 1514 } | 1606 } |
| 1515 | 1607 |
| 1516 bool RenderLayerCompositor::canBeComposited(const RenderLayer* layer) const | 1608 bool RenderLayerCompositor::canBeComposited(const RenderLayer* layer) const |
| 1517 { | 1609 { |
| 1518 // FIXME: We disable accelerated compositing for elements in a RenderFlowThr
ead as it doesn't work properly. | 1610 // FIXME: We disable accelerated compositing for elements in a RenderFlowThr
ead as it doesn't work properly. |
| 1519 // See http://webkit.org/b/84900 to re-enable it. | 1611 // See http://webkit.org/b/84900 to re-enable it. |
| 1520 return m_hasAcceleratedCompositing && layer->isSelfPaintingLayer() && layer-
>renderer()->flowThreadState() == RenderObject::NotInsideFlowThread; | 1612 return m_hasAcceleratedCompositing && layer->isSelfPaintingLayer() && layer-
>renderer()->flowThreadState() == RenderObject::NotInsideFlowThread; |
| 1521 } | 1613 } |
| 1522 | 1614 |
| 1523 CompositingReasons RenderLayerCompositor::directReasonsForCompositing(const Rend
erLayer* layer) const | 1615 CompositingReasons RenderLayerCompositor::directReasonsForCompositing(const Rend
erLayer* layer) const |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 // Return true if the given layer has some ancestor in the RenderLayer hierarchy
that clips, | 1660 // Return true if the given layer has some ancestor in the RenderLayer hierarchy
that clips, |
| 1569 // up to the enclosing compositing ancestor. This is required because compositin
g layers are parented | 1661 // up to the enclosing compositing ancestor. This is required because compositin
g layers are parented |
| 1570 // according to the z-order hierarchy, yet clipping goes down the renderer hiera
rchy. | 1662 // according to the z-order hierarchy, yet clipping goes down the renderer hiera
rchy. |
| 1571 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th
e renderer hierarchy, | 1663 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th
e renderer hierarchy, |
| 1572 // but a sibling in the z-order hierarchy. | 1664 // but a sibling in the z-order hierarchy. |
| 1573 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const | 1665 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const |
| 1574 { | 1666 { |
| 1575 if (!layer->hasCompositedLayerMapping() || !layer->parent()) | 1667 if (!layer->hasCompositedLayerMapping() || !layer->parent()) |
| 1576 return false; | 1668 return false; |
| 1577 | 1669 |
| 1670 // FIXME: need to double-check if semantics of ancestorCompositingLayer() wo
rk correctly here? |
| 1578 const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer(); | 1671 const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer(); |
| 1579 if (!compositingAncestor) | 1672 if (!compositingAncestor) |
| 1580 return false; | 1673 return false; |
| 1581 | 1674 |
| 1582 // If the compositingAncestor clips, that will be taken care of by clipsComp
ositingDescendants(), | 1675 // If the compositingAncestor clips, that will be taken care of by clipsComp
ositingDescendants(), |
| 1583 // so we only care about clipping between its first child that is our ancest
or (the computeClipRoot), | 1676 // so we only care about clipping between its first child that is our ancest
or (the computeClipRoot), |
| 1584 // and layer. | 1677 // and layer. |
| 1585 const RenderLayer* computeClipRoot = 0; | 1678 const RenderLayer* computeClipRoot = 0; |
| 1586 const RenderLayer* curr = layer; | 1679 const RenderLayer* curr = layer; |
| 1587 while (curr) { | 1680 while (curr) { |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2497 } else if (graphicsLayer == m_scrollLayer.get()) { | 2590 } else if (graphicsLayer == m_scrollLayer.get()) { |
| 2498 name = "Frame Scrolling Layer"; | 2591 name = "Frame Scrolling Layer"; |
| 2499 } else { | 2592 } else { |
| 2500 ASSERT_NOT_REACHED(); | 2593 ASSERT_NOT_REACHED(); |
| 2501 } | 2594 } |
| 2502 | 2595 |
| 2503 return name; | 2596 return name; |
| 2504 } | 2597 } |
| 2505 | 2598 |
| 2506 } // namespace WebCore | 2599 } // namespace WebCore |
| OLD | NEW |