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 |
354 private: | 356 private: |
355 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; | 357 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; |
356 | 358 |
357 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; | |
358 | |
359 GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChanne
lSelector, | 359 GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChanne
lSelector, |
360 SkDisplacementMapEffect::ChannelSelectorType yChanne
lSelector, | 360 SkDisplacementMapEffect::ChannelSelectorType yChanne
lSelector, |
361 const SkVector& scale, | 361 const SkVector& scale, |
362 GrTexture* displacement, const SkMatrix& offsetMatri
x, | 362 GrTexture* displacement, const SkMatrix& offsetMatri
x, |
363 GrTexture* color); | 363 GrTexture* color); |
364 | 364 |
365 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 365 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
366 | 366 |
367 GrCoordTransform fDisplacementTransform; | 367 GrCoordTransform fDisplacementTransform; |
368 GrTextureAccess fDisplacementAccess; | 368 GrTextureAccess fDisplacementAccess; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 fColorAccess.getTexture() == s.fColorAccess.getTexture() && | 484 fColorAccess.getTexture() == s.fColorAccess.getTexture() && |
485 fXChannelSelector == s.fXChannelSelector && | 485 fXChannelSelector == s.fXChannelSelector && |
486 fYChannelSelector == s.fYChannelSelector && | 486 fYChannelSelector == s.fYChannelSelector && |
487 fScale == s.fScale; | 487 fScale == s.fScale; |
488 } | 488 } |
489 | 489 |
490 const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() c
onst { | 490 const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() c
onst { |
491 return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInsta
nce(); | 491 return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInsta
nce(); |
492 } | 492 } |
493 | 493 |
494 void GrDisplacementMapEffect::onComputeInvariantOutput(InvariantOutput* inout) c
onst { | 494 void GrDisplacementMapEffect::getConstantColorComponents(GrColor*, |
| 495 uint32_t* validFlags) c
onst { |
495 // Any displacement offset bringing a pixel out of bounds will output a colo
r of (0,0,0,0), | 496 // Any displacement offset bringing a pixel out of bounds will output a colo
r of (0,0,0,0), |
496 // so the only way we'd get a constant alpha is if the input color image has
a constant alpha | 497 // so the only way we'd get a constant alpha is if the input color image has
a constant alpha |
497 // and no displacement offset push any texture coordinates out of bounds OR
if the constant | 498 // and no displacement offset push any texture coordinates out of bounds OR
if the constant |
498 // alpha is 0. Since this isn't trivial to compute at this point, let's assu
me the output is | 499 // alpha is 0. Since this isn't trivial to compute at this point, let's assu
me the output is |
499 // not of constant color when a displacement effect is applied. | 500 // not of constant color when a displacement effect is applied. |
500 inout->fValidFlags = 0; | 501 *validFlags = 0; |
501 inout->fIsSingleComponent = false; | |
502 } | 502 } |
503 | 503 |
504 /////////////////////////////////////////////////////////////////////////////// | 504 /////////////////////////////////////////////////////////////////////////////// |
505 | 505 |
506 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect); | 506 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect); |
507 | 507 |
508 GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(SkRandom* random, | 508 GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(SkRandom* random, |
509 GrContext*, | 509 GrContext*, |
510 const GrDrawTargetCaps&, | 510 const GrDrawTargetCaps&, |
511 GrTexture* textures[]) { | 511 GrTexture* textures[]) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 632 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
633 const GrGLCaps&, GrProcessorKeyBuilder* b
) { | 633 const GrGLCaps&, GrProcessorKeyBuilder* b
) { |
634 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 634 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
635 | 635 |
636 uint32_t xKey = displacementMap.xChannelSelector(); | 636 uint32_t xKey = displacementMap.xChannelSelector(); |
637 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 637 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
638 | 638 |
639 b->add32(xKey | yKey); | 639 b->add32(xKey | yKey); |
640 } | 640 } |
641 #endif | 641 #endif |
OLD | NEW |