I've got a threaded Carbon game which does all its drawing offscreen,
then does a final CopyBits.
It would be far more convenient if the drawing could be in a thread,
so I'm trying to move to Quartz. Instead of a GWorld, I make a
CGImage. Drawing goes (via CGBitmapContextCreate) to this, and I
eventually copy it to the window with CGContextDrawImage.
But nothing was really drawing, so I'm playing around with
CGContextSynchronize or QDFlushPortBuffer. My window is now (usually)
redrawn, but when I turn on Quartz Debug, it appears that any change
now dirties the entire window. I've tried QDSetDirtyRegion -- I get my
region flashed AND the entire window.
So I'm probably missing some trick relating to drawing from a thread,
though possibly it's something related to Quartz coordinates or
flushing in general.
I didn't see anything relevant in the "Transitioning to Quartz 2D"
document, or the list archives. Does anyone have general tips?
I think the primary issues would be:
- don't share a CGContext across threads; I don't believe Quartz
synchronizes context access. Use a separate context for each thread.
- I'm not sure how the default flushing done by the Event Manager will
apply to drawing done in a separate context. You may need to flush
explicitly (sounds like it given your results so far). The general
structure would be: first, draw everything, and second, call
CGContextFlush. You won't need to call CGContextSynchronize,
QDFlushPortBuffer, or QDSetDirtyRegion as long as you only draw with
Quartz and you always call CGContextFlush at the end of the drawing.
-eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden