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

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

Issue 2428513004: [SPv2] Create effect nodes for CSS filter (Closed)
Patch Set: address pdr's comment Created 4 years, 1 month 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 "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,
28 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace,
29 PassRefPtr<const ClipPaintPropertyNode> outputClip,
30 CompositorFilterOperations filter,
29 float opacity) { 31 float opacity) {
30 return adoptRef(new EffectPaintPropertyNode(std::move(parent), opacity)); 32 return adoptRef(new EffectPaintPropertyNode(
33 std::move(parent), std::move(localTransformSpace),
34 std::move(outputClip), std::move(filter), opacity));
31 } 35 }
32 36
33 void update(PassRefPtr<const EffectPaintPropertyNode> parent, float opacity) { 37 void update(PassRefPtr<const EffectPaintPropertyNode> parent,
38 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace,
39 PassRefPtr<const ClipPaintPropertyNode> outputClip,
40 CompositorFilterOperations filter,
41 float opacity) {
34 DCHECK(!isRoot()); 42 DCHECK(!isRoot());
35 DCHECK(parent != this); 43 DCHECK(parent != this);
36 m_parent = parent; 44 m_parent = parent;
45 m_localTransformSpace = localTransformSpace;
46 m_outputClip = outputClip;
47 m_filter = std::move(filter);
37 m_opacity = opacity; 48 m_opacity = opacity;
38 } 49 }
39 50
51 const TransformPaintPropertyNode* localTransformSpace() const {
52 return m_localTransformSpace.get();
53 }
54 const ClipPaintPropertyNode* outputClip() const { return m_outputClip.get(); }
55
40 float opacity() const { return m_opacity; } 56 float opacity() const { return m_opacity; }
57 const CompositorFilterOperations& filter() const { return m_filter; }
41 58
42 // Parent effect or nullptr if this is the root effect. 59 // Parent effect or nullptr if this is the root effect.
43 const EffectPaintPropertyNode* parent() const { return m_parent.get(); } 60 const EffectPaintPropertyNode* parent() const { return m_parent.get(); }
44 bool isRoot() const { return !m_parent; } 61 bool isRoot() const { return !m_parent; }
45 62
46 private: 63 private:
47 EffectPaintPropertyNode(PassRefPtr<const EffectPaintPropertyNode> parent, 64 EffectPaintPropertyNode(
48 float opacity) 65 PassRefPtr<const EffectPaintPropertyNode> parent,
49 : m_parent(parent), m_opacity(opacity) {} 66 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace,
67 PassRefPtr<const ClipPaintPropertyNode> outputClip,
68 CompositorFilterOperations filter,
69 float opacity)
70 : m_parent(parent),
71 m_localTransformSpace(localTransformSpace),
72 m_outputClip(outputClip),
73 m_filter(std::move(filter)),
74 m_opacity(opacity) {}
50 75
51 RefPtr<const EffectPaintPropertyNode> m_parent; 76 RefPtr<const EffectPaintPropertyNode> m_parent;
77 // The local transform space serves two purposes:
78 // 1. Assign a depth mapping for 3D depth sorting against other paint chunks
79 // and effects under the same parent.
80 // 2. Some effects are spatial (namely blur filter and reflection), the
81 // effect parameters will be specified in the local space.
82 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace;
83 // The output of the effect can be optionally clipped when composited onto
84 // the current backdrop.
85 RefPtr<const ClipPaintPropertyNode> m_outputClip;
86
87 // Optionally a number of effects can be applied to the composited output.
88 // The chain of effects will be applied in the following order:
89 // === Begin of effects ===
90 CompositorFilterOperations m_filter;
52 float m_opacity; 91 float m_opacity;
92 // === End of effects ===
53 }; 93 };
54 94
55 // Redeclared here to avoid ODR issues. 95 // Redeclared here to avoid ODR issues.
56 // See platform/testing/PaintPrinters.h. 96 // See platform/testing/PaintPrinters.h.
57 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); 97 void PrintTo(const EffectPaintPropertyNode&, std::ostream*);
58 98
59 } // namespace blink 99 } // namespace blink
60 100
61 #endif // EffectPaintPropertyNode_h 101 #endif // EffectPaintPropertyNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698