862 {
863
864
865 std::unique_ptr<GrFragmentProcessor>
fp;
871 "uniform half r0_2;"
872 "half4 main(float2 p) {"
873
874 "half v = 1;"
875 "float t = r0_2 - p.y * p.y;"
876 "if (t >= 0) {"
877 "t = p.x + sqrt(t);"
878 "} else {"
879 "v = -1;"
880 "}"
881 "return half4(half(t), v, 0, 0);"
882 "}"
883 );
886 "TwoPointConicalStripLayout",
887 nullptr,
889 "r0_2",
890 r0 * r0);
891 } break;
892
896 "uniform half r0;"
897 "uniform half lengthScale;"
898 "half4 main(float2 p) {"
899
900 "half v = 1;"
901 "float t = length(p) * lengthScale - r0;"
902 "return half4(half(t), v, 0, 0);"
903 "}"
904 );
907 bool isRadiusIncreasing =
dr >= 0;
909 "TwoPointConicalRadialLayout",
910 nullptr,
912 "r0",
913 r0,
914 "lengthScale",
915 isRadiusIncreasing ? 1.0f : -1.0f);
916
917
918
919
920
923
925 } break;
926
930
931 "uniform int isRadiusIncreasing;"
932 "uniform int isFocalOnCircle;"
933 "uniform int isWellBehaved;"
934 "uniform int isSwapped;"
935 "uniform int isNativelyFocal;"
936
937 "uniform half invR1;"
938 "uniform half fx;"
939
940 "half4 main(float2 p) {"
941 "float t = -1;"
942 "half v = 1;"
943
944 "float x_t = -1;"
945 "if (bool(isFocalOnCircle)) {"
946 "x_t = dot(p, p) / p.x;"
947 "} else if (bool(isWellBehaved)) {"
948 "x_t = length(p) - p.x * invR1;"
949 "} else {"
950 "float temp = p.x * p.x - p.y * p.y;"
951
952
953
954
955
956
957
958
959
960 "if (temp >= 0) {"
961 "if (bool(isSwapped) || !bool(isRadiusIncreasing)) {"
962 "x_t = -sqrt(temp) - p.x * invR1;"
963 "} else {"
964 "x_t = sqrt(temp) - p.x * invR1;"
965 "}"
966 "}"
967 "}"
968
969
970
971
972 "if (!bool(isWellBehaved)) {"
973
974
975 "if (x_t <= 0.0) {"
976 "v = -1;"
977 "}"
978 "}"
979 "if (bool(isRadiusIncreasing)) {"
980 "if (bool(isNativelyFocal)) {"
981 "t = x_t;"
982 "} else {"
983 "t = x_t + fx;"
984 "}"
985 "} else {"
986 "if (bool(isNativelyFocal)) {"
987 "t = -x_t;"
988 "} else {"
989 "t = -x_t + fx;"
990 "}"
991 "}"
992
993 "if (bool(isSwapped)) {"
994 "t = 1 - t;"
995 "}"
996
997 "return half4(half(t), v, 0, 0);"
998 "}"
999 );
1000
1002 bool isRadiusIncreasing = (1 - focalData.
fFocalX) > 0,
1006
1009 "isRadiusIncreasing", GrSkSLFP::Specialize<int>(isRadiusIncreasing),
1010 "isFocalOnCircle", GrSkSLFP::Specialize<int>(isFocalOnCircle),
1011 "isWellBehaved", GrSkSLFP::Specialize<int>(isWellBehaved),
1012 "isSwapped", GrSkSLFP::Specialize<int>(isSwapped),
1013 "isNativelyFocal", GrSkSLFP::Specialize<int>(isNativelyFocal),
1014 "invR1", 1.0f / focalData.
fR1,
1016 } break;
1017 }
1019 *shader,
args, mRec, std::move(
fp),
matrix.getMaybeNull());
1020}
const SkPoint & getStartCenter() const
SkScalar getDiffRadius() const
SkScalar getCenterX1() const
SkScalar getStartRadius() const
const FocalData & getFocalData() const
static SkMatrix Translate(SkScalar dx, SkScalar dy)
static Result MakeForShader(SkString sksl, const Options &)
std::unique_ptr< GrFragmentProcessor > MakeGradientFP(const SkGradientBaseShader &shader, const GrFPArgs &args, const SkShaders::MatrixRec &mRec, std::unique_ptr< GrFragmentProcessor > layout, const SkMatrix *overrideMatrix)
unsigned useCenter Optional< SkMatrix > matrix
bool isNativelyFocal() const
bool isWellBehaved() const
bool isFocalOnCircle() const