| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector; | 293 SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector; |
| 294 GrGLUniformManager::UniformHandle fScaleUni; | 294 GrGLUniformManager::UniformHandle fScaleUni; |
| 295 | 295 |
| 296 typedef GrGLEffect INHERITED; | 296 typedef GrGLEffect INHERITED; |
| 297 }; | 297 }; |
| 298 | 298 |
| 299 /////////////////////////////////////////////////////////////////////////////// | 299 /////////////////////////////////////////////////////////////////////////////// |
| 300 | 300 |
| 301 class GrDisplacementMapEffect : public GrEffect { | 301 class GrDisplacementMapEffect : public GrEffect { |
| 302 public: | 302 public: |
| 303 static GrEffectRef* Create(SkDisplacementMapEffect::ChannelSelectorType xCha
nnelSelector, | 303 static GrEffect* Create(SkDisplacementMapEffect::ChannelSelectorType xChanne
lSelector, |
| 304 SkDisplacementMapEffect::ChannelSelectorType yCha
nnelSelector, | 304 SkDisplacementMapEffect::ChannelSelectorType yChanne
lSelector, |
| 305 SkVector scale, | 305 SkVector scale, |
| 306 GrTexture* displacement, const SkMatrix& offsetMa
trix, | 306 GrTexture* displacement, const SkMatrix& offsetMatri
x, |
| 307 GrTexture* color) { | 307 GrTexture* color) { |
| 308 return SkNEW_ARGS(GrDisplacementMapEffect, (xChannelSelector, | 308 return SkNEW_ARGS(GrDisplacementMapEffect, (xChannelSelector, |
| 309 yChannelSelector, | 309 yChannelSelector, |
| 310 scale, | 310 scale, |
| 311 displacement, | 311 displacement, |
| 312 offsetMatrix, | 312 offsetMatrix, |
| 313 color)); | 313 color)); |
| 314 } | 314 } |
| 315 | 315 |
| 316 virtual ~GrDisplacementMapEffect(); | 316 virtual ~GrDisplacementMapEffect(); |
| 317 | 317 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 // and no displacement offset push any texture coordinates out of bounds OR
if the constant | 469 // and no displacement offset push any texture coordinates out of bounds OR
if the constant |
| 470 // alpha is 0. Since this isn't trivial to compute at this point, let's assu
me the output is | 470 // alpha is 0. Since this isn't trivial to compute at this point, let's assu
me the output is |
| 471 // not of constant color when a displacement effect is applied. | 471 // not of constant color when a displacement effect is applied. |
| 472 *validFlags = 0; | 472 *validFlags = 0; |
| 473 } | 473 } |
| 474 | 474 |
| 475 /////////////////////////////////////////////////////////////////////////////// | 475 /////////////////////////////////////////////////////////////////////////////// |
| 476 | 476 |
| 477 GR_DEFINE_EFFECT_TEST(GrDisplacementMapEffect); | 477 GR_DEFINE_EFFECT_TEST(GrDisplacementMapEffect); |
| 478 | 478 |
| 479 GrEffectRef* GrDisplacementMapEffect::TestCreate(SkRandom* random, | 479 GrEffect* GrDisplacementMapEffect::TestCreate(SkRandom* random, |
| 480 GrContext*, | 480 GrContext*, |
| 481 const GrDrawTargetCaps&, | 481 const GrDrawTargetCaps&, |
| 482 GrTexture* textures[]) { | 482 GrTexture* textures[]) { |
| 483 int texIdxDispl = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : | 483 int texIdxDispl = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
| 484 GrEffectUnitTest::kAlphaTextureIdx; | 484 GrEffectUnitTest::kAlphaTextureIdx; |
| 485 int texIdxColor = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : | 485 int texIdxColor = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : |
| 486 GrEffectUnitTest::kAlphaTextureIdx; | 486 GrEffectUnitTest::kAlphaTextureIdx; |
| 487 static const int kMaxComponent = 4; | 487 static const int kMaxComponent = 4; |
| 488 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector = | 488 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector = |
| 489 static_cast<SkDisplacementMapEffect::ChannelSelectorType>( | 489 static_cast<SkDisplacementMapEffect::ChannelSelectorType>( |
| 490 random->nextRangeU(1, kMaxComponent)); | 490 random->nextRangeU(1, kMaxComponent)); |
| 491 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector = | 491 SkDisplacementMapEffect::ChannelSelectorType yChannelSelector = |
| 492 static_cast<SkDisplacementMapEffect::ChannelSelectorType>( | 492 static_cast<SkDisplacementMapEffect::ChannelSelectorType>( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 const GrGLCaps&) { | 604 const GrGLCaps&) { |
| 605 const GrDisplacementMapEffect& displacementMap = | 605 const GrDisplacementMapEffect& displacementMap = |
| 606 drawEffect.castEffect<GrDisplacementMapEffect>(); | 606 drawEffect.castEffect<GrDisplacementMapEffect>(); |
| 607 | 607 |
| 608 EffectKey xKey = displacementMap.xChannelSelector(); | 608 EffectKey xKey = displacementMap.xChannelSelector(); |
| 609 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi
ts; | 609 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi
ts; |
| 610 | 610 |
| 611 return xKey | yKey; | 611 return xKey | yKey; |
| 612 } | 612 } |
| 613 #endif | 613 #endif |
| OLD | NEW |