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

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

Issue 643743003: Create helper functions to use in computeInvariantOutput calls (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update blurMaskFilter Created 6 years, 2 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
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('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 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698