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: CGContext lifetime



There was some discussion here recently about QDBegin/EndCGContext, and it
brought to mind a question I've had in the past. Forgive me if this is too
basic, but how long is a CGContext valid? Or I suppose equivalently, what
kinds of things make a CGContext invalid? I know Haroon Sheikh indicated
that the CG context is cached internally so there shouldn't be a big
performance hit, but I'm sure there are still places where you'd want to
minimize the number of times you begin and end a context. So, how long is it
safe to use a context?

The context is a CFObject and is refcounted. The general rule, then is that the context is "valid" as long as it has a non-zero refcount.


Of course, you can do things to make some contexts invalid. For example, if you create an offscreen bitmap context and then delete the memory before you delete the context, that context would be invalid at that point. (OK.. technically the context would be valid, but it would not be a good idea to use it).

Scott

_______________________________________________
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
References: 
 >CGContext lifetime (From: Laurence Harris <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.