Commit graph

4255 commits

Author SHA1 Message Date
Daniel Eklöf
f87a13bbd2
Merge branch 'box-drawing-use-pixman' 2021-05-17 18:09:16 +02:00
Daniel Eklöf
8473deeed3
box-drawing: pre-calculate the LIGHT and HEAVY thicknesses 2021-05-17 17:58:30 +02:00
Daniel Eklöf
3dbb906325
box-drawing: always pass ‘buf’ as the first parameter
This way, the compiler doesn’t have to waste instructions on
re-ordering the parameters
2021-05-17 17:58:30 +02:00
Daniel Eklöf
25ce458281
box-drawing: don’t inline _thickness()
It results in quite a lot of floating point instructions being emitted
in almost every box drawing function we have...
2021-05-17 17:58:30 +02:00
Daniel Eklöf
b48414e72c
box-drawing: use fill_boxes() instead of fill_rectangles() 2021-05-17 17:58:30 +02:00
Daniel Eklöf
b771a28d17
box-drawing: increase brightness of solid shades 2021-05-17 17:58:30 +02:00
Daniel Eklöf
e7109d6b77
config: add tweak.box-drawing-solid-shades=yes|no
When enabled, shades are rendered as solid blocks, using a darker
variant of the current foreground color.

When disabled, shades are instead rendered in a checker box pattern,
using the foreground color unmodified.

Default is enabled.
2021-05-17 17:58:30 +02:00
Daniel Eklöf
c0bd152218
box-drawing: use an a8 buffer when primary font is antialiased
This causes relevant box drawing characters (diagonals, arcs etc) to
be antialiased as well.
2021-05-17 17:58:30 +02:00
Daniel Eklöf
9264d6695c
box-drawing: change_buffer_format: abort on pixman failure 2021-05-17 17:58:30 +02:00
Daniel Eklöf
99a3b034c3
box-drawing: apply antialiasing to LIGHT ARCs
When drawing on an a8 buffer, apply antialiasing to LIGHT ARCs. This
is done by supersampling; draw to a 4 times bigger buffer, then
downsample, where each downsampled pixel is the average of the
corresponding 4x4 pixel from the supersampled buffer.

We also need to take supersampling into account while adjusting the row
and col when pixel aligning the arcs with the regular
horizontal/vertical lines.

The shape of the ARCs can still be improved. Still, this is a much
needed improvement over the current implementation.

Closes #279
2021-05-17 17:58:30 +02:00
Daniel Eklöf
3d97b8c113
box-drawing: draw_pixman_shade(): named struct initialization 2021-05-17 17:58:29 +02:00
Daniel Eklöf
977d37396f
box-drawing: fix typo: missing ‘.’ in struct member initialization 2021-05-17 17:58:29 +02:00
Daniel Eklöf
6937b1add8
box-drawing: shades can now be rendered either using solid color, or checker box
For now, switching is done using a static variable. In the future,
this could be a user option.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
d495da03e1
box-drawing: temporary “fix” for LIGHT ARCs with a8 buffers
We don’t have a method to draw the arcs using pixman yet. Work around
this by replacing the a8 buffer with an a1 buffer, and render the arcs
using our old, non-antialiased, way.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
5dd8a70905
box-drawing: swap amount of shade for LIGHT and DARK shades
The DARK shade is the one most dense, and thus the one that looks
brightest.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
b280928084
box-drawing: draw shades as “antialiased” blocks
When rendering to an a8 surface, render shades using “transparent”
pixman rectangles.

When these glyphs are composited with a color, the resulting look is
the color, but darkened.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
d6898dcc42
box-drawing: use pixman_image_fill_boxes() for rect() 2021-05-17 17:58:29 +02:00
Daniel Eklöf
e05a510a7c
box-drawing: implement LIGHT diagonal lines using pixman
Use trapezoids to rasterize the diagonal lines.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
19fa1b30b8
box-drawing: rect(): implement using pixman
Use pixman_image_fill_rectangles() to render rectangles. Duh!
2021-05-17 17:58:29 +02:00
Daniel Eklöf
155537c2de
box-drawing: {h,v}line: implement using pixman
Use pixman_image_fill_rectangles() to render horizontal and vertical
lines.

