Commit da704ae1 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

don't do the blending here, just apply the opacity on the pixbuf's alpha

2008-03-06  Sven Neumann  <sven@gimp.org>

	* app/display/gimpdisplayshell-preview.c: don't do the blending
	here, just apply the opacity on the pixbuf's alpha channel.


svn path=/trunk/; revision=25048
parent 3ccc439d
2008-03-06 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-preview.c: don't do the blending
here, just apply the opacity on the pixbuf's alpha channel.
2008-03-05 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-preview.c: applied a modified and
......
......@@ -44,7 +44,6 @@
#define INT_MULT(a,b,t) ((t) = (a) * (b) + 0x80, ((((t) >> 8) + (t)) >> 8))
#define INT_BLEND(a,b,alpha,tmp) (INT_MULT((a) - (b), alpha, tmp) + (b))
#define MAX_SUB_COLS 6 /* number of columns and */
......@@ -377,20 +376,10 @@ gimp_display_shell_draw_quad (GimpDrawable *texture,
if (maxx > dwidth - 1) maxx=dwidth - 1;
if (maxy > dheight - 1) maxy=dheight - 1;
area = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
mask ? TRUE : gimp_drawable_has_alpha (texture),
8, maxx - minx + 1, maxy - miny + 1);
area = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
maxx - minx + 1, maxy - miny + 1);
g_return_if_fail (area != NULL);
/* get original data from dest in order to potentially take
* into account opacity
*/
if (opacity != 255)
gdk_pixbuf_get_from_drawable (area, dest, NULL, minx, miny,
0, 0, maxx - minx + 1, maxy - miny + 1);
gimp_display_shell_draw_tri (texture, dest, area, minx, miny,
mask, mask_offx, mask_offy,
x, y, u, v, opacity);
......@@ -611,8 +600,6 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
g_return_if_fail (GDK_IS_PIXBUF (area));
g_return_if_fail (gdk_pixbuf_get_bits_per_sample (area) == 8);
g_return_if_fail (gdk_pixbuf_get_colorspace (area) == GDK_COLORSPACE_RGB);
g_return_if_fail (gdk_pixbuf_get_has_alpha (area) ==
gimp_drawable_has_alpha (texture));
/* make sure the pixel run goes in the positive direction */
if (x1 > x2)
......@@ -666,7 +653,6 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
case GIMP_INDEXED_IMAGE:
cmap = gimp_drawable_get_colormap (texture);
if (opacity == 255)
while (dx--)
{
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
......@@ -676,26 +662,9 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
pptr[0] = cmap[offset + 0];
pptr[1] = cmap[offset + 1];
pptr[2] = cmap[offset + 2];
pptr[3] = opacity;
pptr += 3;
u += du;
v += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = INT_BLEND (pptr[0], cmap[offset + 0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], cmap[offset + 1], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], cmap[offset + 2], opacity, tmp);
pptr += 3;
pptr += 4;
u += du;
v += dv;
......@@ -705,9 +674,10 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
case GIMP_INDEXEDA_IMAGE:
cmap = gimp_drawable_get_colormap (texture);
if (opacity == 255)
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
offset = pixel[0] + pixel[0] + pixel[0];
......@@ -715,26 +685,7 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
pptr[0] = cmap[offset + 0];
pptr[1] = cmap[offset + 1];
pptr[2] = cmap[offset + 2];
pptr[3] = pixel[1];
pptr += 4;
u += du;
v += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = INT_BLEND (pptr[0], cmap[offset + 0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], cmap[offset + 1], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], cmap[offset + 2], opacity, tmp);
pptr[3] = pixel[1];
pptr[3] = INT_MULT (opacity, pixel[1], tmp);
pptr += 4;
......@@ -744,7 +695,6 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
break;
case GIMP_GRAY_IMAGE:
if (opacity == 255)
while (dx--)
{
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
......@@ -752,24 +702,9 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
pptr[0] = pixel[0];
pptr[1] = pixel[0];
pptr[2] = pixel[0];
pptr[3] = opacity;
pptr += 3;
u += du;
v += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = INT_BLEND (pptr[0], pixel[0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], pixel[0], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], pixel[0], opacity, tmp);
pptr += 3;
pptr += 4;
u += du;
v += dv;
......@@ -777,32 +712,16 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
break;
case GIMP_GRAYA_IMAGE:
if (opacity == 255)
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = pixel[0];
pptr[1] = pixel[0];
pptr[2] = pixel[0];
pptr[3] = pixel[1];
pptr += 4;
u += du;
v += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = INT_BLEND (pptr[0], pixel[0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], pixel[0], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], pixel[0], opacity, tmp);
pptr[3] = pixel[1];
pptr[3] = INT_MULT (opacity, pixel[1], tmp);
pptr += 4;
......@@ -812,7 +731,6 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
break;
case GIMP_RGB_IMAGE:
if (opacity == 255)
while (dx--)
{
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
......@@ -820,24 +738,9 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
pptr[0] = pixel[0];
pptr[1] = pixel[1];
pptr[2] = pixel[2];
pptr[3] = opacity;
pptr += 3;
u += du;
v += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = INT_BLEND (pptr[0], pixel[0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], pixel[1], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], pixel[2], opacity, tmp);
pptr += 3;
pptr += 4;
u += du;
v += dv;
......@@ -845,32 +748,16 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
break;
case GIMP_RGBA_IMAGE:
if (opacity == 255)
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = pixel[0];
pptr[1] = pixel[1];
pptr[2] = pixel[2];
pptr[3] = pixel[3];
pptr += 4;
u += du;
v += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = INT_BLEND (pptr[0], pixel[0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], pixel[1], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], pixel[2], opacity, tmp);
pptr[3] = pixel[3];
pptr[3] = INT_MULT (opacity, pixel[3], tmp);
pptr += 4;
......@@ -990,38 +877,19 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
case GIMP_INDEXED_IMAGE:
cmap = gimp_drawable_get_colormap (texture);
if (opacity == 255)
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, pptr + 3);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = cmap[offset + 0];
pptr[1] = cmap[offset + 1];
pptr[2] = cmap[offset + 2];
pptr += 4;
u += du;
v += dv;
mu += du;
mv += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, pptr + 3);
offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = INT_BLEND (pptr[0], cmap[offset + 0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], cmap[offset + 1], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], cmap[offset + 2], opacity, tmp);
pptr[3] = INT_MULT (opacity, maskval, tmp);
pptr += 4;
......@@ -1035,7 +903,6 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
case GIMP_INDEXEDA_IMAGE:
cmap = gimp_drawable_get_colormap (texture);
if (opacity == 255)
while (dx--)
{
register gulong tmp;
......@@ -1043,34 +910,14 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
maskval = INT_MULT (maskval, pixel[1], tmp);
offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = cmap[offset + 0];
pptr[1] = cmap[offset + 1];
pptr[2] = cmap[offset + 2];
pptr[3] = INT_MULT (maskval, pixel[1], tmp);
pptr += 4;
u += du;
v += dv;
mu += du;
mv += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = INT_BLEND (pptr[0], cmap[offset + 0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], cmap[offset + 1], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], cmap[offset + 2], opacity, tmp);
pptr[3] = INT_MULT (maskval, pixel[1], tmp);
pptr[3] = INT_MULT (opacity, maskval, tmp);
pptr += 4;
......@@ -1082,34 +929,17 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
break;
case GIMP_GRAY_IMAGE:
if (opacity == 255)
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, pptr + 3);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
pptr[0] = pixel[0];
pptr[1] = pixel[0];
pptr[2] = pixel[0];
pptr += 4;
u += du;
v += dv;
mu += du;
mv += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, pptr + 3);
pptr[0] = INT_BLEND (pptr[0], pixel[0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], pixel[0], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], pixel[0], opacity, tmp);
pptr[3] = INT_MULT (opacity, maskval, tmp);
pptr += 4;
......@@ -1121,7 +951,6 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
break;
case GIMP_GRAYA_IMAGE:
if (opacity == 255)
while (dx--)
{
register gulong tmp;
......@@ -1129,30 +958,12 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
maskval = INT_MULT (maskval, pixel[1], tmp);
pptr[0] = pixel[0];
pptr[1] = pixel[0];
pptr[2] = pixel[0];
pptr[3] = INT_MULT (maskval, pixel[1], tmp);
pptr += 4;
u += du;
v += dv;
mu += du;
mv += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
pptr[0] = INT_BLEND (pptr[0], pixel[0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], pixel[0], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], pixel[0], opacity, tmp);
pptr[3] = INT_MULT (maskval, pixel[1], tmp);
pptr[3] = INT_MULT (opacity, maskval, tmp);
pptr += 4;
......@@ -1164,34 +975,17 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
break;
case GIMP_RGB_IMAGE:
if (opacity == 255)
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, pptr + 3);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
pptr[0] = pixel[0];
pptr[1] = pixel[1];
pptr[2] = pixel[2];
pptr += 4;
u += du;
v += dv;
mu += du;
mv += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, pptr + 3);
pptr[0] = INT_BLEND (pptr[0], pixel[0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], pixel[1], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], pixel[2], opacity, tmp);
pptr[3] = INT_MULT (opacity, maskval, tmp);
pptr += 4;
......@@ -1203,7 +997,6 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
break;
case GIMP_RGBA_IMAGE:
if (opacity == 255)
while (dx--)
{
register gulong tmp;
......@@ -1211,30 +1004,12 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
maskval = INT_MULT (maskval, pixel[3], tmp);
pptr[0] = pixel[0];
pptr[1] = pixel[1];
pptr[2] = pixel[2];
pptr[3] = INT_MULT (maskval, pixel[3], tmp);
pptr += 4;
u += du;
v += dv;
mu += du;
mv += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
pptr[0] = INT_BLEND (pptr[0], pixel[0], opacity, tmp);
pptr[1] = INT_BLEND (pptr[1], pixel[1], opacity, tmp);
pptr[2] = INT_BLEND (pptr[2], pixel[2], opacity, tmp);
pptr[3] = INT_MULT (maskval, pixel[3], tmp);
pptr[3] = INT_MULT (opacity, maskval, tmp);
pptr += 4;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment