Re: NSGraphicsContext restore crashes my xtension
Re: NSGraphicsContext restore crashes my xtension
- Subject: Re: NSGraphicsContext restore crashes my xtension
- From: glenn andreas <email@hidden>
- Date: Sun, 27 Jul 2008 18:09:30 -0500
On Jul 27, 2008, at 4:19 PM, email@hidden wrote:
-------------- Original message ----------------------
From: glenn andreas <email@hidden>
CG is "stateless", in that there is no "current context" (all drawing
to a CGContext requires passing the CGContextRef).
NSGraphicsContext,
on the other hand, involves an implicit "current context". If you
change that, you need to change it back - that's what currentContext/
setCurrentContext does. Just because NSGraphicsContext is built on
top of CGContextRef doesn't mean that they have the same semantics
(nor is NSGraphicsContext "just a wrapper" - it does a few more
things).
Thanks Glenn.
I'm still confused as to exactly how I should restore or change the
context "back to the original" since the original is a
CGGraphicsContext. and the only NSGraphicsContext is one I create
using the passed in CGGraphicsContext. It seems like a catch-22. I
can't draw the text without creating an NSGraphicsContext and I
can't restore a calling NSGraphicsContext because the calling
context is a CGGraphics context which doesn't work with
[NSGraphicsContext setCurrentContext: nsContext];
Any pointers?
If you call [NSGraphicsContext currentContext] before your
setCurrentContext:, what do you get back?
Whatever that is, that's the context to restore with a second
[NSGraphicsContext setCurrentContext: ] at the end...
Pay no attention to what the CGGraphicsContext is - there is no such
thing as a "current" CGGraphicsContext (since CGGraphicsContext
routines all take the context as an explicit parameter) - it's only
the implicit NSGraphicsContext that matters.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden