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

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

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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 | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('j') | 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 }; 509 };
510 510
511 ///////////////////////////////////////////////////////////////////// 511 /////////////////////////////////////////////////////////////////////
512 512
513 class GrPerlinNoiseEffect : public GrFragmentProcessor { 513 class GrPerlinNoiseEffect : public GrFragmentProcessor {
514 public: 514 public:
515 static GrFragmentProcessor* Create(SkPerlinNoiseShader::Type type, 515 static GrFragmentProcessor* Create(SkPerlinNoiseShader::Type type,
516 int numOctaves, bool stitchTiles, 516 int numOctaves, bool stitchTiles,
517 SkPerlinNoiseShader::PaintingData* painti ngData, 517 SkPerlinNoiseShader::PaintingData* painti ngData,
518 GrTexture* permutationsTexture, GrTexture * noiseTexture, 518 GrTexture* permutationsTexture, GrTexture * noiseTexture,
519 const SkMatrix& matrix) { 519 const SkMatrix& matrix, GrRenderTarget* d st) {
520 return new GrPerlinNoiseEffect(type, numOctaves, stitchTiles, paintingDa ta, 520 return new GrPerlinNoiseEffect(type, numOctaves, stitchTiles, paintingDa ta,
521 permutationsTexture, noiseTexture, matrix ); 521 permutationsTexture, noiseTexture, matrix , dst);
522 } 522 }
523 523
524 virtual ~GrPerlinNoiseEffect() { delete fPaintingData; } 524 virtual ~GrPerlinNoiseEffect() { delete fPaintingData; }
525 525
526 const char* name() const override { return "PerlinNoise"; } 526 const char* name() const override { return "PerlinNoise"; }
527 527
528 const SkPerlinNoiseShader::StitchData& stitchData() const { return fPainting Data->fStitchDataInit; } 528 const SkPerlinNoiseShader::StitchData& stitchData() const { return fPainting Data->fStitchDataInit; }
529 529
530 SkPerlinNoiseShader::Type type() const { return fType; } 530 SkPerlinNoiseShader::Type type() const { return fType; }
531 bool stitchTiles() const { return fStitchTiles; } 531 bool stitchTiles() const { return fStitchTiles; }
(...skipping 21 matching lines...) Expand all
553 } 553 }
554 554
555 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { 555 void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
556 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput); 556 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput);
557 } 557 }
558 558
559 GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type, 559 GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type,
560 int numOctaves, bool stitchTiles, 560 int numOctaves, bool stitchTiles,
561 SkPerlinNoiseShader::PaintingData* paintingData, 561 SkPerlinNoiseShader::PaintingData* paintingData,
562 GrTexture* permutationsTexture, GrTexture* noiseTexture, 562 GrTexture* permutationsTexture, GrTexture* noiseTexture,
563 const SkMatrix& matrix) 563 const SkMatrix& matrix, GrRenderTarget* dst)
564 : fType(type) 564 : fType(type)
565 , fNumOctaves(numOctaves) 565 , fNumOctaves(numOctaves)
566 , fStitchTiles(stitchTiles) 566 , fStitchTiles(stitchTiles)
567 , fPermutationsAccess(permutationsTexture) 567 , fPermutationsAccess(permutationsTexture, GrTextureParams::kNone_FilterMo de,SkShader::kClamp_TileMode, dst)
568 , fNoiseAccess(noiseTexture) 568 , fNoiseAccess(noiseTexture, GrTextureParams::kNone_FilterMode,SkShader::k Clamp_TileMode, dst)
569 , fPaintingData(paintingData) { 569 , fPaintingData(paintingData) {
570 this->initClassID<GrPerlinNoiseEffect>(); 570 this->initClassID<GrPerlinNoiseEffect>();
571 this->addTextureAccess(&fPermutationsAccess); 571 this->addTextureAccess(&fPermutationsAccess);
572 this->addTextureAccess(&fNoiseAccess); 572 this->addTextureAccess(&fNoiseAccess);
573 fCoordTransform.reset(kLocal_GrCoordSet, matrix); 573 fCoordTransform.reset(kLocal_GrCoordSet, matrix);
574 this->addCoordTransform(&fCoordTransform); 574 this->addCoordTransform(&fCoordTransform);
575 } 575 }
576 576
577 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 577 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
578 578
(...skipping 25 matching lines...) Expand all
604 604
605 SkAutoTUnref<SkShader> shader(d->fRandom->nextBool() ? 605 SkAutoTUnref<SkShader> shader(d->fRandom->nextBool() ?
606 SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed, 606 SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed,
607 stitchTiles ? &tileSize : nullpt r) : 607 stitchTiles ? &tileSize : nullpt r) :
608 SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, nu mOctaves, seed, 608 SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, nu mOctaves, seed,
609 stitchTiles ? &tileSize : nullptr)) ; 609 stitchTiles ? &tileSize : nullptr)) ;
610 610
611 GrPaint grPaint; 611 GrPaint grPaint;
612 return shader->asFragmentProcessor(d->fContext, 612 return shader->asFragmentProcessor(d->fContext,
613 GrTest::TestMatrix(d->fRandom), nullptr, 613 GrTest::TestMatrix(d->fRandom), nullptr,
614 kNone_SkFilterQuality); 614 kNone_SkFilterQuality,
615 NULL);
615 } 616 }
616 617
617 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) 618 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor)
618 : fType(processor.cast<GrPerlinNoiseEffect>().type()) 619 : fType(processor.cast<GrPerlinNoiseEffect>().type())
619 , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles()) 620 , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles())
620 , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) { 621 , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) {
621 } 622 }
622 623
623 void GrGLPerlinNoise::emitCode(EmitArgs& args) { 624 void GrGLPerlinNoise::emitCode(EmitArgs& args) {
624 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder() ; 625 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder() ;
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 pdman.set2f(fStitchDataUni, SkIntToScalar(stitchData.fWidth), 911 pdman.set2f(fStitchDataUni, SkIntToScalar(stitchData.fWidth),
911 SkIntToScalar(stitchData.fHeight)); 912 SkIntToScalar(stitchData.fHeight));
912 } 913 }
913 } 914 }
914 915
915 ///////////////////////////////////////////////////////////////////// 916 /////////////////////////////////////////////////////////////////////
916 const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor( 917 const GrFragmentProcessor* SkPerlinNoiseShader::asFragmentProcessor(
917 GrContext* context, 918 GrContext* context,
918 const SkMatrix& viewM, 919 const SkMatrix& viewM,
919 const SkMatrix* externalLoca lMatrix, 920 const SkMatrix* externalLoca lMatrix,
920 SkFilterQuality) const { 921 SkFilterQuality,
922 GrRenderTarget* dst) const {
921 SkASSERT(context); 923 SkASSERT(context);
922 924
923 SkMatrix localMatrix = this->getLocalMatrix(); 925 SkMatrix localMatrix = this->getLocalMatrix();
924 if (externalLocalMatrix) { 926 if (externalLocalMatrix) {
925 localMatrix.preConcat(*externalLocalMatrix); 927 localMatrix.preConcat(*externalLocalMatrix);
926 } 928 }
927 929
928 SkMatrix matrix = viewM; 930 SkMatrix matrix = viewM;
929 matrix.preConcat(localMatrix); 931 matrix.preConcat(localMatrix);
930 932
(...skipping 24 matching lines...) Expand all
955 SkMatrix m = viewM; 957 SkMatrix m = viewM;
956 m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1); 958 m.setTranslateX(-localMatrix.getTranslateX() + SK_Scalar1);
957 m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1); 959 m.setTranslateY(-localMatrix.getTranslateY() + SK_Scalar1);
958 if ((permutationsTexture) && (noiseTexture)) { 960 if ((permutationsTexture) && (noiseTexture)) {
959 SkAutoTUnref<GrFragmentProcessor> inner( 961 SkAutoTUnref<GrFragmentProcessor> inner(
960 GrPerlinNoiseEffect::Create(fType, 962 GrPerlinNoiseEffect::Create(fType,
961 fNumOctaves, 963 fNumOctaves,
962 fStitchTiles, 964 fStitchTiles,
963 paintingData, 965 paintingData,
964 permutationsTexture, noiseTexture, 966 permutationsTexture, noiseTexture,
965 m)); 967 m, dst));
966 return GrFragmentProcessor::MulOutputByInputAlpha(inner); 968 return GrFragmentProcessor::MulOutputByInputAlpha(inner);
967 } 969 }
968 delete paintingData; 970 delete paintingData;
969 return nullptr; 971 return nullptr;
970 } 972 }
971 973
972 #endif 974 #endif
973 975
974 #ifndef SK_IGNORE_TO_STRING 976 #ifndef SK_IGNORE_TO_STRING
975 void SkPerlinNoiseShader::toString(SkString* str) const { 977 void SkPerlinNoiseShader::toString(SkString* str) const {
(...skipping 20 matching lines...) Expand all
996 str->append(" seed: "); 998 str->append(" seed: ");
997 str->appendScalar(fSeed); 999 str->appendScalar(fSeed);
998 str->append(" stitch tiles: "); 1000 str->append(" stitch tiles: ");
999 str->append(fStitchTiles ? "true " : "false "); 1001 str->append(fStitchTiles ? "true " : "false ");
1000 1002
1001 this->INHERITED::toString(str); 1003 this->INHERITED::toString(str);
1002 1004
1003 str->append(")"); 1005 str->append(")");
1004 } 1006 }
1005 #endif 1007 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698