[gtk+/rendering-cleanup: 20/41] API: Make gdk_cairo_create() take a GdkWindow
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup: 20/41] API: Make gdk_cairo_create() take a GdkWindow
- Date: Tue, 23 Nov 2010 00:23:16 +0000 (UTC)
commit 270ce467b375a8663e151c66bcb0917fb45ea7b1
Author: Benjamin Otte <otte redhat com>
Date: Wed Oct 6 19:12:27 2010 +0200
API: Make gdk_cairo_create() take a GdkWindow
This is not strictly an API change as GdkDrawable is typedeffed to
GdkWindow, but it changes the header, so I'm marking it as such.
gdk_cairo_create() can only be used with windows these days, so it makes
sense to pass a window. With that, we can alseo remove the
set_cairo_clip() vfunc from GdkDrawable and implement it inside
gdkwindow.c.
gdk/gdk.symbols | 2 +-
gdk/gdkcairo.c | 36 ------------------------------------
gdk/gdkcairo.h | 2 +-
gdk/gdkdrawable.h | 3 ---
gdk/gdkwindow.c | 39 ++++++++++++++++++++++++++++++++-------
5 files changed, 34 insertions(+), 48 deletions(-)
---
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index bf25cfa..127e3ee 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -286,7 +286,6 @@ gdk_visual_type_get_type G_GNUC_CONST
#if IN_HEADER(__GDK_CAIRO_H__)
#if IN_FILE(__GDK_CAIRO_C__)
-gdk_cairo_create
gdk_cairo_get_clip_rectangle
gdk_cairo_set_source_color
gdk_cairo_set_source_rgba
@@ -548,6 +547,7 @@ gdk_window_impl_x11_get_type G_GNUC_CONST
#if IN_HEADER(__GDK_WINDOW_H__)
#if IN_FILE(__GDK_WINDOW_C__)
+gdk_cairo_create
gdk_get_default_root_window
gdk_window_new
gdk_window_show_unraised
diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c
index a554241..7fe0ccc 100644
--- a/gdk/gdkcairo.c
+++ b/gdk/gdkcairo.c
@@ -43,42 +43,6 @@
/**
- * gdk_cairo_create:
- * @drawable: a #GdkDrawable
- *
- * Creates a Cairo context for drawing to @drawable.
- *
- * <note><para>
- * Note that due to double-buffering, Cairo contexts created
- * in a GTK+ expose event handler cannot be cached and reused
- * between different expose events.
- * </para></note>
- *
- * Return value: A newly created Cairo context. Free with
- * cairo_destroy() when you are done drawing.
- *
- * Since: 2.8
- **/
-cairo_t *
-gdk_cairo_create (GdkDrawable *drawable)
-{
- cairo_surface_t *surface;
- cairo_t *cr;
-
- g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
-
- surface = _gdk_drawable_ref_cairo_surface (drawable);
- cr = cairo_create (surface);
-
- if (GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip)
- GDK_DRAWABLE_GET_CLASS (drawable)->set_cairo_clip (drawable, cr);
-
- cairo_surface_destroy (surface);
-
- return cr;
-}
-
-/**
* gdk_cairo_get_clip_rectangle:
* @cr: a cairo context
* @rect: (out) (allow-none): return location for the clip, or %NULL
diff --git a/gdk/gdkcairo.h b/gdk/gdkcairo.h
index f594f8b..67e08aa 100644
--- a/gdk/gdkcairo.h
+++ b/gdk/gdkcairo.h
@@ -31,7 +31,7 @@
G_BEGIN_DECLS
-cairo_t *gdk_cairo_create (GdkDrawable *drawable);
+cairo_t *gdk_cairo_create (GdkWindow *window);
gboolean gdk_cairo_get_clip_rectangle(cairo_t *cr,
GdkRectangle *rect);
diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h
index a32c185..24fa122 100644
--- a/gdk/gdkdrawable.h
+++ b/gdk/gdkdrawable.h
@@ -67,9 +67,6 @@ struct _GdkDrawableClass
cairo_surface_t *(*ref_cairo_surface) (GdkDrawable *drawable);
- void (*set_cairo_clip) (GdkDrawable *drawable,
- cairo_t *cr);
-
cairo_surface_t * (*create_cairo_surface) (GdkDrawable *drawable,
int width,
int height);
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index fc742cf..923a1de 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -224,8 +224,6 @@ static cairo_surface_t *gdk_window_create_cairo_surface (GdkDrawable *drawable,
int width,
int height);
static void gdk_window_drop_cairo_surface (GdkWindowObject *private);
-static void gdk_window_set_cairo_clip (GdkDrawable *drawable,
- cairo_t *cr);
static cairo_region_t* gdk_window_get_clip_region (GdkDrawable *drawable);
static cairo_region_t* gdk_window_get_visible_region (GdkDrawable *drawable);
@@ -385,7 +383,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
drawable_class->ref_cairo_surface = gdk_window_ref_cairo_surface;
drawable_class->create_cairo_surface = gdk_window_create_cairo_surface;
- drawable_class->set_cairo_clip = gdk_window_set_cairo_clip;
drawable_class->get_clip_region = gdk_window_get_clip_region;
drawable_class->get_visible_region = gdk_window_get_visible_region;
@@ -3717,11 +3714,35 @@ gdk_window_ref_cairo_surface (GdkDrawable *drawable)
return surface;
}
-static void
-gdk_window_set_cairo_clip (GdkDrawable *drawable,
- cairo_t *cr)
+/**
+ * gdk_cairo_create:
+ * @drawable: a #GdkWindow
+ *
+ * Creates a Cairo context for drawing to @window.
+ *
+ * <note><warning>
+ * Note that calling cairo_reset_clip() on the resulting #cairo_t will
+ * produce undefined results, so avoid it at all costs.
+ * </warning></note>
+ *
+ * Return value: A newly created Cairo context. Free with
+ * cairo_destroy() when you are done drawing.
+ *
+ * Since: 2.8
+ **/
+cairo_t *
+gdk_cairo_create (GdkWindow *window)
{
- GdkWindowObject *private = (GdkWindowObject*) drawable;
+ GdkWindowObject *private;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+
+ private = (GdkWindowObject*) window;
+
+ surface = _gdk_drawable_ref_cairo_surface (window);
+ cr = cairo_create (surface);
if (!private->paint_stack)
{
@@ -3755,6 +3776,10 @@ gdk_window_set_cairo_clip (GdkDrawable *drawable,
cairo_clip (cr);
}
}
+
+ cairo_surface_destroy (surface);
+
+ return cr;
}
/* Code for dirty-region queueing
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]