Commit graph

116 commits

Author SHA1 Message Date
Daniel Eklöf
9e6c28f5b6
wayland: implement wayl_win_destroy() 2019-10-27 16:01:44 +01:00
Daniel Eklöf
f63458ef33
term: move per-window wayland objects from wayland struct to terminal struct
Short term, we want to break out the wayland backend from the terminal
struct. Long term, we might want to support multiple windows.

One step towards both the above is separating global wayland objects
from per-window objects.
2019-10-27 12:57:37 +01:00
Daniel Eklöf
a789230cf9
font: font_from_name() returns an allocated font struct 2019-10-16 21:52:12 +02:00
Daniel Eklöf
67905c6000
render: handle compositors that does buffer swapping
Not all compositors support buffer re-use. I.e. they will call the
frame callback *before* the previous buffer has been
released. Effectively causing us to swap between two buffers.

Previously, this made us enter an infinite re-render loop, since we
considered the window 'dirty' (and in need of re-draw) when the buffer
is different from last redraw.

Now, we detect the buffer swapping case; size must match, and we must
not have any other condition that require a full repaint.

In this case, we can memcpy() the old buffer to the new one, without
dirtying the entire grid. We then update only the dirty cells (and
scroll damage).

Note that there was a bug here, where we erased the old
cursor *before* checking for a new buffer. This worked when the buffer
had *not* changed.

Now that we need to handle the case where it *has* changed, we must do
the memcpy() *before* we erase the cursor, or the re-painted cell is
lost.

This makes foot work on Plasma, without burning CPU. The memcpy() does
incur a performance penalty, but we're still (much) faster than
e.g. konsole. In fact, we're still mostly on par with Alacritty.
2019-09-27 19:33:45 +02:00
Daniel Eklöf
b87bf0dd9d
render: attach buffer *before* generating damage
Fixes 'invisible window' on Plasma
2019-09-27 19:33:10 +02:00
Daniel Eklöf
2d6369482e
main: initialize scale to '1'
This ensures we always have a valid (but possibly incorrect) scaling
value. This allows us to simplify code that uses the scale - it
doesn't have to verify the scale if valid.

Furthermore, since render_resize() is the function that actually
updates term->scale, make sure to call it *before* updating the
cursor (otherwise, the cursor will use the old scaling value).
2019-09-26 18:39:49 +02:00
Daniel Eklöf
55968413b6
render: remove assertion that isn't always true
It's not true for e.g. Cascadia code.
2019-09-21 00:45:22 +02:00
Daniel Eklöf
7c4c41fbae
render: search box: use colors from the color table
Use the 'yellow' color from the 'regular' range of colors (SGR 33) for
background when we have a match, or 'red' from the 'regular' range of
colors (SGR 31) when we don't have a match.

Foreground uses the 'black' color from the regular range of
colors (SGR 30).
2019-08-30 21:01:13 +02:00
Daniel Eklöf
e8d187e4f3
render: draw (cursor) bar using the same thickness as underlines 2019-08-30 19:42:33 +02:00
Daniel Eklöf
fcb0e05009
render: search box: fix glyph spacing
We're using the same font as in the terminal, so use the same glyph
spacing.
2019-08-30 19:35:47 +02:00
Daniel Eklöf
2ca7400cc6
render: render_search_box: draw cursor as a bar 2019-08-29 21:03:00 +02:00
Daniel Eklöf
bffa1f05ac
render: draw_strikeout: use font_baseline() for baseline calculation 2019-08-29 20:42:57 +02:00
Daniel Eklöf
1f98c8f787
render: draw_underline: use font_baseline() for baseline calculation 2019-08-29 20:42:45 +02:00
Daniel Eklöf
6e5688d7da
render: draw_bar: don't assume height == ascent+descent
Instead, draw a bar that is ascent+descent tall, positioned around the
baseline such that it starts at the ascent and ends at the descent.
2019-08-29 20:41:40 +02:00
Daniel Eklöf
013cf61ffb
render: add font_baseline() - calculates the y-coordinate for the baseline
The old baseline calculation was copy-pasted to a couple of places,
and also assumed that the font's height was equal to ascent+descent.

While this is typically true, it isn't necessarily so.

Now, we assume that height >= ascent+descent, and then position the
baseline in "center" (but adjusted for the descent).
2019-08-29 20:39:22 +02:00
Daniel Eklöf
3ec7fbf0a3
render: remove INFO log (that really was a debug log) 2019-08-29 20:23:44 +02:00
Daniel Eklöf
2c3ab701e7
search: move render() function to the 'render' module 2019-08-29 20:18:06 +02:00
Daniel Eklöf
2a31c2fbbc
render: reduce amount of dim while searching scrollback history 2019-08-29 19:33:25 +02:00
Daniel Eklöf
242ab66c97
render: double-dim fg+bg when searching the scrollback buffer
By toning down the screen content more, the selection (i.e. the search
match) pops out much more.
2019-08-28 21:53:01 +02:00
Daniel Eklöf
bb4fd58223
render: don't dim selection while searching 2019-08-27 19:40:07 +02:00
Daniel Eklöf
61cabdac13
search: wip: re-direct input while searching, and build a search buffer
This adds a new state, 'is_searching'. While active, input is
re-directed, and stored in a search buffer. In the future, we'll use
this buffer and search for its content in the scrollback buffer, and
move the view and create a selection on matches.

When rendering in 'is_searching', everything is dimmed. In the future,
we'll render the current search buffer on-top of the dimmed "regular"
terminal output.
2019-08-27 17:23:28 +02:00
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