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 "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 !this->filterInput(0, proxy, src, ctx, &displ, &displOffset)) { | 221 !this->filterInput(0, proxy, src, ctx, &displ, &displOffset)) { |
222 return false; | 222 return false; |
223 } | 223 } |
224 if ((displ.colorType() != kN32_SkColorType) || | 224 if ((displ.colorType() != kN32_SkColorType) || |
225 (color.colorType() != kN32_SkColorType)) { | 225 (color.colorType() != kN32_SkColorType)) { |
226 return false; | 226 return false; |
227 } | 227 } |
228 SkIRect bounds; | 228 SkIRect bounds; |
229 // Since computeDisplacement does bounds checking on color pixel access, we
don't need to pad | 229 // Since computeDisplacement does bounds checking on color pixel access, we
don't need to pad |
230 // the color bitmap to bounds here. | 230 // the color bitmap to bounds here. |
231 if (!this->applyCropRect(ctx, color, colorOffset, &bounds)) { | 231 SkIRect srcBounds = color.bounds(); |
| 232 srcBounds.offset(colorOffset); |
| 233 if (!this->applyCropRect(ctx, srcBounds, &bounds)) { |
232 return false; | 234 return false; |
233 } | 235 } |
234 SkIRect displBounds; | 236 SkIRect displBounds; |
235 if (!this->applyCropRect(ctx, proxy, displ, &displOffset, &displBounds, &dis
pl)) { | 237 if (!this->applyCropRect(ctx, proxy, displ, &displOffset, &displBounds, &dis
pl)) { |
236 return false; | 238 return false; |
237 } | 239 } |
238 if (!bounds.intersect(displBounds)) { | 240 if (!bounds.intersect(displBounds)) { |
239 return false; | 241 return false; |
240 } | 242 } |
241 SkAutoLockPixels alp_displacement(displ), alp_color(color); | 243 SkAutoLockPixels alp_displacement(displ), alp_color(color); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 SkBitmap colorBM = src; | 391 SkBitmap colorBM = src; |
390 SkIPoint colorOffset = SkIPoint::Make(0, 0); | 392 SkIPoint colorOffset = SkIPoint::Make(0, 0); |
391 if (!this->filterInputGPU(1, proxy, src, ctx, &colorBM, &colorOffset)) { | 393 if (!this->filterInputGPU(1, proxy, src, ctx, &colorBM, &colorOffset)) { |
392 return false; | 394 return false; |
393 } | 395 } |
394 SkBitmap displacementBM = src; | 396 SkBitmap displacementBM = src; |
395 SkIPoint displacementOffset = SkIPoint::Make(0, 0); | 397 SkIPoint displacementOffset = SkIPoint::Make(0, 0); |
396 if (!this->filterInputGPU(0, proxy, src, ctx, &displacementBM, &displacement
Offset)) { | 398 if (!this->filterInputGPU(0, proxy, src, ctx, &displacementBM, &displacement
Offset)) { |
397 return false; | 399 return false; |
398 } | 400 } |
| 401 SkIRect srcBounds = colorBM.bounds(); |
| 402 srcBounds.offset(colorOffset); |
399 SkIRect bounds; | 403 SkIRect bounds; |
400 // Since GrDisplacementMapEffect does bounds checking on color pixel access,
we don't need to | 404 // Since GrDisplacementMapEffect does bounds checking on color pixel access,
we don't need to |
401 // pad the color bitmap to bounds here. | 405 // pad the color bitmap to bounds here. |
402 if (!this->applyCropRect(ctx, colorBM, colorOffset, &bounds)) { | 406 if (!this->applyCropRect(ctx, srcBounds, &bounds)) { |
403 return false; | 407 return false; |
404 } | 408 } |
405 SkIRect displBounds; | 409 SkIRect displBounds; |
406 if (!this->applyCropRect(ctx, proxy, displacementBM, | 410 if (!this->applyCropRect(ctx, proxy, displacementBM, |
407 &displacementOffset, &displBounds, &displacementBM)
) { | 411 &displacementOffset, &displBounds, &displacementBM)
) { |
408 return false; | 412 return false; |
409 } | 413 } |
410 if (!bounds.intersect(displBounds)) { | 414 if (!bounds.intersect(displBounds)) { |
411 return false; | 415 return false; |
412 } | 416 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 629 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
626 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 630 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
627 | 631 |
628 uint32_t xKey = displacementMap.xChannelSelector(); | 632 uint32_t xKey = displacementMap.xChannelSelector(); |
629 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 633 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
630 | 634 |
631 b->add32(xKey | yKey); | 635 b->add32(xKey | yKey); |
632 } | 636 } |
633 #endif | 637 #endif |
634 | 638 |
OLD | NEW |