Chromium Code Reviews| 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 "SkFlattenableBuffers.h" | 9 #include "SkFlattenableBuffers.h" |
| 10 #include "SkUnPreMultiply.h" | 10 #include "SkUnPreMultiply.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 | 198 |
| 199 SkAutoLockPixels alp_displacement(displ), alp_color(color); | 199 SkAutoLockPixels alp_displacement(displ), alp_color(color); |
| 200 if (!displ.getPixels() || !color.getPixels()) { | 200 if (!displ.getPixels() || !color.getPixels()) { |
| 201 return false; | 201 return false; |
| 202 } | 202 } |
| 203 SkIRect bounds; | 203 SkIRect bounds; |
| 204 color.getBounds(&bounds); | 204 color.getBounds(&bounds); |
| 205 if (!this->applyCropRect(&bounds, ctm)) { | 205 if (!this->applyCropRect(&bounds, ctm)) { |
| 206 return false; | 206 return false; |
| 207 } | 207 } |
| 208 SkIRect displBounds; | |
| 209 displ.getBounds(&displBounds); | |
| 210 if (!this->applyCropRect(&displBounds, ctm)) { | |
|
Stephen White
2013/12/09 21:16:12
Please add a GM test case for this.
| |
| 211 return false; | |
| 212 } | |
| 213 if (!bounds.intersect(displBounds)) { | |
| 214 return false; | |
| 215 } | |
| 208 | 216 |
| 209 dst->setConfig(color.config(), bounds.width(), bounds.height()); | 217 dst->setConfig(color.config(), bounds.width(), bounds.height()); |
| 210 dst->allocPixels(); | 218 dst->allocPixels(); |
| 211 if (!dst->getPixels()) { | 219 if (!dst->getPixels()) { |
| 212 return false; | 220 return false; |
| 213 } | 221 } |
| 214 | 222 |
| 215 computeDisplacement(fXChannelSelector, fYChannelSelector, fScale, dst, &disp l, &color, bounds); | 223 computeDisplacement(fXChannelSelector, fYChannelSelector, fScale, dst, &disp l, &color, bounds); |
| 216 | 224 |
| 217 offset->fX += bounds.left(); | 225 offset->fX += bounds.left(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); | 335 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); |
| 328 | 336 |
| 329 GrPaint paint; | 337 GrPaint paint; |
| 330 paint.addColorEffect( | 338 paint.addColorEffect( |
| 331 GrDisplacementMapEffect::Create(fXChannelSelector, | 339 GrDisplacementMapEffect::Create(fXChannelSelector, |
| 332 fYChannelSelector, | 340 fYChannelSelector, |
| 333 fScale, | 341 fScale, |
| 334 displacement, | 342 displacement, |
| 335 color))->unref(); | 343 color))->unref(); |
| 336 SkIRect bounds; | 344 SkIRect bounds; |
| 337 src.getBounds(&bounds); | 345 src.getBounds(&bounds); |
|
Stephen White
2013/12/09 21:17:23
Shouldn't we also be applying the crop rect to the
| |
| 338 if (!this->applyCropRect(&bounds, ctm)) { | 346 if (!this->applyCropRect(&bounds, ctm)) { |
| 339 return false; | 347 return false; |
| 340 } | 348 } |
| 341 SkRect srcRect = SkRect::Make(bounds); | 349 SkRect srcRect = SkRect::Make(bounds); |
| 342 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); | 350 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); |
| 343 context->drawRectToRect(paint, dstRect, srcRect); | 351 context->drawRectToRect(paint, dstRect, srcRect); |
| 344 offset->fX += bounds.left(); | 352 offset->fX += bounds.left(); |
| 345 offset->fY += bounds.top(); | 353 offset->fY += bounds.top(); |
| 346 return SkImageFilterUtils::WrapTexture(dst, bounds.width(), bounds.height(), result); | 354 return SkImageFilterUtils::WrapTexture(dst, bounds.width(), bounds.height(), result); |
| 347 } | 355 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 const GrGLCaps&) { | 532 const GrGLCaps&) { |
| 525 const GrDisplacementMapEffect& displacementMap = | 533 const GrDisplacementMapEffect& displacementMap = |
| 526 drawEffect.castEffect<GrDisplacementMapEffect>(); | 534 drawEffect.castEffect<GrDisplacementMapEffect>(); |
| 527 | 535 |
| 528 EffectKey xKey = displacementMap.xChannelSelector(); | 536 EffectKey xKey = displacementMap.xChannelSelector(); |
| 529 EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffe ct::kKeyBits; | 537 EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffe ct::kKeyBits; |
| 530 | 538 |
| 531 return xKey | yKey; | 539 return xKey | yKey; |
| 532 } | 540 } |
| 533 #endif | 541 #endif |
| OLD | NEW |