Merge from stable:

2004-06-21  Michael Natterer  <mitch@gimp.org>

	Merge from stable:

	* gdk/x11/gdkdrawable-x11.[ch]: made convert_format() utility
	function public as _gdk_x11_convert_to_format().

	* gdk/x11/gdkcursor-x11.c (create_cursor_image): premultiply
	the pixels from the GdkPixbuf when putting them in the
	Xcursor image. Fixes bug #144350.
This commit is contained in:
Michael Natterer 2004-06-21 16:13:55 +00:00 committed by Michael Natterer
parent fbe92667af
commit 1408c75941
7 changed files with 115 additions and 52 deletions

View File

@ -1,3 +1,14 @@
2004-06-21 Michael Natterer <mitch@gimp.org>
Merge from stable:
* gdk/x11/gdkdrawable-x11.[ch]: made convert_format() utility
function public as _gdk_x11_convert_to_format().
* gdk/x11/gdkcursor-x11.c (create_cursor_image): premultiply
the pixels from the GdkPixbuf when putting them in the
Xcursor image. Fixes bug #144350.
2004-06-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a

View File

@ -1,3 +1,14 @@
2004-06-21 Michael Natterer <mitch@gimp.org>
Merge from stable:
* gdk/x11/gdkdrawable-x11.[ch]: made convert_format() utility
function public as _gdk_x11_convert_to_format().
* gdk/x11/gdkcursor-x11.c (create_cursor_image): premultiply
the pixels from the GdkPixbuf when putting them in the
Xcursor image. Fixes bug #144350.
2004-06-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a

View File

@ -1,3 +1,14 @@
2004-06-21 Michael Natterer <mitch@gimp.org>
Merge from stable:
* gdk/x11/gdkdrawable-x11.[ch]: made convert_format() utility
function public as _gdk_x11_convert_to_format().
* gdk/x11/gdkcursor-x11.c (create_cursor_image): premultiply
the pixels from the GdkPixbuf when putting them in the
Xcursor image. Fixes bug #144350.
2004-06-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a

View File

@ -1,3 +1,14 @@
2004-06-21 Michael Natterer <mitch@gimp.org>
Merge from stable:
* gdk/x11/gdkdrawable-x11.[ch]: made convert_format() utility
function public as _gdk_x11_convert_to_format().
* gdk/x11/gdkcursor-x11.c (create_cursor_image): premultiply
the pixels from the GdkPixbuf when putting them in the
Xcursor image. Fixes bug #144350.
2004-06-16 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a

View File

