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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 GrGLDisplacementMapEffect(const GrProcessor&); | 305 GrGLDisplacementMapEffect(const GrProcessor&); |
306 virtual ~GrGLDisplacementMapEffect(); | 306 virtual ~GrGLDisplacementMapEffect(); |
307 | 307 |
308 virtual void emitCode(GrGLFPBuilder*, | 308 virtual void emitCode(GrGLFPBuilder*, |
309 const GrFragmentProcessor&, | 309 const GrFragmentProcessor&, |
310 const char* outputColor, | 310 const char* outputColor, |
311 const char* inputColor, | 311 const char* inputColor, |
312 const TransformedCoordsArray&, | 312 const TransformedCoordsArray&, |
313 const TextureSamplerArray&) override; | 313 const TextureSamplerArray&) override; |
314 | 314 |
315 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 315 static inline void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessor
KeyBuilder*); |
316 | 316 |
317 void setData(const GrGLProgramDataManager&, const GrProcessor&) override; | 317 void setData(const GrGLProgramDataManager&, const GrProcessor&) override; |
318 const GrTextureDomain::GLDomain& glDomain() const { return fGLDomain; } | 318 const GrTextureDomain::GLDomain& glDomain() const { return fGLDomain; } |
319 | 319 |
320 private: | 320 private: |
321 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; | 321 SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector; |
322 SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector; | 322 SkDisplacementMapEffect::ChannelSelectorType fYChannelSelector; |
323 GrGLProgramDataManager::UniformHandle fScaleUni; | 323 GrGLProgramDataManager::UniformHandle fScaleUni; |
324 GrTextureDomain::GLDomain fGLDomain; | 324 GrTextureDomain::GLDomain fGLDomain; |
325 | 325 |
(...skipping 13 matching lines...) Expand all Loading... |
339 yChannelSelector, | 339 yChannelSelector, |
340 scale, | 340 scale, |
341 displacement, | 341 displacement, |
342 offsetMatrix, | 342 offsetMatrix, |
343 color, | 343 color, |
344 colorDimensions)); | 344 colorDimensions)); |
345 } | 345 } |
346 | 346 |
347 virtual ~GrDisplacementMapEffect(); | 347 virtual ~GrDisplacementMapEffect(); |
348 | 348 |
349 virtual void getGLProcessorKey(const GrGLCaps& caps, | 349 virtual void getGLProcessorKey(const GrGLSLCaps& caps, |
350 GrProcessorKeyBuilder* b) const override { | 350 GrProcessorKeyBuilder* b) const override { |
351 GrGLDisplacementMapEffect::GenKey(*this, caps, b); | 351 GrGLDisplacementMapEffect::GenKey(*this, caps, b); |
352 } | 352 } |
353 | 353 |
354 GrGLFragmentProcessor* createGLInstance() const override { | 354 GrGLFragmentProcessor* createGLInstance() const override { |
355 return SkNEW_ARGS(GrGLDisplacementMapEffect, (*this)); | 355 return SkNEW_ARGS(GrGLDisplacementMapEffect, (*this)); |
356 } | 356 } |
357 | 357 |
358 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const | 358 SkDisplacementMapEffect::ChannelSelectorType xChannelSelector() const |
359 { return fXChannelSelector; } | 359 { return fXChannelSelector; } |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 GrTexture* colorTex = displacementMap.texture(1); | 627 GrTexture* colorTex = displacementMap.texture(1); |
628 SkScalar scaleX = SkScalarDiv(displacementMap.scale().fX, SkIntToScalar(colo
rTex->width())); | 628 SkScalar scaleX = SkScalarDiv(displacementMap.scale().fX, SkIntToScalar(colo
rTex->width())); |
629 SkScalar scaleY = SkScalarDiv(displacementMap.scale().fY, SkIntToScalar(colo
rTex->height())); | 629 SkScalar scaleY = SkScalarDiv(displacementMap.scale().fY, SkIntToScalar(colo
rTex->height())); |
630 pdman.set2f(fScaleUni, SkScalarToFloat(scaleX), | 630 pdman.set2f(fScaleUni, SkScalarToFloat(scaleX), |
631 colorTex->origin() == kTopLeft_GrSurfaceOrigin ? | 631 colorTex->origin() == kTopLeft_GrSurfaceOrigin ? |
632 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); | 632 SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY)); |
633 fGLDomain.setData(pdman, displacementMap.domain(), colorTex->origin()); | 633 fGLDomain.setData(pdman, displacementMap.domain(), colorTex->origin()); |
634 } | 634 } |
635 | 635 |
636 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, | 636 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, |
637 const GrGLCaps&, GrProcessorKeyBuilder* b
) { | 637 const GrGLSLCaps&, GrProcessorKeyBuilder*
b) { |
638 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); | 638 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap
Effect>(); |
639 | 639 |
640 uint32_t xKey = displacementMap.xChannelSelector(); | 640 uint32_t xKey = displacementMap.xChannelSelector(); |
641 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; | 641 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit
s; |
642 | 642 |
643 b->add32(xKey | yKey); | 643 b->add32(xKey | yKey); |
644 } | 644 } |
645 #endif | 645 #endif |
646 | 646 |
OLD | NEW |