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/GrGLSLFragmentProcessor.h" | 11 #include "glsl/GrGLSLFragmentProcessor.h" |
12 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 12 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 13 #include "glsl/GrGLSLUniformHandler.h" |
13 | 14 |
14 class GrGLSimpleTextureEffect : public GrGLSLFragmentProcessor { | 15 class GrGLSimpleTextureEffect : public GrGLSLFragmentProcessor { |
15 public: | 16 public: |
16 void emitCode(EmitArgs& args) override { | 17 void emitCode(EmitArgs& args) override { |
17 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | 18 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
18 fragBuilder->codeAppendf("%s = ", args.fOutputColor); | 19 fragBuilder->codeAppendf("%s = ", args.fOutputColor); |
| 20 const GrGLSLSampler& sampler = args.fUniformHandler->getSampler(args.fTe
xSamplers[0]); |
19 fragBuilder->appendTextureLookupAndModulate(args.fInputColor, | 21 fragBuilder->appendTextureLookupAndModulate(args.fInputColor, |
20 args.fTexSamplers[0], | 22 sampler, |
21 args.fCoords[0].c_str(), | 23 args.fCoords[0].c_str(), |
22 args.fCoords[0].getType()); | 24 args.fCoords[0].getType()); |
23 fragBuilder->codeAppend(";"); | 25 fragBuilder->codeAppend(";"); |
24 } | 26 } |
25 | 27 |
26 private: | 28 private: |
27 typedef GrGLSLFragmentProcessor INHERITED; | 29 typedef GrGLSLFragmentProcessor INHERITED; |
28 }; | 30 }; |
29 | 31 |
30 /////////////////////////////////////////////////////////////////////////////// | 32 /////////////////////////////////////////////////////////////////////////////// |
31 | 33 |
32 void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { | 34 void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { |
(...skipping 30 matching lines...) Expand all Loading... |
63 | 65 |
64 static const GrCoordSet kCoordSets[] = { | 66 static const GrCoordSet kCoordSets[] = { |
65 kLocal_GrCoordSet, | 67 kLocal_GrCoordSet, |
66 kDevice_GrCoordSet | 68 kDevice_GrCoordSet |
67 }; | 69 }; |
68 GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kC
oordSets))]; | 70 GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kC
oordSets))]; |
69 | 71 |
70 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); | 72 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); |
71 return GrSimpleTextureEffect::Create(d->fTextures[texIdx], matrix, coordSet)
; | 73 return GrSimpleTextureEffect::Create(d->fTextures[texIdx], matrix, coordSet)
; |
72 } | 74 } |
OLD | NEW |