Re: gdk/win32 and cairo [was: Cairo now a dependency of HEAD GTK+]



On Thu, 2005-03-17 at 15:12 +0200, Tor Lillqvist wrote:
> Owen Taylor writes:
>  > I committed a big change yesterday to make GTK+/GDK use Cairo
>  > for much of it's drawing.
> 
> Yeah, I just noticed ;-)
> 
>  > So, we need to get something in to keep the win32 port
>  > running. Unless I hear otherwise, what I'll do is fix up my patch
>  > for some changes I made in the GDK backend interface and commit
>  > that.
> 
> Sounds good... We can sort out any differences between your and Hans's
> ideas how to aproach it later. I tried to have a go at applying your
> stuff from Feb 24th, but you probably have a more current
> understanding of what it's about. I haven't been following the
> gdk/cairo/win32 development that closely for some time, but I'll
> really should try to get more involved now.

OK, I've committed something now. There are some obvious issues with
font size ... I think we aren't using the right DPI with the switch
to the Cairo Pango backend, and I've seen a few other issues that
might be attributable to not properly cleaning up DC's when we share
them between Cairo and GDK drawing.

(I had to switch gdk_win32_gc_get_hdc() to using the per-context DC
to get mixed Cairo/GDK drawing working right.)

I'm attaching what I committed to this mail.

> PS: Any comment on my suggestions in bug #58541?

Not yet, I'll try to go over it over the next few days.

Regards,
						Owen


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.6450
diff -u -r1.6450 ChangeLog
--- ChangeLog	17 Mar 2005 20:53:33 -0000	1.6450
+++ ChangeLog	18 Mar 2005 01:21:29 -0000
@@ -1,3 +1,27 @@
+2005-02-24  Owen Taylor  <otaylor redhat com>
+
+	* gdk/gdkwindow.c: Use cairo_set_device_offset().
+
+	* gdk/win32/gdkdrawable-win32.[ch] gdk/win32/gdkwindow-win32.c
+	gdk/win32/gdkpixmap-win32.c: 
+	Add_gdk_win32_drawable_acquire/release_dc() to get a DC for the 
+	drawable. Add _gdk_drawable_win32_finish() to clean up resources
+	when a drawable is destroyed.
+
+	* gdk/win32/gdkgc-win32.c gdk/win32/gdkdrawable-win32.c
+	(blit_from_pixmap) gdk/win32/gdkprivate-win32.h : Use 
+	acquire/release_dc when getting a DC to use with a GC or for 
+	blitting from a pixmap.
+
+	* gdk/win32/gdkdrawable-win32.[ch]: Implement ref_cairo_surface()
+
+	* gdk/win32/gdkpango-win32.c gdk/win32/gdkdrawable-win32.c Makefile.am:
+	Remove gdk_screen_get_pango_context(), draw_glyph[_transformed]
+	implementations.
+
+	* gdk/win32/gdkdrawable-win32.c: Remove 
+	gdk_draw_rectangle_alpha_libgtk_only()
+
 2005-03-17  Owen Taylor  <otaylor redhat com>
 
 	* gdk/gdkpango.c: Fix get_stipple_surface to actually work, set
Index: gdk/gdkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkwindow.c,v
retrieving revision 1.168
diff -u -r1.168 gdkwindow.c
--- gdk/gdkwindow.c	17 Mar 2005 01:54:38 -0000	1.168
+++ gdk/gdkwindow.c	18 Mar 2005 01:21:29 -0000
@@ -974,8 +974,8 @@
 		    MAX (clip_box.width, 1), MAX (clip_box.height, 1), -1);
 
   paint->surface = _gdk_drawable_ref_cairo_surface (paint->pixmap);
