diff --git a/cairo/src/cairo-bentley-ottmann.c b/cairo/src/cairo-bentley-ottmann.c
index 1da9743..d4f9256 100644
--- a/cairo/src/cairo-bentley-ottmann.c
+++ b/cairo/src/cairo-bentley-ottmann.c
@@ -1427,6 +1427,8 @@ _cairo_bentley_ottmann_tessellate_polygon (cairo_traps_t	*traps,
     cairo_fixed_t ymin = 0x7FFFFFFF;
     cairo_fixed_t xmax = -0x80000000;
     cairo_fixed_t ymax = -0x80000000;
+    cairo_box_t limit;
+    cairo_bool_t has_limits = _cairo_traps_get_limit(traps, &limit);
     int num_bo_edges;
     int i;
 
@@ -1471,6 +1473,13 @@ _cairo_bentley_ottmann_tessellate_polygon (cairo_traps_t	*traps,
 	cairo_point_t top = polygon->edges[i].edge.p1;
 	cairo_point_t bot = polygon->edges[i].edge.p2;
 
+        /* Discard the edge if traps doesn't care. */
+        if (has_limits) {
+                /* Strictly above or below the limits? */
+                if (bot.y <= limit.p1.y || top.y >= limit.p2.y)
+                        continue;
+        }
+
 	/* Offset coordinates into the non-negative range. */
 	top.x -= xmin;
 	top.y -= ymin;
diff --git a/cairo/src/cairo-gstate.c b/cairo/src/cairo-gstate.c
index 0f35b7f..e0b4cc6 100644
--- a/cairo/src/cairo-gstate.c
+++ b/cairo/src/cairo-gstate.c
@@ -1028,10 +1028,17 @@ _cairo_gstate_in_fill (cairo_gstate_t	  *gstate,
 {
     cairo_status_t status;
     cairo_traps_t traps;
+    cairo_box_t limit;
 
     _cairo_gstate_user_to_backend (gstate, &x, &y);
 
+    limit.p1.x = _cairo_fixed_from_double (x) - 1;
+    limit.p1.y = _cairo_fixed_from_double (y) - 1;
+    limit.p2.x = limit.p1.x + 2;
+    limit.p2.y = limit.p1.y + 2;
+
     _cairo_traps_init (&traps);
+    _cairo_traps_limit (&traps, &limit);
 
     status = _cairo_path_fixed_fill_to_traps (path,
 					      gstate->fill_rule,
