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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 // to paint on top of the background, but below the layer's main contents. F
or now, because we always composite layers | 599 // to paint on top of the background, but below the layer's main contents. F
or now, because we always composite layers |
600 // when they have a composited negative z-index child, such layers will neve
r need squashing so it is not yet an issue. | 600 // when they have a composited negative z-index child, such layers will neve
r need squashing so it is not yet an issue. |
601 if (compositedLayerUpdate == PutInSquashingLayer) { | 601 if (compositedLayerUpdate == PutInSquashingLayer) { |
602 // A layer that is squashed with other layers cannot have its own Compos
itedLayerMapping. | 602 // A layer that is squashed with other layers cannot have its own Compos
itedLayerMapping. |
603 ASSERT(!layer->hasCompositedLayerMapping()); | 603 ASSERT(!layer->hasCompositedLayerMapping()); |
604 ASSERT(squashingState.hasMostRecentMapping); | 604 ASSERT(squashingState.hasMostRecentMapping); |
605 | 605 |
606 LayoutPoint offsetFromTransformedAncestorForSquashedLayer = layer->compu
teOffsetFromTransformedAncestor(); | 606 LayoutPoint offsetFromTransformedAncestorForSquashedLayer = layer->compu
teOffsetFromTransformedAncestor(); |
607 | 607 |
608 // Compute the offset of this layer from the squashing owner. This compu
tation is correct only because layers are allowed to squash only if they | 608 // Compute the offset of this layer from the squashing owner. This compu
tation is correct only because layers are allowed to squash only if they |
609 // share a transformed ancestor (see canSquashIntoCurrentSquashingOwner)
. | 609 // share a transformed ancestor (see computeSquashingBehaviorWhenSquashi
ngRequired). |
610 LayoutSize offsetFromSquashingCLM(offsetFromTransformedAncestorForSquash
edLayer.x() - squashingState.offsetFromTransformedAncestorForSquashingCLM.x(), | 610 LayoutSize offsetFromSquashingCLM(offsetFromTransformedAncestorForSquash
edLayer.x() - squashingState.offsetFromTransformedAncestorForSquashingCLM.x(), |
611 offsetFromTransformedAncestorForSquashedLayer.y() - squashingState.o
ffsetFromTransformedAncestorForSquashingCLM.y()); | 611 offsetFromTransformedAncestorForSquashedLayer.y() - squashingState.o
ffsetFromTransformedAncestorForSquashingCLM.y()); |
612 | 612 |
613 bool changedSquashingLayer = | 613 bool changedSquashingLayer = |
614 squashingState.mostRecentMapping->updateSquashingLayerAssignment(lay
er, offsetFromSquashingCLM, squashingState.nextSquashedLayerIndex); | 614 squashingState.mostRecentMapping->updateSquashingLayerAssignment(lay
er, offsetFromSquashingCLM, squashingState.nextSquashedLayerIndex); |
615 if (!changedSquashingLayer) | 615 if (!changedSquashingLayer) |
616 return true; | 616 return true; |
617 | 617 |
618 // If we've modified the collection of squashed layers, we must update | 618 // If we've modified the collection of squashed layers, we must update |
619 // the graphics layer geometry. | 619 // the graphics layer geometry. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 bool RenderLayerCompositor::squashingWouldExceedSparsityTolerance(const RenderLa
yer* candidate, const RenderLayerCompositor::SquashingState& squashingState) | 669 bool RenderLayerCompositor::squashingWouldExceedSparsityTolerance(const RenderLa
yer* candidate, const RenderLayerCompositor::SquashingState& squashingState) |
670 { | 670 { |
671 IntRect bounds = candidate->ancestorDependentProperties().clippedAbsoluteBou
ndingBox; | 671 IntRect bounds = candidate->ancestorDependentProperties().clippedAbsoluteBou
ndingBox; |
672 IntRect newBoundingRect = squashingState.boundingRect; | 672 IntRect newBoundingRect = squashingState.boundingRect; |
673 newBoundingRect.unite(bounds); | 673 newBoundingRect.unite(bounds); |
674 const uint64_t newBoundingRectArea = newBoundingRect.size().area(); | 674 const uint64_t newBoundingRectArea = newBoundingRect.size().area(); |
675 const uint64_t newSquashedArea = squashingState.totalAreaOfSquashedRects + b
ounds.size().area(); | 675 const uint64_t newSquashedArea = squashingState.totalAreaOfSquashedRects + b
ounds.size().area(); |
676 return newBoundingRectArea > gSquashingSparsityTolerance * newSquashedArea; | 676 return newBoundingRectArea > gSquashingSparsityTolerance * newSquashedArea; |
677 } | 677 } |
678 | 678 |
679 bool RenderLayerCompositor::canSquashIntoCurrentSquashingOwner(const RenderLayer
* layer, const RenderLayerCompositor::SquashingState& squashingState) | 679 RenderLayerCompositor::NeedsSquashingBehavior RenderLayerCompositor::computeSqua
shingBehaviorWhenSquashingRequired(const RenderLayer* layer, const RenderLayerCo
mpositor::SquashingState& squashingState) |
680 { | 680 { |
681 // FIXME: this special case for video exists only to deal with corner cases | 681 // FIXME: this special case for video exists only to deal with corner cases |
682 // where a RenderVideo does not report that it needs to be directly composit
ed. | 682 // where a RenderVideo does not report that it needs to be directly composit
ed. |
683 // Video does not currently support sharing a backing, but this could be | 683 // Video does not currently support sharing a backing, but this could be |
684 // generalized in the future. The following layout tests fail if we permit t
he | 684 // generalized in the future. The following layout tests fail if we permit t
he |
685 // video to share a backing with other layers. | 685 // video to share a backing with other layers. |
686 // | 686 // |
687 // compositing/video/video-controls-layer-creation.html | 687 // compositing/video/video-controls-layer-creation.html |
688 // virtual/softwarecompositing/video/video-controls-layer-creation.html | 688 // virtual/softwarecompositing/video/video-controls-layer-creation.html |
689 if (layer->renderer()->isVideo()) | 689 if (layer->renderer()->isVideo()) |
690 return false; | 690 return ShouldPaintIntoOwnLayer; |
691 | 691 |
692 if (squashingWouldExceedSparsityTolerance(layer, squashingState)) | 692 if (squashingWouldExceedSparsityTolerance(layer, squashingState)) |
693 return false; | 693 return ShouldPaintIntoOwnLayer; |
694 | 694 |
695 // FIXME: this is not efficient, since it walks up the tree . We should stor
e these values on the AncestorDependentPropertiesCache. | 695 // FIXME: this is not efficient, since it walks up the tree . We should stor
e these values on the AncestorDependentPropertiesCache. |
696 ASSERT(squashingState.hasMostRecentMapping); | 696 ASSERT(squashingState.hasMostRecentMapping); |
697 const RenderLayer& squashingLayer = squashingState.mostRecentMapping->owning
Layer(); | 697 const RenderLayer& squashingLayer = squashingState.mostRecentMapping->owning
Layer(); |
698 | 698 |
699 if (layer->renderer()->clippingContainer() != squashingLayer.renderer()->cli
ppingContainer()) | |
700 return false; | |
701 | |
702 // Composited descendants need to be clipped by a child contianment graphics
layer, which would not be available if the layer is squashed. | 699 // Composited descendants need to be clipped by a child contianment graphics
layer, which would not be available if the layer is squashed. |
703 if (clipsCompositingDescendants(layer)) | 700 if (clipsCompositingDescendants(layer)) |
704 return false; | 701 return ShouldPaintIntoOwnLayer; |
705 | 702 |
706 if (layer->scrollsWithRespectTo(&squashingLayer)) | 703 if (layer->scrollsWithRespectTo(&squashingLayer)) |
707 return false; | 704 return ShouldPaintIntoOwnLayer; |
708 | 705 |
709 const RenderLayer::AncestorDependentProperties& ancestorDependentProperties
= layer->ancestorDependentProperties(); | 706 const RenderLayer::AncestorDependentProperties& ancestorDependentProperties
= layer->ancestorDependentProperties(); |
710 const RenderLayer::AncestorDependentProperties& squashingLayerAncestorDepend
entProperties = squashingLayer.ancestorDependentProperties(); | 707 const RenderLayer::AncestorDependentProperties& squashingLayerAncestorDepend
entProperties = squashingLayer.ancestorDependentProperties(); |
711 | 708 |
712 if (ancestorDependentProperties.opacityAncestor != squashingLayerAncestorDep
endentProperties.opacityAncestor) | 709 if (ancestorDependentProperties.opacityAncestor != squashingLayerAncestorDep
endentProperties.opacityAncestor) |
713 return false; | 710 return ShouldPaintIntoOwnLayer; |
714 | 711 |
715 if (ancestorDependentProperties.transformAncestor != squashingLayerAncestorD
ependentProperties.transformAncestor) | 712 if (ancestorDependentProperties.transformAncestor != squashingLayerAncestorD
ependentProperties.transformAncestor) |
716 return false; | 713 return ShouldPaintIntoOwnLayer; |
717 | 714 |
718 if (ancestorDependentProperties.filterAncestor != squashingLayerAncestorDepe
ndentProperties.filterAncestor) | 715 if (ancestorDependentProperties.filterAncestor != squashingLayerAncestorDepe
ndentProperties.filterAncestor) |
719 return false; | 716 return ShouldPaintIntoOwnLayer; |
720 | 717 |
721 return true; | 718 if (layer->renderer()->clippingContainer() != squashingLayer.renderer()->cli
ppingContainer()) { |
| 719 //layer->renderer()->showRenderObject(); |
| 720 const RenderLayer* parent = layer->renderer()->clippingContainer()->encl
osingLayer()->containingGroupedLayer(); |
| 721 if (parent && squashingLayer.compositedLayerMapping().equals(parent->gro
upedMapping())) |
| 722 return ShouldPaintIntoSameLayer; |
| 723 printf("clipping: ShouldPaintIntoOwnLayer\n"); |
| 724 return ShouldPaintIntoOwnLayer; |
| 725 } |
| 726 |
| 727 return ShouldSquash; |
722 } | 728 } |
723 | 729 |
724 RenderLayerCompositor::CompositingStateTransitionType RenderLayerCompositor::com
puteCompositedLayerUpdate(RenderLayer* layer) | 730 RenderLayerCompositor::CompositingStateTransitionType RenderLayerCompositor::com
puteCompositedLayerUpdate(RenderLayer* layer) |
725 { | 731 { |
726 CompositingStateTransitionType update = NoCompositingStateChange; | 732 CompositingStateTransitionType update = NoCompositingStateChange; |
727 if (!layer->subtreeIsInvisible() && needsOwnBacking(layer)) { | 733 if (!layer->subtreeIsInvisible() && needsOwnBacking(layer)) { |
728 if (!layer->hasCompositedLayerMapping()) { | 734 if (!layer->hasCompositedLayerMapping()) { |
729 update = AllocateOwnCompositedLayerMapping; | 735 update = AllocateOwnCompositedLayerMapping; |
730 } | 736 } |
731 } else { | 737 } else { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 | 830 |
825 nextSquashedLayerIndex = 0; | 831 nextSquashedLayerIndex = 0; |
826 mostRecentMapping = newCompositedLayerMapping; | 832 mostRecentMapping = newCompositedLayerMapping; |
827 hasMostRecentMapping = hasNewCompositedLayerMapping; | 833 hasMostRecentMapping = hasNewCompositedLayerMapping; |
828 offsetFromTransformedAncestorForSquashingCLM = newOffsetFromTransformedAnces
torForSquashingCLM; | 834 offsetFromTransformedAncestorForSquashingCLM = newOffsetFromTransformedAnces
torForSquashingCLM; |
829 } | 835 } |
830 | 836 |
831 void RenderLayerCompositor::assignLayersToBackings(RenderLayer* updateRoot, bool
& layersChanged) | 837 void RenderLayerCompositor::assignLayersToBackings(RenderLayer* updateRoot, bool
& layersChanged) |
832 { | 838 { |
833 SquashingState squashingState; | 839 SquashingState squashingState; |
| 840 printf("RenderLayerCompositor::assignLayersToBackings()\n"); |
834 assignLayersToBackingsInternal(updateRoot, squashingState, layersChanged); | 841 assignLayersToBackingsInternal(updateRoot, squashingState, layersChanged); |
835 if (squashingState.hasMostRecentMapping) | 842 if (squashingState.hasMostRecentMapping) |
836 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa
shingState.nextSquashedLayerIndex); | 843 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa
shingState.nextSquashedLayerIndex); |
837 } | 844 } |
838 | 845 |
839 void RenderLayerCompositor::assignLayersToBackingsForReflectionLayer(RenderLayer
* reflectionLayer, bool& layersChanged) | 846 void RenderLayerCompositor::assignLayersToBackingsForReflectionLayer(RenderLayer
* reflectionLayer, bool& layersChanged) |
840 { | 847 { |
841 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(reflectionLayer); | 848 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(reflectionLayer); |
842 if (compositedLayerUpdate != NoCompositingStateChange) { | 849 if (compositedLayerUpdate != NoCompositingStateChange) { |
843 layersChanged = true; | 850 layersChanged = true; |
844 allocateOrClearCompositedLayerMapping(reflectionLayer, compositedLayerUp
date); | 851 allocateOrClearCompositedLayerMapping(reflectionLayer, compositedLayerUp
date); |
845 } | 852 } |
846 updateDirectCompositingReasons(reflectionLayer); | 853 updateDirectCompositingReasons(reflectionLayer); |
847 if (reflectionLayer->hasCompositedLayerMapping()) | 854 if (reflectionLayer->hasCompositedLayerMapping()) |
848 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat
ion(GraphicsLayerUpdater::ForceUpdate); | 855 reflectionLayer->compositedLayerMapping()->updateGraphicsLayerConfigurat
ion(GraphicsLayerUpdater::ForceUpdate); |
849 } | 856 } |
850 | 857 |
851 void RenderLayerCompositor::assignLayersToBackingsInternal(RenderLayer* layer, S
quashingState& squashingState, bool& layersChanged) | 858 void RenderLayerCompositor::assignLayersToBackingsInternal(RenderLayer* layer, S
quashingState& squashingState, bool& layersChanged) |
852 { | 859 { |
853 if (layerSquashingEnabled() && requiresSquashing(layer->compositingReasons()
) && !canSquashIntoCurrentSquashingOwner(layer, squashingState)) | 860 if (layerSquashingEnabled() && requiresSquashing(layer->compositingReasons()
)) { |
854 layer->setCompositingReasons(layer->compositingReasons() | CompositingRe
asonNoSquashingTargetFound); | 861 switch (computeSquashingBehaviorWhenSquashingRequired(layer, squashingSt
ate)) { |
| 862 case ShouldPaintIntoOwnLayer: { |
| 863 printf("assignLayersToBackingsInternal: ShouldPaintIntoOwnLayer\
n"); |
| 864 layer->setCompositingReasons(layer->compositingReasons() | Compo
sitingReasonNoSquashingTargetFound); |
| 865 break; |
| 866 } |
| 867 case ShouldSquash: |
| 868 break; |
| 869 case ShouldPaintIntoSameLayer: |
| 870 layer->setCompositingReasons(CompositingReasonNone); |
| 871 break; |
| 872 } |
| 873 } |
855 | 874 |
856 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(layer); | 875 CompositingStateTransitionType compositedLayerUpdate = computeCompositedLaye
rUpdate(layer); |
857 | 876 |
858 if (allocateOrClearCompositedLayerMapping(layer, compositedLayerUpdate)) | 877 if (allocateOrClearCompositedLayerMapping(layer, compositedLayerUpdate)) |
859 layersChanged = true; | 878 layersChanged = true; |
860 | 879 |
861 // FIXME: special-casing reflection layers here is not right. | 880 // FIXME: special-casing reflection layers here is not right. |
862 if (layer->reflectionInfo()) | 881 if (layer->reflectionInfo()) |
863 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec
tionLayer(), layersChanged); | 882 assignLayersToBackingsForReflectionLayer(layer->reflectionInfo()->reflec
tionLayer(), layersChanged); |
864 | 883 |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 } else if (graphicsLayer == m_scrollLayer.get()) { | 1724 } else if (graphicsLayer == m_scrollLayer.get()) { |
1706 name = "LocalFrame Scrolling Layer"; | 1725 name = "LocalFrame Scrolling Layer"; |
1707 } else { | 1726 } else { |
1708 ASSERT_NOT_REACHED(); | 1727 ASSERT_NOT_REACHED(); |
1709 } | 1728 } |
1710 | 1729 |
1711 return name; | 1730 return name; |
1712 } | 1731 } |
1713 | 1732 |
1714 } // namespace WebCore | 1733 } // namespace WebCore |
OLD | NEW |