[gtk+/rendering-cleanup-next: 2/199] API: add gdk_cairo_get_clip_rectangle() convenience API
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup-next: 2/199] API: add gdk_cairo_get_clip_rectangle() convenience API
- Date: Thu, 23 Sep 2010 21:19:16 +0000 (UTC)
commit 3f87e161d67c49cefd6d0738365a5d314ef7ec0b
Author: Benjamin Otte <otte redhat com>
Date: Thu Sep 9 01:45:54 2010 +0200
API: add gdk_cairo_get_clip_rectangle() convenience API
docs/reference/gdk/gdk3-sections.txt | 1 +
gdk/gdk.symbols | 1 +
gdk/gdkcairo.c | 39 ++++++++++++++++++++++++++++++++++
gdk/gdkcairo.h | 2 +
4 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index 0b57d32..d03fa85 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -594,6 +594,7 @@ gdk_pango_context_get_for_screen
<FILE>cairo_interaction</FILE>
gdk_window_create_similar_surface
gdk_cairo_create
+gdk_cairo_get_clip_rectangle
gdk_cairo_set_source_color
gdk_cairo_set_source_pixbuf
gdk_cairo_set_source_window
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index a5ec76e..cc9dbcf 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -288,6 +288,7 @@ gdk_visual_type_get_type G_GNUC_CONST
#if IN_FILE(__GDK_CAIRO_C__)
gdk_cairo_create
gdk_cairo_reset_clip
+gdk_cairo_get_clip_rectangle
gdk_cairo_set_source_color
gdk_cairo_set_source_pixbuf
gdk_cairo_set_source_window
diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c
index 7a7fc83..3ef1ce2 100644
--- a/gdk/gdkcairo.c
+++ b/gdk/gdkcairo.c
@@ -90,6 +90,45 @@ gdk_cairo_reset_clip (cairo_t *cr,
}
/**
+ * gdk_cairo_get_clip_rectangle:
+ * @cr: a cairo context
+ * @rect: (out) (allow-none): return location for the clip, or %NULL
+ *
+ * This is a convenience function around cairo_clip_extents(). It rounds
+ * the clip extents to integer coordinates and returns a boolean
+ * indicating if a clip area exists.
+ *
+ * Returns: %TRUE if a clip rectangle exists, %FALSE if all of @cr is
+ * clipped and all drawing can be skipped.
+ **/
+gboolean
+gdk_cairo_get_clip_rectangle (cairo_t *cr,
+ GdkRectangle *rect)
+{
+ double x1, y1, x2, y2;
+ gboolean clip_exists;
+
+ cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
+
+ clip_exists = x1 < x2 && y1 < y2;
+
+ if (rect)
+ {
+ x1 = floor (x1);
+ y1 = floor (y1);
+ x2 = ceil (x2);
+ y2 = ceil (y2);
+
+ rect->x = CLAMP (x1, G_MININT, G_MAXINT);
+ rect->y = CLAMP (y1, G_MININT, G_MAXINT);
+ rect->width = CLAMP (x2 - x1, G_MININT, G_MAXINT);
+ rect->height = CLAMP (y2 - y1, G_MININT, G_MAXINT);
+ }
+
+ return clip_exists;
+}
+
+/**
* gdk_cairo_set_source_color:
* @cr: a #cairo_t
* @color: a #GdkColor
diff --git a/gdk/gdkcairo.h b/gdk/gdkcairo.h
index 99afc06..6da2000 100644
--- a/gdk/gdkcairo.h
+++ b/gdk/gdkcairo.h
@@ -33,6 +33,8 @@ G_BEGIN_DECLS
cairo_t *gdk_cairo_create (GdkDrawable *drawable);
void gdk_cairo_reset_clip (cairo_t *cr,
GdkDrawable *drawable);
+gboolean gdk_cairo_get_clip_rectangle(cairo_t *cr,
+ GdkRectangle *rect);
void gdk_cairo_set_source_color (cairo_t *cr,
const GdkColor *color);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]