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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 break; | 601 break; |
602 case SkDisplacementMapEffect::kA_ChannelSelectorType: | 602 case SkDisplacementMapEffect::kA_ChannelSelectorType: |
603 fragBuilder->codeAppend("a"); | 603 fragBuilder->codeAppend("a"); |
604 break; | 604 break; |
605 case SkDisplacementMapEffect::kUnknown_ChannelSelectorType: | 605 case SkDisplacementMapEffect::kUnknown_ChannelSelectorType: |
606 default: | 606 default: |
607 SkDEBUGFAIL("Unknown Y channel selector"); | 607 SkDEBUGFAIL("Unknown Y channel selector"); |
608 } | 608 } |
609 fragBuilder->codeAppend("-vec2(0.5));\t\t"); | 609 fragBuilder->codeAppend("-vec2(0.5));\t\t"); |
610 | 610 |
611 fGLDomain.sampleTexture(fragBuilder, domain, args.fOutputColor, SkString(cCo
ords), | 611 fGLDomain.sampleTexture(fragBuilder, |
| 612 args.fGLSLCaps, |
| 613 domain, |
| 614 args.fOutputColor, |
| 615 SkString(cCoords), |
612 args.fSamplers[1]); | 616 args.fSamplers[1]); |
613 fragBuilder->codeAppend(";\n"); | 617 fragBuilder->codeAppend(";\n"); |
614 } | 618 } |
615 | 619 |
616 void GrGLDisplacementMapEffect::onSetData(const GrGLSLProgramDataManager& pdman, | 620 void GrGLDisplacementMapEffect::onSetData(const GrGLSLProgramDataManager& pdman, |
617 const GrProcessor& proc) { | 621 const GrProcessor& proc) { |
618 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 622 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
619 GrTexture* colorTex = displacementMap.texture(1); | 623 GrTexture* colorTex = displacementMap.texture(1); |
620 SkScalar scaleX = displacementMap.scale().fX / colorTex->width(); | 624 SkScalar scaleX = displacementMap.scale().fX / colorTex->width(); |
621 SkScalar scaleY = displacementMap.scale().fY / colorTex->height(); | 625 SkScalar scaleY = displacementMap.scale().fY / colorTex->height(); |
622 pdman.set2f(fScaleUni, SkScalarToFloat(scaleX), | 626 pdman.set2f(fScaleUni, SkScalarToFloat(scaleX), |
623 colorTex->origin() == kTopLeft_GrSurfaceOrigin ? | 627 colorTex->origin() == kTopLeft_GrSurfaceOrigin ? |
624 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); | 628 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); |
625 fGLDomain.setData(pdman, displacementMap.domain(), colorTex->origin()); | 629 fGLDomain.setData(pdman, displacementMap.domain(), colorTex->origin()); |
626 } | 630 } |
627 | 631 |
628 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 632 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
629 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { | 633 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
630 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 634 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
631 | 635 |
632 uint32_t xKey = displacementMap.xChannelSelector(); | 636 uint32_t xKey = displacementMap.xChannelSelector(); |
633 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 637 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
634 | 638 |
635 b->add32(xKey | yKey); | 639 b->add32(xKey | yKey); |
636 } | 640 } |
637 #endif | 641 #endif |
638 | 642 |
OLD | NEW |