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 "SkDevice.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 SkAutoTUnref<GrTexture> dst(context->textureProvider()->createApproxTexture(
desc)); | 424 SkAutoTUnref<GrTexture> dst(context->textureProvider()->createApproxTexture(
desc)); |
425 | 425 |
426 if (!dst) { | 426 if (!dst) { |
427 return false; | 427 return false; |
428 } | 428 } |
429 | 429 |
430 SkVector scale = SkVector::Make(fScale, fScale); | 430 SkVector scale = SkVector::Make(fScale, fScale); |
431 ctx.ctm().mapVectors(&scale, 1); | 431 ctx.ctm().mapVectors(&scale, 1); |
432 | 432 |
433 GrPaint paint; | 433 GrPaint paint; |
| 434 // SRGBTODO: AllowSRGBInputs? |
434 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacem
ent); | 435 SkMatrix offsetMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(displacem
ent); |
435 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset.
fX), | 436 offsetMatrix.preTranslate(SkIntToScalar(colorOffset.fX - displacementOffset.
fX), |
436 SkIntToScalar(colorOffset.fY - displacementOffset.
fY)); | 437 SkIntToScalar(colorOffset.fY - displacementOffset.
fY)); |
437 | 438 |
438 paint.addColorFragmentProcessor( | 439 paint.addColorFragmentProcessor( |
439 GrDisplacementMapEffect::Create(fXChannelSelector, | 440 GrDisplacementMapEffect::Create(fXChannelSelector, |
440 fYChannelSelector, | 441 fYChannelSelector, |
441 scale, | 442 scale, |
442 displacement, | 443 displacement, |
443 offsetMatrix, | 444 offsetMatrix, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 626 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
626 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 627 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
627 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 628 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
628 | 629 |
629 uint32_t xKey = displacementMap.xChannelSelector(); | 630 uint32_t xKey = displacementMap.xChannelSelector(); |
630 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 631 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
631 | 632 |
632 b->add32(xKey | yKey); | 633 b->add32(xKey | yKey); |
633 } | 634 } |
634 #endif | 635 #endif |
OLD | NEW |