FROM : Carter R. Harrison
DATE : Mon Apr 14 21:46:44 2008
Hi David,
I'm getting the reference to the context by using:
CGContextRef context = [[NSGraphicsContext currentContext]
graphicsPort];
in my view's initWithFrame: method. Based upon what you said, how
would you recommend I draw to a CGLayer prior to the first invocation
of drawRect: (at which point I could initialize a CGContextRef
instance variable)?
Thanks for your help!
Regards,
Carter
On Apr 14, 2008, at 3:30 PM, David Duncan wrote:
> On Apr 14, 2008, at 11:56 AM, Carter R. Harrison wrote:
>
>> cgback is a CGLayerRef instance variable that I setup when the view
>> is inited. I use the following line:
>>
>> cgback = CGLayerCreateWithContext(context, CGSizeMake([self
>> bounds].size.width, [self bounds].size.height), NULL);
>>
>> It's my understanding that I do not need to retain cgback with
>> CFRetain(), but I do need to release cgback in my dealloc() method
>> - which I'm doing.
>
>
> Where is "context" coming from? CGLayers are made relative to an
> example context that they optimize themselves for, but at -init your
> view hasn't been drawn yet, so there is no context. I suspect that
> your getting something you very much do not expect.
>
> In general if you want to use layers with views, you should create
> the layer on the first -drawRect: call rather than trying to have
> them around from -init forward.
> --
> David Duncan
> Apple DTS Animation and Printing
> david.<email_removed>
>
>
>
DATE : Mon Apr 14 21:46:44 2008
Hi David,
I'm getting the reference to the context by using:
CGContextRef context = [[NSGraphicsContext currentContext]
graphicsPort];
in my view's initWithFrame: method. Based upon what you said, how
would you recommend I draw to a CGLayer prior to the first invocation
of drawRect: (at which point I could initialize a CGContextRef
instance variable)?
Thanks for your help!
Regards,
Carter
On Apr 14, 2008, at 3:30 PM, David Duncan wrote:
> On Apr 14, 2008, at 11:56 AM, Carter R. Harrison wrote:
>
>> cgback is a CGLayerRef instance variable that I setup when the view
>> is inited. I use the following line:
>>
>> cgback = CGLayerCreateWithContext(context, CGSizeMake([self
>> bounds].size.width, [self bounds].size.height), NULL);
>>
>> It's my understanding that I do not need to retain cgback with
>> CFRetain(), but I do need to release cgback in my dealloc() method
>> - which I'm doing.
>
>
> Where is "context" coming from? CGLayers are made relative to an
> example context that they optimize themselves for, but at -init your
> view hasn't been drawn yet, so there is no context. I suspect that
> your getting something you very much do not expect.
>
> In general if you want to use layers with views, you should create
> the layer on the first -drawRect: call rather than trying to have
> them around from -init forward.
> --
> David Duncan
> Apple DTS Animation and Printing
> david.<email_removed>
>
>
>
| Related mails | Author | Date |
|---|---|---|
| Carter R. Harrison | Apr 13, 16:15 | |
| Quincey Morris | Apr 13, 18:03 | |
| Carter R. Harrison | Apr 13, 21:50 | |
| Nathan Vander Wilt | Apr 14, 18:02 | |
| Carter R. Harrison | Apr 14, 20:56 | |
| David Duncan | Apr 14, 21:30 | |
| Carter R. Harrison | Apr 14, 21:46 | |
| David Duncan | Apr 14, 22:01 |






Cocoa mail archive

