Xref: utzoo comp.sys.mac.programmer:6021 comp.sys.mac:31359 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!oliveb!apple!darin From: darin@Apple.COM (Darin Adler) Newsgroups: comp.sys.mac.programmer,comp.sys.mac Subject: Re: CopyBits in MPW C 3.0 Message-ID: <1470@internal.Apple.COM> Date: 20 Apr 89 08:08:26 GMT References: <225@uw-apl.UUCP> <2403@helios.ee.lbl.gov> <1458@internal.Apple.COM> Distribution: na Organization: Apple Lines: 32 In article <1458@internal.Apple.COM> MAC.ROMOS@applelink.apple.com (Ian Hendry) writes: > In article <8904171804.AA00203@vs03csc.UMD.EDU> russotto@wam.UMD.EDU > writes: > > I've never had any problem passing dereferenced handles to CopyBits-- > > I don't believe it is a routine that moves or purges memory (I believe > > it's temp buffers are on the stack) Actually, this almost has to be > > for VBL tasks to be able to draw... > > Copybits generally does not affect memory, but in some cases it does! DO > NOT pass unlocked dereference handles! There are cases where QD may make > memory calls during copybits (which would screw up a dereferenced handle) > and even if I didn't know actual cases I sure wouldn't count on being able > to pass dereferenced handles and have future compatability! Ian is right. You should lock the handles to the pixmaps that you pass to CopyBits. One of the cases where CopyBits moves memory is where it is the first stuff drawn to a particular device. In this case, drawing to that device may cause an inverse table to be built. Again, in future system software, CopyBits may move memory in even more cases. If a VBL task is going to draw, it needs to have it's own separate heap. This is because VBL tasks can run while the contents of the heap are being moved around. During this time the contents of any relocatable blocks can be invalid (this includes the regions inherent in a port: necessary for drawing). Having a separate heap for the VBL gets around this problem, but is a bit complicated...but if you can think of a good reason to draw from a VBL task, go ahead. (You'll also need your own A5 world and QuickDraw globals since A5 might have any random value.) -- Darin Adler, System Software Scapegoat, Apple Computer Internet: darin@Apple.com UUCP: {nsc,sun}!apple!darin