| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 #if SK_SUPPORT_GPU | 272 #if SK_SUPPORT_GPU |
| 273 class GrGLDisplacementMapEffect : public GrGLEffect { | 273 class GrGLDisplacementMapEffect : public GrGLEffect { |
| 274 public: | 274 public: |
| 275 GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory, | 275 GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory, |
| 276 const GrDrawEffect& drawEffect); | 276 const GrDrawEffect& drawEffect); |
| 277 virtual ~GrGLDisplacementMapEffect(); | 277 virtual ~GrGLDisplacementMapEffect(); |
| 278 | 278 |
| 279 virtual void emitCode(GrGLShaderBuilder*, | 279 virtual void emitCode(GrGLShaderBuilder*, |
| 280 const GrDrawEffect&, | 280 const GrDrawEffect&, |
| 281 EffectKey, | 281 const GrEffectKey&, |
| 282 const char* outputColor, | 282 const char* outputColor, |
| 283 const char* inputColor, | 283 const char* inputColor, |
| 284 const TransformedCoordsArray&, | 284 const TransformedCoordsArray&, |
| 285 const TextureSamplerArray&) SK_OVERRIDE; | 285 const TextureSamplerArray&) SK_OVERRIDE; |
| 286 | 286 |
| 287 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&); | 287 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB
uilder*); |
| 288 | 288 |
| 289 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 289 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; |
| 290 | 290 |
| 291 private: | 291 private: |
| 292 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; | 292 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; |
| 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 }; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 : INHERITED(factory) | 506 : INHERITED(factory) |
| 507 , fXChannelSelector(drawEffect.castEffect<GrDisplacementMapEffect>().xChanne
lSelector()) | 507 , fXChannelSelector(drawEffect.castEffect<GrDisplacementMapEffect>().xChanne
lSelector()) |
| 508 , fYChannelSelector(drawEffect.castEffect<GrDisplacementMapEffect>().yChanne
lSelector()) { | 508 , fYChannelSelector(drawEffect.castEffect<GrDisplacementMapEffect>().yChanne
lSelector()) { |
| 509 } | 509 } |
| 510 | 510 |
| 511 GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() { | 511 GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() { |
| 512 } | 512 } |
| 513 | 513 |
| 514 void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder, | 514 void GrGLDisplacementMapEffect::emitCode(GrGLShaderBuilder* builder, |
| 515 const GrDrawEffect&, | 515 const GrDrawEffect&, |
| 516 EffectKey key, | 516 const GrEffectKey& key, |
| 517 const char* outputColor, | 517 const char* outputColor, |
| 518 const char* inputColor, | 518 const char* inputColor, |
| 519 const TransformedCoordsArray& coords, | 519 const TransformedCoordsArray& coords, |
| 520 const TextureSamplerArray& samplers) { | 520 const TextureSamplerArray& samplers) { |
| 521 sk_ignore_unused_variable(inputColor); | 521 sk_ignore_unused_variable(inputColor); |
| 522 | 522 |
| 523 fScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, | 523 fScaleUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, |
| 524 kVec2f_GrSLType, "Scale"); | 524 kVec2f_GrSLType, "Scale"); |
| 525 const char* scaleUni = builder->getUniformCStr(fScaleUni); | 525 const char* scaleUni = builder->getUniformCStr(fScaleUni); |
| 526 const char* dColor = "dColor"; | 526 const char* dColor = "dColor"; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 const GrDisplacementMapEffect& displacementMap = | 593 const GrDisplacementMapEffect& displacementMap = |
| 594 drawEffect.castEffect<GrDisplacementMapEffect>(); | 594 drawEffect.castEffect<GrDisplacementMapEffect>(); |
| 595 GrTexture* colorTex = displacementMap.texture(1); | 595 GrTexture* colorTex = displacementMap.texture(1); |
| 596 SkScalar scaleX = SkScalarDiv(displacementMap.scale().fX, SkIntToScalar(colo
rTex->width())); | 596 SkScalar scaleX = SkScalarDiv(displacementMap.scale().fX, SkIntToScalar(colo
rTex->width())); |
| 597 SkScalar scaleY = SkScalarDiv(displacementMap.scale().fY, SkIntToScalar(colo
rTex->height())); | 597 SkScalar scaleY = SkScalarDiv(displacementMap.scale().fY, SkIntToScalar(colo
rTex->height())); |
| 598 uman.set2f(fScaleUni, SkScalarToFloat(scaleX), | 598 uman.set2f(fScaleUni, SkScalarToFloat(scaleX), |
| 599 colorTex->origin() == kTopLeft_GrSurfaceOrigin ? | 599 colorTex->origin() == kTopLeft_GrSurfaceOrigin ? |
| 600 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); | 600 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); |
| 601 } | 601 } |
| 602 | 602 |
| 603 GrGLEffect::EffectKey GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& draw
Effect, | 603 void GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& drawEffect, |
| 604 const GrGLCaps&) { | 604 const GrGLCaps&, GrEffectKeyBuilder* b) { |
| 605 const GrDisplacementMapEffect& displacementMap = | 605 const GrDisplacementMapEffect& displacementMap = |
| 606 drawEffect.castEffect<GrDisplacementMapEffect>(); | 606 drawEffect.castEffect<GrDisplacementMapEffect>(); |
| 607 | 607 |
| 608 EffectKey xKey = displacementMap.xChannelSelector(); | 608 uint32_t xKey = displacementMap.xChannelSelector(); |
| 609 EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBi
ts; | 609 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
| 610 | 610 |
| 611 return xKey | yKey; | 611 b->add32(xKey | yKey); |
| 612 } | 612 } |
| 613 #endif | 613 #endif |
| OLD | NEW |