* the y-x-banding that's so nice to have...
*/
-#include <config.h>
+#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <gdkregion.h>
overlapFunc overlapFn,
nonOverlapFunc nonOverlap1Fn,
nonOverlapFunc nonOverlap2Fn);
+static void miSetExtents (GdkRegion *pReg);
/**
* gdk_region_new:
return temp;
}
+GdkRegion *
+_gdk_region_new_from_yxbanded_rects (GdkRectangle *rects,
+ int num_rects)
+{
+ GdkRegion *temp;
+ int i;
+
+ temp = g_slice_new (GdkRegion);
+
+ temp->rects = g_new (GdkRegionBox, num_rects);
+ temp->size = num_rects;
+ temp->numRects = num_rects;
+ for (i = 0; i < num_rects; i++)
+ {
+ temp->rects[i].x1 = rects[i].x;
+ temp->rects[i].y1 = rects[i].y;
+ temp->rects[i].x2 = rects[i].x + rects[i].width;
+ temp->rects[i].y2 = rects[i].y + rects[i].height;
+ }
+ miSetExtents (temp);
+
+ return temp;
+}
+
+
/**
* gdk_region_rectangle:
* @rectangle: a #GdkRectangle
return TRUE;
}
+/**
+ * gdk_region_rect_equal:
+ * @region: a #GdkRegion
+ * @rectangle: a #GdkRectangle
+ *
+ * Finds out if a regions is the same as a rectangle.
+ *
+ * Returns: %TRUE if @region and @rectangle are equal.
+ *
+ * Since: 2.18
+ */
+gboolean
+gdk_region_rect_equal (const GdkRegion *region,
+ const GdkRectangle *rectangle)
+{
+ g_return_val_if_fail (region != NULL, FALSE);
+ g_return_val_if_fail (rectangle != NULL, FALSE);
+
+ if (region->numRects != 1) return FALSE;
+ else if (region->extents.x1 != rectangle->x) return FALSE;
+ else if (region->extents.y1 != rectangle->y) return FALSE;
+ else if (region->extents.x2 != rectangle->x + rectangle->width) return FALSE;
+ else if (region->extents.y2 != rectangle->y + rectangle->height) return FALSE;
+ return TRUE;
+}
+
/**
* gdk_region_point_in:
* @region: a #GdkRegion
static void
-gdk_region_unsorted_spans_intersect_foreach (GdkRegion *region,
- GdkSpan *spans,
- int n_spans,
- GdkSpanFunc function,
- gpointer data)
+gdk_region_unsorted_spans_intersect_foreach (GdkRegion *region,
+ const GdkSpan *spans,
+ int n_spans,
+ GdkSpanFunc function,
+ gpointer data)
{
gint i, left, right, y;
gint clipped_left, clipped_right;
GdkRegionBox *pbox;
GdkRegionBox *pboxEnd;
- GdkSpan out_span;
if (!region->numRects)
return;
if ((right > pbox->x1) && (left < pbox->x2))
{
+ GdkSpan out_span;
+
clipped_left = MAX (left, pbox->x1);
clipped_right = MIN (right, pbox->x2);
* Calls a function on each span in the intersection of @region and @spans.
*/
void
-gdk_region_spans_intersect_foreach (GdkRegion *region,
- GdkSpan *spans,
- int n_spans,
- gboolean sorted,
- GdkSpanFunc function,
- gpointer data)
+gdk_region_spans_intersect_foreach (GdkRegion *region,
+ const GdkSpan *spans,
+ int n_spans,
+ gboolean sorted,
+ GdkSpanFunc function,
+ gpointer data)
{
gint left, right, y;
gint clipped_left, clipped_right;
GdkRegionBox *pbox;
GdkRegionBox *pboxEnd;
- GdkSpan *span, *tmpspan;
- GdkSpan *end_span;
- GdkSpan out_span;
+ const GdkSpan *span, *tmpspan;
+ const GdkSpan *end_span;
g_return_if_fail (region != NULL);
g_return_if_fail (spans != NULL);
if ((right > pbox->x1) && (left < pbox->x2))
{
+ GdkSpan out_span;
+
clipped_left = MAX (left, pbox->x1);
clipped_right = MIN (right, pbox->x2);