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

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

Issue 1756573002: [Reland] Fix SkTwoPointConicalGradient zero-radius handling (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: avoid all-zero radius instantiation Created 4 years, 9 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/SkTwoPointConicalGradient.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 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 int colorCount, 833 int colorCount,
834 SkShader::TileMode mode, 834 SkShader::TileMode mode,
835 uint32_t flags, 835 uint32_t flags,
836 const SkMatrix* localMatrix) { 836 const SkMatrix* localMatrix) {
837 if (startRadius < 0 || endRadius < 0) { 837 if (startRadius < 0 || endRadius < 0) {
838 return nullptr; 838 return nullptr;
839 } 839 }
840 if (!valid_grad(colors, pos, colorCount, mode)) { 840 if (!valid_grad(colors, pos, colorCount, mode)) {
841 return nullptr; 841 return nullptr;
842 } 842 }
843 if (start == end && startRadius == endRadius) { 843 if (startRadius == endRadius) {
844 return SkShader::CreateEmptyShader(); 844 if (start == end || startRadius == 0) {
845 return SkShader::CreateEmptyShader();
846 }
845 } 847 }
846 848
847 EXPAND_1_COLOR(colorCount); 849 EXPAND_1_COLOR(colorCount);
848 850
849 bool flipGradient = startRadius > endRadius; 851 bool flipGradient = startRadius > endRadius;
850 852
851 SkGradientShaderBase::Descriptor desc; 853 SkGradientShaderBase::Descriptor desc;
852 854
853 if (!flipGradient) { 855 if (!flipGradient) {
854 desc_init(&desc, colors, pos, colorCount, mode, flags, localMatrix); 856 desc_init(&desc, colors, pos, colorCount, mode, flags, localMatrix);
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 (*stops)[i] = stop; 1206 (*stops)[i] = stop;
1205 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1207 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1206 } 1208 }
1207 } 1209 }
1208 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1210 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1209 1211
1210 return outColors; 1212 return outColors;
1211 } 1213 }
1212 1214
1213 #endif 1215 #endif
OLDNEW
« no previous file with comments | « no previous file | src/effects/gradients/SkTwoPointConicalGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698