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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SkBitmap* getPermutationsBitmap() | 240 SkBitmap* getPermutationsBitmap() |
241 { | 241 { |
242 if (!fPermutationsBitmap) { | 242 if (!fPermutationsBitmap) { |
243 fPermutationsBitmap = SkNEW(SkBitmap); | 243 fPermutationsBitmap = SkNEW(SkBitmap); |
244 fPermutationsBitmap->setConfig(SkBitmap::kA8_Config, kBlockSize, 1); | 244 fPermutationsBitmap->allocPixels(SkImageInfo::MakeA8(kBlockSize, 1))
; |
245 fPermutationsBitmap->allocPixels(); | |
246 uint8_t* bitmapPixels = fPermutationsBitmap->getAddr8(0, 0); | 245 uint8_t* bitmapPixels = fPermutationsBitmap->getAddr8(0, 0); |
247 memcpy(bitmapPixels, fLatticeSelector, sizeof(uint8_t) * kBlockSize)
; | 246 memcpy(bitmapPixels, fLatticeSelector, sizeof(uint8_t) * kBlockSize)
; |
248 } | 247 } |
249 return fPermutationsBitmap; | 248 return fPermutationsBitmap; |
250 } | 249 } |
251 | 250 |
252 SkBitmap* getNoiseBitmap() | 251 SkBitmap* getNoiseBitmap() |
253 { | 252 { |
254 if (!fNoiseBitmap) { | 253 if (!fNoiseBitmap) { |
255 fNoiseBitmap = SkNEW(SkBitmap); | 254 fNoiseBitmap = SkNEW(SkBitmap); |
256 fNoiseBitmap->setConfig(SkBitmap::kARGB_8888_Config, kBlockSize, 4); | 255 fNoiseBitmap->allocPixels(SkImageInfo::MakeN32Premul(kBlockSize, 4))
; |
257 fNoiseBitmap->allocPixels(); | |
258 uint32_t* bitmapPixels = fNoiseBitmap->getAddr32(0, 0); | 256 uint32_t* bitmapPixels = fNoiseBitmap->getAddr32(0, 0); |
259 memcpy(bitmapPixels, fNoise[0][0], sizeof(uint16_t) * kBlockSize * 4
* 2); | 257 memcpy(bitmapPixels, fNoise[0][0], sizeof(uint16_t) * kBlockSize * 4
* 2); |
260 } | 258 } |
261 return fNoiseBitmap; | 259 return fNoiseBitmap; |
262 } | 260 } |
263 }; | 261 }; |
264 | 262 |
265 SkShader* SkPerlinNoiseShader::CreateFractalNoise(SkScalar baseFrequencyX, SkSca
lar baseFrequencyY, | 263 SkShader* SkPerlinNoiseShader::CreateFractalNoise(SkScalar baseFrequencyX, SkSca
lar baseFrequencyY, |
266 int numOctaves, SkScalar seed, | 264 int numOctaves, SkScalar seed, |
267 const SkISize* tileSize) { | 265 const SkISize* tileSize) { |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 str->append(" seed: "); | 1384 str->append(" seed: "); |
1387 str->appendScalar(fSeed); | 1385 str->appendScalar(fSeed); |
1388 str->append(" stitch tiles: "); | 1386 str->append(" stitch tiles: "); |
1389 str->append(fStitchTiles ? "true " : "false "); | 1387 str->append(fStitchTiles ? "true " : "false "); |
1390 | 1388 |
1391 this->INHERITED::toString(str); | 1389 this->INHERITED::toString(str); |
1392 | 1390 |
1393 str->append(")"); | 1391 str->append(")"); |
1394 } | 1392 } |
1395 #endif | 1393 #endif |
OLD | NEW |