#ifdef HAVE_XCURSOR
static XcursorImage*
-create_cursor_image (GdkPixbuf *pixbuf,
- gint x,
+create_cursor_image (GdkPixbuf *pixbuf,
+ gint x,
gint y)
{
guint width, height, rowstride, n_channels;
guchar *pixels, *src;
XcursorImage *xcimage;
XcursorPixel *dest;
- guchar a;
- gint i, j;
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
xcimage = XcursorImageCreate (width, height);
-
+
xcimage->xhot = x;
xcimage->yhot = y;
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];
-
- *dest = (a << 24) | (src[0] << 16) | (src[1] << 8) | src[2];
+ 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];
+ }
+
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;
}
* 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)
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
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
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.
*mask = NULL;
if (*format)
- return FORMAT_ARGB;
+ return GDK_X11_FORMAT_ARGB;
- return FORMAT_NONE;
+ return GDK_X11_FORMAT_NONE;
}
#if 0
}
#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;
{
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)
}
break;
}
- case FORMAT_ARGB:
+ case GDK_X11_FORMAT_ARGB:
{
guchar *p = (src_buf + i * src_rowstride);
guchar *q = (dest_buf + i * dest_rowstride);
#undef MULT
break;
}
- case FORMAT_NONE:
+ case GDK_X11_FORMAT_NONE:
g_assert_not_reached ();
break;
}
static void
draw_with_images (GdkDrawable *drawable,
GdkGC *gc,
- FormatType format_type,
+ GdkX11FormatType format_type,
XRenderPictFormat *format,
XRenderPictFormat *mask_format,
guchar *src_rgb,
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);
static gboolean
draw_with_pixmaps (GdkDrawable *drawable,
GdkGC *gc,
- FormatType format_type,
+ GdkX11FormatType format_type,
XRenderPictFormat *format,
XRenderPictFormat *mask_format,
guchar *src_rgb,
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,
gint x_dither,
gint y_dither)
{
- FormatType format_type;
+ GdkX11FormatType format_type;
XRenderPictFormat *format, *mask_format;
gint rowstride;
#ifdef USE_SHM
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) ||