-  _gdk_windowing_set_surface_device_offset (paint->surface,
-					    - paint->x_offset, - paint->y_offset);
+  cairo_surface_set_device_offset (paint->surface,
+				   - paint->x_offset, - paint->y_offset);
   
   for (list = private->paint_stack; list != NULL; list = list->next)
     {
Index: gdk/win32/Makefile.am
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/Makefile.am,v
retrieving revision 1.21
diff -u -r1.21 Makefile.am
--- gdk/win32/Makefile.am	10 Dec 2003 13:49:54 -0000	1.21
+++ gdk/win32/Makefile.am	18 Mar 2005 01:21:29 -0000
@@ -61,7 +61,6 @@
 	gdkinput-win32.h \
 	gdkkeys-win32.c \
 	gdkmain-win32.c \
-	gdkpango-win32.c \
 	gdkpixmap-win32.c \
 	gdkpixmap-win32.h \
 	gdkprivate-win32.h \
Index: gdk/win32/gdkdrawable-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkdrawable-win32.c,v
retrieving revision 1.73
diff -u -r1.73 gdkdrawable-win32.c
--- gdk/win32/gdkdrawable-win32.c	16 Mar 2005 00:56:26 -0000	1.73
+++ gdk/win32/gdkdrawable-win32.c	18 Mar 2005 01:21:29 -0000
@@ -32,6 +32,7 @@
 #include <glib.h>
 
 #include <pango/pangowin32.h>
+#include <cairo-win32.h>
 
 #include "gdkscreen.h" /* gdk_screen_get_default() */
 #include "gdkregion-generic.h"
@@ -100,19 +101,6 @@
 				      GdkGC          *gc,
 				      GdkPoint       *points,
 				      gint            npoints);
-static void gdk_win32_draw_glyphs    (GdkDrawable      *drawable,
-				      GdkGC            *gc,
-				      PangoFont        *font,
-				      gint              x,
-				      gint              y,
-				      PangoGlyphString *glyphs);
-static void gdk_win32_draw_glyphs_transformed (GdkDrawable      *drawable,
-					     GdkGC            *gc,
-					     PangoMatrix      *matrix,
-					     PangoFont        *font,
-					     gint              x,
-					     gint              y,
-					     PangoGlyphString *glyphs);
 static void gdk_win32_draw_image     (GdkDrawable     *drawable,
 				      GdkGC           *gc,
 				      GdkImage        *image,
@@ -123,6 +111,8 @@
 				      gint             width,
 				      gint             height);
 
+static cairo_surface_t *gdk_win32_ref_cairo_surface (GdkDrawable *drawable);
+     
 static void gdk_win32_set_colormap   (GdkDrawable    *drawable,
 				      GdkColormap    *colormap);
 
@@ -139,6 +129,7 @@
 static void gdk_drawable_impl_win32_finalize   (GObject *object);
 
 static gpointer parent_class = NULL;
+static const cairo_user_data_key_t gdk_win32_cairo_key;
 
 GType
 gdk_drawable_impl_win32_get_type (void)
@@ -188,10 +179,10 @@
   drawable_class->draw_points = gdk_win32_draw_points;
   drawable_class->draw_segments = gdk_win32_draw_segments;
   drawable_class->draw_lines = gdk_win32_draw_lines;
-  drawable_class->draw_glyphs = gdk_win32_draw_glyphs;
-  drawable_class->draw_glyphs_transformed = gdk_win32_draw_glyphs_transformed;
   drawable_class->draw_image = gdk_win32_draw_image;
   
+  drawable_class->ref_cairo_surface = gdk_win32_ref_cairo_surface;
+  
   drawable_class->set_colormap = gdk_win32_set_colormap;
   drawable_class->get_colormap = gdk_win32_get_colormap;
 
@@ -1489,121 +1480,6 @@
 }
 
 static void
