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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
954 | 954 |
955 SkMatrix localMatrix = this->getLocalMatrix(); | 955 SkMatrix localMatrix = this->getLocalMatrix(); |
956 if (externalLocalMatrix) { | 956 if (externalLocalMatrix) { |
957 localMatrix.preConcat(*externalLocalMatrix); | 957 localMatrix.preConcat(*externalLocalMatrix); |
958 } | 958 } |
959 | 959 |
960 SkMatrix matrix = viewM; | 960 SkMatrix matrix = viewM; |
961 matrix.preConcat(localMatrix); | 961 matrix.preConcat(localMatrix); |
962 | 962 |
963 if (0 == fNumOctaves) { | 963 if (0 == fNumOctaves) { |
964 SkColor clearColor = 0; | |
965 if (kFractalNoise_Type == fType) { | 964 if (kFractalNoise_Type == fType) { |
966 clearColor = SkColorSetARGB(paint.getAlpha() / 2, 127, 127, 127); | 965 uint32_t alpha = paint.getAlpha() >> 1; |
967 } | 966 #if 1 |
968 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter( | 967 uint32_t rgb = SkMulDiv255Round(alpha, 127); |
969 clearColor, SkXfermode::kSrc_Mod e)); | 968 #else |
970 SkTDArray<GrFragmentProcessor*> array; | 969 uint32_t rgb = alpha >> 1; |
bsalomon
2015/03/04 04:57:23
Can I get away with this?
sugoi1
2015/03/04 15:53:53
I don't see why not, this should be fine.
| |
971 if (cf->asFragmentProcessors(context, &array)) { | 970 #endif |
972 SkASSERT(1 == array.count()); // modecolorfilter only returns one | 971 *paintColor = GrColorPackRGBA(rgb, rgb, rgb, alpha); |
973 *fp = array[0]; // transfer ownership to fp | 972 } else { |
973 *paintColor = 0; | |
974 } | 974 } |
975 return true; | 975 return true; |
976 } | 976 } |
977 | 977 |
978 // Either we don't stitch tiles, either we have a valid tile size | 978 // Either we don't stitch tiles, either we have a valid tile size |
979 SkASSERT(!fStitchTiles || !fTileSize.isEmpty()); | 979 SkASSERT(!fStitchTiles || !fTileSize.isEmpty()); |
980 | 980 |
981 SkPerlinNoiseShader::PaintingData* paintingData = | 981 SkPerlinNoiseShader::PaintingData* paintingData = |
982 SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFr equencyY, matrix)); | 982 SkNEW_ARGS(PaintingData, (fTileSize, fSeed, fBaseFrequencyX, fBaseFr equencyY, matrix)); |
983 SkAutoTUnref<GrTexture> permutationsTexture( | 983 SkAutoTUnref<GrTexture> permutationsTexture( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1038 str->append(" seed: "); | 1038 str->append(" seed: "); |
1039 str->appendScalar(fSeed); | 1039 str->appendScalar(fSeed); |
1040 str->append(" stitch tiles: "); | 1040 str->append(" stitch tiles: "); |
1041 str->append(fStitchTiles ? "true " : "false "); | 1041 str->append(fStitchTiles ? "true " : "false "); |
1042 | 1042 |
1043 this->INHERITED::toString(str); | 1043 this->INHERITED::toString(str); |
1044 | 1044 |
1045 str->append(")"); | 1045 str->append(")"); |
1046 } | 1046 } |
1047 #endif | 1047 #endif |
OLD | NEW |