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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 } | 173 } |
174 | 174 |
175 RenderGeometryMap& geometryMap() { return m_geometryMap; } | 175 RenderGeometryMap& geometryMap() { return m_geometryMap; } |
176 | 176 |
177 private: | 177 private: |
178 Vector<OverlapMapContainer> m_overlapStack; | 178 Vector<OverlapMapContainer> m_overlapStack; |
179 HashSet<const RenderLayer*> m_layers; | 179 HashSet<const RenderLayer*> m_layers; |
180 RenderGeometryMap m_geometryMap; | 180 RenderGeometryMap m_geometryMap; |
181 }; | 181 }; |
182 | 182 |
183 struct CompositingState { | 183 struct CompositingRecursionData { |
184 CompositingState(RenderLayer* compAncestor, bool testOverlap) | 184 CompositingRecursionData(RenderLayer* compAncestor, bool testOverlap) |
185 : m_compositingAncestor(compAncestor) | 185 : m_compositingAncestor(compAncestor) |
186 , m_subtreeIsCompositing(false) | 186 , m_subtreeIsCompositing(false) |
187 , m_testingOverlap(testOverlap) | 187 , m_testingOverlap(testOverlap) |
188 #ifndef NDEBUG | 188 #ifndef NDEBUG |
189 , m_depth(0) | 189 , m_depth(0) |
190 #endif | 190 #endif |
191 { | 191 { |
192 } | 192 } |
193 | 193 |
194 CompositingState(const CompositingState& other) | 194 CompositingRecursionData(const CompositingRecursionData& other) |
195 : m_compositingAncestor(other.m_compositingAncestor) | 195 : m_compositingAncestor(other.m_compositingAncestor) |
196 , m_subtreeIsCompositing(other.m_subtreeIsCompositing) | 196 , m_subtreeIsCompositing(other.m_subtreeIsCompositing) |
197 , m_testingOverlap(other.m_testingOverlap) | 197 , m_testingOverlap(other.m_testingOverlap) |
198 #ifndef NDEBUG | 198 #ifndef NDEBUG |
199 , m_depth(other.m_depth + 1) | 199 , m_depth(other.m_depth + 1) |
200 #endif | 200 #endif |
201 { | 201 { |
202 } | 202 } |
203 | 203 |
204 RenderLayer* m_compositingAncestor; | 204 RenderLayer* m_compositingAncestor; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 | 317 |
318 IntRect visibleRect = m_containerLayer ? IntRect(IntPoint(), frameView->cont entsSize()) : frameView->visibleContentRect(); | 318 IntRect visibleRect = m_containerLayer ? IntRect(IntPoint(), frameView->cont entsSize()) : frameView->visibleContentRect(); |
319 if (rootLayer->visibleRectChangeRequiresFlush(visibleRect)) { | 319 if (rootLayer->visibleRectChangeRequiresFlush(visibleRect)) { |
320 if (Page* page = this->page()) | 320 if (Page* page = this->page()) |
321 page->chrome().client().scheduleCompositingLayerFlush(); | 321 page->chrome().client().scheduleCompositingLayerFlush(); |
322 } | 322 } |
323 } | 323 } |
324 | 324 |
325 bool RenderLayerCompositor::hasAnyAdditionalCompositedLayers(const RenderLayer* rootLayer) const | 325 bool RenderLayerCompositor::hasAnyAdditionalCompositedLayers(const RenderLayer* rootLayer) const |
326 { | 326 { |
327 return m_compositedLayerCount > (rootLayer->isComposited() ? 1 : 0); | 327 return m_compositedLayerCount > (rootLayer->backing() ? 1 : 0); |
328 } | 328 } |
329 | 329 |
330 void RenderLayerCompositor::updateCompositingRequirementsState() | 330 void RenderLayerCompositor::updateCompositingRequirementsState() |
331 { | 331 { |
332 if (!m_needsUpdateCompositingRequirementsState) | 332 if (!m_needsUpdateCompositingRequirementsState) |
333 return; | 333 return; |
334 | 334 |
335 TRACE_EVENT0("blink_rendering,comp-scroll", "RenderLayerCompositor::updateCo mpositingRequirementsState"); | 335 TRACE_EVENT0("blink_rendering,comp-scroll", "RenderLayerCompositor::updateCo mpositingRequirementsState"); |
336 | 336 |
337 m_needsUpdateCompositingRequirementsState = false; | 337 m_needsUpdateCompositingRequirementsState = false; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 double startTime = 0; | 421 double startTime = 0; |
422 if (compositingLogEnabled()) { | 422 if (compositingLogEnabled()) { |
423 ++m_rootLayerUpdateCount; | 423 ++m_rootLayerUpdateCount; |
424 startTime = currentTime(); | 424 startTime = currentTime(); |
425 } | 425 } |
426 #endif | 426 #endif |
427 | 427 |
428 if (checkForHierarchyUpdate) { | 428 if (checkForHierarchyUpdate) { |
429 // Go through the layers in presentation order, so that we can compute w hich RenderLayers need compositing layers. | 429 // Go through the layers in presentation order, so that we can compute w hich RenderLayers need compositing layers. |
430 // FIXME: we could maybe do this and the hierarchy udpate in one pass, b ut the parenting logic would be more complex. | 430 // FIXME: we could maybe do this and the hierarchy udpate in one pass, b ut the parenting logic would be more complex. |
431 CompositingState compState(updateRoot, true); | 431 CompositingRecursionData compState(updateRoot, true); |
432 bool layersChanged = false; | 432 bool layersChanged = false; |
433 bool saw3DTransform = false; | 433 bool saw3DTransform = false; |
434 { | 434 { |
435 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::computeCompo sitingRequirements"); | 435 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::computeCompo sitingRequirements"); |
436 OverlapMap overlapTestRequestMap; | 436 OverlapMap overlapTestRequestMap; |
437 | 437 |
438 // FIXME: Passing these unclippedDescendants down and keeping track | 438 // FIXME: Passing these unclippedDescendants down and keeping track |
439 // of them dynamically, we are requiring a full tree walk. This | 439 // of them dynamically, we are requiring a full tree walk. This |
440 // should be removed as soon as proper overlap testing based on | 440 // should be removed as soon as proper overlap testing based on |
441 // scrolling and animation bounds is implemented (crbug.com/252472). | 441 // scrolling and animation bounds is implemented (crbug.com/252472). |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
636 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoor dinator()) | 636 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoor dinator()) |
637 scrollingCoordinator->frameViewFixedObjectsDidChange(m_renderVie w->frameView()); | 637 scrollingCoordinator->frameViewFixedObjectsDidChange(m_renderVie w->frameView()); |
638 } | 638 } |
639 } | 639 } |
640 | 640 |
641 return layerChanged; | 641 return layerChanged; |
642 } | 642 } |
643 | 643 |
644 bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer, Comp ositingChangeRepaint shouldRepaint) | 644 bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer, Comp ositingChangeRepaint shouldRepaint) |
645 { | 645 { |
646 CompositingState stateBeforeUpdating = layer->compositingState(); | |
646 bool layerChanged = updateBacking(layer, shouldRepaint); | 647 bool layerChanged = updateBacking(layer, shouldRepaint); |
647 | 648 |
648 // See if we need content or clipping layers. Methods called here should ass ume | 649 // See if we need content or clipping layers. Methods called here should ass ume |
649 // that the compositing state of descendant layers has not been updated yet. | 650 // that the compositing state of descendant layers has not been updated yet. |
650 if (layer->backing() && layer->backing()->updateGraphicsLayerConfiguration() ) | 651 if (layer->backing() && layer->backing()->updateGraphicsLayerConfiguration() ) |
651 layerChanged = true; | 652 layerChanged = true; |
652 | 653 |
653 return layerChanged; | 654 // While this code is gradually evolving, this sanity check will help. |
655 CompositingState stateAfterUpdating = layer->compositingState(); | |
656 bool compositingStateChanged = (stateBeforeUpdating != stateAfterUpdating); | |
657 ASSERT(layerChanged == compositingStateChanged); | |
658 | |
659 // Return true for either condition to avoid bugs in production code. | |
660 return layerChanged || compositingStateChanged; | |
654 } | 661 } |
655 | 662 |
656 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer) | 663 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer) |
657 { | 664 { |
658 // If the renderer is not attached yet, no need to repaint. | 665 // If the renderer is not attached yet, no need to repaint. |
659 if (layer->renderer() != m_renderView && !layer->renderer()->parent()) | 666 if (layer->renderer() != m_renderView && !layer->renderer()->parent()) |
660 return; | 667 return; |
661 | 668 |
662 RenderLayerModelObject* repaintContainer = layer->renderer()->containerForRe paint(); | 669 RenderLayerModelObject* repaintContainer = layer->renderer()->containerForRe paint(); |
663 if (!repaintContainer) | 670 if (!repaintContainer) |
664 repaintContainer = m_renderView; | 671 repaintContainer = m_renderView; |
665 | 672 |
666 layer->repaintIncludingNonCompositingDescendants(repaintContainer); | 673 layer->repaintIncludingNonCompositingDescendants(repaintContainer); |
667 } | 674 } |
668 | 675 |
669 // This method assumes that layout is up-to-date, unlike repaintOnCompositingCha nge(). | 676 // This method assumes that layout is up-to-date, unlike repaintOnCompositingCha nge(). |
670 void RenderLayerCompositor::repaintInCompositedAncestor(RenderLayer* layer, cons t LayoutRect& rect) | 677 void RenderLayerCompositor::repaintInCompositedAncestor(RenderLayer* layer, cons t LayoutRect& rect) |
671 { | 678 { |
672 RenderLayer* compositedAncestor = layer->enclosingCompositingLayerForRepaint (false /*exclude self*/); | 679 RenderLayer* compositedAncestor = layer->enclosingCompositingLayerForRepaint (false /*exclude self*/); |
673 if (compositedAncestor) { | 680 if (compositedAncestor) { |
674 ASSERT(compositedAncestor->backing()); | 681 ASSERT(compositedAncestor->compositingState() == PaintsIntoOwnBacking); |
675 | 682 |
676 LayoutPoint offset; | 683 LayoutPoint offset; |
677 layer->convertToLayerCoords(compositedAncestor, offset); | 684 layer->convertToLayerCoords(compositedAncestor, offset); |
678 | 685 |
679 LayoutRect repaintRect = rect; | 686 LayoutRect repaintRect = rect; |
680 repaintRect.moveBy(offset); | 687 repaintRect.moveBy(offset); |
681 | 688 |
682 compositedAncestor->setBackingNeedsRepaintInRect(repaintRect); | 689 compositedAncestor->setBackingNeedsRepaintInRect(repaintRect); |
683 } | 690 } |
684 } | 691 } |
(...skipping 14 matching lines...) Expand all Loading... | |
699 return layer->calculateLayerBounds(ancestorLayer, 0, flags); | 706 return layer->calculateLayerBounds(ancestorLayer, 0, flags); |
700 } | 707 } |
701 | 708 |
702 void RenderLayerCompositor::layerWasAdded(RenderLayer* /*parent*/, RenderLayer* /*child*/) | 709 void RenderLayerCompositor::layerWasAdded(RenderLayer* /*parent*/, RenderLayer* /*child*/) |
703 { | 710 { |
704 setCompositingLayersNeedRebuild(); | 711 setCompositingLayersNeedRebuild(); |
705 } | 712 } |
706 | 713 |
707 void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer* child) | 714 void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer* child) |
708 { | 715 { |
709 if (!child->isComposited() || parent->renderer()->documentBeingDestroyed()) | 716 if (!child->backing() || parent->renderer()->documentBeingDestroyed()) |
710 return; | 717 return; |
711 | 718 |
712 removeViewportConstrainedLayer(child); | 719 removeViewportConstrainedLayer(child); |
713 repaintInCompositedAncestor(child, child->backing()->compositedBounds()); | 720 repaintInCompositedAncestor(child, child->backing()->compositedBounds()); |
714 | 721 |
715 setCompositingParent(child, 0); | 722 setCompositingParent(child, 0); |
716 setCompositingLayersNeedRebuild(); | 723 setCompositingLayersNeedRebuild(); |
717 } | 724 } |
718 | 725 |
719 RenderLayer* RenderLayerCompositor::enclosingNonStackingClippingLayer(const Rend erLayer* layer) const | 726 RenderLayer* RenderLayerCompositor::enclosingNonStackingClippingLayer(const Rend erLayer* layer) const |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 | 806 |
800 // Recurse through the layers in z-index and overflow order (which is equivalen t to painting order) | 807 // Recurse through the layers in z-index and overflow order (which is equivalen t to painting order) |
801 // For the z-order children of a compositing layer: | 808 // For the z-order children of a compositing layer: |
802 // If a child layers has a compositing layer, then all subsequent layers mu st | 809 // If a child layers has a compositing layer, then all subsequent layers mu st |
803 // be compositing in order to render above that layer. | 810 // be compositing in order to render above that layer. |
804 // | 811 // |
805 // If a child in the negative z-order list is compositing, then the layer i tself | 812 // If a child in the negative z-order list is compositing, then the layer i tself |
806 // must be compositing so that its contents render over that child. | 813 // must be compositing so that its contents render over that child. |
807 // This implies that its positive z-index children must also be compositing . | 814 // This implies that its positive z-index children must also be compositing . |
808 // | 815 // |
809 void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor Layer, RenderLayer* layer, OverlapMap* overlapMap, CompositingState& compositing State, bool& layersChanged, bool& descendantHas3DTransform, Vector<RenderLayer*> & unclippedDescendants) | 816 void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor Layer, RenderLayer* layer, OverlapMap* overlapMap, CompositingRecursionData& cur rentState, bool& layersChanged, bool& descendantHas3DTransform, Vector<RenderLay er*>& unclippedDescendants) |
Ian Vollick
2013/10/02 19:12:26
bikeshed: currentData?
shawnsingh
2013/10/03 03:04:04
How about currentRecursionState? "state" is actua
| |
810 { | 817 { |
811 layer->updateLayerListsIfNeeded(); | 818 layer->updateLayerListsIfNeeded(); |
812 | 819 |
813 if (overlapMap) | 820 if (overlapMap) |
814 overlapMap->geometryMap().pushMappingsToAncestor(layer, ancestorLayer); | 821 overlapMap->geometryMap().pushMappingsToAncestor(layer, ancestorLayer); |
815 | 822 |
816 // Clear the flag | 823 // Clear the flag |
817 layer->setHasCompositingDescendant(false); | 824 layer->setHasCompositingDescendant(false); |
818 | 825 |
819 // Start by assuming this layer will not need to composite. | 826 // Start by assuming this layer will not need to composite. |
820 CompositingReasons reasonsToComposite = CompositingReasonNone; | 827 CompositingReasons reasonsToComposite = CompositingReasonNone; |
821 | 828 |
822 // First accumulate the straightforward compositing reasons. | 829 // First accumulate the straightforward compositing reasons. |
823 CompositingReasons directReasons = directReasonsForCompositing(layer); | 830 CompositingReasons directReasons = directReasonsForCompositing(layer); |
824 | 831 |
825 // Video is special. It's the only RenderLayer type that can both have | 832 // Video is special. It's the only RenderLayer type that can both have |
826 // RenderLayer children and whose children can't use its backing to render | 833 // RenderLayer children and whose children can't use its backing to render |
827 // into. These children (the controls) always need to be promoted into their | 834 // into. These children (the controls) always need to be promoted into their |
828 // own layers to draw on top of the accelerated video. | 835 // own layers to draw on top of the accelerated video. |
829 if (compositingState.m_compositingAncestor && compositingState.m_compositing Ancestor->renderer()->isVideo()) | 836 if (currentState.m_compositingAncestor && currentState.m_compositingAncestor ->renderer()->isVideo()) |
830 directReasons |= CompositingReasonLayerForVideoOverlay; | 837 directReasons |= CompositingReasonLayerForVideoOverlay; |
831 | 838 |
832 if (canBeComposited(layer)) { | 839 if (canBeComposited(layer)) { |
833 reasonsToComposite |= directReasons; | 840 reasonsToComposite |= directReasons; |
834 reasonsToComposite |= (inCompositingMode() && layer->isRootLayer()) ? Co mpositingReasonRoot : CompositingReasonNone; | 841 reasonsToComposite |= (inCompositingMode() && layer->isRootLayer()) ? Co mpositingReasonRoot : CompositingReasonNone; |
835 } | 842 } |
836 | 843 |
837 // Next, accumulate reasons related to overlap. | 844 // Next, accumulate reasons related to overlap. |
838 // If overlap testing is used, this reason will be overridden. If overlap te sting is not | 845 // If overlap testing is used, this reason will be overridden. If overlap te sting is not |
839 // used, we must assume we overlap if there is anything composited behind us in paint-order. | 846 // used, we must assume we overlap if there is anything composited behind us in paint-order. |
840 CompositingReasons overlapCompositingReason = compositingState.m_subtreeIsCo mpositing ? CompositingReasonAssumedOverlap : CompositingReasonNone; | 847 CompositingReasons overlapCompositingReason = currentState.m_subtreeIsCompos iting ? CompositingReasonAssumedOverlap : CompositingReasonNone; |
841 | 848 |
842 if (rootRenderLayer()->compositorDrivenAcceleratedScrollingEnabled()) { | 849 if (rootRenderLayer()->compositorDrivenAcceleratedScrollingEnabled()) { |
843 Vector<size_t> unclippedDescendantsToRemove; | 850 Vector<size_t> unclippedDescendantsToRemove; |
844 for (size_t i = 0; i < unclippedDescendants.size(); i++) { | 851 for (size_t i = 0; i < unclippedDescendants.size(); i++) { |
845 RenderLayer* unclippedDescendant = unclippedDescendants.at(i); | 852 RenderLayer* unclippedDescendant = unclippedDescendants.at(i); |
846 // If we've reached the containing block of one of the unclipped | 853 // If we've reached the containing block of one of the unclipped |
847 // descendants, that element is no longer relevant to whether or not we | 854 // descendants, that element is no longer relevant to whether or not we |
848 // should opt in. Unfortunately we can't easily remove from the list | 855 // should opt in. Unfortunately we can't easily remove from the list |
849 // while we're iterating, so we have to store it for later removal. | 856 // while we're iterating, so we have to store it for later removal. |
850 if (unclippedDescendant->renderer()->containingBlock() == layer->ren derer()) { | 857 if (unclippedDescendant->renderer()->containingBlock() == layer->ren derer()) { |
851 unclippedDescendantsToRemove.append(i); | 858 unclippedDescendantsToRemove.append(i); |
852 continue; | 859 continue; |
853 } | 860 } |
854 if (layer->scrollsWithRespectTo(unclippedDescendant)) | 861 if (layer->scrollsWithRespectTo(unclippedDescendant)) |
855 reasonsToComposite |= CompositingReasonAssumedOverlap; | 862 reasonsToComposite |= CompositingReasonAssumedOverlap; |
856 } | 863 } |
857 | 864 |
858 // Remove irrelevant unclipped descendants in reverse order so our store d | 865 // Remove irrelevant unclipped descendants in reverse order so our store d |
859 // indices remain valid. | 866 // indices remain valid. |
860 for (size_t i = 0; i < unclippedDescendantsToRemove.size(); i++) | 867 for (size_t i = 0; i < unclippedDescendantsToRemove.size(); i++) |
861 unclippedDescendants.remove(unclippedDescendantsToRemove.at(unclippe dDescendantsToRemove.size() - i - 1)); | 868 unclippedDescendants.remove(unclippedDescendantsToRemove.at(unclippe dDescendantsToRemove.size() - i - 1)); |
862 | 869 |
863 if (reasonsToComposite & CompositingReasonOutOfFlowClipping) | 870 if (reasonsToComposite & CompositingReasonOutOfFlowClipping) |
864 unclippedDescendants.append(layer); | 871 unclippedDescendants.append(layer); |
865 } | 872 } |
866 | 873 |
867 bool haveComputedBounds = false; | 874 bool haveComputedBounds = false; |
868 IntRect absBounds; | 875 IntRect absBounds; |
869 // If we know for sure the layer is going to be composited, don't bother loo king it up in the overlap map. | 876 // If we know for sure the layer is going to be composited, don't bother loo king it up in the overlap map. |
870 if (overlapMap && !overlapMap->isEmpty() && compositingState.m_testingOverla p && !requiresCompositing(directReasons)) { | 877 if (overlapMap && !overlapMap->isEmpty() && currentState.m_testingOverlap && !requiresCompositing(directReasons)) { |
871 // If we're testing for overlap, we only need to composite if we overlap something that is already composited. | 878 // If we're testing for overlap, we only need to composite if we overlap something that is already composited. |
872 absBounds = enclosingIntRect(overlapMap->geometryMap().absoluteRect(laye r->overlapBounds())); | 879 absBounds = enclosingIntRect(overlapMap->geometryMap().absoluteRect(laye r->overlapBounds())); |
873 | 880 |
874 // Empty rects never intersect, but we need them to for the purposes of overlap testing. | 881 // Empty rects never intersect, but we need them to for the purposes of overlap testing. |
875 if (absBounds.isEmpty()) | 882 if (absBounds.isEmpty()) |
876 absBounds.setSize(IntSize(1, 1)); | 883 absBounds.setSize(IntSize(1, 1)); |
877 haveComputedBounds = true; | 884 haveComputedBounds = true; |
878 overlapCompositingReason = overlapMap->overlapsLayers(absBounds) ? Compo sitingReasonOverlap : CompositingReasonNone; | 885 overlapCompositingReason = overlapMap->overlapsLayers(absBounds) ? Compo sitingReasonOverlap : CompositingReasonNone; |
879 } | 886 } |
880 | 887 |
881 reasonsToComposite |= overlapCompositingReason; | 888 reasonsToComposite |= overlapCompositingReason; |
882 | 889 |
883 // The children of this layer don't need to composite, unless there is | 890 // The children of this layer don't need to composite, unless there is |
884 // a compositing layer among them, so start by inheriting the compositing | 891 // a compositing layer among them, so start by inheriting the compositing |
885 // ancestor with m_subtreeIsCompositing set to false. | 892 // ancestor with m_subtreeIsCompositing set to false. |
886 CompositingState childState(compositingState); | 893 CompositingRecursionData childState(currentState); |
887 childState.m_subtreeIsCompositing = false; | 894 childState.m_subtreeIsCompositing = false; |
888 | 895 |
889 bool willBeComposited = canBeComposited(layer) && requiresCompositing(reason sToComposite); | 896 bool willBeComposited = canBeComposited(layer) && requiresCompositing(reason sToComposite); |
890 if (willBeComposited) { | 897 if (willBeComposited) { |
891 // Tell the parent it has compositing descendants. | 898 // Tell the parent it has compositing descendants. |
892 compositingState.m_subtreeIsCompositing = true; | 899 currentState.m_subtreeIsCompositing = true; |
893 // This layer now acts as the ancestor for kids. | 900 // This layer now acts as the ancestor for kids. |
894 childState.m_compositingAncestor = layer; | 901 childState.m_compositingAncestor = layer; |
895 | 902 |
896 // Here we know that all children and the layer's own contents can blind ly paint into | 903 // Here we know that all children and the layer's own contents can blind ly paint into |
897 // this layer's backing, until a descendant is composited. So, we don't need to check | 904 // this layer's backing, until a descendant is composited. So, we don't need to check |
898 // for overlap with anything behind this layer. | 905 // for overlap with anything behind this layer. |
899 if (overlapMap) | 906 if (overlapMap) |
900 overlapMap->beginNewOverlapTestingContext(); | 907 overlapMap->beginNewOverlapTestingContext(); |
901 // This layer is going to be composited, so children can safely ignore t he fact that there's an | 908 // This layer is going to be composited, so children can safely ignore t he fact that there's an |
902 // animation running behind this layer, meaning they can rely on the ove rlap map testing again. | 909 // animation running behind this layer, meaning they can rely on the ove rlap map testing again. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1009 | 1016 |
1010 // If the original layer is composited, the reflection needs to be, too. | 1017 // If the original layer is composited, the reflection needs to be, too. |
1011 if (layer->reflectionLayer()) { | 1018 if (layer->reflectionLayer()) { |
1012 // FIXME: Shouldn't we call computeCompositingRequirements to handle a r eflection overlapping with another renderer? | 1019 // FIXME: Shouldn't we call computeCompositingRequirements to handle a r eflection overlapping with another renderer? |
1013 CompositingReasons reflectionCompositingReason = willBeComposited ? Comp ositingReasonReflectionOfCompositedParent : CompositingReasonNone; | 1020 CompositingReasons reflectionCompositingReason = willBeComposited ? Comp ositingReasonReflectionOfCompositedParent : CompositingReasonNone; |
1014 layer->reflectionLayer()->setCompositingReasons(layer->reflectionLayer() ->compositingReasons() | reflectionCompositingReason); | 1021 layer->reflectionLayer()->setCompositingReasons(layer->reflectionLayer() ->compositingReasons() | reflectionCompositingReason); |
1015 } | 1022 } |
1016 | 1023 |
1017 // Subsequent layers in the parent's stacking context may also need to compo site. | 1024 // Subsequent layers in the parent's stacking context may also need to compo site. |
1018 if (childState.m_subtreeIsCompositing) | 1025 if (childState.m_subtreeIsCompositing) |
1019 compositingState.m_subtreeIsCompositing = true; | 1026 currentState.m_subtreeIsCompositing = true; |
1020 | 1027 |
1021 // Set the flag to say that this SC has compositing children. | 1028 // Set the flag to say that this SC has compositing children. |
1022 layer->setHasCompositingDescendant(childState.m_subtreeIsCompositing); | 1029 layer->setHasCompositingDescendant(childState.m_subtreeIsCompositing); |
1023 | 1030 |
1024 | 1031 |
1025 // Turn overlap testing off for later layers if it's already off, or if we h ave an animating transform. | 1032 // Turn overlap testing off for later layers if it's already off, or if we h ave an animating transform. |
1026 // Note that if the layer clips its descendants, there's no reason to propag ate the child animation to the parent layers. That's because | 1033 // Note that if the layer clips its descendants, there's no reason to propag ate the child animation to the parent layers. That's because |
1027 // we know for sure the animation is contained inside the clipping rectangle , which is already added to the overlap map. | 1034 // we know for sure the animation is contained inside the clipping rectangle , which is already added to the overlap map. |
1028 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi te & CompositingReasonClipsCompositingDescendants); | 1035 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi te & CompositingReasonClipsCompositingDescendants); |
1029 if ((!childState.m_testingOverlap && !isCompositedClippingLayer) || isRunnin gAcceleratedTransformAnimation(layer->renderer())) | 1036 if ((!childState.m_testingOverlap && !isCompositedClippingLayer) || isRunnin gAcceleratedTransformAnimation(layer->renderer())) |
1030 compositingState.m_testingOverlap = false; | 1037 currentState.m_testingOverlap = false; |
1031 | 1038 |
1032 if (overlapMap && childState.m_compositingAncestor == layer && !layer->isRoo tLayer()) | 1039 if (overlapMap && childState.m_compositingAncestor == layer && !layer->isRoo tLayer()) |
1033 overlapMap->finishCurrentOverlapTestingContext(); | 1040 overlapMap->finishCurrentOverlapTestingContext(); |
1034 | 1041 |
1035 // If we're back at the root, and no other layers need to be composited, and the root layer itself doesn't need | 1042 // If we're back at the root, and no other layers need to be composited, and the root layer itself doesn't need |
1036 // to be composited, then we can drop out of compositing mode altogether. Ho wever, don't drop out of compositing mode | 1043 // to be composited, then we can drop out of compositing mode altogether. Ho wever, don't drop out of compositing mode |
1037 // if there are composited layers that we didn't hit in our traversal (e.g. because of visibility:hidden). | 1044 // if there are composited layers that we didn't hit in our traversal (e.g. because of visibility:hidden). |
1038 // FIXME: hasAnyAdditionalCompositedLayers() code seems fishy. We need to ma ke root layer logic more obvious. | 1045 // FIXME: hasAnyAdditionalCompositedLayers() code seems fishy. We need to ma ke root layer logic more obvious. |
1039 if (layer->isRootLayer() && !childState.m_subtreeIsCompositing && !requiresC ompositing(directReasons) && !m_forceCompositingMode && !hasAnyAdditionalComposi tedLayers(layer)) { | 1046 if (layer->isRootLayer() && !childState.m_subtreeIsCompositing && !requiresC ompositing(directReasons) && !m_forceCompositingMode && !hasAnyAdditionalComposi tedLayers(layer)) { |
1040 enableCompositingMode(false); | 1047 enableCompositingMode(false); |
1041 willBeComposited = false; | 1048 willBeComposited = false; |
1042 reasonsToComposite = CompositingReasonNone; | 1049 reasonsToComposite = CompositingReasonNone; |
1043 } | 1050 } |
1044 | 1051 |
1045 // At this point we have finished collecting all reasons to composite this l ayer. | 1052 // At this point we have finished collecting all reasons to composite this l ayer. |
1046 layer->setCompositingReasons(reasonsToComposite); | 1053 layer->setCompositingReasons(reasonsToComposite); |
1047 | 1054 |
1048 // Update backing now, so that we can use isComposited() reliably during tre e traversal in rebuildCompositingLayerTree(). | 1055 // Update backing now, so that we can use backing() reliably during tree tra versal in rebuildCompositingLayerTree(). |
1049 if (updateBacking(layer, CompositingChangeRepaintNow)) | 1056 if (updateBacking(layer, CompositingChangeRepaintNow)) |
1050 layersChanged = true; | 1057 layersChanged = true; |
1051 | 1058 |
1052 if (layer->reflectionLayer() && updateLayerCompositingState(layer->reflectio nLayer(), CompositingChangeRepaintNow)) | 1059 if (layer->reflectionLayer() && updateLayerCompositingState(layer->reflectio nLayer(), CompositingChangeRepaintNow)) |
1053 layersChanged = true; | 1060 layersChanged = true; |
1054 | 1061 |
1055 descendantHas3DTransform |= anyDescendantHas3DTransform || layer->has3DTrans form(); | 1062 descendantHas3DTransform |= anyDescendantHas3DTransform || layer->has3DTrans form(); |
1056 | 1063 |
1057 if (overlapMap) | 1064 if (overlapMap) |
1058 overlapMap->geometryMap().popMappingsToAncestor(ancestorLayer); | 1065 overlapMap->geometryMap().popMappingsToAncestor(ancestorLayer); |
1059 } | 1066 } |
1060 | 1067 |
1061 void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render Layer* parentLayer) | 1068 void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render Layer* parentLayer) |
1062 { | 1069 { |
1063 ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer ); | 1070 ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer ); |
1064 ASSERT(childLayer->isComposited()); | 1071 ASSERT(childLayer->backing()); |
1065 | 1072 |
1066 // It's possible to be called with a parent that isn't yet composited when w e're doing | 1073 // It's possible to be called with a parent that isn't yet composited when w e're doing |
1067 // partial updates as required by painting or hit testing. Just bail in that case; | 1074 // partial updates as required by painting or hit testing. Just bail in that case; |
1068 // we'll do a full layer update soon. | 1075 // we'll do a full layer update soon. |
1069 if (!parentLayer || !parentLayer->isComposited()) | 1076 if (!parentLayer || !parentLayer->backing()) |
1070 return; | 1077 return; |
1071 | 1078 |
1072 if (parentLayer) { | 1079 if (parentLayer) { |
1073 GraphicsLayer* hostingLayer = parentLayer->backing()->parentForSublayers (); | 1080 GraphicsLayer* hostingLayer = parentLayer->backing()->parentForSublayers (); |
1074 GraphicsLayer* hostedLayer = childLayer->backing()->childForSuperlayers( ); | 1081 GraphicsLayer* hostedLayer = childLayer->backing()->childForSuperlayers( ); |
1075 | 1082 |
1076 hostingLayer->addChild(hostedLayer); | 1083 hostingLayer->addChild(hostedLayer); |
1077 } else | 1084 } else |
1078 childLayer->backing()->childForSuperlayers()->removeFromParent(); | 1085 childLayer->backing()->childForSuperlayers()->removeFromParent(); |
1079 } | 1086 } |
1080 | 1087 |
1081 void RenderLayerCompositor::removeCompositedChildren(RenderLayer* layer) | 1088 void RenderLayerCompositor::removeCompositedChildren(RenderLayer* layer) |
1082 { | 1089 { |
1083 ASSERT(layer->isComposited()); | 1090 ASSERT(layer->backing()); |
1084 | 1091 |
1085 GraphicsLayer* hostingLayer = layer->backing()->parentForSublayers(); | 1092 GraphicsLayer* hostingLayer = layer->backing()->parentForSublayers(); |
1086 hostingLayer->removeAllChildren(); | 1093 hostingLayer->removeAllChildren(); |
1087 } | 1094 } |
1088 | 1095 |
1089 bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideo* o) const | 1096 bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideo* o) const |
1090 { | 1097 { |
1091 if (!m_hasAcceleratedCompositing) | 1098 if (!m_hasAcceleratedCompositing) |
1092 return false; | 1099 return false; |
1093 | 1100 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1362 return 0; | 1369 return 0; |
1363 } | 1370 } |
1364 | 1371 |
1365 bool RenderLayerCompositor::parentFrameContentLayers(RenderPart* renderer) | 1372 bool RenderLayerCompositor::parentFrameContentLayers(RenderPart* renderer) |
1366 { | 1373 { |
1367 RenderLayerCompositor* innerCompositor = frameContentsCompositor(renderer); | 1374 RenderLayerCompositor* innerCompositor = frameContentsCompositor(renderer); |
1368 if (!innerCompositor || !innerCompositor->inCompositingMode() || innerCompos itor->rootLayerAttachment() != RootLayerAttachedViaEnclosingFrame) | 1375 if (!innerCompositor || !innerCompositor->inCompositingMode() || innerCompos itor->rootLayerAttachment() != RootLayerAttachedViaEnclosingFrame) |
1369 return false; | 1376 return false; |
1370 | 1377 |
1371 RenderLayer* layer = renderer->layer(); | 1378 RenderLayer* layer = renderer->layer(); |
1372 if (!layer->isComposited()) | 1379 if (!layer->backing()) |
1373 return false; | 1380 return false; |
1374 | 1381 |
1375 RenderLayerBacking* backing = layer->backing(); | 1382 RenderLayerBacking* backing = layer->backing(); |
1376 GraphicsLayer* hostingLayer = backing->parentForSublayers(); | 1383 GraphicsLayer* hostingLayer = backing->parentForSublayers(); |
1377 GraphicsLayer* rootLayer = innerCompositor->rootGraphicsLayer(); | 1384 GraphicsLayer* rootLayer = innerCompositor->rootGraphicsLayer(); |
1378 if (hostingLayer->children().size() != 1 || hostingLayer->children()[0] != r ootLayer) { | 1385 if (hostingLayer->children().size() != 1 || hostingLayer->children()[0] != r ootLayer) { |
1379 hostingLayer->removeAllChildren(); | 1386 hostingLayer->removeAllChildren(); |
1380 hostingLayer->addChild(rootLayer); | 1387 hostingLayer->addChild(rootLayer); |
1381 } | 1388 } |
1382 return true; | 1389 return true; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1488 | 1495 |
1489 | 1496 |
1490 void RenderLayerCompositor::repaintCompositedLayers(const IntRect* absRect) | 1497 void RenderLayerCompositor::repaintCompositedLayers(const IntRect* absRect) |
1491 { | 1498 { |
1492 recursiveRepaintLayer(rootRenderLayer(), absRect); | 1499 recursiveRepaintLayer(rootRenderLayer(), absRect); |
1493 } | 1500 } |
1494 | 1501 |
1495 void RenderLayerCompositor::recursiveRepaintLayer(RenderLayer* layer, const IntR ect* rect) | 1502 void RenderLayerCompositor::recursiveRepaintLayer(RenderLayer* layer, const IntR ect* rect) |
1496 { | 1503 { |
1497 // FIXME: This method does not work correctly with transforms. | 1504 // FIXME: This method does not work correctly with transforms. |
1498 if (layer->isComposited() && !layer->backing()->paintsIntoCompositedAncestor ()) { | 1505 if (layer->compositingState() == PaintsIntoOwnBacking) { |
1499 if (rect) | 1506 if (rect) |
1500 layer->setBackingNeedsRepaintInRect(*rect); | 1507 layer->setBackingNeedsRepaintInRect(*rect); |
1501 else | 1508 else |
1502 layer->setBackingNeedsRepaint(); | 1509 layer->setBackingNeedsRepaint(); |
1503 } | 1510 } |
1504 | 1511 |
1505 #if !ASSERT_DISABLED | 1512 #if !ASSERT_DISABLED |
1506 LayerListMutationDetector mutationChecker(layer); | 1513 LayerListMutationDetector mutationChecker(layer); |
1507 #endif | 1514 #endif |
1508 | 1515 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1581 | 1588 |
1582 detachRootLayer(); | 1589 detachRootLayer(); |
1583 } | 1590 } |
1584 } | 1591 } |
1585 | 1592 |
1586 void RenderLayerCompositor::clearBackingForLayerIncludingDescendants(RenderLayer * layer) | 1593 void RenderLayerCompositor::clearBackingForLayerIncludingDescendants(RenderLayer * layer) |
1587 { | 1594 { |
1588 if (!layer) | 1595 if (!layer) |
1589 return; | 1596 return; |
1590 | 1597 |
1591 if (layer->isComposited()) { | 1598 if (layer->backing()) { |
1592 removeViewportConstrainedLayer(layer); | 1599 removeViewportConstrainedLayer(layer); |
1593 layer->clearBacking(); | 1600 layer->clearBacking(); |
1594 } | 1601 } |
1595 | 1602 |
1596 for (RenderLayer* currLayer = layer->firstChild(); currLayer; currLayer = cu rrLayer->nextSibling()) | 1603 for (RenderLayer* currLayer = layer->firstChild(); currLayer; currLayer = cu rrLayer->nextSibling()) |
1597 clearBackingForLayerIncludingDescendants(currLayer); | 1604 clearBackingForLayerIncludingDescendants(currLayer); |
1598 } | 1605 } |
1599 | 1606 |
1600 void RenderLayerCompositor::clearBackingForAllLayers() | 1607 void RenderLayerCompositor::clearBackingForAllLayers() |
1601 { | 1608 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1635 bool RenderLayerCompositor::canBeComposited(const RenderLayer* layer) const | 1642 bool RenderLayerCompositor::canBeComposited(const RenderLayer* layer) const |
1636 { | 1643 { |
1637 // FIXME: We disable accelerated compositing for elements in a RenderFlowThr ead as it doesn't work properly. | 1644 // FIXME: We disable accelerated compositing for elements in a RenderFlowThr ead as it doesn't work properly. |
1638 // See http://webkit.org/b/84900 to re-enable it. | 1645 // See http://webkit.org/b/84900 to re-enable it. |
1639 return m_hasAcceleratedCompositing && layer->isSelfPaintingLayer() && layer- >renderer()->flowThreadState() == RenderObject::NotInsideFlowThread; | 1646 return m_hasAcceleratedCompositing && layer->isSelfPaintingLayer() && layer- >renderer()->flowThreadState() == RenderObject::NotInsideFlowThread; |
1640 } | 1647 } |
1641 | 1648 |
1642 bool RenderLayerCompositor::requiresOwnBackingStore(const RenderLayer* layer, co nst RenderLayer* compositingAncestorLayer) const | 1649 bool RenderLayerCompositor::requiresOwnBackingStore(const RenderLayer* layer, co nst RenderLayer* compositingAncestorLayer) const |
1643 { | 1650 { |
1644 RenderObject* renderer = layer->renderer(); | 1651 RenderObject* renderer = layer->renderer(); |
1652 | |
1653 // A layer definitely needs its own backing if we cannot paint into the comp osited ancestor. | |
1645 if (compositingAncestorLayer | 1654 if (compositingAncestorLayer |
1646 && !(compositingAncestorLayer->backing()->graphicsLayer()->drawsContent( ) | 1655 && !(compositingAncestorLayer->backing()->graphicsLayer()->drawsContent( ) |
1647 || compositingAncestorLayer->backing()->paintsIntoCompositedAncestor ())) | 1656 || compositingAncestorLayer->backing()->paintsIntoCompositedAncestor ())) |
1648 return true; | 1657 return true; |
1649 | 1658 |
1650 if (layer->isRootLayer() | 1659 if (layer->isRootLayer() |
1651 || layer->transform() // note: excludes perspective and transformStyle3D . | 1660 || layer->transform() // note: excludes perspective and transformStyle3D . |
1652 || requiresCompositingForVideo(renderer) | 1661 || requiresCompositingForVideo(renderer) |
1653 || requiresCompositingForCanvas(renderer) | 1662 || requiresCompositingForCanvas(renderer) |
1654 || requiresCompositingForPlugin(renderer) | 1663 || requiresCompositingForPlugin(renderer) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1725 if (requiresCompositingForOutOfFlowClipping(layer)) | 1734 if (requiresCompositingForOutOfFlowClipping(layer)) |
1726 directReasons |= CompositingReasonOutOfFlowClipping; | 1735 directReasons |= CompositingReasonOutOfFlowClipping; |
1727 | 1736 |
1728 return directReasons; | 1737 return directReasons; |
1729 } | 1738 } |
1730 | 1739 |
1731 CompositingReasons RenderLayerCompositor::reasonsForCompositing(const RenderLaye r* layer) const | 1740 CompositingReasons RenderLayerCompositor::reasonsForCompositing(const RenderLaye r* layer) const |
1732 { | 1741 { |
1733 CompositingReasons reasons = CompositingReasonNone; | 1742 CompositingReasons reasons = CompositingReasonNone; |
1734 | 1743 |
1735 if (!layer || !layer->isComposited()) | 1744 if (!layer || !layer->backing()) |
1736 return reasons; | 1745 return reasons; |
1737 | 1746 |
1738 return layer->compositingReasons(); | 1747 return layer->compositingReasons(); |
1739 } | 1748 } |
1740 | 1749 |
1741 #if !LOG_DISABLED | 1750 #if !LOG_DISABLED |
1742 const char* RenderLayerCompositor::logReasonsForCompositing(const RenderLayer* l ayer) | 1751 const char* RenderLayerCompositor::logReasonsForCompositing(const RenderLayer* l ayer) |
1743 { | 1752 { |
1744 CompositingReasons reasons = reasonsForCompositing(layer); | 1753 CompositingReasons reasons = reasonsForCompositing(layer); |
1745 | 1754 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1816 } | 1825 } |
1817 #endif | 1826 #endif |
1818 | 1827 |
1819 // Return true if the given layer has some ancestor in the RenderLayer hierarchy that clips, | 1828 // Return true if the given layer has some ancestor in the RenderLayer hierarchy that clips, |
1820 // up to the enclosing compositing ancestor. This is required because compositin g layers are parented | 1829 // up to the enclosing compositing ancestor. This is required because compositin g layers are parented |
1821 // according to the z-order hierarchy, yet clipping goes down the renderer hiera rchy. | 1830 // according to the z-order hierarchy, yet clipping goes down the renderer hiera rchy. |
1822 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th e renderer hierarchy, | 1831 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th e renderer hierarchy, |
1823 // but a sibling in the z-order hierarchy. | 1832 // but a sibling in the z-order hierarchy. |
1824 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const | 1833 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const |
1825 { | 1834 { |
1826 if (!layer->isComposited() || !layer->parent()) | 1835 if (!layer->backing() || !layer->parent()) |
Ian Vollick
2013/10/02 19:12:26
I think this one is paints into own backing.
shawnsingh
2013/10/03 03:04:04
Trying to do this makes it fail compositing/overfl
| |
1827 return false; | 1836 return false; |
1828 | 1837 |
1829 const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer(); | 1838 const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer(); |
1830 if (!compositingAncestor) | 1839 if (!compositingAncestor) |
1831 return false; | 1840 return false; |
1832 | 1841 |
1833 // If the compositingAncestor clips, that will be taken care of by clipsComp ositingDescendants(), | 1842 // If the compositingAncestor clips, that will be taken care of by clipsComp ositingDescendants(), |
1834 // so we only care about clipping between its first child that is our ancest or (the computeClipRoot), | 1843 // so we only care about clipping between its first child that is our ancest or (the computeClipRoot), |
1835 // and layer. | 1844 // and layer. |
1836 const RenderLayer* computeClipRoot = 0; | 1845 const RenderLayer* computeClipRoot = 0; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1925 | 1934 |
1926 bool composite = renderer->isEmbeddedObject() && toRenderEmbeddedObject(rend erer)->allowsAcceleratedCompositing(); | 1935 bool composite = renderer->isEmbeddedObject() && toRenderEmbeddedObject(rend erer)->allowsAcceleratedCompositing(); |
1927 if (!composite) | 1936 if (!composite) |
1928 return false; | 1937 return false; |
1929 | 1938 |
1930 m_reevaluateCompositingAfterLayout = true; | 1939 m_reevaluateCompositingAfterLayout = true; |
1931 | 1940 |
1932 RenderWidget* pluginRenderer = toRenderWidget(renderer); | 1941 RenderWidget* pluginRenderer = toRenderWidget(renderer); |
1933 // If we can't reliably know the size of the plugin yet, don't change compos iting state. | 1942 // If we can't reliably know the size of the plugin yet, don't change compos iting state. |
1934 if (pluginRenderer->needsLayout()) | 1943 if (pluginRenderer->needsLayout()) |
1935 return pluginRenderer->hasLayer() && pluginRenderer->layer()->isComposit ed(); | 1944 return pluginRenderer->hasLayer() && pluginRenderer->layer()->backing(); |
1936 | 1945 |
1937 // Don't go into compositing mode if height or width are zero, or size is 1x 1. | 1946 // Don't go into compositing mode if height or width are zero, or size is 1x 1. |
1938 IntRect contentBox = pixelSnappedIntRect(pluginRenderer->contentBoxRect()); | 1947 IntRect contentBox = pixelSnappedIntRect(pluginRenderer->contentBoxRect()); |
1939 return contentBox.height() * contentBox.width() > 1; | 1948 return contentBox.height() * contentBox.width() > 1; |
1940 } | 1949 } |
1941 | 1950 |
1942 bool RenderLayerCompositor::requiresCompositingForFrame(RenderObject* renderer) const | 1951 bool RenderLayerCompositor::requiresCompositingForFrame(RenderObject* renderer) const |
1943 { | 1952 { |
1944 if (!renderer->isRenderPart()) | 1953 if (!renderer->isRenderPart()) |
1945 return false; | 1954 return false; |
1946 | 1955 |
1947 RenderPart* frameRenderer = toRenderPart(renderer); | 1956 RenderPart* frameRenderer = toRenderPart(renderer); |
1948 | 1957 |
1949 if (!frameRenderer->requiresAcceleratedCompositing()) | 1958 if (!frameRenderer->requiresAcceleratedCompositing()) |
1950 return false; | 1959 return false; |
1951 | 1960 |
1952 m_reevaluateCompositingAfterLayout = true; | 1961 m_reevaluateCompositingAfterLayout = true; |
1953 | 1962 |
1954 RenderLayerCompositor* innerCompositor = frameContentsCompositor(frameRender er); | 1963 RenderLayerCompositor* innerCompositor = frameContentsCompositor(frameRender er); |
1955 if (!innerCompositor) | 1964 if (!innerCompositor) |
1956 return false; | 1965 return false; |
1957 | 1966 |
1958 // If we can't reliably know the size of the iframe yet, don't change compos iting state. | 1967 // If we can't reliably know the size of the iframe yet, don't change compos iting state. |
1959 if (renderer->needsLayout()) | 1968 if (renderer->needsLayout()) |
1960 return frameRenderer->hasLayer() && frameRenderer->layer()->isComposited (); | 1969 return frameRenderer->hasLayer() && frameRenderer->layer()->backing(); |
1961 | 1970 |
1962 // Don't go into compositing mode if height or width are zero. | 1971 // Don't go into compositing mode if height or width are zero. |
1963 IntRect contentBox = pixelSnappedIntRect(frameRenderer->contentBoxRect()); | 1972 IntRect contentBox = pixelSnappedIntRect(frameRenderer->contentBoxRect()); |
1964 return contentBox.height() * contentBox.width() > 0; | 1973 return contentBox.height() * contentBox.width() > 0; |
1965 } | 1974 } |
1966 | 1975 |
1967 bool RenderLayerCompositor::requiresCompositingForBackfaceVisibilityHidden(Rende rObject* renderer) const | 1976 bool RenderLayerCompositor::requiresCompositingForBackfaceVisibilityHidden(Rende rObject* renderer) const |
1968 { | 1977 { |
1969 return canRender3DTransforms() && renderer->style()->backfaceVisibility() == BackfaceVisibilityHidden; | 1978 return canRender3DTransforms() && renderer->style()->backfaceVisibility() == BackfaceVisibilityHidden; |
1970 } | 1979 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2125 | 2134 |
2126 if (!hasScrollableAncestor) { | 2135 if (!hasScrollableAncestor) { |
2127 if (viewportConstrainedNotCompositedReason) | 2136 if (viewportConstrainedNotCompositedReason) |
2128 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForUnscrollableAncestors; | 2137 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForUnscrollableAncestors; |
2129 return false; | 2138 return false; |
2130 } | 2139 } |
2131 | 2140 |
2132 // Subsequent tests depend on layout. If we can't tell now, just keep things the way they are until layout is done. | 2141 // Subsequent tests depend on layout. If we can't tell now, just keep things the way they are until layout is done. |
2133 if (!m_inPostLayoutUpdate) { | 2142 if (!m_inPostLayoutUpdate) { |
2134 m_reevaluateCompositingAfterLayout = true; | 2143 m_reevaluateCompositingAfterLayout = true; |
2135 return layer->isComposited(); | 2144 return layer->backing(); |
2136 } | 2145 } |
2137 | 2146 |
2138 bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescend ant(); | 2147 bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescend ant(); |
2139 if (!paintsContent) { | 2148 if (!paintsContent) { |
2140 if (viewportConstrainedNotCompositedReason) | 2149 if (viewportConstrainedNotCompositedReason) |
2141 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForNoVisibleContent; | 2150 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForNoVisibleContent; |
2142 return false; | 2151 return false; |
2143 } | 2152 } |
2144 | 2153 |
2145 // Fixed position elements that are invisible in the current view don't get their own layer. | 2154 // Fixed position elements that are invisible in the current view don't get their own layer. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2236 return supportsFixedRootBackgroundCompositing() && m_renderView->rootBackgro undIsEntirelyFixed(); | 2245 return supportsFixedRootBackgroundCompositing() && m_renderView->rootBackgro undIsEntirelyFixed(); |
2237 } | 2246 } |
2238 | 2247 |
2239 GraphicsLayer* RenderLayerCompositor::fixedRootBackgroundLayer() const | 2248 GraphicsLayer* RenderLayerCompositor::fixedRootBackgroundLayer() const |
2240 { | 2249 { |
2241 // Get the fixed root background from the RenderView layer's backing. | 2250 // Get the fixed root background from the RenderView layer's backing. |
2242 RenderLayer* viewLayer = m_renderView->layer(); | 2251 RenderLayer* viewLayer = m_renderView->layer(); |
2243 if (!viewLayer) | 2252 if (!viewLayer) |
2244 return 0; | 2253 return 0; |
2245 | 2254 |
2246 if (viewLayer->isComposited() && viewLayer->backing()->backgroundLayerPaints FixedRootBackground()) | 2255 if (viewLayer->backing() && viewLayer->backing()->backgroundLayerPaintsFixed RootBackground()) |
Ian Vollick
2013/10/02 19:12:26
this one's paints into own backing.
shawnsingh
2013/10/03 03:04:04
Done.
| |
2247 return viewLayer->backing()->backgroundLayer(); | 2256 return viewLayer->backing()->backgroundLayer(); |
2248 | 2257 |
2249 return 0; | 2258 return 0; |
2250 } | 2259 } |
2251 | 2260 |
2252 static void resetTrackedRepaintRectsRecursive(GraphicsLayer* graphicsLayer) | 2261 static void resetTrackedRepaintRectsRecursive(GraphicsLayer* graphicsLayer) |
2253 { | 2262 { |
2254 if (!graphicsLayer) | 2263 if (!graphicsLayer) |
2255 return; | 2264 return; |
2256 | 2265 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2649 | 2658 |
2650 static bool isRootmostFixedOrStickyLayer(RenderLayer* layer) | 2659 static bool isRootmostFixedOrStickyLayer(RenderLayer* layer) |
2651 { | 2660 { |
2652 if (layer->renderer()->isStickyPositioned()) | 2661 if (layer->renderer()->isStickyPositioned()) |
2653 return true; | 2662 return true; |
2654 | 2663 |
2655 if (layer->renderer()->style()->position() != FixedPosition) | 2664 if (layer->renderer()->style()->position() != FixedPosition) |
2656 return false; | 2665 return false; |
2657 | 2666 |
2658 for (RenderLayer* stackingContainer = layer->ancestorStackingContainer(); st ackingContainer; stackingContainer = stackingContainer->ancestorStackingContaine r()) { | 2667 for (RenderLayer* stackingContainer = layer->ancestorStackingContainer(); st ackingContainer; stackingContainer = stackingContainer->ancestorStackingContaine r()) { |
2659 if (stackingContainer->isComposited() && stackingContainer->renderer()-> style()->position() == FixedPosition) | 2668 if (stackingContainer->backing() && stackingContainer->renderer()->style ()->position() == FixedPosition) |
2660 return false; | 2669 return false; |
2661 } | 2670 } |
2662 | 2671 |
2663 return true; | 2672 return true; |
2664 } | 2673 } |
2665 | 2674 |
2666 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer* layer) | 2675 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer* layer) |
2667 { | 2676 { |
2668 if (isRootmostFixedOrStickyLayer(layer)) | 2677 if (isRootmostFixedOrStickyLayer(layer)) |
2669 addViewportConstrainedLayer(layer); | 2678 addViewportConstrainedLayer(layer); |
2670 else | 2679 else |
2671 removeViewportConstrainedLayer(layer); | 2680 removeViewportConstrainedLayer(layer); |
2672 } | 2681 } |
2673 | 2682 |
2674 void RenderLayerCompositor::addViewportConstrainedLayer(RenderLayer* layer) | 2683 void RenderLayerCompositor::addViewportConstrainedLayer(RenderLayer* layer) |
2675 { | 2684 { |
2676 m_viewportConstrainedLayers.add(layer); | 2685 m_viewportConstrainedLayers.add(layer); |
2677 } | 2686 } |
2678 | 2687 |
2679 void RenderLayerCompositor::removeViewportConstrainedLayer(RenderLayer* layer) | 2688 void RenderLayerCompositor::removeViewportConstrainedLayer(RenderLayer* layer) |
2680 { | 2689 { |
2681 if (!m_viewportConstrainedLayers.contains(layer)) | 2690 if (!m_viewportConstrainedLayers.contains(layer)) |
2682 return; | 2691 return; |
2683 | 2692 |
2684 m_viewportConstrainedLayers.remove(layer); | 2693 m_viewportConstrainedLayers.remove(layer); |
2685 } | 2694 } |
2686 | 2695 |
2687 FixedPositionViewportConstraints RenderLayerCompositor::computeFixedViewportCons traints(RenderLayer* layer) const | 2696 FixedPositionViewportConstraints RenderLayerCompositor::computeFixedViewportCons traints(RenderLayer* layer) const |
2688 { | 2697 { |
2689 ASSERT(layer->isComposited()); | 2698 ASSERT(layer->backing()); |
2690 | 2699 |
2691 FrameView* frameView = m_renderView->frameView(); | 2700 FrameView* frameView = m_renderView->frameView(); |
2692 LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect() ; | 2701 LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect() ; |
2693 | 2702 |
2694 FixedPositionViewportConstraints constraints; | 2703 FixedPositionViewportConstraints constraints; |
2695 | 2704 |
2696 GraphicsLayer* graphicsLayer = layer->backing()->graphicsLayer(); | 2705 GraphicsLayer* graphicsLayer = layer->backing()->graphicsLayer(); |
2697 | 2706 |
2698 constraints.setLayerPositionAtLastLayout(graphicsLayer->position()); | 2707 constraints.setLayerPositionAtLastLayout(graphicsLayer->position()); |
2699 constraints.setViewportRectAtLastLayout(viewportRect); | 2708 constraints.setViewportRectAtLastLayout(viewportRect); |
(...skipping 17 matching lines...) Expand all Loading... | |
2717 | 2726 |
2718 // If top and bottom are auto, use top. | 2727 // If top and bottom are auto, use top. |
2719 if (style->top().isAuto() && style->bottom().isAuto()) | 2728 if (style->top().isAuto() && style->bottom().isAuto()) |
2720 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop); | 2729 constraints.addAnchorEdge(ViewportConstraints::AnchorEdgeTop); |
2721 | 2730 |
2722 return constraints; | 2731 return constraints; |
2723 } | 2732 } |
2724 | 2733 |
2725 StickyPositionViewportConstraints RenderLayerCompositor::computeStickyViewportCo nstraints(RenderLayer* layer) const | 2734 StickyPositionViewportConstraints RenderLayerCompositor::computeStickyViewportCo nstraints(RenderLayer* layer) const |
2726 { | 2735 { |
2727 ASSERT(layer->isComposited()); | 2736 ASSERT(layer->backing()); |
2728 | 2737 |
2729 FrameView* frameView = m_renderView->frameView(); | 2738 FrameView* frameView = m_renderView->frameView(); |
2730 LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect() ; | 2739 LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect() ; |
2731 | 2740 |
2732 StickyPositionViewportConstraints constraints; | 2741 StickyPositionViewportConstraints constraints; |
2733 | 2742 |
2734 RenderBoxModelObject* renderer = toRenderBoxModelObject(layer->renderer()); | 2743 RenderBoxModelObject* renderer = toRenderBoxModelObject(layer->renderer()); |
2735 | 2744 |
2736 renderer->computeStickyPositionConstraints(constraints, viewportRect); | 2745 renderer->computeStickyPositionConstraints(constraints, viewportRect); |
2737 | 2746 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2787 } else if (graphicsLayer == m_scrollLayer.get()) { | 2796 } else if (graphicsLayer == m_scrollLayer.get()) { |
2788 name = "Frame Scrolling Layer"; | 2797 name = "Frame Scrolling Layer"; |
2789 } else { | 2798 } else { |
2790 ASSERT_NOT_REACHED(); | 2799 ASSERT_NOT_REACHED(); |
2791 } | 2800 } |
2792 | 2801 |
2793 return name; | 2802 return name; |
2794 } | 2803 } |
2795 | 2804 |
2796 } // namespace WebCore | 2805 } // namespace WebCore |
OLD | NEW |