1cb93a386Sopenharmony_ci#include <metal_stdlib>
2cb93a386Sopenharmony_ci#include <simd/simd.h>
3cb93a386Sopenharmony_ciusing namespace metal;
4cb93a386Sopenharmony_cistruct Uniforms {
5cb93a386Sopenharmony_ci    half4 src;
6cb93a386Sopenharmony_ci    half4 dst;
7cb93a386Sopenharmony_ci};
8cb93a386Sopenharmony_cistruct Inputs {
9cb93a386Sopenharmony_ci};
10cb93a386Sopenharmony_cistruct Outputs {
11cb93a386Sopenharmony_ci    half4 sk_FragColor [[color(0)]];
12cb93a386Sopenharmony_ci};
13cb93a386Sopenharmony_cihalf _blend_overlay_component_hh2h2(half2 s, half2 d) {
14cb93a386Sopenharmony_ci    return 2.0h * d.x <= d.y ? (2.0h * s.x) * d.x : s.y * d.y - (2.0h * (d.y - d.x)) * (s.y - s.x);
15cb93a386Sopenharmony_ci}
16cb93a386Sopenharmony_cifragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
17cb93a386Sopenharmony_ci    Outputs _out;
18cb93a386Sopenharmony_ci    (void)_out;
19cb93a386Sopenharmony_ci    half4 _0_result = half4(_blend_overlay_component_hh2h2(_uniforms.dst.xw, _uniforms.src.xw), _blend_overlay_component_hh2h2(_uniforms.dst.yw, _uniforms.src.yw), _blend_overlay_component_hh2h2(_uniforms.dst.zw, _uniforms.src.zw), _uniforms.dst.w + (1.0h - _uniforms.dst.w) * _uniforms.src.w);
20cb93a386Sopenharmony_ci    _0_result.xyz = _0_result.xyz + _uniforms.src.xyz * (1.0h - _uniforms.dst.w) + _uniforms.dst.xyz * (1.0h - _uniforms.src.w);
21cb93a386Sopenharmony_ci    _out.sk_FragColor = _0_result;
22cb93a386Sopenharmony_ci    return _out;
23cb93a386Sopenharmony_ci}
24