| 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 "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
| 10 #include "SkWriteBuffer.h" | 11 #include "SkWriteBuffer.h" |
| 11 #include "SkUnPreMultiply.h" | 12 #include "SkUnPreMultiply.h" |
| 12 #include "SkColorPriv.h" | 13 #include "SkColorPriv.h" |
| 13 #if SK_SUPPORT_GPU | 14 #if SK_SUPPORT_GPU |
| 14 #include "GrContext.h" | 15 #include "GrContext.h" |
| 15 #include "GrDrawContext.h" | 16 #include "GrDrawContext.h" |
| 16 #include "GrCoordTransform.h" | 17 #include "GrCoordTransform.h" |
| 17 #include "GrInvariantOutput.h" | 18 #include "GrInvariantOutput.h" |
| 18 #include "effects/GrTextureDomain.h" | 19 #include "effects/GrTextureDomain.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 return false; | 233 return false; |
| 233 } | 234 } |
| 234 if (!bounds.intersect(displBounds)) { | 235 if (!bounds.intersect(displBounds)) { |
| 235 return false; | 236 return false; |
| 236 } | 237 } |
| 237 SkAutoLockPixels alp_displacement(displ), alp_color(color); | 238 SkAutoLockPixels alp_displacement(displ), alp_color(color); |
| 238 if (!displ.getPixels() || !color.getPixels()) { | 239 if (!displ.getPixels() || !color.getPixels()) { |
| 239 return false; | 240 return false; |
| 240 } | 241 } |
| 241 | 242 |
| 242 if (!dst->tryAllocPixels(color.info().makeWH(bounds.width(), bounds.height()
))) { | 243 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
| 244 if (!device) { |
| 243 return false; | 245 return false; |
| 244 } | 246 } |
| 247 *dst = device->accessBitmap(false); |
| 248 SkAutoLockPixels alp_dst(*dst); |
| 245 | 249 |
| 246 SkVector scale = SkVector::Make(fScale, fScale); | 250 SkVector scale = SkVector::Make(fScale, fScale); |
| 247 ctx.ctm().mapVectors(&scale, 1); | 251 ctx.ctm().mapVectors(&scale, 1); |
| 248 SkIRect colorBounds = bounds; | 252 SkIRect colorBounds = bounds; |
| 249 colorBounds.offset(-colorOffset); | 253 colorBounds.offset(-colorOffset); |
| 250 | 254 |
| 251 computeDisplacement(fXChannelSelector, fYChannelSelector, scale, dst, | 255 computeDisplacement(fXChannelSelector, fYChannelSelector, scale, dst, |
| 252 &displ, colorOffset - displOffset, &color, colorBounds); | 256 &displ, colorOffset - displOffset, &color, colorBounds); |
| 253 | 257 |
| 254 offset->fX = bounds.left(); | 258 offset->fX = bounds.left(); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 625 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
| 622 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 626 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
| 623 | 627 |
| 624 uint32_t xKey = displacementMap.xChannelSelector(); | 628 uint32_t xKey = displacementMap.xChannelSelector(); |
| 625 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 629 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
| 626 | 630 |
| 627 b->add32(xKey | yKey); | 631 b->add32(xKey | yKey); |
| 628 } | 632 } |
| 629 #endif | 633 #endif |
| 630 | 634 |
| OLD | NEW |