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

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

Issue 793763003: Gradient shaders: make fPtsToUnit const, pre-cache getType(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « no previous file | 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 fLocalMatrix = &fLocalMatrixStorage; 60 fLocalMatrix = &fLocalMatrixStorage;
61 buffer.readMatrix(&fLocalMatrixStorage); 61 buffer.readMatrix(&fLocalMatrixStorage);
62 } else { 62 } else {
63 fLocalMatrix = NULL; 63 fLocalMatrix = NULL;
64 } 64 }
65 return buffer.isValid(); 65 return buffer.isValid();
66 } 66 }
67 67
68 //////////////////////////////////////////////////////////////////////////////// //////////// 68 //////////////////////////////////////////////////////////////////////////////// ////////////
69 69
70 SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc) 70 SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc, const SkMatri x& ptsToUnit)
71 : INHERITED(desc.fLocalMatrix) 71 : INHERITED(desc.fLocalMatrix)
72 , fPtsToUnit(ptsToUnit)
72 { 73 {
74 fPtsToUnit.getType(); // Precache so reads are threadsafe.
73 SkASSERT(desc.fCount > 1); 75 SkASSERT(desc.fCount > 1);
74 76
75 fGradFlags = SkToU8(desc.fGradFlags); 77 fGradFlags = SkToU8(desc.fGradFlags);
76 78
77 SkASSERT((unsigned)desc.fTileMode < SkShader::kTileModeCount); 79 SkASSERT((unsigned)desc.fTileMode < SkShader::kTileModeCount);
78 SkASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gTileProcs)); 80 SkASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gTileProcs));
79 fTileMode = desc.fTileMode; 81 fTileMode = desc.fTileMode;
80 fTileProc = gTileProcs[desc.fTileMode]; 82 fTileProc = gTileProcs[desc.fTileMode];
81 83
82 /* Note: we let the caller skip the first and/or last position. 84 /* Note: we let the caller skip the first and/or last position.
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 (*stops)[i] = stop; 1182 (*stops)[i] = stop;
1181 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1183 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1182 } 1184 }
1183 } 1185 }
1184 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1186 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1185 1187
1186 return outColors; 1188 return outColors;
1187 } 1189 }
1188 1190
1189 #endif 1191 #endif
OLDNEW
« no previous file with comments | « no previous file | src/effects/gradients/SkGradientShaderPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698