]> Pileus Git - ~andy/gtk/commitdiff
Merge from stable:
authorMichael Natterer <mitch@gimp.org>
Mon, 21 Jun 2004 16:13:55 +0000 (16:13 +0000)
committerMichael Natterer <mitch@src.gnome.org>
Mon, 21 Jun 2004 16:13:55 +0000 (16:13 +0000)
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.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/x11/gdkcursor-x11.c
gdk/x11/gdkdrawable-x11.c
gdk/x11/gdkdrawable-x11.h

index 4b12d918fb0d01195c7f3bc09ac185d9b8760ed1..ade5e114c4ee57f91a6f2529ab7efcba88964955 100644 (file)
--- a/ChangeLog
+++ b/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>
 
        * gtk/gtkfilesystemmodel.c (do_files_added): When inserting a
index 4b12d918fb0d01195c7f3bc09ac185d9b8760ed1..ade5e114c4ee57f91a6f2529ab7efcba88964955 100644 (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
index 4b12d918fb0d01195c7f3bc09ac185d9b8760ed1..ade5e114c4ee57f91a6f2529ab7efcba88964955 100644 (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
index 4b12d918fb0d01195c7f3bc09ac185d9b8760ed1..ade5e114c4ee57f91a6f2529ab7efcba88964955 100644 (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
index ae50fc9007890aa6c04e6b06c464a2972c262ac9..51eb0e84c29731d157478da58f6dd21961dfb78c 100644 (file)
@@ -305,16 +305,14 @@ gdk_cursor_get_display (GdkCursor *cursor)
 #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);
@@ -324,27 +322,37 @@ create_cursor_image (GdkPixbuf *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;
 }
index 2c3744b77317155da610770ffc6b8d5294743b09..043b3e2dcd840d0582e46b8ece5bc26c0327fcc1 100644 (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) ||
index ea99938b3c6e832559c95dbb67086e60c7388c9f..bc3f75dbc06bd760fa3208f0a9aa58a322cf333a 100644 (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 */