forked from bartvdbraak/blender
DPI: icons were still drawing with color fringing when scaled up/down, opengl
texture needs to be premul alpha for correct results.
This commit is contained in:
parent
0a1f8ada34
commit
a4cb186df5
@ -467,7 +467,10 @@ static void init_brush_icons(void)
|
||||
bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_ ##name## _png, \
|
||||
datatoc_ ##name## _png_size, \
|
||||
IB_rect, NULL, "<brush icon>"); \
|
||||
if (bbuf) { \
|
||||
IMB_premultiply_alpha(bbuf); \
|
||||
def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
|
||||
} \
|
||||
IMB_freeImBuf(bbuf); \
|
||||
} (void)0
|
||||
/* end INIT_BRUSH_ICON */
|
||||
@ -537,10 +540,14 @@ static void init_internal_icons(void)
|
||||
if (b16buf == NULL)
|
||||
b16buf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons16_png,
|
||||
datatoc_blender_icons16_png_size, IB_rect, NULL, "<blender icons>");
|
||||
if (b16buf)
|
||||
IMB_premultiply_alpha(b16buf);
|
||||
|
||||
if (b32buf == NULL)
|
||||
b32buf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons32_png,
|
||||
datatoc_blender_icons32_png_size, IB_rect, NULL, "<blender icons>");
|
||||
if (b32buf)
|
||||
IMB_premultiply_alpha(b32buf);
|
||||
|
||||
if (b16buf && b32buf) {
|
||||
/* free existing texture if any */
|
||||
@ -940,8 +947,8 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy
|
||||
{
|
||||
float x1, x2, y1, y2;
|
||||
|
||||
if (rgb) glColor4f(rgb[0], rgb[1], rgb[2], alpha);
|
||||
else glColor4f(1.0f, 1.0f, 1.0f, alpha);
|
||||
if (rgb) glColor4f(alpha*rgb[0], rgb[1], rgb[2], alpha);
|
||||
else glColor4f(alpha, alpha, alpha, alpha);
|
||||
|
||||
x1 = ix * icongltex.invw;
|
||||
x2 = (ix + ih) * icongltex.invw;
|
||||
@ -1017,8 +1024,11 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
|
||||
di->data.vector.func((int)x, (int)y, ICON_DEFAULT_HEIGHT, ICON_DEFAULT_HEIGHT, 1.0f);
|
||||
}
|
||||
else if (di->type == ICON_TYPE_TEXTURE) {
|
||||
/* texture image use premul alpha for correct scaling */
|
||||
glBlendFunc(GL_ONE, GL_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);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
else if (di->type == ICON_TYPE_BUFFER) {
|
||||
/* it is a builtin icon */
|
||||
@ -1026,7 +1036,9 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
|
||||
|
||||
if (!iimg->rect) return; /* something has gone wrong! */
|
||||
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
else if (di->type == ICON_TYPE_PREVIEW) {
|
||||
PreviewImage *pi = BKE_previewimg_get((ID *)icon->obj);
|
||||
|
Loading…
Reference in New Issue
Block a user