Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: src/effects/gradients/SkGradientShader.cpp

Issue 23576015: Change old PRG to be SkLCGRandom; change new one to SkRandom (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix some spurious SkMWCRandoms Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698