Discussion:
Changes to Cocoa drawing and scrolling
Neil Hodgson
2014-03-27 12:55:09 UTC
Permalink
The implementation of drawing on Cocoa has always had some problems when styling during painting caused style changes outside the paint area leading to abandoning the paint and scheduling a complete redraw. This has produced some glitching and stuttering.

Since OS X 10.9, responsive scrolling has been supported but there have occasionally been tiles drawn in black, or showing text from another position, when scrolling. This was caused when the system asked for a tile to be painted and Scintilla abandoned the paint because of styling.

Several changes were committed today that appear to have eliminated paint abandonment except with word wrap turned on and its much rarer with word wrap.

For standard drawing, Cocoa calls the viewWillDraw method before calling the main drawRect method. In viewWillDraw it is possible to extend the invalid area because of styling. Thus drawRect is called after all the styling it needs has been completed and all newly styled areas are included in the area being drawn. Therefore there is never a need to abandon the paint. It is not possible to grow the invalid area inside the drawRect method.

For responsive scrolling, tiles outside the visible area are drawn and cached in memory. For this, Cocoa first calls prepareContentInRect and then calls drawRect multiple times - once for each tile. Again Scintilla can perform styling and area invalidation in prepareContentInRect leaving no need to abandon painting inside drawRect.

Word wrap mode is different because it is a background activity, its not possible to depend on it being completed when needed, and wrapping changes the relationship between screen areas and the text. Further work could be performed here to try to avoid paint abandonment.

On Cocoa, the margin is a separate view, so modifying it during painting now only redraws that view, instead of abandoning the paint.

Cached tiles are now discarded when they are invalid instead of just being invalidated to avoid unnecessary redraw. Cocoa will reallocate and ask for tiles to be drawn as needed.

This is a large change so has a good chance of having bugs. Please test it thoroughly, and look for display glitches when scrolling rapidly.

Change set:
http://sourceforge.net/p/scintilla/code/ci/4d85b1a6b1c88e0349e7fbd020a38debf9322ef5/

Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/d/optout.
Loading...