Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: Source/core/rendering/RenderLayerCompositor.cpp

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

Powered by Google App Engine
This is Rietveld 408576698