[gtk+/rendering-cleanup: 30/141] API: Remove gdk_cursor_new_from_pixmap()



commit ef6aaab76726161a5c96ef7180ba519543e0165a
Author: Benjamin Otte <otte redhat com>
Date:   Thu Aug 12 15:43:23 2010 +0200

    API: Remove gdk_cursor_new_from_pixmap()
    
    gdk_cursor_new_from_pixbuf() is the proper replacement.

 docs/reference/gdk/gdk3-sections.txt |    1 -
 docs/reference/gdk/tmpl/cursors.sgml |   15 +---
 gdk/gdk.symbols                      |    1 -
 gdk/gdkcursor.h                      |    6 --
 gdk/quartz/gdkcursor-quartz.c        |   85 ------------------
 gdk/win32/gdkcursor-win32.c          |  163 ----------------------------------
 gdk/x11/gdkcursor-x11.c              |  124 +++++++++++---------------
 7 files changed, 54 insertions(+), 341 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index 4f22a94..34fecff 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -938,7 +938,6 @@ gdk_owner_change_get_type
 GdkCursor
 GdkCursorType
 gdk_cursor_new
-gdk_cursor_new_from_pixmap
 gdk_cursor_new_from_pixbuf
 gdk_cursor_new_from_name
 gdk_cursor_new_for_display
diff --git a/docs/reference/gdk/tmpl/cursors.sgml b/docs/reference/gdk/tmpl/cursors.sgml
index ab5f74d..3ac8b29 100644
--- a/docs/reference/gdk/tmpl/cursors.sgml
+++ b/docs/reference/gdk/tmpl/cursors.sgml
@@ -125,7 +125,7 @@ The standard cursors available.
 @GDK_LAST_CURSOR: last cursor type
 @GDK_BLANK_CURSOR: Blank cursor. Since 2.16
 @GDK_CURSOR_IS_PIXMAP: type of cursors constructed with 
-  gdk_cursor_new_from_pixmap() or gdk_cursor_new_from_pixbuf()
+  gdk_cursor_new_from_pixbuf()
 
 <!-- ##### FUNCTION gdk_cursor_new ##### -->
 <para>
@@ -136,19 +136,6 @@ The standard cursors available.
 @Returns: 
 
 
-<!-- ##### FUNCTION gdk_cursor_new_from_pixmap ##### -->
-<para>
-</para>
-
- source: 
- mask: 
- fg: 
- bg: 
- x: 
- y: 
- Returns: 
-
-
 <!-- ##### FUNCTION gdk_cursor_new_from_pixbuf ##### -->
 <para>
 
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index a2b7554..f97e1f0 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -335,7 +335,6 @@ gdk_cursor_unref
 gdk_cursor_get_display
 gdk_cursor_new_for_display
 gdk_cursor_new_from_pixbuf
-gdk_cursor_new_from_pixmap
 gdk_cursor_new_from_name
 gdk_cursor_get_image
 #endif
