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

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

Issue 143073008: add installPixels (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkLightingImageFilter.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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698