Fix wrong alpha blending for datablock preview icons.
This commit is contained in:
@@ -1602,9 +1602,8 @@ static void icon_draw_size(
|
|||||||
/* no create icon on this level in code */
|
/* no create icon on this level in code */
|
||||||
if (!pi->rect[size]) return; /* something has gone wrong! */
|
if (!pi->rect[size]) return; /* something has gone wrong! */
|
||||||
|
|
||||||
/* preview images use premul alpha ... */
|
/* Preview images use premultiplied alpha. */
|
||||||
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
GPU_blend_set_func_separate(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, rgb, desaturate);
|
icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, rgb, desaturate);
|
||||||
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,8 +378,6 @@ static void file_draw_preview(
|
|||||||
xco = sx + (int)dx;
|
xco = sx + (int)dx;
|
||||||
yco = sy - layout->prv_h + (int)dy;
|
yco = sy - layout->prv_h + (int)dy;
|
||||||
|
|
||||||
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
|
||||||
|
|
||||||
/* shadow */
|
/* shadow */
|
||||||
if (use_dropshadow) {
|
if (use_dropshadow) {
|
||||||
UI_draw_box_shadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
|
UI_draw_box_shadow(220, (float)xco, (float)yco, (float)(xco + ex), (float)(yco + ey));
|
||||||
@@ -392,10 +390,15 @@ static void file_draw_preview(
|
|||||||
UI_GetThemeColor4fv(TH_TEXT, col);
|
UI_GetThemeColor4fv(TH_TEXT, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Preview images use premultiplied alpha. */
|
||||||
|
GPU_blend_set_func_separate(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||||
immDrawPixelsTexScaled(&state, (float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect,
|
immDrawPixelsTexScaled(&state, (float)xco, (float)yco, imb->x, imb->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect,
|
||||||
scale, scale, 1.0f, 1.0f, col);
|
scale, scale, 1.0f, 1.0f, col);
|
||||||
|
|
||||||
|
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
UI_icon_draw_aspect((float)xco, (float)yco, icon, icon_aspect, 1.0f, NULL);
|
UI_icon_draw_aspect((float)xco, (float)yco, icon, icon_aspect, 1.0f, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user