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

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

Issue 1213623022: fix up test create functions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more cleanup Created 5 years, 5 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 GrTextureAccess fNoiseAccess; 595 GrTextureAccess fNoiseAccess;
596 SkPerlinNoiseShader::PaintingData *fPaintingData; 596 SkPerlinNoiseShader::PaintingData *fPaintingData;
597 597
598 private: 598 private:
599 typedef GrFragmentProcessor INHERITED; 599 typedef GrFragmentProcessor INHERITED;
600 }; 600 };
601 601
602 ///////////////////////////////////////////////////////////////////// 602 /////////////////////////////////////////////////////////////////////
603 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoiseEffect); 603 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrPerlinNoiseEffect);
604 604
605 GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(SkRandom* random, 605 GrFragmentProcessor* GrPerlinNoiseEffect::TestCreate(GrProcessorTestData* d) {
606 GrContext* context, 606 int numOctaves = d->fRandom->nextRangeU(2, 10);
607 const GrCaps&, 607 bool stitchTiles = d->fRandom->nextBool();
608 GrTexture**) { 608 SkScalar seed = SkIntToScalar(d->fRandom->nextU());
609 int numOctaves = random->nextRangeU(2, 10); 609 SkISize tileSize = SkISize::Make(d->fRandom->nextRangeU(4, 4096),
610 bool stitchTiles = random->nextBool(); 610 d->fRandom->nextRangeU(4, 4096));
611 SkScalar seed = SkIntToScalar(random->nextU()); 611 SkScalar baseFrequencyX = d->fRandom->nextRangeScalar(0.01f,
612 SkISize tileSize = SkISize::Make(random->nextRangeU(4, 4096), random->nextR angeU(4, 4096)); 612 0.99f);
613 SkScalar baseFrequencyX = random->nextRangeScalar(0.01f, 613 SkScalar baseFrequencyY = d->fRandom->nextRangeScalar(0.01f,
614 0.99f); 614 0.99f);
615 SkScalar baseFrequencyY = random->nextRangeScalar(0.01f,
616 0.99f);
617 615
618 SkShader* shader = random->nextBool() ? 616 SkShader* shader = d->fRandom->nextBool() ?
619 SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed, 617 SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY, numOctaves, seed,
620 stitchTiles ? &tileSize : NULL) : 618 stitchTiles ? &tileSize : NULL) :
621 SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, nu mOctaves, seed, 619 SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, nu mOctaves, seed,
622 stitchTiles ? &tileSize : NULL); 620 stitchTiles ? &tileSize : NULL);
623 621
624 SkPaint paint; 622 SkPaint paint;
625 GrColor paintColor; 623 GrColor paintColor;
626 GrFragmentProcessor* effect; 624 GrFragmentProcessor* effect;
627 GrPaint grPaint; 625 GrPaint grPaint;
628 SkAssertResult(shader->asFragmentProcessor(context, paint, 626 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
629 GrTest::TestMatrix(random), NULL, 627 GrTest::TestMatrix(d->fRandom), N ULL,
630 &paintColor, grPaint.getShaderDat aManager(), 628 &paintColor, grPaint.getShaderDat aManager(),
631 &effect)); 629 &effect));
632 630
633 SkDELETE(shader); 631 SkDELETE(shader);
634 632
635 return effect; 633 return effect;
636 } 634 }
637 635
638 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) 636 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor)
639 : fType(processor.cast<GrPerlinNoiseEffect>().type()) 637 : fType(processor.cast<GrPerlinNoiseEffect>().type())
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 str->append(" seed: "); 1035 str->append(" seed: ");
1038 str->appendScalar(fSeed); 1036 str->appendScalar(fSeed);
1039 str->append(" stitch tiles: "); 1037 str->append(" stitch tiles: ");
1040 str->append(fStitchTiles ? "true " : "false "); 1038 str->append(fStitchTiles ? "true " : "false ");
1041 1039
1042 this->INHERITED::toString(str); 1040 this->INHERITED::toString(str);
1043 1041
1044 str->append(")"); 1042 str->append(")");
1045 } 1043 }
1046 #endif 1044 #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