• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Replace -lockFocus with Block-Based Drawing Method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Replace -lockFocus with Block-Based Drawing Method
      • From: Jerry Krinock <email@hidden>
References: 
 >Why use NSCustomImageRep for drawing in code in NSImage? (From: Jerry Krinock <email@hidden>)
 >Re: Why use NSCustomImageRep for drawing in code in NSImage? (From: Ken Thomases <email@hidden>)
 >Re: Why use NSCustomImageRep for drawing in code in NSImage? (From: Jerry Krinock <email@hidden>)
 >Re: Replace -lockFocus with Block-Based Drawing Method (was NSCustomImageRep…) (From: Jerry Krinock <email@hidden>)
 >Re: Replace -lockFocus with Block-Based Drawing Method (was NSCustomImageRep…) (From: Ken Thomases <email@hidden>)
 >Re: Replace -lockFocus with Block-Based Drawing Method (was NSCustomImageRep…) (From: Jerry Krinock <email@hidden>)
 >Re: Replace -lockFocus with Block-Based Drawing Method (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Replace -lockFocus with Block-Based Drawing Method
  • Next by Date: Re: Replace -lockFocus with Block-Based Drawing Method
  • Previous by thread: Re: Replace -lockFocus with Block-Based Drawing Method
  • Next by thread: Re: Replace -lockFocus with Block-Based Drawing Method
  • Index(es):
    • Date
    • Thread