| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkDisplacementMapEffect.h" | 8 #include "SkDisplacementMapEffect.h" |
| 9 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
| 10 #include "SkWriteBuffer.h" | 10 #include "SkWriteBuffer.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 344 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; |
| 345 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const | 345 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const |
| 346 { return fXChannelSelector; } | 346 { return fXChannelSelector; } |
| 347 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector() const | 347 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector() const |
| 348 { return fYChannelSelector; } | 348 { return fYChannelSelector; } |
| 349 const SkVector& scale() const { return fScale; } | 349 const SkVector& scale() const { return fScale; } |
| 350 | 350 |
| 351 typedef GrGLDisplacementMapEffect GLProcessor; | 351 typedef GrGLDisplacementMapEffect GLProcessor; |
| 352 static const char* Name() { return "DisplacementMap"; } | 352 static const char* Name() { return "DisplacementMap"; } |
| 353 | 353 |
| 354 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | |
| 355 | |
| 356 private: | 354 private: |
| 357 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; | 355 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; |
| 358 | 356 |
| 357 virtual void onGetConstantColorComponents(GrColor* color, uint32_t* validFla
gs, |
| 358 bool* isSingleComponent) const SK_
OVERRIDE; |
| 359 |
| 359 GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChanne
lSelector, | 360 GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChanne
lSelector, |
| 360 SkDisplacementMapEffect::ChannelSelectorType yChanne
lSelector, | 361 SkDisplacementMapEffect::ChannelSelectorType yChanne
lSelector, |
| 361 const SkVector& scale, | 362 const SkVector& scale, |
| 362 GrTexture* displacement, const SkMatrix& offsetMatri
x, | 363 GrTexture* displacement, const SkMatrix& offsetMatri
x, |
| 363 GrTexture* color); | 364 GrTexture* color); |
| 364 | 365 |
| 365 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 366 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 366 | 367 |
| 367 GrCoordTransform fDisplacementTransform; | 368 GrCoordTransform fDisplacementTransform; |
| 368 GrTextureAccess fDisplacementAccess; | 369 GrTextureAccess fDisplacementAccess; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 fColorAccess.getTexture() == s.fColorAccess.getTexture() && | 485 fColorAccess.getTexture() == s.fColorAccess.getTexture() && |
| 485 fXChannelSelector == s.fXChannelSelector && | 486 fXChannelSelector == s.fXChannelSelector && |
| 486 fYChannelSelector == s.fYChannelSelector && | 487 fYChannelSelector == s.fYChannelSelector && |
| 487 fScale == s.fScale; | 488 fScale == s.fScale; |
| 488 } | 489 } |
| 489 | 490 |
| 490 const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() c
onst { | 491 const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() c
onst { |
| 491 return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInsta
nce(); | 492 return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInsta
nce(); |
| 492 } | 493 } |
| 493 | 494 |
| 494 void GrDisplacementMapEffect::getConstantColorComponents(GrColor*, | 495 void GrDisplacementMapEffect::onGetConstantColorComponents(GrColor*, uint32_t* v
alidFlags, |
| 495 uint32_t* validFlags) c
onst { | 496 bool* isSingleCompone
nt) const { |
| 496 // Any displacement offset bringing a pixel out of bounds will output a colo
r of (0,0,0,0), | 497 // Any displacement offset bringing a pixel out of bounds will output a colo
r of (0,0,0,0), |
| 497 // so the only way we'd get a constant alpha is if the input color image has
a constant alpha | 498 // so the only way we'd get a constant alpha is if the input color image has
a constant alpha |
| 498 // and no displacement offset push any texture coordinates out of bounds OR
if the constant | 499 // and no displacement offset push any texture coordinates out of bounds OR
if the constant |
| 499 // alpha is 0. Since this isn't trivial to compute at this point, let's assu
me the output is | 500 // alpha is 0. Since this isn't trivial to compute at this point, let's assu
me the output is |
| 500 // not of constant color when a displacement effect is applied. | 501 // not of constant color when a displacement effect is applied. |
| 501 *validFlags = 0; | 502 *validFlags = 0; |
| 502 } | 503 } |
| 503 | 504 |
| 504 /////////////////////////////////////////////////////////////////////////////// | 505 /////////////////////////////////////////////////////////////////////////////// |
| 505 | 506 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 633 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
| 633 const GrGLCaps&, GrProcessorKeyBuilder* b
) { | 634 const GrGLCaps&, GrProcessorKeyBuilder* b
) { |
| 634 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 635 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
| 635 | 636 |
| 636 uint32_t xKey = displacementMap.xChannelSelector(); | 637 uint32_t xKey = displacementMap.xChannelSelector(); |
| 637 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 638 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
| 638 | 639 |
| 639 b->add32(xKey | yKey); | 640 b->add32(xKey | yKey); |
| 640 } | 641 } |
| 641 #endif | 642 #endif |
| OLD | NEW |