xref: /aosp_15_r20/external/skia/resources/sksl/intrinsics/MixBool.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Workeruniform half4 colorGreen, colorRed, colorBlack, colorWhite, testInputs;
2*c8dee2aaSAndroid Build Coastguard Worker
3*c8dee2aaSAndroid Build Coastguard Worker// This test covers forms of mix that aren't supported in either ES2 or ES3.
4*c8dee2aaSAndroid Build Coastguard Worker// See MixFloatES2 and MixFloatES3 for additional forms of mix.
5*c8dee2aaSAndroid Build Coastguard Worker
6*c8dee2aaSAndroid Build Coastguard Workerhalf4 main(float2 coords) {
7*c8dee2aaSAndroid Build Coastguard Worker    int4 intGreen  = int4(colorGreen * 100);
8*c8dee2aaSAndroid Build Coastguard Worker    int4 intRed    = int4(colorRed   * 100);
9*c8dee2aaSAndroid Build Coastguard Worker    const int4 constIGreen  = int4(0, 100, 0, 100);
10*c8dee2aaSAndroid Build Coastguard Worker    const int4 constIRed    = int4(100, 0, 0, 100);
11*c8dee2aaSAndroid Build Coastguard Worker    const half4 constGreen  = half4(0, 1, 0, 1);
12*c8dee2aaSAndroid Build Coastguard Worker    const half4 constRed    = half4(1, 0, 0, 1);
13*c8dee2aaSAndroid Build Coastguard Worker
14*c8dee2aaSAndroid Build Coastguard Worker    return (mix(intGreen.x,       intRed.x,       false)        == intGreen.x      &&
15*c8dee2aaSAndroid Build Coastguard Worker            mix(intGreen.xy,      intRed.xy,      bool2(false)) == intGreen.xy     &&
16*c8dee2aaSAndroid Build Coastguard Worker            mix(intGreen.xyz,     intRed.xyz,     bool3(false)) == intGreen.xyz    &&
17*c8dee2aaSAndroid Build Coastguard Worker            mix(intGreen.xyzw,    intRed.xyzw,    bool4(false)) == intGreen.xyzw   &&
18*c8dee2aaSAndroid Build Coastguard Worker            mix(intGreen.x,       intRed.x,       true)         == intRed.x        &&
19*c8dee2aaSAndroid Build Coastguard Worker            mix(intGreen.xy,      intRed.xy,      bool2(true))  == intRed.xy       &&
20*c8dee2aaSAndroid Build Coastguard Worker            mix(intGreen.xyz,     intRed.xyz,     bool3(true))  == intRed.xyz      &&
21*c8dee2aaSAndroid Build Coastguard Worker            mix(intGreen.xyzw,    intRed.xyzw,    bool4(true))  == intRed.xyzw     &&
22*c8dee2aaSAndroid Build Coastguard Worker            mix(constIGreen.x,    constIRed.x,    false)        == intGreen.x      &&
23*c8dee2aaSAndroid Build Coastguard Worker            mix(constIGreen.xy,   constIRed.xy,   bool2(false)) == intGreen.xy     &&
24*c8dee2aaSAndroid Build Coastguard Worker            mix(constIGreen.xyz,  constIRed.xyz,  bool3(false)) == intGreen.xyz    &&
25*c8dee2aaSAndroid Build Coastguard Worker            mix(constIGreen.xyzw, constIRed.xyzw, bool4(false)) == intGreen.xyzw   &&
26*c8dee2aaSAndroid Build Coastguard Worker            mix(constIGreen.x,    constIRed.x,    true)         == intRed.x        &&
27*c8dee2aaSAndroid Build Coastguard Worker            mix(constIGreen.xy,   constIRed.xy,   bool2(true))  == intRed.xy       &&
28*c8dee2aaSAndroid Build Coastguard Worker            mix(constIGreen.xyz,  constIRed.xyz,  bool3(true))  == intRed.xyz      &&
29*c8dee2aaSAndroid Build Coastguard Worker            mix(constIGreen.xyzw, constIRed.xyzw, bool4(true))  == intRed.xyzw     &&
30*c8dee2aaSAndroid Build Coastguard Worker            mix(colorGreen.x,     colorRed.x,     false)        == colorGreen.x    &&
31*c8dee2aaSAndroid Build Coastguard Worker            mix(colorGreen.xy,    colorRed.xy,    bool2(false)) == colorGreen.xy   &&
32*c8dee2aaSAndroid Build Coastguard Worker            mix(colorGreen.xyz,   colorRed.xyz,   bool3(false)) == colorGreen.xyz  &&
33*c8dee2aaSAndroid Build Coastguard Worker            mix(colorGreen.xyzw,  colorRed.xyzw,  bool4(false)) == colorGreen.xyzw &&
34*c8dee2aaSAndroid Build Coastguard Worker            mix(colorGreen.x,     colorRed.x,     true)         == colorRed.x      &&
35*c8dee2aaSAndroid Build Coastguard Worker            mix(colorGreen.xy,    colorRed.xy,    bool2(true))  == colorRed.xy     &&
36*c8dee2aaSAndroid Build Coastguard Worker            mix(colorGreen.xyz,   colorRed.xyz,   bool3(true))  == colorRed.xyz    &&
37*c8dee2aaSAndroid Build Coastguard Worker            mix(colorGreen.xyzw,  colorRed.xyzw,  bool4(true))  == colorRed.xyzw   &&
38*c8dee2aaSAndroid Build Coastguard Worker            mix(constGreen.x,     constRed.x,     false)        == colorGreen.x    &&
39*c8dee2aaSAndroid Build Coastguard Worker            mix(constGreen.xy,    constRed.xy,    bool2(false)) == colorGreen.xy   &&
40*c8dee2aaSAndroid Build Coastguard Worker            mix(constGreen.xyz,   constRed.xyz,   bool3(false)) == colorGreen.xyz  &&
41*c8dee2aaSAndroid Build Coastguard Worker            mix(constGreen.xyzw,  constRed.xyzw,  bool4(false)) == colorGreen.xyzw &&
42*c8dee2aaSAndroid Build Coastguard Worker            mix(constGreen.x,     constRed.x,     true)         == colorRed.x      &&
43*c8dee2aaSAndroid Build Coastguard Worker            mix(constGreen.xy,    constRed.xy,    bool2(true))  == colorRed.xy     &&
44*c8dee2aaSAndroid Build Coastguard Worker            mix(constGreen.xyz,   constRed.xyz,   bool3(true))  == colorRed.xyz    &&
45*c8dee2aaSAndroid Build Coastguard Worker            mix(constGreen.xyzw,  constRed.xyzw,  bool4(true))  == colorRed.xyzw) ? colorGreen
46*c8dee2aaSAndroid Build Coastguard Worker                                                                                  : colorRed;
47*c8dee2aaSAndroid Build Coastguard Worker}
48*c8dee2aaSAndroid Build Coastguard Worker
49