From 192a99f47784277baa9eab4864bae1b4382b243c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 8 Oct 2018 13:28:14 +0200 Subject: [PATCH] Fix incorrect alpha blending for icon drawing outside buttons. This was not so noticeable for old icons with black outline, but with white outline it's problematic. --- source/blender/editors/interface/interface_icons.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index fb8c6ec4c56..64f3a8a31d8 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1358,6 +1358,7 @@ void UI_icon_draw_cache_end(void) return; GPU_blend(true); + GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); icon_draw_cache_flush_ex(); @@ -1405,9 +1406,10 @@ static void icon_draw_texture( } /* We need to flush widget base first to ensure correct ordering. */ - GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); UI_widgetbase_draw_cache_flush(); + GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + float x1, x2, y1, y2; x1 = ix * icongltex.invw; @@ -1431,6 +1433,8 @@ static void icon_draw_texture( GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4); glBindTexture(GL_TEXTURE_2D, 0); + + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } /* Drawing size for preview images */ @@ -1518,10 +1522,8 @@ static void icon_draw_size( } else if (di->type == ICON_TYPE_TEXTURE) { /* texture image use premul alpha for correct scaling */ - GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y, di->data.texture.w, di->data.texture.h, alpha, rgb); - GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } else if (di->type == ICON_TYPE_MONO_TEXTURE) { /* icon that matches text color, assumed to be white */ @@ -1539,10 +1541,8 @@ static void icon_draw_size( mul_v4_fl(color, alpha); - GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y, di->data.texture.w, di->data.texture.h, color[3], color); - GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } else if (di->type == ICON_TYPE_BUFFER) {