| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 211 | 211 | 
| 212 void GrGLTextureDomainEffect::GenKey(const GrProcessor& processor, const GrGLSLC
     aps&, | 212 void GrGLTextureDomainEffect::GenKey(const GrProcessor& processor, const GrGLSLC
     aps&, | 
| 213                                      GrProcessorKeyBuilder* b) { | 213                                      GrProcessorKeyBuilder* b) { | 
| 214     const GrTextureDomain& domain = processor.cast<GrTextureDomainEffect>().text
     ureDomain(); | 214     const GrTextureDomain& domain = processor.cast<GrTextureDomainEffect>().text
     ureDomain(); | 
| 215     b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); | 215     b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); | 
| 216 } | 216 } | 
| 217 | 217 | 
| 218 | 218 | 
| 219 /////////////////////////////////////////////////////////////////////////////// | 219 /////////////////////////////////////////////////////////////////////////////// | 
| 220 | 220 | 
| 221 const GrFragmentProcessor* GrTextureDomainEffect::Create(GrTexture* texture, | 221 sk_sp<GrFragmentProcessor> GrTextureDomainEffect::Make(GrTexture* texture, | 
| 222                                                          const SkMatrix& matrix, | 222                                                        const SkMatrix& matrix, | 
| 223                                                          const SkRect& domain, | 223                                                        const SkRect& domain, | 
| 224                                                          GrTextureDomain::Mode m
     ode, | 224                                                        GrTextureDomain::Mode mod
     e, | 
| 225                                                          GrTextureParams::Filter
     Mode filterMode, | 225                                                        GrTextureParams::FilterMo
     de filterMode, | 
| 226                                                          GrCoordSet coordSet) { | 226                                                        GrCoordSet coordSet) { | 
| 227     static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 227     static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 
| 228     if (GrTextureDomain::kIgnore_Mode == mode || | 228     if (GrTextureDomain::kIgnore_Mode == mode || | 
| 229         (GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) { | 229         (GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) { | 
| 230         return GrSimpleTextureEffect::Create(texture, matrix, filterMode); | 230         return GrSimpleTextureEffect::Make(texture, matrix, filterMode); | 
| 231     } else { | 231     } else { | 
| 232         return new GrTextureDomainEffect(texture, matrix, domain, mode, filterMo
     de, coordSet); | 232         return sk_sp<GrFragmentProcessor>( | 
|  | 233             new GrTextureDomainEffect(texture, matrix, domain, mode, filterMode,
      coordSet)); | 
| 233     } | 234     } | 
| 234 } | 235 } | 
| 235 | 236 | 
| 236 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, | 237 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, | 
| 237                                              const SkMatrix& matrix, | 238                                              const SkMatrix& matrix, | 
| 238                                              const SkRect& domain, | 239                                              const SkRect& domain, | 
| 239                                              GrTextureDomain::Mode mode, | 240                                              GrTextureDomain::Mode mode, | 
| 240                                              GrTextureParams::FilterMode filterM
     ode, | 241                                              GrTextureParams::FilterMode filterM
     ode, | 
| 241                                              GrCoordSet coordSet) | 242                                              GrCoordSet coordSet) | 
| 242     : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) | 243     : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 271         } | 272         } | 
| 272     } else { | 273     } else { | 
| 273         this->updateInvariantOutputForModulation(inout); | 274         this->updateInvariantOutputForModulation(inout); | 
| 274     } | 275     } | 
| 275 } | 276 } | 
| 276 | 277 | 
| 277 /////////////////////////////////////////////////////////////////////////////// | 278 /////////////////////////////////////////////////////////////////////////////// | 
| 278 | 279 | 
| 279 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect); | 280 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect); | 
| 280 | 281 | 
| 281 const GrFragmentProcessor* GrTextureDomainEffect::TestCreate(GrProcessorTestData
     * d) { | 282 sk_sp<GrFragmentProcessor> GrTextureDomainEffect::TestCreate(GrProcessorTestData
     * d) { | 
| 282     int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
      : | 283     int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
      : | 
| 283                                           GrProcessorUnitTest::kAlphaTextureIdx; | 284                                           GrProcessorUnitTest::kAlphaTextureIdx; | 
| 284     SkRect domain; | 285     SkRect domain; | 
| 285     domain.fLeft = d->fRandom->nextUScalar1(); | 286     domain.fLeft = d->fRandom->nextUScalar1(); | 
| 286     domain.fRight = d->fRandom->nextRangeScalar(domain.fLeft, SK_Scalar1); | 287     domain.fRight = d->fRandom->nextRangeScalar(domain.fLeft, SK_Scalar1); | 
| 287     domain.fTop = d->fRandom->nextUScalar1(); | 288     domain.fTop = d->fRandom->nextUScalar1(); | 
| 288     domain.fBottom = d->fRandom->nextRangeScalar(domain.fTop, SK_Scalar1); | 289     domain.fBottom = d->fRandom->nextRangeScalar(domain.fTop, SK_Scalar1); | 
| 289     GrTextureDomain::Mode mode = | 290     GrTextureDomain::Mode mode = | 
| 290         (GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kMode
     Count); | 291         (GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kMode
     Count); | 
| 291     const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); | 292     const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); | 
| 292     bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
      : false; | 293     bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
      : false; | 
| 293     GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
     oordSet; | 294     GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
     oordSet; | 
| 294     return GrTextureDomainEffect::Create( | 295     return GrTextureDomainEffect::Make( | 
| 295         d->fTextures[texIdx], | 296         d->fTextures[texIdx], | 
| 296         matrix, | 297         matrix, | 
| 297         domain, | 298         domain, | 
| 298         mode, | 299         mode, | 
| 299         bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
     lterMode, | 300         bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
     lterMode, | 
| 300         coords); | 301         coords); | 
| 301 } | 302 } | 
| OLD | NEW | 
|---|