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