| 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/CompositorElementId.h" | 10 #include "platform/graphics/CompositorElementId.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 static EffectPaintPropertyNode* root(); | 32 static EffectPaintPropertyNode* root(); |
| 33 | 33 |
| 34 static PassRefPtr<EffectPaintPropertyNode> create( | 34 static PassRefPtr<EffectPaintPropertyNode> create( |
| 35 PassRefPtr<const EffectPaintPropertyNode> parent, | 35 PassRefPtr<const EffectPaintPropertyNode> parent, |
| 36 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 36 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
| 37 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 37 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
| 38 CompositorFilterOperations filter, | 38 CompositorFilterOperations filter, |
| 39 float opacity, | 39 float opacity, |
| 40 SkBlendMode blendMode, | 40 SkBlendMode blendMode, |
| 41 CompositingReasons directCompositingReasons = CompositingReasonNone, | 41 CompositingReasons directCompositingReasons = CompositingReasonNone, |
| 42 const CompositorElementId& compositorElementId = CompositorElementId()) { | 42 const CompositorElementId& compositorElementId = CompositorElementId(), |
| 43 const FloatPoint& paintOffset = FloatPoint()) { |
| 43 return adoptRef(new EffectPaintPropertyNode( | 44 return adoptRef(new EffectPaintPropertyNode( |
| 44 std::move(parent), std::move(localTransformSpace), | 45 std::move(parent), std::move(localTransformSpace), |
| 45 std::move(outputClip), std::move(filter), opacity, blendMode, | 46 std::move(outputClip), std::move(filter), opacity, blendMode, |
| 46 directCompositingReasons, compositorElementId)); | 47 directCompositingReasons, compositorElementId, paintOffset)); |
| 47 } | 48 } |
| 48 | 49 |
| 49 void update( | 50 void update( |
| 50 PassRefPtr<const EffectPaintPropertyNode> parent, | 51 PassRefPtr<const EffectPaintPropertyNode> parent, |
| 51 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 52 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
| 52 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 53 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
| 53 CompositorFilterOperations filter, | 54 CompositorFilterOperations filter, |
| 54 float opacity, | 55 float opacity, |
| 55 SkBlendMode blendMode, | 56 SkBlendMode blendMode, |
| 56 CompositingReasons directCompositingReasons = CompositingReasonNone, | 57 CompositingReasons directCompositingReasons = CompositingReasonNone, |
| 57 CompositorElementId compositorElementId = CompositorElementId()) { | 58 const CompositorElementId& compositorElementId = CompositorElementId(), |
| 59 const FloatPoint& paintOffset = FloatPoint()) { |
| 58 DCHECK(!isRoot()); | 60 DCHECK(!isRoot()); |
| 59 DCHECK(parent != this); | 61 DCHECK(parent != this); |
| 60 m_parent = parent; | 62 m_parent = parent; |
| 61 m_localTransformSpace = localTransformSpace; | 63 m_localTransformSpace = localTransformSpace; |
| 62 m_outputClip = outputClip; | 64 m_outputClip = outputClip; |
| 63 m_filter = std::move(filter); | 65 m_filter = std::move(filter); |
| 64 m_opacity = opacity; | 66 m_opacity = opacity; |
| 65 m_blendMode = blendMode; | 67 m_blendMode = blendMode; |
| 66 m_directCompositingReasons = directCompositingReasons; | 68 m_directCompositingReasons = directCompositingReasons; |
| 67 m_compositorElementId = compositorElementId; | 69 m_compositorElementId = compositorElementId; |
| 70 m_paintOffset = paintOffset; |
| 68 } | 71 } |
| 69 | 72 |
| 70 const TransformPaintPropertyNode* localTransformSpace() const { | 73 const TransformPaintPropertyNode* localTransformSpace() const { |
| 71 return m_localTransformSpace.get(); | 74 return m_localTransformSpace.get(); |
| 72 } | 75 } |
| 73 const ClipPaintPropertyNode* outputClip() const { return m_outputClip.get(); } | 76 const ClipPaintPropertyNode* outputClip() const { return m_outputClip.get(); } |
| 74 | 77 |
| 75 SkBlendMode blendMode() const { return m_blendMode; } | 78 SkBlendMode blendMode() const { return m_blendMode; } |
| 76 float opacity() const { return m_opacity; } | 79 float opacity() const { return m_opacity; } |
| 77 const CompositorFilterOperations& filter() const { return m_filter; } | 80 const CompositorFilterOperations& filter() const { return m_filter; } |
| 78 | 81 |
| 79 // Parent effect or nullptr if this is the root effect. | 82 // Parent effect or nullptr if this is the root effect. |
| 80 const EffectPaintPropertyNode* parent() const { return m_parent.get(); } | 83 const EffectPaintPropertyNode* parent() const { return m_parent.get(); } |
| 81 bool isRoot() const { return !m_parent; } | 84 bool isRoot() const { return !m_parent; } |
| 82 | 85 |
| 86 bool hasFilterThatMovesPixels() const { |
| 87 return m_filter.hasFilterThatMovesPixels(); |
| 88 } |
| 89 |
| 90 // Returns a rect covering the pixels that can be affected by pixels in |
| 91 // |inputRect|. The rects are in the space of localTransformSpace. |
| 92 FloatRect mapRect(const FloatRect& inputRect) const; |
| 93 |
| 83 cc::Layer* ensureDummyLayer() const; | 94 cc::Layer* ensureDummyLayer() const; |
| 84 | 95 |
| 85 #if DCHECK_IS_ON() | 96 #if DCHECK_IS_ON() |
| 86 // The clone function is used by FindPropertiesNeedingUpdate.h for recording | 97 // The clone function is used by FindPropertiesNeedingUpdate.h for recording |
| 87 // an effect node before it has been updated, to later detect changes. | 98 // an effect node before it has been updated, to later detect changes. |
| 88 PassRefPtr<EffectPaintPropertyNode> clone() const { | 99 PassRefPtr<EffectPaintPropertyNode> clone() const { |
| 89 return adoptRef(new EffectPaintPropertyNode( | 100 return adoptRef(new EffectPaintPropertyNode( |
| 90 m_parent, m_localTransformSpace, m_outputClip, m_filter, m_opacity, | 101 m_parent, m_localTransformSpace, m_outputClip, m_filter, m_opacity, |
| 91 m_blendMode, m_directCompositingReasons, m_compositorElementId)); | 102 m_blendMode, m_directCompositingReasons, m_compositorElementId, |
| 103 m_paintOffset)); |
| 92 } | 104 } |
| 93 | 105 |
| 94 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking | 106 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking |
| 95 // if an effect node has changed. It ignores changes of reference filters | 107 // if an effect node has changed. It ignores changes of reference filters |
| 96 // because SkImageFilter doesn't have an equality operator. | 108 // because SkImageFilter doesn't have an equality operator. |
| 97 bool operator==(const EffectPaintPropertyNode& o) const { | 109 bool operator==(const EffectPaintPropertyNode& o) const { |
| 98 return m_parent == o.m_parent && | 110 return m_parent == o.m_parent && |
| 99 m_localTransformSpace == o.m_localTransformSpace && | 111 m_localTransformSpace == o.m_localTransformSpace && |
| 100 m_outputClip == o.m_outputClip && | 112 m_outputClip == o.m_outputClip && |
| 101 m_filter.equalsIgnoringReferenceFilters(o.m_filter) && | 113 m_filter.equalsIgnoringReferenceFilters(o.m_filter) && |
| 102 m_opacity == o.m_opacity && m_blendMode == o.m_blendMode && | 114 m_opacity == o.m_opacity && m_blendMode == o.m_blendMode && |
| 103 m_directCompositingReasons == o.m_directCompositingReasons && | 115 m_directCompositingReasons == o.m_directCompositingReasons && |
| 104 m_compositorElementId == o.m_compositorElementId; | 116 m_compositorElementId == o.m_compositorElementId && |
| 117 m_paintOffset == o.m_paintOffset; |
| 105 } | 118 } |
| 106 | 119 |
| 107 String toTreeString() const; | 120 String toTreeString() const; |
| 108 #endif | 121 #endif |
| 109 | 122 |
| 110 String toString() const; | 123 String toString() const; |
| 111 | 124 |
| 112 bool hasDirectCompositingReasons() const { | 125 bool hasDirectCompositingReasons() const { |
| 113 return m_directCompositingReasons != CompositingReasonNone; | 126 return m_directCompositingReasons != CompositingReasonNone; |
| 114 } | 127 } |
| 115 | 128 |
| 116 bool requiresCompositingForAnimation() const { | 129 bool requiresCompositingForAnimation() const { |
| 117 return m_directCompositingReasons & CompositingReasonActiveAnimation; | 130 return m_directCompositingReasons & CompositingReasonActiveAnimation; |
| 118 } | 131 } |
| 119 | 132 |
| 120 const CompositorElementId& compositorElementId() const { | 133 const CompositorElementId& compositorElementId() const { |
| 121 return m_compositorElementId; | 134 return m_compositorElementId; |
| 122 } | 135 } |
| 123 | 136 |
| 124 private: | 137 private: |
| 125 EffectPaintPropertyNode( | 138 EffectPaintPropertyNode( |
| 126 PassRefPtr<const EffectPaintPropertyNode> parent, | 139 PassRefPtr<const EffectPaintPropertyNode> parent, |
| 127 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 140 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, |
| 128 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 141 PassRefPtr<const ClipPaintPropertyNode> outputClip, |
| 129 CompositorFilterOperations filter, | 142 CompositorFilterOperations filter, |
| 130 float opacity, | 143 float opacity, |
| 131 SkBlendMode blendMode, | 144 SkBlendMode blendMode, |
| 132 CompositingReasons directCompositingReasons, | 145 CompositingReasons directCompositingReasons, |
| 133 CompositorElementId compositorElementId) | 146 CompositorElementId compositorElementId, |
| 147 const FloatPoint& paintOffset) |
| 134 : m_parent(parent), | 148 : m_parent(parent), |
| 135 m_localTransformSpace(localTransformSpace), | 149 m_localTransformSpace(localTransformSpace), |
| 136 m_outputClip(outputClip), | 150 m_outputClip(outputClip), |
| 137 m_filter(std::move(filter)), | 151 m_filter(std::move(filter)), |
| 138 m_opacity(opacity), | 152 m_opacity(opacity), |
| 139 m_blendMode(blendMode), | 153 m_blendMode(blendMode), |
| 140 m_directCompositingReasons(directCompositingReasons), | 154 m_directCompositingReasons(directCompositingReasons), |
| 141 m_compositorElementId(compositorElementId) {} | 155 m_compositorElementId(compositorElementId), |
| 156 m_paintOffset(paintOffset) {} |
| 142 | 157 |
| 143 RefPtr<const EffectPaintPropertyNode> m_parent; | 158 RefPtr<const EffectPaintPropertyNode> m_parent; |
| 144 // The local transform space serves two purposes: | 159 // The local transform space serves two purposes: |
| 145 // 1. Assign a depth mapping for 3D depth sorting against other paint chunks | 160 // 1. Assign a depth mapping for 3D depth sorting against other paint chunks |
| 146 // and effects under the same parent. | 161 // and effects under the same parent. |
| 147 // 2. Some effects are spatial (namely blur filter and reflection), the | 162 // 2. Some effects are spatial (namely blur filter and reflection), the |
| 148 // effect parameters will be specified in the local space. | 163 // effect parameters will be specified in the local space. |
| 149 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; | 164 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; |
| 150 // The output of the effect can be optionally clipped when composited onto | 165 // The output of the effect can be optionally clipped when composited onto |
| 151 // the current backdrop. | 166 // the current backdrop. |
| 152 RefPtr<const ClipPaintPropertyNode> m_outputClip; | 167 RefPtr<const ClipPaintPropertyNode> m_outputClip; |
| 153 | 168 |
| 154 // Optionally a number of effects can be applied to the composited output. | 169 // Optionally a number of effects can be applied to the composited output. |
| 155 // The chain of effects will be applied in the following order: | 170 // The chain of effects will be applied in the following order: |
| 156 // === Begin of effects === | 171 // === Begin of effects === |
| 157 CompositorFilterOperations m_filter; | 172 CompositorFilterOperations m_filter; |
| 158 float m_opacity; | 173 float m_opacity; |
| 159 SkBlendMode m_blendMode; | 174 SkBlendMode m_blendMode; |
| 160 // === End of effects === | 175 // === End of effects === |
| 161 | 176 |
| 162 // TODO(trchen): Remove the dummy layer. | 177 // TODO(trchen): Remove the dummy layer. |
| 163 // The main purpose of the dummy layer is to maintain a permanent identity | 178 // The main purpose of the dummy layer is to maintain a permanent identity |
| 164 // to associate with cc::RenderSurfaceImpl for damage tracking. This shall | 179 // to associate with cc::RenderSurfaceImpl for damage tracking. This shall |
| 165 // be removed in favor of a stable ID once cc::LayerImpl no longer owns | 180 // be removed in favor of a stable ID once cc::LayerImpl no longer owns |
| 166 // RenderSurfaceImpl. | 181 // RenderSurfaceImpl. |
| 167 mutable scoped_refptr<cc::Layer> m_dummyLayer; | 182 mutable scoped_refptr<cc::Layer> m_dummyLayer; |
| 168 | 183 |
| 169 CompositingReasons m_directCompositingReasons; | 184 CompositingReasons m_directCompositingReasons; |
| 170 CompositorElementId m_compositorElementId; | 185 CompositorElementId m_compositorElementId; |
| 186 |
| 187 // The offset of the effect's local space in m_localTransformSpace. Some |
| 188 // effects e.g. reflection need this to apply geometry effects in the local |
| 189 // space. |
| 190 FloatPoint m_paintOffset; |
| 171 }; | 191 }; |
| 172 | 192 |
| 173 // Redeclared here to avoid ODR issues. | 193 // Redeclared here to avoid ODR issues. |
| 174 // See platform/testing/PaintPrinters.h. | 194 // See platform/testing/PaintPrinters.h. |
| 175 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); | 195 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); |
| 176 | 196 |
| 177 } // namespace blink | 197 } // namespace blink |
| 178 | 198 |
| 179 #endif // EffectPaintPropertyNode_h | 199 #endif // EffectPaintPropertyNode_h |
| OLD | NEW |