| 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 "GrSimpleTextureEffect.h" | 9 #include "GrSimpleTextureEffect.h" |
| 10 #include "GrTBackendEffectFactory.h" | 10 #include "GrTBackendEffectFactory.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 GrGLEffect::EffectKey GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEf
fect, | 190 GrGLEffect::EffectKey GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEf
fect, |
| 191 const GrGLCaps&) { | 191 const GrGLCaps&) { |
| 192 const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect>
().textureDomain(); | 192 const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect>
().textureDomain(); |
| 193 return GrTextureDomain::GLDomain::DomainKey(domain); | 193 return GrTextureDomain::GLDomain::DomainKey(domain); |
| 194 } | 194 } |
| 195 | 195 |
| 196 | 196 |
| 197 /////////////////////////////////////////////////////////////////////////////// | 197 /////////////////////////////////////////////////////////////////////////////// |
| 198 | 198 |
| 199 GrEffectRef* GrTextureDomainEffect::Create(GrTexture* texture, | 199 GrEffect* GrTextureDomainEffect::Create(GrTexture* texture, |
| 200 const SkMatrix& matrix, | 200 const SkMatrix& matrix, |
| 201 const SkRect& domain, | 201 const SkRect& domain, |
| 202 GrTextureDomain::Mode mode, | 202 GrTextureDomain::Mode mode, |
| 203 GrTextureParams::FilterMode filterMod
e, | 203 GrTextureParams::FilterMode filterMod
e, |
| 204 GrCoordSet coordSet) { | 204 GrCoordSet coordSet) { |
| 205 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 205 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; |
| 206 if (GrTextureDomain::kIgnore_Mode == mode || | 206 if (GrTextureDomain::kIgnore_Mode == mode || |
| 207 (GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) { | 207 (GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) { |
| 208 return GrSimpleTextureEffect::Create(texture, matrix, filterMode); | 208 return GrSimpleTextureEffect::Create(texture, matrix, filterMode); |
| 209 } else { | 209 } else { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 *validFlags = 0; | 246 *validFlags = 0; |
| 247 } else { | 247 } else { |
| 248 this->updateConstantColorComponentsForModulation(color, validFlags); | 248 this->updateConstantColorComponentsForModulation(color, validFlags); |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 /////////////////////////////////////////////////////////////////////////////// | 252 /////////////////////////////////////////////////////////////////////////////// |
| 253 | 253 |
| 254 GR_DEFINE_EFFECT_TEST(GrTextureDomainEffect); | 254 GR_DEFINE_EFFECT_TEST(GrTextureDomainEffect); |
| 255 | 255 |
| 256 GrEffectRef* GrTextureDomainEffect::TestCreate(SkRandom* random, | 256 GrEffect* GrTextureDomainEffect::TestCreate(SkRandom* random, |
| 257 GrContext*, | 257 GrContext*, |
| 258 const GrDrawTargetCaps&, | 258 const GrDrawTargetCaps&, |
| 259 GrTexture* textures[]) { | 259 GrTexture* textures[]) { |
| 260 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : | 260 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
| 261 GrEffectUnitTest::kAlphaTextureIdx; | 261 GrEffectUnitTest::kAlphaTextureIdx; |
| 262 SkRect domain; | 262 SkRect domain; |
| 263 domain.fLeft = random->nextUScalar1(); | 263 domain.fLeft = random->nextUScalar1(); |
| 264 domain.fRight = random->nextRangeScalar(domain.fLeft, SK_Scalar1); | 264 domain.fRight = random->nextRangeScalar(domain.fLeft, SK_Scalar1); |
| 265 domain.fTop = random->nextUScalar1(); | 265 domain.fTop = random->nextUScalar1(); |
| 266 domain.fBottom = random->nextRangeScalar(domain.fTop, SK_Scalar1); | 266 domain.fBottom = random->nextRangeScalar(domain.fTop, SK_Scalar1); |
| 267 GrTextureDomain::Mode mode = | 267 GrTextureDomain::Mode mode = |
| 268 (GrTextureDomain::Mode) random->nextULessThan(GrTextureDomain::kModeCoun
t); | 268 (GrTextureDomain::Mode) random->nextULessThan(GrTextureDomain::kModeCoun
t); |
| 269 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); | 269 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); |
| 270 bool bilerp = random->nextBool(); | 270 bool bilerp = random->nextBool(); |
| 271 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo
rdSet; | 271 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo
rdSet; |
| 272 return GrTextureDomainEffect::Create(textures[texIdx], | 272 return GrTextureDomainEffect::Create(textures[texIdx], |
| 273 matrix, | 273 matrix, |
| 274 domain, | 274 domain, |
| 275 mode, | 275 mode, |
| 276 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, | 276 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, |
| 277 coords); | 277 coords); |
| 278 } | 278 } |
| OLD | NEW |