OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkGradientShaderPriv.h" | 8 #include "SkGradientShaderPriv.h" |
9 #include "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" |
10 #include "SkRadialGradient.h" | 10 #include "SkRadialGradient.h" |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 } | 948 } |
949 | 949 |
950 void GrGradientEffect::getConstantColorComponents(GrColor* color, uint32_t* vali
dFlags) const { | 950 void GrGradientEffect::getConstantColorComponents(GrColor* color, uint32_t* vali
dFlags) const { |
951 if (fIsOpaque && (kA_GrColorComponentFlag & *validFlags) && 0xff == GrColorU
npackA(*color)) { | 951 if (fIsOpaque && (kA_GrColorComponentFlag & *validFlags) && 0xff == GrColorU
npackA(*color)) { |
952 *validFlags = kA_GrColorComponentFlag; | 952 *validFlags = kA_GrColorComponentFlag; |
953 } else { | 953 } else { |
954 *validFlags = 0; | 954 *validFlags = 0; |
955 } | 955 } |
956 } | 956 } |
957 | 957 |
958 int GrGradientEffect::RandomGradientParams(SkMWCRandom* random, | 958 int GrGradientEffect::RandomGradientParams(SkRandom* random, |
959 SkColor colors[], | 959 SkColor colors[], |
960 SkScalar** stops, | 960 SkScalar** stops, |
961 SkShader::TileMode* tm) { | 961 SkShader::TileMode* tm) { |
962 int outColors = random->nextRangeU(1, kMaxRandomGradientColors); | 962 int outColors = random->nextRangeU(1, kMaxRandomGradientColors); |
963 | 963 |
964 // if one color, omit stops, otherwise randomly decide whether or not to | 964 // if one color, omit stops, otherwise randomly decide whether or not to |
965 if (outColors == 1 || (outColors >= 2 && random->nextBool())) { | 965 if (outColors == 1 || (outColors >= 2 && random->nextBool())) { |
966 *stops = NULL; | 966 *stops = NULL; |
967 } | 967 } |
968 | 968 |
969 SkScalar stop = 0.f; | 969 SkScalar stop = 0.f; |
970 for (int i = 0; i < outColors; ++i) { | 970 for (int i = 0; i < outColors; ++i) { |
971 colors[i] = random->nextU(); | 971 colors[i] = random->nextU(); |
972 if (NULL != *stops) { | 972 if (NULL != *stops) { |
973 (*stops)[i] = stop; | 973 (*stops)[i] = stop; |
974 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 974 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
975 } | 975 } |
976 } | 976 } |
977 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 977 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
978 | 978 |
979 return outColors; | 979 return outColors; |
980 } | 980 } |
981 | 981 |
982 #endif | 982 #endif |
OLD | NEW |