| 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 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 fTextureAccess.getParams().getTileModeX() == | 1206 fTextureAccess.getParams().getTileModeX() == |
| 1207 s.fTextureAccess.getParams().getTileModeX() && | 1207 s.fTextureAccess.getParams().getTileModeX() && |
| 1208 this->useAtlas() == s.useAtlas() && | 1208 this->useAtlas() == s.useAtlas() && |
| 1209 fCoordTransform.getMatrix().cheapEqualTo(s.fCoordTransform.getMatrix
()); | 1209 fCoordTransform.getMatrix().cheapEqualTo(s.fCoordTransform.getMatrix
()); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 return false; | 1212 return false; |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 void GrGradientEffect::onComputeInvariantOutput(InvariantOutput* inout) const { | 1215 void GrGradientEffect::onComputeInvariantOutput(InvariantOutput* inout) const { |
| 1216 if (fIsOpaque && inout->isOpaque()) { | 1216 if (fIsOpaque) { |
| 1217 inout->fValidFlags = kA_GrColorComponentFlag; | 1217 inout->mulByUnknownOpaqueColor(); |
| 1218 } else { | 1218 } else { |
| 1219 inout->fValidFlags = 0; | 1219 inout->mulByUnknownColor(); |
| 1220 } | 1220 } |
| 1221 inout->fIsSingleComponent = false; | |
| 1222 } | 1221 } |
| 1223 | 1222 |
| 1224 int GrGradientEffect::RandomGradientParams(SkRandom* random, | 1223 int GrGradientEffect::RandomGradientParams(SkRandom* random, |
| 1225 SkColor colors[], | 1224 SkColor colors[], |
| 1226 SkScalar** stops, | 1225 SkScalar** stops, |
| 1227 SkShader::TileMode* tm) { | 1226 SkShader::TileMode* tm) { |
| 1228 int outColors = random->nextRangeU(1, kMaxRandomGradientColors); | 1227 int outColors = random->nextRangeU(1, kMaxRandomGradientColors); |
| 1229 | 1228 |
| 1230 // if one color, omit stops, otherwise randomly decide whether or not to | 1229 // if one color, omit stops, otherwise randomly decide whether or not to |
| 1231 if (outColors == 1 || (outColors >= 2 && random->nextBool())) { | 1230 if (outColors == 1 || (outColors >= 2 && random->nextBool())) { |
| 1232 *stops = NULL; | 1231 *stops = NULL; |
| 1233 } | 1232 } |
| 1234 | 1233 |
| 1235 SkScalar stop = 0.f; | 1234 SkScalar stop = 0.f; |
| 1236 for (int i = 0; i < outColors; ++i) { | 1235 for (int i = 0; i < outColors; ++i) { |
| 1237 colors[i] = random->nextU(); | 1236 colors[i] = random->nextU(); |
| 1238 if (*stops) { | 1237 if (*stops) { |
| 1239 (*stops)[i] = stop; | 1238 (*stops)[i] = stop; |
| 1240 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1239 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
| 1241 } | 1240 } |
| 1242 } | 1241 } |
| 1243 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1242 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
| 1244 | 1243 |
| 1245 return outColors; | 1244 return outColors; |
| 1246 } | 1245 } |
| 1247 | 1246 |
| 1248 #endif | 1247 #endif |
| OLD | NEW |