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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 void GrGLTextureDomainEffect::GenKey(const GrProcessor& processor, const GrGLSLC
aps&, | 209 void GrGLTextureDomainEffect::GenKey(const GrProcessor& processor, const GrGLSLC
aps&, |
210 GrProcessorKeyBuilder* b) { | 210 GrProcessorKeyBuilder* b) { |
211 const GrTextureDomain& domain = processor.cast<GrTextureDomainEffect>().text
ureDomain(); | 211 const GrTextureDomain& domain = processor.cast<GrTextureDomainEffect>().text
ureDomain(); |
212 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); | 212 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); |
213 } | 213 } |
214 | 214 |
215 | 215 |
216 /////////////////////////////////////////////////////////////////////////////// | 216 /////////////////////////////////////////////////////////////////////////////// |
217 | 217 |
218 GrFragmentProcessor* GrTextureDomainEffect::Create(GrProcessorDataManager* procD
ataManager, | 218 GrFragmentProcessor* GrTextureDomainEffect::Create(GrTexture* texture, |
219 GrTexture* texture, | |
220 const SkMatrix& matrix, | 219 const SkMatrix& matrix, |
221 const SkRect& domain, | 220 const SkRect& domain, |
222 GrTextureDomain::Mode mode, | 221 GrTextureDomain::Mode mode, |
223 GrTextureParams::FilterMode f
ilterMode, | 222 GrTextureParams::FilterMode f
ilterMode, |
224 GrCoordSet coordSet) { | 223 GrCoordSet coordSet) { |
225 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 224 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; |
226 if (GrTextureDomain::kIgnore_Mode == mode || | 225 if (GrTextureDomain::kIgnore_Mode == mode || |
227 (GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) { | 226 (GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) { |
228 return GrSimpleTextureEffect::Create(procDataManager, texture, matrix, f
ilterMode); | 227 return GrSimpleTextureEffect::Create(texture, matrix, filterMode); |
229 } else { | 228 } else { |
230 return new GrTextureDomainEffect(procDataManager, texture, matrix, domai
n, mode, filterMode, | 229 return new GrTextureDomainEffect(texture, matrix, domain, mode, filterMo
de, coordSet); |
231 coordSet); | |
232 } | 230 } |
233 } | 231 } |
234 | 232 |
235 GrTextureDomainEffect::GrTextureDomainEffect(GrProcessorDataManager* procDataMan
ager, | 233 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, |
236 GrTexture* texture, | |
237 const SkMatrix& matrix, | 234 const SkMatrix& matrix, |
238 const SkRect& domain, | 235 const SkRect& domain, |
239 GrTextureDomain::Mode mode, | 236 GrTextureDomain::Mode mode, |
240 GrTextureParams::FilterMode filterM
ode, | 237 GrTextureParams::FilterMode filterM
ode, |
241 GrCoordSet coordSet) | 238 GrCoordSet coordSet) |
242 : GrSingleTextureEffect(procDataManager, texture, matrix, filterMode, coordS
et) | 239 : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) |
243 , fTextureDomain(domain, mode) { | 240 , fTextureDomain(domain, mode) { |
244 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || | 241 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || |
245 filterMode == GrTextureParams::kNone_FilterMode); | 242 filterMode == GrTextureParams::kNone_FilterMode); |
246 this->initClassID<GrTextureDomainEffect>(); | 243 this->initClassID<GrTextureDomainEffect>(); |
247 } | 244 } |
248 | 245 |
249 GrTextureDomainEffect::~GrTextureDomainEffect() { | 246 GrTextureDomainEffect::~GrTextureDomainEffect() { |
250 | 247 |
251 } | 248 } |
252 | 249 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 SkRect domain; | 283 SkRect domain; |
287 domain.fLeft = d->fRandom->nextUScalar1(); | 284 domain.fLeft = d->fRandom->nextUScalar1(); |
288 domain.fRight = d->fRandom->nextRangeScalar(domain.fLeft, SK_Scalar1); | 285 domain.fRight = d->fRandom->nextRangeScalar(domain.fLeft, SK_Scalar1); |
289 domain.fTop = d->fRandom->nextUScalar1(); | 286 domain.fTop = d->fRandom->nextUScalar1(); |
290 domain.fBottom = d->fRandom->nextRangeScalar(domain.fTop, SK_Scalar1); | 287 domain.fBottom = d->fRandom->nextRangeScalar(domain.fTop, SK_Scalar1); |
291 GrTextureDomain::Mode mode = | 288 GrTextureDomain::Mode mode = |
292 (GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kMode
Count); | 289 (GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kMode
Count); |
293 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); | 290 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); |
294 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; | 291 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; |
295 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; | 292 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; |
296 return GrTextureDomainEffect::Create(d->fProcDataManager, | 293 return GrTextureDomainEffect::Create(d->fTextures[texIdx], |
297 d->fTextures[texIdx], | |
298 matrix, | 294 matrix, |
299 domain, | 295 domain, |
300 mode, | 296 mode, |
301 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, | 297 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, |
302 coords); | 298 coords); |
303 } | 299 } |
OLD | NEW |