skia2/tests/sksl/blend/BlendLuminosityStandaloneSettings.glsl
John Stiles 049f0dfaba Reduce unnecessary scratch variables in Inliner.
Arguments without side-effects that aren't read from more than once can
be moved directly into the inlined function, and don't need a scratch
variable. This can allow functions like `guarded_divide` to inline
completely in more cases.

Change-Id: I0bfce35635cf9779f4af1bc0790da966ccfe4230
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386678
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-03-19 14:10:29 +00:00

24 lines
1.1 KiB
GLSL

out vec4 sk_FragColor;
uniform vec4 src;
uniform vec4 dst;
void main() {
float _0_alpha = dst.w * src.w;
vec3 _1_sda = src.xyz * dst.w;
vec3 _2_dsa = dst.xyz * src.w;
vec3 _3_blend_set_color_luminance;
float _4_lum = dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _1_sda);
vec3 _5_result = (_4_lum - dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _2_dsa)) + _2_dsa;
float _6_minComp = min(min(_5_result.x, _5_result.y), _5_result.z);
float _7_maxComp = max(max(_5_result.x, _5_result.y), _5_result.z);
if (_6_minComp < 0.0 && _4_lum != _6_minComp) {
_5_result = _4_lum + (_5_result - _4_lum) * (_4_lum / (_4_lum - _6_minComp));
}
if (_7_maxComp > _0_alpha && _7_maxComp != _4_lum) {
_3_blend_set_color_luminance = _4_lum + ((_5_result - _4_lum) * (_0_alpha - _4_lum)) / (_7_maxComp - _4_lum);
} else {
_3_blend_set_color_luminance = _5_result;
}
sk_FragColor = vec4((((_3_blend_set_color_luminance + dst.xyz) - _2_dsa) + src.xyz) - _1_sda, (src.w + dst.w) - _0_alpha);
}