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 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
10 #include "SkWriteBuffer.h" | 10 #include "SkWriteBuffer.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 this->INHERITED::flatten(buffer); | 188 this->INHERITED::flatten(buffer); |
189 buffer.writeInt((int) fXChannelSelector); | 189 buffer.writeInt((int) fXChannelSelector); |
190 buffer.writeInt((int) fYChannelSelector); | 190 buffer.writeInt((int) fYChannelSelector); |
191 buffer.writeScalar(fScale); | 191 buffer.writeScalar(fScale); |
192 } | 192 } |
193 | 193 |
194 bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy, | 194 bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy, |
195 const SkBitmap& src, | 195 const SkBitmap& src, |
196 const SkMatrix& ctm, | 196 const SkMatrix& ctm, |
197 SkBitmap* dst, | 197 SkBitmap* dst, |
198 SkIPoint* offset) { | 198 SkIPoint* offset) const { |
199 SkBitmap displ = src, color = src; | 199 SkBitmap displ = src, color = src; |
200 SkImageFilter* colorInput = getColorInput(); | 200 const SkImageFilter* colorInput = getColorInput(); |
201 SkImageFilter* displInput = getDisplacementInput(); | 201 const SkImageFilter* displInput = getDisplacementInput(); |
202 SkIPoint colorOffset = SkIPoint::Make(0, 0), displOffset = SkIPoint::Make(0,
0); | 202 SkIPoint colorOffset = SkIPoint::Make(0, 0), displOffset = SkIPoint::Make(0,
0); |
203 if ((colorInput && !colorInput->filterImage(proxy, src, ctm, &color, &colorO
ffset)) || | 203 if ((colorInput && !colorInput->filterImage(proxy, src, ctm, &color, &colorO
ffset)) || |
204 (displInput && !displInput->filterImage(proxy, src, ctm, &displ, &displO
ffset))) { | 204 (displInput && !displInput->filterImage(proxy, src, ctm, &displ, &displO
ffset))) { |
205 return false; | 205 return false; |
206 } | 206 } |
207 if ((displ.config() != SkBitmap::kARGB_8888_Config) || | 207 if ((displ.config() != SkBitmap::kARGB_8888_Config) || |
208 (color.config() != SkBitmap::kARGB_8888_Config)) { | 208 (color.config() != SkBitmap::kARGB_8888_Config)) { |
209 return false; | 209 return false; |
210 } | 210 } |
211 | 211 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 GrCoordTransform fColorTransform; | 341 GrCoordTransform fColorTransform; |
342 GrTextureAccess fColorAccess; | 342 GrTextureAccess fColorAccess; |
343 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; | 343 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; |
344 SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector; | 344 SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector; |
345 SkVector fScale; | 345 SkVector fScale; |
346 | 346 |
347 typedef GrEffect INHERITED; | 347 typedef GrEffect INHERITED; |
348 }; | 348 }; |
349 | 349 |
350 bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
const SkMatrix& ctm, | 350 bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
const SkMatrix& ctm, |
351 SkBitmap* result, SkIPoint* offset)
{ | 351 SkBitmap* result, SkIPoint* offset)
const { |
352 SkBitmap colorBM; | 352 SkBitmap colorBM; |
353 SkIPoint colorOffset = SkIPoint::Make(0, 0); | 353 SkIPoint colorOffset = SkIPoint::Make(0, 0); |
354 if (!SkImageFilterUtils::GetInputResultGPU(getColorInput(), proxy, src, ctm,
&colorBM, | 354 if (!SkImageFilterUtils::GetInputResultGPU(getColorInput(), proxy, src, ctm,
&colorBM, |
355 &colorOffset)) { | 355 &colorOffset)) { |
356 return false; | 356 return false; |
357 } | 357 } |
358 GrTexture* color = colorBM.getTexture(); | 358 GrTexture* color = colorBM.getTexture(); |
359 SkBitmap displacementBM; | 359 SkBitmap displacementBM; |
360 SkIPoint displacementOffset = SkIPoint::Make(0, 0); | 360 SkIPoint displacementOffset = SkIPoint::Make(0, 0); |
361 if (!SkImageFilterUtils::GetInputResultGPU(getDisplacementInput(), proxy, sr
c, ctm, | 361 if (!SkImageFilterUtils::GetInputResultGPU(getDisplacementInput(), proxy, sr
c, ctm, |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 const GrGLCaps&) { | 599 const GrGLCaps&) { |
600 const GrDisplacementMapEffect& displacementMap = | 600 const GrDisplacementMapEffect& displacementMap = |
601 drawEffect.castEffect<GrDisplacementMapEffect>(); | 601 drawEffect.castEffect<GrDisplacementMapEffect>(); |
602 | 602 |
603 EffectKey xKey = displacementMap.xChannelSelector(); | 603 EffectKey xKey = displacementMap.xChannelSelector(); |
604 EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffe
ct::kKeyBits; | 604 EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffe
ct::kKeyBits; |
605 | 605 |
606 return xKey | yKey; | 606 return xKey | yKey; |
607 } | 607 } |
608 #endif | 608 #endif |
OLD | NEW |