From 932c374779716622b3b46447d25756934dbabc31 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 3 Jun 2022 14:01:50 +0300 Subject: [PATCH] gl-renderer: move undo-premult to color_pipeline() Now that we have the if-else ladder to call color_pipeline() only when necessary, and since only color_pipeline() needs undo-premult, move undo-premult into color_pipeline(). This is a small step towards improving code readability. Signed-off-by: Pekka Paalanen --- libweston/renderer-gl/fragment.glsl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libweston/renderer-gl/fragment.glsl b/libweston/renderer-gl/fragment.glsl index 908075e6..6271c9cd 100644 --- a/libweston/renderer-gl/fragment.glsl +++ b/libweston/renderer-gl/fragment.glsl @@ -249,6 +249,14 @@ color_mapping(vec3 color) vec4 color_pipeline(vec4 color) { + /* Ensure straight alpha */ + if (c_input_is_premult) { + if (color.a == 0.0) + color.rgb = vec3(0, 0, 0); + else + color.rgb *= 1.0 / color.a; + } + color.rgb = color_pre_curve(color.rgb); color.rgb = color_mapping(color.rgb); @@ -264,15 +272,7 @@ main() color = sample_input_texture(); if (c_need_color_pipeline) { - /* Ensure straight alpha */ - if (c_input_is_premult) { - if (color.a == 0.0) - color.rgb = vec3(0, 0, 0); - else - color.rgb *= 1.0 / color.a; - } - - color = color_pipeline(color); + color = color_pipeline(color); /* Produces straight alpha */ color.a *= view_alpha;