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 "wtf/PassRefPtr.h" | 9 #include "platform/graphics/paint/PaintPropertyNode.h" |
10 #include "wtf/RefCounted.h" | |
11 #include "wtf/RefPtr.h" | |
12 | 10 |
13 #include <iosfwd> | 11 #include <iosfwd> |
14 | 12 |
15 namespace blink { | 13 namespace blink { |
16 | 14 |
17 // A paint effect created by the opacity css property along with a reference to | 15 // A paint effect created by the opacity css property along with a reference to |
18 // the parent effect node, or nullptr for the root. | 16 // the parent effect node, or nullptr for the root. |
19 // TODO(pdr): Support more effects than just opacity. | 17 // TODO(pdr): Support more effects than just opacity. |
20 class PLATFORM_EXPORT EffectPaintPropertyNode : public RefCounted<EffectPaintPro
pertyNode> { | 18 class PLATFORM_EXPORT EffectPaintPropertyNode : public PaintPropertyNode<EffectP
aintPropertyNode> { |
21 public: | 19 public: |
22 using Value = float; | 20 using Value = float; |
23 | 21 |
24 static PassRefPtr<EffectPaintPropertyNode> create(float opacity, PassRefPtr<
EffectPaintPropertyNode> parent = nullptr) | 22 static PassRefPtr<EffectPaintPropertyNode> create(float opacity, PassRefPtr<
EffectPaintPropertyNode> parent = nullptr) |
25 { | 23 { |
26 return adoptRef(new EffectPaintPropertyNode(opacity, parent)); | 24 return adoptRef(new EffectPaintPropertyNode(opacity, parent)); |
27 } | 25 } |
28 | 26 |
29 Value value() const { return m_opacity; } | 27 Value value() const { return m_opacity; } |
30 float opacity() const { return m_opacity; } | 28 float opacity() const { return m_opacity; } |
31 | 29 |
32 // Parent effect or nullptr if this is the root effect. | |
33 const EffectPaintPropertyNode* parent() const { return m_parent.get(); } | |
34 | |
35 // Moves this node and its subtrees under another parent. | |
36 void setParent(PassRefPtr<EffectPaintPropertyNode> parent) { m_parent = pare
nt; } | |
37 | |
38 private: | 30 private: |
39 EffectPaintPropertyNode(float opacity, PassRefPtr<EffectPaintPropertyNode> p
arent) | 31 EffectPaintPropertyNode(float opacity, PassRefPtr<EffectPaintPropertyNode> p
arent) |
40 : m_opacity(opacity), m_parent(parent) { } | 32 : PaintPropertyNode(parent), m_opacity(opacity) { } |
41 | 33 |
42 const float m_opacity; | 34 const float m_opacity; |
43 RefPtr<EffectPaintPropertyNode> m_parent; | |
44 }; | 35 }; |
45 | 36 |
46 // Redeclared here to avoid ODR issues. | 37 // Redeclared here to avoid ODR issues. |
47 // See platform/testing/PaintPrinters.h. | 38 // See platform/testing/PaintPrinters.h. |
48 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); | 39 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); |
49 | 40 |
50 } // namespace blink | 41 } // namespace blink |
51 | 42 |
52 #endif // EffectPaintPropertyNode_h | 43 #endif // EffectPaintPropertyNode_h |
OLD | NEW |