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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 getColorInput()->computeFastBounds(src, dst); | 250 getColorInput()->computeFastBounds(src, dst); |
251 } else { | 251 } else { |
252 *dst = src; | 252 *dst = src; |
253 } | 253 } |
254 dst->outset(fScale * SK_ScalarHalf, fScale * SK_ScalarHalf); | 254 dst->outset(fScale * SK_ScalarHalf, fScale * SK_ScalarHalf); |
255 } | 255 } |
256 | 256 |
257 bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix&
ctm, | 257 bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix&
ctm, |
258 SkIRect* dst) const { | 258 SkIRect* dst) const { |
259 SkIRect bounds = src; | 259 SkIRect bounds = src; |
260 if (getColorInput() && !getColorInput()->filterBounds(src, ctm, &bounds)) { | 260 SkVector scale = SkVector::Make(fScale, fScale); |
261 return false; | 261 ctm.mapVectors(&scale, 1); |
| 262 bounds.outset(SkScalarCeilToInt(scale.fX * SK_ScalarHalf), |
| 263 SkScalarCeilToInt(scale.fY * SK_ScalarHalf)); |
| 264 if (getColorInput()) { |
| 265 return getColorInput()->filterBounds(bounds, ctm, dst); |
262 } | 266 } |
263 bounds.outset(SkScalarCeilToInt(fScale * SK_ScalarHalf), | |
264 SkScalarCeilToInt(fScale * SK_ScalarHalf)); | |
265 *dst = bounds; | 267 *dst = bounds; |
266 return true; | 268 return true; |
267 } | 269 } |
268 | 270 |
269 /////////////////////////////////////////////////////////////////////////////// | 271 /////////////////////////////////////////////////////////////////////////////// |
270 | 272 |
271 #if SK_SUPPORT_GPU | 273 #if SK_SUPPORT_GPU |
272 class GrGLDisplacementMapEffect : public GrGLEffect { | 274 class GrGLDisplacementMapEffect : public GrGLEffect { |
273 public: | 275 public: |
274 GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory, | 276 GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory, |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 const GrGLCaps&) { | 606 const GrGLCaps&) { |
605 const GrDisplacementMapEffect& displacementMap = | 607 const GrDisplacementMapEffect& displacementMap = |
606 drawEffect.castEffect<GrDisplacementMapEffect>(); | 608 drawEffect.castEffect<GrDisplacementMapEffect>(); |
607 | 609 |
608 EffectKey xKey = displacementMap.xChannelSelector(); | 610 EffectKey xKey = displacementMap.xChannelSelector(); |
609 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi
ts; | 611 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi
ts; |
610 | 612 |
611 return xKey | yKey; | 613 return xKey | yKey; |
612 } | 614 } |
613 #endif | 615 #endif |
OLD | NEW |