Commit graph

95 commits

Author SHA1 Message Date
Daniel Eklöf
2d7ca416f0
render: center grid in window
Instead of placing the upper left corner of the grid at 0,0 in the
window, center it.
2019-08-27 15:25:35 +02:00
Daniel Eklöf
dcf6d18872
render: log frame rendering time with microseconds instead of milliseconds 2019-08-24 11:32:28 +02:00
Daniel Eklöf
74a0c5f3fc
render: change resize debug log message to an info log message 2019-08-23 17:23:09 +02:00
Daniel Eklöf
7c7720a3ab
scrolling: optimize row access by assuming number of rows is a power of 2
With this assumption, we can replace 'a % b' with 'a & (b - 1)'. In
terms of instructions, this means a fast 'and' instead of a slow
'div'.

Further optimize scrolling by:

* not double-initializing empty rows. Previously, grid_row_alloc()
  called calloc(), which was then followed by a memset() when
  scrolling. This is of course unnecessary.

* Don't loop the entire set of visible rows (this was done to ensure
  all visible rows had been allocated, and to prefetch the cell
  contents).

  This isn't necessary; only newly pulled in rows can be NULL. For
  now, don't prefetch at all.
2019-08-22 17:33:23 +02:00
Daniel Eklöf
c1903f5522
render: multiply width/height with *new* scale factor, not old 2019-08-21 17:56:41 +02:00
Daniel Eklöf
d5bc46f333
render: reload cursor theme when scale (may) have changed 2019-08-21 17:53:52 +02:00
Daniel Eklöf
d84b485202
render: don't 're-calculate fg unnecessarily 2019-08-18 18:11:38 +02:00
Daniel Eklöf
9b6d0cfcd1
render: minor optimization
Don't instantiate a pixman color unnecessarily when drawing a block
cursor.
2019-08-17 17:43:47 +02:00
Daniel Eklöf
80aef9b6af
render: use 32-bit pixman calls, where applicable 2019-08-17 17:36:27 +02:00
Daniel Eklöf
72d3cbca26
shm/render: there's no need to have one pixman image per thread 2019-08-16 22:54:05 +02:00
Daniel Eklöf
81107753bf
render: replace all usage of cairo with pixman 2019-08-16 22:06:06 +02:00
Daniel Eklöf
bed7b34c28
wip: render background and glyphs using pixman 2019-08-16 20:40:32 +02:00
Daniel Eklöf
9fe6e8cc48
Add background alpha support 2019-08-15 18:15:43 +02:00
Daniel Eklöf
c2451e2a80
output: track output we're mapped on, and use maximum scale
Our surface may be on multiple outputs at the same time. In this case,
we use the largest scale factor, and let the compositor down scale on
the "other" output(s).
2019-08-12 21:49:17 +02:00
Daniel Eklöf
05e91fa9df
output: resize on scale changes 2019-08-12 21:33:24 +02:00
Daniel Eklöf
74f723e0cf
output: initial support for output scaling
* Not updated run-time; only scale at start up used
* Multiple monitors (outputs) not supported, as we can't track which
  output we're on (yet).
2019-08-12 21:33:24 +02:00
Daniel Eklöf
c6640adde3
render: fix foreground color for non-block cursor
When rendering either the 'bar' or 'underline' cursor styles, only use
the configured "cursor color" if it has actually been configured.

If it hasn't, use the current foreground color.
2019-08-12 20:00:28 +02:00
Daniel Eklöf
2a8962fd1a
render: selection may not be "ordered", since it may not have been finalized 2019-08-08 17:58:06 +02:00
Daniel Eklöf
1e08d93528
selection: ensure start < end in finalize
When the selection is finalized, swap start/end if necessary, to make
sure start <= end.
2019-08-05 20:15:18 +02:00
Daniel Eklöf
c411dedc3b
render: make sure the current view is allocated and visible 2019-08-04 18:34:14 +02:00
Daniel Eklöf
4d7993b36f
cell: pack more efficiently and store glyph as a wchar
The 'attributes' struct is now 8 bytes and naturally packed (used to
be 9 bytes, artificially packed).

'cell' struct is now 12 bytes, naturally packed (used to be 13 bytes,
artificially packed).

Furthermore, the glyph is stored as a wchar instead of a char*. This
makes it easier (faster) to do glyph lookup when rendering.
2019-08-02 18:19:07 +02:00
Daniel Eklöf
57564c2b59
render: special case worker-count == 0
Allow render worker count to be 0, in which case the main thread
renders the entire screen.
2019-08-01 20:09:39 +02:00
Daniel Eklöf
bd734d5bed
threads: set thread titles 2019-08-01 20:09:16 +02:00
Daniel Eklöf
67b4b9401d
render: always damage two cells when rendering the cursor
Hack to render cursor-at-double-width-characters correctly. Should be
replaced with something better.
2019-07-31 21:16:37 +02:00
Daniel Eklöf
4a01be5522
render: draw cell decorations (cursor, underline etc) correctly for double-width characters 2019-07-31 21:15:40 +02:00
Daniel Eklöf
858a0d9906
font: initial support for double-width *and* color emoji glyphs
Fonts are now loaded with FT_LOAD_COLOR and we recognize and support
the FT_PIXEL_MODE_BGRA pixel mode.

This is mapped to a CAIRO_FORMAT_ARGB32 surface, that is blitted
as-is (instead of used as a mask like we do for gray and mono glyphs).

Furthermore, since many emojis are double-width, we add initial
support for double-width glyphs.

These are assumed to always be utf8. When PRINT:ing an utf8 character,
we check its width, and add empty "spacer" cells after the cell with
the multi-column glyph.

When rendering, we render the columns in each row backwards. This
ensures the spacer cells get cleared *before* we render the glyph (so
that we don't end up erasing part of the glyph).

Finally, emoji fonts are usually bitmap fonts with *large*
glyphs. These aren't automatically scaled down. I.e. even if we
request a glyph of 13 pixels, we might end up getting a 100px glyph.

To handle this, fontconfig must be configured to scale bitmap
fonts. When it is, we can look at the 'scalable' and 'pixelsizefixup'
properties, and use these to scale the rendered glyph.
2019-07-31 18:03:35 +02:00
Daniel Eklöf
10536aad3f
render: make resize log messages debug messages 2019-07-30 22:01:49 +02:00
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