Commit 60d24b4c authored by Michael Natterer's avatar Michael Natterer 😴

app: get rid of #ifdef USE_CAIRO_REGION almost everywhere

get replaced by GDK region functions and use the cairo region
functions unconditionally all over the place.
parent 40797f1f
......@@ -29,7 +29,15 @@
#endif
#ifndef USE_CAIRO_REGION
typedef GdkRegion cairo_region_t;
#define cairo_region_t GdkRegion
#define cairo_rectangle_int_t GdkRectangle
#define cairo_region_destroy gdk_region_destroy
#define cairo_region_union gdk_region_union
#define cairo_region_create_rectangle gdk_region_rectangle
#define cairo_region_union_rectangle gdk_region_union_with_rect
#define cairo_region_get_extents gdk_region_get_clipbox
#define cairo_region_subtract gdk_region_subtract
#define cairo_region_xor gdk_region_xor
#endif
......
......@@ -305,11 +305,7 @@ 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 *
......
......@@ -340,11 +340,7 @@ 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 *
......
......@@ -423,11 +423,7 @@ 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 *
......
......@@ -199,11 +199,7 @@ 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 *
......
......@@ -364,11 +364,7 @@ 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
......
......@@ -217,13 +217,8 @@ 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
}
}
......@@ -279,11 +274,7 @@ gimp_canvas_group_add_item (GimpCanvasGroup *group,
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
}
}
......@@ -320,11 +311,7 @@ gimp_canvas_group_remove_item (GimpCanvasGroup *group,
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
}
}
......
......@@ -241,11 +241,7 @@ 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
......
......@@ -500,11 +500,7 @@ 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 *
......
......@@ -267,11 +267,7 @@ gimp_canvas_item_dispatch_properties_changed (GObject *object,
{
g_signal_emit (object, item_signals[UPDATE], 0,
region);
#ifdef USE_CAIRO_REGION
cairo_region_destroy (region);
#else
gdk_region_destroy (region);
#endif
}
}
}
......@@ -484,13 +480,8 @@ 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;
......@@ -499,20 +490,12 @@ 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;
}
}
......
......@@ -247,11 +247,7 @@ 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 *
......
......@@ -89,19 +89,11 @@ gimp_canvas_passe_partout_get_extents (GimpCanvasItem *item,
gimp_display_shell_draw_get_scaled_image_size (shell,
&rect.width, &rect.height);
#ifdef USE_CAIRO_REGION
outer = cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rect);
#else
outer = gdk_region_rectangle (&rect);
#endif
inner = GIMP_CANVAS_ITEM_CLASS (parent_class)->get_extents (item, shell);
#ifdef USE_CAIRO_REGION
cairo_region_subtract (outer, inner);
#else
gdk_region_subtract (outer, inner);
#endif
return outer;
}
......
......@@ -258,11 +258,7 @@ 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;
......
......@@ -172,22 +172,14 @@ 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;
......
......@@ -285,11 +285,7 @@ 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 *
......
......@@ -276,11 +276,7 @@ gimp_canvas_rectangle_get_extents (GimpCanvasItem *item,
rectangle.width = ceil (w + 2.0);
rectangle.height = ceil (h + 2.0);
#ifdef USE_CAIRO_REGION
return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
#else
return gdk_region_rectangle (&rectangle);
#endif
return cairo_region_create_rectangle ((cairo_rectangle_int_t *) &rectangle);
}
else if (w > 64 && h > 64)
{
......@@ -292,20 +288,12 @@ 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);
......@@ -313,20 +301,12 @@ 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;
}
......@@ -337,11 +317,7 @@ 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
}
}
......
......@@ -281,11 +281,7 @@ 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
......
......@@ -294,11 +294,7 @@ 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 *
......
......@@ -1768,33 +1768,17 @@ gimp_display_shell_set_highlight (GimpDisplayShell *shell,
if (memcmp (shell->highlight, highlight, sizeof (GdkRectangle)) == 0)
return;
#ifdef USE_CAIRO_REGION
old = cairo_region_create_rectangle ((cairo_rectangle_int_t *) shell->highlight);
#else
old = gdk_region_rectangle (shell->highlight);
#endif
*shell->highlight = *highlight;
#ifdef USE_CAIRO_REGION
new = cairo_region_create_rectangle ((cairo_rectangle_int_t *) shell->highlight);
cairo_region_xor (old, new);
#else
new = gdk_region_rectangle (shell->highlight);
gdk_region_xor (old, new);
#endif
gimp_display_shell_expose_region (shell, old);
#ifdef USE_CAIRO_REGION
cairo_region_destroy (old);
cairo_region_destroy (new);
#else
gdk_region_destroy (old);
gdk_region_destroy (new);
#endif
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment