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

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

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

Powered by Google App Engine
This is Rietveld 408576698