summaryrefslogtreecommitdiff
path: root/gdk/win32/gdkgc-win32.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2005-03-18 01:23:23 +0000
committerOwen Taylor <otaylor@src.gnome.org>2005-03-18 01:23:23 +0000
commit368f15ca59c2383346c5aa2e67142c6b5ced0766 (patch)
tree613f40fb30e62dfca714907fafcdf15231a3f2cf /gdk/win32/gdkgc-win32.c
parentd1bc66a20cdf7692282fdfb85e0dd7af98ead25d (diff)
downloadgtk+-368f15ca59c2383346c5aa2e67142c6b5ced0766.tar.gz
Use cairo_set_device_offset().
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()
Diffstat (limited to 'gdk/win32/gdkgc-win32.c')
-rw-r--r--gdk/win32/gdkgc-win32.c66
1 files changed, 23 insertions, 43 deletions
diff --git a/gdk/win32/gdkgc-win32.c b/gdk/win32/gdkgc-win32.c
index 3b520417ce..787a013546 100644
--- a/gdk/win32/gdkgc-win32.c
+++ b/gdk/win32/gdkgc-win32.c
@@ -475,7 +475,6 @@ _gdk_win32_gc_new (GdkDrawable *drawable,
GDK_NOTE (GC, g_print ("\n"));
win32_gc->hdc = NULL;
- win32_gc->hwnd = NULL;
return gc;
}
@@ -764,7 +763,6 @@ gdk_gc_copy (GdkGC *dst_gc,
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 @@ predraw (GdkGC *gc,
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 @@ gdk_win32_hdc_get (GdkDrawable *drawable,
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 @@ gdk_win32_hdc_release (GdkDrawable *drawable,
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 @@ gdk_win32_hdc_release (GdkDrawable *drawable,
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));