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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 const SkMatrix& matrix, | 220 const SkMatrix& matrix, |
221 const SkRect& domain, | 221 const SkRect& domain, |
222 GrTextureDomain::Mode mode, | 222 GrTextureDomain::Mode mode, |
223 GrTextureParams::FilterMode f
ilterMode, | 223 GrTextureParams::FilterMode f
ilterMode, |
224 GrCoordSet coordSet) { | 224 GrCoordSet coordSet) { |
225 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 225 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; |
226 if (GrTextureDomain::kIgnore_Mode == mode || | 226 if (GrTextureDomain::kIgnore_Mode == mode || |
227 (GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) { | 227 (GrTextureDomain::kClamp_Mode == mode && domain.contains(kFullRect))) { |
228 return GrSimpleTextureEffect::Create(procDataManager, texture, matrix, f
ilterMode); | 228 return GrSimpleTextureEffect::Create(procDataManager, texture, matrix, f
ilterMode); |
229 } else { | 229 } else { |
230 | 230 return new GrTextureDomainEffect(procDataManager, texture, matrix, domai
n, mode, filterMode, |
231 return SkNEW_ARGS(GrTextureDomainEffect, (procDataManager, | 231 coordSet); |
232 texture, | |
233 matrix, | |
234 domain, | |
235 mode, | |
236 filterMode, | |
237 coordSet)); | |
238 } | 232 } |
239 } | 233 } |
240 | 234 |
241 GrTextureDomainEffect::GrTextureDomainEffect(GrProcessorDataManager* procDataMan
ager, | 235 GrTextureDomainEffect::GrTextureDomainEffect(GrProcessorDataManager* procDataMan
ager, |
242 GrTexture* texture, | 236 GrTexture* texture, |
243 const SkMatrix& matrix, | 237 const SkMatrix& matrix, |
244 const SkRect& domain, | 238 const SkRect& domain, |
245 GrTextureDomain::Mode mode, | 239 GrTextureDomain::Mode mode, |
246 GrTextureParams::FilterMode filterM
ode, | 240 GrTextureParams::FilterMode filterM
ode, |
247 GrCoordSet coordSet) | 241 GrCoordSet coordSet) |
248 : GrSingleTextureEffect(procDataManager, texture, matrix, filterMode, coordS
et) | 242 : GrSingleTextureEffect(procDataManager, texture, matrix, filterMode, coordS
et) |
249 , fTextureDomain(domain, mode) { | 243 , fTextureDomain(domain, mode) { |
250 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || | 244 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || |
251 filterMode == GrTextureParams::kNone_FilterMode); | 245 filterMode == GrTextureParams::kNone_FilterMode); |
252 this->initClassID<GrTextureDomainEffect>(); | 246 this->initClassID<GrTextureDomainEffect>(); |
253 } | 247 } |
254 | 248 |
255 GrTextureDomainEffect::~GrTextureDomainEffect() { | 249 GrTextureDomainEffect::~GrTextureDomainEffect() { |
256 | 250 |
257 } | 251 } |
258 | 252 |
259 void GrTextureDomainEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 253 void GrTextureDomainEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
260 GrProcessorKeyBuilder* b) const { | 254 GrProcessorKeyBuilder* b) const { |
261 GrGLTextureDomainEffect::GenKey(*this, caps, b); | 255 GrGLTextureDomainEffect::GenKey(*this, caps, b); |
262 } | 256 } |
263 | 257 |
264 GrGLFragmentProcessor* GrTextureDomainEffect::onCreateGLInstance() const { | 258 GrGLFragmentProcessor* GrTextureDomainEffect::onCreateGLInstance() const { |
265 return SkNEW_ARGS(GrGLTextureDomainEffect, (*this)); | 259 return new GrGLTextureDomainEffect(*this); |
266 } | 260 } |
267 | 261 |
268 bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 262 bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
269 const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>(); | 263 const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>(); |
270 return this->fTextureDomain == s.fTextureDomain; | 264 return this->fTextureDomain == s.fTextureDomain; |
271 } | 265 } |
272 | 266 |
273 void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { | 267 void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { |
274 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper | 268 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper |
275 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) { | 269 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) { |
(...skipping 24 matching lines...) Expand all Loading... |
300 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; | 294 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool()
: false; |
301 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; | 295 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC
oordSet; |
302 return GrTextureDomainEffect::Create(d->fProcDataManager, | 296 return GrTextureDomainEffect::Create(d->fProcDataManager, |
303 d->fTextures[texIdx], | 297 d->fTextures[texIdx], |
304 matrix, | 298 matrix, |
305 domain, | 299 domain, |
306 mode, | 300 mode, |
307 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, | 301 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, |
308 coords); | 302 coords); |
309 } | 303 } |
OLD | NEW |