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 "gl/builders/GrGLProgramBuilder.h" | |
9 #include "GrSimpleTextureEffect.h" | 8 #include "GrSimpleTextureEffect.h" |
| 9 #include "GrInvariantOutput.h" |
| 10 #include "GrTBackendProcessorFactory.h" |
| 11 #include "GrTexture.h" |
10 #include "gl/GrGLProcessor.h" | 12 #include "gl/GrGLProcessor.h" |
11 #include "gl/GrGLSL.h" | 13 #include "gl/GrGLSL.h" |
12 #include "gl/GrGLTexture.h" | 14 #include "gl/GrGLTexture.h" |
13 #include "GrTBackendProcessorFactory.h" | 15 #include "gl/builders/GrGLProgramBuilder.h" |
14 #include "GrTexture.h" | |
15 | 16 |
16 class GrGLSimpleTextureEffect : public GrGLFragmentProcessor { | 17 class GrGLSimpleTextureEffect : public GrGLFragmentProcessor { |
17 public: | 18 public: |
18 GrGLSimpleTextureEffect(const GrBackendProcessorFactory& factory, const GrPr
ocessor&) | 19 GrGLSimpleTextureEffect(const GrBackendProcessorFactory& factory, const GrPr
ocessor&) |
19 : INHERITED (factory) { | 20 : INHERITED (factory) { |
20 } | 21 } |
21 | 22 |
22 virtual void emitCode(GrGLFPBuilder* builder, | 23 virtual void emitCode(GrGLFPBuilder* builder, |
23 const GrFragmentProcessor& fp, | 24 const GrFragmentProcessor& fp, |
24 const GrProcessorKey& key, | 25 const GrProcessorKey& key, |
25 const char* outputColor, | 26 const char* outputColor, |
26 const char* inputColor, | 27 const char* inputColor, |
27 const TransformedCoordsArray& coords, | 28 const TransformedCoordsArray& coords, |
28 const TextureSamplerArray& samplers) SK_OVERRIDE { | 29 const TextureSamplerArray& samplers) SK_OVERRIDE { |
29 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 30 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
30 fsBuilder->codeAppendf("\t%s = ", outputColor); | 31 fsBuilder->codeAppendf("\t%s = ", outputColor); |
31 fsBuilder->appendTextureLookupAndModulate(inputColor, | 32 fsBuilder->appendTextureLookupAndModulate(inputColor, |
32 samplers[0], | 33 samplers[0], |
33 coords[0].c_str(), | 34 coords[0].c_str(), |
34 coords[0].getType()); | 35 coords[0].getType()); |
35 fsBuilder->codeAppend(";\n"); | 36 fsBuilder->codeAppend(";\n"); |
36 } | 37 } |
37 | 38 |
38 private: | 39 private: |
39 typedef GrGLFragmentProcessor INHERITED; | 40 typedef GrGLFragmentProcessor INHERITED; |
40 }; | 41 }; |
41 | 42 |
42 /////////////////////////////////////////////////////////////////////////////// | 43 /////////////////////////////////////////////////////////////////////////////// |
43 | 44 |
44 void GrSimpleTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) con
st { | 45 void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { |
45 this->updateInvariantOutputForModulation(inout); | 46 this->updateInvariantOutputForModulation(inout); |
46 } | 47 } |
47 | 48 |
48 const GrBackendFragmentProcessorFactory& GrSimpleTextureEffect::getFactory() con
st { | 49 const GrBackendFragmentProcessorFactory& GrSimpleTextureEffect::getFactory() con
st { |
49 return GrTBackendFragmentProcessorFactory<GrSimpleTextureEffect>::getInstanc
e(); | 50 return GrTBackendFragmentProcessorFactory<GrSimpleTextureEffect>::getInstanc
e(); |
50 } | 51 } |
51 | 52 |
52 /////////////////////////////////////////////////////////////////////////////// | 53 /////////////////////////////////////////////////////////////////////////////// |
53 | 54 |
54 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect); | 55 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect); |
(...skipping 18 matching lines...) Expand all Loading... |
73 | 74 |
74 static const GrCoordSet kCoordSets[] = { | 75 static const GrCoordSet kCoordSets[] = { |
75 kLocal_GrCoordSet, | 76 kLocal_GrCoordSet, |
76 kPosition_GrCoordSet | 77 kPosition_GrCoordSet |
77 }; | 78 }; |
78 GrCoordSet coordSet = kCoordSets[random->nextULessThan(SK_ARRAY_COUNT(kCoord
Sets))]; | 79 GrCoordSet coordSet = kCoordSets[random->nextULessThan(SK_ARRAY_COUNT(kCoord
Sets))]; |
79 | 80 |
80 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random); | 81 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random); |
81 return GrSimpleTextureEffect::Create(textures[texIdx], matrix, coordSet); | 82 return GrSimpleTextureEffect::Create(textures[texIdx], matrix, coordSet); |
82 } | 83 } |
OLD | NEW |