Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/effects/SkPerlinNoiseShader.cpp

Issue 336043002: Perlin noise cleanup. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove now-redundant fMatrix member. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkDither.h" 8 #include "SkDither.h"
9 #include "SkPerlinNoiseShader.h" 9 #include "SkPerlinNoiseShader.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 PaintingData(const SkISize& tileSize, SkScalar seed, 81 PaintingData(const SkISize& tileSize, SkScalar seed,
82 SkScalar baseFrequencyX, SkScalar baseFrequencyY) 82 SkScalar baseFrequencyX, SkScalar baseFrequencyY)
83 : fTileSize(tileSize) 83 : fTileSize(tileSize)
84 , fBaseFrequency(SkPoint::Make(baseFrequencyX, baseFrequencyY)) 84 , fBaseFrequency(SkPoint::Make(baseFrequencyX, baseFrequencyY))
85 { 85 {
86 this->init(seed); 86 this->init(seed);
87 if (!fTileSize.isEmpty()) { 87 if (!fTileSize.isEmpty()) {
88 this->stitch(); 88 this->stitch();
89 } 89 }
90 90
91 #if SK_SUPPORT_GPU && !defined(SK_USE_SIMPLEX_NOISE) 91 #if SK_SUPPORT_GPU
92 fPermutationsBitmap.setInfo(SkImageInfo::MakeA8(kBlockSize, 1)); 92 fPermutationsBitmap.setInfo(SkImageInfo::MakeA8(kBlockSize, 1));
93 fPermutationsBitmap.setPixels(fLatticeSelector); 93 fPermutationsBitmap.setPixels(fLatticeSelector);
94 94
95 fNoiseBitmap.setInfo(SkImageInfo::MakeN32Premul(kBlockSize, 4)); 95 fNoiseBitmap.setInfo(SkImageInfo::MakeN32Premul(kBlockSize, 4));
96 fNoiseBitmap.setPixels(fNoise[0][0]); 96 fNoiseBitmap.setPixels(fNoise[0][0]);
97 #endif 97 #endif
98 } 98 }
99 99
100 int fSeed; 100 int fSeed;
101 uint8_t fLatticeSelector[kBlockSize]; 101 uint8_t fLatticeSelector[kBlockSize];
102 uint16_t fNoise[4][kBlockSize][2]; 102 uint16_t fNoise[4][kBlockSize][2];
103 SkPoint fGradient[4][kBlockSize]; 103 SkPoint fGradient[4][kBlockSize];
104 SkISize fTileSize; 104 SkISize fTileSize;
105 SkVector fBaseFrequency; 105 SkVector fBaseFrequency;
106 StitchData fStitchDataInit; 106 StitchData fStitchDataInit;
107 107
108 private: 108 private:
109 109
110 #if SK_SUPPORT_GPU && !defined(SK_USE_SIMPLEX_NOISE) 110 #if SK_SUPPORT_GPU
111 SkBitmap fPermutationsBitmap; 111 SkBitmap fPermutationsBitmap;
112 SkBitmap fNoiseBitmap; 112 SkBitmap fNoiseBitmap;
113 #endif 113 #endif
114 114
115 inline int random() { 115 inline int random() {
116 static const int gRandAmplitude = 16807; // 7**5; primitive root of m 116 static const int gRandAmplitude = 16807; // 7**5; primitive root of m
117 static const int gRandQ = 127773; // m / a 117 static const int gRandQ = 127773; // m / a
118 static const int gRandR = 2836; // m % a 118 static const int gRandR = 2836; // m % a
119 119
120 int result = gRandAmplitude * (fSeed % gRandQ) - gRandR * (fSeed / gRand Q); 120 int result = gRandAmplitude * (fSeed % gRandQ) - gRandR * (fSeed / gRand Q);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 fStitchDataInit.fWidth = 232 fStitchDataInit.fWidth =
233 SkScalarRoundToInt(tileWidth * fBaseFrequency.fX); 233 SkScalarRoundToInt(tileWidth * fBaseFrequency.fX);
234 fStitchDataInit.fWrapX = kPerlinNoise + fStitchDataInit.fWidth; 234 fStitchDataInit.fWrapX = kPerlinNoise + fStitchDataInit.fWidth;
235 fStitchDataInit.fHeight = 235 fStitchDataInit.fHeight =
236 SkScalarRoundToInt(tileHeight * fBaseFrequency.fY); 236 SkScalarRoundToInt(tileHeight * fBaseFrequency.fY);
237 fStitchDataInit.fWrapY = kPerlinNoise + fStitchDataInit.fHeight; 237 fStitchDataInit.fWrapY = kPerlinNoise + fStitchDataInit.fHeight;
238 } 238 }
239 239
240 public: 240 public:
241 241
242 #if SK_SUPPORT_GPU && !defined(SK_USE_SIMPLEX_NOISE) 242 #if SK_SUPPORT_GPU
243 const SkBitmap& getPermutationsBitmap() const { return fPermutationsBitmap; } 243 const SkBitmap& getPermutationsBitmap() const { return fPermutationsBitmap; }
244 244
245 const SkBitmap& getNoiseBitmap() const { return fNoiseBitmap; } 245 const SkBitmap& getNoiseBitmap() const { return fNoiseBitmap; }
246 #endif 246 #endif
247 }; 247 };
248 248
249 SkShader* SkPerlinNoiseShader::CreateFractalNoise(SkScalar baseFrequencyX, SkSca lar baseFrequencyY, 249 SkShader* SkPerlinNoiseShader::CreateFractalNoise(SkScalar baseFrequencyX, SkSca lar baseFrequencyY,
250 int numOctaves, SkScalar seed, 250 int numOctaves, SkScalar seed,
251 const SkISize* tileSize) { 251 const SkISize* tileSize) {
252 return SkNEW_ARGS(SkPerlinNoiseShader, (kFractalNoise_Type, baseFrequencyX, baseFrequencyY, 252 return SkNEW_ARGS(SkPerlinNoiseShader, (kFractalNoise_Type, baseFrequencyX, baseFrequencyY,
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 point.fX += SK_Scalar1; 484 point.fX += SK_Scalar1;
485 } 485 }
486 } 486 }
487 487
488 ///////////////////////////////////////////////////////////////////// 488 /////////////////////////////////////////////////////////////////////
489 489
490 #if SK_SUPPORT_GPU 490 #if SK_SUPPORT_GPU
491 491
492 #include "GrTBackendEffectFactory.h" 492 #include "GrTBackendEffectFactory.h"
493 493
494 class GrGLNoise : public GrGLEffect { 494 class GrGLPerlinNoise : public GrGLEffect {
495 public:
496 GrGLNoise(const GrBackendEffectFactory& factory,
497 const GrDrawEffect& drawEffect);
498 virtual ~GrGLNoise() {}
499
500 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
501
502 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE;
503
504 protected:
505 SkPerlinNoiseShader::Type fType;
506 bool fStitchTiles;
507 int fNumOctaves;
508 GrGLUniformManager::UniformHandle fBaseFrequencyUni;
509 GrGLUniformManager::UniformHandle fAlphaUni;
510 GrGLUniformManager::UniformHandle fInvMatrixUni;
511
512 private:
513 typedef GrGLEffect INHERITED;
514 };
515
516 class GrGLPerlinNoise : public GrGLNoise {
517 public: 495 public:
518 GrGLPerlinNoise(const GrBackendEffectFactory& factory, 496 GrGLPerlinNoise(const GrBackendEffectFactory& factory,
519 const GrDrawEffect& drawEffect) 497 const GrDrawEffect& drawEffect);
520 : GrGLNoise(factory, drawEffect) {}
521 virtual ~GrGLPerlinNoise() {} 498 virtual ~GrGLPerlinNoise() {}
522 499
523 virtual void emitCode(GrGLShaderBuilder*, 500 virtual void emitCode(GrGLShaderBuilder*,
524 const GrDrawEffect&, 501 const GrDrawEffect&,
525 EffectKey, 502 EffectKey,
526 const char* outputColor, 503 const char* outputColor,
527 const char* inputColor, 504 const char* inputColor,
528 const TransformedCoordsArray&, 505 const TransformedCoordsArray&,
529 const TextureSamplerArray&) SK_OVERRIDE; 506 const TextureSamplerArray&) SK_OVERRIDE;
530 507
531 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE; 508 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE;
532 509
533 private: 510 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
534 GrGLUniformManager::UniformHandle fStitchDataUni;
535
536 typedef GrGLNoise INHERITED;
537 };
538
539 class GrGLSimplexNoise : public GrGLNoise {
540 // Note : This is for reference only. GrGLPerlinNoise is used for processing .
541 public:
542 GrGLSimplexNoise(const GrBackendEffectFactory& factory,
543 const GrDrawEffect& drawEffect)
544 : GrGLNoise(factory, drawEffect) {}
545
546 virtual ~GrGLSimplexNoise() {}
547
548 virtual void emitCode(GrGLShaderBuilder*,
549 const GrDrawEffect&,
550 EffectKey,
551 const char* outputColor,
552 const char* inputColor,
553 const TransformedCoordsArray&,
554 const TextureSamplerArray&) SK_OVERRIDE;
555
556 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE;
557 511
558 private: 512 private:
559 GrGLUniformManager::UniformHandle fSeedUni;
560 513
561 typedef GrGLNoise INHERITED; 514 GrGLUniformManager::UniformHandle fStitchDataUni;
515 SkPerlinNoiseShader::Type fType;
516 bool fStitchTiles;
517 int fNumOctaves;
518 GrGLUniformManager::UniformHandle fBaseFrequencyUni;
519 GrGLUniformManager::UniformHandle fAlphaUni;
520 GrGLUniformManager::UniformHandle fInvMatrixUni;
521
522 private:
523 typedef GrGLEffect INHERITED;
562 }; 524 };
563 525
564 ///////////////////////////////////////////////////////////////////// 526 /////////////////////////////////////////////////////////////////////
565 527
566 class GrNoiseEffect : public GrEffect { 528 class GrPerlinNoiseEffect : public GrEffect {
567 public:
568 virtual ~GrNoiseEffect() { }
569
570 SkPerlinNoiseShader::Type type() const { return fType; }
571 bool stitchTiles() const { return fStitchTiles; }
572 const SkVector& baseFrequency() const { return fBaseFrequency; }
573 int numOctaves() const { return fNumOctaves; }
574 const SkMatrix& matrix() const { return fCoordTransform.getMatrix(); }
575 uint8_t alpha() const { return fAlpha; }
576
577 void getConstantColorComponents(GrColor*, uint32_t* validFlags) const SK_OVE RRIDE {
578 *validFlags = 0; // This is noise. Nothing is constant.
579 }
580
581 protected:
582 virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
583 const GrNoiseEffect& s = CastEffect<GrNoiseEffect>(sBase);
584 return fType == s.fType &&
585 fBaseFrequency == s.fBaseFrequency &&
586 fNumOctaves == s.fNumOctaves &&
587 fStitchTiles == s.fStitchTiles &&
588 fCoordTransform.getMatrix() == s.fCoordTransform.getMatrix() &&
589 fAlpha == s.fAlpha;
590 }
591
592 GrNoiseEffect(SkPerlinNoiseShader::Type type, const SkVector& baseFrequency, int numOctaves,
593 bool stitchTiles, const SkMatrix& matrix, uint8_t alpha)
594 : fType(type)
595 , fBaseFrequency(baseFrequency)
596 , fNumOctaves(numOctaves)
597 , fStitchTiles(stitchTiles)
598 , fMatrix(matrix)
599 , fAlpha(alpha) {
600 // This (1,1) translation is due to WebKit's 1 based coordinates for the noise
601 // (as opposed to 0 based, usually). The same adjustment is in the shade Span() functions.
602 SkMatrix m = matrix;
603 m.postTranslate(SK_Scalar1, SK_Scalar1);
604 fCoordTransform.reset(kLocal_GrCoordSet, m);
605 this->addCoordTransform(&fCoordTransform);
606 this->setWillNotUseInputColor();
607 }
608
609 SkPerlinNoiseShader::Type fType;
610 GrCoordTransform fCoordTransform;
611 SkVector fBaseFrequency;
612 int fNumOctaves;
613 bool fStitchTiles;
614 SkMatrix fMatrix;
615 uint8_t fAlpha;
616
617 private:
618 typedef GrEffect INHERITED;
619 };
620
621 class GrPerlinNoiseEffect : public GrNoiseEffect {
622 public: 529 public:
623 static GrEffectRef* Create(SkPerlinNoiseShader::Type type, const SkVector& b aseFrequency, 530 static GrEffectRef* Create(SkPerlinNoiseShader::Type type, const SkVector& b aseFrequency,
624 int numOctaves, bool stitchTiles, 531 int numOctaves, bool stitchTiles,
625 const SkPerlinNoiseShader::StitchData& stitchData , 532 const SkPerlinNoiseShader::StitchData& stitchData ,
626 GrTexture* permutationsTexture, GrTexture* noiseT exture, 533 GrTexture* permutationsTexture, GrTexture* noiseT exture,
627 const SkMatrix& matrix, uint8_t alpha) { 534 const SkMatrix& matrix, uint8_t alpha) {
628 AutoEffectUnref effect(SkNEW_ARGS(GrPerlinNoiseEffect, (type, baseFreque ncy, numOctaves, 535 AutoEffectUnref effect(SkNEW_ARGS(GrPerlinNoiseEffect, (type, baseFreque ncy, numOctaves,
629 stitchTiles, stitchData, permutationsTexture, noiseTexture, matrix, alpha))); 536 stitchTiles, stitchData, permutationsTexture, noiseTexture, matrix, alpha)));
630 return CreateEffectRef(effect); 537 return CreateEffectRef(effect);
631 } 538 }
632 539
633 virtual ~GrPerlinNoiseEffect() { } 540 virtual ~GrPerlinNoiseEffect() { }
634 541
635 static const char* Name() { return "PerlinNoise"; } 542 static const char* Name() { return "PerlinNoise"; }
636 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { 543 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
637 return GrTBackendEffectFactory<GrPerlinNoiseEffect>::getInstance(); 544 return GrTBackendEffectFactory<GrPerlinNoiseEffect>::getInstance();
638 } 545 }
639 const SkPerlinNoiseShader::StitchData& stitchData() const { return fStitchDa ta; } 546 const SkPerlinNoiseShader::StitchData& stitchData() const { return fStitchDa ta; }
640 547
548 SkPerlinNoiseShader::Type type() const { return fType; }
549 bool stitchTiles() const { return fStitchTiles; }
550 const SkVector& baseFrequency() const { return fBaseFrequency; }
551 int numOctaves() const { return fNumOctaves; }
552 const SkMatrix& matrix() const { return fCoordTransform.getMatrix(); }
553 uint8_t alpha() const { return fAlpha; }
554
641 typedef GrGLPerlinNoise GLEffect; 555 typedef GrGLPerlinNoise GLEffect;
642 556
643 private: 557 private:
644 virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE { 558 virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
645 const GrPerlinNoiseEffect& s = CastEffect<GrPerlinNoiseEffect>(sBase); 559 const GrPerlinNoiseEffect& s = CastEffect<GrPerlinNoiseEffect>(sBase);
646 return INHERITED::onIsEqual(sBase) && 560 return fType == s.fType &&
561 fBaseFrequency == s.fBaseFrequency &&
562 fNumOctaves == s.fNumOctaves &&
563 fStitchTiles == s.fStitchTiles &&
564 fCoordTransform.getMatrix() == s.fCoordTransform.getMatrix() &&
565 fAlpha == s.fAlpha &&
647 fPermutationsAccess.getTexture() == s.fPermutationsAccess.getText ure() && 566 fPermutationsAccess.getTexture() == s.fPermutationsAccess.getText ure() &&
648 fNoiseAccess.getTexture() == s.fNoiseAccess.getTexture() && 567 fNoiseAccess.getTexture() == s.fNoiseAccess.getTexture() &&
649 fStitchData == s.fStitchData; 568 fStitchData == s.fStitchData;
650 } 569 }
651 570
652 GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type, const SkVector& baseFreq uency, 571 GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type, const SkVector& baseFreq uency,
653 int numOctaves, bool stitchTiles, 572 int numOctaves, bool stitchTiles,
654 const SkPerlinNoiseShader::StitchData& stitchData, 573 const SkPerlinNoiseShader::StitchData& stitchData,
655 GrTexture* permutationsTexture, GrTexture* noiseTexture, 574 GrTexture* permutationsTexture, GrTexture* noiseTexture,
656 const SkMatrix& matrix, uint8_t alpha) 575 const SkMatrix& matrix, uint8_t alpha)
657 : GrNoiseEffect(type, baseFrequency, numOctaves, stitchTiles, matrix, alph a) 576 : fType(type)
577 , fBaseFrequency(baseFrequency)
578 , fNumOctaves(numOctaves)
579 , fStitchTiles(stitchTiles)
580 , fAlpha(alpha)
658 , fPermutationsAccess(permutationsTexture) 581 , fPermutationsAccess(permutationsTexture)
659 , fNoiseAccess(noiseTexture) 582 , fNoiseAccess(noiseTexture)
660 , fStitchData(stitchData) { 583 , fStitchData(stitchData) {
661 this->addTextureAccess(&fPermutationsAccess); 584 this->addTextureAccess(&fPermutationsAccess);
662 this->addTextureAccess(&fNoiseAccess); 585 this->addTextureAccess(&fNoiseAccess);
586 SkMatrix m = matrix;
587 m.postTranslate(SK_Scalar1, SK_Scalar1);
588 fCoordTransform.reset(kLocal_GrCoordSet, m);
589 this->addCoordTransform(&fCoordTransform);
590 this->setWillNotUseInputColor();
663 } 591 }
664 592
665 GR_DECLARE_EFFECT_TEST; 593 GR_DECLARE_EFFECT_TEST;
666 594
595 SkPerlinNoiseShader::Type fType;
596 GrCoordTransform fCoordTransform;
597 SkVector fBaseFrequency;
598 int fNumOctaves;
599 bool fStitchTiles;
600 uint8_t fAlpha;
667 GrTextureAccess fPermutationsAccess; 601 GrTextureAccess fPermutationsAccess;
668 GrTextureAccess fNoiseAccess; 602 GrTextureAccess fNoiseAccess;
669 SkPerlinNoiseShader::StitchData fStitchData; 603 SkPerlinNoiseShader::StitchData fStitchData;
670 604
671 typedef GrNoiseEffect INHERITED; 605 void getConstantColorComponents(GrColor*, uint32_t* validFlags) const SK_OVE RRIDE {
672 }; 606 *validFlags = 0; // This is noise. Nothing is constant.
673
674 class GrSimplexNoiseEffect : public GrNoiseEffect {
675 // Note : This is for reference only. GrPerlinNoiseEffect is used for proces sing.
676 public:
677 static GrEffectRef* Create(SkPerlinNoiseShader::Type type, const SkVector& b aseFrequency,
678 int numOctaves, bool stitchTiles, const SkScalar seed,
679 const SkMatrix& matrix, uint8_t alpha) {
680 AutoEffectUnref effect(SkNEW_ARGS(GrSimplexNoiseEffect, (type, baseFrequ ency, numOctaves,
681 stitchTiles, seed, matrix, alpha)));
682 return CreateEffectRef(effect);
683 } 607 }
684 608
685 virtual ~GrSimplexNoiseEffect() { }
686
687 static const char* Name() { return "SimplexNoise"; }
688 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
689 return GrTBackendEffectFactory<GrSimplexNoiseEffect>::getInstance();
690 }
691 const SkScalar& seed() const { return fSeed; }
692
693 typedef GrGLSimplexNoise GLEffect;
694
695 private: 609 private:
696 virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE { 610 typedef GrEffect INHERITED;
697 const GrSimplexNoiseEffect& s = CastEffect<GrSimplexNoiseEffect>(sBase);
698 return INHERITED::onIsEqual(sBase) && fSeed == s.fSeed;
699 }
700
701 GrSimplexNoiseEffect(SkPerlinNoiseShader::Type type, const SkVector& baseFre quency,
702 int numOctaves, bool stitchTiles, const SkScalar seed,
703 const SkMatrix& matrix, uint8_t alpha)
704 : GrNoiseEffect(type, baseFrequency, numOctaves, stitchTiles, matrix, alph a)
705 , fSeed(seed) {
706 }
707
708 SkScalar fSeed;
709
710 typedef GrNoiseEffect INHERITED;
711 }; 611 };
712 612
713 ///////////////////////////////////////////////////////////////////// 613 /////////////////////////////////////////////////////////////////////
714 GR_DEFINE_EFFECT_TEST(GrPerlinNoiseEffect); 614 GR_DEFINE_EFFECT_TEST(GrPerlinNoiseEffect);
715 615
716 GrEffectRef* GrPerlinNoiseEffect::TestCreate(SkRandom* random, 616 GrEffectRef* GrPerlinNoiseEffect::TestCreate(SkRandom* random,
717 GrContext* context, 617 GrContext* context,
718 const GrDrawTargetCaps&, 618 const GrDrawTargetCaps&,
719 GrTexture**) { 619 GrTexture**) {
720 int numOctaves = random->nextRangeU(2, 10); 620 int numOctaves = random->nextRangeU(2, 10);
(...skipping 14 matching lines...) Expand all
735 SkPaint paint; 635 SkPaint paint;
736 GrColor grColor; 636 GrColor grColor;
737 GrEffectRef* effect; 637 GrEffectRef* effect;
738 shader->asNewEffect(context, paint, NULL, &grColor, &effect); 638 shader->asNewEffect(context, paint, NULL, &grColor, &effect);
739 639
740 SkDELETE(shader); 640 SkDELETE(shader);
741 641
742 return effect; 642 return effect;
743 } 643 }
744 644
745 ///////////////////////////////////////////////////////////////////// 645 GrGLPerlinNoise::GrGLPerlinNoise(const GrBackendEffectFactory& factory, const Gr DrawEffect& drawEffect)
746 646 : INHERITED (factory)
747 void GrGLSimplexNoise::emitCode(GrGLShaderBuilder* builder, 647 , fType(drawEffect.castEffect<GrPerlinNoiseEffect>().type())
748 const GrDrawEffect&, 648 , fStitchTiles(drawEffect.castEffect<GrPerlinNoiseEffect>().stitchTiles())
749 EffectKey key, 649 , fNumOctaves(drawEffect.castEffect<GrPerlinNoiseEffect>().numOctaves()) {
750 const char* outputColor,
751 const char* inputColor,
752 const TransformedCoordsArray& coords,
753 const TextureSamplerArray&) {
754 sk_ignore_unused_variable(inputColor);
755
756 SkString vCoords = builder->ensureFSCoords2D(coords, 0);
757
758 fSeedUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
759 kFloat_GrSLType, "seed");
760 const char* seedUni = builder->getUniformCStr(fSeedUni);
761 fInvMatrixUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
762 kMat33f_GrSLType, "invMatrix");
763 const char* invMatrixUni = builder->getUniformCStr(fInvMatrixUni);
764 fBaseFrequencyUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibil ity,
765 kVec2f_GrSLType, "baseFrequency");
766 const char* baseFrequencyUni = builder->getUniformCStr(fBaseFrequencyUni);
767 fAlphaUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
768 kFloat_GrSLType, "alpha");
769 const char* alphaUni = builder->getUniformCStr(fAlphaUni);
770
771 // Add vec3 modulo 289 function
772 static const GrGLShaderVar gVec3Args[] = {
773 GrGLShaderVar("x", kVec3f_GrSLType)
774 };
775
776 SkString mod289_3_funcName;
777 builder->fsEmitFunction(kVec3f_GrSLType,
778 "mod289", SK_ARRAY_COUNT(gVec3Args), gVec3Args,
779 "const vec2 C = vec2(1.0 / 289.0, 289.0);\n"
780 "return x - floor(x * C.xxx) * C.yyy;", &mod289_3_fu ncName);
781
782 // Add vec4 modulo 289 function
783 static const GrGLShaderVar gVec4Args[] = {
784 GrGLShaderVar("x", kVec4f_GrSLType)
785 };
786
787 SkString mod289_4_funcName;
788 builder->fsEmitFunction(kVec4f_GrSLType,
789 "mod289", SK_ARRAY_COUNT(gVec4Args), gVec4Args,
790 "const vec2 C = vec2(1.0 / 289.0, 289.0);\n"
791 "return x - floor(x * C.xxxx) * C.yyyy;", &mod289_4_ funcName);
792
793 // Add vec4 permute function
794 SkString permuteCode;
795 permuteCode.appendf("const vec2 C = vec2(34.0, 1.0);\n"
796 "return %s(((x * C.xxxx) + C.yyyy) * x);", mod289_4_func Name.c_str());
797 SkString permuteFuncName;
798 builder->fsEmitFunction(kVec4f_GrSLType,
799 "permute", SK_ARRAY_COUNT(gVec4Args), gVec4Args,
800 permuteCode.c_str(), &permuteFuncName);
801
802 // Add vec4 taylorInvSqrt function
803 SkString taylorInvSqrtFuncName;
804 builder->fsEmitFunction(kVec4f_GrSLType,
805 "taylorInvSqrt", SK_ARRAY_COUNT(gVec4Args), gVec4Arg s,
806 "const vec2 C = vec2(-0.85373472095314, 1.7928429140 0159);\n"
807 "return x * C.xxxx + C.yyyy;", &taylorInvSqrtFuncNam e);
808
809 // Add vec3 noise function
810 static const GrGLShaderVar gNoiseVec3Args[] = {
811 GrGLShaderVar("v", kVec3f_GrSLType)
812 };
813
814 SkString noiseCode;
815 noiseCode.append(
816 "const vec2 C = vec2(1.0/6.0, 1.0/3.0);\n"
817 "const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n"
818
819 // First corner
820 "vec3 i = floor(v + dot(v, C.yyy));\n"
821 "vec3 x0 = v - i + dot(i, C.xxx);\n"
822
823 // Other corners
824 "vec3 g = step(x0.yzx, x0.xyz);\n"
825 "vec3 l = 1.0 - g;\n"
826 "vec3 i1 = min(g.xyz, l.zxy);\n"
827 "vec3 i2 = max(g.xyz, l.zxy);\n"
828
829 "vec3 x1 = x0 - i1 + C.xxx;\n"
830 "vec3 x2 = x0 - i2 + C.yyy;\n" // 2.0*C.x = 1/3 = C.y
831 "vec3 x3 = x0 - D.yyy;\n" // -1.0+3.0*C.x = -0.5 = -D.y
832 );
833
834 noiseCode.appendf(
835 // Permutations
836 "i = %s(i);\n"
837 "vec4 p = %s(%s(%s(\n"
838 " i.z + vec4(0.0, i1.z, i2.z, 1.0)) +\n"
839 " i.y + vec4(0.0, i1.y, i2.y, 1.0)) +\n"
840 " i.x + vec4(0.0, i1.x, i2.x, 1.0));\n",
841 mod289_3_funcName.c_str(), permuteFuncName.c_str(), permuteFuncName.c_st r(),
842 permuteFuncName.c_str());
843
844 noiseCode.append(
845 // Gradients: 7x7 points over a square, mapped onto an octahedron.
846 // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
847 "float n_ = 0.142857142857;\n" // 1.0/7.0
848 "vec3 ns = n_ * D.wyz - D.xzx;\n"
849
850 "vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n" // mod(p,7*7)
851
852 "vec4 x_ = floor(j * ns.z);\n"
853 "vec4 y_ = floor(j - 7.0 * x_);" // mod(j,N)
854
855 "vec4 x = x_ *ns.x + ns.yyyy;\n"
856 "vec4 y = y_ *ns.x + ns.yyyy;\n"
857 "vec4 h = 1.0 - abs(x) - abs(y);\n"
858
859 "vec4 b0 = vec4(x.xy, y.xy);\n"
860 "vec4 b1 = vec4(x.zw, y.zw);\n"
861 );
862
863 noiseCode.append(
864 "vec4 s0 = floor(b0) * 2.0 + 1.0;\n"
865 "vec4 s1 = floor(b1) * 2.0 + 1.0;\n"
866 "vec4 sh = -step(h, vec4(0.0));\n"
867
868 "vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n"
869 "vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n"
870
871 "vec3 p0 = vec3(a0.xy, h.x);\n"
872 "vec3 p1 = vec3(a0.zw, h.y);\n"
873 "vec3 p2 = vec3(a1.xy, h.z);\n"
874 "vec3 p3 = vec3(a1.zw, h.w);\n"
875 );
876
877 noiseCode.appendf(
878 // Normalise gradients
879 "vec4 norm = %s(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\ n"
880 "p0 *= norm.x;\n"
881 "p1 *= norm.y;\n"
882 "p2 *= norm.z;\n"
883 "p3 *= norm.w;\n"
884
885 // Mix final noise value
886 "vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)) , 0.0);\n"
887 "m = m * m;\n"
888 "return 42.0 * dot(m*m, vec4(dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3, x3)));",
889 taylorInvSqrtFuncName.c_str());
890
891 SkString noiseFuncName;
892 builder->fsEmitFunction(kFloat_GrSLType,
893 "snoise", SK_ARRAY_COUNT(gNoiseVec3Args), gNoiseVec3 Args,
894 noiseCode.c_str(), &noiseFuncName);
895
896 const char* noiseVecIni = "noiseVecIni";
897 const char* factors = "factors";
898 const char* sum = "sum";
899 const char* xOffsets = "xOffsets";
900 const char* yOffsets = "yOffsets";
901 const char* channel = "channel";
902
903 // Fill with some prime numbers
904 builder->fsCodeAppendf("\t\tconst vec4 %s = vec4(13.0, 53.0, 101.0, 151.0);\ n", xOffsets);
905 builder->fsCodeAppendf("\t\tconst vec4 %s = vec4(109.0, 167.0, 23.0, 67.0);\ n", yOffsets);
906
907 // There are rounding errors if the floor operation is not performed here
908 builder->fsCodeAppendf(
909 "\t\tvec3 %s = vec3(floor((%s*vec3(%s, 1.0)).xy) * vec2(0.66) * %s, 0.0) ;\n",
910 noiseVecIni, invMatrixUni, vCoords.c_str(), baseFrequencyUni);
911
912 // Perturb the texcoords with three components of noise
913 builder->fsCodeAppendf("\t\t%s += 0.1 * vec3(%s(%s + vec3( 0.0, 0.0, %s)) ,"
914 "%s(%s + vec3( 43.0, 17.0, %s)) ,"
915 "%s(%s + vec3(-17.0, -43.0, %s)) );\n",
916 noiseVecIni, noiseFuncName.c_str(), noiseVecIni, seed Uni,
917 noiseFuncName.c_str(), noiseVecIni, seed Uni,
918 noiseFuncName.c_str(), noiseVecIni, seed Uni);
919
920 builder->fsCodeAppendf("\t\t%s = vec4(0.0);\n", outputColor);
921
922 builder->fsCodeAppendf("\t\tvec3 %s = vec3(1.0);\n", factors);
923 builder->fsCodeAppendf("\t\tfloat %s = 0.0;\n", sum);
924
925 // Loop over all octaves
926 builder->fsCodeAppendf("\t\tfor (int octave = 0; octave < %d; ++octave) {\n" , fNumOctaves);
927
928 // Loop over the 4 channels
929 builder->fsCodeAppendf("\t\t\tfor (int %s = 3; %s >= 0; --%s) {\n", channel, channel, channel);
930
931 builder->fsCodeAppendf(
932 "\t\t\t\t%s[channel] += %s.x * %s(%s * %s.yyy - vec3(%s[%s], %s[%s], %s * %s.z));\n",
933 outputColor, factors, noiseFuncName.c_str(), noiseVecIni, factors, xOffs ets, channel,
934 yOffsets, channel, seedUni, factors);
935
936 builder->fsCodeAppend("\t\t\t}\n"); // end of the for loop on channels
937
938 builder->fsCodeAppendf("\t\t\t%s += %s.x;\n", sum, factors);
939 builder->fsCodeAppendf("\t\t\t%s *= vec3(0.5, 2.0, 0.75);\n", factors);
940
941 builder->fsCodeAppend("\t\t}\n"); // end of the for loop on octaves
942
943 if (fType == SkPerlinNoiseShader::kFractalNoise_Type) {
944 // The value of turbulenceFunctionResult comes from ((turbulenceFunction Result) + 1) / 2
945 // by fractalNoise and (turbulenceFunctionResult) by turbulence.
946 builder->fsCodeAppendf("\t\t%s = %s * vec4(0.5 / %s) + vec4(0.5);\n",
947 outputColor, outputColor, sum);
948 } else {
949 builder->fsCodeAppendf("\t\t%s = abs(%s / vec4(%s));\n",
950 outputColor, outputColor, sum);
951 }
952
953 builder->fsCodeAppendf("\t\t%s.a *= %s;\n", outputColor, alphaUni);
954
955 // Clamp values
956 builder->fsCodeAppendf("\t\t%s = clamp(%s, 0.0, 1.0);\n", outputColor, outpu tColor);
957
958 // Pre-multiply the result
959 builder->fsCodeAppendf("\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n",
960 outputColor, outputColor, outputColor, outputColor);
961 } 650 }
962 651
963 void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder, 652 void GrGLPerlinNoise::emitCode(GrGLShaderBuilder* builder,
964 const GrDrawEffect&, 653 const GrDrawEffect&,
965 EffectKey key, 654 EffectKey key,
966 const char* outputColor, 655 const char* outputColor,
967 const char* inputColor, 656 const char* inputColor,
968 const TransformedCoordsArray& coords, 657 const TransformedCoordsArray& coords,
969 const TextureSamplerArray& samplers) { 658 const TextureSamplerArray& samplers) {
970 sk_ignore_unused_variable(inputColor); 659 sk_ignore_unused_variable(inputColor);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 builder->fsCodeAppendf("\n\t\t%s.a *= %s;", outputColor, alphaUni); 900 builder->fsCodeAppendf("\n\t\t%s.a *= %s;", outputColor, alphaUni);
1212 901
1213 // Clamp values 902 // Clamp values
1214 builder->fsCodeAppendf("\n\t\t%s = clamp(%s, 0.0, 1.0);", outputColor, outpu tColor); 903 builder->fsCodeAppendf("\n\t\t%s = clamp(%s, 0.0, 1.0);", outputColor, outpu tColor);
1215 904
1216 // Pre-multiply the result 905 // Pre-multiply the result
1217 builder->fsCodeAppendf("\n\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n", 906 builder->fsCodeAppendf("\n\t\t%s = vec4(%s.rgb * %s.aaa, %s.a);\n",
1218 outputColor, outputColor, outputColor, outputColor); 907 outputColor, outputColor, outputColor, outputColor);
1219 } 908 }
1220 909
1221 GrGLNoise::GrGLNoise(const GrBackendEffectFactory& factory, const GrDrawEffect& drawEffect) 910 GrGLEffect::EffectKey GrGLPerlinNoise::GenKey(const GrDrawEffect& drawEffect, co nst GrGLCaps&) {
1222 : INHERITED (factory)
1223 , fType(drawEffect.castEffect<GrPerlinNoiseEffect>().type())
1224 , fStitchTiles(drawEffect.castEffect<GrPerlinNoiseEffect>().stitchTiles())
1225 , fNumOctaves(drawEffect.castEffect<GrPerlinNoiseEffect>().numOctaves()) {
1226 }
1227
1228 GrGLEffect::EffectKey GrGLNoise::GenKey(const GrDrawEffect& drawEffect, const Gr GLCaps&) {
1229 const GrPerlinNoiseEffect& turbulence = drawEffect.castEffect<GrPerlinNoiseE ffect>(); 911 const GrPerlinNoiseEffect& turbulence = drawEffect.castEffect<GrPerlinNoiseE ffect>();
1230 912
1231 EffectKey key = turbulence.numOctaves(); 913 EffectKey key = turbulence.numOctaves();
1232 914
1233 key = key << 3; // Make room for next 3 bits 915 key = key << 3; // Make room for next 3 bits
1234 916
1235 switch (turbulence.type()) { 917 switch (turbulence.type()) {
1236 case SkPerlinNoiseShader::kFractalNoise_Type: 918 case SkPerlinNoiseShader::kFractalNoise_Type:
1237 key |= 0x1; 919 key |= 0x1;
1238 break; 920 break;
1239 case SkPerlinNoiseShader::kTurbulence_Type: 921 case SkPerlinNoiseShader::kTurbulence_Type:
1240 key |= 0x2; 922 key |= 0x2;
1241 break; 923 break;
1242 default: 924 default:
1243 // leave key at 0 925 // leave key at 0
1244 break; 926 break;
1245 } 927 }
1246 928
1247 if (turbulence.stitchTiles()) { 929 if (turbulence.stitchTiles()) {
1248 key |= 0x4; // Flip the 3rd bit if tile stitching is on 930 key |= 0x4; // Flip the 3rd bit if tile stitching is on
1249 } 931 }
1250 932
1251 return key; 933 return key;
1252 } 934 }
1253 935
1254 void GrGLNoise::setData(const GrGLUniformManager& uman, const GrDrawEffect& draw Effect) { 936 void GrGLPerlinNoise::setData(const GrGLUniformManager& uman, const GrDrawEffect & drawEffect) {
937 INHERITED::setData(uman, drawEffect);
938
1255 const GrPerlinNoiseEffect& turbulence = drawEffect.castEffect<GrPerlinNoiseE ffect>(); 939 const GrPerlinNoiseEffect& turbulence = drawEffect.castEffect<GrPerlinNoiseE ffect>();
1256 940
1257 const SkVector& baseFrequency = turbulence.baseFrequency(); 941 const SkVector& baseFrequency = turbulence.baseFrequency();
1258 uman.set2f(fBaseFrequencyUni, baseFrequency.fX, baseFrequency.fY); 942 uman.set2f(fBaseFrequencyUni, baseFrequency.fX, baseFrequency.fY);
1259 uman.set1f(fAlphaUni, SkScalarDiv(SkIntToScalar(turbulence.alpha()), SkIntTo Scalar(255))); 943 uman.set1f(fAlphaUni, SkScalarDiv(SkIntToScalar(turbulence.alpha()), SkIntTo Scalar(255)));
1260 944
1261 SkMatrix m = turbulence.matrix(); 945 SkMatrix m = turbulence.matrix();
1262 m.postTranslate(-SK_Scalar1, -SK_Scalar1); 946 m.postTranslate(-SK_Scalar1, -SK_Scalar1);
1263 SkMatrix invM; 947 SkMatrix invM;
1264 if (!m.invert(&invM)) { 948 if (!m.invert(&invM)) {
1265 invM.reset(); 949 invM.reset();
1266 } else { 950 } else {
1267 invM.postConcat(invM); // Square the matrix 951 invM.postConcat(invM); // Square the matrix
1268 } 952 }
1269 uman.setSkMatrix(fInvMatrixUni, invM); 953 uman.setSkMatrix(fInvMatrixUni, invM);
1270 }
1271 954
1272 void GrGLPerlinNoise::setData(const GrGLUniformManager& uman, const GrDrawEffect & drawEffect) {
1273 INHERITED::setData(uman, drawEffect);
1274
1275 const GrPerlinNoiseEffect& turbulence = drawEffect.castEffect<GrPerlinNoiseE ffect>();
1276 if (turbulence.stitchTiles()) { 955 if (turbulence.stitchTiles()) {
1277 const SkPerlinNoiseShader::StitchData& stitchData = turbulence.stitchDat a(); 956 const SkPerlinNoiseShader::StitchData& stitchData = turbulence.stitchDat a();
1278 uman.set2f(fStitchDataUni, SkIntToScalar(stitchData.fWidth), 957 uman.set2f(fStitchDataUni, SkIntToScalar(stitchData.fWidth),
1279 SkIntToScalar(stitchData.fHeight)); 958 SkIntToScalar(stitchData.fHeight));
1280 } 959 }
1281 } 960 }
1282 961
1283 void GrGLSimplexNoise::setData(const GrGLUniformManager& uman, const GrDrawEffec t& drawEffect) {
1284 INHERITED::setData(uman, drawEffect);
1285
1286 const GrSimplexNoiseEffect& turbulence = drawEffect.castEffect<GrSimplexNois eEffect>();
1287 uman.set1f(fSeedUni, turbulence.seed());
1288 }
1289
1290 ///////////////////////////////////////////////////////////////////// 962 /////////////////////////////////////////////////////////////////////
1291 963
1292 bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint, 964 bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
1293 const SkMatrix* externalLocalMatrix, GrCol or* grColor, 965 const SkMatrix* externalLocalMatrix, GrCol or* grColor,
1294 GrEffectRef** grEffect) const { 966 GrEffectRef** grEffect) const {
1295 SkASSERT(NULL != context); 967 SkASSERT(NULL != context);
1296 968
1297 *grColor = SkColor2GrColorJustAlpha(paint.getColor()); 969 *grColor = SkColor2GrColorJustAlpha(paint.getColor());
1298 970
1299 SkMatrix localMatrix = this->getLocalMatrix(); 971 SkMatrix localMatrix = this->getLocalMatrix();
1300 if (externalLocalMatrix) { 972 if (externalLocalMatrix) {
1301 localMatrix.preConcat(*externalLocalMatrix); 973 localMatrix.preConcat(*externalLocalMatrix);
1302 } 974 }
1303 975
1304 if (0 == fNumOctaves) { 976 if (0 == fNumOctaves) {
1305 SkColor clearColor = 0; 977 SkColor clearColor = 0;
1306 if (kFractalNoise_Type == fType) { 978 if (kFractalNoise_Type == fType) {
1307 clearColor = SkColorSetARGB(paint.getAlpha() / 2, 127, 127, 127); 979 clearColor = SkColorSetARGB(paint.getAlpha() / 2, 127, 127, 127);
1308 } 980 }
1309 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter( 981 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(
1310 clearColor, SkXfermode::kSrc_Mod e)); 982 clearColor, SkXfermode::kSrc_Mod e));
1311 *grEffect = cf->asNewEffect(context); 983 *grEffect = cf->asNewEffect(context);
1312 return true; 984 return true;
1313 } 985 }
1314 986
1315 // Either we don't stitch tiles, either we have a valid tile size 987 // Either we don't stitch tiles, either we have a valid tile size
1316 SkASSERT(!fStitchTiles || !fTileSize.isEmpty()); 988 SkASSERT(!fStitchTiles || !fTileSize.isEmpty());
1317 989
1318 #ifdef SK_USE_SIMPLEX_NOISE
1319 // Simplex noise is currently disabled but can be enabled by defining SK_USE _SIMPLEX_NOISE
1320 sk_ignore_unused_variable(context);
1321 *grEffect =
1322 GrSimplexNoiseEffect::Create(fType, fPaintingData->fBaseFrequency,
1323 fNumOctaves, fStitchTiles, fSeed,
1324 this->getLocalMatrix(), paint.getAlpha());
1325 #else
1326 GrTexture* permutationsTexture = GrLockAndRefCachedBitmapTexture( 990 GrTexture* permutationsTexture = GrLockAndRefCachedBitmapTexture(
1327 context, fPaintingData->getPermutationsBitmap(), NULL); 991 context, fPaintingData->getPermutationsBitmap(), NULL);
1328 GrTexture* noiseTexture = GrLockAndRefCachedBitmapTexture( 992 GrTexture* noiseTexture = GrLockAndRefCachedBitmapTexture(
1329 context, fPaintingData->getNoiseBitmap(), NULL); 993 context, fPaintingData->getNoiseBitmap(), NULL);
1330 994
1331 *grEffect = (NULL != permutationsTexture) && (NULL != noiseTexture) ? 995 *grEffect = (NULL != permutationsTexture) && (NULL != noiseTexture) ?
1332 GrPerlinNoiseEffect::Create(fType, fPaintingData->fBaseFrequency, 996 GrPerlinNoiseEffect::Create(fType, fPaintingData->fBaseFrequency,
1333 fNumOctaves, fStitchTiles, 997 fNumOctaves, fStitchTiles,
1334 fPaintingData->fStitchDataInit, 998 fPaintingData->fStitchDataInit,
1335 permutationsTexture, noiseTexture, 999 permutationsTexture, noiseTexture,
1336 localMatrix, paint.getAlpha()) : 1000 localMatrix, paint.getAlpha()) :
1337 NULL; 1001 NULL;
1338 1002
1339 // Unlock immediately, this is not great, but we don't have a way of 1003 // Unlock immediately, this is not great, but we don't have a way of
1340 // knowing when else to unlock it currently. TODO: Remove this when 1004 // knowing when else to unlock it currently. TODO: Remove this when
1341 // unref becomes the unlock replacement for all types of textures. 1005 // unref becomes the unlock replacement for all types of textures.
1342 if (NULL != permutationsTexture) { 1006 if (NULL != permutationsTexture) {
1343 GrUnlockAndUnrefCachedBitmapTexture(permutationsTexture); 1007 GrUnlockAndUnrefCachedBitmapTexture(permutationsTexture);
1344 } 1008 }
1345 if (NULL != noiseTexture) { 1009 if (NULL != noiseTexture) {
1346 GrUnlockAndUnrefCachedBitmapTexture(noiseTexture); 1010 GrUnlockAndUnrefCachedBitmapTexture(noiseTexture);
1347 } 1011 }
1348 #endif
1349 1012
1350 return true; 1013 return true;
1351 } 1014 }
1352 1015
1353 #else 1016 #else
1354 1017
1355 bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint, 1018 bool SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint,
1356 const SkMatrix* externalLocalMatrix, GrCol or* grColor, 1019 const SkMatrix* externalLocalMatrix, GrCol or* grColor,
1357 GrEffectRef** grEffect) const { 1020 GrEffectRef** grEffect) const {
1358 SkDEBUGFAIL("Should not call in GPU-less build"); 1021 SkDEBUGFAIL("Should not call in GPU-less build");
(...skipping 27 matching lines...) Expand all
1386 str->append(" seed: "); 1049 str->append(" seed: ");
1387 str->appendScalar(fSeed); 1050 str->appendScalar(fSeed);
1388 str->append(" stitch tiles: "); 1051 str->append(" stitch tiles: ");
1389 str->append(fStitchTiles ? "true " : "false "); 1052 str->append(fStitchTiles ? "true " : "false ");
1390 1053
1391 this->INHERITED::toString(str); 1054 this->INHERITED::toString(str);
1392 1055
1393 str->append(")"); 1056 str->append(")");
1394 } 1057 }
1395 #endif 1058 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698