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

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

Issue 2349153004: Harden LinearGradient4fContext (Closed)
Patch Set: Created 4 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
« no previous file with comments | « src/effects/gradients/Sk4fLinearGradient.cpp ('k') | no next file » | 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 "Sk4fLinearGradient.h" 8 #include "Sk4fLinearGradient.h"
9 #include "SkGradientShaderPriv.h" 9 #include "SkGradientShaderPriv.h"
10 #include "SkLinearGradient.h" 10 #include "SkLinearGradient.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 //////////////////////////////////////////////////////////////////////////////// //////////// 70 //////////////////////////////////////////////////////////////////////////////// ////////////
71 71
72 SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc, const SkMatri x& ptsToUnit) 72 SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc, const SkMatri x& ptsToUnit)
73 : INHERITED(desc.fLocalMatrix) 73 : INHERITED(desc.fLocalMatrix)
74 , fPtsToUnit(ptsToUnit) 74 , fPtsToUnit(ptsToUnit)
75 { 75 {
76 fPtsToUnit.getType(); // Precache so reads are threadsafe. 76 fPtsToUnit.getType(); // Precache so reads are threadsafe.
77 SkASSERT(desc.fCount > 1); 77 SkASSERT(desc.fCount > 1);
78 78
79 fGradFlags = SkToU8(desc.fGradFlags); 79 fGradFlags = static_cast<uint8_t>(desc.fGradFlags);
80 80
81 SkASSERT((unsigned)desc.fTileMode < SkShader::kTileModeCount); 81 SkASSERT((unsigned)desc.fTileMode < SkShader::kTileModeCount);
82 SkASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gTileProcs)); 82 SkASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gTileProcs));
83 fTileMode = desc.fTileMode; 83 fTileMode = desc.fTileMode;
84 fTileProc = gTileProcs[desc.fTileMode]; 84 fTileProc = gTileProcs[desc.fTileMode];
85 85
86 /* Note: we let the caller skip the first and/or last position. 86 /* Note: we let the caller skip the first and/or last position.
87 i.e. pos[0] = 0.3, pos[1] = 0.7 87 i.e. pos[0] = 0.3, pos[1] = 0.7
88 In these cases, we insert dummy entries to ensure that the final data 88 In these cases, we insert dummy entries to ensure that the final data
89 will be bracketed by [0, 1]. 89 will be bracketed by [0, 1].
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 (*stops)[i] = stop; 1508 (*stops)[i] = stop;
1509 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1509 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1510 } 1510 }
1511 } 1511 }
1512 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1512 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1513 1513
1514 return outColors; 1514 return outColors;
1515 } 1515 }
1516 1516
1517 #endif 1517 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/Sk4fLinearGradient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698