OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |