diff --git a/src/cairo-mesh-pattern-rasterizer.c b/src/cairo-mesh-pattern-rasterizer.c index 1b63ca8..baab704 100644 --- a/src/cairo-mesh-pattern-rasterizer.c +++ b/src/cairo-mesh-pattern-rasterizer.c @@ -39,6 +39,8 @@ #include "cairo-array-private.h" #include "cairo-pattern-private.h" +#include + /* * Rasterizer for mesh patterns. * @@ -165,6 +167,12 @@ sqlen (cairo_point_double_t p0, cairo_point_double_t p1) delta.x = p0.x - p1.x; delta.y = p0.y - p1.y; + if (fabs(delta.x) <= 2 * DBL_EPSILON * MAX(fabs(p0.x), fabs(p1.x))) + delta.x = 0; + + if (fabs(delta.y) <= 2 * DBL_EPSILON * MAX(fabs(p0.y), fabs(p1.y))) + delta.y = 0; + return delta.x * delta.x + delta.y * delta.y; }