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