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 sk_sp<GrFragmentProcessor> GrTextureDomainEffect::Make(GrTexture* texture, | 221 sk_sp<GrFragmentProcessor> GrTextureDomainEffect::Make(GrTexture* texture, |
| 222 sk_sp<GrColorSpaceXform>
colorSpaceXform, |
222 const SkMatrix& matrix, | 223 const SkMatrix& matrix, |
223 const SkRect& domain, | 224 const SkRect& domain, |
224 GrTextureDomain::Mode mod
e, | 225 GrTextureDomain::Mode mod
e, |
225 GrTextureParams::FilterMo
de filterMode, | 226 GrTextureParams::FilterMo
de filterMode, |
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::Make(texture, matrix, filterMode); | 231 return GrSimpleTextureEffect::Make(texture, std::move(colorSpaceXform),
matrix, filterMode); |
231 } else { | 232 } else { |
232 return sk_sp<GrFragmentProcessor>( | 233 return sk_sp<GrFragmentProcessor>( |
233 new GrTextureDomainEffect(texture, matrix, domain, mode, filterMode,
coordSet)); | 234 new GrTextureDomainEffect(texture, std::move(colorSpaceXform), matri
x, domain, mode, |
| 235 filterMode, coordSet)); |
234 } | 236 } |
235 } | 237 } |
236 | 238 |
237 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, | 239 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, |
| 240 sk_sp<GrColorSpaceXform> colorSpace
Xform, |
238 const SkMatrix& matrix, | 241 const SkMatrix& matrix, |
239 const SkRect& domain, | 242 const SkRect& domain, |
240 GrTextureDomain::Mode mode, | 243 GrTextureDomain::Mode mode, |
241 GrTextureParams::FilterMode filterM
ode, | 244 GrTextureParams::FilterMode filterM
ode, |
242 GrCoordSet coordSet) | 245 GrCoordSet coordSet) |
243 : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) | 246 : GrSingleTextureEffect(texture, std::move(colorSpaceXform), matrix, filterM
ode, coordSet) |
244 , fTextureDomain(domain, mode) { | 247 , fTextureDomain(domain, mode) { |
245 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || | 248 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || |
246 filterMode == GrTextureParams::kNone_FilterMode); | 249 filterMode == GrTextureParams::kNone_FilterMode); |
247 this->initClassID<GrTextureDomainEffect>(); | 250 this->initClassID<GrTextureDomainEffect>(); |
248 } | 251 } |
249 | 252 |
250 GrTextureDomainEffect::~GrTextureDomainEffect() {} | 253 GrTextureDomainEffect::~GrTextureDomainEffect() {} |
251 | 254 |
252 void GrTextureDomainEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 255 void GrTextureDomainEffect::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
253 GrProcessorKeyBuilder* b) cons
t { | 256 GrProcessorKeyBuilder* b) cons
t { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 domain.fRight = d->fRandom->nextRangeScalar(domain.fLeft, SK_Scalar1); | 290 domain.fRight = d->fRandom->nextRangeScalar(domain.fLeft, SK_Scalar1); |
288 domain.fTop = d->fRandom->nextUScalar1(); | 291 domain.fTop = d->fRandom->nextUScalar1(); |
289 domain.fBottom = d->fRandom->nextRangeScalar(domain.fTop, SK_Scalar1); | 292 domain.fBottom = d->fRandom->nextRangeScalar(domain.fTop, SK_Scalar1); |
290 GrTextureDomain::Mode mode = | 293 GrTextureDomain::Mode mode = |
291 (GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kMode
Count); | 294 (GrTextureDomain::Mode) d->fRandom->nextULessThan(GrTextureDomain::kMode
Count); |
292 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); | 295 const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom); |
293 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; | 296 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; |
294 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; | 297 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; |
295 return GrTextureDomainEffect::Make( | 298 return GrTextureDomainEffect::Make( |
296 d->fTextures[texIdx], | 299 d->fTextures[texIdx], |
| 300 nullptr, |
297 matrix, | 301 matrix, |
298 domain, | 302 domain, |
299 mode, | 303 mode, |
300 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
lterMode, | 304 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi
lterMode, |
301 coords); | 305 coords); |
302 } | 306 } |
OLD | NEW |