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