Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: CGContextRef for Databrowser custom drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGContextRef for Databrowser custom drawing



On 11/29/05 9:24 AM, Scott Thompson didst favor us with:

>
> On Nov 22, 2005, at 2:34 PM, Laurence Harris wrote:
>
>> On 11/22/05 3:24 PM, Alex Curylo didst favor us with:
>>
>>> on 11/22/05 12:01 PM, email@hidden at
>>> email@hidden wrote:
>>>
>>>> Is there a way to get the CGContext for the DB custom cell
>>>> drawing callback?
>>>> Or do I have to use QD APIs?
>>>
>>> CGContextRef cgContext = NULL;
>>> GrafPtr port = NULL;
>>> ::GetPort(&port);
>>> OSStatus status = ::QDBeginCGContext(port, &cgContext);
>>>
>>> ... draw ...
>>>
>>> ::QDEndCGContext(port, &cgContext);
>>
>> This will work, but I use the approach I suggested because it's more
>> efficient. If you get the context in the kEventControlDraw handler
>> and then
>> use it in the callback, you only have to get it once. If you use
>> the above
>> approach, you have to call all of that for every row and every custom
>> column, so if you had 20 rows and three custom columns, you'd end
>> up calling
>> the above code 60 times for a single redraw of the DataBrowser.
>
> Are you sure that it's more "efficient"?  (have you profiled it).
>
> The system caches the CGContextRef between calls to
> QDBeginCGContext.  Calling it repeatedly on the same port is a low-
> overhead operation.

No, I haven't profiled it, but I'm pretty sure that not calling this code at
all is more efficient than calling it repeatedly. Is that an evil
assumption?

Larry

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: CGContextRef for Databrowser custom drawing (From: Scott Thompson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.