bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/GrCoordTransform.h" |
| 9 | #include "src/gpu/GrFragmentProcessor.h" |
| 10 | #include "src/gpu/GrPipeline.h" |
| 11 | #include "src/gpu/GrProcessorAnalysis.h" |
| 12 | #include "src/gpu/effects/GrXfermodeFragmentProcessor.h" |
Brian Osman | 6f5e940 | 2020-01-22 10:39:31 -0500 | [diff] [blame] | 13 | #include "src/gpu/effects/generated/GrClampFragmentProcessor.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "src/gpu/effects/generated/GrConstColorProcessor.h" |
| 15 | #include "src/gpu/effects/generated/GrOverrideInputFragmentProcessor.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 16 | #include "src/gpu/glsl/GrGLSLFragmentProcessor.h" |
| 17 | #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" |
| 18 | #include "src/gpu/glsl/GrGLSLProgramDataManager.h" |
| 19 | #include "src/gpu/glsl/GrGLSLUniformHandler.h" |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 20 | |
bsalomon | 7312ff8 | 2016-09-12 08:55:38 -0700 | [diff] [blame] | 21 | bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that) const { |
Brian Salomon | e782f84 | 2018-07-31 13:53:11 -0400 | [diff] [blame] | 22 | if (this->classID() != that.classID()) { |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 23 | return false; |
| 24 | } |
Brian Salomon | e782f84 | 2018-07-31 13:53:11 -0400 | [diff] [blame] | 25 | if (this->numTextureSamplers() != that.numTextureSamplers()) { |
| 26 | return false; |
| 27 | } |
| 28 | for (int i = 0; i < this->numTextureSamplers(); ++i) { |
| 29 | if (this->textureSampler(i) != that.textureSampler(i)) { |
| 30 | return false; |
| 31 | } |
| 32 | } |
bsalomon | 7312ff8 | 2016-09-12 08:55:38 -0700 | [diff] [blame] | 33 | if (!this->hasSameTransforms(that)) { |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 34 | return false; |
| 35 | } |
| 36 | if (!this->onIsEqual(that)) { |
| 37 | return false; |
| 38 | } |
| 39 | if (this->numChildProcessors() != that.numChildProcessors()) { |
| 40 | return false; |
| 41 | } |
| 42 | for (int i = 0; i < this->numChildProcessors(); ++i) { |
bsalomon | 7312ff8 | 2016-09-12 08:55:38 -0700 | [diff] [blame] | 43 | if (!this->childProcessor(i).isEqual(that.childProcessor(i))) { |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 44 | return false; |
| 45 | } |
| 46 | } |
| 47 | return true; |
| 48 | } |
| 49 | |
Chris Dalton | 7eb5c0f | 2019-05-23 15:15:47 -0600 | [diff] [blame] | 50 | void GrFragmentProcessor::visitProxies(const GrOp::VisitProxyFunc& func) { |
Brian Salomon | c241b58 | 2019-11-27 08:57:17 -0500 | [diff] [blame] | 51 | for (auto [sampler, fp] : FPTextureSamplerRange(*this)) { |
| 52 | bool mipped = (GrSamplerState::Filter::kMipMap == sampler.samplerState().filter()); |
Robert Phillips | bd99c0c | 2019-12-12 13:26:58 +0000 | [diff] [blame] | 53 | func(sampler.view().proxy(), GrMipMapped(mipped)); |
Brian Salomon | e782f84 | 2018-07-31 13:53:11 -0400 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 57 | GrGLSLFragmentProcessor* GrFragmentProcessor::createGLSLInstance() const { |
| 58 | GrGLSLFragmentProcessor* glFragProc = this->onCreateGLSLInstance(); |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 59 | glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); |
| 60 | for (int i = 0; i < fChildProcessors.count(); ++i) { |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 61 | glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLSLInstance(); |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 62 | } |
| 63 | return glFragProc; |
| 64 | } |
| 65 | |
Brian Salomon | e782f84 | 2018-07-31 13:53:11 -0400 | [diff] [blame] | 66 | const GrFragmentProcessor::TextureSampler& GrFragmentProcessor::textureSampler(int i) const { |
| 67 | SkASSERT(i >= 0 && i < fTextureSamplerCnt); |
| 68 | return this->onTextureSampler(i); |
| 69 | } |
| 70 | |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 71 | int GrFragmentProcessor::numCoordTransforms() const { |
Michael Ludwig | fbe2859 | 2020-06-26 16:02:15 -0400 | [diff] [blame] | 72 | if (SkToBool(fFlags & kUsesSampleCoordsDirectly_Flag) && !this->isSampledWithExplicitCoords()) { |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 73 | // coordTransform(0) will return an implicitly defined coord transform so that varyings are |
| 74 | // added for this FP in order to support const/uniform sample matrix lifting. |
| 75 | return 1; |
| 76 | } else { |
Michael Ludwig | fbe2859 | 2020-06-26 16:02:15 -0400 | [diff] [blame] | 77 | return 0; |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | |
| 81 | const GrCoordTransform& GrFragmentProcessor::coordTransform(int i) const { |
Michael Ludwig | fbe2859 | 2020-06-26 16:02:15 -0400 | [diff] [blame] | 82 | SkASSERT(i == 0 && SkToBool(fFlags & kUsesSampleCoordsDirectly_Flag) && |
| 83 | !this->isSampledWithExplicitCoords()); |
| 84 | // as things stand, matrices only work when there's a coord transform, so we need to add |
| 85 | // an identity transform to keep the downstream code happy |
| 86 | static const GrCoordTransform kImplicitIdentity; |
| 87 | return kImplicitIdentity; |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Ethan Nicholas | d3a95c2 | 2020-06-03 13:24:46 -0400 | [diff] [blame] | 90 | void GrFragmentProcessor::setSampleMatrix(SkSL::SampleMatrix newMatrix) { |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 91 | SkASSERT(!newMatrix.isNoOp()); |
| 92 | SkASSERT(fMatrix.isNoOp()); |
| 93 | |
| 94 | fMatrix = newMatrix; |
| 95 | // When an FP is sampled using variable matrix expressions, it is effectively being sampled |
| 96 | // explicitly, except that the call site will automatically evaluate the matrix expression to |
| 97 | // produce the float2 passed into this FP. |
| 98 | if (fMatrix.isVariable()) { |
| 99 | this->addAndPushFlagToChildren(kSampledWithExplicitCoords_Flag); |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 100 | } |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 101 | // Push perspective matrix type to children |
| 102 | if (fMatrix.fHasPerspective) { |
| 103 | this->addAndPushFlagToChildren(kNetTransformHasPerspective_Flag); |
Ethan Nicholas | 5843012 | 2020-04-14 09:54:02 -0400 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 107 | void GrFragmentProcessor::addAndPushFlagToChildren(PrivateFlags flag) { |
| 108 | // This propagates down, so if we've already marked it, all our children should have it too |
| 109 | if (!(fFlags & flag)) { |
| 110 | fFlags |= flag; |
| 111 | for (auto& child : fChildProcessors) { |
| 112 | child->addAndPushFlagToChildren(flag); |
| 113 | } |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 114 | } |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 115 | #ifdef SK_DEBUG |
| 116 | for (auto& child : fChildProcessors) { |
| 117 | SkASSERT(child->fFlags & flag); |
| 118 | } |
| 119 | #endif |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 120 | } |
| 121 | |
Robert Phillips | 82774f8 | 2019-06-20 14:38:27 -0400 | [diff] [blame] | 122 | #ifdef SK_DEBUG |
| 123 | bool GrFragmentProcessor::isInstantiated() const { |
Brian Salomon | e782f84 | 2018-07-31 13:53:11 -0400 | [diff] [blame] | 124 | for (int i = 0; i < fTextureSamplerCnt; ++i) { |
Robert Phillips | 82774f8 | 2019-06-20 14:38:27 -0400 | [diff] [blame] | 125 | if (!this->textureSampler(i).isInstantiated()) { |
Brian Salomon | e782f84 | 2018-07-31 13:53:11 -0400 | [diff] [blame] | 126 | return false; |
| 127 | } |
Robert Phillips | a91e0b7 | 2017-05-01 13:12:20 -0400 | [diff] [blame] | 128 | } |
| 129 | |
Robert Phillips | 9bee2e5 | 2017-05-29 12:37:20 -0400 | [diff] [blame] | 130 | for (int i = 0; i < this->numChildProcessors(); ++i) { |
Robert Phillips | 82774f8 | 2019-06-20 14:38:27 -0400 | [diff] [blame] | 131 | if (!this->childProcessor(i).isInstantiated()) { |
Robert Phillips | 9bee2e5 | 2017-05-29 12:37:20 -0400 | [diff] [blame] | 132 | return false; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return true; |
| 137 | } |
Robert Phillips | 82774f8 | 2019-06-20 14:38:27 -0400 | [diff] [blame] | 138 | #endif |
Robert Phillips | 9bee2e5 | 2017-05-29 12:37:20 -0400 | [diff] [blame] | 139 | |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 140 | int GrFragmentProcessor::registerChild(std::unique_ptr<GrFragmentProcessor> child, |
| 141 | SkSL::SampleMatrix sampleMatrix, |
| 142 | bool explicitlySampled) { |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 143 | // The child should not have been attached to another FP already and not had any sampling |
| 144 | // strategy set on it. |
| 145 | SkASSERT(child && !child->fParent && child->sampleMatrix().isNoOp() && |
| 146 | !child->isSampledWithExplicitCoords() && !child->hasPerspectiveTransform()); |
| 147 | |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 148 | // Configure child's sampling state first |
| 149 | if (explicitlySampled) { |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 150 | child->addAndPushFlagToChildren(kSampledWithExplicitCoords_Flag); |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 151 | } |
| 152 | if (sampleMatrix.fKind != SkSL::SampleMatrix::Kind::kNone) { |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 153 | child->setSampleMatrix(sampleMatrix); |
| 154 | } |
| 155 | |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 156 | if (child->sampleMatrix().fKind == SkSL::SampleMatrix::Kind::kVariable) { |
| 157 | // Since the child is sampled with a variable matrix expression, auto-generated code in |
| 158 | // invokeChildWithMatrix() for this FP will refer to the local coordinates. |
| 159 | this->setUsesSampleCoordsDirectly(); |
| 160 | } |
| 161 | |
| 162 | // If the child is not sampled explicitly and not already accessing sample coords directly |
| 163 | // (through reference or variable matrix expansion), then mark that this FP tree relies on |
| 164 | // coordinates at a lower level. If the child is sampled with explicit coordinates and |
| 165 | // there isn't any other direct reference to the sample coords, we halt the upwards propagation |
| 166 | // because it means this FP is determining coordinates on its own. |
| 167 | if (!child->isSampledWithExplicitCoords()) { |
| 168 | if ((child->fFlags & kUsesSampleCoordsDirectly_Flag || |
| 169 | child->fFlags & kUsesSampleCoordsIndirectly_Flag)) { |
| 170 | fFlags |= kUsesSampleCoordsIndirectly_Flag; |
| 171 | } |
| 172 | } |
| 173 | |
Chris Dalton | d7291ba | 2019-03-07 14:17:03 -0700 | [diff] [blame] | 174 | fRequestedFeatures |= child->fRequestedFeatures; |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 175 | |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 176 | int index = fChildProcessors.count(); |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 177 | // Record that the child is attached to us; this FP is the source of any uniform data needed |
| 178 | // to evaluate the child sample matrix. |
| 179 | child->fParent = this; |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 180 | fChildProcessors.push_back(std::move(child)); |
Michael Ludwig | e88320b | 2020-06-24 09:04:56 -0400 | [diff] [blame] | 181 | |
| 182 | // Sanity check: our sample strategy comes from a parent we shouldn't have yet. |
| 183 | SkASSERT(!this->isSampledWithExplicitCoords() && !this->hasPerspectiveTransform() && |
| 184 | fMatrix.isNoOp() && !fParent); |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 185 | return index; |
| 186 | } |
| 187 | |
John Stiles | 3779f44 | 2020-06-15 10:48:49 -0400 | [diff] [blame] | 188 | int GrFragmentProcessor::cloneAndRegisterChildProcessor(const GrFragmentProcessor& fp) { |
| 189 | std::unique_ptr<GrFragmentProcessor> clone = fp.clone(); |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 190 | return this->registerChild(std::move(clone), fp.sampleMatrix(), |
| 191 | fp.isSampledWithExplicitCoords()); |
John Stiles | 3779f44 | 2020-06-15 10:48:49 -0400 | [diff] [blame] | 192 | } |
| 193 | |
John Stiles | 9ec6b05 | 2020-06-15 12:06:10 -0400 | [diff] [blame] | 194 | void GrFragmentProcessor::cloneAndRegisterAllChildProcessors(const GrFragmentProcessor& src) { |
| 195 | for (int i = 0; i < src.numChildProcessors(); ++i) { |
| 196 | this->cloneAndRegisterChildProcessor(src.childProcessor(i)); |
| 197 | } |
| 198 | } |
| 199 | |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 200 | bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) const { |
bsalomon | a624bf3 | 2016-09-20 09:12:47 -0700 | [diff] [blame] | 201 | if (this->numCoordTransforms() != that.numCoordTransforms()) { |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 202 | return false; |
| 203 | } |
bsalomon | a624bf3 | 2016-09-20 09:12:47 -0700 | [diff] [blame] | 204 | int count = this->numCoordTransforms(); |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 205 | for (int i = 0; i < count; ++i) { |
Brian Salomon | 7d8b397 | 2019-11-26 22:34:44 -0500 | [diff] [blame] | 206 | if (!this->coordTransform(i).hasSameEffectiveMatrix(that.coordTransform(i))) { |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 207 | return false; |
| 208 | } |
| 209 | } |
| 210 | return true; |
| 211 | } |
| 212 | |
Mike Reed | 28eaed2 | 2018-02-01 11:24:53 -0500 | [diff] [blame] | 213 | std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MulChildByInputAlpha( |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 214 | std::unique_ptr<GrFragmentProcessor> fp) { |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 215 | if (!fp) { |
| 216 | return nullptr; |
| 217 | } |
John Stiles | 5c57e88 | 2020-06-30 14:05:03 -0400 | [diff] [blame] | 218 | return GrXfermodeFragmentProcessor::Make(/*src=*/nullptr, std::move(fp), SkBlendMode::kDstIn); |
bsalomon | bf87730 | 2015-09-22 09:06:13 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Mike Reed | 28eaed2 | 2018-02-01 11:24:53 -0500 | [diff] [blame] | 221 | std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MulInputByChildAlpha( |
| 222 | std::unique_ptr<GrFragmentProcessor> fp) { |
| 223 | if (!fp) { |
| 224 | return nullptr; |
| 225 | } |
John Stiles | 5c57e88 | 2020-06-30 14:05:03 -0400 | [diff] [blame] | 226 | return GrXfermodeFragmentProcessor::Make(/*src=*/nullptr, std::move(fp), SkBlendMode::kSrcIn); |
Mike Reed | 28eaed2 | 2018-02-01 11:24:53 -0500 | [diff] [blame] | 227 | } |
| 228 | |
Brian Osman | 6f5e940 | 2020-01-22 10:39:31 -0500 | [diff] [blame] | 229 | std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::ClampPremulOutput( |
| 230 | std::unique_ptr<GrFragmentProcessor> fp) { |
| 231 | if (!fp) { |
| 232 | return nullptr; |
| 233 | } |
John Stiles | 5a2a7b3 | 2020-06-04 10:57:21 -0400 | [diff] [blame] | 234 | return GrClampFragmentProcessor::Make(std::move(fp), /*clampToPremul=*/true); |
Brian Osman | 6f5e940 | 2020-01-22 10:39:31 -0500 | [diff] [blame] | 235 | } |
| 236 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 237 | std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::SwizzleOutput( |
| 238 | std::unique_ptr<GrFragmentProcessor> fp, const GrSwizzle& swizzle) { |
Brian Osman | ce42551 | 2017-03-22 14:37:50 -0400 | [diff] [blame] | 239 | class SwizzleFragmentProcessor : public GrFragmentProcessor { |
| 240 | public: |
John Stiles | eed56f0 | 2020-06-04 13:30:51 -0400 | [diff] [blame] | 241 | static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> fp, |
| 242 | const GrSwizzle& swizzle) { |
| 243 | return std::unique_ptr<GrFragmentProcessor>( |
| 244 | new SwizzleFragmentProcessor(std::move(fp), swizzle)); |
Brian Osman | ce42551 | 2017-03-22 14:37:50 -0400 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | const char* name() const override { return "Swizzle"; } |
| 248 | const GrSwizzle& swizzle() const { return fSwizzle; } |
| 249 | |
John Stiles | eed56f0 | 2020-06-04 13:30:51 -0400 | [diff] [blame] | 250 | std::unique_ptr<GrFragmentProcessor> clone() const override { |
| 251 | return Make(this->childProcessor(0).clone(), fSwizzle); |
| 252 | } |
Brian Salomon | 216f2e0 | 2017-07-25 15:52:51 -0400 | [diff] [blame] | 253 | |
Brian Osman | ce42551 | 2017-03-22 14:37:50 -0400 | [diff] [blame] | 254 | private: |
John Stiles | eed56f0 | 2020-06-04 13:30:51 -0400 | [diff] [blame] | 255 | SwizzleFragmentProcessor(std::unique_ptr<GrFragmentProcessor> fp, const GrSwizzle& swizzle) |
| 256 | : INHERITED(kSwizzleFragmentProcessor_ClassID, ProcessorOptimizationFlags(fp.get())) |
| 257 | , fSwizzle(swizzle) { |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 258 | this->registerChild(std::move(fp)); |
John Stiles | eed56f0 | 2020-06-04 13:30:51 -0400 | [diff] [blame] | 259 | } |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 260 | |
Brian Osman | ce42551 | 2017-03-22 14:37:50 -0400 | [diff] [blame] | 261 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { |
| 262 | class GLFP : public GrGLSLFragmentProcessor { |
| 263 | public: |
| 264 | void emitCode(EmitArgs& args) override { |
John Stiles | 0af87fe | 2020-06-05 13:33:09 -0400 | [diff] [blame] | 265 | SkString childColor = this->invokeChild(0, args.fInputColor, args); |
John Stiles | eed56f0 | 2020-06-04 13:30:51 -0400 | [diff] [blame] | 266 | |
Brian Osman | ce42551 | 2017-03-22 14:37:50 -0400 | [diff] [blame] | 267 | const SwizzleFragmentProcessor& sfp = args.fFp.cast<SwizzleFragmentProcessor>(); |
| 268 | const GrSwizzle& swizzle = sfp.swizzle(); |
| 269 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 270 | |
| 271 | fragBuilder->codeAppendf("%s = %s.%s;", |
John Stiles | eed56f0 | 2020-06-04 13:30:51 -0400 | [diff] [blame] | 272 | args.fOutputColor, childColor.c_str(), swizzle.asString().c_str()); |
Brian Osman | ce42551 | 2017-03-22 14:37:50 -0400 | [diff] [blame] | 273 | } |
| 274 | }; |
| 275 | return new GLFP; |
| 276 | } |
| 277 | |
| 278 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const override { |
| 279 | b->add32(fSwizzle.asKey()); |
| 280 | } |
| 281 | |
| 282 | bool onIsEqual(const GrFragmentProcessor& other) const override { |
| 283 | const SwizzleFragmentProcessor& sfp = other.cast<SwizzleFragmentProcessor>(); |
| 284 | return fSwizzle == sfp.fSwizzle; |
| 285 | } |
| 286 | |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 287 | SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override { |
Brian Osman | ce42551 | 2017-03-22 14:37:50 -0400 | [diff] [blame] | 288 | return fSwizzle.applyTo(input); |
| 289 | } |
| 290 | |
| 291 | GrSwizzle fSwizzle; |
| 292 | |
| 293 | typedef GrFragmentProcessor INHERITED; |
| 294 | }; |
| 295 | |
| 296 | if (!fp) { |
| 297 | return nullptr; |
| 298 | } |
| 299 | if (GrSwizzle::RGBA() == swizzle) { |
| 300 | return fp; |
| 301 | } |
John Stiles | eed56f0 | 2020-06-04 13:30:51 -0400 | [diff] [blame] | 302 | return SwizzleFragmentProcessor::Make(std::move(fp), swizzle); |
Brian Osman | ce42551 | 2017-03-22 14:37:50 -0400 | [diff] [blame] | 303 | } |
| 304 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 305 | std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MakeInputPremulAndMulByOutput( |
| 306 | std::unique_ptr<GrFragmentProcessor> fp) { |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 307 | class PremulFragmentProcessor : public GrFragmentProcessor { |
| 308 | public: |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 309 | static std::unique_ptr<GrFragmentProcessor> Make( |
| 310 | std::unique_ptr<GrFragmentProcessor> processor) { |
| 311 | return std::unique_ptr<GrFragmentProcessor>( |
| 312 | new PremulFragmentProcessor(std::move(processor))); |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | const char* name() const override { return "Premultiply"; } |
| 316 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 317 | std::unique_ptr<GrFragmentProcessor> clone() const override { |
Brian Salomon | 96271cd | 2017-07-31 16:27:23 -0400 | [diff] [blame] | 318 | return Make(this->childProcessor(0).clone()); |
Brian Salomon | 216f2e0 | 2017-07-25 15:52:51 -0400 | [diff] [blame] | 319 | } |
| 320 | |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 321 | private: |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 322 | PremulFragmentProcessor(std::unique_ptr<GrFragmentProcessor> processor) |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 323 | : INHERITED(kPremulFragmentProcessor_ClassID, OptFlags(processor.get())) { |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 324 | this->registerChild(std::move(processor)); |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 325 | } |
| 326 | |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 327 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 328 | class GLFP : public GrGLSLFragmentProcessor { |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 329 | public: |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 330 | void emitCode(EmitArgs& args) override { |
cdalton | 8528541 | 2016-02-18 12:37:07 -0800 | [diff] [blame] | 331 | GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
Brian Osman | 978693c | 2020-01-24 14:52:10 -0500 | [diff] [blame] | 332 | SkString temp = this->invokeChild(0, args); |
Brian Osman | cddfc5e | 2020-01-24 10:24:27 -0500 | [diff] [blame] | 333 | fragBuilder->codeAppendf("%s = %s;", args.fOutputColor, temp.c_str()); |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 334 | fragBuilder->codeAppendf("%s.rgb *= %s.rgb;", args.fOutputColor, |
Brian Osman | cddfc5e | 2020-01-24 10:24:27 -0500 | [diff] [blame] | 335 | args.fInputColor); |
egdaniel | 4ca2e60 | 2015-11-18 08:01:26 -0800 | [diff] [blame] | 336 | fragBuilder->codeAppendf("%s *= %s.a;", args.fOutputColor, args.fInputColor); |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 337 | } |
| 338 | }; |
| 339 | return new GLFP; |
| 340 | } |
| 341 | |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 342 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {} |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 343 | |
| 344 | bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
| 345 | |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 346 | static OptimizationFlags OptFlags(const GrFragmentProcessor* inner) { |
| 347 | OptimizationFlags flags = kNone_OptimizationFlags; |
| 348 | if (inner->preservesOpaqueInput()) { |
| 349 | flags |= kPreservesOpaqueInput_OptimizationFlag; |
| 350 | } |
| 351 | if (inner->hasConstantOutputForConstantInput()) { |
| 352 | flags |= kConstantOutputForConstantInput_OptimizationFlag; |
| 353 | } |
| 354 | return flags; |
| 355 | } |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 356 | |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 357 | SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& input) const override { |
| 358 | SkPMColor4f childColor = ConstantOutputForConstantInput(this->childProcessor(0), |
Brian Osman | f28e55d | 2018-10-03 16:35:54 -0400 | [diff] [blame] | 359 | SK_PMColor4fWHITE); |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 360 | SkPMColor4f premulInput = SkColor4f{ input.fR, input.fG, input.fB, input.fA }.premul(); |
| 361 | return premulInput * childColor; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | typedef GrFragmentProcessor INHERITED; |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 365 | }; |
| 366 | if (!fp) { |
| 367 | return nullptr; |
| 368 | } |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 369 | return PremulFragmentProcessor::Make(std::move(fp)); |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | ////////////////////////////////////////////////////////////////////////////// |
| 373 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 374 | std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::OverrideInput( |
Brian Salomon | c0d79e5 | 2019-04-10 15:02:11 -0400 | [diff] [blame] | 375 | std::unique_ptr<GrFragmentProcessor> fp, const SkPMColor4f& color, bool useUniform) { |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 376 | if (!fp) { |
| 377 | return nullptr; |
| 378 | } |
Brian Salomon | c0d79e5 | 2019-04-10 15:02:11 -0400 | [diff] [blame] | 379 | return GrOverrideInputFragmentProcessor::Make(std::move(fp), color, useUniform); |
bsalomon | f1b7a1d | 2015-09-28 06:26:28 -0700 | [diff] [blame] | 380 | } |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 381 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 382 | std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::RunInSeries( |
Brian Salomon | 64f4206 | 2020-02-14 10:42:45 -0500 | [diff] [blame] | 383 | std::unique_ptr<GrFragmentProcessor> series[], int cnt) { |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 384 | class SeriesFragmentProcessor : public GrFragmentProcessor { |
| 385 | public: |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 386 | static std::unique_ptr<GrFragmentProcessor> Make( |
| 387 | std::unique_ptr<GrFragmentProcessor>* children, int cnt) { |
| 388 | return std::unique_ptr<GrFragmentProcessor>(new SeriesFragmentProcessor(children, cnt)); |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | const char* name() const override { return "Series"; } |
| 392 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 393 | std::unique_ptr<GrFragmentProcessor> clone() const override { |
| 394 | SkSTArray<4, std::unique_ptr<GrFragmentProcessor>> children(this->numChildProcessors()); |
Brian Salomon | 216f2e0 | 2017-07-25 15:52:51 -0400 | [diff] [blame] | 395 | for (int i = 0; i < this->numChildProcessors(); ++i) { |
| 396 | if (!children.push_back(this->childProcessor(i).clone())) { |
| 397 | return nullptr; |
| 398 | } |
| 399 | } |
| 400 | return Make(children.begin(), this->numChildProcessors()); |
| 401 | } |
| 402 | |
| 403 | private: |
egdaniel | 57d3b03 | 2015-11-13 11:57:27 -0800 | [diff] [blame] | 404 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { |
egdaniel | 64c4728 | 2015-11-13 06:54:19 -0800 | [diff] [blame] | 405 | class GLFP : public GrGLSLFragmentProcessor { |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 406 | public: |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 407 | void emitCode(EmitArgs& args) override { |
dvonbeck | ca9eeab | 2016-07-06 12:00:06 -0700 | [diff] [blame] | 408 | // First guy's input might be nil. |
Brian Osman | 978693c | 2020-01-24 14:52:10 -0500 | [diff] [blame] | 409 | SkString result = this->invokeChild(0, args.fInputColor, args); |
Brian Osman | cddfc5e | 2020-01-24 10:24:27 -0500 | [diff] [blame] | 410 | for (int i = 1; i < this->numChildProcessors(); ++i) { |
Brian Osman | 978693c | 2020-01-24 14:52:10 -0500 | [diff] [blame] | 411 | result = this->invokeChild(i, result.c_str(), args); |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 412 | } |
Brian Osman | cddfc5e | 2020-01-24 10:24:27 -0500 | [diff] [blame] | 413 | // Copy last output to our output variable |
Brian Osman | 978693c | 2020-01-24 14:52:10 -0500 | [diff] [blame] | 414 | args.fFragBuilder->codeAppendf("%s = %s;", args.fOutputColor, result.c_str()); |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 415 | } |
| 416 | }; |
| 417 | return new GLFP; |
| 418 | } |
Brian Salomon | 216f2e0 | 2017-07-25 15:52:51 -0400 | [diff] [blame] | 419 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 420 | SeriesFragmentProcessor(std::unique_ptr<GrFragmentProcessor>* children, int cnt) |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 421 | : INHERITED(kSeriesFragmentProcessor_ClassID, OptFlags(children, cnt)) { |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 422 | SkASSERT(cnt > 1); |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 423 | for (int i = 0; i < cnt; ++i) { |
Michael Ludwig | 9aba625 | 2020-06-22 14:46:36 -0400 | [diff] [blame] | 424 | this->registerChild(std::move(children[i])); |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 425 | } |
| 426 | } |
| 427 | |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 428 | static OptimizationFlags OptFlags(std::unique_ptr<GrFragmentProcessor>* children, int cnt) { |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 429 | OptimizationFlags flags = kAll_OptimizationFlags; |
| 430 | for (int i = 0; i < cnt && flags != kNone_OptimizationFlags; ++i) { |
| 431 | flags &= children[i]->optimizationFlags(); |
| 432 | } |
| 433 | return flags; |
| 434 | } |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 435 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {} |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 436 | |
| 437 | bool onIsEqual(const GrFragmentProcessor&) const override { return true; } |
| 438 | |
Brian Osman | 1d5b598 | 2018-10-01 13:41:39 -0400 | [diff] [blame] | 439 | SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& inColor) const override { |
| 440 | SkPMColor4f color = inColor; |
Brian Salomon | 587e08f | 2017-01-27 10:59:27 -0500 | [diff] [blame] | 441 | int childCnt = this->numChildProcessors(); |
| 442 | for (int i = 0; i < childCnt; ++i) { |
| 443 | color = ConstantOutputForConstantInput(this->childProcessor(i), color); |
| 444 | } |
| 445 | return color; |
| 446 | } |
| 447 | |
| 448 | typedef GrFragmentProcessor INHERITED; |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 449 | }; |
| 450 | |
| 451 | if (!cnt) { |
| 452 | return nullptr; |
| 453 | } |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 454 | if (1 == cnt) { |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 455 | return std::move(series[0]); |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 456 | } |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 457 | // Run the through the series, do the invariant output processing, and look for eliminations. |
Brian Salomon | 650ced0 | 2017-07-20 16:46:46 -0400 | [diff] [blame] | 458 | GrProcessorAnalysisColor inputColor; |
| 459 | inputColor.setToUnknown(); |
Brian Salomon | 64f4206 | 2020-02-14 10:42:45 -0500 | [diff] [blame] | 460 | GrColorFragmentProcessorAnalysis info(inputColor, series, cnt); |
Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 461 | SkTArray<std::unique_ptr<GrFragmentProcessor>> replacementSeries; |
Brian Osman | f28e55d | 2018-10-03 16:35:54 -0400 | [diff] [blame] | 462 | SkPMColor4f knownColor; |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 463 | int leadingFPsToEliminate = info.initialProcessorsToEliminate(&knownColor); |
| 464 | if (leadingFPsToEliminate) { |
John Stiles | e3a39f7 | 2020-06-15 13:58:48 -0400 | [diff] [blame] | 465 | std::unique_ptr<GrFragmentProcessor> colorFP = GrConstColorProcessor::Make( |
| 466 | /*inputFP=*/nullptr, knownColor, GrConstColorProcessor::InputMode::kIgnore); |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 467 | if (leadingFPsToEliminate == cnt) { |
| 468 | return colorFP; |
| 469 | } |
| 470 | cnt = cnt - leadingFPsToEliminate + 1; |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 471 | replacementSeries.reserve(cnt); |
| 472 | replacementSeries.emplace_back(std::move(colorFP)); |
| 473 | for (int i = 0; i < cnt - 1; ++i) { |
Brian Salomon | eec6f7b | 2017-02-10 14:29:38 -0500 | [diff] [blame] | 474 | replacementSeries.emplace_back(std::move(series[leadingFPsToEliminate + i])); |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 475 | } |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 476 | series = replacementSeries.begin(); |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 477 | } |
Robert Phillips | 1c9686b | 2017-06-30 08:40:28 -0400 | [diff] [blame] | 478 | return SeriesFragmentProcessor::Make(series, cnt); |
bsalomon | e25eea4 | 2015-09-29 06:38:55 -0700 | [diff] [blame] | 479 | } |
bsalomon | a624bf3 | 2016-09-20 09:12:47 -0700 | [diff] [blame] | 480 | |
| 481 | ////////////////////////////////////////////////////////////////////////////// |
| 482 | |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 483 | GrFragmentProcessor::CIter::CIter(const GrPaint& paint) { |
Chris Dalton | 1c54894 | 2018-05-22 13:09:48 -0600 | [diff] [blame] | 484 | for (int i = paint.numCoverageFragmentProcessors() - 1; i >= 0; --i) { |
| 485 | fFPStack.push_back(paint.getCoverageFragmentProcessor(i)); |
| 486 | } |
| 487 | for (int i = paint.numColorFragmentProcessors() - 1; i >= 0; --i) { |
| 488 | fFPStack.push_back(paint.getColorFragmentProcessor(i)); |
| 489 | } |
| 490 | } |
| 491 | |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 492 | GrFragmentProcessor::CIter::CIter(const GrProcessorSet& set) { |
Brian Salomon | c241b58 | 2019-11-27 08:57:17 -0500 | [diff] [blame] | 493 | for (int i = set.numCoverageFragmentProcessors() - 1; i >= 0; --i) { |
| 494 | fFPStack.push_back(set.coverageFragmentProcessor(i)); |
bsalomon | a624bf3 | 2016-09-20 09:12:47 -0700 | [diff] [blame] | 495 | } |
Brian Salomon | c241b58 | 2019-11-27 08:57:17 -0500 | [diff] [blame] | 496 | for (int i = set.numColorFragmentProcessors() - 1; i >= 0; --i) { |
| 497 | fFPStack.push_back(set.colorFragmentProcessor(i)); |
| 498 | } |
| 499 | } |
| 500 | |
Brian Salomon | 7eabfe8 | 2019-12-02 14:20:20 -0500 | [diff] [blame] | 501 | GrFragmentProcessor::CIter::CIter(const GrPipeline& pipeline) { |
Brian Salomon | c241b58 | 2019-11-27 08:57:17 -0500 | [diff] [blame] | 502 | for (int i = pipeline.numFragmentProcessors() - 1; i >= 0; --i) { |
| 503 | fFPStack.push_back(&pipeline.getFragmentProcessor(i)); |
| 504 | } |
| 505 | } |
| 506 | |
Brian Salomon | e782f84 | 2018-07-31 13:53:11 -0400 | [diff] [blame] | 507 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 508 | |
Robert Phillips | bd99c0c | 2019-12-12 13:26:58 +0000 | [diff] [blame] | 509 | GrFragmentProcessor::TextureSampler::TextureSampler(GrSurfaceProxyView view, |
Brian Salomon | ccb6142 | 2020-01-09 10:46:36 -0500 | [diff] [blame] | 510 | GrSamplerState samplerState) |
| 511 | : fView(std::move(view)), fSamplerState(samplerState) { |
Robert Phillips | bd99c0c | 2019-12-12 13:26:58 +0000 | [diff] [blame] | 512 | GrSurfaceProxy* proxy = this->proxy(); |
Greg Daniel | acf5929 | 2019-12-11 13:45:17 -0500 | [diff] [blame] | 513 | fSamplerState.setFilterMode( |
Brian Osman | 788b916 | 2020-02-07 10:36:46 -0500 | [diff] [blame] | 514 | std::min(samplerState.filter(), |
Robert Phillips | bd99c0c | 2019-12-12 13:26:58 +0000 | [diff] [blame] | 515 | GrTextureProxy::HighestFilterMode(proxy->backendFormat().textureType()))); |
Greg Daniel | acf5929 | 2019-12-11 13:45:17 -0500 | [diff] [blame] | 516 | } |
Robert Phillips | bd99c0c | 2019-12-12 13:26:58 +0000 | [diff] [blame] | 517 | |
Robert Phillips | bd99c0c | 2019-12-12 13:26:58 +0000 | [diff] [blame] | 518 | #if GR_TEST_UTILS |
| 519 | void GrFragmentProcessor::TextureSampler::set(GrSurfaceProxyView view, |
Brian Salomon | ccb6142 | 2020-01-09 10:46:36 -0500 | [diff] [blame] | 520 | GrSamplerState samplerState) { |
Robert Phillips | bd99c0c | 2019-12-12 13:26:58 +0000 | [diff] [blame] | 521 | SkASSERT(view.proxy()->asTextureProxy()); |
| 522 | fView = std::move(view); |
| 523 | fSamplerState = samplerState; |
| 524 | |
| 525 | fSamplerState.setFilterMode( |
Brian Osman | 788b916 | 2020-02-07 10:36:46 -0500 | [diff] [blame] | 526 | std::min(samplerState.filter(), |
Robert Phillips | bd99c0c | 2019-12-12 13:26:58 +0000 | [diff] [blame] | 527 | GrTextureProxy::HighestFilterMode(this->proxy()->backendFormat().textureType()))); |
| 528 | } |
| 529 | #endif |