@ -313,8 +313,6 @@ create_cursor_image (GdkPixbuf *pixbuf,
guchar *pixels, *src;
XcursorImage *xcimage;
XcursorPixel *dest;
guchar a;
gint i, j;
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
@ -330,21 +328,31 @@ create_cursor_image (GdkPixbuf *pixbuf,
dest = xcimage->pixels;
for (j = 0; j < height; j++)
if (n_channels == 3)
{
src = pixels + j * rowstride;
for (i = 0; i < width; i++)
{
if (n_channels == 3)
a = 0xff;
else
a = src[3];
gint i, j;
for (j = 0; j < height; j++)
{
src = pixels + j * rowstride;
for (i = 0; i < width; i++)
{
*dest = (0xff << 24) | (src[0] << 16) | (src[1] << 8) | src[2];
}
*dest = (a << 24) | (src[0] << 16) | (src[1] << 8) | src[2];
src += n_channels;
dest++;
}
}
else
{
_gdk_x11_convert_to_format (pixels, rowstride,
(guchar *) dest, 4 * width,
GDK_X11_FORMAT_ARGB,
(G_BYTE_ORDER == G_BIG_ENDIAN) ?
GDK_MSB_FIRST : GDK_LSB_FIRST,
width, height);
}
return xcimage;
}

View File

@ -921,14 +921,8 @@ gdk_x11_drawable_get_xid (GdkDrawable *drawable)
* what's the fastest depending on the available picture formats,
* whether we can used shared pixmaps, etc.
*/
typedef enum {
FORMAT_NONE,
FORMAT_EXACT_MASK,
FORMAT_ARGB_MASK,
FORMAT_ARGB
} FormatType;
static FormatType
static GdkX11FormatType
select_format (GdkDisplay *display,
XRenderPictFormat **format,
XRenderPictFormat **mask)
@ -937,7 +931,7 @@ select_format (GdkDisplay *display,
XRenderPictFormat pf;
if (!_gdk_x11_have_render (display))
return FORMAT_NONE;
return GDK_X11_FORMAT_NONE;
/* Look for a 32-bit xRGB and Axxx formats that exactly match the
* in memory data format. We can use them as pixmap and mask
@ -993,7 +987,7 @@ select_format (GdkDisplay *display,
0);
if (*format && *mask)
return FORMAT_EXACT_MASK;
return GDK_X11_FORMAT_EXACT_MASK;
/* OK, that failed, now look for xRGB and Axxx formats in
* RENDER's preferred order
@ -1023,7 +1017,7 @@ select_format (GdkDisplay *display,
0);
if (*format && *mask)
return FORMAT_ARGB_MASK;
return GDK_X11_FORMAT_ARGB_MASK;
/* Finally, if neither of the above worked, fall back to
* looking for combined ARGB -- we'll premultiply ourselves.
@ -1048,9 +1042,9 @@ select_format (GdkDisplay *display,
*mask = NULL;
if (*format)
return FORMAT_ARGB;
return GDK_X11_FORMAT_ARGB;
return FORMAT_NONE;
return GDK_X11_FORMAT_NONE;
}
#if 0
@ -1081,15 +1075,15 @@ list_formats (XRenderPictFormat *pf)
}
#endif
static void
convert_to_format (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
FormatType dest_format,
GdkByteOrder dest_byteorder,
gint width,
gint height)
void
_gdk_x11_convert_to_format (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
GdkX11FormatType dest_format,
GdkByteOrder dest_byteorder,
gint width,
gint height)
{
gint i;
@ -1097,14 +1091,14 @@ convert_to_format (guchar *src_buf,
{
switch (dest_format)
{
case FORMAT_EXACT_MASK:
case GDK_X11_FORMAT_EXACT_MASK:
{
memcpy (dest_buf + i * dest_rowstride,
src_buf + i * src_rowstride,
width * 4);
break;
}
case FORMAT_ARGB_MASK:
case GDK_X11_FORMAT_ARGB_MASK:
{
guchar *row = src_buf + i * src_rowstride;
if (((gsize)row & 3) != 0)
@ -1182,7 +1176,7 @@ convert_to_format (guchar *src_buf,
}
break;
}
case FORMAT_ARGB:
case GDK_X11_FORMAT_ARGB:
{
guchar *p = (src_buf + i * src_rowstride);
guchar *q = (dest_buf + i * dest_rowstride);
@ -1218,7 +1212,7 @@ convert_to_format (guchar *src_buf,
#undef MULT
break;
}
case FORMAT_NONE:
case GDK_X11_FORMAT_NONE:
g_assert_not_reached ();
break;
}
@ -1228,7 +1222,7 @@ convert_to_format (guchar *src_buf,
static void
draw_with_images (GdkDrawable *drawable,
GdkGC *gc,
FormatType format_type,
GdkX11FormatType format_type,
XRenderPictFormat *format,
XRenderPictFormat *mask_format,
guchar *src_rgb,
@ -1273,10 +1267,10 @@ draw_with_images (GdkDrawable *drawable,
image = _gdk_image_get_scratch (screen, width1, height1, 32, &xs0, &ys0);
convert_to_format (src_rgb + y0 * src_rowstride + 4 * x0, src_rowstride,
(guchar *)image->mem + ys0 * image->bpl + xs0 * image->bpp, image->bpl,
format_type, image->byte_order,
width1, height1);
_gdk_x11_convert_to_format (src_rgb + y0 * src_rowstride + 4 * x0, src_rowstride,
(guchar *)image->mem + ys0 * image->bpl + xs0 * image->bpp, image->bpl,
format_type, image->byte_order,
width1, height1);
gdk_draw_image (pix, pix_gc,
image, xs0, ys0, x0, y0, width1, height1);
@ -1352,7 +1346,7 @@ get_shm_pixmap_for_image (Display *xdisplay,
static gboolean
draw_with_pixmaps (GdkDrawable *drawable,
GdkGC *gc,
FormatType format_type,
GdkX11FormatType format_type,
XRenderPictFormat *format,
XRenderPictFormat *mask_format,
guchar *src_rgb,
@ -1386,10 +1380,10 @@ draw_with_pixmaps (GdkDrawable *drawable,
if (!get_shm_pixmap_for_image (xdisplay, image, format, mask_format, &pix, &pict, &mask))
return FALSE;
convert_to_format (src_rgb + y0 * src_rowstride + 4 * x0, src_rowstride,
(guchar *)image->mem + ys0 * image->bpl + xs0 * image->bpp, image->bpl,
format_type, image->byte_order,
width1, height1);
_gdk_x11_convert_to_format (src_rgb + y0 * src_rowstride + 4 * x0, src_rowstride,
(guchar *)image->mem + ys0 * image->bpl + xs0 * image->bpp, image->bpl,
format_type, image->byte_order,
width1, height1);
XRenderComposite (xdisplay, PictOpOver, pict, mask, dest_pict,
xs0, ys0, xs0, ys0, x0 + dest_x, y0 + dest_y,
@ -1415,7 +1409,7 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable,
gint x_dither,
gint y_dither)
{
FormatType format_type;
GdkX11FormatType format_type;
XRenderPictFormat *format, *mask_format;
gint rowstride;
#ifdef USE_SHM
@ -1425,7 +1419,7 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable,
format_type = select_format (gdk_drawable_get_display (drawable),
&format, &mask_format);
if (format_type == FORMAT_NONE ||
if (format_type == GDK_X11_FORMAT_NONE ||
!gdk_pixbuf_get_has_alpha (pixbuf) ||
gdk_drawable_get_depth (drawable) == 1 ||
(dither == GDK_RGB_DITHER_MAX && gdk_drawable_get_depth (drawable) != 24) ||

View File

@ -41,6 +41,14 @@ extern "C" {
/* Drawable implementation for X11
*/
typedef enum
{
GDK_X11_FORMAT_NONE,
GDK_X11_FORMAT_EXACT_MASK,
GDK_X11_FORMAT_ARGB_MASK,
GDK_X11_FORMAT_ARGB
} GdkX11FormatType;
typedef struct _GdkDrawableImplX11 GdkDrawableImplX11;
typedef struct _GdkDrawableImplX11Class GdkDrawableImplX11Class;
@ -73,6 +81,15 @@ struct _GdkDrawableImplX11Class
GType _gdk_drawable_impl_x11_get_type (void);
void _gdk_x11_convert_to_format (guchar *src_buf,
gint src_rowstride,
guchar *dest_buf,
gint dest_rowstride,
GdkX11FormatType dest_format,
GdkByteOrder dest_byteorder,
gint width,
gint height);
#ifdef __cplusplus
}
#endif /* __cplusplus */