| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" | 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
| 6 | 6 |
| 7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
| 8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
| 9 #include "cc/layers/picture_layer.h" | 9 #include "cc/layers/picture_layer.h" |
| 10 #include "cc/playback/compositing_display_item.h" | 10 #include "cc/playback/compositing_display_item.h" |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 setupRootClipNode(); | 596 setupRootClipNode(); |
| 597 setupRootEffectNode(); | 597 setupRootEffectNode(); |
| 598 setupRootScrollNode(); | 598 setupRootScrollNode(); |
| 599 } | 599 } |
| 600 | 600 |
| 601 void setupRootTransformNode(); | 601 void setupRootTransformNode(); |
| 602 void setupRootClipNode(); | 602 void setupRootClipNode(); |
| 603 void setupRootEffectNode(); | 603 void setupRootEffectNode(); |
| 604 void setupRootScrollNode(); | 604 void setupRootScrollNode(); |
| 605 | 605 |
| 606 // A brief discourse on cc property tree nodes, identifiers, and current and |
| 607 // future design evolution envisioned: |
| 608 // |
| 609 // cc property trees identify nodes by their |id|, which implementation-wise |
| 610 // is actually its index in the property tree's vector of its node type. More |
| 611 // recent cc code now refers to these as 'node indices', or 'property tree |
| 612 // indices'. |parent_id| is the same sort of 'node index' of that node's |
| 613 // parent, whereas |owner_id| is the layer id of the layer owning that node. |
| 614 // |
| 615 // Note there are two other primary types of 'ids' referenced in cc property |
| 616 // tree related logic: (1) ElementId, also known Blink-side as |
| 617 // CompositorElementId, used by the animation system to allow tying an element |
| 618 // to its respective layer, and (2) layer ids. There are other ancillary ids |
| 619 // not relevant to any of the above, such as |
| 620 // cc::TransformNode::sorting_context_id |
| 621 // (a.k.a. blink::TransformPaintPropertyNode::renderingContextId()). |
| 622 // |
| 623 // There is a vision to move toward a world where cc property nodes have no |
| 624 // association with layers and instead have a |stable_id|. The id could come |
| 625 // from an ElementId in turn derived from the layout object responsible for |
| 626 // creating the property node. |
| 627 // |
| 628 // We would also like to explore moving to use a single shared property tree |
| 629 // representation across both cc and Blink. See |
| 630 // platform/graphics/paint/README.md for more. |
| 631 // |
| 632 // With the above as background, we can now state more clearly a description |
| 633 // of the below set of compositor id generation methods: they take Blink paint |
| 634 // property tree nodes as input and produce a corresponding cc 'node id', |
| 635 // a.k.a., 'node index', for use as we build out the corresponding cc property |
| 636 // tree representation. |
| 637 |
| 606 int compositorIdForTransformNode(const TransformPaintPropertyNode*); | 638 int compositorIdForTransformNode(const TransformPaintPropertyNode*); |
| 607 int compositorIdForClipNode(const ClipPaintPropertyNode*); | 639 int compositorIdForClipNode(const ClipPaintPropertyNode*); |
| 608 int switchToEffectNode(const EffectPaintPropertyNode& nextEffect); | 640 int switchToEffectNode(const EffectPaintPropertyNode& nextEffect); |
| 609 int compositorIdForCurrentEffectNode() const { | 641 int compositorIdForCurrentEffectNode() const { |
| 610 return m_effectStack.back().id; | 642 return m_effectStack.back().id; |
| 611 } | 643 } |
| 612 int compositorIdForScrollNode(const ScrollPaintPropertyNode*); | 644 int compositorIdForScrollNode(const ScrollPaintPropertyNode*); |
| 613 | 645 |
| 614 // Scroll offset has special treatment in the transform and scroll trees. | 646 // Scroll offset has special treatment in the transform and scroll trees. |
| 615 void updateScrollOffset(int layerId, int scrollId); | 647 void updateScrollOffset(int layerId, int scrollId); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 633 // have any actual children, but at present must exist in the tree. | 665 // have any actual children, but at present must exist in the tree. |
| 634 cc::Layer* m_rootLayer; | 666 cc::Layer* m_rootLayer; |
| 635 | 667 |
| 636 // Maps from Blink-side property tree nodes to cc property node indices. | 668 // Maps from Blink-side property tree nodes to cc property node indices. |
| 637 HashMap<const TransformPaintPropertyNode*, int> m_transformNodeMap; | 669 HashMap<const TransformPaintPropertyNode*, int> m_transformNodeMap; |
| 638 HashMap<const ClipPaintPropertyNode*, int> m_clipNodeMap; | 670 HashMap<const ClipPaintPropertyNode*, int> m_clipNodeMap; |
| 639 HashMap<const ScrollPaintPropertyNode*, int> m_scrollNodeMap; | 671 HashMap<const ScrollPaintPropertyNode*, int> m_scrollNodeMap; |
| 640 | 672 |
| 641 struct BlinkEffectAndCcIdPair { | 673 struct BlinkEffectAndCcIdPair { |
| 642 const EffectPaintPropertyNode* effect; | 674 const EffectPaintPropertyNode* effect; |
| 675 // The cc property tree effect node id, or 'node index', for the cc effect |
| 676 // node corresponding to the above Blink effect paint property node. |
| 643 int id; | 677 int id; |
| 644 }; | 678 }; |
| 645 Vector<BlinkEffectAndCcIdPair> m_effectStack; | 679 Vector<BlinkEffectAndCcIdPair> m_effectStack; |
| 646 | 680 |
| 647 #if DCHECK_IS_ON() | 681 #if DCHECK_IS_ON() |
| 648 HashSet<const EffectPaintPropertyNode*> m_effectNodesConverted; | 682 HashSet<const EffectPaintPropertyNode*> m_effectNodesConverted; |
| 649 #endif | 683 #endif |
| 650 }; | 684 }; |
| 651 | 685 |
| 652 void PropertyTreeManager::setupRootTransformNode() { | 686 void PropertyTreeManager::setupRootTransformNode() { |
| 653 // cc is hardcoded to use transform node index 1 for device scale and | 687 // cc is hardcoded to use transform node index 1 for device scale and |
| 654 // transform. | 688 // transform. |
| 655 cc::TransformTree& transformTree = m_propertyTrees.transform_tree; | 689 cc::TransformTree& transformTree = m_propertyTrees.transform_tree; |
| 656 transformTree.clear(); | 690 transformTree.clear(); |
| 657 cc::TransformNode& transformNode = *transformTree.Node( | 691 cc::TransformNode& transformNode = *transformTree.Node( |
| 658 transformTree.Insert(cc::TransformNode(), kRealRootNodeId)); | 692 transformTree.Insert(cc::TransformNode(), kRealRootNodeId)); |
| 659 DCHECK_EQ(transformNode.id, kSecondaryRootNodeId); | 693 DCHECK_EQ(transformNode.id, kSecondaryRootNodeId); |
| 660 transformNode.source_node_id = transformNode.parent_id; | 694 transformNode.source_node_id = transformNode.parent_id; |
| 661 transformTree.SetTargetId(transformNode.id, kRealRootNodeId); | 695 transformTree.SetTargetId(transformNode.id, kRealRootNodeId); |
| 662 transformTree.SetContentTargetId(transformNode.id, kRealRootNodeId); | 696 transformTree.SetContentTargetId(transformNode.id, kRealRootNodeId); |
| 663 | 697 |
| 664 // TODO(jaydasika): We shouldn't set ToScreeen and FromScreen of root | 698 // TODO(jaydasika): We shouldn't set ToScreen and FromScreen of root |
| 665 // transform node here. They should be set while updating transform tree in | 699 // transform node here. They should be set while updating transform tree in |
| 666 // cc. | 700 // cc. |
| 667 float deviceScaleFactor = m_rootLayer->GetLayerTree()->device_scale_factor(); | 701 float deviceScaleFactor = m_rootLayer->GetLayerTree()->device_scale_factor(); |
| 668 gfx::Transform toScreen; | 702 gfx::Transform toScreen; |
| 669 toScreen.Scale(deviceScaleFactor, deviceScaleFactor); | 703 toScreen.Scale(deviceScaleFactor, deviceScaleFactor); |
| 670 transformTree.SetToScreen(kRealRootNodeId, toScreen); | 704 transformTree.SetToScreen(kRealRootNodeId, toScreen); |
| 671 gfx::Transform fromScreen; | 705 gfx::Transform fromScreen; |
| 672 bool invertible = toScreen.GetInverse(&fromScreen); | 706 bool invertible = toScreen.GetInverse(&fromScreen); |
| 673 DCHECK(invertible); | 707 DCHECK(invertible); |
| 674 transformTree.SetFromScreen(kRealRootNodeId, fromScreen); | 708 transformTree.SetFromScreen(kRealRootNodeId, fromScreen); |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 #ifndef NDEBUG | 1231 #ifndef NDEBUG |
| 1198 void PaintArtifactCompositor::showDebugData() { | 1232 void PaintArtifactCompositor::showDebugData() { |
| 1199 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) | 1233 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) |
| 1200 ->toPrettyJSONString() | 1234 ->toPrettyJSONString() |
| 1201 .utf8() | 1235 .utf8() |
| 1202 .data(); | 1236 .data(); |
| 1203 } | 1237 } |
| 1204 #endif | 1238 #endif |
| 1205 | 1239 |
| 1206 } // namespace blink | 1240 } // namespace blink |
| OLD | NEW |