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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp

Issue 2610963002: Add documentation on cc/Blink nodes, ids, and indices. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/paint/README.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 indexes', or 'property tree
chrishtr 2017/01/04 20:54:28 Could you land a patch that changes them to only h
wkorman 2017/01/04 21:22:55 Sure, I'll look at that in a separate change and c
612 // indexes'. |parent_id| and |owner_id| in the cc property tree nodes are the
613 // same sort of node ids, all of which are stitched together to produce a tree
614 // representation.
615 //
616 // Note there are two other primary types of 'ids' referenced in cc property
617 // tree related logic: (1) ElementId, also known Blink-side as
618 // CompositorElementId, used by the animation system to allow tying an element
619 // to its respective layer, and (2) layer ids. There are other ancillary ids
620 // not relevant to any of the above, such as
621 // cc::TransformNode::sorting_context_id
622 // (a.k.a. blink::TransformPaintPropertyNode::renderingContextId()).
623 //
624 // There is a vision to move toward every layer having a |stable_id| instead
625 // of its current |id|. This could be represented by the layer's ElementId,
ajuma 2017/01/04 20:57:52 "current |owner_id|"
wkorman 2017/01/04 21:22:55 Rephrased this and next paragraph, let me know how
ajuma 2017/01/04 22:00:48 Looks great, thanks!
626 // excepting that currently for performance reasons these are only assigned to
627 // layers with a composited animation. Once all layers have one, this could
628 // become the |stable_id| and the |owner_id| in each cc property tree node
629 // could then be the |stable_id| of its associated layer.
ajuma 2017/01/04 20:57:52 The plan is that there won't be an associated laye
wkorman 2017/01/04 21:22:55 See above comment.
630 //
631 // So, eventually cc property trees should not have to know anything about
632 // layer ids (once it is not assumed that each node is owned by a layer). That
633 // is, property tree nodes will have a |stable_id| and an index, but neither
634 // will correspond to a layer id. We would also like to explore moving to use
635 // a single shared property tree representation across both cc and Blink. See
636 // platform/graphics/paint/README.md for more.
637 //
638 // With the above as background, we can now state more clearly a description
639 // of the below set of compositor id generation methods: they take Blink paint
640 // property tree nodes as input and produce a corresponding cc 'node id',
641 // a.k.a., 'node index', for use as we build out the corresponding cc property
642 // tree representation.
643
606 int compositorIdForTransformNode(const TransformPaintPropertyNode*); 644 int compositorIdForTransformNode(const TransformPaintPropertyNode*);
607 int compositorIdForClipNode(const ClipPaintPropertyNode*); 645 int compositorIdForClipNode(const ClipPaintPropertyNode*);
608 int switchToEffectNode(const EffectPaintPropertyNode& nextEffect); 646 int switchToEffectNode(const EffectPaintPropertyNode& nextEffect);
609 int compositorIdForCurrentEffectNode() const { 647 int compositorIdForCurrentEffectNode() const {
610 return m_effectStack.back().id; 648 return m_effectStack.back().id;
611 } 649 }
612 int compositorIdForScrollNode(const ScrollPaintPropertyNode*); 650 int compositorIdForScrollNode(const ScrollPaintPropertyNode*);
613 651
614 // Scroll offset has special treatment in the transform and scroll trees. 652 // Scroll offset has special treatment in the transform and scroll trees.
615 void updateScrollOffset(int layerId, int scrollId); 653 void updateScrollOffset(int layerId, int scrollId);
(...skipping 17 matching lines...) Expand all
633 // have any actual children, but at present must exist in the tree. 671 // have any actual children, but at present must exist in the tree.
634 cc::Layer* m_rootLayer; 672 cc::Layer* m_rootLayer;
635 673
636 // Maps from Blink-side property tree nodes to cc property node indices. 674 // Maps from Blink-side property tree nodes to cc property node indices.
637 HashMap<const TransformPaintPropertyNode*, int> m_transformNodeMap; 675 HashMap<const TransformPaintPropertyNode*, int> m_transformNodeMap;
638 HashMap<const ClipPaintPropertyNode*, int> m_clipNodeMap; 676 HashMap<const ClipPaintPropertyNode*, int> m_clipNodeMap;
639 HashMap<const ScrollPaintPropertyNode*, int> m_scrollNodeMap; 677 HashMap<const ScrollPaintPropertyNode*, int> m_scrollNodeMap;
640 678
641 struct BlinkEffectAndCcIdPair { 679 struct BlinkEffectAndCcIdPair {
642 const EffectPaintPropertyNode* effect; 680 const EffectPaintPropertyNode* effect;
681 // The cc property tree effect node id, or 'node index', for the cc effect
682 // node corresponding to the above Blink effect paint property node.
643 int id; 683 int id;
644 }; 684 };
645 Vector<BlinkEffectAndCcIdPair> m_effectStack; 685 Vector<BlinkEffectAndCcIdPair> m_effectStack;
646 686
647 #if DCHECK_IS_ON() 687 #if DCHECK_IS_ON()
648 HashSet<const EffectPaintPropertyNode*> m_effectNodesConverted; 688 HashSet<const EffectPaintPropertyNode*> m_effectNodesConverted;
649 #endif 689 #endif
650 }; 690 };
651 691
652 void PropertyTreeManager::setupRootTransformNode() { 692 void PropertyTreeManager::setupRootTransformNode() {
653 // cc is hardcoded to use transform node index 1 for device scale and 693 // cc is hardcoded to use transform node index 1 for device scale and
654 // transform. 694 // transform.
655 cc::TransformTree& transformTree = m_propertyTrees.transform_tree; 695 cc::TransformTree& transformTree = m_propertyTrees.transform_tree;
656 transformTree.clear(); 696 transformTree.clear();
657 cc::TransformNode& transformNode = *transformTree.Node( 697 cc::TransformNode& transformNode = *transformTree.Node(
658 transformTree.Insert(cc::TransformNode(), kRealRootNodeId)); 698 transformTree.Insert(cc::TransformNode(), kRealRootNodeId));
659 DCHECK_EQ(transformNode.id, kSecondaryRootNodeId); 699 DCHECK_EQ(transformNode.id, kSecondaryRootNodeId);
660 transformNode.source_node_id = transformNode.parent_id; 700 transformNode.source_node_id = transformNode.parent_id;
661 transformTree.SetTargetId(transformNode.id, kRealRootNodeId); 701 transformTree.SetTargetId(transformNode.id, kRealRootNodeId);
662 transformTree.SetContentTargetId(transformNode.id, kRealRootNodeId); 702 transformTree.SetContentTargetId(transformNode.id, kRealRootNodeId);
663 703
664 // TODO(jaydasika): We shouldn't set ToScreeen and FromScreen of root 704 // TODO(jaydasika): We shouldn't set ToScreen and FromScreen of root
665 // transform node here. They should be set while updating transform tree in 705 // transform node here. They should be set while updating transform tree in
666 // cc. 706 // cc.
667 float deviceScaleFactor = m_rootLayer->GetLayerTree()->device_scale_factor(); 707 float deviceScaleFactor = m_rootLayer->GetLayerTree()->device_scale_factor();
668 gfx::Transform toScreen; 708 gfx::Transform toScreen;
669 toScreen.Scale(deviceScaleFactor, deviceScaleFactor); 709 toScreen.Scale(deviceScaleFactor, deviceScaleFactor);
670 transformTree.SetToScreen(kRealRootNodeId, toScreen); 710 transformTree.SetToScreen(kRealRootNodeId, toScreen);
671 gfx::Transform fromScreen; 711 gfx::Transform fromScreen;
672 bool invertible = toScreen.GetInverse(&fromScreen); 712 bool invertible = toScreen.GetInverse(&fromScreen);
673 DCHECK(invertible); 713 DCHECK(invertible);
674 transformTree.SetFromScreen(kRealRootNodeId, fromScreen); 714 transformTree.SetFromScreen(kRealRootNodeId, fromScreen);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 #ifndef NDEBUG 1237 #ifndef NDEBUG
1198 void PaintArtifactCompositor::showDebugData() { 1238 void PaintArtifactCompositor::showDebugData() {
1199 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo) 1239 LOG(ERROR) << layersAsJSON(LayerTreeIncludesDebugInfo)
1200 ->toPrettyJSONString() 1240 ->toPrettyJSONString()
1201 .utf8() 1241 .utf8()
1202 .data(); 1242 .data();
1203 } 1243 }
1204 #endif 1244 #endif
1205 1245
1206 } // namespace blink 1246 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/graphics/paint/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698