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 #ifndef EffectPaintPropertyNode_h | 5 #ifndef EffectPaintPropertyNode_h |
6 #define EffectPaintPropertyNode_h | 6 #define EffectPaintPropertyNode_h |
7 | 7 |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "platform/PlatformExport.h" | 9 #include "platform/PlatformExport.h" |
10 #include "platform/graphics/CompositorElementId.h" | |
10 #include "platform/graphics/CompositorFilterOperations.h" | 11 #include "platform/graphics/CompositorFilterOperations.h" |
11 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 12 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
12 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 13 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
13 #include "wtf/PassRefPtr.h" | 14 #include "wtf/PassRefPtr.h" |
14 #include "wtf/RefCounted.h" | 15 #include "wtf/RefCounted.h" |
15 #include "wtf/RefPtr.h" | 16 #include "wtf/RefPtr.h" |
16 #include "wtf/text/WTFString.h" | 17 #include "wtf/text/WTFString.h" |
17 | 18 |
18 #include <iosfwd> | 19 #include <iosfwd> |
19 | 20 |
20 namespace blink { | 21 namespace blink { |
21 | 22 |
22 // Effect nodes are abstraction of isolated groups, along with optional effects | 23 // Effect nodes are abstraction of isolated groups, along with optional effects |
23 // that can be applied to the composited output of the group. | 24 // that can be applied to the composited output of the group. |
24 // | 25 // |
25 // The effect tree is rooted at a node with no parent. This root node should | 26 // The effect tree is rooted at a node with no parent. This root node should |
26 // not be modified. | 27 // not be modified. |
27 class PLATFORM_EXPORT EffectPaintPropertyNode | 28 class PLATFORM_EXPORT EffectPaintPropertyNode |
28 : public RefCounted<EffectPaintPropertyNode> { | 29 : public RefCounted<EffectPaintPropertyNode> { |
29 public: | 30 public: |
30 static EffectPaintPropertyNode* root(); | 31 static EffectPaintPropertyNode* root(); |
31 | 32 |
32 static PassRefPtr<EffectPaintPropertyNode> create( | 33 static PassRefPtr<EffectPaintPropertyNode> create( |
33 PassRefPtr<const EffectPaintPropertyNode> parent, | 34 PassRefPtr<const EffectPaintPropertyNode> parent, |
34 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 35 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
35 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 36 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
36 CompositorFilterOperations filter, | 37 CompositorFilterOperations filter, |
37 float opacity, | 38 float opacity, |
38 SkBlendMode blendMode, | 39 SkBlendMode blendMode, |
39 CompositingReasons directCompositingReasons = CompositingReasonNone) { | 40 CompositingReasons directCompositingReasons = CompositingReasonNone, |
41 const CompositorElementId& compositorElementId = CompositorElementId()) { | |
40 return adoptRef(new EffectPaintPropertyNode( | 42 return adoptRef(new EffectPaintPropertyNode( |
41 std::move(parent), std::move(localTransformSpace), | 43 std::move(parent), std::move(localTransformSpace), |
42 std::move(outputClip), std::move(filter), opacity, blendMode, | 44 std::move(outputClip), std::move(filter), opacity, blendMode, |
43 directCompositingReasons)); | 45 directCompositingReasons, compositorElementId)); |
44 } | 46 } |
45 | 47 |
46 void update( | 48 void update( |
47 PassRefPtr<const EffectPaintPropertyNode> parent, | 49 PassRefPtr<const EffectPaintPropertyNode> parent, |
48 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 50 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
49 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 51 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
50 CompositorFilterOperations filter, | 52 CompositorFilterOperations filter, |
51 float opacity, | 53 float opacity, |
52 SkBlendMode blendMode, | 54 SkBlendMode blendMode, |
53 CompositingReasons directCompositingReasons = CompositingReasonNone) { | 55 CompositingReasons directCompositingReasons = CompositingReasonNone, |
56 CompositorElementId compositorElementId = CompositorElementId()) { | |
54 DCHECK(!isRoot()); | 57 DCHECK(!isRoot()); |
55 DCHECK(parent != this); | 58 DCHECK(parent != this); |
56 m_parent = parent; | 59 m_parent = parent; |
57 m_localTransformSpace = localTransformSpace; | 60 m_localTransformSpace = localTransformSpace; |
58 m_outputClip = outputClip; | 61 m_outputClip = outputClip; |
59 m_filter = std::move(filter); | 62 m_filter = std::move(filter); |
60 m_opacity = opacity; | 63 m_opacity = opacity; |
61 m_blendMode = blendMode; | 64 m_blendMode = blendMode; |
62 m_directCompositingReasons = directCompositingReasons; | 65 m_directCompositingReasons = directCompositingReasons; |
66 m_compositorElementId = compositorElementId; | |
63 } | 67 } |
64 | 68 |
65 const TransformPaintPropertyNode* localTransformSpace() const { | 69 const TransformPaintPropertyNode* localTransformSpace() const { |
66 return m_localTransformSpace.get(); | 70 return m_localTransformSpace.get(); |
67 } | 71 } |
68 const ClipPaintPropertyNode* outputClip() const { return m_outputClip.get(); } | 72 const ClipPaintPropertyNode* outputClip() const { return m_outputClip.get(); } |
69 | 73 |
70 SkBlendMode blendMode() const { return m_blendMode; } | 74 SkBlendMode blendMode() const { return m_blendMode; } |
71 float opacity() const { return m_opacity; } | 75 float opacity() const { return m_opacity; } |
72 const CompositorFilterOperations& filter() const { return m_filter; } | 76 const CompositorFilterOperations& filter() const { return m_filter; } |
73 | 77 |
74 // Parent effect or nullptr if this is the root effect. | 78 // Parent effect or nullptr if this is the root effect. |
75 const EffectPaintPropertyNode* parent() const { return m_parent.get(); } | 79 const EffectPaintPropertyNode* parent() const { return m_parent.get(); } |
76 bool isRoot() const { return !m_parent; } | 80 bool isRoot() const { return !m_parent; } |
77 | 81 |
78 cc::Layer* ensureDummyLayer() const; | 82 cc::Layer* ensureDummyLayer() const; |
79 | 83 |
80 #if DCHECK_IS_ON() | 84 #if DCHECK_IS_ON() |
81 // The clone function is used by FindPropertiesNeedingUpdate.h for recording | 85 // The clone function is used by FindPropertiesNeedingUpdate.h for recording |
82 // an effect node before it has been updated, to later detect changes. | 86 // an effect node before it has been updated, to later detect changes. |
83 PassRefPtr<EffectPaintPropertyNode> clone() const { | 87 PassRefPtr<EffectPaintPropertyNode> clone() const { |
84 return adoptRef(new EffectPaintPropertyNode( | 88 return adoptRef(new EffectPaintPropertyNode( |
85 m_parent, m_localTransformSpace, m_outputClip, m_filter, m_opacity, | 89 m_parent, m_localTransformSpace, m_outputClip, m_filter, m_opacity, |
86 m_blendMode, m_directCompositingReasons)); | 90 m_blendMode, m_directCompositingReasons, m_compositorElementId)); |
87 } | 91 } |
88 | 92 |
89 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking | 93 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking |
90 // if an effect node has changed. It ignores changes of reference filters | 94 // if an effect node has changed. It ignores changes of reference filters |
91 // because SkImageFilter doesn't have an equality operator. | 95 // because SkImageFilter doesn't have an equality operator. |
92 bool operator==(const EffectPaintPropertyNode& o) const { | 96 bool operator==(const EffectPaintPropertyNode& o) const { |
93 return m_parent == o.m_parent && | 97 return m_parent == o.m_parent && |
94 m_localTransformSpace == o.m_localTransformSpace && | 98 m_localTransformSpace == o.m_localTransformSpace && |
95 m_outputClip == o.m_outputClip && | 99 m_outputClip == o.m_outputClip && |
96 m_filter.equalsIgnoringReferenceFilters(o.m_filter) && | 100 m_filter.equalsIgnoringReferenceFilters(o.m_filter) && |
97 m_opacity == o.m_opacity && m_blendMode == o.m_blendMode && | 101 m_opacity == o.m_opacity && m_blendMode == o.m_blendMode && |
98 m_directCompositingReasons == o.m_directCompositingReasons; | 102 m_directCompositingReasons == o.m_directCompositingReasons && |
103 m_compositorElementId == o.m_compositorElementId; | |
99 } | 104 } |
100 #endif | 105 #endif |
101 | 106 |
102 String toString() const; | 107 String toString() const; |
103 | 108 |
104 bool hasDirectCompositingReasons() const { | 109 bool hasDirectCompositingReasons() const { |
105 return m_directCompositingReasons != CompositingReasonNone; | 110 return m_directCompositingReasons != CompositingReasonNone; |
106 } | 111 } |
107 | 112 |
113 const CompositorElementId& compositorElementId() const { | |
114 return m_compositorElementId; | |
115 } | |
116 | |
108 private: | 117 private: |
109 EffectPaintPropertyNode( | 118 EffectPaintPropertyNode( |
110 PassRefPtr<const EffectPaintPropertyNode> parent, | 119 PassRefPtr<const EffectPaintPropertyNode> parent, |
111 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 120 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
112 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 121 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
113 CompositorFilterOperations filter, | 122 CompositorFilterOperations filter, |
114 float opacity, | 123 float opacity, |
115 SkBlendMode blendMode, | 124 SkBlendMode blendMode, |
116 CompositingReasons directCompositingReasons) | 125 CompositingReasons directCompositingReasons, |
126 CompositorElementId compositorElementId) | |
117 : m_parent(parent), | 127 : m_parent(parent), |
118 m_localTransformSpace(localTransformSpace), | 128 m_localTransformSpace(localTransformSpace), |
119 m_outputClip(outputClip), | 129 m_outputClip(outputClip), |
120 m_filter(std::move(filter)), | 130 m_filter(std::move(filter)), |
121 m_opacity(opacity), | 131 m_opacity(opacity), |
122 m_blendMode(blendMode), | 132 m_blendMode(blendMode), |
123 m_directCompositingReasons(directCompositingReasons) {} | 133 m_directCompositingReasons(directCompositingReasons), |
134 m_compositorElementId(compositorElementId) {} | |
124 | 135 |
125 RefPtr<const EffectPaintPropertyNode> m_parent; | 136 RefPtr<const EffectPaintPropertyNode> m_parent; |
126 // The local transform space serves two purposes: | 137 // The local transform space serves two purposes: |
127 // 1. Assign a depth mapping for 3D depth sorting against other paint chunks | 138 // 1. Assign a depth mapping for 3D depth sorting against other paint chunks |
128 // and effects under the same parent. | 139 // and effects under the same parent. |
129 // 2. Some effects are spatial (namely blur filter and reflection), the | 140 // 2. Some effects are spatial (namely blur filter and reflection), the |
130 // effect parameters will be specified in the local space. | 141 // effect parameters will be specified in the local space. |
131 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; | 142 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; |
132 // The output of the effect can be optionally clipped when composited onto | 143 // The output of the effect can be optionally clipped when composited onto |
133 // the current backdrop. | 144 // the current backdrop. |
134 RefPtr<const ClipPaintPropertyNode> m_outputClip; | 145 RefPtr<const ClipPaintPropertyNode> m_outputClip; |
135 | 146 |
136 // Optionally a number of effects can be applied to the composited output. | 147 // Optionally a number of effects can be applied to the composited output. |
137 // The chain of effects will be applied in the following order: | 148 // The chain of effects will be applied in the following order: |
138 // === Begin of effects === | 149 // === Begin of effects === |
139 CompositorFilterOperations m_filter; | 150 CompositorFilterOperations m_filter; |
140 float m_opacity; | 151 float m_opacity; |
141 SkBlendMode m_blendMode; | 152 SkBlendMode m_blendMode; |
142 // === End of effects === | 153 // === End of effects === |
143 | 154 |
144 // TODO(trchen): Remove the dummy layer. | 155 // TODO(trchen): Remove the dummy layer. |
145 // The main purpose of the dummy layer is to maintain a permanent identity | 156 // The main purpose of the dummy layer is to maintain a permanent identity |
146 // to associate with cc::RenderSurfaceImpl for damage tracking. This shall | 157 // to associate with cc::RenderSurfaceImpl for damage tracking. This shall |
147 // be removed in favor of a stable ID once cc::LayerImpl no longer owns | 158 // be removed in favor of a stable ID once cc::LayerImpl no longer owns |
148 // RenderSurfaceImpl. | 159 // RenderSurfaceImpl. |
149 mutable scoped_refptr<cc::Layer> m_dummyLayer; | 160 mutable scoped_refptr<cc::Layer> m_dummyLayer; |
150 | 161 |
151 CompositingReasons m_directCompositingReasons; | 162 CompositingReasons m_directCompositingReasons; |
163 CompositorElementId m_compositorElementId; | |
Xianzhu
2016/12/29 20:40:38
Please also update toString().
wkorman
2016/12/29 20:59:47
Done.
| |
152 }; | 164 }; |
153 | 165 |
154 // Redeclared here to avoid ODR issues. | 166 // Redeclared here to avoid ODR issues. |
155 // See platform/testing/PaintPrinters.h. | 167 // See platform/testing/PaintPrinters.h. |
156 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); | 168 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); |
157 | 169 |
158 } // namespace blink | 170 } // namespace blink |
159 | 171 |
160 #endif // EffectPaintPropertyNode_h | 172 #endif // EffectPaintPropertyNode_h |
OLD | NEW |