| 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 GrFragmentProcessor* GrTextureDomainEffect::Create(GrTexture* texture, | 221 GrFragmentProcessor* GrTextureDomainEffect::Create(GrProcessorDataManager* procD
ataManager, |
| 222 GrTexture* texture, |
| 222 const SkMatrix& matrix, | 223 const SkMatrix& matrix, |
| 223 const SkRect& domain, | 224 const SkRect& domain, |
| 224 GrTextureDomain::Mode mode, | 225 GrTextureDomain::Mode mode, |
| 225 GrTextureParams::FilterMode f
ilterMode, | 226 GrTextureParams::FilterMode f
ilterMode, |
| 226 GrCoordSet coordSet) { | 227 GrCoordSet coordSet) { |
| 227 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 228 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; |
| 228 if (GrTextureDomain::kIgnore_Mode == mode || | 229 if (GrTextureDomain::kIgnore_Mode == mode || |
| 229 (GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) { | 230 (GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) { |
| 230 return GrSimpleTextureEffect::Create(texture, matrix, filterMode); | 231 return GrSimpleTextureEffect::Create(procDataManager, texture, matrix, f
ilterMode); |
| 231 } else { | 232 } else { |
| 232 | 233 |
| 233 return SkNEW_ARGS(GrTextureDomainEffect, (texture, | 234 return SkNEW_ARGS(GrTextureDomainEffect, (procDataManager, |
| 235 texture, |
| 234 matrix, | 236 matrix, |
| 235 domain, | 237 domain, |
| 236 mode, | 238 mode, |
| 237 filterMode, | 239 filterMode, |
| 238 coordSet)); | 240 coordSet)); |
| 239 } | 241 } |
| 240 } | 242 } |
| 241 | 243 |
| 242 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, | 244 GrTextureDomainEffect::GrTextureDomainEffect(GrProcessorDataManager* procDataMan
ager, |
| 245 GrTexture* texture, |
| 243 const SkMatrix& matrix, | 246 const SkMatrix& matrix, |
| 244 const SkRect& domain, | 247 const SkRect& domain, |
| 245 GrTextureDomain::Mode mode, | 248 GrTextureDomain::Mode mode, |
| 246 GrTextureParams::FilterMode filterM
ode, | 249 GrTextureParams::FilterMode filterM
ode, |
| 247 GrCoordSet coordSet) | 250 GrCoordSet coordSet) |
| 248 : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) | 251 : GrSingleTextureEffect(procDataManager, texture, matrix, filterMode, coordS
et) |
| 249 , fTextureDomain(domain, mode) { | 252 , fTextureDomain(domain, mode) { |
| 250 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || | 253 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || |
| 251 filterMode == GrTextureParams::kNone_FilterMode); | 254 filterMode == GrTextureParams::kNone_FilterMode); |
| 252 this->initClassID<GrTextureDomainEffect>(); | 255 this->initClassID<GrTextureDomainEffect>(); |
| 253 } | 256 } |
| 254 | 257 |
| 255 GrTextureDomainEffect::~GrTextureDomainEffect() { | 258 GrTextureDomainEffect::~GrTextureDomainEffect() { |
| 256 | 259 |
| 257 } | 260 } |
| 258 | 261 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 SkRect domain; | 295 SkRect domain; |
| 293 domain.fLeft = d->fRandom->nextUScalar1(); | 296 domain.fLeft = d->fRandom->nextUScalar1(); |
| 294 domain.fRight = d->fRandom->nextRangeScalar(domain.fLeft, SK_Scalar1); | 297 domain.fRight = d->fRandom->nextRangeScalar(domain.fLeft, SK_Scalar1); |
| 295 domain.fTop = d->fRandom->nextUScalar1(); | 298 domain.fTop = d->fRandom->nextUScalar1(); |
| 296 domain.fBottom = d->fRandom->nextRangeScalar(domain.fTop, SK_Scalar1); | 299 domain.fBottom = d->fRandom->nextRangeScalar(domain.fTop, SK_Scalar1); |
| 297 GrTextureDomain::Mode mode = | 300 GrTextureDomain::Mode mode = |
| 298 (GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kMode
Count); | 301 (GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kMode
Count); |
| 299 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); | 302 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); |
| 300 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; | 303 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; |
| 301 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; | 304 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; |
| 302 return GrTextureDomainEffect::Create(d->fTextures[texIdx], | 305 return GrTextureDomainEffect::Create(d->fProcDataManager, |
| 306 d->fTextures[texIdx], |
| 303 matrix, | 307 matrix, |
| 304 domain, | 308 domain, |
| 305 mode, | 309 mode, |
| 306 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, | 310 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, |
| 307 coords); | 311 coords); |
| 308 } | 312 } |
| OLD | NEW |