-draw_glyphs (GdkGCWin32 *gcwin32,
-	     HDC         hdc,
-	     gint        x_offset,
-	     gint        y_offset,
-	     va_list     args)
-{
-  PangoFont *font;
-  gint x;
-  gint y;
-  PangoGlyphString *glyphs;
-
-  font = va_arg (args, PangoFont *);
-  x = va_arg (args, gint);
-  y = va_arg (args, gint);
-  glyphs = va_arg (args, PangoGlyphString *);
-
-  x -= x_offset;
-  y -= y_offset;
-
-  pango_win32_render (hdc, font, glyphs, x, y);
-}
-
-static void
-draw_glyphs_transformed (GdkGCWin32 *gcwin32,
-			 HDC         hdc,
-			 gint        x_offset,
-			 gint        y_offset,
-			 va_list     args)
-{
-  PangoFont *font;
-  gint x;
-  gint y;
-  PangoGlyphString *glyphs;
-  PangoMatrix *matrix;
-
-  matrix = va_arg(args, PangoMatrix *);
-  font = va_arg (args, PangoFont *);
-  x = va_arg (args, gint);
-  y = va_arg (args, gint);
-  glyphs = va_arg (args, PangoGlyphString *);
-
-  x -= x_offset;
-  y -= y_offset;
-
-  pango_win32_render_transformed (hdc, matrix, font, glyphs, x, y);
-}
-
-static void
-gdk_win32_draw_glyphs (GdkDrawable      *drawable,
-		       GdkGC            *gc,
-		       PangoFont        *font,
-		       gint              x,
-		       gint              y,
-		       PangoGlyphString *glyphs)
-{
-  GdkRectangle bounds;
-  GdkRegion *region;
-  PangoRectangle ink_rect;
-
-  pango_glyph_string_extents (glyphs, font, &ink_rect, NULL);
-
-  bounds.x = x + PANGO_PIXELS (ink_rect.x) - 1;
-  bounds.y = y + PANGO_PIXELS (ink_rect.y) - 1;
-  bounds.width = PANGO_PIXELS (ink_rect.width) + 2;
-  bounds.height = PANGO_PIXELS (ink_rect.height) + 2;
-  region = gdk_region_rectangle (&bounds);
-  
-  generic_draw (drawable, gc, GDK_GC_FOREGROUND|GDK_GC_FONT,
-		draw_glyphs, region, font, x, y, glyphs);
-
-  gdk_region_destroy (region);
-}
-
-static void 
-gdk_win32_draw_glyphs_transformed (GdkDrawable      *drawable,
-				   GdkGC            *gc,
-				   PangoMatrix      *matrix,
-				   PangoFont        *font,
-				   gint              x,
-				   gint              y,
-				   PangoGlyphString *glyphs)
-{
-  GdkRectangle bounds;
-  GdkRegion *region;
-  PangoRectangle ink_rect;
-
-  pango_glyph_string_extents (glyphs, font, &ink_rect, NULL);
-
-  bounds.x = x + PANGO_PIXELS (ink_rect.x) - 1;
-  bounds.y = y + PANGO_PIXELS (ink_rect.y) - 1;
-  bounds.width = PANGO_PIXELS (ink_rect.width) + 2;
-  bounds.height = PANGO_PIXELS (ink_rect.height) + 2;
-  region = gdk_region_rectangle (&bounds);
-
-  if (matrix)
-    {
-      /* transform region */
-      bounds.x = bounds.x * matrix->xx + bounds.y * matrix->xy + matrix->x0;
-      bounds.y = bounds.x * matrix->yx + bounds.y * matrix->yy + matrix->x0;
-      bounds.width  = bounds.width  * matrix->xx + bounds.height * matrix->xy;
-      bounds.height = bounds.height * matrix->yx + bounds.width  * matrix->xy;
- 
-      generic_draw (drawable, gc, GDK_GC_FOREGROUND|GDK_GC_FONT,
-		    draw_glyphs_transformed, region, matrix, font, x, y, glyphs);
-    }
-  else
-    { 
-       generic_draw (drawable, gc, GDK_GC_FOREGROUND|GDK_GC_FONT,
-		     draw_glyphs, region, font, x/PANGO_SCALE, y/PANGO_SCALE, glyphs);
-    }
-
-  gdk_region_destroy (region);
-}
-
-static void
 blit_from_pixmap (gboolean              use_fg_bg,
 		  GdkDrawableImplWin32 *dest,
 		  HDC                   hdc,
@@ -1626,12 +1502,10 @@
   
   GDK_NOTE (MISC, g_print ("blit_from_pixmap\n"));
 
-  if (!(srcdc = CreateCompatibleDC (NULL)))
-    {
-      WIN32_GDI_FAILED ("CreateCompatibleDC");
-      return;
-    }
-      
+  srcdc = _gdk_win32_drawable_acquire_dc (GDK_DRAWABLE (src));
+  if (!srcdc)
+    return;
+  
   if (!(holdbitmap = SelectObject (srcdc, ((GdkDrawableImplWin32 *) src)->handle)))
     WIN32_GDI_FAILED ("SelectObject");
   else
@@ -1736,7 +1610,8 @@
       
       GDI_CALL (SelectObject, (srcdc, holdbitmap));
     }
-  GDI_CALL (DeleteDC, (srcdc));
+  
+  _gdk_win32_drawable_release_dc (GDK_DRAWABLE (src));
 }
 
 static void
@@ -1935,6 +1810,130 @@
 		   xsrc, ysrc, xdest, ydest, width, height);
 }
 
