OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrSimpleTextureEffect.h" | 8 #include "GrSimpleTextureEffect.h" |
9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
11 #include "glsl/GrGLSLColorSpaceXformHelper.h" | 11 #include "glsl/GrGLSLColorSpaceXformHelper.h" |
12 #include "glsl/GrGLSLFragmentProcessor.h" | 12 #include "glsl/GrGLSLFragmentProcessor.h" |
13 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 13 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
14 | 14 |
15 class GrGLSimpleTextureEffect : public GrGLSLFragmentProcessor { | 15 class GrGLSimpleTextureEffect : public GrGLSLFragmentProcessor { |
16 public: | 16 public: |
17 void emitCode(EmitArgs& args) override { | 17 void emitCode(EmitArgs& args) override { |
18 const GrSimpleTextureEffect& textureEffect = args.fFp.cast<GrSimpleTextu
reEffect>(); | 18 const GrSimpleTextureEffect& textureEffect = args.fFp.cast<GrSimpleTextu
reEffect>(); |
19 GrGLSLColorSpaceXformHelper colorSpaceHelper(args.fUniformHandler, | 19 GrGLSLColorSpaceXformHelper colorSpaceHelper(args.fUniformHandler, |
20 textureEffect.colorSpaceXfo
rm(), | 20 textureEffect.colorSpaceXfo
rm(), |
21 &fColorSpaceXformUni); | 21 &fColorSpaceXformUni); |
22 | 22 |
23 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | 23 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
24 fragBuilder->codeAppendf("%s = ", args.fOutputColor); | 24 fragBuilder->codeAppendf("%s = ", args.fOutputColor); |
25 fragBuilder->appendTextureLookupAndModulate(args.fInputColor, | 25 fragBuilder->appendTextureLookupAndModulate(args.fInputColor, |
26 args.fTexSamplers[0], | 26 args.fTexSamplers[0], |
27 args.fCoords[0].c_str(), | 27 args.fTransformedCoords[0].c
_str(), |
28 args.fCoords[0].getType(), | 28 args.fTransformedCoords[0].g
etType(), |
29 &colorSpaceHelper); | 29 &colorSpaceHelper); |
30 fragBuilder->codeAppend(";"); | 30 fragBuilder->codeAppend(";"); |
31 } | 31 } |
32 | 32 |
33 static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&, | 33 static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&, |
34 GrProcessorKeyBuilder* b) { | 34 GrProcessorKeyBuilder* b) { |
35 const GrSimpleTextureEffect& textureEffect = effect.cast<GrSimpleTexture
Effect>(); | 35 const GrSimpleTextureEffect& textureEffect = effect.cast<GrSimpleTexture
Effect>(); |
36 b->add32(GrColorSpaceXform::XformKey(textureEffect.colorSpaceXform())); | 36 b->add32(GrColorSpaceXform::XformKey(textureEffect.colorSpaceXform())); |
37 } | 37 } |
38 | 38 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 static const GrCoordSet kCoordSets[] = { | 87 static const GrCoordSet kCoordSets[] = { |
88 kLocal_GrCoordSet, | 88 kLocal_GrCoordSet, |
89 kDevice_GrCoordSet | 89 kDevice_GrCoordSet |
90 }; | 90 }; |
91 GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kC
oordSets))]; | 91 GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kC
oordSets))]; |
92 | 92 |
93 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); | 93 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); |
94 return GrSimpleTextureEffect::Make(d->fTextures[texIdx], nullptr, matrix, co
ordSet); | 94 return GrSimpleTextureEffect::Make(d->fTextures[texIdx], nullptr, matrix, co
ordSet); |
95 } | 95 } |
OLD | NEW |