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

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

Issue 1974463002: Harden linear gradients (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: remove unneeded 1-color veto Created 4 years, 7 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 | « no previous file | src/effects/gradients/SkLinearGradient.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 "Sk4fLinearGradient.h" 8 #include "Sk4fLinearGradient.h"
9 #include "SkGradientShaderPriv.h" 9 #include "SkGradientShaderPriv.h"
10 #include "SkLinearGradient.h" 10 #include "SkLinearGradient.h"
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 tmp[0] = tmp[1] = colors[0]; \ 767 tmp[0] = tmp[1] = colors[0]; \
768 colors = tmp; \ 768 colors = tmp; \
769 pos = nullptr; \ 769 pos = nullptr; \
770 count = 2; \ 770 count = 2; \
771 } \ 771 } \
772 } while (0) 772 } while (0)
773 773
774 static void desc_init(SkGradientShaderBase::Descriptor* desc, 774 static void desc_init(SkGradientShaderBase::Descriptor* desc,
775 const SkColor colors[], const SkScalar pos[], int colorCou nt, 775 const SkColor colors[], const SkScalar pos[], int colorCou nt,
776 SkShader::TileMode mode, uint32_t flags, const SkMatrix* l ocalMatrix) { 776 SkShader::TileMode mode, uint32_t flags, const SkMatrix* l ocalMatrix) {
777 SkASSERT(colorCount > 1);
778
777 desc->fColors = colors; 779 desc->fColors = colors;
778 desc->fPos = pos; 780 desc->fPos = pos;
779 desc->fCount = colorCount; 781 desc->fCount = colorCount;
780 desc->fTileMode = mode; 782 desc->fTileMode = mode;
781 desc->fGradFlags = flags; 783 desc->fGradFlags = flags;
782 desc->fLocalMatrix = localMatrix; 784 desc->fLocalMatrix = localMatrix;
783 } 785 }
784 786
785 sk_sp<SkShader> SkGradientShader::MakeLinear(const SkPoint pts[2], 787 sk_sp<SkShader> SkGradientShader::MakeLinear(const SkPoint pts[2],
786 const SkColor colors[], 788 const SkColor colors[],
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 (*stops)[i] = stop; 1205 (*stops)[i] = stop;
1204 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1206 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1205 } 1207 }
1206 } 1208 }
1207 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1209 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1208 1210
1209 return outColors; 1211 return outColors;
1210 } 1212 }
1211 1213
1212 #endif 1214 #endif
OLDNEW
« no previous file with comments | « no previous file | src/effects/gradients/SkLinearGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698