| 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" | |
| 9 #include "SkPerlinNoiseShader.h" | 8 #include "SkPerlinNoiseShader.h" |
| 10 #include "SkColorFilter.h" | 9 #include "SkColorFilter.h" |
| 11 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
| 12 #include "SkWriteBuffer.h" | 11 #include "SkWriteBuffer.h" |
| 13 #include "SkShader.h" | 12 #include "SkShader.h" |
| 14 #include "SkUnPreMultiply.h" | 13 #include "SkUnPreMultiply.h" |
| 15 #include "SkString.h" | 14 #include "SkString.h" |
| 16 | 15 |
| 17 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
| 18 #include "GrContext.h" | 17 #include "GrContext.h" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 void SkPerlinNoiseShader::PerlinNoiseShaderContext::shadeSpan( | 459 void SkPerlinNoiseShader::PerlinNoiseShaderContext::shadeSpan( |
| 461 int x, int y, SkPMColor result[], int count) { | 460 int x, int y, SkPMColor result[], int count) { |
| 462 SkPoint point = SkPoint::Make(SkIntToScalar(x), SkIntToScalar(y)); | 461 SkPoint point = SkPoint::Make(SkIntToScalar(x), SkIntToScalar(y)); |
| 463 StitchData stitchData; | 462 StitchData stitchData; |
| 464 for (int i = 0; i < count; ++i) { | 463 for (int i = 0; i < count; ++i) { |
| 465 result[i] = shade(point, stitchData); | 464 result[i] = shade(point, stitchData); |
| 466 point.fX += SK_Scalar1; | 465 point.fX += SK_Scalar1; |
| 467 } | 466 } |
| 468 } | 467 } |
| 469 | 468 |
| 470 void SkPerlinNoiseShader::PerlinNoiseShaderContext::shadeSpan16( | |
| 471 int x, int y, uint16_t result[], int count) { | |
| 472 SkPoint point = SkPoint::Make(SkIntToScalar(x), SkIntToScalar(y)); | |
| 473 StitchData stitchData; | |
| 474 DITHER_565_SCAN(y); | |
| 475 for (int i = 0; i < count; ++i) { | |
| 476 unsigned dither = DITHER_VALUE(x); | |
| 477 result[i] = SkDitherRGB32To565(shade(point, stitchData), dither); | |
| 478 DITHER_INC_X(x); | |
| 479 point.fX += SK_Scalar1; | |
| 480 } | |
| 481 } | |
| 482 | |
| 483 ///////////////////////////////////////////////////////////////////// | 469 ///////////////////////////////////////////////////////////////////// |
| 484 | 470 |
| 485 #if SK_SUPPORT_GPU | 471 #if SK_SUPPORT_GPU |
| 486 | 472 |
| 487 class GrGLPerlinNoise : public GrGLSLFragmentProcessor { | 473 class GrGLPerlinNoise : public GrGLSLFragmentProcessor { |
| 488 public: | 474 public: |
| 489 GrGLPerlinNoise(const GrProcessor&); | 475 GrGLPerlinNoise(const GrProcessor&); |
| 490 virtual ~GrGLPerlinNoise() {} | 476 virtual ~GrGLPerlinNoise() {} |
| 491 | 477 |
| 492 virtual void emitCode(EmitArgs&) override; | 478 virtual void emitCode(EmitArgs&) override; |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 str->append(" seed: "); | 982 str->append(" seed: "); |
| 997 str->appendScalar(fSeed); | 983 str->appendScalar(fSeed); |
| 998 str->append(" stitch tiles: "); | 984 str->append(" stitch tiles: "); |
| 999 str->append(fStitchTiles ? "true " : "false "); | 985 str->append(fStitchTiles ? "true " : "false "); |
| 1000 | 986 |
| 1001 this->INHERITED::toString(str); | 987 this->INHERITED::toString(str); |
| 1002 | 988 |
| 1003 str->append(")"); | 989 str->append(")"); |
| 1004 } | 990 } |
| 1005 #endif | 991 #endif |
| OLD | NEW |