[gimp] app: use cairo_region_t for canvas items if cairo >= 1.10 is available
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: use cairo_region_t for canvas items if cairo >= 1.10 is available
- Date: Mon, 18 Oct 2010 18:02:11 +0000 (UTC)
commit 479082075bb9d7e69909091a34a5386f15622a9e
Author: Michael Natterer <mitch gimp org>
Date: Mon Oct 18 19:59:13 2010 +0200
app: use cairo_region_t for canvas items if cairo >= 1.10 is available
This is a gross hack that typedefs around between GdkRegion and
cairo_region_t and has some evil #ifdefs. This is going to die
immeditately once we can depend on cairo 1.10.
app/display/display-types.h | 9 ++++
app/display/gimpcanvasarc.c | 32 ++++++++------
app/display/gimpcanvasboundary.c | 34 ++++++++------
app/display/gimpcanvascorner.c | 32 ++++++++------
app/display/gimpcanvascursor.c | 32 ++++++++------
app/display/gimpcanvasgrid.c | 40 +++++++++--------
app/display/gimpcanvasgroup.c | 59 +++++++++++++++----------
app/display/gimpcanvasguide.c | 38 +++++++++-------
app/display/gimpcanvashandle.c | 32 ++++++++------
app/display/gimpcanvasitem.c | 78 ++++++++++++++++++++-------------
app/display/gimpcanvasitem.h | 78 ++++++++++++++++----------------
app/display/gimpcanvaslayerboundary.c | 34 +++++++-------
app/display/gimpcanvasline.c | 32 ++++++++------
app/display/gimpcanvaspath.c | 40 +++++++++--------
app/display/gimpcanvaspen.c | 38 ++++++++++------
app/display/gimpcanvaspolygon.c | 34 ++++++++------
app/display/gimpcanvasrectangle.c | 56 +++++++++++++++++-------
app/display/gimpcanvassamplepoint.c | 44 ++++++++++--------
app/display/gimpcanvastextcursor.c | 32 ++++++++------
app/display/gimpdisplayshell-expose.c | 25 ++++++++++-
app/display/gimpdisplayshell-expose.h | 2 +-
app/display/gimpdisplayshell-items.c | 4 +-
22 files changed, 473 insertions(+), 332 deletions(-)
---
diff --git a/app/display/display-types.h b/app/display/display-types.h
index 66ae14c..7873abe 100644
--- a/app/display/display-types.h
+++ b/app/display/display-types.h
@@ -24,6 +24,15 @@
#include "display/display-enums.h"
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
+#define USE_CAIRO_REGION
+#endif
+
+#ifndef USE_CAIRO_REGION
+typedef GdkRegion cairo_region_t;
+#endif
+
+
typedef struct _GimpCanvas GimpCanvas;
typedef struct _GimpCanvasItem GimpCanvasItem;
typedef struct _GimpCanvasGroup GimpCanvasGroup;
diff --git a/app/display/gimpcanvasarc.c b/app/display/gimpcanvasarc.c
index 7aaabcd..333563c 100644
--- a/app/display/gimpcanvasarc.c
+++ b/app/display/gimpcanvasarc.c
@@ -69,19 +69,19 @@ struct _GimpCanvasArcPrivate
/* local function prototypes */
-static void gimp_canvas_arc_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_arc_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_arc_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_arc_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
+static void gimp_canvas_arc_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_arc_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_arc_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_arc_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasArc, gimp_canvas_arc,
@@ -288,7 +288,7 @@ gimp_canvas_arc_draw (GimpCanvasItem *item,
_gimp_canvas_item_stroke (item, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_arc_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -305,7 +305,11 @@ gimp_canvas_arc_get_extents (GimpCanvasItem *item,
rectangle.width = ceil (center_x + radius_x + 1.5) - rectangle.x;
rectangle.height = ceil (center_y + radius_y + 1.5) - rectangle.y;
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
GimpCanvasItem *
diff --git a/app/display/gimpcanvasboundary.c b/app/display/gimpcanvasboundary.c
index 84223aa..e37887c 100644
--- a/app/display/gimpcanvasboundary.c
+++ b/app/display/gimpcanvasboundary.c
@@ -68,20 +68,20 @@ struct _GimpCanvasBoundaryPrivate
/* local function prototypes */
-static void gimp_canvas_boundary_finalize (GObject *object);
-static void gimp_canvas_boundary_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_boundary_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_boundary_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_boundary_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
+static void gimp_canvas_boundary_finalize (GObject *object);
+static void gimp_canvas_boundary_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_boundary_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_boundary_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_boundary_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasBoundary, gimp_canvas_boundary,
@@ -301,7 +301,7 @@ gimp_canvas_boundary_draw (GimpCanvasItem *item,
g_free (segs);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_boundary_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -340,7 +340,11 @@ gimp_canvas_boundary_get_extents (GimpCanvasItem *item,
rectangle.width = x2 - x1 + 4;
rectangle.height = y2 - y1 + 4;
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
GimpCanvasItem *
diff --git a/app/display/gimpcanvascorner.c b/app/display/gimpcanvascorner.c
index 4cd44f0..17eb2e7 100644
--- a/app/display/gimpcanvascorner.c
+++ b/app/display/gimpcanvascorner.c
@@ -69,19 +69,19 @@ struct _GimpCanvasCornerPrivate
/* local function prototypes */
-static void gimp_canvas_corner_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_corner_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_corner_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_corner_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
+static void gimp_canvas_corner_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_corner_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_corner_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_corner_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasCorner, gimp_canvas_corner,
@@ -408,7 +408,7 @@ gimp_canvas_corner_draw (GimpCanvasItem *item,
_gimp_canvas_item_stroke (item, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_corner_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -423,7 +423,11 @@ gimp_canvas_corner_get_extents (GimpCanvasItem *item,
rectangle.width = ceil (w + 3.0);
rectangle.height = ceil (h + 3.0);
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
GimpCanvasItem *
diff --git a/app/display/gimpcanvascursor.c b/app/display/gimpcanvascursor.c
index 6386c1c..9b95d58 100644
--- a/app/display/gimpcanvascursor.c
+++ b/app/display/gimpcanvascursor.c
@@ -62,19 +62,19 @@ struct _GimpCanvasCursorPrivate
/* local function prototypes */
-static void gimp_canvas_cursor_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_cursor_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_cursor_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_cursor_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
+static void gimp_canvas_cursor_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_cursor_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_cursor_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_cursor_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasCursor, gimp_canvas_cursor,
@@ -183,7 +183,7 @@ gimp_canvas_cursor_draw (GimpCanvasItem *item,
_gimp_canvas_item_stroke (item, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_cursor_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -199,7 +199,11 @@ gimp_canvas_cursor_get_extents (GimpCanvasItem *item,
rectangle.width = ceil (x + GIMP_CURSOR_SIZE + 1.5) - rectangle.x;
rectangle.height = ceil (y + GIMP_CURSOR_SIZE + 1.5) - rectangle.y;
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
GimpCanvasItem *
diff --git a/app/display/gimpcanvasgrid.c b/app/display/gimpcanvasgrid.c
index 660d280..304be04 100644
--- a/app/display/gimpcanvasgrid.c
+++ b/app/display/gimpcanvasgrid.c
@@ -63,23 +63,23 @@ struct _GimpCanvasGridPrivate
/* local function prototypes */
-static void gimp_canvas_grid_finalize (GObject *object);
-static void gimp_canvas_grid_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_grid_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_grid_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_grid_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
-static void gimp_canvas_grid_stroke (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
+static void gimp_canvas_grid_finalize (GObject *object);
+static void gimp_canvas_grid_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_grid_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_grid_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_grid_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
+static void gimp_canvas_grid_stroke (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
G_DEFINE_TYPE (GimpCanvasGrid, gimp_canvas_grid, GIMP_TYPE_CANVAS_ITEM)
@@ -340,7 +340,7 @@ gimp_canvas_grid_draw (GimpCanvasItem *item,
_gimp_canvas_item_stroke (item, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_grid_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -364,7 +364,11 @@ gimp_canvas_grid_get_extents (GimpCanvasItem *item,
rectangle.width = ceil (x2) - rectangle.x;
rectangle.height = ceil (y2) - rectangle.y;
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
static void
diff --git a/app/display/gimpcanvasgroup.c b/app/display/gimpcanvasgroup.c
index 14bb51d..0387606 100644
--- a/app/display/gimpcanvasgroup.c
+++ b/app/display/gimpcanvasgroup.c
@@ -58,23 +58,23 @@ struct _GimpCanvasGroupPrivate
/* local function prototypes */
-static void gimp_canvas_group_dispose (GObject *object);
-static void gimp_canvas_group_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_group_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_group_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_group_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
-static void gimp_canvas_group_child_update (GimpCanvasItem *item,
- GdkRegion *region,
- GimpCanvasGroup *group);
+static void gimp_canvas_group_dispose (GObject *object);
+static void gimp_canvas_group_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_group_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_group_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_group_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
+static void gimp_canvas_group_child_update (GimpCanvasItem *item,
+ cairo_region_t *region,
+ GimpCanvasGroup *group);
G_DEFINE_TYPE (GimpCanvasGroup, gimp_canvas_group, GIMP_TYPE_CANVAS_ITEM)
@@ -198,18 +198,18 @@ gimp_canvas_group_draw (GimpCanvasItem *item,
_gimp_canvas_item_fill (item, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_group_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GimpCanvasGroupPrivate *private = GET_PRIVATE (item);
- GdkRegion *region = NULL;
+ cairo_region_t *region = NULL;
GList *list;
for (list = private->items; list; list = g_list_next (list))
{
GimpCanvasItem *sub_item = list->data;
- GdkRegion *sub_region = gimp_canvas_item_get_extents (sub_item);
+ cairo_region_t *sub_region = gimp_canvas_item_get_extents (sub_item);
if (! region)
{
@@ -217,8 +217,13 @@ gimp_canvas_group_get_extents (GimpCanvasItem *item,
}
else if (sub_region)
{
+#ifdef USE_CAIRO_REGION
+ cairo_region_union (region, sub_region);
+ cairo_region_destroy (sub_region);
+#else
gdk_region_union (region, sub_region);
gdk_region_destroy (sub_region);
+#endif
}
}
@@ -227,7 +232,7 @@ gimp_canvas_group_get_extents (GimpCanvasItem *item,
static void
gimp_canvas_group_child_update (GimpCanvasItem *item,
- GdkRegion *region,
+ cairo_region_t *region,
GimpCanvasGroup *group)
{
if (_gimp_canvas_item_needs_update (GIMP_CANVAS_ITEM (group)))
@@ -269,12 +274,16 @@ gimp_canvas_group_add_item (GimpCanvasGroup *group,
if (_gimp_canvas_item_needs_update (GIMP_CANVAS_ITEM (group)))
{
- GdkRegion *region = gimp_canvas_item_get_extents (item);
+ cairo_region_t *region = gimp_canvas_item_get_extents (item);
if (region)
{
_gimp_canvas_item_update (GIMP_CANVAS_ITEM (group), region);
+#ifdef USE_CAIRO_REGION
+ cairo_region_destroy (region);
+#else
gdk_region_destroy (region);
+#endif
}
}
@@ -306,12 +315,16 @@ gimp_canvas_group_remove_item (GimpCanvasGroup *group,
if (_gimp_canvas_item_needs_update (GIMP_CANVAS_ITEM (group)))
{
- GdkRegion *region = gimp_canvas_item_get_extents (item);
+ cairo_region_t *region = gimp_canvas_item_get_extents (item);
if (region)
{
_gimp_canvas_item_update (GIMP_CANVAS_ITEM (group), region);
+#ifdef USE_CAIRO_REGION
+ cairo_region_destroy (region);
+#else
gdk_region_destroy (region);
+#endif
}
}
diff --git a/app/display/gimpcanvasguide.c b/app/display/gimpcanvasguide.c
index 919c0b6..6476b80 100644
--- a/app/display/gimpcanvasguide.c
+++ b/app/display/gimpcanvasguide.c
@@ -60,22 +60,22 @@ struct _GimpCanvasGuidePrivate
/* local function prototypes */
-static void gimp_canvas_guide_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_guide_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_guide_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_guide_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
-static void gimp_canvas_guide_stroke (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
+static void gimp_canvas_guide_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_guide_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_guide_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_guide_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
+static void gimp_canvas_guide_stroke (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
G_DEFINE_TYPE (GimpCanvasGuide, gimp_canvas_guide, GIMP_TYPE_CANVAS_ITEM)
@@ -226,7 +226,7 @@ gimp_canvas_guide_draw (GimpCanvasItem *item,
_gimp_canvas_item_stroke (item, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_guide_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -241,7 +241,11 @@ gimp_canvas_guide_get_extents (GimpCanvasItem *item,
rectangle.width = ABS (x2 - x1) + 3.0;
rectangle.height = ABS (y2 - y1) + 3.0;
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
static void
diff --git a/app/display/gimpcanvashandle.c b/app/display/gimpcanvashandle.c
index bd1555c..08a627d 100644
--- a/app/display/gimpcanvashandle.c
+++ b/app/display/gimpcanvashandle.c
@@ -71,19 +71,19 @@ struct _GimpCanvasHandlePrivate
/* local function prototypes */
-static void gimp_canvas_handle_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_handle_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_handle_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_handle_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
+static void gimp_canvas_handle_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_handle_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_handle_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_handle_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasHandle, gimp_canvas_handle,
@@ -467,7 +467,7 @@ gimp_canvas_handle_draw (GimpCanvasItem *item,
}
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_handle_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -500,7 +500,11 @@ gimp_canvas_handle_get_extents (GimpCanvasItem *item,
break;
}
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
GimpCanvasItem *
diff --git a/app/display/gimpcanvasitem.c b/app/display/gimpcanvasitem.c
index ccd8246..c841a04 100644
--- a/app/display/gimpcanvasitem.c
+++ b/app/display/gimpcanvasitem.c
@@ -61,7 +61,7 @@ struct _GimpCanvasItemPrivate
gint suspend_stroking;
gint suspend_filling;
gint change_count;
- GdkRegion *change_region;
+ cairo_region_t *change_region;
};
#define GET_PRIVATE(item) \
@@ -72,31 +72,30 @@ struct _GimpCanvasItemPrivate
/* local function prototypes */
-static void gimp_canvas_item_constructed (GObject *object);
-static void gimp_canvas_item_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_item_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void
- gimp_canvas_item_dispatch_properties_changed (GObject *object,
- guint n_pspecs,
- GParamSpec **pspecs);
-
-static void gimp_canvas_item_real_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_item_real_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
-static void gimp_canvas_item_real_stroke (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static void gimp_canvas_item_real_fill (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
+static void gimp_canvas_item_constructed (GObject *object);
+static void gimp_canvas_item_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_item_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_item_dispatch_properties_changed (GObject *object,
+ guint n_pspecs,
+ GParamSpec **pspecs);
+
+static void gimp_canvas_item_real_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_item_real_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
+static void gimp_canvas_item_real_stroke (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static void gimp_canvas_item_real_fill (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
G_DEFINE_TYPE (GimpCanvasItem, gimp_canvas_item,
@@ -262,13 +261,17 @@ gimp_canvas_item_dispatch_properties_changed (GObject *object,
if (_gimp_canvas_item_needs_update (item))
{
- GdkRegion *region = gimp_canvas_item_get_extents (item);
+ cairo_region_t *region = gimp_canvas_item_get_extents (item);
if (region)
{
g_signal_emit (object, item_signals[UPDATE], 0,
region);
+#ifdef USE_CAIRO_REGION
+ cairo_region_destroy (region);
+#else
gdk_region_destroy (region);
+#endif
}
}
}
@@ -281,7 +284,7 @@ gimp_canvas_item_real_draw (GimpCanvasItem *item,
g_warn_if_reached ();
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_item_real_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -341,7 +344,7 @@ gimp_canvas_item_draw (GimpCanvasItem *item,
}
}
-GdkRegion *
+cairo_region_t *
gimp_canvas_item_get_extents (GimpCanvasItem *item)
{
GimpCanvasItemPrivate *private;
@@ -473,7 +476,7 @@ gimp_canvas_item_end_change (GimpCanvasItem *item)
{
if (g_signal_has_handler_pending (item, item_signals[UPDATE], 0, FALSE))
{
- GdkRegion *region = gimp_canvas_item_get_extents (item);
+ cairo_region_t *region = gimp_canvas_item_get_extents (item);
if (! region)
{
@@ -481,8 +484,13 @@ gimp_canvas_item_end_change (GimpCanvasItem *item)
}
else if (private->change_region)
{
+#ifdef USE_CAIRO_REGION
+ cairo_region_union (region, private->change_region);
+ cairo_region_destroy (private->change_region);
+#else
gdk_region_union (region, private->change_region);
gdk_region_destroy (private->change_region);
+#endif
}
private->change_region = NULL;
@@ -491,12 +499,20 @@ gimp_canvas_item_end_change (GimpCanvasItem *item)
{
g_signal_emit (item, item_signals[UPDATE], 0,
region);
+#ifdef USE_CAIRO_REGION
+ cairo_region_destroy (region);
+#else
gdk_region_destroy (region);
+#endif
}
}
else if (private->change_region)
{
+#ifdef USE_CAIRO_REGION
+ cairo_region_destroy (private->change_region);
+#else
gdk_region_destroy (private->change_region);
+#endif
private->change_region = NULL;
}
}
@@ -559,7 +575,7 @@ gimp_canvas_item_resume_filling (GimpCanvasItem *item)
void
_gimp_canvas_item_update (GimpCanvasItem *item,
- GdkRegion *region)
+ cairo_region_t *region)
{
g_signal_emit (item, item_signals[UPDATE], 0,
region);
diff --git a/app/display/gimpcanvasitem.h b/app/display/gimpcanvasitem.h
index 95ea3f2..a72342e 100644
--- a/app/display/gimpcanvasitem.h
+++ b/app/display/gimpcanvasitem.h
@@ -45,61 +45,61 @@ struct _GimpCanvasItemClass
GimpObjectClass parent_class;
/* signals */
- void (* update) (GimpCanvasItem *item,
- GdkRegion *region);
+ void (* update) (GimpCanvasItem *item,
+ cairo_region_t *region);
/* virtual functions */
- void (* draw) (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
- GdkRegion * (* get_extents) (GimpCanvasItem *item,
- GimpDisplayShell *shell);
-
- void (* stroke) (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
- void (* fill) (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
+ void (* draw) (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+ cairo_region_t * (* get_extents) (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
+
+ void (* stroke) (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+ void (* fill) (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
};
-GType gimp_canvas_item_get_type (void) G_GNUC_CONST;
+GType gimp_canvas_item_get_type (void) G_GNUC_CONST;
-void gimp_canvas_item_draw (GimpCanvasItem *item,
- cairo_t *cr);
-GdkRegion * gimp_canvas_item_get_extents (GimpCanvasItem *item);
+void gimp_canvas_item_draw (GimpCanvasItem *item,
+ cairo_t *cr);
+cairo_region_t * gimp_canvas_item_get_extents (GimpCanvasItem *item);
-void gimp_canvas_item_set_visible (GimpCanvasItem *item,
- gboolean visible);
-gboolean gimp_canvas_item_get_visible (GimpCanvasItem *item);
+void gimp_canvas_item_set_visible (GimpCanvasItem *item,
+ gboolean visible);
+gboolean gimp_canvas_item_get_visible (GimpCanvasItem *item);
-void gimp_canvas_item_set_line_cap (GimpCanvasItem *item,
- cairo_line_cap_t line_cap);
+void gimp_canvas_item_set_line_cap (GimpCanvasItem *item,
+ cairo_line_cap_t line_cap);
-void gimp_canvas_item_set_highlight (GimpCanvasItem *item,
- gboolean highlight);
-gboolean gimp_canvas_item_get_highlight (GimpCanvasItem *item);
+void gimp_canvas_item_set_highlight (GimpCanvasItem *item,
+ gboolean highlight);
+gboolean gimp_canvas_item_get_highlight (GimpCanvasItem *item);
-void gimp_canvas_item_begin_change (GimpCanvasItem *item);
-void gimp_canvas_item_end_change (GimpCanvasItem *item);
+void gimp_canvas_item_begin_change (GimpCanvasItem *item);
+void gimp_canvas_item_end_change (GimpCanvasItem *item);
-void gimp_canvas_item_suspend_stroking (GimpCanvasItem *item);
-void gimp_canvas_item_resume_stroking (GimpCanvasItem *item);
+void gimp_canvas_item_suspend_stroking (GimpCanvasItem *item);
+void gimp_canvas_item_resume_stroking (GimpCanvasItem *item);
-void gimp_canvas_item_suspend_filling (GimpCanvasItem *item);
-void gimp_canvas_item_resume_filling (GimpCanvasItem *item);
+void gimp_canvas_item_suspend_filling (GimpCanvasItem *item);
+void gimp_canvas_item_resume_filling (GimpCanvasItem *item);
/* protected */
-void _gimp_canvas_item_update (GimpCanvasItem *item,
- GdkRegion *region);
-gboolean _gimp_canvas_item_needs_update (GimpCanvasItem *item);
-void _gimp_canvas_item_stroke (GimpCanvasItem *item,
- cairo_t *cr);
-void _gimp_canvas_item_fill (GimpCanvasItem *item,
- cairo_t *cr);
+void _gimp_canvas_item_update (GimpCanvasItem *item,
+ cairo_region_t *region);
+gboolean _gimp_canvas_item_needs_update (GimpCanvasItem *item);
+void _gimp_canvas_item_stroke (GimpCanvasItem *item,
+ cairo_t *cr);
+void _gimp_canvas_item_fill (GimpCanvasItem *item,
+ cairo_t *cr);
#endif /* __GIMP_CANVAS_ITEM_H__ */
diff --git a/app/display/gimpcanvaslayerboundary.c b/app/display/gimpcanvaslayerboundary.c
index fcab4b7..4fa1c76 100644
--- a/app/display/gimpcanvaslayerboundary.c
+++ b/app/display/gimpcanvaslayerboundary.c
@@ -64,22 +64,22 @@ struct _GimpCanvasLayerBoundaryPrivate
/* local function prototypes */
-static void gimp_canvas_layer_boundary_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_layer_boundary_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_layer_boundary_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_layer_boundary_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
-static void gimp_canvas_layer_boundary_stroke (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
+static void gimp_canvas_layer_boundary_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_layer_boundary_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_layer_boundary_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_layer_boundary_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
+static void gimp_canvas_layer_boundary_stroke (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
G_DEFINE_TYPE (GimpCanvasLayerBoundary, gimp_canvas_layer_boundary,
@@ -176,7 +176,7 @@ gimp_canvas_layer_boundary_draw (GimpCanvasItem *item,
GIMP_CANVAS_ITEM_CLASS (parent_class)->draw (item, shell, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_layer_boundary_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
diff --git a/app/display/gimpcanvasline.c b/app/display/gimpcanvasline.c
index 325d763..9ae7782 100644
--- a/app/display/gimpcanvasline.c
+++ b/app/display/gimpcanvasline.c
@@ -61,19 +61,19 @@ struct _GimpCanvasLinePrivate
/* local function prototypes */
-static void gimp_canvas_line_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_line_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_line_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_line_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
+static void gimp_canvas_line_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_line_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_line_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_line_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasLine, gimp_canvas_line, GIMP_TYPE_CANVAS_ITEM)
@@ -222,7 +222,7 @@ gimp_canvas_line_draw (GimpCanvasItem *item,
_gimp_canvas_item_stroke (item, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_line_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -247,7 +247,11 @@ gimp_canvas_line_get_extents (GimpCanvasItem *item,
rectangle.height = ceil (ABS (y2 - y1) + 5.0);
}
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
GimpCanvasItem *
diff --git a/app/display/gimpcanvaspath.c b/app/display/gimpcanvaspath.c
index 0db0285..bc3abdb 100644
--- a/app/display/gimpcanvaspath.c
+++ b/app/display/gimpcanvaspath.c
@@ -64,23 +64,23 @@ struct _GimpCanvasPathPrivate
/* local function prototypes */
-static void gimp_canvas_path_finalize (GObject *object);
-static void gimp_canvas_path_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_path_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_path_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_path_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
-static void gimp_canvas_path_stroke (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
+static void gimp_canvas_path_finalize (GObject *object);
+static void gimp_canvas_path_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_path_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_path_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_path_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
+static void gimp_canvas_path_stroke (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
G_DEFINE_TYPE (GimpCanvasPath, gimp_canvas_path,
@@ -218,7 +218,7 @@ gimp_canvas_path_draw (GimpCanvasItem *item,
}
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_path_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -258,7 +258,11 @@ gimp_canvas_path_get_extents (GimpCanvasItem *item,
rectangle.height = ceil (y2 + 1.5) - rectangle.y;
}
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
return NULL;
diff --git a/app/display/gimpcanvaspen.c b/app/display/gimpcanvaspen.c
index 4d5e9e5..343cb15 100644
--- a/app/display/gimpcanvaspen.c
+++ b/app/display/gimpcanvaspen.c
@@ -62,19 +62,19 @@ struct _GimpCanvasPenPrivate
/* local function prototypes */
-static void gimp_canvas_pen_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_pen_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static GdkRegion * gimp_canvas_pen_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
-static void gimp_canvas_pen_stroke (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
+static void gimp_canvas_pen_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_pen_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static cairo_region_t * gimp_canvas_pen_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
+static void gimp_canvas_pen_stroke (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
G_DEFINE_TYPE (GimpCanvasPen, gimp_canvas_pen,
@@ -159,12 +159,12 @@ gimp_canvas_pen_get_property (GObject *object,
}
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_pen_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
GimpCanvasPenPrivate *private = GET_PRIVATE (item);
- GdkRegion *region;
+ cairo_region_t *region;
region = GIMP_CANVAS_ITEM_CLASS (parent_class)->get_extents (item, shell);
@@ -172,14 +172,22 @@ gimp_canvas_pen_get_extents (GimpCanvasItem *item,
{
GdkRectangle rectangle;
+#ifdef USE_CAIRO_REGION
+ cairo_region_get_extents (region, (cairo_rectangle_int_t *) &rectangle);
+#else
gdk_region_get_clipbox (region, &rectangle);
+#endif
rectangle.x -= ceil (private->width / 2.0);
rectangle.y -= ceil (private->width / 2.0);
rectangle.width += private->width + 1;
rectangle.height += private->width + 1;
+#ifdef USE_CAIRO_REGION
+ cairo_region_union_rectangle (region, (cairo_rectangle_int_t *) &rectangle);
+#else
gdk_region_union_with_rect (region, &rectangle);
+#endif
}
return region;
diff --git a/app/display/gimpcanvaspolygon.c b/app/display/gimpcanvaspolygon.c
index 019d71b..daac2df 100644
--- a/app/display/gimpcanvaspolygon.c
+++ b/app/display/gimpcanvaspolygon.c
@@ -60,20 +60,20 @@ struct _GimpCanvasPolygonPrivate
/* local function prototypes */
-static void gimp_canvas_polygon_finalize (GObject *object);
-static void gimp_canvas_polygon_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_polygon_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_polygon_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_polygon_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
+static void gimp_canvas_polygon_finalize (GObject *object);
+static void gimp_canvas_polygon_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_polygon_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_polygon_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_polygon_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasPolygon, gimp_canvas_polygon,
@@ -246,7 +246,7 @@ gimp_canvas_polygon_draw (GimpCanvasItem *item,
g_free (points);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_polygon_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -285,7 +285,11 @@ gimp_canvas_polygon_get_extents (GimpCanvasItem *item,
rectangle.width = x2 - x1;
rectangle.height = y2 - y1;
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
GimpCanvasItem *
diff --git a/app/display/gimpcanvasrectangle.c b/app/display/gimpcanvasrectangle.c
index 872a5f4..d7e3415 100644
--- a/app/display/gimpcanvasrectangle.c
+++ b/app/display/gimpcanvasrectangle.c
@@ -63,19 +63,19 @@ struct _GimpCanvasRectanglePrivate
/* local function prototypes */
-static void gimp_canvas_rectangle_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_rectangle_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_rectangle_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_rectangle_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
+static void gimp_canvas_rectangle_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_rectangle_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_rectangle_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_rectangle_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasRectangle, gimp_canvas_rectangle,
@@ -258,7 +258,7 @@ gimp_canvas_rectangle_draw (GimpCanvasItem *item,
_gimp_canvas_item_stroke (item, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_rectangle_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -276,11 +276,15 @@ gimp_canvas_rectangle_get_extents (GimpCanvasItem *item,
rectangle.width = ceil (w + 2.0);
rectangle.height = ceil (h + 2.0);
- return gdk_region_rectangle (&rectangle);
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
+ return gdk_region_rectangle (&rectangle);
+#endif
}
else if (w > 64 && h > 64)
{
- GdkRegion *region;
+ cairo_region_t *region;
/* left */
rectangle.x = floor (x - 1.5);
@@ -288,12 +292,20 @@ gimp_canvas_rectangle_get_extents (GimpCanvasItem *item,
rectangle.width = 3.0;
rectangle.height = ceil (h + 3.0);
+#ifdef USE_CAIRO_REGION
+ region = cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
region = gdk_region_rectangle (&rectangle);
+#endif
/* right */
rectangle.x = floor (x + w - 1.5);
+#ifdef USE_CAIRO_REGION
+ cairo_region_union_rectangle (region, (cairo_rectangle_int_t *) &rectangle);
+#else
gdk_region_union_with_rect (region, &rectangle);
+#endif
/* top */
rectangle.x = floor (x - 1.5);
@@ -301,12 +313,20 @@ gimp_canvas_rectangle_get_extents (GimpCanvasItem *item,
rectangle.width = ceil (w + 3.0);
rectangle.height = 3.0;
+#ifdef USE_CAIRO_REGION
+ cairo_region_union_rectangle (region, (cairo_rectangle_int_t *) &rectangle);
+#else
gdk_region_union_with_rect (region, &rectangle);
+#endif
/* bottom */
rectangle.y = floor (y + h - 1.5);
+#ifdef USE_CAIRO_REGION
+ cairo_region_union_rectangle (region, (cairo_rectangle_int_t *) &rectangle);
+#else
gdk_region_union_with_rect (region, &rectangle);
+#endif
return region;
}
@@ -317,7 +337,11 @@ gimp_canvas_rectangle_get_extents (GimpCanvasItem *item,
rectangle.width = ceil (w + 3.0);
rectangle.height = ceil (h + 3.0);
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
}
diff --git a/app/display/gimpcanvassamplepoint.c b/app/display/gimpcanvassamplepoint.c
index d73dff8..93f70bb 100644
--- a/app/display/gimpcanvassamplepoint.c
+++ b/app/display/gimpcanvassamplepoint.c
@@ -66,25 +66,25 @@ struct _GimpCanvasSamplePointPrivate
/* local function prototypes */
-static void gimp_canvas_sample_point_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_sample_point_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_sample_point_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_sample_point_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
-static void gimp_canvas_sample_point_stroke (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static void gimp_canvas_sample_point_fill (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
+static void gimp_canvas_sample_point_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_sample_point_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_sample_point_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_sample_point_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
+static void gimp_canvas_sample_point_stroke (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static void gimp_canvas_sample_point_fill (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
G_DEFINE_TYPE (GimpCanvasSamplePoint, gimp_canvas_sample_point,
@@ -257,7 +257,7 @@ gimp_canvas_sample_point_draw (GimpCanvasItem *item,
_gimp_canvas_item_fill (item, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_sample_point_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -281,7 +281,11 @@ gimp_canvas_sample_point_get_extents (GimpCanvasItem *item,
rectangle.width += 5;
rectangle.height += 5;
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
static void
diff --git a/app/display/gimpcanvastextcursor.c b/app/display/gimpcanvastextcursor.c
index d3e640b..c33b470 100644
--- a/app/display/gimpcanvastextcursor.c
+++ b/app/display/gimpcanvastextcursor.c
@@ -63,19 +63,19 @@ struct _GimpCanvasTextCursorPrivate
/* local function prototypes */
-static void gimp_canvas_text_cursor_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_text_cursor_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_canvas_text_cursor_draw (GimpCanvasItem *item,
- GimpDisplayShell *shell,
- cairo_t *cr);
-static GdkRegion * gimp_canvas_text_cursor_get_extents (GimpCanvasItem *item,
- GimpDisplayShell *shell);
+static void gimp_canvas_text_cursor_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_text_cursor_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_canvas_text_cursor_draw (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static cairo_region_t * gimp_canvas_text_cursor_get_extents (GimpCanvasItem *item,
+ GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpCanvasTextCursor, gimp_canvas_text_cursor,
@@ -268,7 +268,7 @@ gimp_canvas_text_cursor_draw (GimpCanvasItem *item,
_gimp_canvas_item_stroke (item, cr);
}
-static GdkRegion *
+static cairo_region_t *
gimp_canvas_text_cursor_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell)
{
@@ -294,7 +294,11 @@ gimp_canvas_text_cursor_get_extents (GimpCanvasItem *item,
rectangle.height = ceil (h + 3.0);
}
+#ifdef USE_CAIRO_REGION
+ return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
+#else
return gdk_region_rectangle (&rectangle);
+#endif
}
GimpCanvasItem *
diff --git a/app/display/gimpdisplayshell-expose.c b/app/display/gimpdisplayshell-expose.c
index b8361db..7c98525 100644
--- a/app/display/gimpdisplayshell-expose.c
+++ b/app/display/gimpdisplayshell-expose.c
@@ -46,13 +46,36 @@ gimp_display_shell_expose_area (GimpDisplayShell *shell,
void
gimp_display_shell_expose_region (GimpDisplayShell *shell,
- GdkRegion *region)
+ cairo_region_t *region)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (region != NULL);
+#ifdef USE_CAIRO_REGION
+ {
+ GdkRegion *gdk_region = gdk_region_new ();
+ gint n_rectangles;
+ gint i;
+
+ n_rectangles = cairo_region_num_rectangles (region);
+
+ for (i = 0; i < n_rectangles; i++)
+ {
+ cairo_rectangle_int_t rectangle;
+
+ cairo_region_get_rectangle (region, i, &rectangle);
+
+ gdk_region_union_with_rect (gdk_region, (GdkRectangle *) &rectangle);
+ }
+
+ gdk_window_invalidate_region (gtk_widget_get_window (shell->canvas),
+ gdk_region, TRUE);
+ gdk_region_destroy (gdk_region);
+ }
+#else
gdk_window_invalidate_region (gtk_widget_get_window (shell->canvas),
region, TRUE);
+#endif
}
void
diff --git a/app/display/gimpdisplayshell-expose.h b/app/display/gimpdisplayshell-expose.h
index 96a59cb..d3a1f2a 100644
--- a/app/display/gimpdisplayshell-expose.h
+++ b/app/display/gimpdisplayshell-expose.h
@@ -25,7 +25,7 @@ void gimp_display_shell_expose_area (GimpDisplayShell *shell,
gint w,
gint h);
void gimp_display_shell_expose_region (GimpDisplayShell *shell,
- GdkRegion *region);
+ cairo_region_t *region);
void gimp_display_shell_expose_vectors (GimpDisplayShell *shell,
GimpVectors *vectors);
void gimp_display_shell_expose_full (GimpDisplayShell *shell);
diff --git a/app/display/gimpdisplayshell-items.c b/app/display/gimpdisplayshell-items.c
index 1928852..2b80103 100644
--- a/app/display/gimpdisplayshell-items.c
+++ b/app/display/gimpdisplayshell-items.c
@@ -36,7 +36,7 @@
/* local function prototypes */
static void gimp_display_shell_item_update (GimpCanvasItem *item,
- GdkRegion *region,
+ cairo_region_t *region,
GimpDisplayShell *shell);
@@ -129,7 +129,7 @@ gimp_display_shell_remove_item (GimpDisplayShell *shell,
static void
gimp_display_shell_item_update (GimpCanvasItem *item,
- GdkRegion *region,
+ cairo_region_t *region,
GimpDisplayShell *shell)
{
gimp_display_shell_expose_region (shell, region);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]