+/**
+ * _gdk_win32_drawable_acquire_dc
+ * @drawable: a Win32 #GdkDrawable implementation
+ * 
+ * Gets a DC with the given drawable selected into
+ * it.
+ *
+ * Return value: The DC, on success. Otherwise
+ *  %NULL. If this function succeeded
+ *  _gdk_win32_drawable_release_dc()  must be called
+ *  release the DC when you are done using it.
+ **/
+HDC 
+_gdk_win32_drawable_acquire_dc (GdkDrawable *drawable)
+{
+  GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
+  
+  if (GDK_IS_WINDOW_IMPL_WIN32 (drawable) &&
+      GDK_WINDOW_DESTROYED (impl->wrapper))
+    return NULL;
+
+  if (!impl->hdc)
+    {
+      if (GDK_IS_PIXMAP_IMPL_WIN32 (impl))
+	{
+	  impl->hdc = CreateCompatibleDC (NULL);
+	  if (!impl->hdc)
+	    WIN32_GDI_FAILED ("CreateCompatibleDC");
+	  
+	  if (impl->hdc)
+	    {
+	      impl->saved_dc_bitmap = SelectObject (impl->hdc,
+						    impl->handle);
+	      if (!impl->saved_dc_bitmap)
+		{
+		  WIN32_GDI_FAILED ("CreateCompatibleDC");
+		  DeleteDC (impl->hdc);
+		  impl->hdc = NULL;
+		}
+	    }
+	}
+      else
+	{
+	  impl->hdc = GetDC (impl->handle);
+	  if (!impl->hdc)
+	    WIN32_GDI_FAILED ("GetDC");
+	}
+    }
+
+  if (impl->hdc)
+    {
+      impl->hdc_count++;
+      return impl->hdc;
+    }
+  else
+    return NULL;
+}
+
+/**
+ * _gdk_win32_drawable_release_dc
+ * @drawable: a Win32 #GdkDrawable implementation
+ * 
+ * Releases the reference count for the DC
+ * from _gdk_win32_drawable_acquire_dc()
+ **/
+void
+_gdk_win32_drawable_release_dc (GdkDrawable *drawable)
+{
+  GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
+  
+  g_return_if_fail (impl->hdc_count > 0);
+
+  impl->hdc_count--;
+  if (impl->hdc_count == 0)
+    {
+      if (impl->saved_dc_bitmap)
+	{
+	  GDI_CALL (SelectObject, (impl->hdc, impl->saved_dc_bitmap));
+	  impl->saved_dc_bitmap = NULL;
+	}
+      
+      if (impl->hdc)
+	{
+	  GDI_CALL (DeleteDC, (impl->hdc));
+	  impl->hdc = NULL;
+	}
+    }
+}
+
+static void
+gdk_win32_cairo_surface_destroy (void *data)
+{
+  GdkDrawableImplWin32 *impl = data;
+
+  _gdk_win32_drawable_release_dc (GDK_DRAWABLE (impl));
+  impl->cairo_surface = NULL;
+}
+
+static cairo_surface_t *
+gdk_win32_ref_cairo_surface (GdkDrawable *drawable)
+{
+  GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
+
+  if (GDK_IS_WINDOW_IMPL_WIN32 (drawable) &&
+      GDK_WINDOW_DESTROYED (impl->wrapper))
+    return NULL;
+
+  if (!impl->cairo_surface)
+    {
+      HDC hdc = _gdk_win32_drawable_acquire_dc (drawable);
+      if (!hdc)
+	return NULL;
+
+      impl->cairo_surface = cairo_win32_surface_create (hdc);
+
+      cairo_surface_set_user_data (impl->cairo_surface, &gdk_win32_cairo_key,
+				   drawable, gdk_win32_cairo_surface_destroy);
+    }
+  else
+    cairo_surface_reference (impl->cairo_surface);
+
+  return impl->cairo_surface;
+}
+
 static gint
 gdk_win32_get_depth (GdkDrawable *drawable)
 {
@@ -1961,14 +1960,27 @@
   return GDK_DRAWABLE_HANDLE (drawable);
 }
 
-gboolean
-gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
-				      gint         x,
-				      gint         y,
-				      gint         width,
-				      gint         height,
-				      GdkColor    *color,
-				      guint16      alpha)
+/**
+ * _gdk_win32_drawable_finish
+ * @drawable: a Win32 #GdkDrawable implementation
+ * 
+ * Releases any resources allocated internally for the drawable.
+ * This is called when the drawable becomes unusable
+ * (gdk_window_destroy() for a window, or the refcount going to
+ * zero for a pixmap.)
+ **/
+void
+_gdk_win32_drawable_finish (GdkDrawable *drawable)
 {
-  return FALSE;
+  GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
+
+  if (impl->cairo_surface)
+    {
+      cairo_surface_finish (impl->cairo_surface);
+      cairo_surface_set_user_data (impl->cairo_surface, &gdk_win32_cairo_key,
+				   NULL, NULL);
+    }
+  
+  g_assert (impl->hdc_count == 0);
 }
