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> 2008-03-05 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-preview.c: applied a modified and * app/display/gimpdisplayshell-preview.c: applied a modified and
......
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#define INT_MULT(a,b,t) ((t) = (a) * (b) + 0x80, ((((t) >> 8) + (t)) >> 8)) #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 */ #define MAX_SUB_COLS 6 /* number of columns and */
...@@ -377,20 +376,10 @@ gimp_display_shell_draw_quad (GimpDrawable *texture, ...@@ -377,20 +376,10 @@ gimp_display_shell_draw_quad (GimpDrawable *texture,
if (maxx > dwidth - 1) maxx=dwidth - 1; if (maxx > dwidth - 1) maxx=dwidth - 1;
if (maxy > dheight - 1) maxy=dheight - 1; if (maxy > dheight - 1) maxy=dheight - 1;
area = gdk_pixbuf_new (GDK_COLORSPACE_RGB, area = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
mask ? TRUE : gimp_drawable_has_alpha (texture), maxx - minx + 1, maxy - miny + 1);
8, maxx - minx + 1, maxy - miny + 1);
g_return_if_fail (area != NULL); 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, gimp_display_shell_draw_tri (texture, dest, area, minx, miny,
mask, mask_offx, mask_offy, mask, mask_offx, mask_offy,
x, y, u, v, opacity); x, y, u, v, opacity);
...@@ -611,8 +600,6 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture, ...@@ -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_IS_PIXBUF (area));
g_return_if_fail (gdk_pixbuf_get_bits_per_sample (area) == 8); 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_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 */ /* make sure the pixel run goes in the positive direction */
if (x1 > x2) if (x1 > x2)
...@@ -666,217 +653,117 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture, ...@@ -666,217 +653,117 @@ gimp_display_shell_draw_tri_row (GimpDrawable *texture,
case GIMP_INDEXED_IMAGE: case GIMP_INDEXED_IMAGE:
cmap = gimp_drawable_get_colormap (texture); cmap = gimp_drawable_get_colormap (texture);
if (opacity == 255) while (dx--)
while (dx--) {
{ read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = cmap[offset + 0];
pptr[1] = cmap[offset + 1];
pptr[2] = cmap[offset + 2];
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]; offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = INT_BLEND (pptr[0], cmap[offset + 0], opacity, tmp); pptr[0] = cmap[offset + 0];
pptr[1] = INT_BLEND (pptr[1], cmap[offset + 1], opacity, tmp); pptr[1] = cmap[offset + 1];
pptr[2] = INT_BLEND (pptr[2], cmap[offset + 2], opacity, tmp); pptr[2] = cmap[offset + 2];
pptr[3] = opacity;
pptr += 3; pptr += 4;
u += du; u += du;
v += dv; v += dv;
} }
break; break;
case GIMP_INDEXEDA_IMAGE: case GIMP_INDEXEDA_IMAGE:
cmap = gimp_drawable_get_colormap (texture); cmap = gimp_drawable_get_colormap (texture);
if (opacity == 255) while (dx--)
while (dx--) {
{ register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
offset = pixel[0] + pixel[0] + pixel[0];
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); read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
offset = pixel[0] + pixel[0] + pixel[0]; offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = INT_BLEND (pptr[0], cmap[offset + 0], opacity, tmp); pptr[0] = cmap[offset + 0];
pptr[1] = INT_BLEND (pptr[1], cmap[offset + 1], opacity, tmp); pptr[1] = cmap[offset + 1];
pptr[2] = INT_BLEND (pptr[2], cmap[offset + 2], opacity, tmp); pptr[2] = cmap[offset + 2];
pptr[3] = pixel[1]; pptr[3] = INT_MULT (opacity, pixel[1], tmp);
pptr += 4; pptr += 4;
u += du; u += du;
v += dv; v += dv;
} }
break; break;
case GIMP_GRAY_IMAGE: case GIMP_GRAY_IMAGE:
if (opacity == 255) while (dx--)
while (dx--) {
{ read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = pixel[0];
pptr[1] = pixel[0];
pptr[2] = pixel[0];
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[0] = pixel[0];
pptr[1] = INT_BLEND (pptr[1], pixel[0], opacity, tmp); pptr[1] = pixel[0];
pptr[2] = INT_BLEND (pptr[2], pixel[0], opacity, tmp); pptr[2] = pixel[0];
pptr[3] = opacity;
pptr += 3; pptr += 4;
u += du; u += du;
v += dv; v += dv;
} }
break; break;
case GIMP_GRAYA_IMAGE: case GIMP_GRAYA_IMAGE:
if (opacity == 255) while (dx--)
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); read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = INT_BLEND (pptr[0], pixel[0], opacity, tmp); pptr[0] = pixel[0];
pptr[1] = INT_BLEND (pptr[1], pixel[0], opacity, tmp); pptr[1] = pixel[0];
pptr[2] = INT_BLEND (pptr[2], pixel[0], opacity, tmp); pptr[2] = pixel[0];
pptr[3] = pixel[1]; pptr[3] = INT_MULT (opacity, pixel[1], tmp);
pptr += 4; pptr += 4;
u += du; u += du;
v += dv; v += dv;
} }
break; break;
case GIMP_RGB_IMAGE: case GIMP_RGB_IMAGE:
if (opacity == 255) while (dx--)
while (dx--) {
{ read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = pixel[0];
pptr[1] = pixel[1];
pptr[2] = pixel[2];
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[0] = pixel[0];
pptr[1] = INT_BLEND (pptr[1], pixel[1], opacity, tmp); pptr[1] = pixel[1];
pptr[2] = INT_BLEND (pptr[2], pixel[2], opacity, tmp); pptr[2] = pixel[2];
pptr[3] = opacity;
pptr += 3; pptr += 4;
u += du; u += du;
v += dv; v += dv;
} }
break; break;
case GIMP_RGBA_IMAGE: case GIMP_RGBA_IMAGE:
if (opacity == 255) while (dx--)
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); read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
pptr[0] = INT_BLEND (pptr[0], pixel[0], opacity, tmp); pptr[0] = pixel[0];
pptr[1] = INT_BLEND (pptr[1], pixel[1], opacity, tmp); pptr[1] = pixel[1];
pptr[2] = INT_BLEND (pptr[2], pixel[2], opacity, tmp); pptr[2] = pixel[2];
pptr[3] = pixel[3]; pptr[3] = INT_MULT (opacity, pixel[3], tmp);
pptr += 4; pptr += 4;
u += du; u += du;
v += dv; v += dv;
} }
break; break;
default: default:
...@@ -990,259 +877,147 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture, ...@@ -990,259 +877,147 @@ gimp_display_shell_draw_tri_row_mask (GimpDrawable *texture,
case GIMP_INDEXED_IMAGE: case GIMP_INDEXED_IMAGE:
cmap = gimp_drawable_get_colormap (texture); cmap = gimp_drawable_get_colormap (texture);
if (opacity == 255) while (dx--)
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] = 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 (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]; offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = INT_BLEND (pptr[0], cmap[offset + 0], opacity, tmp); pptr[0] = cmap[offset + 0];
pptr[1] = INT_BLEND (pptr[1], cmap[offset + 1], opacity, tmp); pptr[1] = cmap[offset + 1];
pptr[2] = INT_BLEND (pptr[2], cmap[offset + 2], opacity, tmp); pptr[2] = cmap[offset + 2];
pptr[3] = INT_MULT (opacity, maskval, tmp);
pptr += 4; pptr += 4;
u += du; u += du;
v += dv; v += dv;
mu += du; mu += du;
mv += dv; mv += dv;
} }
break; break;
case GIMP_INDEXEDA_IMAGE: case GIMP_INDEXEDA_IMAGE:
cmap = gimp_drawable_get_colormap (texture); cmap = gimp_drawable_get_colormap (texture);
if (opacity == 255) while (dx--)
while (dx--) {
{ register gulong tmp;
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] = 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; read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);
v += dv; read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
mu += du;
mv += dv;
}
else
while (dx--)
{
register gulong tmp;
read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel); maskval = INT_MULT (maskval, pixel[1], tmp);
read_pixel_data_1 (masktiles, (gint) mu, (gint) mv, &maskval);
offset = pixel[0] + pixel[0] + pixel[0]; offset = pixel[0] + pixel[0] + pixel[0];
pptr[0] = INT_BLEND (pptr[0], cmap[offset + 0], opacity, tmp); pptr[0] = cmap[offset + 0];
pptr[1] = INT_BLEND (pptr[1], cmap[offset + 1], opacity, tmp); pptr[1] = cmap[offset + 1];
pptr[2] = INT_BLEND (pptr[2], cmap[offset + 2], opacity, tmp); pptr[2] = cmap[offset + 2];
pptr[3] = INT_MULT (maskval, pixel[1], tmp); pptr[3] = INT_MULT (opacity, maskval, tmp);
pptr += 4; pptr += 4;
u += du; u += du;
v += dv; v += dv;
mu += du; mu += du;
mv += dv; mv += dv;
} }
break; break;
case GIMP_GRAY_IMAGE: case GIMP_GRAY_IMAGE:
if (opacity == 255) while (dx--)
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] = 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 (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] = INT_BLEND (pptr[0], pixel[0], opacity, tmp); pptr[0] = pixel[0];
pptr[1] = INT_BLEND (pptr[1], pixel[0], opacity, tmp); pptr[1] = pixel[0];
pptr[2] = INT_BLEND (pptr[2], pixel[0], opacity, tmp); pptr[2] = pixel[0];
pptr[3] = INT_MULT (opacity, maskval, tmp);
pptr += 4; pptr += 4;
u += du; u += du;
v += dv; v += dv;
mu += du; mu += du;
mv += dv; mv += dv;
} }
break; break;
case GIMP_GRAYA_IMAGE: case GIMP_GRAYA_IMAGE:
if (opacity == 255) while (dx--)
while (dx--) {
{ register gulong tmp;
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] = pixel[0];
pptr[1] = pixel[0];
pptr[2] = pixel[0];
pptr[3] = INT_MULT (maskval, pixel[1], tmp);
pptr += 4;
u += du; read_pixel_data_1 (tiles, (gint) u, (gint) v, pixel);