| 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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 desc->fGradFlags = flags; | 783 desc->fGradFlags = flags; |
| 784 desc->fLocalMatrix = localMatrix; | 784 desc->fLocalMatrix = localMatrix; |
| 785 } | 785 } |
| 786 | 786 |
| 787 sk_sp<SkShader> SkGradientShader::MakeLinear(const SkPoint pts[2], | 787 sk_sp<SkShader> SkGradientShader::MakeLinear(const SkPoint pts[2], |
| 788 const SkColor colors[], | 788 const SkColor colors[], |
| 789 const SkScalar pos[], int colorCount, | 789 const SkScalar pos[], int colorCount, |
| 790 SkShader::TileMode mode, | 790 SkShader::TileMode mode, |
| 791 uint32_t flags, | 791 uint32_t flags, |
| 792 const SkMatrix* localMatrix) { | 792 const SkMatrix* localMatrix) { |
| 793 if (!pts) { | 793 if (!pts || !SkScalarIsFinite((pts[1] - pts[0]).length())) { |
| 794 return nullptr; | 794 return nullptr; |
| 795 } | 795 } |
| 796 if (!valid_grad(colors, pos, colorCount, mode)) { | 796 if (!valid_grad(colors, pos, colorCount, mode)) { |
| 797 return nullptr; | 797 return nullptr; |
| 798 } | 798 } |
| 799 EXPAND_1_COLOR(colorCount); | 799 EXPAND_1_COLOR(colorCount); |
| 800 | 800 |
| 801 SkGradientShaderBase::Descriptor desc; | 801 SkGradientShaderBase::Descriptor desc; |
| 802 desc_init(&desc, colors, pos, colorCount, mode, flags, localMatrix); | 802 desc_init(&desc, colors, pos, colorCount, mode, flags, localMatrix); |
| 803 return sk_make_sp<SkLinearGradient>(pts, desc); | 803 return sk_make_sp<SkLinearGradient>(pts, desc); |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 (*stops)[i] = stop; | 1208 (*stops)[i] = stop; |
| 1209 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1209 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
| 1210 } | 1210 } |
| 1211 } | 1211 } |
| 1212 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1212 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
| 1213 | 1213 |
| 1214 return outColors; | 1214 return outColors; |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 #endif | 1217 #endif |
| OLD | NEW |