Chromium Code Reviews| 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 "SkFlattenableBuffers.h" | 11 #include "SkFlattenableBuffers.h" |
| 11 #include "SkShader.h" | 12 #include "SkShader.h" |
| 12 #include "SkUnPreMultiply.h" | 13 #include "SkUnPreMultiply.h" |
| 13 #include "SkString.h" | 14 #include "SkString.h" |
| 14 | 15 |
| 15 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
| 16 #include "GrContext.h" | 17 #include "GrContext.h" |
| 17 #include "GrCoordTransform.h" | 18 #include "GrCoordTransform.h" |
| 18 #include "gl/GrGLEffect.h" | 19 #include "gl/GrGLEffect.h" |
| 19 #include "GrTBackendEffectFactory.h" | 20 #include "GrTBackendEffectFactory.h" |
| (...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1288 | 1289 |
| 1289 const GrSimplexNoiseEffect& turbulence = drawEffect.castEffect<GrSimplexNois eEffect>(); | 1290 const GrSimplexNoiseEffect& turbulence = drawEffect.castEffect<GrSimplexNois eEffect>(); |
| 1290 uman.set1f(fSeedUni, turbulence.seed()); | 1291 uman.set1f(fSeedUni, turbulence.seed()); |
| 1291 } | 1292 } |
| 1292 | 1293 |
| 1293 ///////////////////////////////////////////////////////////////////// | 1294 ///////////////////////////////////////////////////////////////////// |
| 1294 | 1295 |
| 1295 GrEffectRef* SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint) const { | 1296 GrEffectRef* SkPerlinNoiseShader::asNewEffect(GrContext* context, const SkPaint& paint) const { |
| 1296 SkASSERT(NULL != context); | 1297 SkASSERT(NULL != context); |
| 1297 | 1298 |
| 1299 if (0 == fNumOctaves) { | |
| 1300 SkColor clearColor = 0; | |
| 1301 if (kFractalNoise_Type == fType) { | |
| 1302 clearColor = SkColorSetARGB(paint.getAlpha() / 2, 127, 127, 127); | |
| 1303 } | |
| 1304 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter( | |
|
bsalomon
2013/11/05 20:30:22
Ha.. ok.
| |
| 1305 clearColor, SkXfermode::kSrc_Mod e)); | |
| 1306 return cf->asNewEffect(context); | |
| 1307 } | |
| 1308 | |
| 1298 // Either we don't stitch tiles, either we have a valid tile size | 1309 // Either we don't stitch tiles, either we have a valid tile size |
| 1299 SkASSERT(!fStitchTiles || !fTileSize.isEmpty()); | 1310 SkASSERT(!fStitchTiles || !fTileSize.isEmpty()); |
| 1300 | 1311 |
| 1301 #ifdef SK_USE_SIMPLEX_NOISE | 1312 #ifdef SK_USE_SIMPLEX_NOISE |
| 1302 // Simplex noise is currently disabled but can be enabled by defining SK_USE _SIMPLEX_NOISE | 1313 // Simplex noise is currently disabled but can be enabled by defining SK_USE _SIMPLEX_NOISE |
| 1303 sk_ignore_unused_variable(context); | 1314 sk_ignore_unused_variable(context); |
| 1304 GrEffectRef* effect = | 1315 GrEffectRef* effect = |
| 1305 GrSimplexNoiseEffect::Create(fType, fPaintingData->fBaseFrequency, | 1316 GrSimplexNoiseEffect::Create(fType, fPaintingData->fBaseFrequency, |
| 1306 fNumOctaves, fStitchTiles, fSeed, | 1317 fNumOctaves, fStitchTiles, fSeed, |
| 1307 this->getLocalMatrix(), paint.getAlpha()); | 1318 this->getLocalMatrix(), paint.getAlpha()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1367 str->append(" seed: "); | 1378 str->append(" seed: "); |
| 1368 str->appendScalar(fSeed); | 1379 str->appendScalar(fSeed); |
| 1369 str->append(" stitch tiles: "); | 1380 str->append(" stitch tiles: "); |
| 1370 str->append(fStitchTiles ? "true " : "false "); | 1381 str->append(fStitchTiles ? "true " : "false "); |
| 1371 | 1382 |
| 1372 this->INHERITED::toString(str); | 1383 this->INHERITED::toString(str); |
| 1373 | 1384 |
| 1374 str->append(")"); | 1385 str->append(")"); |
| 1375 } | 1386 } |
| 1376 #endif | 1387 #endif |
| OLD | NEW |