diff --git a/gdk/gdkcursor.h b/gdk/gdkcursor.h
index 5446188..91fd6d5 100644
--- a/gdk/gdkcursor.h
+++ b/gdk/gdkcursor.h
@@ -141,12 +141,6 @@ GdkCursor* gdk_cursor_new_for_display	 (GdkDisplay      *display,
 #ifndef GDK_MULTIHEAD_SAFE
 GdkCursor* gdk_cursor_new		 (GdkCursorType	   cursor_type);
 #endif
-GdkCursor* gdk_cursor_new_from_pixmap	 (GdkPixmap	  *source,
-					  GdkPixmap	  *mask,
-					  const GdkColor  *fg,
-					  const GdkColor  *bg,
-					  gint		   x,
-					  gint		   y);
 GdkCursor* gdk_cursor_new_from_pixbuf	 (GdkDisplay      *display,
 					  GdkPixbuf       *pixbuf,
 					  gint             x,
diff --git a/gdk/quartz/gdkcursor-quartz.c b/gdk/quartz/gdkcursor-quartz.c
index dcd4220..96dc770 100644
--- a/gdk/quartz/gdkcursor-quartz.c
+++ b/gdk/quartz/gdkcursor-quartz.c
@@ -237,91 +237,6 @@ gdk_cursor_new_for_display (GdkDisplay    *display,
   return gdk_quartz_cursor_new_from_nscursor (nscursor, cursor_type);
 }
 
-GdkCursor*
-gdk_cursor_new_from_pixmap (GdkPixmap      *source,
-			    GdkPixmap      *mask,
-			    const GdkColor *fg,
-			    const GdkColor *bg,
-			    gint            x,
-			    gint            y)
-{
-  NSBitmapImageRep *bitmap_rep;
-  NSImage *image;
-  NSCursor *nscursor;
-  GdkCursor *cursor;
-  int width, height;
-  gint tmp_x, tmp_y;
-  guchar *dst_data, *mask_data, *src_data;
-  guchar *mask_start, *src_start;
-  int dst_stride;
-
-  g_return_val_if_fail (GDK_IS_PIXMAP (source), NULL);
-  g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL);
-  g_return_val_if_fail (fg != NULL, NULL);
-  g_return_val_if_fail (bg != NULL, NULL);
-
-  GDK_QUARTZ_ALLOC_POOL;
-
-  gdk_drawable_get_size (source, &width, &height);
-
-  bitmap_rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
-		pixelsWide:(NSInteger)width pixelsHigh:(NSInteger)height
-		bitsPerSample:8 samplesPerPixel:4
-		hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace
-		bytesPerRow:0 bitsPerPixel:0];
-
-  dst_stride = [bitmap_rep bytesPerRow];
-  mask_start = GDK_PIXMAP_IMPL_QUARTZ (GDK_PIXMAP_OBJECT (mask)->impl)->data;
-  src_start = GDK_PIXMAP_IMPL_QUARTZ (GDK_PIXMAP_OBJECT (source)->impl)->data;
-
-  for (tmp_y = 0; tmp_y < height; tmp_y++)
-    {
-      dst_data = [bitmap_rep bitmapData] + tmp_y * dst_stride;
-      mask_data = mask_start + tmp_y * width;
-      src_data = src_start + tmp_y * width;
-
-      for (tmp_x = 0; tmp_x < width; tmp_x++)
-	{
-	  if (*mask_data++)
-	    {
-	      const GdkColor *color;
-
-	      if (*src_data++)
-		color = fg;
-	      else
-		color = bg;
-
-	      *dst_data++ = (color->red >> 8) & 0xff;
-	      *dst_data++ = (color->green >> 8) & 0xff;
-	      *dst_data++ = (color->blue >> 8) & 0xff;
-	      *dst_data++ = 0xff;
-
-	    }
-	  else
-	    {
-	      *dst_data++ = 0x00;
-	      *dst_data++ = 0x00;
-	      *dst_data++ = 0x00;
-	      *dst_data++ = 0x00;
-
-	      src_data++;
-	    }
-	}
-    }
-  image = [[NSImage alloc] init];
-  [image addRepresentation:bitmap_rep];
-  [bitmap_rep release];
-
-  nscursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(x, y)];
-  [image release];
-
-  cursor = gdk_quartz_cursor_new_from_nscursor (nscursor, GDK_CURSOR_IS_PIXMAP);
-
-  GDK_QUARTZ_RELEASE_POOL;
-
-  return cursor;
-}
-
 static NSImage *
 _gdk_quartz_pixbuf_to_ns_image (GdkPixbuf *pixbuf)
 {
diff --git a/gdk/win32/gdkcursor-win32.c b/gdk/win32/gdkcursor-win32.c
index d3d709a..6c10945 100644
--- a/gdk/win32/gdkcursor-win32.c
+++ b/gdk/win32/gdkcursor-win32.c
@@ -178,169 +178,6 @@ color_is_white (const GdkColor *color)
 	  && color->blue == 0xFFFF);
 }
 
