[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing to offscreen bitmap bombs

At 10:52 AM 9/7/93 -0600, Tom McDougal wrote:
>Thanks to Mark, Bill, and Daniel for their assistance.  Is it ok to give
>WITH-PORT an uninitialized port?  If so (I tried it and it seemed to work),
>then Bill's code can be simplified somewhat:
>>(rlet ((port :grafport))
>>  (unwind-protect
>>    (without-interrupts              ; omit; subsumed by with-port
>>     (with-focused-view nil          ; omit
>>       (with-port (ccl::%getport)
>>         (#_openPort port)
>>         (#_setPortBits *bitmap-1*)
>>         (#_moveTo 20 20)
>>         (#_lineTo 70 30))))
>>    (#_closePort port)))
>(rlet ((port :grafport))
>  (unwind-protect
>    (with-port port          ; ok?  port is not yet initialized
>      (#_openPort port)
>      (#_setPortBits *bitmap-1*)
>      ;; various drawing commands
>      )
>    (#_closePort port)))

Since you initialize the port first thing and WITH-PORT's body is executed
WITHOUT-INTERRUPTS, this looks OK to me.

>Regarding with-focused-view, the docs say:
> If [the view is] nil, the current GrafPort is set to an invisible 
> GrafPort.
>Invisible GrafPort?  Maybe then I don't have to create an additional port? 
>What is the usual purpose of this invisible GrafPort?

I don't advise playing with the invisible port. It's implementation could change
sometime in the future. It's purpose was to make sure that some port is always
the current port so if you do drawing commands without focusing, the output
will be swallowed instead of causing a crash.