Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AW: CopyBits and dual monitor configration - Problem solved



On Jul 30, 2004, at 3:19 AM, Dotzler, Josef wrote:

Calling LockPortBits did it!
After reading the documentation for LockPortBits a long time ago, I thought that it was not necessary to call this function when using Quickdraw or Quartz and didn't care about it any more. Calls to PaintRect and others seemed to confirm this. But the exception proves the rule, this is not the case for CopyBits.


Sorry to disappoint you; but I am 100% affirmative (and I should know! :-) that application code only needs to call LockPortBits when it wants to change pixels of a window backbuffer directly, i.e. by accessing GetPixBaseAddr(GetPortPixMap(GetWindowPort(w))). Specifically, you definitely don't need to call LockPortBits for CopyBits calls.

Your problem was most likely due to the current port not being set to the destination of the CopyBits call; but I cannot be absolutely sure without debugging it. If the LockPortBits call seems to "fix" the problem, then I stand behind the statement of John Stiles:
"I still suspect your real bug is elsewhere, and that this is masking the problem."


Also, there is often a confusion between LockPortBits and LockPixels.
LockPortBits(port) does nothing if the port is not a window port. For a window port, it makes sure the window buffer pixels are locked and the port's portPixMap corresponds to it.
LockPixels(pixMapHandle) does nothing if the pixMapHandle is not from a GWorld. For a GWorld, it makes sure that the GWorldPixMap's pixelBuffer is locked (rather pointless on X) and that the pixMap's baseAddr points to it. Because QD can determine itself whether LockPixels has been called or not when it should have been called, code has been added over time that deals gracefully with forgotten LockPixels calls. This feature is not documented and guaranteed, however.

Joseph Maurer
Former Quickdraw engineer
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.


References: 
 >AW: CopyBits and dual monitor configration - Problem solved (From: "Dotzler, Josef" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.