| 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 GrCoordTransform fColorTransform; | 377 GrCoordTransform fColorTransform; |
| 378 GrTextureAccess fColorAccess; | 378 GrTextureAccess fColorAccess; |
| 379 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; | 379 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; |
| 380 SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector; | 380 SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector; |
| 381 SkVector fScale; | 381 SkVector fScale; |
| 382 | 382 |
| 383 typedef GrFragmentProcessor INHERITED; | 383 typedef GrFragmentProcessor INHERITED; |
| 384 }; | 384 }; |
| 385 | 385 |
| 386 bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
const Context& ctx, | 386 bool SkDisplacementMapEffect::filterImageGPU(Proxy* proxy, const SkBitmap& src,
const Context& ctx, |
| 387 SkBitmap* result, SkIPoint* offset)
const { | 387 const GrClip& clip, SkBitmap* resul
t, |
| 388 SkIPoint* offset) const { |
| 388 SkBitmap colorBM = src; | 389 SkBitmap colorBM = src; |
| 389 SkIPoint colorOffset = SkIPoint::Make(0, 0); | 390 SkIPoint colorOffset = SkIPoint::Make(0, 0); |
| 390 if (getColorInput() && !getColorInput()->getInputResultGPU(proxy, src, ctx,
&colorBM, | 391 if (getColorInput() && !getColorInput()->getInputResultGPU(proxy, src, ctx,
&colorBM, |
| 391 &colorOffset)) { | 392 &colorOffset)) { |
| 392 return false; | 393 return false; |
| 393 } | 394 } |
| 394 SkBitmap displacementBM = src; | 395 SkBitmap displacementBM = src; |
| 395 SkIPoint displacementOffset = SkIPoint::Make(0, 0); | 396 SkIPoint displacementOffset = SkIPoint::Make(0, 0); |
| 396 if (getDisplacementInput() && | 397 if (getDisplacementInput() && |
| 397 !getDisplacementInput()->getInputResultGPU(proxy, src, ctx, &displacemen
tBM, | 398 !getDisplacementInput()->getInputResultGPU(proxy, src, ctx, &displacemen
tBM, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 fYChannelSelector, | 443 fYChannelSelector, |
| 443 scale, | 444 scale, |
| 444 displacement, | 445 displacement, |
| 445 offsetMatrix, | 446 offsetMatrix, |
| 446 color))->unref(); | 447 color))->unref(); |
| 447 SkIRect colorBounds = bounds; | 448 SkIRect colorBounds = bounds; |
| 448 colorBounds.offset(-colorOffset); | 449 colorBounds.offset(-colorOffset); |
| 449 SkMatrix matrix; | 450 SkMatrix matrix; |
| 450 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), | 451 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), |
| 451 -SkIntToScalar(colorBounds.y())); | 452 -SkIntToScalar(colorBounds.y())); |
| 452 context->drawRect(dst->asRenderTarget(), paint, matrix, SkRect::Make(colorBo
unds)); | 453 context->drawRect(dst->asRenderTarget(), clip, paint, matrix, SkRect::Make(c
olorBounds)); |
| 453 offset->fX = bounds.left(); | 454 offset->fX = bounds.left(); |
| 454 offset->fY = bounds.top(); | 455 offset->fY = bounds.top(); |
| 455 WrapTexture(dst, bounds.width(), bounds.height(), result); | 456 WrapTexture(dst, bounds.width(), bounds.height(), result); |
| 456 return true; | 457 return true; |
| 457 } | 458 } |
| 458 | 459 |
| 459 /////////////////////////////////////////////////////////////////////////////// | 460 /////////////////////////////////////////////////////////////////////////////// |
| 460 | 461 |
| 461 GrDisplacementMapEffect::GrDisplacementMapEffect( | 462 GrDisplacementMapEffect::GrDisplacementMapEffect( |
| 462 SkDisplacementMapEffect::ChannelSelectorType xChann
elSelector, | 463 SkDisplacementMapEffect::ChannelSelectorType xChann
elSelector, |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 const GrGLCaps&, GrProcessorKeyBuilder* b
) { | 631 const GrGLCaps&, GrProcessorKeyBuilder* b
) { |
| 631 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 632 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
| 632 | 633 |
| 633 uint32_t xKey = displacementMap.xChannelSelector(); | 634 uint32_t xKey = displacementMap.xChannelSelector(); |
| 634 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 635 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
| 635 | 636 |
| 636 b->add32(xKey | yKey); | 637 b->add32(xKey | yKey); |
| 637 } | 638 } |
| 638 #endif | 639 #endif |
| 639 | 640 |
| OLD | NEW |