+
Index: gdk/win32/gdkdrawable-win32.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkdrawable-win32.h,v
retrieving revision 1.3
diff -u -r1.3 gdkdrawable-win32.h
--- gdk/win32/gdkdrawable-win32.h	17 Feb 2002 00:25:05 -0000	1.3
+++ gdk/win32/gdkdrawable-win32.h	18 Mar 2005 01:21:29 -0000
@@ -53,6 +53,11 @@
   GdkDrawable *wrapper;
   GdkColormap *colormap;
   HANDLE handle;
+
+  guint hdc_count;
+  HDC hdc;
+  HBITMAP saved_dc_bitmap;	/* Original bitmap for dc */
+  cairo_surface_t *cairo_surface;
 };
  
 struct _GdkDrawableImplWin32Class 
@@ -62,6 +67,10 @@
 };
 
 GType gdk_drawable_impl_win32_get_type (void);
+
+HDC  _gdk_win32_drawable_acquire_dc (GdkDrawable *drawable);
+void _gdk_win32_drawable_release_dc (GdkDrawable *drawable);
+void _gdk_win32_drawable_finish     (GdkDrawable *drawable);
 
 #ifdef __cplusplus
 }
Index: gdk/win32/gdkgc-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkgc-win32.c,v
retrieving revision 1.66
diff -u -r1.66 gdkgc-win32.c
--- gdk/win32/gdkgc-win32.c	11 Mar 2005 23:50:21 -0000	1.66
+++ gdk/win32/gdkgc-win32.c	18 Mar 2005 01:21:29 -0000
@@ -475,7 +475,6 @@
   GDK_NOTE (GC, g_print ("\n"));
 
   win32_gc->hdc = NULL;
-  win32_gc->hwnd = NULL;
 
   return gc;
 }
@@ -764,7 +763,6 @@
 
   dst_win32_gc->hdc = NULL;
   dst_win32_gc->saved_dc = FALSE;
-  dst_win32_gc->hwnd = NULL;
   dst_win32_gc->holdpal = NULL;
   dst_win32_gc->pen_hbrbg = NULL;
 }
@@ -846,6 +844,21 @@
   return ok;
 }
 
