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" |
11 #include "SkUnPreMultiply.h" | 11 #include "SkUnPreMultiply.h" |
12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
14 #include "GrContext.h" | 14 #include "GrContext.h" |
| 15 #include "GrDrawContext.h" |
15 #include "GrCoordTransform.h" | 16 #include "GrCoordTransform.h" |
16 #include "GrInvariantOutput.h" | 17 #include "GrInvariantOutput.h" |
17 #include "effects/GrTextureDomain.h" | 18 #include "effects/GrTextureDomain.h" |
18 #include "gl/GrGLProcessor.h" | 19 #include "gl/GrGLProcessor.h" |
19 #include "gl/builders/GrGLProgramBuilder.h" | 20 #include "gl/builders/GrGLProgramBuilder.h" |
20 #endif | 21 #endif |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 #define kChannelSelectorKeyBits 3; // Max value is 4, so 3 bits are required at
most | 25 #define kChannelSelectorKeyBits 3; // Max value is 4, so 3 bits are required at
most |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 scale, | 451 scale, |
451 displacement, | 452 displacement, |
452 offsetMatrix, | 453 offsetMatrix, |
453 color, | 454 color, |
454 colorBM.dimensions()))->unref(); | 455 colorBM.dimensions()))->unref(); |
455 SkIRect colorBounds = bounds; | 456 SkIRect colorBounds = bounds; |
456 colorBounds.offset(-colorOffset); | 457 colorBounds.offset(-colorOffset); |
457 SkMatrix matrix; | 458 SkMatrix matrix; |
458 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), | 459 matrix.setTranslate(-SkIntToScalar(colorBounds.x()), |
459 -SkIntToScalar(colorBounds.y())); | 460 -SkIntToScalar(colorBounds.y())); |
460 context->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matrix, | 461 |
461 SkRect::Make(colorBounds)); | 462 GrDrawContext* drawContext = context->drawContext(); |
| 463 if (!drawContext) { |
| 464 return false; |
| 465 } |
| 466 |
| 467 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, matr
ix, |
| 468 SkRect::Make(colorBounds)); |
462 offset->fX = bounds.left(); | 469 offset->fX = bounds.left(); |
463 offset->fY = bounds.top(); | 470 offset->fY = bounds.top(); |
464 WrapTexture(dst, bounds.width(), bounds.height(), result); | 471 WrapTexture(dst, bounds.width(), bounds.height(), result); |
465 return true; | 472 return true; |
466 } | 473 } |
467 | 474 |
468 /////////////////////////////////////////////////////////////////////////////// | 475 /////////////////////////////////////////////////////////////////////////////// |
469 | 476 |
470 GrDisplacementMapEffect::GrDisplacementMapEffect( | 477 GrDisplacementMapEffect::GrDisplacementMapEffect( |
471 SkDisplacementMapEffect::ChannelSelectorType xChann
elSelector, | 478 SkDisplacementMapEffect::ChannelSelectorType xChann
elSelector, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 644 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
638 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 645 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
639 | 646 |
640 uint32_t xKey = displacementMap.xChannelSelector(); | 647 uint32_t xKey = displacementMap.xChannelSelector(); |
641 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 648 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
642 | 649 |
643 b->add32(xKey | yKey); | 650 b->add32(xKey | yKey); |
644 } | 651 } |
645 #endif | 652 #endif |
646 | 653 |
OLD | NEW |