| 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 "SkColorFilter.h" |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 615 |
| 616 SkShader* shader = random->nextBool() ? | 616 SkShader* shader = random->nextBool() ? |
| 617 SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY,
numOctaves, seed, | 617 SkPerlinNoiseShader::CreateFractalNoise(baseFrequencyX, baseFrequencyY,
numOctaves, seed, |
| 618 stitchTiles ? &tileSize : NULL)
: | 618 stitchTiles ? &tileSize : NULL)
: |
| 619 SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, nu
mOctaves, seed, | 619 SkPerlinNoiseShader::CreateTurbulence(baseFrequencyX, baseFrequencyY, nu
mOctaves, seed, |
| 620 stitchTiles ? &tileSize : NULL); | 620 stitchTiles ? &tileSize : NULL); |
| 621 | 621 |
| 622 SkPaint paint; | 622 SkPaint paint; |
| 623 GrColor paintColor; | 623 GrColor paintColor; |
| 624 GrFragmentProcessor* effect; | 624 GrFragmentProcessor* effect; |
| 625 GrPaint grPaint; |
| 625 SkAssertResult(shader->asFragmentProcessor(context, paint, | 626 SkAssertResult(shader->asFragmentProcessor(context, paint, |
| 626 GrTest::TestMatrix(random), NULL, | 627 GrTest::TestMatrix(random), NULL, |
| 627 &paintColor, &effect)); | 628 &paintColor, grPaint.getShaderDat
aManager(), |
| 629 &effect)); |
| 628 | 630 |
| 629 SkDELETE(shader); | 631 SkDELETE(shader); |
| 630 | 632 |
| 631 return effect; | 633 return effect; |
| 632 } | 634 } |
| 633 | 635 |
| 634 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) | 636 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) |
| 635 : fType(processor.cast<GrPerlinNoiseEffect>().type()) | 637 : fType(processor.cast<GrPerlinNoiseEffect>().type()) |
| 636 , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles()) | 638 , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles()) |
| 637 , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) { | 639 , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 pdman.set2f(fStitchDataUni, SkIntToScalar(stitchData.fWidth), | 938 pdman.set2f(fStitchDataUni, SkIntToScalar(stitchData.fWidth), |
| 937 SkIntToScalar(stitchData.fHeight)); | 939 SkIntToScalar(stitchData.fHeight)); |
| 938 } | 940 } |
| 939 } | 941 } |
| 940 | 942 |
| 941 ///////////////////////////////////////////////////////////////////// | 943 ///////////////////////////////////////////////////////////////////// |
| 942 | 944 |
| 943 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext* context, const SkPaint&
paint, | 945 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext* context, const SkPaint&
paint, |
| 944 const SkMatrix& viewM, | 946 const SkMatrix& viewM, |
| 945 const SkMatrix* externalLocalMatri
x, | 947 const SkMatrix* externalLocalMatri
x, |
| 946 GrColor* paintColor, GrFragmentPro
cessor** fp) const { | 948 GrColor* paintColor, GrShaderDataM
anager*, |
| 949 GrFragmentProcessor** fp) const { |
| 947 SkASSERT(context); | 950 SkASSERT(context); |
| 948 | 951 |
| 949 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); | 952 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); |
| 950 | 953 |
| 951 SkMatrix localMatrix = this->getLocalMatrix(); | 954 SkMatrix localMatrix = this->getLocalMatrix(); |
| 952 if (externalLocalMatrix) { | 955 if (externalLocalMatrix) { |
| 953 localMatrix.preConcat(*externalLocalMatrix); | 956 localMatrix.preConcat(*externalLocalMatrix); |
| 954 } | 957 } |
| 955 | 958 |
| 956 SkMatrix matrix = viewM; | 959 SkMatrix matrix = viewM; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 } else { | 993 } else { |
| 991 SkDELETE(paintingData); | 994 SkDELETE(paintingData); |
| 992 *fp = NULL; | 995 *fp = NULL; |
| 993 } | 996 } |
| 994 return true; | 997 return true; |
| 995 } | 998 } |
| 996 | 999 |
| 997 #else | 1000 #else |
| 998 | 1001 |
| 999 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext*, const SkPaint&, const
SkMatrix&, | 1002 bool SkPerlinNoiseShader::asFragmentProcessor(GrContext*, const SkPaint&, const
SkMatrix&, |
| 1000 const SkMatrix*, GrColor*, | 1003 const SkMatrix*, GrColor*, GrShade
rDataManager*, |
| 1001 GrFragmentProcessor**) const { | 1004 GrFragmentProcessor**) const { |
| 1002 SkDEBUGFAIL("Should not call in GPU-less build"); | 1005 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 1003 return false; | 1006 return false; |
| 1004 } | 1007 } |
| 1005 | 1008 |
| 1006 #endif | 1009 #endif |
| 1007 | 1010 |
| 1008 #ifndef SK_IGNORE_TO_STRING | 1011 #ifndef SK_IGNORE_TO_STRING |
| 1009 void SkPerlinNoiseShader::toString(SkString* str) const { | 1012 void SkPerlinNoiseShader::toString(SkString* str) const { |
| 1010 str->append("SkPerlinNoiseShader: ("); | 1013 str->append("SkPerlinNoiseShader: ("); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1030 str->append(" seed: "); | 1033 str->append(" seed: "); |
| 1031 str->appendScalar(fSeed); | 1034 str->appendScalar(fSeed); |
| 1032 str->append(" stitch tiles: "); | 1035 str->append(" stitch tiles: "); |
| 1033 str->append(fStitchTiles ? "true " : "false "); | 1036 str->append(fStitchTiles ? "true " : "false "); |
| 1034 | 1037 |
| 1035 this->INHERITED::toString(str); | 1038 this->INHERITED::toString(str); |
| 1036 | 1039 |
| 1037 str->append(")"); | 1040 str->append(")"); |
| 1038 } | 1041 } |
| 1039 #endif | 1042 #endif |
| OLD | NEW |