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

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

Issue 2107453002: Fix Perlin noise fuzz issue (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Working Created 4 years, 5 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 | « src/core/SkValidatingReadBuffer.cpp ('k') | no next file » | 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 "SkPerlinNoiseShader.h" 8 #include "SkPerlinNoiseShader.h"
9 #include "SkColorFilter.h" 9 #include "SkColorFilter.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 268
269 SkPerlinNoiseShader::SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, 269 SkPerlinNoiseShader::SkPerlinNoiseShader(SkPerlinNoiseShader::Type type,
270 SkScalar baseFrequencyX, 270 SkScalar baseFrequencyX,
271 SkScalar baseFrequencyY, 271 SkScalar baseFrequencyY,
272 int numOctaves, 272 int numOctaves,
273 SkScalar seed, 273 SkScalar seed,
274 const SkISize* tileSize) 274 const SkISize* tileSize)
275 : fType(type) 275 : fType(type)
276 , fBaseFrequencyX(baseFrequencyX) 276 , fBaseFrequencyX(baseFrequencyX)
277 , fBaseFrequencyY(baseFrequencyY) 277 , fBaseFrequencyY(baseFrequencyY)
278 , fNumOctaves(numOctaves > 255 ? 255 : numOctaves/*[0,255] octaves allowed*/) 278 , fNumOctaves(SkTPin<int>(numOctaves, 0, 255)) // [0,255] octaves allowed
279 , fSeed(seed) 279 , fSeed(seed)
280 , fTileSize(nullptr == tileSize ? SkISize::Make(0, 0) : *tileSize) 280 , fTileSize(nullptr == tileSize ? SkISize::Make(0, 0) : *tileSize)
281 , fStitchTiles(!fTileSize.isEmpty()) 281 , fStitchTiles(!fTileSize.isEmpty())
282 { 282 {
283 SkASSERT(numOctaves >= 0 && numOctaves < 256); 283 SkASSERT(fNumOctaves >= 0 && fNumOctaves < 256);
284 } 284 }
285 285
286 SkPerlinNoiseShader::~SkPerlinNoiseShader() { 286 SkPerlinNoiseShader::~SkPerlinNoiseShader() {
287 } 287 }
288 288
289 sk_sp<SkFlattenable> SkPerlinNoiseShader::CreateProc(SkReadBuffer& buffer) { 289 sk_sp<SkFlattenable> SkPerlinNoiseShader::CreateProc(SkReadBuffer& buffer) {
290 Type type = (Type)buffer.readInt(); 290 Type type = (Type)buffer.readInt();
291 SkScalar freqX = buffer.readScalar(); 291 SkScalar freqX = buffer.readScalar();
292 SkScalar freqY = buffer.readScalar(); 292 SkScalar freqY = buffer.readScalar();
293 int octaves = buffer.readInt(); 293 int octaves = buffer.readInt();
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 str->append(" seed: "); 977 str->append(" seed: ");
978 str->appendScalar(fSeed); 978 str->appendScalar(fSeed);
979 str->append(" stitch tiles: "); 979 str->append(" stitch tiles: ");
980 str->append(fStitchTiles ? "true " : "false "); 980 str->append(fStitchTiles ? "true " : "false ");
981 981
982 this->INHERITED::toString(str); 982 this->INHERITED::toString(str);
983 983
984 str->append(")"); 984 str->append(")");
985 } 985 }
986 #endif 986 #endif
OLDNEW
« no previous file with comments | « src/core/SkValidatingReadBuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698