Despite the name, this *is* the appropriate function to use, since our
lines *do* have a thickness, and thus *are* rectangles.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
e03257d342
box-drawing: U+256C - BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL: add missing corner
The inner corner, where the upper/left lines meet, were missing
2021-05-17 17:58:29 +02:00
Daniel Eklöf
8d09ba5bd2
box-drawing: include pixman image in the buffer we’re passing around 2021-05-17 17:58:29 +02:00
Daniel Eklöf
ed60c66522
Merge branch 'reflow-performane-no-new-row-initialization'
Part of #504
2021-05-17 17:57:47 +02:00
Daniel Eklöf
1aa4a31c6f
grid: reflow: free old rows as soon as we’re done with them
This reduces the memory cost of reflowing text, as we no longer needs
to hold both the old and the new grid, in their entirety, in memory at
the same time.
2021-05-17 17:57:41 +02:00
Daniel Eklöf
11c7990ec8
grid: reflow: don’t initialize newly allocated rows
We’re going to write to it immediately anyway. In most cases, *all*
newly allocated, and zero-initialized, cells are overwritten.

So let’s skip the zero-initialization of the new cells.

There are two cases where we need to explicitly clear cells now:

* When inserting a hard line break - erase the remaining cells
* When done, the *last* row may not have been completely written -
  erase the remaining cells
2021-05-17 17:57:41 +02:00
Daniel Eklöf
ba23ee73e5
Merge branch 'font-scaling-factor-wrong'
Closes #509
2021-05-17 17:56:02 +02:00
Daniel Eklöf
2afc678236
term: get rid of term->font_scale, use term->scale only
We only needed term->font_scale to be able to detect scaling factor
changes (term->font_scale != term->scale).

But, we already have the old scaling factor in all places where
term_font_dpi_changed() is called, so let’s pass the old scaling
factor as an argument instead.
2021-05-17 17:55:49 +02:00
Daniel Eklöf
e7c01f3e52
changelog: fonts sometimes not being reloaded with the correct scaling factor 2021-05-17 17:55:49 +02:00
Daniel Eklöf
0e7e7b769b
render: simply check for an invalid (not set) scaling factor 2021-05-17 17:55:49 +02:00
Daniel Eklöf
0935428695
term: remove get_font_scale()
get_font_scale() was used to get the new scaling factor when loading
fonts. This was then compared to the last seen font scaling factor. If
there was no difference, the fonts were not reloaded.

The problem was, the initial term->scale was set differently. This
sometimes led to term->scale=2, while get_font_scale() return 1. That
meant, fonts were initially scaled by 2 (when dpi-aware=no). Later,
when mapped on an output (and thus term->scale being set to 1), the
fonts weren’t reloaded with the correct scaling factor since the
cached term->font_scale value was already 1.

Since term->scale always reflects the *new* scaling factor when
term_font_dpi_changed() is called, use that directly, and remove
get_font_scale().

Also rename the following functions:

* font_should_size_by_dpi() -> font_size_by_dpi_for_scale()
* font_size_by_dpi() -> font_sized_by_dpi()
* font_size_by_scale() -> font_sized_by_scale()
2021-05-17 17:55:39 +02:00
Daniel Eklöf
3405a9c81c
Merge branch 'reflow-performance'
Part of #504
2021-05-16 18:48:19 +02:00
Craig Barnes
cf3eeff951 Merge branch 'vt-anywhere-fix2' 2021-05-16 11:50:19 +01:00
Daniel Eklöf
a0ab4f3f1c
Merge branch 'sixel-dont-shrink-below-sra-size' 2021-05-16 11:05:59 +02:00
Daniel Eklöf
e0f1a4ae33
sixel: don’t *ever* shrink image below its SRA size
If the image was accompanied with a “Set Raster Attributes” (SRA)
command, make sure we *never* shrink the image below the size
specified in the SRA.

Images are normally shrunk when their bottom rows are fully
transparent. This enables sixels that aren’t a multiple of 6 to be
emitted, without also emitting an SRA command.

But if there *is* an SRA command, obey it.

