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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 | 838 |
839 bool flipGradient = startRadius > endRadius; | 839 bool flipGradient = startRadius > endRadius; |
840 | 840 |
841 SkGradientShaderBase::Descriptor desc; | 841 SkGradientShaderBase::Descriptor desc; |
842 | 842 |
843 if (!flipGradient) { | 843 if (!flipGradient) { |
844 desc_init(&desc, opt.fColors, opt.fPos, opt.fCount, mode, flags, localMa
trix); | 844 desc_init(&desc, opt.fColors, opt.fPos, opt.fCount, mode, flags, localMa
trix); |
845 return sk_make_sp<SkTwoPointConicalGradient>(start, startRadius, end, en
dRadius, | 845 return sk_make_sp<SkTwoPointConicalGradient>(start, startRadius, end, en
dRadius, |
846 flipGradient, desc); | 846 flipGradient, desc); |
847 } else { | 847 } else { |
848 SkAutoSTArray<8, SkColor> colorsNew(colorCount); | 848 SkAutoSTArray<8, SkColor> colorsNew(opt.fCount); |
849 SkAutoSTArray<8, SkScalar> posNew(colorCount); | 849 SkAutoSTArray<8, SkScalar> posNew(opt.fCount); |
850 for (int i = 0; i < colorCount; ++i) { | 850 for (int i = 0; i < opt.fCount; ++i) { |
851 colorsNew[i] = opt.fColors[colorCount - i - 1]; | 851 colorsNew[i] = opt.fColors[opt.fCount - i - 1]; |
852 } | 852 } |
853 | 853 |
854 if (pos) { | 854 if (pos) { |
855 for (int i = 0; i < colorCount; ++i) { | 855 for (int i = 0; i < opt.fCount; ++i) { |
856 posNew[i] = 1 - opt.fPos[colorCount - i - 1]; | 856 posNew[i] = 1 - opt.fPos[opt.fCount - i - 1]; |
857 } | 857 } |
858 desc_init(&desc, colorsNew.get(), posNew.get(), colorCount, mode, fl
ags, localMatrix); | 858 desc_init(&desc, colorsNew.get(), posNew.get(), opt.fCount, mode, fl
ags, localMatrix); |
859 } else { | 859 } else { |
860 desc_init(&desc, colorsNew.get(), nullptr, colorCount, mode, flags,
localMatrix); | 860 desc_init(&desc, colorsNew.get(), nullptr, opt.fCount, mode, flags,
localMatrix); |
861 } | 861 } |
862 | 862 |
863 return sk_make_sp<SkTwoPointConicalGradient>(end, endRadius, start, star
tRadius, | 863 return sk_make_sp<SkTwoPointConicalGradient>(end, endRadius, start, star
tRadius, |
864 flipGradient, desc); | 864 flipGradient, desc); |
865 } | 865 } |
866 } | 866 } |
867 | 867 |
868 sk_sp<SkShader> SkGradientShader::MakeSweep(SkScalar cx, SkScalar cy, | 868 sk_sp<SkShader> SkGradientShader::MakeSweep(SkScalar cx, SkScalar cy, |
869 const SkColor colors[], | 869 const SkColor colors[], |
870 const SkScalar pos[], | 870 const SkScalar pos[], |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 (*stops)[i] = stop; | 1508 (*stops)[i] = stop; |
1509 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1509 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
1510 } | 1510 } |
1511 } | 1511 } |
1512 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1512 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
1513 | 1513 |
1514 return outColors; | 1514 return outColors; |
1515 } | 1515 } |
1516 | 1516 |
1517 #endif | 1517 #endif |
OLD | NEW |