Chromium Code Reviews| 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& offset = 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, offset)); | 
| 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& offset = 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_offset = offset; | |
| 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 hasFilterThanMovesPixels() const { | |
| 87 return m_filter.hasFilterThatMovesPixels(); | |
| 88 } | |
| 89 | |
| 90 // Returns a rect covering the pixels that can be affected by pixels in the | |
| 91 // input rect. The rects are in the space of localTransformSpace. | |
| 92 FloatRect mapRect(const FloatRect&) const; | |
| 
 
chrishtr
2017/02/01 02:59:12
Nit: name the argument inputRect.
 
Xianzhu
2017/02/03 01:38:16
Done.
 
 | |
| 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_offset)); | |
| 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_offset == o.m_offset; | |
| 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 const CompositorElementId& compositorElementId() const { | 129 const CompositorElementId& compositorElementId() const { | 
| 117 return m_compositorElementId; | 130 return m_compositorElementId; | 
| 118 } | 131 } | 
| 119 | 132 | 
| 120 private: | 133 private: | 
| 121 EffectPaintPropertyNode( | 134 EffectPaintPropertyNode( | 
| 122 PassRefPtr<const EffectPaintPropertyNode> parent, | 135 PassRefPtr<const EffectPaintPropertyNode> parent, | 
| 123 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 136 PassRefPtr<const TransformPaintPropertyNode> localTransformSpace, | 
| 124 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 137 PassRefPtr<const ClipPaintPropertyNode> outputClip, | 
| 125 CompositorFilterOperations filter, | 138 CompositorFilterOperations filter, | 
| 126 float opacity, | 139 float opacity, | 
| 127 SkBlendMode blendMode, | 140 SkBlendMode blendMode, | 
| 128 CompositingReasons directCompositingReasons, | 141 CompositingReasons directCompositingReasons, | 
| 129 CompositorElementId compositorElementId) | 142 CompositorElementId compositorElementId, | 
| 143 const FloatPoint& offset) | |
| 130 : m_parent(parent), | 144 : m_parent(parent), | 
| 131 m_localTransformSpace(localTransformSpace), | 145 m_localTransformSpace(localTransformSpace), | 
| 132 m_outputClip(outputClip), | 146 m_outputClip(outputClip), | 
| 133 m_filter(std::move(filter)), | 147 m_filter(std::move(filter)), | 
| 134 m_opacity(opacity), | 148 m_opacity(opacity), | 
| 135 m_blendMode(blendMode), | 149 m_blendMode(blendMode), | 
| 136 m_directCompositingReasons(directCompositingReasons), | 150 m_directCompositingReasons(directCompositingReasons), | 
| 137 m_compositorElementId(compositorElementId) {} | 151 m_compositorElementId(compositorElementId), | 
| 152 m_offset(offset) {} | |
| 138 | 153 | 
| 139 RefPtr<const EffectPaintPropertyNode> m_parent; | 154 RefPtr<const EffectPaintPropertyNode> m_parent; | 
| 140 // The local transform space serves two purposes: | 155 // The local transform space serves two purposes: | 
| 141 // 1. Assign a depth mapping for 3D depth sorting against other paint chunks | 156 // 1. Assign a depth mapping for 3D depth sorting against other paint chunks | 
| 142 // and effects under the same parent. | 157 // and effects under the same parent. | 
| 143 // 2. Some effects are spatial (namely blur filter and reflection), the | 158 // 2. Some effects are spatial (namely blur filter and reflection), the | 
| 144 // effect parameters will be specified in the local space. | 159 // effect parameters will be specified in the local space. | 
| 145 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; | 160 RefPtr<const TransformPaintPropertyNode> m_localTransformSpace; | 
| 146 // The output of the effect can be optionally clipped when composited onto | 161 // The output of the effect can be optionally clipped when composited onto | 
| 147 // the current backdrop. | 162 // the current backdrop. | 
| 148 RefPtr<const ClipPaintPropertyNode> m_outputClip; | 163 RefPtr<const ClipPaintPropertyNode> m_outputClip; | 
| 149 | 164 | 
| 150 // Optionally a number of effects can be applied to the composited output. | 165 // Optionally a number of effects can be applied to the composited output. | 
| 151 // The chain of effects will be applied in the following order: | 166 // The chain of effects will be applied in the following order: | 
| 152 // === Begin of effects === | 167 // === Begin of effects === | 
| 153 CompositorFilterOperations m_filter; | 168 CompositorFilterOperations m_filter; | 
| 154 float m_opacity; | 169 float m_opacity; | 
| 155 SkBlendMode m_blendMode; | 170 SkBlendMode m_blendMode; | 
| 156 // === End of effects === | 171 // === End of effects === | 
| 157 | 172 | 
| 158 // TODO(trchen): Remove the dummy layer. | 173 // TODO(trchen): Remove the dummy layer. | 
| 159 // The main purpose of the dummy layer is to maintain a permanent identity | 174 // The main purpose of the dummy layer is to maintain a permanent identity | 
| 160 // to associate with cc::RenderSurfaceImpl for damage tracking. This shall | 175 // to associate with cc::RenderSurfaceImpl for damage tracking. This shall | 
| 161 // be removed in favor of a stable ID once cc::LayerImpl no longer owns | 176 // be removed in favor of a stable ID once cc::LayerImpl no longer owns | 
| 162 // RenderSurfaceImpl. | 177 // RenderSurfaceImpl. | 
| 163 mutable scoped_refptr<cc::Layer> m_dummyLayer; | 178 mutable scoped_refptr<cc::Layer> m_dummyLayer; | 
| 164 | 179 | 
| 165 CompositingReasons m_directCompositingReasons; | 180 CompositingReasons m_directCompositingReasons; | 
| 166 CompositorElementId m_compositorElementId; | 181 CompositorElementId m_compositorElementId; | 
| 182 | |
| 183 // The offset of the effect's local space in m_localTransformSpace. Some | |
| 184 // effects e.g. reflection need this to apply geometry effects in the local | |
| 185 // space. | |
| 186 FloatPoint m_offset; | |
| 
 
chrishtr
2017/02/01 02:59:12
Why not m_paintOffset?
 
Xianzhu
2017/02/03 01:38:16
No specific reason :)
Modified to paintOffset to k
 
 | |
| 167 }; | 187 }; | 
| 168 | 188 | 
| 169 // Redeclared here to avoid ODR issues. | 189 // Redeclared here to avoid ODR issues. | 
| 170 // See platform/testing/PaintPrinters.h. | 190 // See platform/testing/PaintPrinters.h. | 
| 171 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); | 191 void PrintTo(const EffectPaintPropertyNode&, std::ostream*); | 
| 172 | 192 | 
| 173 } // namespace blink | 193 } // namespace blink | 
| 174 | 194 | 
| 175 #endif // EffectPaintPropertyNode_h | 195 #endif // EffectPaintPropertyNode_h | 
| OLD | NEW |