#include "Xcopyright.h" /* * Written by: Michael Bidun 9/85 * modified by Michael Bidun 11/5/85 */ #include "X.h" #include "Xproto.h" #include "Xint.h" #include "dix.h" /* returns : 1 = no clipping needed - all inside. * -1 = no clipping needed - all outside. * 0 = clipping needed. */ int clip (r, x1, y1, x2, y2) register BOX *r; /* clipping region */ register int x1, y1, x2, y2; /* extents */ { if ( (x1 >= r->x1) && (x1 <= r->x2) && (x2 >= r->x1) && (x2 <= r->x2) && (y1 >= r->y1) && (y1 <= r->y2) && (y2 >= r->y1) && (y2 <= r->y2)) return(1); /* trivial accept */ if (( x2 < r->x1 ) || /* only have to check vertex each -- tdn */ ( x1 > r->x2 ) || ( y2 < r->y1 ) || ( y1 > r->y2 ) ) return(-1); /* trivial reject */ return(0); /* must clip */ }