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 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 | 1151 |
1152 SkASSERT(this->useAtlas() == s.useAtlas()); | 1152 SkASSERT(this->useAtlas() == s.useAtlas()); |
1153 return true; | 1153 return true; |
1154 } | 1154 } |
1155 | 1155 |
1156 return false; | 1156 return false; |
1157 } | 1157 } |
1158 | 1158 |
1159 void GrGradientEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ | 1159 void GrGradientEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
1160 if (fIsOpaque) { | 1160 if (fIsOpaque) { |
1161 inout->mulByUnknownOpaqueColor(); | 1161 inout->mulByUnknownOpaqueFourComponents(); |
1162 } else { | 1162 } else { |
1163 inout->mulByUnknownColor(); | 1163 inout->mulByUnknownFourComponents(); |
1164 } | 1164 } |
1165 } | 1165 } |
1166 | 1166 |
1167 int GrGradientEffect::RandomGradientParams(SkRandom* random, | 1167 int GrGradientEffect::RandomGradientParams(SkRandom* random, |
1168 SkColor colors[], | 1168 SkColor colors[], |
1169 SkScalar** stops, | 1169 SkScalar** stops, |
1170 SkShader::TileMode* tm) { | 1170 SkShader::TileMode* tm) { |
1171 int outColors = random->nextRangeU(1, kMaxRandomGradientColors); | 1171 int outColors = random->nextRangeU(1, kMaxRandomGradientColors); |
1172 | 1172 |
1173 // if one color, omit stops, otherwise randomly decide whether or not to | 1173 // if one color, omit stops, otherwise randomly decide whether or not to |
1174 if (outColors == 1 || (outColors >= 2 && random->nextBool())) { | 1174 if (outColors == 1 || (outColors >= 2 && random->nextBool())) { |
1175 *stops = NULL; | 1175 *stops = NULL; |
1176 } | 1176 } |
1177 | 1177 |
1178 SkScalar stop = 0.f; | 1178 SkScalar stop = 0.f; |
1179 for (int i = 0; i < outColors; ++i) { | 1179 for (int i = 0; i < outColors; ++i) { |
1180 colors[i] = random->nextU(); | 1180 colors[i] = random->nextU(); |
1181 if (*stops) { | 1181 if (*stops) { |
1182 (*stops)[i] = stop; | 1182 (*stops)[i] = stop; |
1183 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1183 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
1184 } | 1184 } |
1185 } | 1185 } |
1186 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1186 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
1187 | 1187 |
1188 return outColors; | 1188 return outColors; |
1189 } | 1189 } |
1190 | 1190 |
1191 #endif | 1191 #endif |
OLD | NEW |