[gs-devel] Re: Another good excercise

Leonardo leonardo at artifex.com
Wed Jan 10 13:47:25 PST 2007


Folks,

Thanks to all who responded to this.
Here I update it with Alex's observation :

#define signed_eo(a) ((a) < 0 ? -((a) & 1) : ((a) & 1))
#define ADVANCE_WINDING(inside, alp, ll) \
{ int k = alp->contour_count; \
  int v = ll->windings[k]; \
  inside -= signed_eo(v); \
  v = ll->windings[k] += alp->direction; \
  inside += signed_eo(v); \
}

I should have explain constraints, in which it forks.
Sorry that I didn't at first time.

1. The variable alp varies in the inner loop,
which executes it. 'll' is a constant :

int inside = 0;

for (.......; alp = alp->next) {
    ..........
    ADVANCE_WINDING(inside, alp, ll)
    ..........
    if (inside)
        fill();
}

2. alp->direction is either 1 or -1. No other values.

3. There is no other change to ll->windings .

See details in gs/src/gxfilltr.h rev. 7594.

I guess an optimization may be done
with dispatching cases and algebra.
Note : within ADVANCE_WINDING one of two 
calls to signed_eo returns zero anyway.

Leo.




More information about the gs-devel mailing list