Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-12-19 14:12:58 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-12-19 14:12:58 +0400
commita4cb186df510bc422116ac47828d2d938f906aba (patch)
tree182f2a0ce953ea785a1c6efcdc7356e72b5d4520 /source/blender/editors/interface/interface_icons.c
parent0a1f8ada3424dd6c737bcab91c1cdf54a59879fc (diff)
DPI: icons were still drawing with color fringing when scaled up/down, opengl
texture needs to be premul alpha for correct results.
Diffstat (limited to 'source/blender/editors/interface/interface_icons.c')
-rw-r--r--source/blender/editors/interface/interface_icons.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index d44e856231a..7240477737d 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -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>"); \
- def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
+ 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);