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