Should single-phase drawing be removed?

107 views
Skip to first unread message

Neil Hodgson

unread,
Mar 21, 2017, 1:40:09 AM3/21/17
to Scintilla mailing list
An offline contributor has proposed that single-phase drawing be removed from Scintilla as it complicates the source code.

In single-phase mode, both the background colour and text are drawn in a single call. This was how Scintilla was initially implemented and it was a good match for Windows 95 where this call was fast and avoided flicker.

Sometimes characters overlap other characters horizontally, most commonly due to kerning such as when the “T” and “o” in “To” are moved closer together. Italic text often shares horizontal space. Single-phase doesn’t work well here as the character at the end of a segment may be partly obscured by the background colour of the next segment. Some languages will not display correctly with single-phase drawing as some characters must share space - for example, vowel marks may go over their associated consonant.

Two-phase drawing was implemented to fix this. In this mode, all the backgrounds are drawn first and then the text is drawn transparently over the backgrounds, ensuring that all the characters are visible. It also allowed some indicators, such as strike-out to be drawn over the background but under the text, leaving the text more easily perceived than if the strike-out was drawn over the text. This mode works quite well on current platforms.

Single-phase drawing does not appear to be needed for the included platform layers. Other platform layers may need to retain single-phase drawing. I don’t know how the text-mode curses platform implements drawing but it may be difficult to implement it with two-phase drawing. Platform layers, like Windows 95 in the past, may perform better or avoid flickering with single-phase drawing.

If anyone wants to retain single-phase drawing then please communicate. Otherwise I’d like to start deprecating this mode in a release or two.

Neil

Mike Lischke

unread,
Mar 21, 2017, 4:40:03 AM3/21/17
to scintilla...@googlegroups.com
>
> If anyone wants to retain single-phase drawing then please communicate. Otherwise I’d like to start deprecating this mode in a release or two.


The default has been double-phase drawing since a while, right? And you got no bug reports for that? If so then I'd say it's save to deprecate it. I have never felt the need to switch the drawing mode.

Mike
--
www.soft-gems.net

Mitchell

unread,
Mar 21, 2017, 8:43:13 PM3/21/17
to scintilla...@googlegroups.com
Hi Neil,
The curses platform uses single-phase drawing (`view.phasesDraw =
EditView::phasesOne`). As far as I can tell, there is no curses API that
allows you to ask a cell for its current attributes (including foreground
and background colors) in order to draw text "transparently" in a separate
phase. When you draw into a cell in curses, you must specify both colors
-- there is no "bitwise AND" type of drawing with previous contents.

Furthermore, the curses platform is able to determine what Scintilla is
trying to draw based solely on which of "DrawTextNoClip",
"DrawTextClipped", or "DrawTextTransparent" is being called. For example,
when "DrawTextTransparent" is called, and since I am in single phase
drawing mode, I know Scintilla can only be trying to draw call tip text
and can adjust my "pen" accordingly without it affecting normal text
drawing. If forcing two phase drawing causes this same function to be
called on separate occasions for separate things, then I do not think I'll
be able to differentiate between the two calls and things will end up
looking weird.

The long story short is, being able to use Scintilla in a terminal
application with no changes to Scintilla's drawing code required some
clever tricks that rely on single phase drawing.

> If anyone wants to retain single-phase drawing then please
> communicate. Otherwise I’d like to start deprecating this mode in a
> release or two.

I'd prefer to keep the single-phase option.

Cheers,
Mitchell

Neil Hodgson

unread,
Mar 23, 2017, 12:56:38 AM3/23/17
to Scintilla mailing list
Mitchell:

> The curses platform uses single-phase drawing (`view.phasesDraw = EditView::phasesOne`). As far as I can tell, there is no curses API that allows you to ask a cell for its current attributes (including foreground and background colors) in order to draw text "transparently" in a separate phase.

OK. Single-phase drawing is necessary.

> Furthermore, the curses platform is able to determine what Scintilla is trying to draw based solely on which of "DrawTextNoClip", "DrawTextClipped", or "DrawTextTransparent" is being called. For example, when "DrawTextTransparent" is called, and since I am in single phase drawing mode, I know Scintilla can only be trying to draw call tip text and can adjust my "pen" accordingly without it affecting normal text drawing. If forcing two phase drawing causes this same function to be called on separate occasions for separate things, then I do not think I'll be able to differentiate between the two calls and things will end up looking weird.

That sounds fragile. It may be better to tag the Surface created for the calltip so text drawn there is treated in this special way.

Neil

Matthew Brush

unread,
Mar 23, 2017, 1:34:41 AM3/23/17
to scintilla...@googlegroups.com
On 2017-03-22 09:56 PM, Neil Hodgson wrote:
> Mitchell:
>
>> The curses platform uses single-phase drawing (`view.phasesDraw = EditView::phasesOne`). As far as I can tell, there is no curses API that allows you to ask a cell for its current attributes (including foreground and background colors) in order to draw text "transparently" in a separate phase.
>
> OK. Single-phase drawing is necessary.
>

I've no idea of about as a Scintilla backend, but you can get a cell's
attributes using various curses API functions like mvinch/mvwinch and
others.

Regards,
Matthew Brush

Mitchell

unread,
Jun 17, 2017, 10:00:12 PM6/17/17
to scintilla...@googlegroups.com
Hi Neil,

On Thu, 23 Mar 2017, Neil Hodgson wrote:

> Mitchell:
>
>> The curses platform uses single-phase drawing (`view.phasesDraw =
>> EditView::phasesOne`). As far as I can tell, there is no curses API
>> that allows you to ask a cell for its current attributes (including
>> foreground and background colors) in order to draw text "transparently"
>> in a separate phase.
>
> OK. Single-phase drawing is necessary.

It is likely that I will not be able to support the curses platform for
Scintilla 4.x, but only for the 3.x LTS branch. If the curses platform is
the sole reason holding you back from dropping support for single-phase
drawing in 4.x, then I'd say you can go ahead and drop it. If my situation
changes, I'll figure out how to get curses to work with two-phase drawing
for 4.x.

Thanks for all your hard work.

Cheers,
Mitchell

Neil Hodgson

unread,
Jun 20, 2017, 8:05:59 PM6/20/17
to scintilla-interest
Mitchell:

> It is likely that I will not be able to support the curses platform for Scintilla 4.x, but only for the 3.x LTS branch. If the curses platform is the sole reason holding you back from dropping support for single-phase drawing in 4.x, then I'd say you can go ahead and drop it. If my situation changes, I'll figure out how to get curses to work with two-phase drawing for 4.x.

It will only be deprecated in 4.0 which means it won’t be eliminated for at least a year.

Neil

Neil Hodgson

unread,
Jun 30, 2017, 10:23:52 PM6/30/17
to scintilla...@googlegroups.com

> It will only be deprecated in 4.0 which means it won’t be eliminated for at least a year.

Single-phase drawing deprecated by this commit:
https://sourceforge.net/p/scintilla/code/ci/59f341b22087bd86a25943621e07ffb6a897cf40/

Neil

Reply all
Reply to author
Forward
0 new messages