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

Side by Side Diff: experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp

Issue 1855733002: change flattenable factory to return sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | gm/dcshader.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 "SkPerlinNoiseShader2.h" 9 #include "SkPerlinNoiseShader2.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 , fSeed(seed) 345 , fSeed(seed)
346 , fTileSize(nullptr == tileSize ? SkISize::Make(0, 0) : *tileSize) 346 , fTileSize(nullptr == tileSize ? SkISize::Make(0, 0) : *tileSize)
347 , fStitchTiles(!fTileSize.isEmpty()) 347 , fStitchTiles(!fTileSize.isEmpty())
348 { 348 {
349 SkASSERT(numOctaves >= 0 && numOctaves < 256); 349 SkASSERT(numOctaves >= 0 && numOctaves < 256);
350 } 350 }
351 351
352 SkPerlinNoiseShader2::~SkPerlinNoiseShader2() { 352 SkPerlinNoiseShader2::~SkPerlinNoiseShader2() {
353 } 353 }
354 354
355 SkFlattenable* SkPerlinNoiseShader2::CreateProc(SkReadBuffer& buffer) { 355 sk_sp<SkFlattenable> SkPerlinNoiseShader2::CreateProc(SkReadBuffer& buffer) {
356 Type type = (Type)buffer.readInt(); 356 Type type = (Type)buffer.readInt();
357 SkScalar freqX = buffer.readScalar(); 357 SkScalar freqX = buffer.readScalar();
358 SkScalar freqY = buffer.readScalar(); 358 SkScalar freqY = buffer.readScalar();
359 int octaves = buffer.readInt(); 359 int octaves = buffer.readInt();
360 SkScalar seed = buffer.readScalar(); 360 SkScalar seed = buffer.readScalar();
361 SkISize tileSize; 361 SkISize tileSize;
362 tileSize.fWidth = buffer.readInt(); 362 tileSize.fWidth = buffer.readInt();
363 tileSize.fHeight = buffer.readInt(); 363 tileSize.fHeight = buffer.readInt();
364 364
365 switch (type) { 365 switch (type) {
366 case kFractalNoise_Type: 366 case kFractalNoise_Type:
367 return SkPerlinNoiseShader2::MakeFractalNoise(freqX, freqY, octaves, seed, 367 return SkPerlinNoiseShader2::MakeFractalNoise(freqX, freqY, octaves, seed, &tileSize);
368 &tileSize).release();
369 case kTurbulence_Type: 368 case kTurbulence_Type:
370 return SkPerlinNoiseShader2::MakeTubulence(freqX, freqY, octaves, se ed, 369 return SkPerlinNoiseShader2::MakeTubulence(freqX, freqY, octaves, se ed, &tileSize);
371 &tileSize).release();
372 case kImprovedNoise_Type: 370 case kImprovedNoise_Type:
373 return SkPerlinNoiseShader2::MakeImprovedNoise(freqX, freqY, octaves , seed).release(); 371 return SkPerlinNoiseShader2::MakeImprovedNoise(freqX, freqY, octaves , seed);
374 default: 372 default:
375 return nullptr; 373 return nullptr;
376 } 374 }
377 } 375 }
378 376
379 void SkPerlinNoiseShader2::flatten(SkWriteBuffer& buffer) const { 377 void SkPerlinNoiseShader2::flatten(SkWriteBuffer& buffer) const {
380 buffer.writeInt((int) fType); 378 buffer.writeInt((int) fType);
381 buffer.writeScalar(fBaseFrequencyX); 379 buffer.writeScalar(fBaseFrequencyX);
382 buffer.writeScalar(fBaseFrequencyY); 380 buffer.writeScalar(fBaseFrequencyY);
383 buffer.writeInt(fNumOctaves); 381 buffer.writeInt(fNumOctaves);
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 str->append(" seed: "); 1396 str->append(" seed: ");
1399 str->appendScalar(fSeed); 1397 str->appendScalar(fSeed);
1400 str->append(" stitch tiles: "); 1398 str->append(" stitch tiles: ");
1401 str->append(fStitchTiles ? "true " : "false "); 1399 str->append(fStitchTiles ? "true " : "false ");
1402 1400
1403 this->INHERITED::toString(str); 1401 this->INHERITED::toString(str);
1404 1402
1405 str->append(")"); 1403 str->append(")");
1406 } 1404 }
1407 #endif 1405 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/dcshader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698