/* @(#)trap_step.h 9.2 88/01/19 SMI */ /* * Copyright (c) 1985 by Sun Microsystems, Inc. */ /*- Macros for stepping down chain defined traps. trap_step.h, Wed Jun 26 21:38:50 1985 James Gosling, Sun Microsystems */ #ifndef step_down_trap struct fine_trap_state { short y, x1, x2; struct shape_trapseg next; short used; struct shape_trapseg *limit; struct shape_trapseg *start; struct shape_trapseg *seg; }; /* advances the given trap state by k pixels in y */ #define step_down_trap(t,k) { \ (t)->y += k; \ while ((t)->y >= (t)->next.y && (t)->seg<=(t)->limit) { \ (t)->x1 = (t)->next.x1; \ (t)->x2 = (t)->next.x2; \ (t)->next = *(t)->seg++; \ } \ } /* Initialize to scan down an trap */ #define init_fine_trap(t, T) { \ (t)->y = -1; \ (t)->seg = (T)->segs; \ (t)->used = (T)->used; \ (t)->start = (T)->segs; \ (t)->limit = &(T)->segs[(T)->used]; \ (t)->next = *(t)->seg++; \ } #define stepping_up_trap(t, T) { \ (t)->seg -= 3; \ (t)->next = *(t)->seg; \ } #define fast_step_up_trap_to(t,dy) { \ (t)->y = dy; \ while ((t)->next.y > (t)->y && (t)->seg > (t)->start) \ (t)->next = *--(t)->seg; \ (t)->x1 = (t)->next.x1; \ (t)->x2 = (t)->next.x2; \ if ((t)->next.y == (t)->y && (t)->seg > (t)->start) (t)->next = *--(t)->seg; \ } #define grab_trap_segment(skip) \ short x1 = dx, \ x2 = xlimit; \ register height; \ if (trap.x1 > x1) { \ sx1 = sx + trap.x1 - x1; \ x1 = trap.x1; \ } \ \ else \ sx1 = sx; \ if (trap.x2 < x2) \ x2 = trap.x2; \ if (skip) { \ if (dst.pos.x == x1) \ if (xlimit == x2) \ while (trap.next.x1 <= x1 && trap.next.x2 >= x2 && trap.next.y < ylimit) \ trap.next = *trap.seg++; \ else \ while (trap.next.x1 <= x1 && trap.next.x2 == x2 && trap.next.y < ylimit) \ trap.next = *trap.seg++; \ else if (xlimit == x2) \ while (trap.next.x1 == x1 && trap.next.x2 >= x2 && trap.next.y < ylimit) \ trap.next = *trap.seg++; \ else \ while (trap.next.x1 == x1 && trap.next.x2 == x2 && trap.next.y < ylimit) \ trap.next = *trap.seg++; \ } \ height = (trap.seg < trap.limit ? trap.next.y \ : shape->trapset->bottom) - trap.y; \ if (height <= 0) \ break; \ if (height > dst.size.y) \ height = dst.size.y; \ step_down_trap(&trap, height); #define step_up_trap(t,k) fast_step_up_trap_to(t,(t)->y-k) #endif