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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h

Issue 2581843002: Implement merging non-composited paint property nodes in the PACompositor. (Closed)
Patch Set: none Created 3 years, 12 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef PropertyTreeState_h 5 #ifndef PropertyTreeState_h
6 #define PropertyTreeState_h 6 #define PropertyTreeState_h
7 7
8 #include "platform/graphics/paint/ClipPaintPropertyNode.h" 8 #include "platform/graphics/paint/ClipPaintPropertyNode.h"
9 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 9 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
10 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" 10 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
12 #include "wtf/HashFunctions.h" 12 #include "wtf/HashFunctions.h"
13 #include "wtf/HashTraits.h" 13 #include "wtf/HashTraits.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 // A complete set of paint properties including those that are inherited from 17 // A complete set of paint properties including those that are inherited from
18 // other objects. RefPtrs are used to guard against use-after-free bugs and 18 // other objects. RefPtrs are used to guard against use-after-free bugs and
19 // DCHECKs ensure PropertyTreeState never retains the last reference to a 19 // DCHECKs ensure PropertyTreeState never retains the last reference to a
20 // property tree node. 20 // property tree node.
21 class PropertyTreeState { 21 class PLATFORM_EXPORT PropertyTreeState {
22 public: 22 public:
23 PropertyTreeState(const TransformPaintPropertyNode* transform, 23 PropertyTreeState(const TransformPaintPropertyNode* transform,
24 const ClipPaintPropertyNode* clip, 24 const ClipPaintPropertyNode* clip,
25 const EffectPaintPropertyNode* effect, 25 const EffectPaintPropertyNode* effect,
26 const ScrollPaintPropertyNode* scroll) 26 const ScrollPaintPropertyNode* scroll)
27 : m_transform(transform), 27 : m_transform(transform),
28 m_clip(clip), 28 m_clip(clip),
29 m_effect(effect), 29 m_effect(effect),
30 m_scroll(scroll) { 30 m_scroll(scroll) {
31 DCHECK(!m_transform || !m_transform->hasOneRef()); 31 DCHECK(!m_transform || !m_transform->hasOneRef());
32 DCHECK(!m_clip || !m_clip->hasOneRef()); 32 DCHECK(!m_clip || !m_clip->hasOneRef());
33 DCHECK(!m_effect || !m_effect->hasOneRef()); 33 DCHECK(!m_effect || !m_effect->hasOneRef());
34 DCHECK(!m_scroll || !m_scroll->hasOneRef()); 34 DCHECK(!m_scroll || !m_scroll->hasOneRef());
35 } 35 }
36 36
37 bool hasDirectCompositingReasons() const;
38
37 const TransformPaintPropertyNode* transform() const { 39 const TransformPaintPropertyNode* transform() const {
38 DCHECK(!m_transform || !m_transform->hasOneRef()); 40 DCHECK(!m_transform || !m_transform->hasOneRef());
39 return m_transform.get(); 41 return m_transform.get();
40 } 42 }
41 void setTransform(RefPtr<const TransformPaintPropertyNode> node) { 43 void setTransform(RefPtr<const TransformPaintPropertyNode> node) {
42 m_transform = std::move(node); 44 m_transform = std::move(node);
43 } 45 }
44 46
45 const ClipPaintPropertyNode* clip() const { 47 const ClipPaintPropertyNode* clip() const {
46 DCHECK(!m_clip || !m_clip->hasOneRef()); 48 DCHECK(!m_clip || !m_clip->hasOneRef());
(...skipping 12 matching lines...) Expand all
59 } 61 }
60 62
61 const ScrollPaintPropertyNode* scroll() const { 63 const ScrollPaintPropertyNode* scroll() const {
62 DCHECK(!m_scroll || !m_scroll->hasOneRef()); 64 DCHECK(!m_scroll || !m_scroll->hasOneRef());
63 return m_scroll.get(); 65 return m_scroll.get();
64 } 66 }
65 void setScroll(RefPtr<const ScrollPaintPropertyNode> node) { 67 void setScroll(RefPtr<const ScrollPaintPropertyNode> node) {
66 m_scroll = std::move(node); 68 m_scroll = std::move(node);
67 } 69 }
68 70
71 enum InnermostNode {
72 None, // None means that all nodes are their root values
73 Transform,
74 Clip,
75 Effect,
76 };
77
78 // There is always a well-defined order in which the transform, clip
79 // and effects of a PropertyTreeState apply. This method returns which
80 // of them applies first to content drawn with this PropertyTreeState.
81 // Note that it may be the case that multiple nodes from the same tree apply
82 // before any from another tree. This can happen, for example, if multiple
83 // effects or clips apply to a descendant transform state from the transform
84 // node.
85 //
86 // This method is meant to be used in concert with
87 // |PropertyTreeStateIterator|, which allows one to iterate over the nodes in
88 // the order in which they apply.
89 //
90 // Example:
91 //
92 // Transform tree Clip tree Effect tree
93 // ~~~~~~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~~~
94 // Root Root Root
95 // | | |
96 // T C E
97 //
98 // Suppose that PropertyTreeState(T, C, E).innerMostNode() is E, and
99 // PropertytreeState(T, C, Root).innermostNode() is C. Then a PaintChunk
100 // that has propertyTreeState = PropertyTreeState(T, C, E) can be painted
101 // with the following display list structure:
102 //
103 // [BeginTransform] [BeginClip] [BeginEffect] PaintChunk drawings
104 // [EndEffect] [EndClip] [EndTransform]
105 //
106 // The PropertyTreeStateIterator will behave like this:
107 //
108 // PropertyTreeStateIterator iterator(PropertyTreeState(T, C, E));
109 // DCHECK(iterator.innermostNode() == Effect);
110 // DCHECK(iterator.next()->innermostNode() == Clip);
111 // DCHECK(iterator.next()->innermostNode() == Transform);
112 // DCHECK(iterator.next()->innermostNode() == None);
113 InnermostNode innermostNode() const;
114
69 private: 115 private:
70 RefPtr<const TransformPaintPropertyNode> m_transform; 116 RefPtr<const TransformPaintPropertyNode> m_transform;
71 RefPtr<const ClipPaintPropertyNode> m_clip; 117 RefPtr<const ClipPaintPropertyNode> m_clip;
72 RefPtr<const EffectPaintPropertyNode> m_effect; 118 RefPtr<const EffectPaintPropertyNode> m_effect;
73 RefPtr<const ScrollPaintPropertyNode> m_scroll; 119 RefPtr<const ScrollPaintPropertyNode> m_scroll;
74 }; 120 };
75 121
76 inline bool operator==(const PropertyTreeState& a, const PropertyTreeState& b) { 122 inline bool operator==(const PropertyTreeState& a, const PropertyTreeState& b) {
77 return a.transform() == b.transform() && a.clip() == b.clip() && 123 return a.transform() == b.transform() && a.clip() == b.clip() &&
78 a.effect() == b.effect() && a.scroll() == b.scroll(); 124 a.effect() == b.effect() && a.scroll() == b.scroll();
79 } 125 }
80 126
127 // Iterates over the sequence transforms, clips and effects for a
128 // PropertyTreeState between that state and the "root" state (all nodes equal
129 // to *::Root()), in the order that they apply.
130 //
131 // See also PropertyTreeState::innermostNode for a more detailed example.
132 class PLATFORM_EXPORT PropertyTreeStateIterator {
133 public:
134 PropertyTreeStateIterator(const PropertyTreeState& properties)
135 : m_properties(properties) {}
136 const PropertyTreeState* next();
137
138 private:
139 PropertyTreeState m_properties;
140 };
141
81 } // namespace blink 142 } // namespace blink
82 143
83 #endif // PropertyTreeState_h 144 #endif // PropertyTreeState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698