| 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 "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
| 9 #include "GrTextureDomain.h" | 9 #include "GrTextureDomain.h" |
| 10 #include "GrInvariantOutput.h" |
| 10 #include "GrSimpleTextureEffect.h" | 11 #include "GrSimpleTextureEffect.h" |
| 11 #include "GrTBackendProcessorFactory.h" | 12 #include "GrTBackendProcessorFactory.h" |
| 12 #include "gl/GrGLProcessor.h" | 13 #include "gl/GrGLProcessor.h" |
| 13 #include "SkFloatingPoint.h" | 14 #include "SkFloatingPoint.h" |
| 14 | 15 |
| 15 | 16 |
| 16 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) | 17 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) |
| 17 : fIndex(index) { | 18 : fIndex(index) { |
| 18 | 19 |
| 19 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; | 20 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 262 |
| 262 const GrBackendFragmentProcessorFactory& GrTextureDomainEffect::getFactory() con
st { | 263 const GrBackendFragmentProcessorFactory& GrTextureDomainEffect::getFactory() con
st { |
| 263 return GrTBackendFragmentProcessorFactory<GrTextureDomainEffect>::getInstanc
e(); | 264 return GrTBackendFragmentProcessorFactory<GrTextureDomainEffect>::getInstanc
e(); |
| 264 } | 265 } |
| 265 | 266 |
| 266 bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 267 bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
| 267 const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>(); | 268 const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>(); |
| 268 return this->fTextureDomain == s.fTextureDomain; | 269 return this->fTextureDomain == s.fTextureDomain; |
| 269 } | 270 } |
| 270 | 271 |
| 271 void GrTextureDomainEffect::onComputeInvariantOutput(InvariantOutput* inout) con
st { | 272 void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c
onst { |
| 272 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper | 273 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper |
| 273 inout->mulByUnknownColor(); | 274 inout->mulByUnknownColor(); |
| 274 } else { | 275 } else { |
| 275 this->updateInvariantOutputForModulation(inout); | 276 this->updateInvariantOutputForModulation(inout); |
| 276 } | 277 } |
| 277 } | 278 } |
| 278 | 279 |
| 279 /////////////////////////////////////////////////////////////////////////////// | 280 /////////////////////////////////////////////////////////////////////////////// |
| 280 | 281 |
| 281 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect); | 282 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 296 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random); | 297 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random); |
| 297 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f
alse; | 298 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f
alse; |
| 298 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo
rdSet; | 299 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo
rdSet; |
| 299 return GrTextureDomainEffect::Create(textures[texIdx], | 300 return GrTextureDomainEffect::Create(textures[texIdx], |
| 300 matrix, | 301 matrix, |
| 301 domain, | 302 domain, |
| 302 mode, | 303 mode, |
| 303 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, | 304 bilerp ? GrTextureParams::kBilerp_Filte
rMode : GrTextureParams::kNone_FilterMode, |
| 304 coords); | 305 coords); |
| 305 } | 306 } |
| OLD | NEW |