| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 return false; | 247 return false; |
| 248 } | 248 } |
| 249 if (!bounds.intersect(displBounds)) { | 249 if (!bounds.intersect(displBounds)) { |
| 250 return false; | 250 return false; |
| 251 } | 251 } |
| 252 SkAutoLockPixels alp_displacement(displ), alp_color(color); | 252 SkAutoLockPixels alp_displacement(displ), alp_color(color); |
| 253 if (!displ.getPixels() || !color.getPixels()) { | 253 if (!displ.getPixels() || !color.getPixels()) { |
| 254 return false; | 254 return false; |
| 255 } | 255 } |
| 256 | 256 |
| 257 if (!dst->allocPixels(color.info().makeWH(bounds.width(), bounds.height())))
{ | 257 if (!dst->tryAllocPixels(color.info().makeWH(bounds.width(), bounds.height()
))) { |
| 258 return false; | 258 return false; |
| 259 } | 259 } |
| 260 | 260 |
| 261 SkVector scale = SkVector::Make(fScale, fScale); | 261 SkVector scale = SkVector::Make(fScale, fScale); |
| 262 ctx.ctm().mapVectors(&scale, 1); | 262 ctx.ctm().mapVectors(&scale, 1); |
| 263 SkIRect colorBounds = bounds; | 263 SkIRect colorBounds = bounds; |
| 264 colorBounds.offset(-colorOffset); | 264 colorBounds.offset(-colorOffset); |
| 265 | 265 |
| 266 computeDisplacement(fXChannelSelector, fYChannelSelector, scale, dst, | 266 computeDisplacement(fXChannelSelector, fYChannelSelector, scale, dst, |
| 267 &displ, colorOffset - displOffset, &color, colorBounds); | 267 &displ, colorOffset - displOffset, &color, colorBounds); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 const GrGLCaps&, GrEffectKeyBuilder* b) { | 635 const GrGLCaps&, GrEffectKeyBuilder* b) { |
| 636 const GrDisplacementMapEffect& displacementMap = | 636 const GrDisplacementMapEffect& displacementMap = |
| 637 drawEffect.castEffect<GrDisplacementMapEffect>(); | 637 drawEffect.castEffect<GrDisplacementMapEffect>(); |
| 638 | 638 |
| 639 uint32_t xKey = displacementMap.xChannelSelector(); | 639 uint32_t xKey = displacementMap.xChannelSelector(); |
| 640 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 640 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
| 641 | 641 |
| 642 b->add32(xKey | yKey); | 642 b->add32(xKey | yKey); |
| 643 } | 643 } |
| 644 #endif | 644 #endif |
| OLD | NEW |