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 "gm.h" | 8 #include "gm.h" |
9 #include "SkPerlinNoiseShader.h" | 9 #include "SkPerlinNoiseShader.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 SkIntToScalar(fSize.width()), SkIntToScalar(fSize.heigh
t()))); | 32 SkIntToScalar(fSize.width()), SkIntToScalar(fSize.heigh
t()))); |
33 SkRect r = SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), | 33 SkRect r = SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), |
34 SkIntToScalar(fSize.width()), | 34 SkIntToScalar(fSize.width()), |
35 SkIntToScalar(fSize.height())); | 35 SkIntToScalar(fSize.height())); |
36 canvas->drawRect(r, paint); | 36 canvas->drawRect(r, paint); |
37 canvas->restore(); | 37 canvas->restore(); |
38 } | 38 } |
39 | 39 |
40 void test(SkCanvas* canvas, int x, int y, SkPerlinNoiseShader::Type type, | 40 void test(SkCanvas* canvas, int x, int y, SkPerlinNoiseShader::Type type, |
41 float baseFrequencyX, float baseFrequencyY, int numOctaves, float
seed, | 41 float baseFrequencyX, float baseFrequencyY, int numOctaves, float
seed, |
42 bool stitchTiles) | 42 bool stitchTiles) { |
43 { | |
44 SkShader* shader = (type == SkPerlinNoiseShader::kFractalNoise_Type) ? | 43 SkShader* shader = (type == SkPerlinNoiseShader::kFractalNoise_Type) ? |
45 SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequenc
yY, numOctaves, | 44 SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequenc
yY, numOctaves, |
46 seed, stitchTiles ? &fSize :
NULL) : | 45 seed, stitchTiles ? &fSize :
NULL) : |
47 SkPerlinNoiseShader::CreateTubulence(baseFrequencyX, baseFrequencyY,
numOctaves, | 46 SkPerlinNoiseShader::CreateTubulence(baseFrequencyX, baseFrequencyY,
numOctaves, |
48 seed, stitchTiles ? &fSize : NUL
L); | 47 seed, stitchTiles ? &fSize : NUL
L); |
49 SkPaint paint; | 48 SkPaint paint; |
50 paint.setShader(shader)->unref(); | 49 paint.setShader(shader)->unref(); |
51 drawClippedRect(canvas, x, y, paint); | 50 drawClippedRect(canvas, x, y, paint); |
52 } | 51 } |
53 | 52 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 typedef GM INHERITED; | 104 typedef GM INHERITED; |
106 SkISize fSize; | 105 SkISize fSize; |
107 }; | 106 }; |
108 | 107 |
109 ////////////////////////////////////////////////////////////////////////////// | 108 ////////////////////////////////////////////////////////////////////////////// |
110 | 109 |
111 static GM* MyFactory(void*) { return new PerlinNoiseGM; } | 110 static GM* MyFactory(void*) { return new PerlinNoiseGM; } |
112 static GMRegistry reg(MyFactory); | 111 static GMRegistry reg(MyFactory); |
113 | 112 |
114 } | 113 } |
OLD | NEW |