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