summaryrefslogtreecommitdiff
path: root/src/cairo-traps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-traps.c')
-rw-r--r--src/cairo-traps.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/cairo-traps.c b/src/cairo-traps.c
index e786ad42a..9b44d38ea 100644
--- a/src/cairo-traps.c
+++ b/src/cairo-traps.c
@@ -608,3 +608,40 @@ _cairo_traps_contain (cairo_traps_t *traps, double x, double y)
return 0;
}
+
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+static void
+_cairo_trap_extents (cairo_trapezoid_t *t, cairo_box_t *extents)
+{
+ cairo_fixed_t x;
+
+ if (t->top < extents->p1.y)
+ extents->p1.y = t->top;
+
+ if (t->bottom > extents->p2.y)
+ extents->p2.y = t->bottom;
+
+ x = MIN (_compute_x (&t->left, t->top),
+ _compute_x (&t->left, t->bottom));
+ if (x < extents->p1.x)
+ extents->p1.x = x;
+
+ x = MAX (_compute_x (&t->right, t->top),
+ _compute_x (&t->right, t->bottom));
+ if (x > extents->p2.x)
+ extents->p2.x = x;
+}
+
+void
+_cairo_traps_extents (cairo_traps_t *traps, cairo_box_t *extents)
+{
+ int i;
+
+ extents->p1.x = extents->p1.y = SHRT_MAX << 16;
+ extents->p2.x = extents->p2.y = SHRT_MIN << 16;
+
+ for (i = 0; i < traps->num_traps; i++)
+ _cairo_trap_extents (&traps->traps[i], extents);
+}