| 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/CompositorFilterOperations.h" | 10 #include "platform/graphics/CompositorFilterOperations.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class PLATFORM_EXPORT EffectPaintPropertyNode | 27 class PLATFORM_EXPORT EffectPaintPropertyNode |
| 28 : public RefCounted<EffectPaintPropertyNode> { | 28 : public RefCounted<EffectPaintPropertyNode> { |
| 29 public: | 29 public: |
| 30 static EffectPaintPropertyNode* root(); | 30 static EffectPaintPropertyNode* root(); |
| 31 | 31 |
| 32 static PassRefPtr<EffectPaintPropertyNode> create( | 32 static PassRefPtr<EffectPaintPropertyNode> create( |
| 33 PassRefPtr<const EffectPaintPropertyNode> parent, | 33 PassRefPtr<const EffectPaintPropertyNode> parent, |
| 34 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 34 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
| 35 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 35 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
| 36 CompositorFilterOperations filter, | 36 CompositorFilterOperations filter, |
| 37 float opacity) { | 37 float opacity, |
| 38 SkBlendMode blendMode) { |
| 38 return adoptRef(new EffectPaintPropertyNode( | 39 return adoptRef(new EffectPaintPropertyNode( |
| 39 std::move(parent), std::move(localTransformSpace), | 40 std::move(parent), std::move(localTransformSpace), |
| 40 std::move(outputClip), std::move(filter), opacity)); | 41 std::move(outputClip), std::move(filter), opacity, blendMode)); |
| 41 } | 42 } |
| 42 | 43 |
| 43 void update(PassRefPtr<const EffectPaintPropertyNode> parent, | 44 void update(PassRefPtr<const EffectPaintPropertyNode> parent, |
| 44 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 45 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
| 45 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 46 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
| 46 CompositorFilterOperations filter, | 47 CompositorFilterOperations filter, |
| 47 float opacity) { | 48 float opacity, |
| 49 SkBlendMode blendMode) { |
| 48 DCHECK(!isRoot()); | 50 DCHECK(!isRoot()); |
| 49 DCHECK(parent != this); | 51 DCHECK(parent != this); |
| 50 m_parent = parent; | 52 m_parent = parent; |
| 51 m_localTransformSpace = localTransformSpace; | 53 m_localTransformSpace = localTransformSpace; |
| 52 m_outputClip = outputClip; | 54 m_outputClip = outputClip; |
| 53 m_filter = std::move(filter); | 55 m_filter = std::move(filter); |
| 54 m_opacity = opacity; | 56 m_opacity = opacity; |
| 57 m_blendMode = blendMode; |
| 55 } | 58 } |
| 56 | 59 |
| 57 const TransformPaintPropertyNode* localTransformSpace() const { | 60 const TransformPaintPropertyNode* localTransformSpace() const { |
| 58 return m_localTransformSpace.get(); | 61 return m_localTransformSpace.get(); |
| 59 } | 62 } |
| 60 const ClipPaintPropertyNode* outputClip() const { return m_outputClip.get(); } | 63 const ClipPaintPropertyNode* outputClip() const { return m_outputClip.get(); } |
| 61 | 64 |
| 65 SkBlendMode blendMode() const { return m_blendMode; } |
| 62 float opacity() const { return m_opacity; } | 66 float opacity() const { return m_opacity; } |
| 63 const CompositorFilterOperations& filter() const { return m_filter; } | 67 const CompositorFilterOperations& filter() const { return m_filter; } |
| 64 | 68 |
| 65 // Parent effect or nullptr if this is the root effect. | 69 // Parent effect or nullptr if this is the root effect. |
| 66 const EffectPaintPropertyNode* parent() const { return m_parent.get(); } | 70 const EffectPaintPropertyNode* parent() const { return m_parent.get(); } |
| 67 bool isRoot() const { return !m_parent; } | 71 bool isRoot() const { return !m_parent; } |
| 68 | 72 |
| 69 cc::Layer* ensureDummyLayer() const; | 73 cc::Layer* ensureDummyLayer() const; |
| 70 | 74 |
| 71 #if DCHECK_IS_ON() | 75 #if DCHECK_IS_ON() |
| 72 // The clone function is used by FindPropertiesNeedingUpdate.h for recording | 76 // The clone function is used by FindPropertiesNeedingUpdate.h for recording |
| 73 // an effect node before it has been updated, to later detect changes. | 77 // an effect node before it has been updated, to later detect changes. |
| 74 PassRefPtr<EffectPaintPropertyNode> clone() const { | 78 PassRefPtr<EffectPaintPropertyNode> clone() const { |
| 75 return adoptRef(new EffectPaintPropertyNode( | 79 return adoptRef(new EffectPaintPropertyNode(m_parent, m_localTransformSpace, |
| 76 m_parent, m_localTransformSpace, m_outputClip, m_filter, m_opacity)); | 80 m_outputClip, m_filter, |
| 81 m_opacity, m_blendMode)); |
| 77 } | 82 } |
| 78 | 83 |
| 79 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking | 84 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking |
| 80 // if an effect node has changed. It ignores changes of reference filters | 85 // if an effect node has changed. It ignores changes of reference filters |
| 81 // because SkImageFilter doesn't have an equality operator. | 86 // because SkImageFilter doesn't have an equality operator. |
| 82 bool operator==(const EffectPaintPropertyNode& o) const { | 87 bool operator==(const EffectPaintPropertyNode& o) const { |
| 83 return m_parent == o.m_parent && | 88 return m_parent == o.m_parent && |
| 84 m_localTransformSpace == o.m_localTransformSpace && | 89 m_localTransformSpace == o.m_localTransformSpace && |
| 85 m_outputClip == o.m_outputClip && m_opacity == o.m_opacity && | 90 m_outputClip == o.m_outputClip && m_opacity == o.m_opacity && |
| 91 m_blendMode == o.m_blendMode && |
| 86 m_filter.equalsIgnoringReferenceFilters(o.m_filter); | 92 m_filter.equalsIgnoringReferenceFilters(o.m_filter); |
| 87 } | 93 } |
| 88 #endif | 94 #endif |
| 89 | 95 |
| 90 String toString() const; | 96 String toString() const; |
| 91 | 97 |
| 92 private: | 98 private: |
| 93 EffectPaintPropertyNode( | 99 EffectPaintPropertyNode( |
| 94 PassRefPtr<const EffectPaintPropertyNode> parent, | 100 PassRefPtr<const EffectPaintPropertyNode> parent, |
| 95 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 101 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
| 96 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 102 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
| 97 CompositorFilterOperations filter, | 103 CompositorFilterOperations filter, |
| 98 float opacity) | 104 float opacity, |
| 105 SkBlendMode blendMode) |
| 99 : m_parent(parent), | 106 : m_parent(parent), |
| 100 m_localTransformSpace(localTransformSpace), | 107 m_localTransformSpace(localTransformSpace), |
| 101 m_outputClip(outputClip), | 108 m_outputClip(outputClip), |
| 102 m_filter(std::move(filter)), | 109 m_filter(std::move(filter)), |
| 103 m_opacity(opacity) {} | 110 m_opacity(opacity), |
| 111 m_blendMode(blendMode) {} |
| 104 | 112 |
| 105 RefPtr<const EffectPaintPropertyNode> m_parent; | 113 RefPtr<const EffectPaintPropertyNode> m_parent; |
| 106 // The local transform space serves two purposes: | 114 // The local transform space serves two purposes: |
| 107 // 1. Assign a depth mapping for 3D depth sorting against other paint chunks | 115 // 1. Assign a depth mapping for 3D depth sorting against other paint chunks |
| 108 // and effects under the same parent. | 116 // and effects under the same parent. |
| 109 // 2. Some effects are spatial (namely blur filter and reflection), the | 117 // 2. Some effects are spatial (namely blur filter and reflection), the |
| 110 // effect parameters will be specified in the local space. | 118 // effect parameters will be specified in the local space. |
| 111 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; | 119 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; |
| 112 // The output of the effect can be optionally clipped when composited onto | 120 // The output of the effect can be optionally clipped when composited onto |
| 113 // the current backdrop. | 121 // the current backdrop. |
| 114 RefPtr<const ClipPaintPropertyNode> m_outputClip; | 122 RefPtr<const ClipPaintPropertyNode> m_outputClip; |
| 115 | 123 |
| 116 // Optionally a number of effects can be applied to the composited output. | 124 // Optionally a number of effects can be applied to the composited output. |
| 117 // The chain of effects will be applied in the following order: | 125 // The chain of effects will be applied in the following order: |
| 118 // === Begin of effects === | 126 // === Begin of effects === |
| 119 CompositorFilterOperations m_filter; | 127 CompositorFilterOperations m_filter; |
| 120 float m_opacity; | 128 float m_opacity; |
| 129 SkBlendMode m_blendMode; |
| 121 // === End of effects === | 130 // === End of effects === |
| 122 | 131 |
| 123 // TODO(trchen): Remove the dummy layer. | 132 // TODO(trchen): Remove the dummy layer. |
| 124 // The main purpose of the dummy layer is to maintain a permanent identity | 133 // The main purpose of the dummy layer is to maintain a permanent identity |
| 125 // to associate with cc::RenderSurfaceImpl for damage tracking. This shall | 134 // to associate with cc::RenderSurfaceImpl for damage tracking. This shall |
| 126 // be removed in favor of a stable ID once cc::LayerImpl no longer owns | 135 // be removed in favor of a stable ID once cc::LayerImpl no longer owns |
| 127 // RenderSurfaceImpl. | 136 // RenderSurfaceImpl. |
| 128 mutable scoped_refptr<cc::Layer> m_dummyLayer; | 137 mutable scoped_refptr<cc::Layer> m_dummyLayer; |
| 129 }; | 138 }; |
| 130 | 139 |
| 131 // Redeclared here to avoid ODR issues. | 140 // Redeclared here to avoid ODR issues. |
| 132 // See platform/testing/PaintPrinters.h. | 141 // See platform/testing/PaintPrinters.h. |
| 133 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); | 142 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); |
| 134 | 143 |
| 135 } // namespace blink | 144 } // namespace blink |
| 136 | 145 |
| 137 #endif // EffectPaintPropertyNode_h | 146 #endif // EffectPaintPropertyNode_h |
| OLD | NEW |