terminal/src/renderer/gdi
James Holderness 6ee8099a2c
Refactor grid line renderers with support for more line types (#7107)
This is a refactoring of the grid line renderers, adjusting the line
widths to scale with the font size, and optimising the implementation to
cut down on the number of draw calls. It also extends the supported grid
line types to include true underlines and strike-through lines in the
style of the active font.

The main gist of the optimisation was to render the horizontal lines
with a single draw call, instead of a loop with lots of little strokes
joined together. In the case of the vertical lines, which still needed
to be handled in a loop, I've tried to move the majority of static
calculations outside the loop, so there is bit of optimisation there
too.

At the same time this code was updated to support a variable stroke
width for the lines, instead of having them hardcoded to 1 pixel. The
width is now calculated as a fraction of the font size (0.025 "em"),
which is still going to be 1 pixel wide in most typical usage, but will
scale up appropriately if you zoom in far enough.

And in preparation for supporting the SGR strike-through attribute, and
true underlines, I've extended the grid line renders with options for
handling those line types as well. The offset and thickness of the lines
is obtained from the font metrics (rounded to a pixel width, with a
minimum of one pixel), so they match the style of the font.

VALIDATION

For now we're still only rendering grid lines, and only the top and
bottom lines in the case of the DirectX renderer in Windows Terminal. So
to test, I hacked in some code to force the renderer to use all the
different options, confirming that they were working in both the GDI and
DirectX renderers.

I've tested the output with a number of different fonts, comparing it
with the same text rendered in WordPad. For the most part they match
exactly, but there can be slight differences when we adjust the font
size for grid alignment. And in the case of the GDI renderer, where
we're working with pixel heights rather than points, it's difficult to
match the sizes exactly.

This is a first step towards supporting the strike-through attribute
(#6205) and true underlines (#2915).

Closes #6911
2020-07-30 22:43:37 +00:00
..
lib Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
tool Replace old C headers (xxx.h) with modern ones (cxxx) (#5080) 2020-07-01 11:00:24 -07:00
dirs Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
gdirenderer.hpp Refactor grid line renderers with support for more line types (#7107) 2020-07-30 22:43:37 +00:00
invalidate.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
math.cpp ci: run spell check in CI, fix remaining issues (#4799) 2020-03-25 11:02:53 -07:00
paint.cpp Refactor grid line renderers with support for more line types (#7107) 2020-07-30 22:43:37 +00:00
precomp.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.h Replace old C headers (xxx.h) with modern ones (cxxx) (#5080) 2020-07-01 11:00:24 -07:00
sources.inc Import build fix changes from OS for sync to a34a957cf 2020-03-16 18:26:48 +00:00
state.cpp Refactor grid line renderers with support for more line types (#7107) 2020-07-30 22:43:37 +00:00