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