diff --git a/src/backend/gl/shaders.c b/src/backend/gl/shaders.c index b45325de78..19f6f27054 100644 --- a/src/backend/gl/shaders.c +++ b/src/backend/gl/shaders.c @@ -154,24 +154,26 @@ const char blit_shader_glsl[] = GLSL(330, border_color.rgb = border_color.rgb * (max_brightness / brightness); } - // Rim color is the color of the outer rim of the window, if there is no - // border, it's the color of the window itself, otherwise it's the border. - // Using mix() to avoid a branch here. - vec4 rim_color = mix(c, border_color, clamp(border_width, 0.0f, 1.0f)); + if (corner_radius != 0) { + // Rim color is the color of the outer rim of the window, if there is no + // border, it's the color of the window itself, otherwise it's the border. + // Using mix() to avoid a branch here. + vec4 rim_color = mix(c, border_color, clamp(border_width, 0.0f, 1.0f)); - vec2 outer_size = effective_size; - vec2 inner_size = outer_size - vec2(corner_radius) * 2.0f; - // +1.0 so the last 1-pixel ring of the rounded rectangle will transition - // smoothly from 1 to 0 for anti-aliasing. If we don't do this, everything - // inside the corner radius will be solid, and we will have an extra 1-pixel - // feathering outside the corner radius, which makes it look bad. - float rect_distance = rectangle_sdf(texcoord - outer_size / 2.0f, - inner_size / 2.0f) - corner_radius + 1.0f; - if (rect_distance > 0.0f) { - c = (1.0f - clamp(rect_distance, 0.0f, 1.0f)) * rim_color; - } else { - float factor = clamp(rect_distance + border_width, 0.0f, 1.0f); - c = (1.0f - factor) * c + factor * border_color; + vec2 outer_size = effective_size; + vec2 inner_size = outer_size - vec2(corner_radius) * 2.0f; + // +1.0 so the last 1-pixel ring of the rounded rectangle will transition + // smoothly from 1 to 0 for anti-aliasing. If we don't do this, everything + // inside the corner radius will be solid, and we will have an extra 1-pixel + // feathering outside the corner radius, which makes it look bad. + float rect_distance = rectangle_sdf(texcoord - outer_size / 2.0f, + inner_size / 2.0f) - corner_radius + 1.0f; + if (rect_distance > 0.0f) { + c = (1.0f - clamp(rect_distance, 0.0f, 1.0f)) * rim_color; + } else { + float factor = clamp(rect_distance + border_width, 0.0f, 1.0f); + c = (1.0f - factor) * c + factor * border_color; + } } return c;