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