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 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 | 883 |
884 bool flipGradient = startRadius > endRadius; | 884 bool flipGradient = startRadius > endRadius; |
885 | 885 |
886 SkGradientShaderBase::Descriptor desc; | 886 SkGradientShaderBase::Descriptor desc; |
887 | 887 |
888 if (!flipGradient) { | 888 if (!flipGradient) { |
889 desc_init(&desc, opt.fColors, opt.fPos, opt.fCount, mode, flags, localMa
trix); | 889 desc_init(&desc, opt.fColors, opt.fPos, opt.fCount, mode, flags, localMa
trix); |
890 return sk_make_sp<SkTwoPointConicalGradient>(start, startRadius, end, en
dRadius, | 890 return sk_make_sp<SkTwoPointConicalGradient>(start, startRadius, end, en
dRadius, |
891 flipGradient, desc); | 891 flipGradient, desc); |
892 } else { | 892 } else { |
893 SkAutoSTArray<8, SkColor> colorsNew(colorCount); | 893 SkAutoSTArray<8, SkColor> colorsNew(opt.fCount); |
894 SkAutoSTArray<8, SkScalar> posNew(colorCount); | 894 SkAutoSTArray<8, SkScalar> posNew(opt.fCount); |
895 for (int i = 0; i < colorCount; ++i) { | 895 for (int i = 0; i < opt.fCount; ++i) { |
896 colorsNew[i] = opt.fColors[colorCount - i - 1]; | 896 colorsNew[i] = opt.fColors[opt.fCount - i - 1]; |
897 } | 897 } |
898 | 898 |
899 if (pos) { | 899 if (pos) { |
900 for (int i = 0; i < colorCount; ++i) { | 900 for (int i = 0; i < opt.fCount; ++i) { |
901 posNew[i] = 1 - opt.fPos[colorCount - i - 1]; | 901 posNew[i] = 1 - opt.fPos[opt.fCount - i - 1]; |
902 } | 902 } |
903 desc_init(&desc, colorsNew.get(), posNew.get(), colorCount, mode, fl
ags, localMatrix); | 903 desc_init(&desc, colorsNew.get(), posNew.get(), opt.fCount, mode, fl
ags, localMatrix); |
904 } else { | 904 } else { |
905 desc_init(&desc, colorsNew.get(), nullptr, colorCount, mode, flags,
localMatrix); | 905 desc_init(&desc, colorsNew.get(), nullptr, opt.fCount, mode, flags,
localMatrix); |
906 } | 906 } |
907 | 907 |
908 return sk_make_sp<SkTwoPointConicalGradient>(end, endRadius, start, star
tRadius, | 908 return sk_make_sp<SkTwoPointConicalGradient>(end, endRadius, start, star
tRadius, |
909 flipGradient, desc); | 909 flipGradient, desc); |
910 } | 910 } |
911 } | 911 } |
912 | 912 |
913 sk_sp<SkShader> SkGradientShader::MakeSweep(SkScalar cx, SkScalar cy, | 913 sk_sp<SkShader> SkGradientShader::MakeSweep(SkScalar cx, SkScalar cy, |
914 const SkColor colors[], | 914 const SkColor colors[], |
915 const SkScalar pos[], | 915 const SkScalar pos[], |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 (*stops)[i] = stop; | 1485 (*stops)[i] = stop; |
1486 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; | 1486 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st
op) : 1.f; |
1487 } | 1487 } |
1488 } | 1488 } |
1489 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); | 1489 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM
odeCount)); |
1490 | 1490 |
1491 return outColors; | 1491 return outColors; |
1492 } | 1492 } |
1493 | 1493 |
1494 #endif | 1494 #endif |
OLD | NEW |