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 "SkDither.h" | 8 #include "SkDither.h" |
9 #include "SkPerlinNoiseShader.h" | 9 #include "SkPerlinNoiseShader.h" |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 int fWrapX; // Minimum value to wrap. | 71 int fWrapX; // Minimum value to wrap. |
72 int fHeight; | 72 int fHeight; |
73 int fWrapY; | 73 int fWrapY; |
74 }; | 74 }; |
75 | 75 |
76 struct SkPerlinNoiseShader::PaintingData { | 76 struct SkPerlinNoiseShader::PaintingData { |
77 PaintingData(const SkISize& tileSize, SkScalar seed, | 77 PaintingData(const SkISize& tileSize, SkScalar seed, |
78 SkScalar baseFrequencyX, SkScalar baseFrequencyY, | 78 SkScalar baseFrequencyX, SkScalar baseFrequencyY, |
79 const SkMatrix& matrix) | 79 const SkMatrix& matrix) |
80 { | 80 { |
81 SkVector wavelength = SkVector::Make(SkScalarInvert(baseFrequencyX), | 81 SkVector vec[2] = { |
82 SkScalarInvert(baseFrequencyY)); | 82 { SkScalarInvert(baseFrequencyX), SkScalarInvert(baseFrequencyY)
}, |
83 matrix.mapVectors(&wavelength, 1); | 83 { SkIntToScalar(tileSize.fWidth), SkIntToScalar(tileSize.fHeight)
}, |
84 fBaseFrequency.fX = SkScalarInvert(wavelength.fX); | 84 }; |
85 fBaseFrequency.fY = SkScalarInvert(wavelength.fY); | 85 matrix.mapVectors(vec, 2); |
86 SkVector sizeVec = SkVector::Make(SkIntToScalar(tileSize.fWidth), | 86 |
87 SkIntToScalar(tileSize.fHeight)); | 87 fBaseFrequency.set(SkScalarInvert(vec[0].fX), SkScalarInvert(vec[0].fY))
; |
88 matrix.mapVectors(&sizeVec, 1); | 88 fTileSize.set(SkScalarRoundToInt(vec[1].fX), SkScalarRoundToInt(vec[1].f
Y)); |
89 fTileSize.fWidth = SkScalarRoundToInt(sizeVec.fX); | |
90 fTileSize.fHeight = SkScalarRoundToInt(sizeVec.fY); | |
91 this->init(seed); | 89 this->init(seed); |
92 if (!fTileSize.isEmpty()) { | 90 if (!fTileSize.isEmpty()) { |
93 this->stitch(); | 91 this->stitch(); |
94 } | 92 } |
95 | 93 |
96 #if SK_SUPPORT_GPU | 94 #if SK_SUPPORT_GPU |
97 fPermutationsBitmap.setInfo(SkImageInfo::MakeA8(kBlockSize, 1)); | 95 fPermutationsBitmap.setInfo(SkImageInfo::MakeA8(kBlockSize, 1)); |
98 fPermutationsBitmap.setPixels(fLatticeSelector); | 96 fPermutationsBitmap.setPixels(fLatticeSelector); |
99 | 97 |
100 fNoiseBitmap.setInfo(SkImageInfo::MakeN32Premul(kBlockSize, 4)); | 98 fNoiseBitmap.setInfo(SkImageInfo::MakeN32Premul(kBlockSize, 4)); |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 str->append(" seed: "); | 1032 str->append(" seed: "); |
1035 str->appendScalar(fSeed); | 1033 str->appendScalar(fSeed); |
1036 str->append(" stitch tiles: "); | 1034 str->append(" stitch tiles: "); |
1037 str->append(fStitchTiles ? "true " : "false "); | 1035 str->append(fStitchTiles ? "true " : "false "); |
1038 | 1036 |
1039 this->INHERITED::toString(str); | 1037 this->INHERITED::toString(str); |
1040 | 1038 |
1041 str->append(")"); | 1039 str->append(")"); |
1042 } | 1040 } |
1043 #endif | 1041 #endif |
OLD | NEW |