-GdkCursor*
-gdk_cursor_new_from_pixmap (GdkPixmap      *source,
-			    GdkPixmap      *mask,
-			    const GdkColor *fg,
-			    const GdkColor *bg,
-			    gint            x,
-			    gint            y)
-{
-  GdkPixmapImplWin32 *source_impl, *mask_impl;
-  guchar *source_bits, *mask_bits;
-  gint source_bpl, mask_bpl;
-  HCURSOR hcursor;
-  guchar *p, *q, *xor_mask, *and_mask;
-  gint width, height, cursor_width, cursor_height;
-  guchar residue;
-  gint ix, iy;
-  const gboolean bg_is_white = color_is_white (bg);
-  
-  g_return_val_if_fail (GDK_IS_PIXMAP (source), NULL);
-  g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL);
-  g_return_val_if_fail (fg != NULL, NULL);
-  g_return_val_if_fail (bg != NULL, NULL);
-
-  source_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (source)->impl);
-  mask_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (mask)->impl);
-
-  g_return_val_if_fail (source_impl->width == mask_impl->width
-			&& source_impl->height == mask_impl->height,
-			NULL);
-  width = source_impl->width;
-  height = source_impl->height;
-  cursor_width = GetSystemMetrics (SM_CXCURSOR);
-  cursor_height = GetSystemMetrics (SM_CYCURSOR);
-
-  g_return_val_if_fail (width <= cursor_width && height <= cursor_height,
-			NULL);
-
-  residue = (1 << ((8-(width%8))%8)) - 1;
-
-  source_bits = source_impl->bits;
-  mask_bits = mask_impl->bits;
-
-  g_return_val_if_fail (GDK_PIXMAP_OBJECT (source)->depth == 1
-  			&& GDK_PIXMAP_OBJECT (mask)->depth == 1,
-			NULL);
-
-  source_bpl = ((width - 1)/32 + 1)*4;
-  mask_bpl = ((mask_impl->width - 1)/32 + 1)*4;
-
-  GDK_NOTE (CURSOR, {
-      g_print ("gdk_cursor_new_from_pixmap: source=%p:\n",
-	       source_impl->parent_instance.handle);
-      for (iy = 0; iy < height; iy++)
-	{
-	  if (iy == 16)
-	    break;
-
-	  p = source_bits + iy*source_bpl;
-	  for (ix = 0; ix < width; ix++)
-	    {
-	      if (ix == 79)
-		break;
-	      g_print ("%c", ".X"[((*p)>>(7-(ix%8)))&1]);
-	      if ((ix%8) == 7)
-		p++;
-	    }
-	  g_print ("\n");
-	}
-      g_print ("...mask=%p:\n", mask_impl->parent_instance.handle);
-      for (iy = 0; iy < height; iy++)
-	{
-	  if (iy == 16)
-	    break;
-
-	  p = mask_bits + iy*source_bpl;
-	  for (ix = 0; ix < width; ix++)
-	    {
-	      if (ix == 79)
-		break;
-	      g_print ("%c", ".X"[((*p)>>(7-(ix%8)))&1]);
-	      if ((ix%8) == 7)
-		p++;
-	    }
-	  g_print ("\n");
-	}
-    });
-
-  /* Such complex bit manipulation for this simple task, sigh.
-   * The X cursor and Windows cursor concepts are quite different.
-   * We assume here that we are always called with fg == black and
-   * bg == white, *or* the other way around. Random colours won't work.
-   * (Well, you will get a cursor, but not in those colours.)
-   */
-
-  /* Note: The comments below refer to the case fg==black and
-   * bg==white, as that was what was implemented first. The fg==white
-   * (the "if (fg->pixel)" branches) case was added later.
-   */
-
-  /* First set masked-out source bits, as all source bits matter on Windoze.
-   * As we invert them below, they will be clear in the final xor_mask.
-   */
-  for (iy = 0; iy < height; iy++)
-    {
-      p = source_bits + iy*source_bpl;
-      q = mask_bits + iy*mask_bpl;
-      
-      for (ix = 0; ix < ((width-1)/8+1); ix++)
-	if (bg_is_white)
-	  *p++ |= ~(*q++);
-	else
-	  *p++ &= *q++;
-    }
-
-  /* XOR mask is initialized to zero */
-  xor_mask = g_malloc0 (cursor_width/8 * cursor_height);
-
-  for (iy = 0; iy < height; iy++)
-    {
-      p = source_bits + iy*source_bpl;
-      q = xor_mask + iy*cursor_width/8;
-
-      for (ix = 0; ix < ((width-1)/8+1); ix++)
-	if (bg_is_white)
-	  *q++ = ~(*p++);
-	else
-	  *q++ = *p++;
-
-      q[-1] &= ~residue;	/* Clear left-over bits */
-    }
-      
-  /* AND mask is initialized to ones */
-  and_mask = g_malloc (cursor_width/8 * cursor_height);
-  memset (and_mask, 0xFF, cursor_width/8 * cursor_height);
-
-  for (iy = 0; iy < height; iy++)
-    {
-      p = mask_bits + iy*mask_bpl;
-      q = and_mask + iy*cursor_width/8;
-
-      for (ix = 0; ix < ((width-1)/8+1); ix++)
-	*q++ = ~(*p++);
-
-      q[-1] |= residue;	/* Set left-over bits */
-    }
-      
-  hcursor = CreateCursor (_gdk_app_hmodule, x, y, cursor_width, cursor_height,
-			  and_mask, xor_mask);
-
-  GDK_NOTE (CURSOR, g_print ("gdk_cursor_new_from_pixmap: "
-			     "%p (%dx%d) %p (%dx%d) = %p (%dx%d)\n",
-			     GDK_PIXMAP_HBITMAP (source),
-			     source_impl->width, source_impl->height,
-			     GDK_PIXMAP_HBITMAP (mask),
-			     mask_impl->width, mask_impl->height,
-			     hcursor, cursor_width, cursor_height));
-
-  g_free (xor_mask);
-  g_free (and_mask);
-
-  return cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
-}
-
 /* FIXME: The named cursors below are presumably not really useful, as
  * the names are Win32-specific. No GTK+ application developed on Unix
  * (and most cross-platform GTK+ apps are developed on Unix) is going
diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c
index a96af58..cf54f5c 100644
--- a/gdk/x11/gdkcursor-x11.c
+++ b/gdk/x11/gdkcursor-x11.c
@@ -306,75 +306,6 @@ gdk_cursor_new_for_display (GdkDisplay    *display,
   return cursor;
 }
 
-/**
- * gdk_cursor_new_from_pixmap:
- * @source: the pixmap specifying the cursor.
- * @mask: the pixmap specifying the mask, which must be the same size as 
- *    @source.
- * @fg: the foreground color, used for the bits in the source which are 1.
- *    The color does not have to be allocated first. 
- * @bg: the background color, used for the bits in the source which are 0.
- *    The color does not have to be allocated first.
- * @x: the horizontal offset of the 'hotspot' of the cursor. 
- * @y: the vertical offset of the 'hotspot' of the cursor.
- * 
- * Creates a new cursor from a given pixmap and mask. Both the pixmap and mask
- * must have a depth of 1 (i.e. each pixel has only 2 values - on or off).
- * The standard cursor size is 16 by 16 pixels.
- *
- * Return value: a new #GdkCursor.
- **/
-GdkCursor*
-gdk_cursor_new_from_pixmap (GdkPixmap      *source,
-			    GdkPixmap      *mask,
-			    const GdkColor *fg,
-			    const GdkColor *bg,
-			    gint            x,
-			    gint            y)
-{
-  GdkCursorPrivate *private;
-  GdkCursor *cursor;
-  Pixmap source_pixmap, mask_pixmap;
-  Cursor xcursor;
-  XColor xfg, xbg;
-  GdkDisplay *display;
-
-  g_return_val_if_fail (GDK_IS_PIXMAP (source), NULL);
-  g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL);
-  g_return_val_if_fail (fg != NULL, NULL);
-  g_return_val_if_fail (bg != NULL, NULL);
-
-  source_pixmap = GDK_PIXMAP_XID (source);
-  mask_pixmap   = GDK_PIXMAP_XID (mask);
-  display = GDK_PIXMAP_DISPLAY (source);
-
-  xfg.pixel = fg->pixel;
-  xfg.red = fg->red;
-  xfg.blue = fg->blue;
-  xfg.green = fg->green;
-  xbg.pixel = bg->pixel;
-  xbg.red = bg->red;
-  xbg.blue = bg->blue;
-  xbg.green = bg->green;
-  
-  if (display->closed)
-    xcursor = None;
-  else
-    xcursor = XCreatePixmapCursor (GDK_DISPLAY_XDISPLAY (display),
-				   source_pixmap, mask_pixmap, &xfg, &xbg, x, y);
-  private = g_new (GdkCursorPrivate, 1);
-  private->display = display;
-  private->xcursor = xcursor;
-  private->name = NULL;
-  private->serial = theme_serial;
-
-  cursor = (GdkCursor *) private;
-  cursor->type = GDK_CURSOR_IS_PIXMAP;
-  cursor->ref_count = 1;
-  
-  return cursor;
-}
-
 void
 _gdk_cursor_destroy (GdkCursor *cursor)
 {
@@ -588,8 +519,8 @@ update_cursor (gpointer data,
  * If the windowing system supports it, existing cursors created 
  * with gdk_cursor_new(), gdk_cursor_new_for_display() and 
  * gdk_cursor_new_for_name() are updated to reflect the theme 
- * change. Custom cursors constructed with gdk_cursor_new_from_pixmap() 
- * or gdk_cursor_new_from_pixbuf() will have to be handled
+ * change. Custom cursors constructed with
+ * gdk_cursor_new_from_pixbuf() will have to be handled
  * by the application (GTK+ applications can learn about 
  * cursor theme changes by listening for change notification
  * for the corresponding #GtkSetting).
@@ -891,6 +822,57 @@ gdk_display_get_default_cursor_size (GdkDisplay *display)
 
 #else
 
+static GdkCursor*
+gdk_cursor_new_from_pixmap (GdkPixmap      *source,
+			    GdkPixmap      *mask,
+			    const GdkColor *fg,
+			    const GdkColor *bg,
+			    gint            x,
+			    gint            y)
+{
+  GdkCursorPrivate *private;
+  GdkCursor *cursor;
+  Pixmap source_pixmap, mask_pixmap;
+  Cursor xcursor;
+  XColor xfg, xbg;
+  GdkDisplay *display;
+
+  g_return_val_if_fail (GDK_IS_PIXMAP (source), NULL);
+  g_return_val_if_fail (GDK_IS_PIXMAP (mask), NULL);
+  g_return_val_if_fail (fg != NULL, NULL);
+  g_return_val_if_fail (bg != NULL, NULL);
+
+  source_pixmap = GDK_PIXMAP_XID (source);
+  mask_pixmap   = GDK_PIXMAP_XID (mask);
+  display = GDK_PIXMAP_DISPLAY (source);
+
+  xfg.pixel = fg->pixel;
+  xfg.red = fg->red;
+  xfg.blue = fg->blue;
+  xfg.green = fg->green;
+  xbg.pixel = bg->pixel;
+  xbg.red = bg->red;
+  xbg.blue = bg->blue;
+  xbg.green = bg->green;
+  
+  if (display->closed)
+    xcursor = None;
+  else
+    xcursor = XCreatePixmapCursor (GDK_DISPLAY_XDISPLAY (display),
+				   source_pixmap, mask_pixmap, &xfg, &xbg, x, y);
+  private = g_new (GdkCursorPrivate, 1);
+  private->display = display;
+  private->xcursor = xcursor;
+  private->name = NULL;
+  private->serial = theme_serial;
+
+  cursor = (GdkCursor *) private;
+  cursor->type = GDK_CURSOR_IS_PIXMAP;
+  cursor->ref_count = 1;
+  
+  return cursor;
+}
+
 GdkCursor *
 gdk_cursor_new_from_pixbuf (GdkDisplay *display, 
 			    GdkPixbuf  *pixbuf,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]