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 "glsl/GrGLSLFragmentShaderBuilder.h" |
| 15 #include "glsl/GrGLSLProgramBuilder.h" |
15 | 16 |
16 class GrGLSimpleTextureEffect : public GrGLFragmentProcessor { | 17 class GrGLSimpleTextureEffect : public GrGLFragmentProcessor { |
17 public: | 18 public: |
18 GrGLSimpleTextureEffect(const GrProcessor&) {} | 19 GrGLSimpleTextureEffect(const GrProcessor&) {} |
19 | 20 |
20 virtual void emitCode(EmitArgs& args) override { | 21 virtual void emitCode(EmitArgs& args) override { |
21 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder
(); | 22 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuild
er(); |
22 fsBuilder->codeAppendf("\t%s = ", args.fOutputColor); | 23 fsBuilder->codeAppendf("\t%s = ", args.fOutputColor); |
23 fsBuilder->appendTextureLookupAndModulate(args.fInputColor, | 24 fsBuilder->appendTextureLookupAndModulate(args.fInputColor, |
24 args.fSamplers[0], | 25 args.fSamplers[0], |
25 args.fCoords[0].c_str(), | 26 args.fCoords[0].c_str(), |
26 args.fCoords[0].getType()); | 27 args.fCoords[0].getType()); |
27 fsBuilder->codeAppend(";\n"); | 28 fsBuilder->codeAppend(";\n"); |
28 } | 29 } |
29 | 30 |
30 private: | 31 private: |
31 typedef GrGLFragmentProcessor INHERITED; | 32 typedef GrGLFragmentProcessor INHERITED; |
32 }; | 33 }; |
33 | 34 |
34 /////////////////////////////////////////////////////////////////////////////// | 35 /////////////////////////////////////////////////////////////////////////////// |
35 | 36 |
36 void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { | 37 void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { |
37 this->updateInvariantOutputForModulation(inout); | 38 this->updateInvariantOutputForModulation(inout); |
38 } | 39 } |
39 | 40 |
40 void GrSimpleTextureEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 41 void GrSimpleTextureEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
41 GrProcessorKeyBuilder* b) const { | 42 GrProcessorKeyBuilder* b) const
{ |
42 GrGLSimpleTextureEffect::GenKey(*this, caps, b); | 43 GrGLSimpleTextureEffect::GenKey(*this, caps, b); |
43 } | 44 } |
44 | 45 |
45 GrGLFragmentProcessor* GrSimpleTextureEffect::onCreateGLInstance() const { | 46 GrGLFragmentProcessor* GrSimpleTextureEffect::onCreateGLInstance() const { |
46 return new GrGLSimpleTextureEffect(*this); | 47 return new GrGLSimpleTextureEffect(*this); |
47 } | 48 } |
48 | 49 |
49 /////////////////////////////////////////////////////////////////////////////// | 50 /////////////////////////////////////////////////////////////////////////////// |
50 | 51 |
51 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect); | 52 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect); |
(...skipping 15 matching lines...) Loading... |
67 | 68 |
68 static const GrCoordSet kCoordSets[] = { | 69 static const GrCoordSet kCoordSets[] = { |
69 kLocal_GrCoordSet, | 70 kLocal_GrCoordSet, |
70 kDevice_GrCoordSet | 71 kDevice_GrCoordSet |
71 }; | 72 }; |
72 GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kC
oordSets))]; | 73 GrCoordSet coordSet = kCoordSets[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kC
oordSets))]; |
73 | 74 |
74 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); | 75 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); |
75 return GrSimpleTextureEffect::Create(d->fTextures[texIdx], matrix, coordSet)
; | 76 return GrSimpleTextureEffect::Create(d->fTextures[texIdx], matrix, coordSet)
; |
76 } | 77 } |
OLD | NEW |