| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 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 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 // Regardless, mark the graphics layer, scrolling layer and scrolling block | 1514 // Regardless, mark the graphics layer, scrolling layer and scrolling block |
| 1515 // selection layer (if they exist) as not flattening. Having them flatten | 1515 // selection layer (if they exist) as not flattening. Having them flatten |
| 1516 // causes unclipped render surfaces which cause bugs. | 1516 // causes unclipped render surfaces which cause bugs. |
| 1517 // http://crbug.com/521768 | 1517 // http://crbug.com/521768 |
| 1518 if (hasScrollingLayer()) { | 1518 if (hasScrollingLayer()) { |
| 1519 m_graphicsLayer->setShouldFlattenTransform(false); | 1519 m_graphicsLayer->setShouldFlattenTransform(false); |
| 1520 m_scrollingLayer->setShouldFlattenTransform(false); | 1520 m_scrollingLayer->setShouldFlattenTransform(false); |
| 1521 } | 1521 } |
| 1522 } | 1522 } |
| 1523 | 1523 |
| 1524 // Some background on when you receive an element id or mutable properties. | |
| 1525 // | |
| 1526 // element id: | |
| 1527 // If you have a compositor proxy, an animation, or you're a scroller (and | |
| 1528 // might impl animate). | |
| 1529 // | |
| 1530 // mutable properties: | |
| 1531 // Only if you have a compositor proxy. | |
| 1532 // | |
| 1533 // The element id for the scroll layers is assigned when they're constructed, | |
| 1534 // since this is unconditional. However, the element id for the primary layer as | |
| 1535 // well as the mutable properties for all layers may change according to the | |
| 1536 // rules above so we update those values here. | |
| 1537 void CompositedLayerMapping::updateElementIdAndCompositorMutableProperties() | 1524 void CompositedLayerMapping::updateElementIdAndCompositorMutableProperties() |
| 1538 { | 1525 { |
| 1539 int elementId = 0; | 1526 if (!RuntimeEnabledFeatures::compositorWorkerEnabled()) |
| 1540 uint32_t primaryMutableProperties = CompositorMutableProperty::kNone; | 1527 return; |
| 1528 |
| 1529 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "CompositedLaye
rMapping::updateElementId()"); |
| 1530 |
| 1531 uint64_t elementId = 0; |
| 1532 uint32_t mainMutableProperties = CompositorMutableProperty::kNone; |
| 1541 uint32_t scrollMutableProperties = CompositorMutableProperty::kNone; | 1533 uint32_t scrollMutableProperties = CompositorMutableProperty::kNone; |
| 1542 | 1534 |
| 1543 Node* owningNode = m_owningLayer.layoutObject()->generatingNode(); | 1535 if (m_owningLayer.layoutObject()->style()->hasCompositorProxy()) { |
| 1544 Element* owningElement = nullptr; | 1536 if (Node* owningNode = m_owningLayer.layoutObject()->generatingNode()) { |
| 1545 if (owningNode && owningNode->isElementNode()) | 1537 if (owningNode->isElementNode()) { |
| 1546 owningElement = toElement(owningNode); | 1538 Element* owningElement = toElement(owningNode); |
| 1547 | 1539 uint32_t compositorMutableProperties = owningElement->compositor
MutableProperties(); |
| 1548 if (RuntimeEnabledFeatures::compositorWorkerEnabled() && owningElement && m_
owningLayer.layoutObject()->style()->hasCompositorProxy()) { | 1540 elementId = DOMNodeIds::idForNode(owningNode); |
| 1549 uint32_t compositorMutableProperties = owningElement->compositorMutableP
roperties(); | 1541 mainMutableProperties = (CompositorMutableProperty::kOpacity | C
ompositorMutableProperty::kTransform) & compositorMutableProperties; |
| 1550 elementId = DOMNodeIds::idForNode(owningNode); | 1542 scrollMutableProperties = (CompositorMutableProperty::kScrollLef
t | CompositorMutableProperty::kScrollTop) & compositorMutableProperties; |
| 1551 primaryMutableProperties = (CompositorMutableProperty::kOpacity | Compos
itorMutableProperty::kTransform) & compositorMutableProperties; | 1543 } |
| 1552 scrollMutableProperties = (CompositorMutableProperty::kScrollLeft | Comp
ositorMutableProperty::kScrollTop) & compositorMutableProperties; | 1544 } |
| 1553 } | 1545 } |
| 1554 | 1546 |
| 1555 if (m_owningLayer.layoutObject()->style()->shouldCompositeForCurrentAnimatio
ns() && owningNode) | 1547 m_graphicsLayer->setElementId(elementId); |
| 1556 elementId = DOMNodeIds::idForNode(owningNode); | 1548 m_graphicsLayer->setCompositorMutableProperties(mainMutableProperties); |
| 1557 | 1549 |
| 1558 CompositorElementId compositorElementId; | 1550 if (m_scrollingContentsLayer.get()) { |
| 1559 if (elementId) | 1551 m_scrollingContentsLayer->setElementId(elementId); |
| 1560 compositorElementId = createCompositorElementId(elementId, CompositorSub
ElementId::Primary); | |
| 1561 | |
| 1562 m_graphicsLayer->setElementId(compositorElementId); | |
| 1563 m_graphicsLayer->setCompositorMutableProperties(primaryMutableProperties); | |
| 1564 | |
| 1565 // We always set the elementId for m_scrollingContentsLayer since it can be | |
| 1566 // animated for smooth scrolling, so we don't need to set it conditionally | |
| 1567 // here. | |
| 1568 if (m_scrollingContentsLayer.get()) | |
| 1569 m_scrollingContentsLayer->setCompositorMutableProperties(scrollMutablePr
operties); | 1552 m_scrollingContentsLayer->setCompositorMutableProperties(scrollMutablePr
operties); |
| 1553 } |
| 1570 } | 1554 } |
| 1571 | 1555 |
| 1572 bool CompositedLayerMapping::updateForegroundLayer(bool needsForegroundLayer) | 1556 bool CompositedLayerMapping::updateForegroundLayer(bool needsForegroundLayer) |
| 1573 { | 1557 { |
| 1574 bool layerChanged = false; | 1558 bool layerChanged = false; |
| 1575 if (needsForegroundLayer) { | 1559 if (needsForegroundLayer) { |
| 1576 if (!m_foregroundLayer) { | 1560 if (!m_foregroundLayer) { |
| 1577 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor
eground); | 1561 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor
eground); |
| 1578 layerChanged = true; | 1562 layerChanged = true; |
| 1579 } | 1563 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 bool layerChanged = false; | 1630 bool layerChanged = false; |
| 1647 if (needsScrollingLayers) { | 1631 if (needsScrollingLayers) { |
| 1648 if (!m_scrollingLayer) { | 1632 if (!m_scrollingLayer) { |
| 1649 // Outer layer which corresponds with the scroll view. | 1633 // Outer layer which corresponds with the scroll view. |
| 1650 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForScro
llingContainer); | 1634 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForScro
llingContainer); |
| 1651 m_scrollingLayer->setDrawsContent(false); | 1635 m_scrollingLayer->setDrawsContent(false); |
| 1652 m_scrollingLayer->setMasksToBounds(true); | 1636 m_scrollingLayer->setMasksToBounds(true); |
| 1653 | 1637 |
| 1654 // Inner layer which renders the content that scrolls. | 1638 // Inner layer which renders the content that scrolls. |
| 1655 m_scrollingContentsLayer = createGraphicsLayer(CompositingReasonLaye
rForScrollingContents); | 1639 m_scrollingContentsLayer = createGraphicsLayer(CompositingReasonLaye
rForScrollingContents); |
| 1656 | |
| 1657 if (Node* owningNode = m_owningLayer.layoutObject()->generatingNode(
)) { | |
| 1658 m_scrollingContentsLayer->setElementId(createCompositorElementId
(DOMNodeIds::idForNode(owningNode), CompositorSubElementId::Scroll)); | |
| 1659 m_scrollingContentsLayer->setCompositorMutableProperties(Composi
torMutableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop); | |
| 1660 } | |
| 1661 | |
| 1662 m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); | 1640 m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); |
| 1663 | 1641 |
| 1664 layerChanged = true; | 1642 layerChanged = true; |
| 1665 if (scrollingCoordinator) { | 1643 if (scrollingCoordinator) { |
| 1666 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_ownin
gLayer.getScrollableArea()); | 1644 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_ownin
gLayer.getScrollableArea()); |
| 1667 scrollingCoordinator->scrollableAreasDidChange(); | 1645 scrollingCoordinator->scrollableAreasDidChange(); |
| 1668 } | 1646 } |
| 1669 } | 1647 } |
| 1670 } else if (m_scrollingLayer) { | 1648 } else if (m_scrollingLayer) { |
| 1671 m_scrollingLayer = nullptr; | 1649 m_scrollingLayer = nullptr; |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2676 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2654 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
| 2677 name = "Scrolling Contents Layer"; | 2655 name = "Scrolling Contents Layer"; |
| 2678 } else { | 2656 } else { |
| 2679 ASSERT_NOT_REACHED(); | 2657 ASSERT_NOT_REACHED(); |
| 2680 } | 2658 } |
| 2681 | 2659 |
| 2682 return name; | 2660 return name; |
| 2683 } | 2661 } |
| 2684 | 2662 |
| 2685 } // namespace blink | 2663 } // namespace blink |
| OLD | NEW |