[comp.lang.postscript] Setscreen question

CXT105@psuvm.psu.edu (Christopher Tate) (04/17/91)

Does binding the procedure argument to setscreen have any effect?  I.e. is

       85 35 {dup mul exch dup mul add 1.0 exch sub} bind setscreen

equivalent in function to

       85 35 {dup mul exch dup mul add 1.0 exch sub} setscreen ?

Does binding the spot function give incorrect results?  If not, it seems
like binding it should give an appreciable savings in speed, since it's
called often.  Or, it could be that the setscreen operator binds it itself,
or some other part of the imaging system does.  In that case, binding it
would have essentially no effect....

Which of the above is correct?  :-)

-------
Christopher Tate                   |
Student-Type Person                |   "The whole place is coming alive!"
cxt105@psuvm.psu.edu               |
{...}!psuvax1!psuvm.bitnet!cxt105  |   "Yeah, and we're coming *dead*...."
cxt105@psuvm.bitnet                |

deadman@garnet.berkeley.edu (Ben Haller) (04/17/91)

In article <91106.223332CXT105@psuvm.psu.edu> Christopher Tate
   <CXT105@psuvm.psu.edu> writes:
>Does binding the procedure argument to setscreen have any effect?  I.e. is
>       85 35 {dup mul exch dup mul add 1.0 exch sub} bind setscreen
>equivalent in function to
>       85 35 {dup mul exch dup mul add 1.0 exch sub} setscreen ?
>Does binding the spot function give incorrect results?  If not, it seems
>like binding it should give an appreciable savings in speed, since it's
>called often.  Or, it could be that the setscreen operator binds it itself,
>or some other part of the imaging system does.  In that case, binding it
>would have essentially no effect....

  Well, I don't claim to know very much about this.  But it's my impression
that PostScript takes the setscreen parameters, and immediately converts
that into an internal format that's much faster to use (and may be of a
different frequency, angle, etc, as explained in the book _Real World
PostScript_).  So the spot function would be called perhaps several
hundred times, the results would be tabulated and sorted, resulting in
some internal pattern format for the halftone patterns.
  So my answer is, it shouldn't matter unless you're changing the spot
function often, like within a larger loop.
  To answer the original question, I don't know if it hurts to bind it (I
don't imagine it does, but I have no idea really), and I don't know if
it would speed up that initial tabulation process or not.  Why not try it?

-Ben Haller (deadman@garnet.berkeley.edu)
"Sleeping with your devil mask / Is all I wanna do
 And when I stop, it means I'm through with YOU!  Yeah, yeah you. "
   - Robyn Hitchcock

andrew@visix.com (Andrew Bernard) (04/18/91)

In article <91106.223332CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes:
>Does binding the procedure argument to setscreen have any effect?  I.e. is
>
>       85 35 {dup mul exch dup mul add 1.0 exch sub} bind setscreen
>
>equivalent in function to
>
>       85 35 {dup mul exch dup mul add 1.0 exch sub} setscreen ?
>
>Does binding the spot function give incorrect results?  If not, it seems
>like binding it should give an appreciable savings in speed, since it's
>called often.  Or, it could be that the setscreen operator binds it itself,
>or some other part of the imaging system does.  In that case, binding it
>would have essentially no effect....
>
>Which of the above is correct?  :-)
>

It shouldn't give different results unless you've got a dictionary on the
dict stack which shadows the normal operator bindings.  As far as speed, it
probably won't make any difference, since a good interpreter will compile
the results of the samples into its own internal matrix.  So, I suspect
the sample procedure will only get called once for each pixel in the halftone
square, no matter how many times you render with it.  Of course, if you're
changing the screen a lot, I suppose it could have an impact on performance,
but that's an unusual case.

BTW, a good interpreter will do a similar optimization for _settransfer_:
the procedure gets called once for each possible grey value (this is limited
by the interpreter's internal color representation and the size of the
halftone spot) and the results are stuffed into an array which is used later
to look up the actual color values.

Try putting _print_ operators into your screen procs and you can tell how
often they get called.


-- 
     andrew bernard              ring the doorbell on your mind  
    software engineer            but it's locked from the outside
     visix software                                 -dinosaur jr.
    andrew@visix.com