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 "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "platform/graphics/CompositorFilterOperations.h" | |
9 #include "wtf/PassRefPtr.h" | 10 #include "wtf/PassRefPtr.h" |
10 #include "wtf/RefCounted.h" | 11 #include "wtf/RefCounted.h" |
11 #include "wtf/RefPtr.h" | 12 #include "wtf/RefPtr.h" |
12 | 13 |
13 #include <iosfwd> | 14 #include <iosfwd> |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 | 17 |
17 // A paint effect created by the opacity css property along with a reference to | 18 // Effect nodes are abstraction of isolated groups, along with optional effects |
18 // the parent effect for inherited effects. | 19 // that can be applied to the composited output of the group. |
19 // | 20 // |
20 // The effect tree is rooted at a node with no parent. This root node should | 21 // The effect tree is rooted at a node with no parent. This root node should |
21 // not be modified. | 22 // not be modified. |
22 // | |
23 // TODO(pdr): Support more effects than just opacity. | |
24 class PLATFORM_EXPORT EffectPaintPropertyNode | 23 class PLATFORM_EXPORT EffectPaintPropertyNode |
25 : public RefCounted<EffectPaintPropertyNode> { | 24 : public RefCounted<EffectPaintPropertyNode> { |
26 public: | 25 public: |
27 static PassRefPtr<EffectPaintPropertyNode> create( | 26 static PassRefPtr<EffectPaintPropertyNode> create( |
28 PassRefPtr<const EffectPaintPropertyNode> parent, | 27 PassRefPtr<const EffectPaintPropertyNode> parent, |
29 float opacity) { | 28 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
30 return adoptRef(new EffectPaintPropertyNode(std::move(parent), opacity)); | 29 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
30 float opacity, CompositorFilterOperations filter) { | |
31 return adoptRef(new EffectPaintPropertyNode(std::move(parent), std::move(loc alTransformSpace), std::move(outputClip), opacity, std::move(filter))); | |
31 } | 32 } |
32 | 33 |
33 void update(PassRefPtr<const EffectPaintPropertyNode> parent, float opacity) { | 34 void update(PassRefPtr<const EffectPaintPropertyNode> parent, |
35 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | |
36 PassRefPtr<const ClipPaintPropertyNode> outputClip, | |
37 float opacity, CompositorFilterOperations filter) { | |
34 DCHECK(!isRoot()); | 38 DCHECK(!isRoot()); |
35 DCHECK(parent != this); | 39 DCHECK(parent != this); |
36 m_parent = parent; | 40 m_parent = parent; |
41 m_localTransformSpace = localTransformSpace; | |
42 m_outputClip = outputClip; | |
37 m_opacity = opacity; | 43 m_opacity = opacity; |
44 m_filter = std::move(filter); | |
38 } | 45 } |
39 | 46 |
47 const TransformPaintPropertyNode* localTransformSpace() const { return m_local TransformSpace.get(); } | |
48 const ClipPaintPropertyNode* outputClip() const { return m_outputClip.get(); } | |
49 | |
40 float opacity() const { return m_opacity; } | 50 float opacity() const { return m_opacity; } |
51 const CompositorFilterOperations& filter() const { return m_filter; } | |
41 | 52 |
42 // Parent effect or nullptr if this is the root effect. | 53 // Parent effect or nullptr if this is the root effect. |
43 const EffectPaintPropertyNode* parent() const { return m_parent.get(); } | 54 const EffectPaintPropertyNode* parent() const { return m_parent.get(); } |
44 bool isRoot() const { return !m_parent; } | 55 bool isRoot() const { return !m_parent; } |
45 | 56 |
46 private: | 57 private: |
47 EffectPaintPropertyNode(PassRefPtr<const EffectPaintPropertyNode> parent, | 58 EffectPaintPropertyNode(PassRefPtr<const EffectPaintPropertyNode> parent, |
48 float opacity) | 59 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
49 : m_parent(parent), m_opacity(opacity) {} | 60 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
61 float opacity, CompositorFilterOperations filter) | |
62 : m_parent(parent), m_localTransformSpace(localTransformSpace), m_outputCl ip(outputClip), m_opacity(opacity), m_filter(std::move(filter)) {} | |
50 | 63 |
51 RefPtr<const EffectPaintPropertyNode> m_parent; | 64 RefPtr<const EffectPaintPropertyNode> m_parent; |
65 // The local transform space serves two purposes: | |
66 // 1. Assign a depth mapping for 3D depth sorting against other paint chunks | |
67 // and effects under the same parent. | |
68 // 2. Some effects are spatial (namely blur filter and reflection), the | |
69 // effect parameters will be specified in the local space. | |
70 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; | |
71 // The output of the effect can be optionally clipped when composited onto | |
72 // the current backdrop. | |
73 RefPtr<const ClipPaintPropertyNode> m_outputClip; | |
74 | |
75 // Optionally a number of effects can be applied to the composited output. | |
76 // The chain of effects are applied in reverse order of the following list: | |
pdr.
2016/10/19 17:44:43
Nit: can we list these in order instead of reverse
trchen
2016/10/21 23:26:39
Done.
By the way every time we added a new proper
| |
77 // === Begin of effects === | |
52 float m_opacity; | 78 float m_opacity; |
79 CompositorFilterOperations m_filter; | |
80 // === End of effects === | |
53 }; | 81 }; |
54 | 82 |
55 // Redeclared here to avoid ODR issues. | 83 // Redeclared here to avoid ODR issues. |
56 // See platform/testing/PaintPrinters.h. | 84 // See platform/testing/PaintPrinters.h. |
57 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); | 85 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); |
58 | 86 |
59 } // namespace blink | 87 } // namespace blink |
60 | 88 |
61 #endif // EffectPaintPropertyNode_h | 89 #endif // EffectPaintPropertyNode_h |
OLD | NEW |