| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 return false; | 220 return false; |
| 221 } | 221 } |
| 222 if (!bounds.intersect(displBounds)) { | 222 if (!bounds.intersect(displBounds)) { |
| 223 return false; | 223 return false; |
| 224 } | 224 } |
| 225 SkAutoLockPixels alp_displacement(displ), alp_color(color); | 225 SkAutoLockPixels alp_displacement(displ), alp_color(color); |
| 226 if (!displ.getPixels() || !color.getPixels()) { | 226 if (!displ.getPixels() || !color.getPixels()) { |
| 227 return false; | 227 return false; |
| 228 } | 228 } |
| 229 | 229 |
| 230 dst->setConfig(color.config(), bounds.width(), bounds.height()); | 230 if (!dst->allocPixels(color.info().makeWH(bounds.width(), bounds.height())))
{ |
| 231 if (!dst->allocPixels()) { | |
| 232 return false; | 231 return false; |
| 233 } | 232 } |
| 234 | 233 |
| 235 SkVector scale = SkVector::Make(fScale, fScale); | 234 SkVector scale = SkVector::Make(fScale, fScale); |
| 236 ctx.ctm().mapVectors(&scale, 1); | 235 ctx.ctm().mapVectors(&scale, 1); |
| 237 SkIRect colorBounds = bounds; | 236 SkIRect colorBounds = bounds; |
| 238 colorBounds.offset(-colorOffset); | 237 colorBounds.offset(-colorOffset); |
| 239 | 238 |
| 240 computeDisplacement(fXChannelSelector, fYChannelSelector, scale, dst, | 239 computeDisplacement(fXChannelSelector, fYChannelSelector, scale, dst, |
| 241 &displ, colorOffset - displOffset, &color, colorBounds); | 240 &displ, colorOffset - displOffset, &color, colorBounds); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 const GrGLCaps&) { | 605 const GrGLCaps&) { |
| 607 const GrDisplacementMapEffect& displacementMap = | 606 const GrDisplacementMapEffect& displacementMap = |
| 608 drawEffect.castEffect<GrDisplacementMapEffect>(); | 607 drawEffect.castEffect<GrDisplacementMapEffect>(); |
| 609 | 608 |
| 610 EffectKey xKey = displacementMap.xChannelSelector(); | 609 EffectKey xKey = displacementMap.xChannelSelector(); |
| 611 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi
ts; | 610 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi
ts; |
| 612 | 611 |
| 613 return xKey | yKey; | 612 return xKey | yKey; |
| 614 } | 613 } |
| 615 #endif | 614 #endif |
| OLD | NEW |