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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address reviewer feedback Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void CompositedLayerMapping::updateElementIdAndCompositorMutableProperties() 1524 void CompositedLayerMapping::updateElementIdAndCompositorMutableProperties()
1525 { 1525 {
1526 if (!RuntimeEnabledFeatures::compositorWorkerEnabled())
1527 return;
1528
1529 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "CompositedLaye rMapping::updateElementId()");
1530
1531 uint64_t elementId = 0; 1526 uint64_t elementId = 0;
1532 uint32_t mainMutableProperties = CompositorMutableProperty::kNone; 1527 uint32_t primaryMutableProperties = CompositorMutableProperty::kNone;
1533 uint32_t scrollMutableProperties = CompositorMutableProperty::kNone; 1528 uint32_t scrollMutableProperties = CompositorMutableProperty::kNone;
1534 1529
1535 if (m_owningLayer.layoutObject()->style()->hasCompositorProxy()) { 1530 Node* owningNode = m_owningLayer.layoutObject()->generatingNode();
1536 if (Node* owningNode = m_owningLayer.layoutObject()->generatingNode()) { 1531 Element* owningElement = nullptr;
1537 if (owningNode->isElementNode()) { 1532 if (owningNode && owningNode->isElementNode())
1538 Element* owningElement = toElement(owningNode); 1533 owningElement = toElement(owningNode);
1539 uint32_t compositorMutableProperties = owningElement->compositor MutableProperties(); 1534
1540 elementId = DOMNodeIds::idForNode(owningNode); 1535 if (RuntimeEnabledFeatures::compositorWorkerEnabled() && owningElement && m_ owningLayer.layoutObject()->style()->hasCompositorProxy()) {
1541 mainMutableProperties = (CompositorMutableProperty::kOpacity | C ompositorMutableProperty::kTransform) & compositorMutableProperties; 1536 uint32_t compositorMutableProperties = owningElement->compositorMutableP roperties();
1542 scrollMutableProperties = (CompositorMutableProperty::kScrollLef t | CompositorMutableProperty::kScrollTop) & compositorMutableProperties; 1537 elementId = DOMNodeIds::idForNode(owningNode);
1543 } 1538 primaryMutableProperties = (CompositorMutableProperty::kOpacity | Compos itorMutableProperty::kTransform) & compositorMutableProperties;
1544 } 1539 scrollMutableProperties = (CompositorMutableProperty::kScrollLeft | Comp ositorMutableProperty::kScrollTop) & compositorMutableProperties;
1545 } 1540 }
1546 1541
1547 m_graphicsLayer->setElementId(elementId); 1542 if (m_owningLayer.layoutObject()->style()->shouldCompositeForCurrentAnimatio ns() && owningNode)
1548 m_graphicsLayer->setCompositorMutableProperties(mainMutableProperties); 1543 elementId = DOMNodeIds::idForNode(owningNode);
1549 1544
1550 if (m_scrollingContentsLayer.get()) { 1545 m_graphicsLayer->setElementId(createCompositorElementId(elementId, Composito rSubElementId::Primary));
ajuma 2016/06/07 13:44:01 This is implicitly relying on Primary having value
Ian Vollick 2016/06/07 14:30:08 This is perhaps too subtle, but operator bool for
1551 m_scrollingContentsLayer->setElementId(elementId); 1546 m_graphicsLayer->setCompositorMutableProperties(primaryMutableProperties);
1547
1548 // We always set the elementId for m_scrollingContentsLayer since it can be
1549 // animated for smooth scrolling.
1550 if (m_scrollingContentsLayer.get())
1552 m_scrollingContentsLayer->setCompositorMutableProperties(scrollMutablePr operties); 1551 m_scrollingContentsLayer->setCompositorMutableProperties(scrollMutablePr operties);
ajuma 2016/06/07 13:44:01 How does this relate to the logic added to ::updat
Ian Vollick 2016/06/07 14:30:08 Good question. * element id: if you have a compo
1553 }
1554 } 1552 }
1555 1553
1556 bool CompositedLayerMapping::updateForegroundLayer(bool needsForegroundLayer) 1554 bool CompositedLayerMapping::updateForegroundLayer(bool needsForegroundLayer)
1557 { 1555 {
1558 bool layerChanged = false; 1556 bool layerChanged = false;
1559 if (needsForegroundLayer) { 1557 if (needsForegroundLayer) {
1560 if (!m_foregroundLayer) { 1558 if (!m_foregroundLayer) {
1561 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor eground); 1559 m_foregroundLayer = createGraphicsLayer(CompositingReasonLayerForFor eground);
1562 layerChanged = true; 1560 layerChanged = true;
1563 } 1561 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 bool layerChanged = false; 1628 bool layerChanged = false;
1631 if (needsScrollingLayers) { 1629 if (needsScrollingLayers) {
1632 if (!m_scrollingLayer) { 1630 if (!m_scrollingLayer) {
1633 // Outer layer which corresponds with the scroll view. 1631 // Outer layer which corresponds with the scroll view.
1634 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForScro llingContainer); 1632 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForScro llingContainer);
1635 m_scrollingLayer->setDrawsContent(false); 1633 m_scrollingLayer->setDrawsContent(false);
1636 m_scrollingLayer->setMasksToBounds(true); 1634 m_scrollingLayer->setMasksToBounds(true);
1637 1635
1638 // Inner layer which renders the content that scrolls. 1636 // Inner layer which renders the content that scrolls.
1639 m_scrollingContentsLayer = createGraphicsLayer(CompositingReasonLaye rForScrollingContents); 1637 m_scrollingContentsLayer = createGraphicsLayer(CompositingReasonLaye rForScrollingContents);
1638
1639 if (Node* owningNode = m_owningLayer.layoutObject()->generatingNode( )) {
1640 m_scrollingContentsLayer->setElementId(createCompositorElementId (DOMNodeIds::idForNode(owningNode), CompositorSubElementId::Scroll));
1641 m_scrollingContentsLayer->setCompositorMutableProperties(Composi torMutableProperty::kScrollLeft | CompositorMutableProperty::kScrollTop);
1642 }
1643
1640 m_scrollingLayer->addChild(m_scrollingContentsLayer.get()); 1644 m_scrollingLayer->addChild(m_scrollingContentsLayer.get());
1641 1645
1642 layerChanged = true; 1646 layerChanged = true;
1643 if (scrollingCoordinator) { 1647 if (scrollingCoordinator) {
1644 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_ownin gLayer.getScrollableArea()); 1648 scrollingCoordinator->scrollableAreaScrollLayerDidChange(m_ownin gLayer.getScrollableArea());
1645 scrollingCoordinator->scrollableAreasDidChange(); 1649 scrollingCoordinator->scrollableAreasDidChange();
1646 } 1650 }
1647 } 1651 }
1648 } else if (m_scrollingLayer) { 1652 } else if (m_scrollingLayer) {
1649 m_scrollingLayer = nullptr; 1653 m_scrollingLayer = nullptr;
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
2654 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2658 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2655 name = "Scrolling Contents Layer"; 2659 name = "Scrolling Contents Layer";
2656 } else { 2660 } else {
2657 ASSERT_NOT_REACHED(); 2661 ASSERT_NOT_REACHED();
2658 } 2662 }
2659 2663
2660 return name; 2664 return name;
2661 } 2665 }
2662 2666
2663 } // namespace blink 2667 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698