| 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" | 
| 11 #include "SkFloatingPoint.h" | 11 #include "SkFloatingPoint.h" | 
| 12 #include "gl/GrGLContext.h" | 12 #include "glsl/GrGLSLFragmentProcessor.h" | 
| 13 #include "gl/GrGLFragmentProcessor.h" |  | 
| 14 #include "glsl/GrGLSLProgramBuilder.h" | 13 #include "glsl/GrGLSLProgramBuilder.h" | 
| 15 #include "glsl/GrGLSLProgramDataManager.h" | 14 #include "glsl/GrGLSLProgramDataManager.h" | 
| 16 #include "glsl/GrGLSLTextureSampler.h" | 15 #include "glsl/GrGLSLTextureSampler.h" | 
| 17 | 16 | 
| 18 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) | 17 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) | 
| 19     : fIndex(index) { | 18     : fIndex(index) { | 
| 20 | 19 | 
| 21     static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 20     static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 
| 22     if (domain.contains(kFullRect) && kClamp_Mode == mode) { | 21     if (domain.contains(kFullRect) && kClamp_Mode == mode) { | 
| 23         fMode = kIgnore_Mode; | 22         fMode = kIgnore_Mode; | 
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 166         if (0 != memcmp(values, fPrevDomain, kPrevDomainCount * sizeof(float))) 
     { | 165         if (0 != memcmp(values, fPrevDomain, kPrevDomainCount * sizeof(float))) 
     { | 
| 167             pdman.set4fv(fDomainUni, 1, values); | 166             pdman.set4fv(fDomainUni, 1, values); | 
| 168             memcpy(fPrevDomain, values, kPrevDomainCount * sizeof(float)); | 167             memcpy(fPrevDomain, values, kPrevDomainCount * sizeof(float)); | 
| 169         } | 168         } | 
| 170     } | 169     } | 
| 171 } | 170 } | 
| 172 | 171 | 
| 173 | 172 | 
| 174 ////////////////////////////////////////////////////////////////////////////// | 173 ////////////////////////////////////////////////////////////////////////////// | 
| 175 | 174 | 
| 176 class GrGLTextureDomainEffect : public GrGLFragmentProcessor { | 175 class GrGLTextureDomainEffect : public GrGLSLFragmentProcessor { | 
| 177 public: | 176 public: | 
| 178     GrGLTextureDomainEffect(const GrProcessor&); | 177     GrGLTextureDomainEffect(const GrProcessor&); | 
| 179 | 178 | 
| 180     virtual void emitCode(EmitArgs&) override; | 179     virtual void emitCode(EmitArgs&) override; | 
| 181 | 180 | 
| 182     static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor
     KeyBuilder*); | 181     static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor
     KeyBuilder*); | 
| 183 | 182 | 
| 184 protected: | 183 protected: | 
| 185     void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
     ; | 184     void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
     ; | 
| 186 | 185 | 
| 187 private: | 186 private: | 
| 188     GrTextureDomain::GLDomain         fGLDomain; | 187     GrTextureDomain::GLDomain         fGLDomain; | 
| 189     typedef GrGLFragmentProcessor INHERITED; | 188     typedef GrGLSLFragmentProcessor INHERITED; | 
| 190 }; | 189 }; | 
| 191 | 190 | 
| 192 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrProcessor&) { | 191 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrProcessor&) { | 
| 193 } | 192 } | 
| 194 | 193 | 
| 195 void GrGLTextureDomainEffect::emitCode(EmitArgs& args) { | 194 void GrGLTextureDomainEffect::emitCode(EmitArgs& args) { | 
| 196     const GrTextureDomainEffect& textureDomainEffect = args.fFp.cast<GrTextureDo
     mainEffect>(); | 195     const GrTextureDomainEffect& textureDomainEffect = args.fFp.cast<GrTextureDo
     mainEffect>(); | 
| 197     const GrTextureDomain& domain = textureDomainEffect.textureDomain(); | 196     const GrTextureDomain& domain = textureDomainEffect.textureDomain(); | 
| 198 | 197 | 
| 199     GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder()
     ; | 198     GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder()
     ; | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 246     this->initClassID<GrTextureDomainEffect>(); | 245     this->initClassID<GrTextureDomainEffect>(); | 
| 247 } | 246 } | 
| 248 | 247 | 
| 249 GrTextureDomainEffect::~GrTextureDomainEffect() {} | 248 GrTextureDomainEffect::~GrTextureDomainEffect() {} | 
| 250 | 249 | 
| 251 void GrTextureDomainEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 250 void GrTextureDomainEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 
| 252                                                 GrProcessorKeyBuilder* b) const 
     { | 251                                                 GrProcessorKeyBuilder* b) const 
     { | 
| 253     GrGLTextureDomainEffect::GenKey(*this, caps, b); | 252     GrGLTextureDomainEffect::GenKey(*this, caps, b); | 
| 254 } | 253 } | 
| 255 | 254 | 
| 256 GrGLFragmentProcessor* GrTextureDomainEffect::onCreateGLInstance() const  { | 255 GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLInstance() const  { | 
| 257     return new GrGLTextureDomainEffect(*this); | 256     return new GrGLTextureDomainEffect(*this); | 
| 258 } | 257 } | 
| 259 | 258 | 
| 260 bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 259 bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 
| 261     const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>(); | 260     const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>(); | 
| 262     return this->fTextureDomain == s.fTextureDomain; | 261     return this->fTextureDomain == s.fTextureDomain; | 
| 263 } | 262 } | 
| 264 | 263 | 
| 265 void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
     onst { | 264 void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
     onst { | 
| 266     if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper | 265     if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 292     bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
      : false; | 291     bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
      : false; | 
| 293     GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
     oordSet; | 292     GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
     oordSet; | 
| 294     return GrTextureDomainEffect::Create( | 293     return GrTextureDomainEffect::Create( | 
| 295         d->fTextures[texIdx], | 294         d->fTextures[texIdx], | 
| 296         matrix, | 295         matrix, | 
| 297         domain, | 296         domain, | 
| 298         mode, | 297         mode, | 
| 299         bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
     lterMode, | 298         bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
     lterMode, | 
| 300         coords); | 299         coords); | 
| 301 } | 300 } | 
| OLD | NEW | 
|---|