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: Quartz from a thread



On Mon, 24 Jan 2005 14:09:25 -0800, David Dunham <email@hidden> wrote:
> 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.

What I've usually done is take one of the existing (working) samples and
thread it. Once I get it working I then start tweaking the parts that I want
to draw differently. I've done about a half dozen of these and although I
don't understand the quartz part as well as I should they do work. And
performance wise they're faster than my old CopyBits code. Sign...

> 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.

I don't use ether CGContextSynchronize or QDFlushPortBuffer. The best
behavior I've got is to have my background thread create and draw into a
CGImage (or CGBitmap) that it then sends to the main thread (via posting a
custom carbon event); the custom carbon event handler disposes of any old
image (or bitmap) and assigns the new image to an HIView and then calls
HIViewNeedsDisplay on that HIView. Strictly speaking, in this case I'm not
actually drawing anything onscreen in my background thread but all the image
compositing is being done there (it is sucking up some CPU time. ;-).

About two years ago I used a threaded OvalTeen to demo MP quartz. It worked
well.


-- 
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)


 _______________________________________________
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

This email sent to 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.