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 "gl/GrGLCaps.h" | 11 #include "gl/GrGLCaps.h" |
12 #include "gl/GrGLFragmentProcessor.h" | 12 #include "gl/GrGLFragmentProcessor.h" |
13 #include "gl/GrGLTexture.h" | 13 #include "gl/GrGLTexture.h" |
14 #include "gl/builders/GrGLProgramBuilder.h" | 14 #include "gl/builders/GrGLProgramBuilder.h" |
15 | 15 |
16 class GrGLSimpleTextureEffect : public GrGLFragmentProcessor { | 16 class GrGLSimpleTextureEffect : public GrGLFragmentProcessor { |
17 public: | 17 public: |
18 GrGLSimpleTextureEffect(const GrProcessor&) {} | 18 GrGLSimpleTextureEffect(const GrProcessor&) {} |
19 | 19 |
20 virtual void emitCode(GrGLFPBuilder* builder, | 20 virtual void emitCode(EmitArgs& args) override { |
21 const GrFragmentProcessor& fp, | 21 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder
(); |
22 const char* outputColor, | 22 fsBuilder->codeAppendf("\t%s = ", args.fOutputColor); |
23 const char* inputColor, | 23 fsBuilder->appendTextureLookupAndModulate(args.fInputColor, |
24 const TransformedCoordsArray& coords, | 24 args.fSamplers[0], |
25 const TextureSamplerArray& samplers) override { | 25 args.fCoords[0].c_str(), |
26 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 26 args.fCoords[0].getType()); |
27 fsBuilder->codeAppendf("\t%s = ", outputColor); | |
28 fsBuilder->appendTextureLookupAndModulate(inputColor, | |
29 samplers[0], | |
30 coords[0].c_str(), | |
31 coords[0].getType()); | |
32 fsBuilder->codeAppend(";\n"); | 27 fsBuilder->codeAppend(";\n"); |
33 } | 28 } |
34 | 29 |
35 private: | 30 private: |
36 typedef GrGLFragmentProcessor INHERITED; | 31 typedef GrGLFragmentProcessor INHERITED; |
37 }; | 32 }; |
38 | 33 |
39 /////////////////////////////////////////////////////////////////////////////// | 34 /////////////////////////////////////////////////////////////////////////////// |
40 | 35 |
41 void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { | 36 void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 static const GrCoordSet kCoordSets[] = { | 68 static const GrCoordSet kCoordSets[] = { |
74 kLocal_GrCoordSet, | 69 kLocal_GrCoordSet, |
75 kDevice_GrCoordSet | 70 kDevice_GrCoordSet |
76 }; | 71 }; |
77 GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kC
oordSets))]; | 72 GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kC
oordSets))]; |
78 | 73 |
79 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); | 74 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); |
80 return GrSimpleTextureEffect::Create(d->fProcDataManager, d->fTextures[texId
x], matrix, | 75 return GrSimpleTextureEffect::Create(d->fProcDataManager, d->fTextures[texId
x], matrix, |
81 coordSet); | 76 coordSet); |
82 } | 77 } |
OLD | NEW |