xref: /aosp_15_r20/external/skia/tests/sksl/shared/UnaryPositiveNegative.glsl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1
2out vec4 sk_FragColor;
3uniform vec4 colorWhite;
4uniform vec4 colorGreen;
5uniform vec4 colorRed;
6uniform mat2 testMatrix2x2;
7uniform mat3 testMatrix3x3;
8uniform mat4 testMatrix4x4;
9bool test_iscalar_b() {
10    int x = int(colorWhite.x);
11    x = -x;
12    return x == -1;
13}
14bool test_fvec_b() {
15    vec2 x = colorWhite.xy;
16    x = -x;
17    return x == vec2(-1.0);
18}
19bool test_ivec_b() {
20    ivec2 x = ivec2(int(colorWhite.x));
21    x = -x;
22    return x == ivec2(-1);
23}
24bool test_mat2_b() {
25    const mat2 negated = mat2(-1.0, -2.0, -3.0, -4.0);
26    mat2 x = testMatrix2x2;
27    x = -x;
28    return x == negated;
29}
30bool test_mat3_b() {
31    const mat3 negated = mat3(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0);
32    mat3 x = testMatrix3x3;
33    x = -x;
34    return x == negated;
35}
36bool test_mat4_b() {
37    const mat4 negated = mat4(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0, -10.0, -11.0, -12.0, -13.0, -14.0, -15.0, -16.0);
38    mat4 x = testMatrix4x4;
39    x = -x;
40    return x == negated;
41}
42bool test_hmat2_b() {
43    const mat2 negated = mat2(-1.0, -2.0, -3.0, -4.0);
44    mat2 x = testMatrix2x2;
45    x = -x;
46    return x == negated;
47}
48bool test_hmat3_b() {
49    const mat3 negated = mat3(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0);
50    mat3 x = testMatrix3x3;
51    x = -x;
52    return x == negated;
53}
54bool test_hmat4_b() {
55    const mat4 negated = mat4(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0, -10.0, -11.0, -12.0, -13.0, -14.0, -15.0, -16.0);
56    mat4 x = testMatrix4x4;
57    x = -x;
58    return x == negated;
59}
60vec4 main() {
61    float _0_x = colorWhite.x;
62    _0_x = -_0_x;
63    return ((((((((_0_x == -1.0 && test_iscalar_b()) && test_fvec_b()) && test_ivec_b()) && test_mat2_b()) && test_mat3_b()) && test_mat4_b()) && test_hmat2_b()) && test_hmat3_b()) && test_hmat4_b() ? colorGreen : colorRed;
64}
65