Commit graph

68 commits

Author SHA1 Message Date
Daniel Eklöf
84f868f88d
render: don't pass a struct buffer when all we need is a cairo_t 2019-07-30 20:43:37 +02:00
Daniel Eklöf
d8ab96b8d9
render: don't call wl_surface_set_buffer_scale()
Since we don't support scaling, don't call
wl_surface_set_buffer_scale(). This way, at least will get auto-scaled
by the compositor.
2019-07-30 20:33:17 +02:00
Daniel Eklöf
2c3f2269fc
render: remove #if 0 code 2019-07-30 20:31:59 +02:00
Daniel Eklöf
f630633a81
render: fix 'suggest braces around initialization...' warning (clang) 2019-07-30 20:28:21 +02:00
Daniel Eklöf
20af289759
render: only explicitly re-render old cursor cell if it isn't dirty
If it is dirty, it will be rendered in the normal rendering
process.
2019-07-30 20:18:58 +02:00
Daniel Eklöf
efdb69f2d8
render: remove all traces of glyph-sequence
This was used to optimize the call(s) to cairo_show_glyphs(), which we
aren't using anymore.
2019-07-30 19:33:56 +02:00
Daniel Eklöf
73b4d5d05a
font: add support for fallback fonts
A top-level font now has a list of fallback fonts. When a glyph cannot
be found, we try each fallback font in turn, until we either find one
that has the glyph, or until we've exhausted the list.

To make this actually work in practise (read: to make performance
acceptable), the cache is re-worked and is now populated on demand.

It also supports non-ASCII characters, by using the 4-byte unicode
character as index instead.

Since having an array that can be indexed by a 4-byte value isn't
really viable, we now have a simple hash table instead of an array.
2019-07-30 18:04:28 +02:00
Daniel Eklöf
85ef9df586
render: add a 'clean' bit to each cell; only render cells that aren't clean
This patch takes a bit from the foreground color value in a
cell (todo: split up foreground/background into bitfields with a
separate field for 'foreground/background' has been set), and only
re-renders cells that aren't marked as clean.

Note: we use a 'clean' bit rather than a 'dirty' bit to make it easy
to erase cells - we can (keep doing) do that by simply memsetting a
cell range to 0.
2019-07-30 18:03:03 +02:00
Daniel Eklöf
c531795b83
wip: initial multithreaded renderer 2019-07-29 20:13:26 +02:00
Daniel Eklöf
fe882bddba
font: populate glyph cache (ASCII characters only) when instantiating font 2019-07-28 21:03:38 +02:00
Daniel Eklöf
9e57ba2108
font: add font_glyph_for_utf8()
This function fills in a struct glyph with glyph bitmap data for the
provided utf-8 character (essentially a FT_Bitmap wrapped in a cairo
surface).
2019-07-28 20:37:59 +02:00
Daniel Eklöf
175dc9cf94
cairo-ft: remove all usages of cairo-ft 2019-07-28 12:45:01 +02:00
Daniel Eklöf
27dca15caf
render: use FreeType face from font, instead of from cairo's scaled font 2019-07-28 12:11:44 +02:00
Daniel Eklöf
cb02c9cf41
font: load FreeType face, and set it's pixel sizes 2019-07-28 12:09:22 +02:00
Daniel Eklöf
90d357befb
render: poc: use freetype to render glyphs
Initial POC that uses freetype to render the glyphs. The bitmap
produced by freetype contains the alpha value.

We use this bitmap in a mask surface and then draw the final glyph
with cairo by applying the source rgb using the OVER operator and the
freetype generated alpha mask as surface mask.

Note that we only support grayscale antialiasing (and no
antialiasing).

We are probably not setting the antialias options correctly either.
2019-07-26 18:54:14 +02:00
Daniel Eklöf
709c29c7c4
render: reset "last cursor" when resizing
The cell pointer is likely invalid since we realloc the
grids. Besides. we're redrawing the entire window anyway.
2019-07-26 18:51:47 +02:00
Daniel Eklöf
269e04fa1b
render: flush glyph sequence after erase previous cursor
If not, we may have scrolled when we later flush the glyph sequence,
causing the glyph to be rendered in wrong location.
2019-07-26 18:50:41 +02:00
Daniel Eklöf
bb3e33948f
render: add render_row() 2019-07-24 20:31:21 +02:00
Daniel Eklöf
a712ca40e1
render: minor 2019-07-24 20:26:32 +02:00
Daniel Eklöf
f93384b9c9
render: move local static variables into the terminal struct 2019-07-24 20:21:41 +02:00
Daniel Eklöf
4838763d18
render: move frame_callback to term.render 2019-07-24 20:11:49 +02:00
Daniel Eklöf
ebf0a11fa0
render: add render_refresh() 2019-07-24 20:11:41 +02:00
Daniel Eklöf
10a7b94804
render: bug: previous cursor wasn't always redrawn correctly
The main problem is knowing:

* The correct *cell* (to be able to render the *content* when erasing
  the old cursor)
* Whether the cursor has moved (to determine whether to stop the
  rendering loop or not)
* Where on the *screen* the cursor is/was (since the terminal may be
  partly scrolled back)

This patch stores three static variables:

* last_cursor is used to compare against current cursor to see if the
  cursor has moved or not
