OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDisplacementMapEffect.h" | 8 #include "SkDisplacementMapEffect.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 default: | 156 default: |
157 break; | 157 break; |
158 } | 158 } |
159 return false; | 159 return false; |
160 } | 160 } |
161 | 161 |
162 } // end namespace | 162 } // end namespace |
163 | 163 |
164 /////////////////////////////////////////////////////////////////////////////// | 164 /////////////////////////////////////////////////////////////////////////////// |
165 | 165 |
166 sk_sp<SkImageFilter> SkDisplacementMapEffect::Make(ChannelSelectorType xChannelS
elector, | 166 SkImageFilter* SkDisplacementMapEffect::Create(ChannelSelectorType xChannelSelec
tor, |
167 ChannelSelectorType yChannelS
elector, | 167 ChannelSelectorType yChannelSelec
tor, |
168 SkScalar scale, | 168 SkScalar scale, |
169 sk_sp<SkImageFilter> displace
ment, | 169 SkImageFilter* displacement, |
170 sk_sp<SkImageFilter> color, | 170 SkImageFilter* color, |
171 const CropRect* cropRect) { | 171 const CropRect* cropRect) { |
172 if (!channel_selector_type_is_valid(xChannelSelector) || | 172 if (!channel_selector_type_is_valid(xChannelSelector) || |
173 !channel_selector_type_is_valid(yChannelSelector)) { | 173 !channel_selector_type_is_valid(yChannelSelector)) { |
174 return nullptr; | 174 return nullptr; |
175 } | 175 } |
176 | 176 |
177 sk_sp<SkImageFilter> inputs[2] = { std::move(displacement), std::move(color)
}; | 177 SkImageFilter* inputs[2] = { displacement, color }; |
178 return sk_sp<SkImageFilter>(new SkDisplacementMapEffect(xChannelSelector, | 178 return new SkDisplacementMapEffect(xChannelSelector, yChannelSelector, scale
, inputs, cropRect); |
179 yChannelSelector, | |
180 scale, inputs, cropR
ect)); | |
181 } | 179 } |
182 | 180 |
183 SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSel
ector, | 181 SkDisplacementMapEffect::SkDisplacementMapEffect(ChannelSelectorType xChannelSel
ector, |
184 ChannelSelectorType yChannelSel
ector, | 182 ChannelSelectorType yChannelSel
ector, |
185 SkScalar scale, | 183 SkScalar scale, |
186 sk_sp<SkImageFilter> inputs[2], | 184 SkImageFilter* inputs[2], |
187 const CropRect* cropRect) | 185 const CropRect* cropRect) |
188 : INHERITED(inputs, 2, cropRect) | 186 : INHERITED(2, inputs, cropRect) |
189 , fXChannelSelector(xChannelSelector) | 187 , fXChannelSelector(xChannelSelector) |
190 , fYChannelSelector(yChannelSelector) | 188 , fYChannelSelector(yChannelSelector) |
191 , fScale(scale) { | 189 , fScale(scale) { |
192 } | 190 } |
193 | 191 |
194 SkDisplacementMapEffect::~SkDisplacementMapEffect() { | 192 SkDisplacementMapEffect::~SkDisplacementMapEffect() { |
195 } | 193 } |
196 | 194 |
197 sk_sp<SkFlattenable> SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) { | 195 sk_sp<SkFlattenable> SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) { |
198 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); | 196 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); |
199 ChannelSelectorType xsel = (ChannelSelectorType)buffer.readInt(); | 197 ChannelSelectorType xsel = (ChannelSelectorType)buffer.readInt(); |
200 ChannelSelectorType ysel = (ChannelSelectorType)buffer.readInt(); | 198 ChannelSelectorType ysel = (ChannelSelectorType)buffer.readInt(); |
201 SkScalar scale = buffer.readScalar(); | 199 SkScalar scale = buffer.readScalar(); |
202 return Make(xsel, ysel, scale, | 200 return sk_sp<SkFlattenable>(Create(xsel, ysel, scale, common.getInput(0).get
(), |
203 common.getInput(0), common.getInput(1), | 201 common.getInput(1).get(), &common.cropRec
t())); |
204 &common.cropRect()); | |
205 } | 202 } |
206 | 203 |
207 void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const { | 204 void SkDisplacementMapEffect::flatten(SkWriteBuffer& buffer) const { |
208 this->INHERITED::flatten(buffer); | 205 this->INHERITED::flatten(buffer); |
209 buffer.writeInt((int) fXChannelSelector); | 206 buffer.writeInt((int) fXChannelSelector); |
210 buffer.writeInt((int) fYChannelSelector); | 207 buffer.writeInt((int) fYChannelSelector); |
211 buffer.writeScalar(fScale); | 208 buffer.writeScalar(fScale); |
212 } | 209 } |
213 | 210 |
214 #if SK_SUPPORT_GPU | 211 #if SK_SUPPORT_GPU |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 625 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
629 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 626 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
630 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 627 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
631 | 628 |
632 uint32_t xKey = displacementMap.xChannelSelector(); | 629 uint32_t xKey = displacementMap.xChannelSelector(); |
633 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 630 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
634 | 631 |
635 b->add32(xKey | yKey); | 632 b->add32(xKey | yKey); |
636 } | 633 } |
637 #endif | 634 #endif |
OLD | NEW |