forked from AuroraMiddleware/gtk
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:
parent
fbe92667af
commit
1408c75941
11
ChangeLog
11
ChangeLog
@ -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>
|
2004-06-16 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a
|
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a
|
||||||
|
@ -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>
|
2004-06-16 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a
|
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a
|
||||||
|
@ -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>
|
2004-06-16 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a
|
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a
|
||||||
|
@ -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>
|
2004-06-16 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a
|
* gtk/gtkfilesystemmodel.c (do_files_added): When inserting a
|
||||||
|
@ -305,16 +305,14 @@ gdk_cursor_get_display (GdkCursor *cursor)
|
|||||||
#ifdef HAVE_XCURSOR
|
#ifdef HAVE_XCURSOR
|
||||||
|
|
||||||
static XcursorImage*
|
static XcursorImage*
|
||||||
create_cursor_image (GdkPixbuf *pixbuf,
|
create_cursor_image (GdkPixbuf *pixbuf,
|
||||||
gint x,
|
gint x,
|
||||||
gint y)
|
gint y)
|
||||||
{
|
{
|
||||||
guint width, height, rowstride, n_channels;
|
guint width, height, rowstride, n_channels;
|
||||||
guchar *pixels, *src;
|
guchar *pixels, *src;
|
||||||
XcursorImage *xcimage;
|
XcursorImage *xcimage;
|
||||||
XcursorPixel *dest;
|
XcursorPixel *dest;
|
||||||
guchar a;
|
|
||||||
gint i, j;
|
|
||||||
|
|
||||||
width = gdk_pixbuf_get_width (pixbuf);
|
width = gdk_pixbuf_get_width (pixbuf);
|
||||||
height = gdk_pixbuf_get_height (pixbuf);
|
height = gdk_pixbuf_get_height (pixbuf);
|
||||||
@ -324,27 +322,37 @@ create_cursor_image (GdkPixbuf *pixbuf,
|
|||||||
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
||||||
|
|
||||||
xcimage = XcursorImageCreate (width, height);
|
xcimage = XcursorImageCreate (width, height);
|
||||||
|
|
||||||
xcimage->xhot = x;
|
xcimage->xhot = x;
|
||||||
xcimage->yhot = y;
|
xcimage->yhot = y;
|
||||||
|
|
||||||
dest = xcimage->pixels;
|
dest = xcimage->pixels;
|
||||||
|
|
||||||
for (j = 0; j < height; j++)
|
if (n_channels == 3)
|
||||||
{
|
{
|
||||||
src = pixels + j * rowstride;
|
gint i, j;
|
||||||
for (i = 0; i < width; i++)
|
|
||||||
{
|
for (j = 0; j < height; j++)
|
||||||
if (n_channels == 3)
|
{
|
||||||
a = 0xff;
|
src = pixels + j * rowstride;
|
||||||
else
|
for (i = 0; i < width; i++)
|
||||||
a = src[3];
|
{
|
||||||
|
*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;
|
src += n_channels;
|
||||||
dest++;
|
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;
|
return xcimage;
|
||||||
}
|
}
|
||||||
|
@ -921,14 +921,8 @@ gdk_x11_drawable_get_xid (GdkDrawable *drawable)
|
|||||||
* what's the fastest depending on the available picture formats,
|
* what's the fastest depending on the available picture formats,
|
||||||
* whether we can used shared pixmaps, etc.
|
* 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,
|
select_format (GdkDisplay *display,
|
||||||
XRenderPictFormat **format,
|
XRenderPictFormat **format,
|
||||||
XRenderPictFormat **mask)
|
XRenderPictFormat **mask)
|
||||||
@ -937,7 +931,7 @@ select_format (GdkDisplay *display,
|
|||||||
XRenderPictFormat pf;
|
XRenderPictFormat pf;
|
||||||
|
|
||||||
if (!_gdk_x11_have_render (display))
|
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
|
/* 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
|
* in memory data format. We can use them as pixmap and mask
|
||||||
@ -993,7 +987,7 @@ select_format (GdkDisplay *display,
|
|||||||
0);
|
0);
|
||||||
|
|
||||||
if (*format && *mask)
|
if (*format && *mask)
|
||||||
return FORMAT_EXACT_MASK;
|
return GDK_X11_FORMAT_EXACT_MASK;
|
||||||
|
|
||||||
/* OK, that failed, now look for xRGB and Axxx formats in
|
/* OK, that failed, now look for xRGB and Axxx formats in
|
||||||
* RENDER's preferred order
|
* RENDER's preferred order
|
||||||
@ -1023,7 +1017,7 @@ select_format (GdkDisplay *display,
|
|||||||
0);
|
0);
|
||||||
|
|
||||||
if (*format && *mask)
|
if (*format && *mask)
|
||||||
return FORMAT_ARGB_MASK;
|
return GDK_X11_FORMAT_ARGB_MASK;
|
||||||
|
|
||||||
/* Finally, if neither of the above worked, fall back to
|
/* Finally, if neither of the above worked, fall back to
|
||||||
* looking for combined ARGB -- we'll premultiply ourselves.
|
* looking for combined ARGB -- we'll premultiply ourselves.
|
||||||
@ -1048,9 +1042,9 @@ select_format (GdkDisplay *display,
|
|||||||
*mask = NULL;
|
*mask = NULL;
|
||||||
|
|
||||||
if (*format)
|
if (*format)
|
||||||
return FORMAT_ARGB;
|
return GDK_X11_FORMAT_ARGB;
|
||||||
|
|
||||||
return FORMAT_NONE;
|
return GDK_X11_FORMAT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -1081,15 +1075,15 @@ list_formats (XRenderPictFormat *pf)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
void
|
||||||
convert_to_format (guchar *src_buf,
|
_gdk_x11_convert_to_format (guchar *src_buf,
|
||||||
gint src_rowstride,
|
gint src_rowstride,
|
||||||
guchar *dest_buf,
|
guchar *dest_buf,
|
||||||
gint dest_rowstride,
|
gint dest_rowstride,
|
||||||
FormatType dest_format,
|
GdkX11FormatType dest_format,
|
||||||
GdkByteOrder dest_byteorder,
|
GdkByteOrder dest_byteorder,
|
||||||
gint width,
|
gint width,
|
||||||
gint height)
|
gint height)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
@ -1097,14 +1091,14 @@ convert_to_format (guchar *src_buf,
|
|||||||
{
|
{
|
||||||
switch (dest_format)
|
switch (dest_format)
|
||||||
{
|
{
|
||||||
case FORMAT_EXACT_MASK:
|
case GDK_X11_FORMAT_EXACT_MASK:
|
||||||
{
|
{
|
||||||
memcpy (dest_buf + i * dest_rowstride,
|
memcpy (dest_buf + i * dest_rowstride,
|
||||||
src_buf + i * src_rowstride,
|
src_buf + i * src_rowstride,
|
||||||
width * 4);
|
width * 4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FORMAT_ARGB_MASK:
|
case GDK_X11_FORMAT_ARGB_MASK:
|
||||||
{
|
{
|
||||||
guchar *row = src_buf + i * src_rowstride;
|
guchar *row = src_buf + i * src_rowstride;
|
||||||
if (((gsize)row & 3) != 0)
|
if (((gsize)row & 3) != 0)
|
||||||
@ -1182,7 +1176,7 @@ convert_to_format (guchar *src_buf,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FORMAT_ARGB:
|
case GDK_X11_FORMAT_ARGB:
|
||||||
{
|
{
|
||||||
guchar *p = (src_buf + i * src_rowstride);
|
guchar *p = (src_buf + i * src_rowstride);
|
||||||
guchar *q = (dest_buf + i * dest_rowstride);
|
guchar *q = (dest_buf + i * dest_rowstride);
|
||||||
@ -1218,7 +1212,7 @@ convert_to_format (guchar *src_buf,
|
|||||||
#undef MULT
|
#undef MULT
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FORMAT_NONE:
|
case GDK_X11_FORMAT_NONE:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1228,7 +1222,7 @@ convert_to_format (guchar *src_buf,
|
|||||||
static void
|
static void
|
||||||
draw_with_images (GdkDrawable *drawable,
|
draw_with_images (GdkDrawable *drawable,
|
||||||
GdkGC *gc,
|
GdkGC *gc,
|
||||||
FormatType format_type,
|
GdkX11FormatType format_type,
|
||||||
XRenderPictFormat *format,
|
XRenderPictFormat *format,
|
||||||
XRenderPictFormat *mask_format,
|
XRenderPictFormat *mask_format,
|
||||||
guchar *src_rgb,
|
guchar *src_rgb,
|
||||||
@ -1273,10 +1267,10 @@ draw_with_images (GdkDrawable *drawable,
|
|||||||
|
|
||||||
image = _gdk_image_get_scratch (screen, width1, height1, 32, &xs0, &ys0);
|
image = _gdk_image_get_scratch (screen, width1, height1, 32, &xs0, &ys0);
|
||||||
|
|
||||||
convert_to_format (src_rgb + y0 * src_rowstride + 4 * x0, src_rowstride,
|
_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,
|
(guchar *)image->mem + ys0 * image->bpl + xs0 * image->bpp, image->bpl,
|
||||||
format_type, image->byte_order,
|
format_type, image->byte_order,
|
||||||
width1, height1);
|
width1, height1);
|
||||||
|
|
||||||
gdk_draw_image (pix, pix_gc,
|
gdk_draw_image (pix, pix_gc,
|
||||||
image, xs0, ys0, x0, y0, width1, height1);
|
image, xs0, ys0, x0, y0, width1, height1);
|
||||||
@ -1352,7 +1346,7 @@ get_shm_pixmap_for_image (Display *xdisplay,
|
|||||||
static gboolean
|
static gboolean
|
||||||
draw_with_pixmaps (GdkDrawable *drawable,
|
draw_with_pixmaps (GdkDrawable *drawable,
|
||||||
GdkGC *gc,
|
GdkGC *gc,
|
||||||
FormatType format_type,
|
GdkX11FormatType format_type,
|
||||||
XRenderPictFormat *format,
|
XRenderPictFormat *format,
|
||||||
XRenderPictFormat *mask_format,
|
XRenderPictFormat *mask_format,
|
||||||
guchar *src_rgb,
|
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))
|
if (!get_shm_pixmap_for_image (xdisplay, image, format, mask_format, &pix, &pict, &mask))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
convert_to_format (src_rgb + y0 * src_rowstride + 4 * x0, src_rowstride,
|
_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,
|
(guchar *)image->mem + ys0 * image->bpl + xs0 * image->bpp, image->bpl,
|
||||||
format_type, image->byte_order,
|
format_type, image->byte_order,
|
||||||
width1, height1);
|
width1, height1);
|
||||||
|
|
||||||
XRenderComposite (xdisplay, PictOpOver, pict, mask, dest_pict,
|
XRenderComposite (xdisplay, PictOpOver, pict, mask, dest_pict,
|
||||||
xs0, ys0, xs0, ys0, x0 + dest_x, y0 + dest_y,
|
xs0, ys0, xs0, ys0, x0 + dest_x, y0 + dest_y,
|
||||||
@ -1415,7 +1409,7 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable,
|
|||||||
gint x_dither,
|
gint x_dither,
|
||||||
gint y_dither)
|
gint y_dither)
|
||||||
{
|
{
|
||||||
FormatType format_type;
|
GdkX11FormatType format_type;
|
||||||
XRenderPictFormat *format, *mask_format;
|
XRenderPictFormat *format, *mask_format;
|
||||||
gint rowstride;
|
gint rowstride;
|
||||||
#ifdef USE_SHM
|
#ifdef USE_SHM
|
||||||
@ -1425,7 +1419,7 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable,
|
|||||||
format_type = select_format (gdk_drawable_get_display (drawable),
|
format_type = select_format (gdk_drawable_get_display (drawable),
|
||||||
&format, &mask_format);
|
&format, &mask_format);
|
||||||
|
|
||||||
if (format_type == FORMAT_NONE ||
|
if (format_type == GDK_X11_FORMAT_NONE ||
|
||||||
!gdk_pixbuf_get_has_alpha (pixbuf) ||
|
!gdk_pixbuf_get_has_alpha (pixbuf) ||
|
||||||
gdk_drawable_get_depth (drawable) == 1 ||
|
gdk_drawable_get_depth (drawable) == 1 ||
|
||||||
(dither == GDK_RGB_DITHER_MAX && gdk_drawable_get_depth (drawable) != 24) ||
|
(dither == GDK_RGB_DITHER_MAX && gdk_drawable_get_depth (drawable) != 24) ||
|
||||||
|
@ -41,6 +41,14 @@ extern "C" {
|
|||||||
/* Drawable implementation for X11
|
/* 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 _GdkDrawableImplX11 GdkDrawableImplX11;
|
||||||
typedef struct _GdkDrawableImplX11Class GdkDrawableImplX11Class;
|
typedef struct _GdkDrawableImplX11Class GdkDrawableImplX11Class;
|
||||||
|
|
||||||
@ -73,6 +81,15 @@ struct _GdkDrawableImplX11Class
|
|||||||
|
|
||||||
GType _gdk_drawable_impl_x11_get_type (void);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
Loading…
Reference in New Issue
Block a user