Re: Replace -lockFocus with Block-Based Drawing Method
Re: Replace -lockFocus with Block-Based Drawing Method
- Subject: Re: Replace -lockFocus with Block-Based Drawing Method
- From: Ken Thomases <email@hidden>
- Date: Tue, 30 Dec 2014 22:22:39 -0600
On Dec 30, 2014, at 9:57 PM, Jerry Krinock <email@hidden> wrote:
> Just to clarify on the guidelines for using -lockFocus in the Resolution Independent world…
>
> Apple’s advice to avoid -lockFocus [1] only applies to drawing into NSImage objects, which is called “off-screen drawing”. Using -lockFocus in -[NSView drawRect] is, I suppose, “on-screen drawing”, and this is still OK.
>
> Am I correct?
Um, maybe. Why are you using -lockFocus inside of -drawRect:? When -drawRect: is called, the focus is already locked on the view which is being asked to draw itself. It should not be necessary to lock the focus again.
The intent of the guideline is that drawing that is done once and then reused over time is prone to becoming mismatched to the ultimate on-screen destination. A screen, window, or view may change from high-resolution to standard-resolution or vice versa. Views and windows will redraw themselves in response to that, so the drawing will be appropriate to the destination. However, if you draw images at one point in time and then reuse them, they will be cached at a particular resolution and won't be re-rendered for the new resolution of the destination when drawn. They may end up looking blocky or blurry as a result. So, you are encouraged to use a technique that allows them to be re-rendered as necessary.
Regards,
Ken
_______________________________________________
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