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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 { | 436 { |
437 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::computeCompo sitingRequirements"); | 437 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::computeCompo sitingRequirements"); |
438 OverlapMap overlapTestRequestMap; | 438 OverlapMap overlapTestRequestMap; |
439 | 439 |
440 // FIXME: Passing these unclippedDescendants down and keeping track | 440 // FIXME: Passing these unclippedDescendants down and keeping track |
441 // of them dynamically, we are requiring a full tree walk. This | 441 // of them dynamically, we are requiring a full tree walk. This |
442 // should be removed as soon as proper overlap testing based on | 442 // should be removed as soon as proper overlap testing based on |
443 // scrolling and animation bounds is implemented (crbug.com/252472). | 443 // scrolling and animation bounds is implemented (crbug.com/252472). |
444 Vector<RenderLayer*> unclippedDescendants; | 444 Vector<RenderLayer*> unclippedDescendants; |
445 computeCompositingRequirements(0, updateRoot, &overlapTestRequestMap , recursionData, saw3DTransform, unclippedDescendants); | 445 computeCompositingRequirements(0, updateRoot, &overlapTestRequestMap , recursionData, saw3DTransform, unclippedDescendants); |
446 } | |
446 | 447 |
448 { | |
449 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::assignLayers ToBackings"); | |
447 assignLayersToBackings(updateRoot, layersChanged); | 450 assignLayersToBackings(updateRoot, layersChanged); |
451 } | |
448 | 452 |
453 { | |
454 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::updateHasVis ibleNonLayerContent"); | |
449 const FrameView::ScrollableAreaSet* scrollableAreas = m_renderView-> frameView()->scrollableAreas(); | 455 const FrameView::ScrollableAreaSet* scrollableAreas = m_renderView-> frameView()->scrollableAreas(); |
450 if (scrollableAreas) { | 456 if (scrollableAreas) { |
451 for (FrameView::ScrollableAreaSet::iterator it = scrollableAreas ->begin(); it != scrollableAreas->end(); ++it) | 457 for (FrameView::ScrollableAreaSet::iterator it = scrollableAreas ->begin(); it != scrollableAreas->end(); ++it) |
452 (*it)->updateHasVisibleNonLayerContent(); | 458 (*it)->updateHasVisibleNonLayerContent(); |
453 } | 459 } |
454 } | 460 } |
461 | |
455 needHierarchyAndGeometryUpdate |= layersChanged; | 462 needHierarchyAndGeometryUpdate |= layersChanged; |
456 } | 463 } |
457 | 464 |
458 if (needHierarchyAndGeometryUpdate) { | 465 if (needHierarchyAndGeometryUpdate) { |
459 // Update the hierarchy of the compositing layers. | 466 // Update the hierarchy of the compositing layers. |
460 Vector<GraphicsLayer*> childList; | 467 Vector<GraphicsLayer*> childList; |
461 { | 468 { |
462 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::rebuildCompo sitingLayerTree"); | 469 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::rebuildCompo sitingLayerTree"); |
463 rebuildCompositingLayerTree(updateRoot, childList, 0); | 470 rebuildCompositingLayerTree(updateRoot, childList, 0); |
464 } | 471 } |
465 | 472 |
466 // Host the document layer in the RenderView's root layer. | 473 // Host the document layer in the RenderView's root layer. |
467 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isMainFra me()) { | 474 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isMainFra me()) { |
468 RenderVideo* video = findFullscreenVideoRenderer(&m_renderView->docu ment()); | 475 RenderVideo* video = findFullscreenVideoRenderer(&m_renderView->docu ment()); |
469 if (video && video->hasCompositedLayerMapping()) { | 476 if (video && video->hasCompositedLayerMapping()) { |
470 childList.clear(); | 477 childList.clear(); |
471 childList.append(video->compositedLayerMapping()->mainGraphicsLa yer()); | 478 childList.append(video->compositedLayerMapping()->mainGraphicsLa yer()); |
472 } | 479 } |
473 } | 480 } |
474 | 481 |
475 // FIXME: the following comment and if-statement seem wrong. We do trave rse visibility:hidden elements. | 482 // FIXME: the following comment and if-statement seem wrong. We do trave rse visibility:hidden elements. |
476 // Even when childList is empty, don't drop out of compositing mode if t here are | 483 // Even when childList is empty, don't drop out of compositing mode if t here are |
477 // composited layers that we didn't hit in our traversal (e.g. because o f visibility:hidden). | 484 // composited layers that we didn't hit in our traversal (e.g. because o f visibility:hidden). |
478 if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(updateRoot) ) | 485 if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(updateRoot) ) |
479 destroyRootLayer(); | 486 destroyRootLayer(); |
480 else | 487 else |
481 m_rootContentLayer->setChildren(childList); | 488 m_rootContentLayer->setChildren(childList); |
482 } else if (needGeometryUpdate) { | 489 } else if (needGeometryUpdate) { |
490 | |
Ian Vollick
2013/12/07 02:44:42
Unnecessary ws change?
shawnsingh
2013/12/11 18:50:34
removed
| |
483 // We just need to do a geometry update. This is only used for position: fixed scrolling; | 491 // We just need to do a geometry update. This is only used for position: fixed scrolling; |
484 // most of the time, geometry is updated via RenderLayer::styleChanged() . | 492 // most of the time, geometry is updated via RenderLayer::styleChanged() . |
485 updateLayerTreeGeometry(updateRoot); | 493 updateLayerTreeGeometry(updateRoot); |
486 } | 494 } |
487 | 495 |
488 ASSERT(updateRoot || !m_compositingLayersNeedRebuild); | 496 ASSERT(updateRoot || !m_compositingLayersNeedRebuild); |
489 | 497 |
490 if (!hasAcceleratedCompositing()) | 498 if (!hasAcceleratedCompositing()) |
491 enableCompositingMode(false); | 499 enableCompositingMode(false); |
492 | 500 |
493 // The scrolling coordinator may realize that it needs updating while compos iting was being updated in this function. | 501 // The scrolling coordinator may realize that it needs updating while compos iting was being updated in this function. |
494 needsToUpdateScrollingCoordinator |= scrollingCoordinator() ? scrollingCoord inator()->needsToUpdateAfterCompositingChange() : false; | 502 needsToUpdateScrollingCoordinator |= scrollingCoordinator() ? scrollingCoord inator()->needsToUpdateAfterCompositingChange() : false; |
495 if (needsToUpdateScrollingCoordinator && isMainFrame() && scrollingCoordinat or() && inCompositingMode()) | 503 if (needsToUpdateScrollingCoordinator && isMainFrame() && scrollingCoordinat or() && inCompositingMode()) |
496 scrollingCoordinator()->updateAfterCompositingChange(); | 504 scrollingCoordinator()->updateAfterCompositingChange(); |
497 | 505 |
498 // Inform the inspector that the layer tree has changed. | 506 // Inform the inspector that the layer tree has changed. |
499 if (isMainFrame()) | 507 if (isMainFrame()) |
500 InspectorInstrumentation::layerTreeDidChange(page()); | 508 InspectorInstrumentation::layerTreeDidChange(page()); |
501 } | 509 } |
502 | 510 |
503 void RenderLayerCompositor::layerBecameNonComposited(const RenderLayer* renderLa yer) | 511 void RenderLayerCompositor::layerBecameNonComposited(const RenderLayer* renderLa yer) |
504 { | 512 { |
505 ASSERT(m_compositedLayerCount > 0); | 513 ASSERT(m_compositedLayerCount > 0); |
506 --m_compositedLayerCount; | 514 --m_compositedLayerCount; |
507 } | 515 } |
508 | 516 |
517 static bool requiresCompositingOrSquashing(CompositingReasons reasons) | |
518 { | |
519 return reasons != CompositingReasonNone; | |
520 } | |
521 | |
509 static bool requiresCompositing(CompositingReasons reasons) | 522 static bool requiresCompositing(CompositingReasons reasons) |
510 { | 523 { |
511 return reasons != CompositingReasonNone; | 524 // Any reasons other than overlap or assumed overlap will require the layer to be separately compositing. |
525 return reasons & ~CompositingReasonComboAllOverlapReasons; | |
526 } | |
527 | |
528 static bool requiresSquashing(CompositingReasons reasons) | |
529 { | |
530 // If the layer has overlap or assumed overlap, but no other reasons, then i t should be squashed. | |
531 return !requiresCompositing(reasons) && (reasons & CompositingReasonComboAll OverlapReasons); | |
512 } | 532 } |
513 | 533 |
514 void RenderLayerCompositor::addOutOfFlowPositionedLayer(RenderLayer* layer) | 534 void RenderLayerCompositor::addOutOfFlowPositionedLayer(RenderLayer* layer) |
515 { | 535 { |
516 m_outOfFlowPositionedLayers.add(layer); | 536 m_outOfFlowPositionedLayers.add(layer); |
517 } | 537 } |
518 | 538 |
519 void RenderLayerCompositor::removeOutOfFlowPositionedLayer(RenderLayer* layer) | 539 void RenderLayerCompositor::removeOutOfFlowPositionedLayer(RenderLayer* layer) |
520 { | 540 { |
521 m_outOfFlowPositionedLayers.remove(layer); | 541 m_outOfFlowPositionedLayers.remove(layer); |
(...skipping 17 matching lines...) Expand all Loading... | |
539 | 559 |
540 layer->ensureCompositedLayerMapping(); | 560 layer->ensureCompositedLayerMapping(); |
541 compositedLayerMappingChanged = true; | 561 compositedLayerMappingChanged = true; |
542 | 562 |
543 // At this time, the ScrollingCooridnator only supports the top-leve l frame. | 563 // At this time, the ScrollingCooridnator only supports the top-leve l frame. |
544 if (layer->isRootLayer() && isMainFrame()) { | 564 if (layer->isRootLayer() && isMainFrame()) { |
545 if (ScrollingCoordinator* scrollingCoordinator = this->scrolling Coordinator()) | 565 if (ScrollingCoordinator* scrollingCoordinator = this->scrolling Coordinator()) |
546 scrollingCoordinator->frameViewRootLayerDidChange(m_renderVi ew->frameView()); | 566 scrollingCoordinator->frameViewRootLayerDidChange(m_renderVi ew->frameView()); |
547 } | 567 } |
548 | 568 |
569 // If this layer was previously squashed, we need to remove its refe rence to a groupedMapping right away, so | |
570 // that computing repaint rects will know the layer's correct compos itingState. | |
571 // FIXME: do we need to also remove the layer from it's location in the squashing list of its groupedMapping? | |
572 // Need to create a test where a squashed layer pops into compositin g. And also to cover all other | |
573 // sorts of compositingState transitions. | |
574 layer->setGroupedMapping(0); | |
575 | |
576 // FIXME: it seems premature to compute this before all compositing state has been updated? | |
549 // This layer and all of its descendants have cached repaints rects that are relative to | 577 // This layer and all of its descendants have cached repaints rects that are relative to |
550 // the repaint container, so change when compositing changes; we nee d to update them here. | 578 // the repaint container, so change when compositing changes; we nee d to update them here. |
551 if (layer->parent()) | 579 if (layer->parent()) |
552 layer->repainter().computeRepaintRectsIncludingDescendants(); | 580 layer->repainter().computeRepaintRectsIncludingDescendants(); |
553 } | 581 } |
554 | 582 |
555 if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForInt rinsicReasons()) | 583 if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForInt rinsicReasons()) |
556 compositedLayerMappingChanged = true; | 584 compositedLayerMappingChanged = true; |
557 } else { | 585 } else { |
558 if (layer->hasCompositedLayerMapping()) { | 586 if (layer->hasCompositedLayerMapping()) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 } | 633 } |
606 | 634 |
607 return compositedLayerMappingChanged || nonCompositedReasonChanged; | 635 return compositedLayerMappingChanged || nonCompositedReasonChanged; |
608 } | 636 } |
609 | 637 |
610 bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer) | 638 bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer) |
611 { | 639 { |
612 updateDirectCompositingReasons(layer); | 640 updateDirectCompositingReasons(layer); |
613 bool layerChanged = allocateOrClearCompositedLayerMapping(layer); | 641 bool layerChanged = allocateOrClearCompositedLayerMapping(layer); |
614 | 642 |
643 // FIXME: this is not correct... info may be out of date and squashing retur ning true doesn't indicate that the layer changed | |
644 layerChanged = requiresSquashing(layer->compositingReasons()); | |
645 | |
615 // See if we need content or clipping layers. Methods called here should ass ume | 646 // See if we need content or clipping layers. Methods called here should ass ume |
616 // that the compositing state of descendant layers has not been updated yet. | 647 // that the compositing state of descendant layers has not been updated yet. |
617 if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->u pdateGraphicsLayerConfiguration()) | 648 if (layer->hasCompositedLayerMapping() && layer->compositedLayerMapping()->u pdateGraphicsLayerConfiguration()) |
618 layerChanged = true; | 649 layerChanged = true; |
619 | 650 |
620 return layerChanged; | 651 return layerChanged; |
621 } | 652 } |
622 | 653 |
623 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer) | 654 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer) |
624 { | 655 { |
625 // If the renderer is not attached yet, no need to repaint. | 656 // If the renderer is not attached yet, no need to repaint. |
626 if (layer->renderer() != m_renderView && !layer->renderer()->parent()) | 657 if (layer->renderer() != m_renderView && !layer->renderer()->parent()) |
627 return; | 658 return; |
628 | 659 |
629 RenderLayerModelObject* repaintContainer = layer->renderer()->containerForRe paint(); | 660 RenderLayerModelObject* repaintContainer = layer->renderer()->containerForRe paint(); |
630 if (!repaintContainer) | 661 if (!repaintContainer) |
631 repaintContainer = m_renderView; | 662 repaintContainer = m_renderView; |
632 | 663 |
633 layer->repainter().repaintIncludingNonCompositingDescendants(repaintContaine r); | 664 layer->repainter().repaintIncludingNonCompositingDescendants(repaintContaine r); |
634 } | 665 } |
635 | 666 |
636 // This method assumes that layout is up-to-date, unlike repaintOnCompositingCha nge(). | 667 // This method assumes that layout is up-to-date, unlike repaintOnCompositingCha nge(). |
637 void RenderLayerCompositor::repaintInCompositedAncestor(RenderLayer* layer, cons t LayoutRect& rect) | 668 void RenderLayerCompositor::repaintInCompositedAncestor(RenderLayer* layer, cons t LayoutRect& rect) |
638 { | 669 { |
639 RenderLayer* compositedAncestor = layer->enclosingCompositingLayerForRepaint (false /*exclude self*/); | 670 RenderLayer* compositedAncestor = layer->enclosingCompositingLayerForRepaint (false /*exclude self*/); |
640 if (compositedAncestor) { | 671 if (compositedAncestor) { |
641 ASSERT(compositedAncestor->compositingState() == PaintsIntoOwnBacking); | 672 // FIXME: make sure repaintRect is computed correctly for squashed scena rio |
642 | |
643 LayoutPoint offset; | 673 LayoutPoint offset; |
644 layer->convertToLayerCoords(compositedAncestor, offset); | 674 layer->convertToLayerCoords(compositedAncestor, offset); |
645 | 675 |
646 LayoutRect repaintRect = rect; | 676 LayoutRect repaintRect = rect; |
647 repaintRect.moveBy(offset); | 677 repaintRect.moveBy(offset); |
648 | 678 |
649 compositedAncestor->repainter().setBackingNeedsRepaintInRect(repaintRect ); | 679 if (compositedAncestor->compositingState() == PaintsIntoOwnBacking) |
680 compositedAncestor->repainter().setBackingNeedsRepaintInRect(repaint Rect); | |
681 else if (compositedAncestor->compositingState() == PaintsIntoGroupedBack ing) | |
682 compositedAncestor->groupedMapping()->squashingLayer()->setNeedsDisp layInRect(repaintRect); | |
683 else | |
684 ASSERT_NOT_REACHED(); | |
650 } | 685 } |
651 } | 686 } |
652 | 687 |
653 // The bounds of the GraphicsLayer created for a compositing layer is the union of the bounds of all the descendant | 688 // The bounds of the GraphicsLayer created for a compositing layer is the union of the bounds of all the descendant |
654 // RenderLayers that are rendered by the composited RenderLayer. | 689 // RenderLayers that are rendered by the composited RenderLayer. |
655 IntRect RenderLayerCompositor::calculateCompositedBounds(const RenderLayer* laye r, const RenderLayer* ancestorLayer) const | 690 IntRect RenderLayerCompositor::calculateCompositedBounds(const RenderLayer* laye r, const RenderLayer* ancestorLayer) const |
656 { | 691 { |
657 if (!canBeComposited(layer)) | 692 if (!canBeComposited(layer)) |
658 return IntRect(); | 693 return IntRect(); |
659 | 694 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
802 for (size_t i = 0; i < unclippedDescendantsToRemove.size(); i++) | 837 for (size_t i = 0; i < unclippedDescendantsToRemove.size(); i++) |
803 unclippedDescendants.remove(unclippedDescendantsToRemove.at(unclippe dDescendantsToRemove.size() - i - 1)); | 838 unclippedDescendants.remove(unclippedDescendantsToRemove.at(unclippe dDescendantsToRemove.size() - i - 1)); |
804 | 839 |
805 if (reasonsToComposite & CompositingReasonOutOfFlowClipping) | 840 if (reasonsToComposite & CompositingReasonOutOfFlowClipping) |
806 unclippedDescendants.append(layer); | 841 unclippedDescendants.append(layer); |
807 } | 842 } |
808 | 843 |
809 bool haveComputedBounds = false; | 844 bool haveComputedBounds = false; |
810 IntRect absBounds; | 845 IntRect absBounds; |
811 // 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. |
812 if (overlapMap && !overlapMap->isEmpty() && currentRecursionData.m_testingOv erlap && !requiresCompositing(directReasons)) { | 847 if (overlapMap && !overlapMap->isEmpty() && currentRecursionData.m_testingOv erlap && !requiresCompositingOrSquashing(directReasons)) { |
813 // 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. |
814 absBounds = enclosingIntRect(overlapMap->geometryMap().absoluteRect(laye r->overlapBounds())); | 849 absBounds = enclosingIntRect(overlapMap->geometryMap().absoluteRect(laye r->overlapBounds())); |
815 | 850 |
816 // 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. |
817 if (absBounds.isEmpty()) | 852 if (absBounds.isEmpty()) |
818 absBounds.setSize(IntSize(1, 1)); | 853 absBounds.setSize(IntSize(1, 1)); |
819 haveComputedBounds = true; | 854 haveComputedBounds = true; |
820 overlapCompositingReason = overlapMap->overlapsLayers(absBounds) ? Compo sitingReasonOverlap : CompositingReasonNone; | 855 overlapCompositingReason = overlapMap->overlapsLayers(absBounds) ? Compo sitingReasonOverlap : CompositingReasonNone; |
821 } | 856 } |
822 | 857 |
823 reasonsToComposite |= overlapCompositingReason; | 858 reasonsToComposite |= overlapCompositingReason; |
824 | 859 |
825 // 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 |
826 // a compositing layer among them, so start by inheriting the compositing | 861 // a compositing layer among them, so start by inheriting the compositing |
827 // ancestor with m_subtreeIsCompositing set to false. | 862 // ancestor with m_subtreeIsCompositing set to false. |
828 CompositingRecursionData childRecursionData(currentRecursionData); | 863 CompositingRecursionData childRecursionData(currentRecursionData); |
829 childRecursionData.m_subtreeIsCompositing = false; | 864 childRecursionData.m_subtreeIsCompositing = false; |
830 | 865 |
831 bool willBeComposited = canBeComposited(layer) && requiresCompositing(reason sToComposite); | 866 bool willBeComposited = canBeComposited(layer) && requiresCompositingOrSquas hing(reasonsToComposite); |
832 if (willBeComposited) { | 867 if (willBeComposited) { |
833 // Tell the parent it has compositing descendants. | 868 // Tell the parent it has compositing descendants. |
834 currentRecursionData.m_subtreeIsCompositing = true; | 869 currentRecursionData.m_subtreeIsCompositing = true; |
835 // This layer now acts as the ancestor for kids. | 870 // This layer now acts as the ancestor for kids. |
836 childRecursionData.m_compositingAncestor = layer; | 871 childRecursionData.m_compositingAncestor = layer; |
837 | 872 |
838 // 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 |
839 // 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 |
840 // for overlap with anything behind this layer. | 875 // for overlap with anything behind this layer. |
841 if (overlapMap) | 876 if (overlapMap) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
920 if (layer->stackingNode()->isStackingContext()) { | 955 if (layer->stackingNode()->isStackingContext()) { |
921 layer->setShouldIsolateCompositedDescendants(childRecursionData.m_hasUni solatedCompositedBlendingDescendant); | 956 layer->setShouldIsolateCompositedDescendants(childRecursionData.m_hasUni solatedCompositedBlendingDescendant); |
922 } else { | 957 } else { |
923 layer->setShouldIsolateCompositedDescendants(false); | 958 layer->setShouldIsolateCompositedDescendants(false); |
924 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = child RecursionData.m_hasUnisolatedCompositedBlendingDescendant; | 959 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = child RecursionData.m_hasUnisolatedCompositedBlendingDescendant; |
925 } | 960 } |
926 | 961 |
927 // Now check for reasons to become composited that depend on the state of de scendant layers. | 962 // Now check for reasons to become composited that depend on the state of de scendant layers. |
928 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing( layer->renderer(), childRecursionData.m_subtreeIsCompositing, anyDescendantHas3D Transform); | 963 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing( layer->renderer(), childRecursionData.m_subtreeIsCompositing, anyDescendantHas3D Transform); |
929 reasonsToComposite |= subtreeCompositingReasons; | 964 reasonsToComposite |= subtreeCompositingReasons; |
930 if (!willBeComposited && canBeComposited(layer) && requiresCompositing(subtr eeCompositingReasons)) { | 965 if (!willBeComposited && canBeComposited(layer) && requiresCompositingOrSqua shing(subtreeCompositingReasons)) { |
931 childRecursionData.m_compositingAncestor = layer; | 966 childRecursionData.m_compositingAncestor = layer; |
932 if (overlapMap) { | 967 if (overlapMap) { |
933 // FIXME: this context push is effectively a no-op but needs to exis t for | 968 // FIXME: this context push is effectively a no-op but needs to exis t for |
934 // now, because the code is designed to push overlap information to the | 969 // now, because the code is designed to push overlap information to the |
935 // second-from-top context of the stack. | 970 // second-from-top context of the stack. |
936 overlapMap->beginNewOverlapTestingContext(); | 971 overlapMap->beginNewOverlapTestingContext(); |
937 addToOverlapMapRecursive(*overlapMap, layer); | 972 addToOverlapMapRecursive(*overlapMap, layer); |
938 } | 973 } |
939 willBeComposited = true; | 974 willBeComposited = true; |
940 } | 975 } |
(...skipping 21 matching lines...) Expand all Loading... | |
962 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi te & CompositingReasonClipsCompositingDescendants); | 997 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi te & CompositingReasonClipsCompositingDescendants); |
963 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) || isRunningAcceleratedTransformAnimation(layer->renderer())) | 998 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) || isRunningAcceleratedTransformAnimation(layer->renderer())) |
964 currentRecursionData.m_testingOverlap = false; | 999 currentRecursionData.m_testingOverlap = false; |
965 | 1000 |
966 if (overlapMap && childRecursionData.m_compositingAncestor == layer && !laye r->isRootLayer()) | 1001 if (overlapMap && childRecursionData.m_compositingAncestor == layer && !laye r->isRootLayer()) |
967 overlapMap->finishCurrentOverlapTestingContext(); | 1002 overlapMap->finishCurrentOverlapTestingContext(); |
968 | 1003 |
969 if (layer->isRootLayer()) { | 1004 if (layer->isRootLayer()) { |
970 // 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. |
971 // Otherwise, we can disable compositing entirely. | 1006 // Otherwise, we can disable compositing entirely. |
972 if (childRecursionData.m_subtreeIsCompositing || requiresCompositing(rea sonsToComposite) || m_forceCompositingMode) { | 1007 if (childRecursionData.m_subtreeIsCompositing || requiresCompositingOrSq uashing(reasonsToComposite) || m_forceCompositingMode) { |
973 willBeComposited = true; | 1008 willBeComposited = true; |
974 reasonsToComposite |= CompositingReasonRoot; | 1009 reasonsToComposite |= CompositingReasonRoot; |
975 } else { | 1010 } else { |
976 enableCompositingMode(false); | 1011 enableCompositingMode(false); |
977 willBeComposited = false; | 1012 willBeComposited = false; |
978 reasonsToComposite = CompositingReasonNone; | 1013 reasonsToComposite = CompositingReasonNone; |
979 } | 1014 } |
980 } | 1015 } |
981 | 1016 |
982 // 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. |
983 layer->setCompositingReasons(reasonsToComposite); | 1018 layer->setCompositingReasons(reasonsToComposite); |
984 | 1019 |
985 if (!willBeComposited && layer->parent()) | 1020 if (!willBeComposited && layer->parent()) |
986 layer->parent()->setHasNonCompositedChild(true); | 1021 layer->parent()->setHasNonCompositedChild(true); |
987 | 1022 |
988 descendantHas3DTransform |= anyDescendantHas3DTransform || layer->has3DTrans form(); | 1023 descendantHas3DTransform |= anyDescendantHas3DTransform || layer->has3DTrans form(); |
989 | 1024 |
990 if (overlapMap) | 1025 if (overlapMap) |
991 overlapMap->geometryMap().popMappingsToAncestor(ancestorLayer); | 1026 overlapMap->geometryMap().popMappingsToAncestor(ancestorLayer); |
992 } | 1027 } |
993 | 1028 |
994 void RenderLayerCompositor::assignLayersToBackings(RenderLayer* layer, bool& lay ersChanged) | 1029 void RenderLayerCompositor::SquashingState::updateSquashingStateForNewMapping(Co mpositedLayerMappingPtr newCompositedLayerMapping, bool hasNewCompositedLayerMap ping, IntPoint newOffsetFromAbsolute) |
1030 { | |
1031 // The most recent backing is done accumulating any more squashing layers. | |
1032 if (hasMostRecentMapping) | |
1033 mostRecentMapping->finishAccumulatingSquashingLayers(nextSquashedLayerIn dex); | |
1034 | |
1035 nextSquashedLayerIndex = 0; | |
1036 mostRecentMapping = newCompositedLayerMapping; | |
1037 hasMostRecentMapping = hasNewCompositedLayerMapping; | |
1038 offsetFromAbsolute = newOffsetFromAbsolute; | |
1039 } | |
1040 | |
1041 void RenderLayerCompositor::assignLayersToBackings(RenderLayer* updateRoot, bool & layersChanged) | |
1042 { | |
1043 SquashingState squashingState; | |
1044 assignLayersToBackingsInternal(updateRoot, squashingState, layersChanged); | |
1045 if (squashingState.hasMostRecentMapping) | |
1046 squashingState.mostRecentMapping->finishAccumulatingSquashingLayers(squa shingState.nextSquashedLayerIndex); | |
1047 } | |
1048 | |
1049 static IntPoint computeOffsetFromAbsolute(RenderLayer* layer) | |
1050 { | |
1051 TransformState transformState(TransformState::ApplyTransformDirection, Float Point()); | |
1052 layer->renderer()->mapLocalToContainer(0, transformState, ApplyContainerFlip ); | |
1053 transformState.flatten(); | |
1054 return roundedIntPoint(transformState.lastPlanarPoint()); | |
1055 } | |
1056 | |
1057 void RenderLayerCompositor::assignLayersToBackingsInternal(RenderLayer* layer, S quashingState& squashingState, bool& layersChanged) | |
995 { | 1058 { |
996 if (allocateOrClearCompositedLayerMapping(layer)) | 1059 if (allocateOrClearCompositedLayerMapping(layer)) |
997 layersChanged = true; | 1060 layersChanged = true; |
998 | 1061 |
999 if (layer->reflectionInfo() && updateLayerCompositingState(layer->reflection Info()->reflectionLayer())) | 1062 if (layer->reflectionInfo() && updateLayerCompositingState(layer->reflection Info()->reflectionLayer())) |
1000 layersChanged = true; | 1063 layersChanged = true; |
1001 | 1064 |
1002 // FIXME: squashing code here: if a layer requiresSquashing(), then assign t his layer to the most recent | 1065 // Add this layer to a squashing backing if needed. |
1003 // squashing layer and update recursion state of this function. | 1066 if (isLayerSquashingEnabled()) { |
1067 // NOTE: In the future as we generalize this, the background of this lay er may need to be assigned to a different backing than | |
1068 // the layer's own primary contents. This would happen when we have a co mposited negative z-index element that needs to | |
1069 // paint on top of the background, but below the layer's main contents. For now, because we always composite layers | |
1070 // when they have a composited negative z-index child, such layers will never need squashing so it is not yet an issue. | |
1071 if (requiresSquashing(layer->compositingReasons())) { | |
1072 // A layer that is squashed with other layers cannot have its own Co mpositedLayerMapping. | |
1073 ASSERT(!layer->hasCompositedLayerMapping()); | |
1074 ASSERT(squashingState.hasMostRecentMapping); | |
1075 | |
1076 IntPoint offsetFromAbsolute = computeOffsetFromAbsolute(layer); | |
1077 | |
1078 // FIXME: see if we can refactor this to be clearer | |
1079 IntSize offsetFromTargetBacking(offsetFromAbsolute.x() - squashingSt ate.offsetFromAbsolute.x(), | |
1080 offsetFromAbsolute.y() - squashingState.offsetFromAbsolute.y()); | |
1081 | |
1082 squashingState.mostRecentMapping->addRenderLayerToSquashingGraphicsL ayer(layer, offsetFromTargetBacking, squashingState.nextSquashedLayerIndex); | |
1083 squashingState.nextSquashedLayerIndex++; | |
1084 | |
1085 // FIXME: does this need to be true here? Do we need more logic to d ecide when it should be true? | |
1086 layersChanged = true; | |
1087 } | |
1088 } | |
1004 | 1089 |
1005 if (layer->stackingNode()->isStackingContainer()) { | 1090 if (layer->stackingNode()->isStackingContainer()) { |
1006 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren); | 1091 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren); |
1007 while (RenderLayerStackingNode* curNode = iterator.next()) | 1092 while (RenderLayerStackingNode* curNode = iterator.next()) |
1008 assignLayersToBackings(curNode->layer(), layersChanged); | 1093 assignLayersToBackingsInternal(curNode->layer(), squashingState, lay ersChanged); |
1009 } | 1094 } |
1010 | 1095 |
1011 // FIXME: squashing code here: if this layer actually becomes separately com posited, then we need to update the | 1096 if (isLayerSquashingEnabled()) { |
1012 // squashing layer that subsequent overlapping layers will contribute to. | 1097 // At this point, if the layer is to be "separately" composited, then it s backing becomes the most recent in paint-order. |
1098 if (layer->compositingState() == PaintsIntoOwnBacking || layer->composit ingState() == HasOwnBackingButPaintsIntoAncestor) { | |
1099 ASSERT(!requiresSquashing(layer->compositingReasons())); | |
1100 IntPoint offsetFromAbsolute = computeOffsetFromAbsolute(layer); | |
1101 squashingState.updateSquashingStateForNewMapping(layer->compositedLa yerMapping(), layer->hasCompositedLayerMapping(), offsetFromAbsolute); | |
1102 } | |
1103 } | |
1013 | 1104 |
1014 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren); | 1105 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren); |
1015 while (RenderLayerStackingNode* curNode = iterator.next()) | 1106 while (RenderLayerStackingNode* curNode = iterator.next()) |
1016 assignLayersToBackings(curNode->layer(), layersChanged); | 1107 assignLayersToBackingsInternal(curNode->layer(), squashingState, layersC hanged); |
1017 } | 1108 } |
1018 | 1109 |
1019 void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render Layer* parentLayer) | 1110 void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render Layer* parentLayer) |
1020 { | 1111 { |
1021 ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer ); | 1112 ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer ); |
1022 ASSERT(childLayer->hasCompositedLayerMapping()); | 1113 ASSERT(childLayer->hasCompositedLayerMapping()); |
1023 | 1114 |
1024 // It's possible to be called with a parent that isn't yet composited when w e're doing | 1115 // It's possible to be called with a parent that isn't yet composited when w e're doing |
1025 // partial updates as required by painting or hit testing. Just bail in that case; | 1116 // partial updates as required by painting or hit testing. Just bail in that case; |
1026 // we'll do a full layer update soon. | 1117 // we'll do a full layer update soon. |
1027 if (!parentLayer || !parentLayer->hasCompositedLayerMapping()) | 1118 if (!parentLayer || !parentLayer->hasCompositedLayerMapping()) |
1028 return; | 1119 return; |
1029 | 1120 |
1030 if (parentLayer) { | 1121 if (parentLayer) { |
1031 GraphicsLayer* hostingLayer = parentLayer->compositedLayerMapping()->par entForSublayers(); | 1122 GraphicsLayer* hostingLayer = parentLayer->compositedLayerMapping()->par entForSublayers(); |
1032 GraphicsLayer* hostedLayer = childLayer->compositedLayerMapping()->child ForSuperlayers(); | 1123 GraphicsLayer* hostedLayer = childLayer->compositedLayerMapping()->child ForSuperlayers(); |
1033 | 1124 |
1034 hostingLayer->addChild(hostedLayer); | 1125 hostingLayer->addChild(hostedLayer); |
1035 } else { | 1126 } else { |
1036 childLayer->compositedLayerMapping()->childForSuperlayers()->removeFromP arent(); | 1127 childLayer->compositedLayerMapping()->childForSuperlayers()->removeFromP arent(); |
1037 } | 1128 } |
1038 } | 1129 } |
1039 | 1130 |
1040 void RenderLayerCompositor::removeCompositedChildren(RenderLayer* layer) | 1131 void RenderLayerCompositor::removeCompositedChildren(RenderLayer* layer) |
1041 { | 1132 { |
1042 ASSERT(layer->hasCompositedLayerMapping()); | 1133 ASSERT(layer->hasCompositedLayerMapping()); |
1134 // FIXME: this is probably not necessary, a leftover from the hacked prototy pe. | |
1135 if (!layer->hasCompositedLayerMapping()) | |
1136 return; | |
1043 | 1137 |
1044 GraphicsLayer* hostingLayer = layer->compositedLayerMapping()->parentForSubl ayers(); | 1138 GraphicsLayer* hostingLayer = layer->compositedLayerMapping()->parentForSubl ayers(); |
1045 hostingLayer->removeAllChildren(); | 1139 hostingLayer->removeAllChildren(); |
1046 } | 1140 } |
1047 | 1141 |
1048 bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideo* o) const | 1142 bool RenderLayerCompositor::canAccelerateVideoRendering(RenderVideo* o) const |
1049 { | 1143 { |
1050 if (!m_hasAcceleratedCompositing) | 1144 if (!m_hasAcceleratedCompositing) |
1051 return false; | 1145 return false; |
1052 | 1146 |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1505 layerReasons &= ~CompositingReasonComboAllDirectReasons; | 1599 layerReasons &= ~CompositingReasonComboAllDirectReasons; |
1506 layerReasons |= directReasonsForCompositing(layer); | 1600 layerReasons |= directReasonsForCompositing(layer); |
1507 layer->setCompositingReasons(layerReasons); | 1601 layer->setCompositingReasons(layerReasons); |
1508 } | 1602 } |
1509 | 1603 |
1510 bool RenderLayerCompositor::needsOwnBacking(const RenderLayer* layer) const | 1604 bool RenderLayerCompositor::needsOwnBacking(const RenderLayer* layer) const |
1511 { | 1605 { |
1512 if (!canBeComposited(layer)) | 1606 if (!canBeComposited(layer)) |
1513 return false; | 1607 return false; |
1514 | 1608 |
1515 return requiresCompositing(layer->compositingReasons()) || (inCompositingMod e() && layer->isRootLayer()); | 1609 // If squashing is disabled, then layers that would have been squashed shoul d just be separately composited. |
1610 bool needsOwnBackingDueToOverlap = !isLayerSquashingEnabled() && requiresSqu ashing(layer->compositingReasons()); | |
Ian Vollick
2013/12/07 02:44:42
Does this not imply that the only reason we'd ever
shawnsingh
2013/12/11 18:50:34
No, it may not always be true... re-named variable
| |
1611 | |
1612 return requiresCompositing(layer->compositingReasons()) || needsOwnBackingDu eToOverlap || (inCompositingMode() && layer->isRootLayer()); | |
1516 } | 1613 } |
1517 | 1614 |
1518 bool RenderLayerCompositor::canBeComposited(const RenderLayer* layer) const | 1615 bool RenderLayerCompositor::canBeComposited(const RenderLayer* layer) const |
1519 { | 1616 { |
1520 // FIXME: We disable accelerated compositing for elements in a RenderFlowThr ead as it doesn't work properly. | 1617 // FIXME: We disable accelerated compositing for elements in a RenderFlowThr ead as it doesn't work properly. |
1521 // See http://webkit.org/b/84900 to re-enable it. | 1618 // See http://webkit.org/b/84900 to re-enable it. |
1522 return m_hasAcceleratedCompositing && layer->isSelfPaintingLayer() && layer- >renderer()->flowThreadState() == RenderObject::NotInsideFlowThread; | 1619 return m_hasAcceleratedCompositing && layer->isSelfPaintingLayer() && layer- >renderer()->flowThreadState() == RenderObject::NotInsideFlowThread; |
1523 } | 1620 } |
1524 | 1621 |
1525 CompositingReasons RenderLayerCompositor::directReasonsForCompositing(const Rend erLayer* layer) const | 1622 CompositingReasons RenderLayerCompositor::directReasonsForCompositing(const Rend erLayer* layer) const |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1570 // Return true if the given layer has some ancestor in the RenderLayer hierarchy that clips, | 1667 // Return true if the given layer has some ancestor in the RenderLayer hierarchy that clips, |
1571 // up to the enclosing compositing ancestor. This is required because compositin g layers are parented | 1668 // up to the enclosing compositing ancestor. This is required because compositin g layers are parented |
1572 // according to the z-order hierarchy, yet clipping goes down the renderer hiera rchy. | 1669 // according to the z-order hierarchy, yet clipping goes down the renderer hiera rchy. |
1573 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th e renderer hierarchy, | 1670 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th e renderer hierarchy, |
1574 // but a sibling in the z-order hierarchy. | 1671 // but a sibling in the z-order hierarchy. |
1575 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const | 1672 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const |
1576 { | 1673 { |
1577 if (!layer->hasCompositedLayerMapping() || !layer->parent()) | 1674 if (!layer->hasCompositedLayerMapping() || !layer->parent()) |
1578 return false; | 1675 return false; |
1579 | 1676 |
1677 // FIXME: need to see if new semantics of ancestorCompositingLayer() work co rrectly here? | |
1580 const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer(); | 1678 const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer(); |
1581 if (!compositingAncestor) | 1679 if (!compositingAncestor) |
1582 return false; | 1680 return false; |
1583 | 1681 |
1584 // If the compositingAncestor clips, that will be taken care of by clipsComp ositingDescendants(), | 1682 // If the compositingAncestor clips, that will be taken care of by clipsComp ositingDescendants(), |
1585 // so we only care about clipping between its first child that is our ancest or (the computeClipRoot), | 1683 // so we only care about clipping between its first child that is our ancest or (the computeClipRoot), |
1586 // and layer. | 1684 // and layer. |
1587 const RenderLayer* computeClipRoot = 0; | 1685 const RenderLayer* computeClipRoot = 0; |
1588 const RenderLayer* curr = layer; | 1686 const RenderLayer* curr = layer; |
1589 while (curr) { | 1687 while (curr) { |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2502 } else if (graphicsLayer == m_scrollLayer.get()) { | 2600 } else if (graphicsLayer == m_scrollLayer.get()) { |
2503 name = "Frame Scrolling Layer"; | 2601 name = "Frame Scrolling Layer"; |
2504 } else { | 2602 } else { |
2505 ASSERT_NOT_REACHED(); | 2603 ASSERT_NOT_REACHED(); |
2506 } | 2604 } |
2507 | 2605 |
2508 return name; | 2606 return name; |
2509 } | 2607 } |
2510 | 2608 |
2511 } // namespace WebCore | 2609 } // namespace WebCore |
OLD | NEW |