Verified against XTerm-367
2021-05-16 11:00:32 +02:00
Craig Barnes
d37b2a7f7b Update term->vt.state for each iteration of vt_from_slave() loop
Otherwise it may be stale when read by the anywhere() function.
2021-05-15 19:20:36 +01:00
Daniel Eklöf
8d1b724056
grid: reflow: qsort_r() is not portable
Replace with qsort() + global variable. Not thread safe!
2021-05-15 13:37:46 +02:00
Daniel Eklöf
aa1f589e3f
grid: include <stdlib.h>, for qsort_r() 2021-05-15 13:32:10 +02:00
Daniel Eklöf
c7e51bdf72
grid: reflow: always run qsort_r(), handle rows == 0 in tp_cmp() instead 2021-05-15 13:00:46 +02:00
Daniel Eklöf
528e91aece
grid: take scrollback start into account when sorting the tracking points array
The row numbers in the tracking points are in absolute
numbers. However, when we walk the old grid, we do so starting in the
beginning of the scrollback history.

We must ensure the tracking points are sorted such that the *first*
one we see is the “oldest” one. I.e. the one furthest back in the
scrollback history.
2021-05-15 12:54:59 +02:00
Daniel Eklöf
60a55d04ac
grid: fix 32-bit compilation 2021-05-15 12:11:58 +02:00
Daniel Eklöf
a5d7f2e592
grid: reflow: tag tracking point if-statements with likely/unlikely 2021-05-15 11:44:13 +02:00
Daniel Eklöf
0d6abf1515
grid: reflow: use a sorted array for tracking points
Instead of iterating a linked list of tracking points, for *each and
every* cell in the old grid, use a sorted array.

This allows us to step through the array of tracking points as we walk
the old grid; each time we match a tracking point, we move to the next
one.

This means we only have to check a single tracking point for each cell.
2021-05-15 11:40:39 +02:00
Daniel Eklöf
d2c0a65b70
render: set tracking point count to 0 if there’s no active selection 2021-05-15 11:39:59 +02:00
Daniel Eklöf
a5ec26ccc9
grid: reflow: no need to check for combining characters
Since we no longer call wcwidth(), we don’t need the base character.
2021-05-15 00:12:51 +02:00
Daniel Eklöf
8e05f42a1c
grid: don’t depend on wcwidth()
Calling wcwidth() on every character in the entire scrollback history
is slow.

We already have the character width encoded in the grid; it’s in the
CELL_SPACERs following a multi-column character.

Thus, when we see a non-SPACER character, that isn’t in the last
column, peek the next character. If it’s a SPACER, get the current
characters width from it.

The only thing we need the width for, is to be able to print padding
SPACERS in the right margin, if the there isn’t enough space on the
current row for the current character.
2021-05-14 16:32:06 +02:00
Daniel Eklöf
d9e1aefb91
term: rename CELL_MULT_COL_SPACER -> CELL_SPACER, and change its definition
Instead of using CELL_SPACER for *all* cells that previously used
CELL_MULT_COL_SPACER, include the remaining number of spacers
following, and including, itself. This is encoded by adding to the
CELL_SPACER value.

So, a double width character will now store the character itself in
the first cell (just like before), and CELL_SPACER+1 in the second
cell.

A three-cell character would store the character itself, then
CELL_SPACER+2, and finally CELL_SPACER+1.

In other words, the last spacer is always CELL_SPACER+1.

CELL_SPACER+0 is used when padding at the right margin. I.e. when
writing e.g. a double width character in the last column, we insert a
CELL_SPACER+0 pad character, and then write the double width character
in the first column on the next row.
2021-05-14 14:41:02 +02:00
Daniel Eklöf
5bec83c406
grid: add compile-time define to enable timing of the reflow operation 2021-05-14 14:30:18 +02:00
Daniel Eklöf
92e517ae34
Merge branch 'xdg-activation'
Closes #487
2021-05-14 14:23:19 +02:00
Daniel Eklöf
8211484185
changeloge: xdg-activation support 2021-05-14 14:22:43 +02:00
Daniel Eklöf
3c898770cb
ci: try switching the gitlab CI from alpine:latest -> alpine:edge 2021-05-14 13:26:13 +02:00