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 "GrTextureDomain.h" | 8 #include "GrTextureDomain.h" |
9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
10 #include "GrSimpleTextureEffect.h" | 10 #include "GrSimpleTextureEffect.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 | 170 |
171 ////////////////////////////////////////////////////////////////////////////// | 171 ////////////////////////////////////////////////////////////////////////////// |
172 | 172 |
173 class GrGLTextureDomainEffect : public GrGLFragmentProcessor { | 173 class GrGLTextureDomainEffect : public GrGLFragmentProcessor { |
174 public: | 174 public: |
175 GrGLTextureDomainEffect(const GrProcessor&); | 175 GrGLTextureDomainEffect(const GrProcessor&); |
176 | 176 |
177 virtual void emitCode(EmitArgs&) override; | 177 virtual void emitCode(EmitArgs&) override; |
178 | 178 |
179 void setData(const GrGLProgramDataManager&, const GrProcessor&) override; | 179 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor
KeyBuilder*); |
180 | 180 |
181 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor
KeyBuilder*); | 181 protected: |
| 182 void onSetData(const GrGLProgramDataManager&, const GrProcessor&) override; |
182 | 183 |
183 private: | 184 private: |
184 GrTextureDomain::GLDomain fGLDomain; | 185 GrTextureDomain::GLDomain fGLDomain; |
185 typedef GrGLFragmentProcessor INHERITED; | 186 typedef GrGLFragmentProcessor INHERITED; |
186 }; | 187 }; |
187 | 188 |
188 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrProcessor&) { | 189 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrProcessor&) { |
189 } | 190 } |
190 | 191 |
191 void GrGLTextureDomainEffect::emitCode(EmitArgs& args) { | 192 void GrGLTextureDomainEffect::emitCode(EmitArgs& args) { |
192 const GrTextureDomainEffect& textureDomainEffect = args.fFp.cast<GrTextureDo
mainEffect>(); | 193 const GrTextureDomainEffect& textureDomainEffect = args.fFp.cast<GrTextureDo
mainEffect>(); |
193 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); | 194 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); |
194 | 195 |
195 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder(); | 196 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder(); |
196 SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0); | 197 SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0); |
197 fGLDomain.sampleTexture(fsBuilder, domain, args.fOutputColor, coords2D, args
.fSamplers[0], | 198 fGLDomain.sampleTexture(fsBuilder, domain, args.fOutputColor, coords2D, args
.fSamplers[0], |
198 args.fInputColor); | 199 args.fInputColor); |
199 } | 200 } |
200 | 201 |
201 void GrGLTextureDomainEffect::setData(const GrGLProgramDataManager& pdman, | 202 void GrGLTextureDomainEffect::onSetData(const GrGLProgramDataManager& pdman, |
202 const GrProcessor& processor) { | 203 const GrProcessor& processor) { |
203 const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureD
omainEffect>(); | 204 const GrTextureDomainEffect& textureDomainEffect = processor.cast<GrTextureD
omainEffect>(); |
204 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); | 205 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); |
205 fGLDomain.setData(pdman, domain, processor.texture(0)->origin()); | 206 fGLDomain.setData(pdman, domain, processor.texture(0)->origin()); |
206 } | 207 } |
207 | 208 |
208 void GrGLTextureDomainEffect::GenKey(const GrProcessor& processor, const GrGLSLC
aps&, | 209 void GrGLTextureDomainEffect::GenKey(const GrProcessor& processor, const GrGLSLC
aps&, |
209 GrProcessorKeyBuilder* b) { | 210 GrProcessorKeyBuilder* b) { |
210 const GrTextureDomain& domain = processor.cast<GrTextureDomainEffect>().text
ureDomain(); | 211 const GrTextureDomain& domain = processor.cast<GrTextureDomainEffect>().text
ureDomain(); |
211 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); | 212 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 254 |
254 GrTextureDomainEffect::~GrTextureDomainEffect() { | 255 GrTextureDomainEffect::~GrTextureDomainEffect() { |
255 | 256 |
256 } | 257 } |
257 | 258 |
258 void GrTextureDomainEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 259 void GrTextureDomainEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
259 GrProcessorKeyBuilder* b) const { | 260 GrProcessorKeyBuilder* b) const { |
260 GrGLTextureDomainEffect::GenKey(*this, caps, b); | 261 GrGLTextureDomainEffect::GenKey(*this, caps, b); |
261 } | 262 } |
262 | 263 |
263 GrGLFragmentProcessor* GrTextureDomainEffect::createGLInstance() const { | 264 GrGLFragmentProcessor* GrTextureDomainEffect::onCreateGLInstance() const { |
264 return SkNEW_ARGS(GrGLTextureDomainEffect, (*this)); | 265 return SkNEW_ARGS(GrGLTextureDomainEffect, (*this)); |
265 } | 266 } |
266 | 267 |
267 bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 268 bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
268 const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>(); | 269 const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>(); |
269 return this->fTextureDomain == s.fTextureDomain; | 270 return this->fTextureDomain == s.fTextureDomain; |
270 } | 271 } |
271 | 272 |
272 void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { | 273 void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { |
273 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper | 274 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper |
(...skipping 25 matching lines...) Expand all Loading... |
299 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; | 300 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; |
300 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; | 301 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; |
301 return GrTextureDomainEffect::Create(d->fProcDataManager, | 302 return GrTextureDomainEffect::Create(d->fProcDataManager, |
302 d->fTextures[texIdx], | 303 d->fTextures[texIdx], |
303 matrix, | 304 matrix, |
304 domain, | 305 domain, |
305 mode, | 306 mode, |
306 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, | 307 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, |
307 coords); | 308 coords); |
308 } | 309 } |
OLD | NEW |