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

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: Addressed reviewer feedback 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 { 433 {
434 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::computeCompo sitingRequirements"); 434 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::computeCompo sitingRequirements");
435 OverlapMap overlapTestRequestMap; 435 OverlapMap overlapTestRequestMap;
436 436
437 // FIXME: Passing these unclippedDescendants down and keeping track 437 // FIXME: Passing these unclippedDescendants down and keeping track
438 // of them dynamically, we are requiring a full tree walk. This 438 // of them dynamically, we are requiring a full tree walk. This
439 // should be removed as soon as proper overlap testing based on 439 // should be removed as soon as proper overlap testing based on
440 // scrolling and animation bounds is implemented (crbug.com/252472). 440 // scrolling and animation bounds is implemented (crbug.com/252472).
441 Vector<RenderLayer*> unclippedDescendants; 441 Vector<RenderLayer*> unclippedDescendants;
442 computeCompositingRequirements(0, updateRoot, &overlapTestRequestMap , recursionData, saw3DTransform, unclippedDescendants); 442 computeCompositingRequirements(0, updateRoot, &overlapTestRequestMap , recursionData, saw3DTransform, unclippedDescendants);
443 }
443 444
445 {
446 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::assignLayers ToBackings");
444 assignLayersToBackings(updateRoot, layersChanged); 447 assignLayersToBackings(updateRoot, layersChanged);
448 }
445 449
450 {
451 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::updateHasVis ibleNonLayerContent");
446 const FrameView::ScrollableAreaSet* scrollableAreas = m_renderView-> frameView()->scrollableAreas(); 452 const FrameView::ScrollableAreaSet* scrollableAreas = m_renderView-> frameView()->scrollableAreas();
447 if (scrollableAreas) { 453 if (scrollableAreas) {
448 for (FrameView::ScrollableAreaSet::iterator it = scrollableAreas ->begin(); it != scrollableAreas->end(); ++it) 454 for (FrameView::ScrollableAreaSet::iterator it = scrollableAreas ->begin(); it != scrollableAreas->end(); ++it)
449 (*it)->updateHasVisibleNonLayerContent(); 455 (*it)->updateHasVisibleNonLayerContent();
450 } 456 }
451 } 457 }
458
452 needHierarchyAndGeometryUpdate |= layersChanged; 459 needHierarchyAndGeometryUpdate |= layersChanged;
453 } 460 }
454 461
455 if (needHierarchyAndGeometryUpdate) { 462 if (needHierarchyAndGeometryUpdate) {
456 // Update the hierarchy of the compositing layers. 463 // Update the hierarchy of the compositing layers.
457 Vector<GraphicsLayer*> childList; 464 Vector<GraphicsLayer*> childList;
458 { 465 {
459 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::rebuildCompo sitingLayerTree"); 466 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::rebuildCompo sitingLayerTree");
460 rebuildCompositingLayerTree(updateRoot, childList, 0); 467 rebuildCompositingLayerTree(updateRoot, childList, 0);
461 } 468 }
462 469
463 // Host the document layer in the RenderView's root layer. 470 // Host the document layer in the RenderView's root layer.
464 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isMainFra me()) { 471 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isMainFra me()) {
465 RenderVideo* video = findFullscreenVideoRenderer(&m_renderView->docu ment()); 472 RenderVideo* video = findFullscreenVideoRenderer(&m_renderView->docu ment());
466 if (video && video->hasCompositedLayerMapping()) { 473 if (video && video->hasCompositedLayerMapping()) {
467 childList.clear(); 474 childList.clear();
468 childList.append(video->compositedLayerMapping()->mainGraphicsLa yer()); 475 childList.append(video->compositedLayerMapping()->mainGraphicsLa yer());
469 } 476 }
470 } 477 }
471 478
472 // FIXME: the following comment and if-statement seem wrong. We do trave rse visibility:hidden elements. 479 // FIXME: the following comment and if-statement seem wrong. We do trave rse visibility:hidden elements.
473 // Even when childList is empty, don't drop out of compositing mode if t here are 480 // Even when childList is empty, don't drop out of compositing mode if t here are
474 // composited layers that we didn't hit in our traversal (e.g. because o f visibility:hidden). 481 // composited layers that we didn't hit in our traversal (e.g. because o f visibility:hidden).
475 if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(updateRoot) ) 482 if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(updateRoot) )
476 destroyRootLayer(); 483 destroyRootLayer();
477 else 484 else
478 m_rootContentLayer->setChildren(childList); 485 m_rootContentLayer->setChildren(childList);
479 } else if (needGeometryUpdate) { 486 } else if (needGeometryUpdate) {
487
480 // We just need to do a geometry update. This is only used for position: fixed scrolling; 488 // We just need to do a geometry update. This is only used for position: fixed scrolling;
481 // most of the time, geometry is updated via RenderLayer::styleChanged() . 489 // most of the time, geometry is updated via RenderLayer::styleChanged() .
482 updateLayerTreeGeometry(updateRoot); 490 updateLayerTreeGeometry(updateRoot);
483 } 491 }
484 492
485 ASSERT(updateRoot || !m_compositingLayersNeedRebuild); 493 ASSERT(updateRoot || !m_compositingLayersNeedRebuild);
486 494
487 if (!hasAcceleratedCompositing()) 495 if (!hasAcceleratedCompositing())
488 enableCompositingMode(false); 496 enableCompositingMode(false);
489 497
490 // The scrolling coordinator may realize that it needs updating while compos iting was being updated in this function. 498 // The scrolling coordinator may realize that it needs updating while compos iting was being updated in this function.
491 needsToUpdateScrollingCoordinator |= scrollingCoordinator() ? scrollingCoord inator()->needsToUpdateAfterCompositingChange() : false; 499 needsToUpdateScrollingCoordinator |= scrollingCoordinator() ? scrollingCoord inator()->needsToUpdateAfterCompositingChange() : false;
492 if (needsToUpdateScrollingCoordinator && isMainFrame() && scrollingCoordinat or() && inCompositingMode()) 500 if (needsToUpdateScrollingCoordinator && isMainFrame() && scrollingCoordinat or() && inCompositingMode())
493 scrollingCoordinator()->updateAfterCompositingChange(); 501 scrollingCoordinator()->updateAfterCompositingChange();
494 502
495 // Inform the inspector that the layer tree has changed. 503 // Inform the inspector that the layer tree has changed.
496 if (isMainFrame()) 504 if (isMainFrame())
497 InspectorInstrumentation::layerTreeDidChange(page()); 505 InspectorInstrumentation::layerTreeDidChange(page());
498 } 506 }
499 507
500 void RenderLayerCompositor::layerBecameNonComposited(const RenderLayer* renderLa yer) 508 void RenderLayerCompositor::layerBecameNonComposited(const RenderLayer* renderLa yer)
501 { 509 {
502 ASSERT(m_compositedLayerCount > 0); 510 ASSERT(m_compositedLayerCount > 0);
503 --m_compositedLayerCount; 511 --m_compositedLayerCount;
504 } 512 }
505 513
514 static bool requiresCompositingOrSquashing(CompositingReasons reasons)
515 {
516 return reasons != CompositingReasonNone;
517 }
518
506 static bool requiresCompositing(CompositingReasons reasons) 519 static bool requiresCompositing(CompositingReasons reasons)
507 { 520 {
508 return reasons != CompositingReasonNone; 521 // Any reasons other than overlap or assumed overlap will require the layer to be separately compositing.
522 return reasons & ~CompositingReasonComboAllOverlapReasons;
523 }
524
525 static bool requiresSquashing(CompositingReasons reasons)
526 {
527 // If the layer has overlap or assumed overlap, but no other reasons, then i t should be squashed.
Ian Vollick 2013/12/02 21:17:05 Can we also allow CompositingReasonOverflowScrolli
shawnsingh 2013/12/05 17:55:24 I don't think we can yet. If you remember we had
528 return !requiresCompositing(reasons) && (reasons & CompositingReasonComboAll OverlapReasons);
509 } 529 }
510 530
511 void RenderLayerCompositor::addOutOfFlowPositionedLayer(RenderLayer* layer) 531 void RenderLayerCompositor::addOutOfFlowPositionedLayer(RenderLayer* layer)
512 { 532 {
513 m_outOfFlowPositionedLayers.add(layer); 533 m_outOfFlowPositionedLayers.add(layer);
514 } 534 }
515 535
516 void RenderLayerCompositor::removeOutOfFlowPositionedLayer(RenderLayer* layer) 536 void RenderLayerCompositor::removeOutOfFlowPositionedLayer(RenderLayer* layer)
517 { 537 {
518 m_outOfFlowPositionedLayers.remove(layer); 538 m_outOfFlowPositionedLayers.remove(layer);
(...skipping 17 matching lines...) Expand all
536 556
537 layer->ensureCompositedLayerMapping(); 557 layer->ensureCompositedLayerMapping();
538 compositedLayerMappingChanged = true; 558 compositedLayerMappingChanged = true;
539 559
540 // At this time, the ScrollingCooridnator only supports the top-leve l frame. 560 // At this time, the ScrollingCooridnator only supports the top-leve l frame.
541 if (layer->isRootLayer() && isMainFrame()) { 561 if (layer->isRootLayer() && isMainFrame()) {
542 if (ScrollingCoordinator* scrollingCoordinator = this->scrolling Coordinator()) 562 if (ScrollingCoordinator* scrollingCoordinator = this->scrolling Coordinator())
543 scrollingCoordinator->frameViewRootLayerDidChange(m_renderVi ew->frameView()); 563 scrollingCoordinator->frameViewRootLayerDidChange(m_renderVi ew->frameView());
544 } 564 }
545 565
566 // If this layer was previously squashed, we need to remove its refe rence to a groupedMapping right away, so
567 // that computing repaint rects will know the layer's correct compos itingState.
568 // FIXME: do we need to also remove the layer from it's location in the squashing list of its groupedMapping?
569 // where are we doing that, again?
570 // and what happens when the groupedMapping may have changed under o ur feet based on previou CLMs being allocated/de-allocated?
Ian Vollick 2013/12/02 21:17:05 We've got ptrs going in both directions right? We
shawnsingh 2013/12/05 17:55:24 Short answer - yes. longer answer - I want to bra
571 layer->setGroupedMapping(0);
572
573 // FIXME: it seems premature to compute this before all compositing state has been updated?
546 // This layer and all of its descendants have cached repaints rects that are relative to 574 // This layer and all of its descendants have cached repaints rects that are relative to
547 // the repaint container, so change when compositing changes; we nee d to update them here. 575 // the repaint container, so change when compositing changes; we nee d to update them here.
548 if (layer->parent()) 576 if (layer->parent())
549 layer->repainter().computeRepaintRectsIncludingDescendants(); 577 layer->repainter().computeRepaintRectsIncludingDescendants();
550 } 578 }
551 579
552 if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForInt rinsicReasons()) 580 if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForInt rinsicReasons())
553 compositedLayerMappingChanged = true; 581 compositedLayerMappingChanged = true;
554 } else { 582 } else {
555 if (layer->hasCompositedLayerMapping()) { 583 if (layer->hasCompositedLayerMapping()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 } 630 }
603 631
604 return compositedLayerMappingChanged || nonCompositedReasonChanged; 632 return compositedLayerMappingChanged || nonCompositedReasonChanged;
605 } 633 }
606 634
607 bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer) 635 bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer)
608 { 636 {
609 updateDirectCompositingReasons(layer); 637 updateDirectCompositingReasons(layer);
610 bool layerChanged = allocateOrClearCompositedLayerMapping(layer); 638 bool layerChanged = allocateOrClearCompositedLayerMapping(layer);
611 639
640 // FIXME: this is not correct... info may be out of date and squashing retur ning true doesn't indicate that the layer changed
641 layerChanged = requiresSquashing(layer->compositingReasons());
642
612 // See if we need content or clipping layers. Methods called here should ass ume 643 // See if we need content or clipping layers. Methods called here should ass ume
613 // that the compositing state of descendant layers has not been updated yet. 644 // that the compositing state of descendant layers has not been updated yet.
614 if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->u pdateGraphicsLayerConfiguration()) 645 if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->u pdateGraphicsLayerConfiguration())
615 layerChanged = true; 646 layerChanged = true;
616 647
617 return layerChanged; 648 return layerChanged;
618 } 649 }
619 650
620 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer) 651 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer)
621 { 652 {
622 // If the renderer is not attached yet, no need to repaint. 653 // If the renderer is not attached yet, no need to repaint.
623 if (layer->renderer() != m_renderView && !layer->renderer()->parent()) 654 if (layer->renderer() != m_renderView && !layer->renderer()->parent())
624 return; 655 return;
625 656
626 RenderLayerModelObject* repaintContainer = layer->renderer()->containerForRe paint(); 657 RenderLayerModelObject* repaintContainer = layer->renderer()->containerForRe paint();
627 if (!repaintContainer) 658 if (!repaintContainer)
628 repaintContainer = m_renderView; 659 repaintContainer = m_renderView;
629 660
630 layer->repainter().repaintIncludingNonCompositingDescendants(repaintContaine r); 661 layer->repainter().repaintIncludingNonCompositingDescendants(repaintContaine r);
631 } 662 }
632 663
633 // This method assumes that layout is up-to-date, unlike repaintOnCompositingCha nge(). 664 // This method assumes that layout is up-to-date, unlike repaintOnCompositingCha nge().
634 void RenderLayerCompositor::repaintInCompositedAncestor(RenderLayer* layer, cons t LayoutRect& rect) 665 void RenderLayerCompositor::repaintInCompositedAncestor(RenderLayer* layer, cons t LayoutRect& rect)
635 { 666 {
636 RenderLayer* compositedAncestor = layer->enclosingCompositingLayerForRepaint (false /*exclude self*/); 667 RenderLayer* compositedAncestor = layer->enclosingCompositingLayerForRepaint (false /*exclude self*/);
637 if (compositedAncestor) { 668 if (compositedAncestor) {
638 ASSERT(compositedAncestor->compositingState() == PaintsIntoOwnBacking); 669 // FIXME: make sure repaintRect is computed correctly for squashed scena rio
639
640 LayoutPoint offset; 670 LayoutPoint offset;
641 layer->convertToLayerCoords(compositedAncestor, offset); 671 layer->convertToLayerCoords(compositedAncestor, offset);
642 672
643 LayoutRect repaintRect = rect; 673 LayoutRect repaintRect = rect;
644 repaintRect.moveBy(offset); 674 repaintRect.moveBy(offset);
645 675
646 compositedAncestor->repainter().setBackingNeedsRepaintInRect(repaintRect ); 676 if (compositedAncestor->compositingState() == PaintsIntoOwnBacking)
677 compositedAncestor->repainter().setBackingNeedsRepaintInRect(repaint Rect);
678 else if (compositedAncestor->compositingState() == PaintsIntoGroupedBack ing)
679 compositedAncestor->groupedMapping()->squashingLayer()->setNeedsDisp layInRect(repaintRect);
680 else
681 ASSERT_NOT_REACHED();
647 } 682 }
648 } 683 }
649 684
650 // The bounds of the GraphicsLayer created for a compositing layer is the union of the bounds of all the descendant 685 // The bounds of the GraphicsLayer created for a compositing layer is the union of the bounds of all the descendant
651 // RenderLayers that are rendered by the composited RenderLayer. 686 // RenderLayers that are rendered by the composited RenderLayer.
652 IntRect RenderLayerCompositor::calculateCompositedBounds(const RenderLayer* laye r, const RenderLayer* ancestorLayer) const 687 IntRect RenderLayerCompositor::calculateCompositedBounds(const RenderLayer* laye r, const RenderLayer* ancestorLayer) const
653 { 688 {
654 if (!canBeComposited(layer)) 689 if (!canBeComposited(layer))
655 return IntRect(); 690 return IntRect();
656 691
657 RenderLayer::CalculateLayerBoundsFlags flags = RenderLayer::DefaultCalculate LayerBoundsFlags | RenderLayer::ExcludeHiddenDescendants | RenderLayer::DontCons trainForMask; 692 RenderLayer::CalculateLayerBoundsFlags flags = RenderLayer::DefaultCalculate LayerBoundsFlags | RenderLayer::ExcludeHiddenDescendants | RenderLayer::DontCons trainForMask;
658 #if HAVE(COMPOSITOR_FILTER_OUTSETS) 693 #if HAVE(COMPOSITOR_FILTER_OUTSETS)
659 // If the compositor computes its own filter outsets, don't include them in the composited bounds. 694 // If the compositor computes its own filter outsets, don't include them in the composited bounds.
660 if (!layer->paintsWithFilters()) 695 if (!layer->paintsWithFilters())
661 flags &= ~RenderLayer::IncludeLayerFilterOutsets; 696 flags &= ~RenderLayer::IncludeLayerFilterOutsets;
662 #endif 697 #endif
663 return layer->calculateLayerBounds(ancestorLayer, 0, flags); 698 return layer->calculateLayerBounds(ancestorLayer, 0, flags);
664 } 699 }
665 700
666 void RenderLayerCompositor::layerWasAdded(RenderLayer* /*parent*/, RenderLayer* /*child*/) 701 void RenderLayerCompositor::layerWasAdded(RenderLayer* /*parent*/, RenderLayer* /*child*/)
667 { 702 {
703 // FIXME: possibly need to do something here for squashed layers...
668 setCompositingLayersNeedRebuild(); 704 setCompositingLayersNeedRebuild();
669 } 705 }
670 706
671 void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer* child) 707 void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer* child)
672 { 708 {
709 // FIXME: almost certainly need to do something here for squashed layers...
710
673 if (!child->hasCompositedLayerMapping() || parent->renderer()->documentBeing Destroyed()) 711 if (!child->hasCompositedLayerMapping() || parent->renderer()->documentBeing Destroyed())
674 return; 712 return;
675 713
676 removeViewportConstrainedLayer(child); 714 removeViewportConstrainedLayer(child);
677 repaintInCompositedAncestor(child, child->compositedLayerMapping()->composit edBounds()); 715 repaintInCompositedAncestor(child, child->compositedLayerMapping()->composit edBounds());
678 716
679 setCompositingParent(child, 0); 717 setCompositingParent(child, 0);
680 setCompositingLayersNeedRebuild(); 718 setCompositingLayersNeedRebuild();
681 } 719 }
682 720
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 for (size_t i = 0; i < unclippedDescendantsToRemove.size(); i++) 837 for (size_t i = 0; i < unclippedDescendantsToRemove.size(); i++)
800 unclippedDescendants.remove(unclippedDescendantsToRemove.at(unclippe dDescendantsToRemove.size() - i - 1)); 838 unclippedDescendants.remove(unclippedDescendantsToRemove.at(unclippe dDescendantsToRemove.size() - i - 1));
801 839
802 if (reasonsToComposite & CompositingReasonOutOfFlowClipping) 840 if (reasonsToComposite & CompositingReasonOutOfFlowClipping)
803 unclippedDescendants.append(layer); 841 unclippedDescendants.append(layer);
804 } 842 }
805 843
806 bool haveComputedBounds = false; 844 bool haveComputedBounds = false;
807 IntRect absBounds; 845 IntRect absBounds;
808 // If we know for sure the layer is going to be composited, don't bother loo king it up in the overlap map. 846 // If we know for sure the layer is going to be composited, don't bother loo king it up in the overlap map.
809 if (overlapMap && !overlapMap->isEmpty() && currentRecursionData.m_testingOv erlap && !requiresCompositing(directReasons)) { 847 if (overlapMap && !overlapMap->isEmpty() && currentRecursionData.m_testingOv erlap && !requiresCompositingOrSquashing(directReasons)) {
810 // If we're testing for overlap, we only need to composite if we overlap something that is already composited. 848 // If we're testing for overlap, we only need to composite if we overlap something that is already composited.
811 absBounds = enclosingIntRect(overlapMap->geometryMap().absoluteRect(laye r->overlapBounds())); 849 absBounds = enclosingIntRect(overlapMap->geometryMap().absoluteRect(laye r->overlapBounds()));
812 850
813 // Empty rects never intersect, but we need them to for the purposes of overlap testing. 851 // Empty rects never intersect, but we need them to for the purposes of overlap testing.
814 if (absBounds.isEmpty()) 852 if (absBounds.isEmpty())
815 absBounds.setSize(IntSize(1, 1)); 853 absBounds.setSize(IntSize(1, 1));
816 haveComputedBounds = true; 854 haveComputedBounds = true;
817 overlapCompositingReason = overlapMap->overlapsLayers(absBounds) ? Compo sitingReasonOverlap : CompositingReasonNone; 855 overlapCompositingReason = overlapMap->overlapsLayers(absBounds) ? Compo sitingReasonOverlap : CompositingReasonNone;
818 } 856 }
819 857
820 reasonsToComposite |= overlapCompositingReason; 858 reasonsToComposite |= overlapCompositingReason;
821 859
822 // The children of this layer don't need to composite, unless there is 860 // The children of this layer don't need to composite, unless there is
823 // a compositing layer among them, so start by inheriting the compositing 861 // a compositing layer among them, so start by inheriting the compositing
824 // ancestor with m_subtreeIsCompositing set to false. 862 // ancestor with m_subtreeIsCompositing set to false.
825 CompositingRecursionData childRecursionData(currentRecursionData); 863 CompositingRecursionData childRecursionData(currentRecursionData);
826 childRecursionData.m_subtreeIsCompositing = false; 864 childRecursionData.m_subtreeIsCompositing = false;
827 865
828 bool willBeComposited = canBeComposited(layer) && requiresCompositing(reason sToComposite); 866 bool willBeComposited = canBeComposited(layer) && requiresCompositingOrSquas hing(reasonsToComposite);
829 if (willBeComposited) { 867 if (willBeComposited) {
830 // Tell the parent it has compositing descendants. 868 // Tell the parent it has compositing descendants.
831 currentRecursionData.m_subtreeIsCompositing = true; 869 currentRecursionData.m_subtreeIsCompositing = true;
832 // This layer now acts as the ancestor for kids. 870 // This layer now acts as the ancestor for kids.
833 childRecursionData.m_compositingAncestor = layer; 871 childRecursionData.m_compositingAncestor = layer;
834 872
835 // Here we know that all children and the layer's own contents can blind ly paint into 873 // Here we know that all children and the layer's own contents can blind ly paint into
836 // this layer's backing, until a descendant is composited. So, we don't need to check 874 // this layer's backing, until a descendant is composited. So, we don't need to check
837 // for overlap with anything behind this layer. 875 // for overlap with anything behind this layer.
838 if (overlapMap) 876 if (overlapMap)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 if (inCompositingMode() && m_hasAcceleratedCompositing) 945 if (inCompositingMode() && m_hasAcceleratedCompositing)
908 willBeComposited = true; 946 willBeComposited = true;
909 } 947 }
910 948
911 // All layers (even ones that aren't being composited) need to get added to 949 // All layers (even ones that aren't being composited) need to get added to
912 // the overlap map. Layers that are not separately composited will paint int o their 950 // the overlap map. Layers that are not separately composited will paint int o their
913 // compositing ancestor's backing, and so are still considered for overlap. 951 // compositing ancestor's backing, and so are still considered for overlap.
914 if (overlapMap && childRecursionData.m_compositingAncestor && !childRecursio nData.m_compositingAncestor->isRootLayer()) 952 if (overlapMap && childRecursionData.m_compositingAncestor && !childRecursio nData.m_compositingAncestor->isRootLayer())
915 addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds); 953 addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds);
916 954
955 // At this point, we definitely have computed the absolute bounds for the la yers if it needs to be squashed or composited.
956 // FIXME: can we do something cleaner?
957 if (haveComputedBounds)
958 layer->setAbsoluteBounds(absBounds);
959
917 // Now check for reasons to become composited that depend on the state of de scendant layers. 960 // Now check for reasons to become composited that depend on the state of de scendant layers.
918 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing( layer->renderer(), childRecursionData.m_subtreeIsCompositing, anyDescendantHas3D Transform); 961 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing( layer->renderer(), childRecursionData.m_subtreeIsCompositing, anyDescendantHas3D Transform);
919 reasonsToComposite |= subtreeCompositingReasons; 962 reasonsToComposite |= subtreeCompositingReasons;
920 if (!willBeComposited && canBeComposited(layer) && requiresCompositing(subtr eeCompositingReasons)) { 963 if (!willBeComposited && canBeComposited(layer) && requiresCompositingOrSqua shing(subtreeCompositingReasons)) {
921 childRecursionData.m_compositingAncestor = layer; 964 childRecursionData.m_compositingAncestor = layer;
922 if (overlapMap) { 965 if (overlapMap) {
923 // FIXME: this context push is effectively a no-op but needs to exis t for 966 // FIXME: this context push is effectively a no-op but needs to exis t for
924 // now, because the code is designed to push overlap information to the 967 // now, because the code is designed to push overlap information to the
925 // second-from-top context of the stack. 968 // second-from-top context of the stack.
926 overlapMap->beginNewOverlapTestingContext(); 969 overlapMap->beginNewOverlapTestingContext();
927 addToOverlapMapRecursive(*overlapMap, layer); 970 addToOverlapMapRecursive(*overlapMap, layer);
928 } 971 }
929 willBeComposited = true; 972 willBeComposited = true;
930 } 973 }
(...skipping 18 matching lines...) Expand all
949 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi te & CompositingReasonClipsCompositingDescendants); 992 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi te & CompositingReasonClipsCompositingDescendants);
950 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) || isRunningAcceleratedTransformAnimation(layer->renderer())) 993 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) || isRunningAcceleratedTransformAnimation(layer->renderer()))
951 currentRecursionData.m_testingOverlap = false; 994 currentRecursionData.m_testingOverlap = false;
952 995
953 if (overlapMap && childRecursionData.m_compositingAncestor == layer && !laye r->isRootLayer()) 996 if (overlapMap && childRecursionData.m_compositingAncestor == layer && !laye r->isRootLayer())
954 overlapMap->finishCurrentOverlapTestingContext(); 997 overlapMap->finishCurrentOverlapTestingContext();
955 998
956 if (layer->isRootLayer()) { 999 if (layer->isRootLayer()) {
957 // The root layer needs to be composited if anything else in the tree is composited. 1000 // The root layer needs to be composited if anything else in the tree is composited.
958 // Otherwise, we can disable compositing entirely. 1001 // Otherwise, we can disable compositing entirely.
959 if (childRecursionData.m_subtreeIsCompositing || requiresCompositing(rea sonsToComposite) || m_forceCompositingMode) { 1002 if (childRecursionData.m_subtreeIsCompositing || requiresCompositingOrSq uashing(reasonsToComposite) || m_forceCompositingMode) {
960 willBeComposited = true; 1003 willBeComposited = true;
961 reasonsToComposite |= CompositingReasonRoot; 1004 reasonsToComposite |= CompositingReasonRoot;
962 } else { 1005 } else {
963 enableCompositingMode(false); 1006 enableCompositingMode(false);
964 willBeComposited = false; 1007 willBeComposited = false;
965 reasonsToComposite = CompositingReasonNone; 1008 reasonsToComposite = CompositingReasonNone;
966 } 1009 }
967 } 1010 }
968 1011
969 // At this point we have finished collecting all reasons to composite this l ayer. 1012 // At this point we have finished collecting all reasons to composite this l ayer.
970 layer->setCompositingReasons(reasonsToComposite); 1013 layer->setCompositingReasons(reasonsToComposite);
971 1014
972 if (!willBeComposited && layer->parent()) 1015 if (!willBeComposited && layer->parent())
973 layer->parent()->setHasNonCompositedChild(true); 1016 layer->parent()->setHasNonCompositedChild(true);
974 1017
975 descendantHas3DTransform |= anyDescendantHas3DTransform || layer->has3DTrans form(); 1018 descendantHas3DTransform |= anyDescendantHas3DTransform || layer->has3DTrans form();
976 1019
977 if (overlapMap) 1020 if (overlapMap)
978 overlapMap->geometryMap().popMappingsToAncestor(ancestorLayer); 1021 overlapMap->geometryMap().popMappingsToAncestor(ancestorLayer);
979 } 1022 }
980 1023
981 void RenderLayerCompositor::assignLayersToBackings(RenderLayer* layer, bool& lay ersChanged) 1024 void RenderLayerCompositor::SquashingState::updateSquashingStateForNewMapping(Co mpositedLayerMappingPtr newCompositedLayerMapping, bool hasNewCompositedLayerMap ping, IntSize newAbsToLocalOffset)
1025 {
1026 // The most recent backing is done accumulating any more squashing layers.
1027 if (hasMostRecentMapping)
1028 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn dex);
1029
1030 nextSquashedLayerIndex = 0;
1031 mostRecentMapping = newCompositedLayerMapping;
1032 hasMostRecentMapping = hasNewCompositedLayerMapping;
1033 absToLocalOffset = newAbsToLocalOffset;
1034 }
1035
1036 void RenderLayerCompositor::assignLayersToBackings(RenderLayer* updateRoot, bool & layersChanged)
1037 {
1038 SquashingState squashingState;
1039 assignLayersToBackingsInternal(updateRoot, squashingState, layersChanged);
1040 if (squashingState.hasMostRecentMapping)
1041 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa shingState.nextSquashedLayerIndex);
1042 }
1043
1044 void RenderLayerCompositor::assignLayersToBackingsInternal(RenderLayer* layer, S quashingState& squashingState, bool& layersChanged)
982 { 1045 {
983 if (allocateOrClearCompositedLayerMapping(layer)) 1046 if (allocateOrClearCompositedLayerMapping(layer))
984 layersChanged = true; 1047 layersChanged = true;
985 1048
986 if (layer->reflectionInfo() && updateLayerCompositingState(layer->reflection Info()->reflectionLayer())) 1049 if (layer->reflectionInfo() && updateLayerCompositingState(layer->reflection Info()->reflectionLayer()))
987 layersChanged = true; 1050 layersChanged = true;
988 1051
989 // FIXME: squashing code here: if a layer requiresSquashing(), then assign t his layer to the most recent 1052 // Add this layer to a squashing backing if needed.
990 // squashing layer and update recursion state of this function. 1053 if (isLayerSquashingEnabled()) {
1054 // NOTE: In the future as we generalize this, the background of this lay er may need to be assigned to a different backing than
1055 // the layer's own primary contents. This would happen when we have a co mposited negative z-index element that needs to
1056 // paint on top of the background, but below the layer's main contents. For now, because we always composite layers
1057 // when they have a composited negative z-index child, such layers will never need squashing so it is not yet an issue.
1058 if (requiresSquashing(layer->compositingReasons())) {
1059 // A layer that is squashed with other layers cannot have its own Co mpositedLayerMapping.
1060 ASSERT(!layer->hasCompositedLayerMapping());
1061 ASSERT(squashingState.hasMostRecentMapping);
1062
1063 IntRect absBounds = layer->absoluteBounds();
1064
1065 // FIXME: see if we can refactor this to be clearer
1066 IntSize offsetFromTargetBacking(absBounds.x() + squashingState.absTo LocalOffset.width(),
1067 absBounds.y() + squashingState.absToLocalOffset.height());
trchen 2013/12/02 22:56:55 I don't quite understand this, but doing a linear
shawnsingh 2013/12/05 17:55:24 New patch works for transforms =) (I have the tes
1068
1069 squashingState.mostRecentMapping->addRenderLayerToSquashingGraphicsL ayer(layer, offsetFromTargetBacking, squashingState.nextSquashedLayerIndex);
1070 squashingState.nextSquashedLayerIndex++;
1071
1072 // FIXME: does this need to be true here? Do we need more logic to d ecide when it should be true?
Ian Vollick 2013/12/02 21:17:05 I think we'll need to plumb a boolean out of addRe
shawnsingh 2013/12/05 17:55:24 Agreed - but not yet done in latest patch =/
1073 layersChanged = true;
1074 }
1075 }
991 1076
992 if (layer->stackingNode()->isStackingContainer()) { 1077 if (layer->stackingNode()->isStackingContainer()) {
993 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren); 1078 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren);
994 while (RenderLayerStackingNode* curNode = iterator.next()) 1079 while (RenderLayerStackingNode* curNode = iterator.next())
995 assignLayersToBackings(curNode->layer(), layersChanged); 1080 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay ersChanged);
996 } 1081 }
997 1082
998 // FIXME: squashing code here: if this layer actually becomes separately com posited, then we need to update the 1083 if (isLayerSquashingEnabled()) {
999 // squashing layer that subsequent overlapping layers will contribute to. 1084 // At this point, if the layer is to be "separately" composited, then it s backing becomes the most recent in paint-order.
1085 if (layer->compositingState() == PaintsIntoOwnBacking || layer->composit ingState() == HasOwnBackingButPaintsIntoAncestor) {
1086 ASSERT(!requiresSquashing(layer->compositingReasons()));
1087 IntRect absBounds = layer->absoluteBounds();
1088 squashingState.updateSquashingStateForNewMapping(layer->compositedLa yerMapping(), layer->hasCompositedLayerMapping(), IntSize(-absBounds.x(), -absBo unds.y()));
1089 }
1090 }
1000 1091
1001 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren); 1092 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren);
1002 while (RenderLayerStackingNode* curNode = iterator.next()) 1093 while (RenderLayerStackingNode* curNode = iterator.next())
1003 assignLayersToBackings(curNode->layer(), layersChanged); 1094 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersC hanged);
1004 } 1095 }
1005 1096
1006 void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render Layer* parentLayer) 1097 void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render Layer* parentLayer)
1007 { 1098 {
1008 ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer ); 1099 ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer );
1009 ASSERT(childLayer->hasCompositedLayerMapping()); 1100 ASSERT(childLayer->hasCompositedLayerMapping());
1010 1101
1011 // It's possible to be called with a parent that isn't yet composited when w e're doing 1102 // It's possible to be called with a parent that isn't yet composited when w e're doing
1012 // partial updates as required by painting or hit testing. Just bail in that case; 1103 // partial updates as required by painting or hit testing. Just bail in that case;
1013 // we'll do a full layer update soon. 1104 // we'll do a full layer update soon.
1014 if (!parentLayer || !parentLayer->hasCompositedLayerMapping()) 1105 if (!parentLayer || !parentLayer->hasCompositedLayerMapping())
1015 return; 1106 return;
1016 1107
1017 if (parentLayer) { 1108 if (parentLayer) {
1018 GraphicsLayer* hostingLayer = parentLayer->compositedLayerMapping()->par entForSublayers(); 1109 GraphicsLayer* hostingLayer = parentLayer->compositedLayerMapping()->par entForSublayers();
1019 GraphicsLayer* hostedLayer = childLayer->compositedLayerMapping()->child ForSuperlayers(); 1110 GraphicsLayer* hostedLayer = childLayer->compositedLayerMapping()->child ForSuperlayers();
1020 1111
1021 hostingLayer->addChild(hostedLayer); 1112 hostingLayer->addChild(hostedLayer);
1022 } else { 1113 } else {
1023 childLayer->compositedLayerMapping()->childForSuperlayers()->removeFromP arent(); 1114 childLayer->compositedLayerMapping()->childForSuperlayers()->removeFromP arent();
1024 } 1115 }
1025 } 1116 }
1026 1117
1027 void RenderLayerCompositor::removeCompositedChildren(RenderLayer* layer) 1118 void RenderLayerCompositor::removeCompositedChildren(RenderLayer* layer)
1028 { 1119 {
1029 ASSERT(layer->hasCompositedLayerMapping()); 1120 ASSERT(layer->hasCompositedLayerMapping());
1121 // FIXME: this is probably not necessary, a leftover from the hacked prototy pe.
1122 if (!layer->hasCompositedLayerMapping())
1123 return;
1030 1124
1031 GraphicsLayer* hostingLayer = layer->compositedLayerMapping()->parentForSubl ayers(); 1125 GraphicsLayer* hostingLayer = layer->compositedLayerMapping()->parentForSubl ayers();
1032 hostingLayer->removeAllChildren(); 1126 hostingLayer->removeAllChildren();
1033 } 1127 }
1034 1128
1035 bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideo* o) const 1129 bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideo* o) const
1036 { 1130 {
1037 if (!m_hasAcceleratedCompositing) 1131 if (!m_hasAcceleratedCompositing)
1038 return false; 1132 return false;
1039 1133
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 layerReasons &= ~CompositingReasonComboAllDirectReasons; 1586 layerReasons &= ~CompositingReasonComboAllDirectReasons;
1493 layerReasons |= directReasonsForCompositing(layer); 1587 layerReasons |= directReasonsForCompositing(layer);
1494 layer->setCompositingReasons(layerReasons); 1588 layer->setCompositingReasons(layerReasons);
1495 } 1589 }
1496 1590
1497 bool RenderLayerCompositor::needsOwnBacking(const RenderLayer* layer) const 1591 bool RenderLayerCompositor::needsOwnBacking(const RenderLayer* layer) const
1498 { 1592 {
1499 if (!canBeComposited(layer)) 1593 if (!canBeComposited(layer))
1500 return false; 1594 return false;
1501 1595
1502 return requiresCompositing(layer->compositingReasons()) || (inCompositingMod e() && layer->isRootLayer()); 1596 // If squashing is disabled, then layers that would have been squashed shoul d just be separately composited.
1597 bool needsOwnBackingDueToOverlap = !isLayerSquashingEnabled() && requiresSqu ashing(layer->compositingReasons());
1598
1599 return requiresCompositing(layer->compositingReasons()) || needsOwnBackingDu eToOverlap || (inCompositingMode() && layer->isRootLayer());
1503 } 1600 }
1504 1601
1505 bool RenderLayerCompositor::canBeComposited(const RenderLayer* layer) const 1602 bool RenderLayerCompositor::canBeComposited(const RenderLayer* layer) const
1506 { 1603 {
1507 // FIXME: We disable accelerated compositing for elements in a RenderFlowThr ead as it doesn't work properly. 1604 // FIXME: We disable accelerated compositing for elements in a RenderFlowThr ead as it doesn't work properly.
1508 // See http://webkit.org/b/84900 to re-enable it. 1605 // See http://webkit.org/b/84900 to re-enable it.
1509 return m_hasAcceleratedCompositing && layer->isSelfPaintingLayer() && layer- >renderer()->flowThreadState() == RenderObject::NotInsideFlowThread; 1606 return m_hasAcceleratedCompositing && layer->isSelfPaintingLayer() && layer- >renderer()->flowThreadState() == RenderObject::NotInsideFlowThread;
1510 } 1607 }
1511 1608
1512 CompositingReasons RenderLayerCompositor::directReasonsForCompositing(const Rend erLayer* layer) const 1609 CompositingReasons RenderLayerCompositor::directReasonsForCompositing(const Rend erLayer* layer) const
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 // Return true if the given layer has some ancestor in the RenderLayer hierarchy that clips, 1654 // Return true if the given layer has some ancestor in the RenderLayer hierarchy that clips,
1558 // up to the enclosing compositing ancestor. This is required because compositin g layers are parented 1655 // up to the enclosing compositing ancestor. This is required because compositin g layers are parented
1559 // according to the z-order hierarchy, yet clipping goes down the renderer hiera rchy. 1656 // according to the z-order hierarchy, yet clipping goes down the renderer hiera rchy.
1560 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th e renderer hierarchy, 1657 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th e renderer hierarchy,
1561 // but a sibling in the z-order hierarchy. 1658 // but a sibling in the z-order hierarchy.
1562 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const 1659 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const
1563 { 1660 {
1564 if (!layer->hasCompositedLayerMapping() || !layer->parent()) 1661 if (!layer->hasCompositedLayerMapping() || !layer->parent())
1565 return false; 1662 return false;
1566 1663
1664 // FIXME: need to see if new semantics of ancestorCompositingLayer() work co rrectly here?
1567 const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer(); 1665 const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer();
1568 if (!compositingAncestor) 1666 if (!compositingAncestor)
1569 return false; 1667 return false;
1570 1668
1571 // If the compositingAncestor clips, that will be taken care of by clipsComp ositingDescendants(), 1669 // If the compositingAncestor clips, that will be taken care of by clipsComp ositingDescendants(),
1572 // so we only care about clipping between its first child that is our ancest or (the computeClipRoot), 1670 // so we only care about clipping between its first child that is our ancest or (the computeClipRoot),
1573 // and layer. 1671 // and layer.
1574 const RenderLayer* computeClipRoot = 0; 1672 const RenderLayer* computeClipRoot = 0;
1575 const RenderLayer* curr = layer; 1673 const RenderLayer* curr = layer;
1576 while (curr) { 1674 while (curr) {
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 } else if (graphicsLayer == m_scrollLayer.get()) { 2582 } else if (graphicsLayer == m_scrollLayer.get()) {
2485 name = "Frame Scrolling Layer"; 2583 name = "Frame Scrolling Layer";
2486 } else { 2584 } else {
2487 ASSERT_NOT_REACHED(); 2585 ASSERT_NOT_REACHED();
2488 } 2586 }
2489 2587
2490 return name; 2588 return name;
2491 } 2589 }
2492 2590
2493 } // namespace WebCore 2591 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698