* last_cursor_on_screen is the actual screen coordinates the cursor
  was rendered at (typically the same as last_cursor, but may be
  offset by the view)
* last_cursor_cell is a pointer to the cell to render
2019-07-24 18:15:24 +02:00
Daniel Eklöf
bf4847d3e0
conf: allow the user to configure a fixed cursor color
The default is to reverse the foreground/background colors in the cell
with the cursor.

But, if the user configures a specific set of cursor colors, those
will always be used, regardless of other cell attributes (dim, reverse
etc).

The cursor color is specified as two color values, 'text' and
'cursor'.

The block cursor uses the 'cursor' color as background, and the 'text'
color for the glyph.

All other cursor styles uses the 'cursor' color for the cursor, but
uses the cell's foreground color for the glyph (meaning,
dim/reverse/etc applies).
2019-07-23 18:54:58 +02:00
Daniel Eklöf
ed5df194b8
render: implement cursor styles 'bar' and 'underline' 2019-07-22 20:07:34 +02:00
Daniel Eklöf
428b31f071
term: group 'blink' state together in a struct 2019-07-22 19:17:57 +02:00
Daniel Eklöf
196f9d67c2
term: group 'flash' state together in a struct 2019-07-22 19:15:56 +02:00
Daniel Eklöf
e21ab8cf33
blink: implement 'blink' 2019-07-21 20:11:20 +02:00
Daniel Eklöf
0dd8951cb3
flash: implement 'flash'
Use our own escape sequence for the 'flash' terminfo entry.

Implemented by arming a timer FD and setting a boolean that indicates
we're currently "flashing".

The renderer draws a semi-transparent yellowish layer over the entire
window when "flashing" is active.
2019-07-21 19:14:19 +02:00
Daniel Eklöf
86faed473d
render: make "new buffer" a debug log message, not warning 2019-07-21 15:36:32 +02:00
Daniel Eklöf
29d855d7c6
term: prepare for configurable colors; add color variables to terminal 2019-07-21 10:58:09 +02:00
Daniel Eklöf
6e69cf9562
glyph-cache: generate at startup, never update while rendering 2019-07-18 13:03:21 +02:00
Daniel Eklöf
d2e0ba3670
render: comments 2019-07-18 10:47:09 +02:00
Daniel Eklöf
71c7219b35
render: make frame rendering time measuring optional 2019-07-18 10:35:27 +02:00
Daniel Eklöf
6e55be1557
render: cache generated glyphs for regular ASCII characters
To avoid having to re-generate glyphs, cache the glyphs.

For now, we only cache ASCII characters, as this allows us to lookup
the cache by simply indexing with the character (into a 256-entry
array).
2019-07-18 10:33:58 +02:00
Daniel Eklöf
c9803a2018
render: break out color conversion 2019-07-18 10:04:13 +02:00
Daniel Eklöf
0ca20e3e6c
render: time how long time it takes to render a frame 2019-07-18 09:33:49 +02:00
Daniel Eklöf
6bce2bed00
render: use cairo_rel_line_to() 2019-07-16 21:54:48 +02:00
Daniel Eklöf
d71c5f15a1
render: shorten foreground/background local variable names 2019-07-16 19:52:45 +02:00
Daniel Eklöf
06f9495ae2
render: implement strikeout 2019-07-16 15:08:02 +02:00
Daniel Eklöf
d93ca2f654
render: implement 'underline' 2019-07-16 14:20:39 +02:00
Daniel Eklöf
441337645a
render: implement 'dim' 2019-07-16 13:25:57 +02:00
Daniel Eklöf
ccc8ef9606
terminal: foreground/background in cell attributes are now uint32_t
This reduces the cell size, and thus improves the cache behavour
2019-07-16 13:17:51 +02:00
Daniel Eklöf
7dd80b08b3
render: bug: don't render cursor when hide cursor is enabled 2019-07-11 17:38:01 +02:00
Daniel Eklöf
632790d5d8
selection: selections can be made, and are rendered
* Start selection on mouse button down
* Update selection on motion
* Button release cancels selection if there were no motion after start
* Renderer detects cells inside the selection and inverts their colors
2019-07-11 17:38:01 +02:00
Daniel Eklöf
4ffd93ca4c
render: reduce scrollback line count
More than 1000 lines and we start exhibiting bad cache behavior
2019-07-10 18:49:34 +02:00
Daniel Eklöf
b1f8dd75d6
cell: we only need 4 bytes for the longest utf8 sequence
We don't *have* to NULL-terminate the utf8 string. So don't. This
makes the cell glyph 4 bytes exactly, which is better for alignment
and cache usage.
2019-07-10 18:47:32 +02:00
Daniel Eklöf
1ff1b3a71e
grid: don't pre-allocate the entire grid (with all scrollback lines)
The row array may now contain NULL pointers. This means the
corresponding row hasn't yet been allocated and initialized.

On a resize, we explicitly allocate the visible rows.

Uninitialized rows are then allocated the first time they are
referenced.
2019-07-10 16:27:55 +02:00
Daniel Eklöf
e01060caf9
render: damage the *view* too, when resizing 2019-07-10 14:34:43 +02:00
Daniel Eklöf
4cef8ed2cc
render: reset 'normal' grid's view correctly 2019-07-10 14:34:32 +02:00