- gfxpoly_t* currentclip = 0;
- int type = 0;
-
- /* we can't rely on gfxpoly actually being able to convert
- a gfxline into a gfxpoly- for polygons which are too
- complex or just degenerate, this might fail. So handle
- all the cases where polygon conversion or intersection
- might go awry */
- if(!poly && !oldclip) {
- i->out->startclip(i->out,line);
- currentclip = 0;
- type = 1;
- } else if(!poly && oldclip) {
- gfxline_t*oldclipline = gfxpoly_to_gfxline(oldclip);
- i->out->startclip(i->out,oldclipline);
- i->out->startclip(i->out,line);
- currentclip = 0;
- type = 2;
- } else if(poly && oldclip) {
- gfxpoly_t*intersection = gfxpoly_intersect(poly, oldclip);
- if(intersection) {
- // this case is what usually happens
- gfxpoly_free(poly);poly=0;
- currentclip = intersection;
- type = 0;
- } else {
- gfxline_t*oldclipline = gfxpoly_to_gfxline(oldclip);
- i->out->startclip(i->out, oldclipline);
- currentclip = poly;
- type = 1;
- }
- } else if(poly && !oldclip) {
- currentclip = poly;
- type = 0;
- }