bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 1 | /* |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 2 | * Copyright 2017 Google Inc. |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Ethan Nicholas | 130fb3f | 2018-02-01 12:14:34 -0500 | [diff] [blame] | 8 | /************************************************************************************************** |
| 9 | *** This file was autogenerated from GrSimpleTextureEffect.fp; do not modify. |
| 10 | **************************************************************************************************/ |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 11 | #include "GrSimpleTextureEffect.h" |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 12 | #include "glsl/GrGLSLFragmentProcessor.h" |
egdaniel | 2d721d3 | 2015-11-11 13:06:05 -0800 | [diff] [blame] | 13 | #include "glsl/GrGLSLFragmentShaderBuilder.h" |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 14 | #include "glsl/GrGLSLProgramBuilder.h" |
Ethan Nicholas | 2d5f9b3 | 2017-12-13 14:36:14 -0500 | [diff] [blame] | 15 | #include "GrTexture.h" |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 16 | #include "SkSLCPP.h" |
| 17 | #include "SkSLUtil.h" |
| 18 | class GrGLSLSimpleTextureEffect : public GrGLSLFragmentProcessor { |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 19 | public: |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 20 | GrGLSLSimpleTextureEffect() {} |
robertphillips | 9cdb992 | 2016-02-03 12:25:40 -0800 | [diff] [blame] | 21 | void emitCode(EmitArgs& args) override { |
Mike Klein | d6ab77a | 2019-03-21 08:18:24 -0500 | [diff] [blame^] | 22 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 23 | const GrSimpleTextureEffect& _outer = args.fFp.cast<GrSimpleTextureEffect>(); |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 24 | (void)_outer; |
Ethan Nicholas | 8239946 | 2017-10-16 12:35:44 -0400 | [diff] [blame] | 25 | auto matrix = _outer.matrix(); |
| 26 | (void)matrix; |
Brian Osman | 72a37be | 2017-08-15 09:19:53 -0400 | [diff] [blame] | 27 | SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]); |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 28 | fragBuilder->codeAppendf( |
Mike Klein | d6ab77a | 2019-03-21 08:18:24 -0500 | [diff] [blame^] | 29 | "%s = %s * texture(%s, %s).%s;\n", args.fOutputColor, args.fInputColor, |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 30 | fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(), |
| 31 | sk_TransformedCoords2D_0.c_str(), |
Brian Osman | 2240be9 | 2017-10-18 13:15:13 -0400 | [diff] [blame] | 32 | fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str()); |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 33 | } |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 34 | |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 35 | private: |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 36 | void onSetData(const GrGLSLProgramDataManager& pdman, |
Mike Klein | d6ab77a | 2019-03-21 08:18:24 -0500 | [diff] [blame^] | 37 | const GrFragmentProcessor& _proc) override {} |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 38 | }; |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 39 | GrGLSLFragmentProcessor* GrSimpleTextureEffect::onCreateGLSLInstance() const { |
| 40 | return new GrGLSLSimpleTextureEffect(); |
Ethan Nicholas | baf981f | 2017-07-12 13:51:34 +0000 | [diff] [blame] | 41 | } |
Mike Klein | d6ab77a | 2019-03-21 08:18:24 -0500 | [diff] [blame^] | 42 | void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, |
Brian Osman | 2240be9 | 2017-10-18 13:15:13 -0400 | [diff] [blame] | 43 | GrProcessorKeyBuilder* b) const {} |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 44 | bool GrSimpleTextureEffect::onIsEqual(const GrFragmentProcessor& other) const { |
| 45 | const GrSimpleTextureEffect& that = other.cast<GrSimpleTextureEffect>(); |
Ethan Nicholas | b7e8c3b | 2017-07-19 13:54:20 -0400 | [diff] [blame] | 46 | (void)that; |
Mike Klein | d6ab77a | 2019-03-21 08:18:24 -0500 | [diff] [blame^] | 47 | if (fImage != that.fImage) return false; |
| 48 | if (fMatrix != that.fMatrix) return false; |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 49 | return true; |
| 50 | } |
Ethan Nicholas | f57c0d6 | 2017-07-31 11:18:22 -0400 | [diff] [blame] | 51 | GrSimpleTextureEffect::GrSimpleTextureEffect(const GrSimpleTextureEffect& src) |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 52 | : INHERITED(kGrSimpleTextureEffect_ClassID, src.optimizationFlags()) |
Ethan Nicholas | f57c0d6 | 2017-07-31 11:18:22 -0400 | [diff] [blame] | 53 | , fImage(src.fImage) |
Ethan Nicholas | f57c0d6 | 2017-07-31 11:18:22 -0400 | [diff] [blame] | 54 | , fMatrix(src.fMatrix) |
| 55 | , fImageCoordTransform(src.fImageCoordTransform) { |
Brian Salomon | f7dcd76 | 2018-07-30 14:48:15 -0400 | [diff] [blame] | 56 | this->setTextureSamplerCnt(1); |
Ethan Nicholas | f57c0d6 | 2017-07-31 11:18:22 -0400 | [diff] [blame] | 57 | this->addCoordTransform(&fImageCoordTransform); |
| 58 | } |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 59 | std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::clone() const { |
| 60 | return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(*this)); |
Ethan Nicholas | f57c0d6 | 2017-07-31 11:18:22 -0400 | [diff] [blame] | 61 | } |
Brian Salomon | f7dcd76 | 2018-07-30 14:48:15 -0400 | [diff] [blame] | 62 | const GrFragmentProcessor::TextureSampler& GrSimpleTextureEffect::onTextureSampler( |
| 63 | int index) const { |
| 64 | return IthTextureSampler(index, fImage); |
| 65 | } |
Ethan Nicholas | baf981f | 2017-07-12 13:51:34 +0000 | [diff] [blame] | 66 | GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect); |
Ethan Nicholas | baf981f | 2017-07-12 13:51:34 +0000 | [diff] [blame] | 67 | #if GR_TEST_UTILS |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 68 | std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate( |
| 69 | GrProcessorTestData* testData) { |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 70 | int texIdx = testData->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx |
| 71 | : GrProcessorUnitTest::kAlphaTextureIdx; |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 72 | GrSamplerState::WrapMode wrapModes[2]; |
| 73 | GrTest::TestWrapModes(testData->fRandom, wrapModes); |
Robert Phillips | b350f1c | 2017-10-20 17:26:51 -0400 | [diff] [blame] | 74 | if (!testData->caps()->npotTextureTileSupport()) { |
| 75 | // Performing repeat sampling on npot textures will cause asserts on HW |
| 76 | // that lacks support. |
| 77 | wrapModes[0] = GrSamplerState::WrapMode::kClamp; |
| 78 | wrapModes[1] = GrSamplerState::WrapMode::kClamp; |
| 79 | } |
| 80 | |
Mike Klein | d6ab77a | 2019-03-21 08:18:24 -0500 | [diff] [blame^] | 81 | GrSamplerState params(wrapModes, testData->fRandom->nextBool() |
| 82 | ? GrSamplerState::Filter::kBilerp |
| 83 | : GrSamplerState::Filter::kNearest); |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame] | 84 | |
Ethan Nicholas | 68990be | 2017-07-13 09:36:52 -0400 | [diff] [blame] | 85 | const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom); |
Robert Phillips | 2b2936e | 2017-10-20 15:11:35 -0400 | [diff] [blame] | 86 | return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), matrix, params); |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 87 | } |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 88 | #endif |