On 1 Jan 2020, at 2:46, Rob Petrovec via Cocoa-dev wrote:

drawRect is not deprecated. Correct. However, it is technically old fashioned. It is much more efficient to use layers. Layers can take better advantage of the video card especially during animations, and don’t require unnecessary redraws if (part of) your view is covered up and then uncovered (e.g. during scrolling or windows moving around etc).

In itself it is not “much more efficient to use layers”.

Only if you change layer properties for animation effects do you save on redraws, but it comes at the cost of extra memory consumption.

As for redrawing windows, these are already drawn into off-screen buffers and clip views maintain some overdraw rectangles to make scrolling smoother. So you normally don’t reduce redraws by using layers.

Also, the layer equivalent of a scroll view is CATiledLayer, this has different behavior in that it redraws tiles in a background thread and then uses transitions to make them appear. But it also uses transitions when you change properties which I found problematic, for example resizing the document view because of changed content would re-use existing tile and just scale it, before transitioning to the new tile (being drawn in a background thread).

For some types of applications, this behavior is fine, but probably not for a text editor like OP is writing, and at least I was unable to find a way to just do atomic updates without the transition stuff (I did try CATransaction).
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to