+static GdkDrawableImplWin32 *
+get_impl_drawable (GdkDrawable *drawable)
+{
+  if (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable))
+    return GDK_DRAWABLE_IMPL_WIN32(drawable);
+  else if (GDK_IS_WINDOW (drawable))
+    return GDK_DRAWABLE_IMPL_WIN32 ((GDK_WINDOW_OBJECT (drawable))->impl);
+  else if (GDK_IS_PIXMAP (drawable))
+    return GDK_DRAWABLE_IMPL_WIN32 ((GDK_PIXMAP_OBJECT (drawable))->impl);
+  else
+    g_assert_not_reached ();
+
+  return NULL;
+}
+
 /**
  * gdk_win32_hdc_get:
  * @drawable: destination #GdkDrawable
@@ -911,37 +924,14 @@
 
   g_assert (win32_gc->hdc == NULL);
 
-  if (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable))
-    impl = GDK_DRAWABLE_IMPL_WIN32(drawable);
-  else if (GDK_IS_WINDOW (drawable))
-    impl = GDK_DRAWABLE_IMPL_WIN32 ((GDK_WINDOW_OBJECT (drawable))->impl);
-  else if (GDK_IS_PIXMAP (drawable))
-    impl = GDK_DRAWABLE_IMPL_WIN32 ((GDK_PIXMAP_OBJECT (drawable))->impl);
-  else
-    g_assert_not_reached ();
-
-  win32_gc->hwnd = impl->handle;
-
-  if (GDK_IS_PIXMAP_IMPL_WIN32 (impl))
-    {
-      if ((win32_gc->hdc = CreateCompatibleDC (NULL)) == NULL)
-	WIN32_GDI_FAILED ("CreateCompatibleDC"), ok = FALSE;
+  impl = get_impl_drawable (drawable);
+  
+  win32_gc->hdc = _gdk_win32_drawable_acquire_dc (GDK_DRAWABLE (impl));
+  ok = win32_gc->hdc != NULL;
 
-      if (ok && (win32_gc->saved_dc = SaveDC (win32_gc->hdc)) == 0)
-	WIN32_GDI_FAILED ("SaveDC"), ok = FALSE;
-      
-      if (ok && SelectObject (win32_gc->hdc, win32_gc->hwnd) == NULL)
-	WIN32_GDI_FAILED ("SelectObject"), ok = FALSE;
-    }
-  else
-    {
-      if ((win32_gc->hdc = GetDC (win32_gc->hwnd)) == NULL)
-	WIN32_GDI_FAILED ("GetDC");
+  if (ok && (win32_gc->saved_dc = SaveDC (win32_gc->hdc)) == 0)
+    WIN32_GDI_FAILED ("SaveDC"), ok = FALSE;
       
-      if (ok && (win32_gc->saved_dc = SaveDC (win32_gc->hdc)) == 0)
-	WIN32_GDI_FAILED ("SaveDC");
-    }
-
   if (ok && (usage & (GDK_GC_FOREGROUND | GDK_GC_BACKGROUND)))
       ok = predraw (gc, impl->colormap);
 
@@ -1061,14 +1051,7 @@
 			 win32_gc, win32_gc->hdc,
 			 _gdk_win32_gcvalues_mask_to_string (usage)));
 
-  if (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable))
-    impl = GDK_DRAWABLE_IMPL_WIN32(drawable);
-  else if (GDK_IS_WINDOW (drawable))
-    impl = GDK_DRAWABLE_IMPL_WIN32 ((GDK_WINDOW_OBJECT (drawable))->impl);
-  else if (GDK_IS_PIXMAP (drawable))
-    impl = GDK_DRAWABLE_IMPL_WIN32 ((GDK_PIXMAP_OBJECT (drawable))->impl);
-  else
-    g_assert_not_reached ();
+  impl = get_impl_drawable (drawable);
 
   if (win32_gc->holdpal != NULL)
     {
@@ -1094,10 +1077,7 @@
 
   GDI_CALL (RestoreDC, (win32_gc->hdc, win32_gc->saved_dc));
 
-  if (GDK_IS_PIXMAP_IMPL_WIN32 (impl))
-    GDI_CALL (DeleteDC, (win32_gc->hdc));
-  else
-    GDI_CALL (ReleaseDC, (win32_gc->hwnd, win32_gc->hdc));
+  _gdk_win32_drawable_release_dc (GDK_DRAWABLE (impl));
 
   if (hpen != NULL)
     GDI_CALL (DeleteObject, (hpen));
Index: gdk/win32/gdkpixmap-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkpixmap-win32.c,v
retrieving revision 1.41
diff -u -r1.41 gdkpixmap-win32.c
--- gdk/win32/gdkpixmap-win32.c	16 Mar 2005 02:21:14 -0000	1.41
+++ gdk/win32/gdkpixmap-win32.c	18 Mar 2005 01:21:29 -0000
@@ -108,6 +108,8 @@
   GDK_NOTE (PIXMAP, g_print ("gdk_pixmap_impl_win32_finalize: %p\n",
 			     GDK_PIXMAP_HBITMAP (wrapper)));
 
+  _gdk_win32_drawable_finish (GDK_DRAWABLE (object));  
+
   GDI_CALL (DeleteObject, (GDK_PIXMAP_HBITMAP (wrapper)));
 
   gdk_win32_handle_table_remove (GDK_PIXMAP_HBITMAP (wrapper));
Index: gdk/win32/gdkprivate-win32.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkprivate-win32.h,v
retrieving revision 1.68
diff -u -r1.68 gdkprivate-win32.h
--- gdk/win32/gdkprivate-win32.h	16 Mar 2005 02:21:14 -0000	1.68
+++ gdk/win32/gdkprivate-win32.h	18 Mar 2005 01:21:29 -0000
@@ -290,9 +290,6 @@
   HDC hdc;
   int saved_dc;
 
-  HANDLE hwnd;			/* For which window, or what bitmap is
-				 * selected into it
-				 */
   HPALETTE holdpal;
 };
 
Index: gdk/win32/gdkwindow-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkwindow-win32.c,v
retrieving revision 1.132
diff -u -r1.132 gdkwindow-win32.c
--- gdk/win32/gdkwindow-win32.c	16 Mar 2005 02:21:14 -0000	1.132
+++ gdk/win32/gdkwindow-win32.c	18 Mar 2005 01:21:29 -0000
@@ -857,6 +857,8 @@
 
   if (!recursing && !foreign_destroy)
     {
+      _gdk_win32_drawable_finish (private->impl);
+
       private->destroyed = TRUE;
       DestroyWindow (GDK_WINDOW_HWND (window));
     }


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