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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 const GrFragmentProcessor* GrTextureDomainEffect::Create(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 mode, |
225 GrTextureParams::Filter
Mode filterMode, | 225 GrTextureParams::FilterMode f
ilterMode, |
226 GrCoordSet coordSet) { | 226 GrCoordSet coordSet, GrRender
Target* dst) { |
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::Create(texture, matrix, filterMode, kLocal
_GrCoordSet, dst); |
231 } else { | 231 } else { |
232 return new GrTextureDomainEffect(texture, matrix, domain, mode, filterMo
de, coordSet); | 232 return new GrTextureDomainEffect(texture, matrix, domain, mode, filterMo
de, coordSet, dst); |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, | 236 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, |
237 const SkMatrix& matrix, | 237 const SkMatrix& matrix, |
238 const SkRect& domain, | 238 const SkRect& domain, |
239 GrTextureDomain::Mode mode, | 239 GrTextureDomain::Mode mode, |
240 GrTextureParams::FilterMode filterM
ode, | 240 GrTextureParams::FilterMode filterM
ode, |
241 GrCoordSet coordSet) | 241 GrCoordSet coordSet, |
242 : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) | 242 GrRenderTarget* dst) |
| 243 : GrSingleTextureEffect(texture, matrix, filterMode, coordSet, dst) |
243 , fTextureDomain(domain, mode) { | 244 , fTextureDomain(domain, mode) { |
244 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || | 245 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || |
245 filterMode == GrTextureParams::kNone_FilterMode); | 246 filterMode == GrTextureParams::kNone_FilterMode); |
246 this->initClassID<GrTextureDomainEffect>(); | 247 this->initClassID<GrTextureDomainEffect>(); |
247 } | 248 } |
248 | 249 |
249 GrTextureDomainEffect::~GrTextureDomainEffect() {} | 250 GrTextureDomainEffect::~GrTextureDomainEffect() {} |
250 | 251 |
251 void GrTextureDomainEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 252 void GrTextureDomainEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
252 GrProcessorKeyBuilder* b) const
{ | 253 GrProcessorKeyBuilder* b) const
{ |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::Create(d->fTextures[texIdx], |
295 d->fTextures[texIdx], | 296 matrix, |
296 matrix, | 297 domain, |
297 domain, | 298 mode, |
298 mode, | 299 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, |
299 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
lterMode, | 300 coords, NULL); |
300 coords); | |
301 } | 301 } |
OLD | NEW |