Commit graph

3948 commits

Author SHA1 Message Date
Daniel Eklöf
ebc57d1a80
changelog: sixel decoding performance improvements 2021-03-12 21:43:35 +01:00
Daniel Eklöf
f19e1e4c36
Merge branch 'sixel-background-and-transparency'
Closes #391
2021-03-12 21:42:17 +01:00
Daniel Eklöf
5a9ae07167
changelog: implemented DCS parameter P2 2021-03-11 17:37:56 +01:00
Daniel Eklöf
655e756f58
render: sixels: render cursor, if it’s partially covered by an opaque sixel 2021-03-11 17:34:19 +01:00
Daniel Eklöf
7d315d7bf9
sixel: implement P2=1 - transparent pixels
When P2=1, empty pixels are transparent.

This patch also changes the behavior of P2=0|2, from setting empty
pixels to the default background color, to instead use the *current*
background color.

To implement this, a couple of changes are needed:

* Sixel pixels always use alpha=1.0, except for *empty* cells when
  P2=1 (i.e. transparent pixels).
* The renderer draws sixels with the OVER operator, instead of the SRC
  operator.
* The renderer *must* now render the cells beneath the sixel. As an
  optimization, this is only done for sixels where P2=1. I.e. for
  fully opaque sixels, there’s no need to render the cells beneath.

The sixel renderer isn’t yet hooked into the multi-threaded
renderer. This means *rows* (not just the cells) beneath
maybe-transparent sixels are rendered single-threaded.

Closes #391.
2021-03-11 17:34:19 +01:00
Daniel Eklöf
5650120e08
Merge branch 'sixel-optimize' 2021-03-11 17:33:41 +01:00
Daniel Eklöf
5e852f148e
changelog: empty pixel rows at the bottom of a sixel is now trimmed 2021-03-11 17:33:01 +01:00
Daniel Eklöf
6f6bcbc1bc
sixel: decgra: set max-non-empty-row-no when resizing the image
This ensures we don’t trim off bottom rows in unhook().

This could happen either because the application used “Set Raster
Attributes” to configure an image size larger than the sixels later
emitted.

Or, the last sixel row contains empty pixel rows.

In either case, the size set with “Set Raster Attributes” defines
the *minimum* image size; the image may still end up being larger.
2021-03-11 17:33:01 +01:00
Daniel Eklöf
a8186351d1
generate-alt-random: sixel: emit at least 4 color bands
This fixes an issue where there was a relatively high chance of not
emitting any color bands at all, causing the final image size to be
too small.
2021-03-11 17:33:01 +01:00
Daniel Eklöf
f3bc5a95b5
generate-alt-random: DECGRI: don’t emit zero-length repeat sequences 2021-03-11 17:33:00 +01:00
Daniel Eklöf
8ba455f70e
generate-alt-random: DECGRI: random repeat lengths 2021-03-11 17:33:00 +01:00
Daniel Eklöf
660a7f9345
generate-alt-random: don’t skip that last partial row 2021-03-11 17:33:00 +01:00
Daniel Eklöf
0bc98877f3
generate-alt-random: emit “Set Raster Attributes” before color definitions 2021-03-11 17:33:00 +01:00
Daniel Eklöf
a3f2e2220a
generate-alt-random: 50% chance of overwriting the last sixel 2021-03-11 17:33:00 +01:00
Daniel Eklöf
4a86cd7475
generate-alt-random: emit sixels on the alt screen 2021-03-11 17:32:59 +01:00
Daniel Eklöf
f8e51fcb17
generate-alt-random: emit multiple sixel bands
This ensures we’re getting the ‘$’ command PGO:d
2021-03-11 17:32:59 +01:00
Daniel Eklöf
ae86043780
sixel: decgri: handle a repeat count of 0, by ignoring it 2021-03-11 17:32:59 +01:00
Daniel Eklöf
eee216f5fe
generate-alt-random: sixel: pan/pad must not be 0 2021-03-11 17:32:59 +01:00
Daniel Eklöf
6d208fa5e0
sixel: add: add sixel_add_many(), improving performance of DECGRI
DECGRI, i.e. repeat sixel character, only need to do image resizing,
and updating the current ‘column’ value *once*.

By adding sixel_add_many(), and doing the size/resize checking there,
the performance of sixel_add() is made much simpler.

This boosts performance quite noticeably when the application is
emitting many and/or long repeat sequences.
2021-03-11 17:32:59 +01:00
Daniel Eklöf
6e963dbf68
sixel: add: calculate absolute row no inside the loop
This results in the same number of instructions inside the loop, with
a ‘lea’ instead of a ‘mov’, but simplifies the post-loop logic to
update the global state.
2021-03-11 17:32:59 +01:00
Daniel Eklöf
751ccf5316
sixel: add: increase data pointer instead of offset
Same ‘add’ instruction to increase the offset, but simpler ‘mov’
instruction when writing the pixel data.
2021-03-11 17:32:58 +01:00
Daniel Eklöf
777576b66b
sixel: decgri: avoid load inside for-loop 2021-03-11 17:32:58 +01:00
Daniel Eklöf
9f224a13df
sixel: add optimized resize_horizontally() and resize_vertically()
The resize operations performed in the “hot” path either change the
width, or the height, but not both at the same time.
2021-03-11 17:32:58 +01:00
Daniel Eklöf
c181eb2bf6
sixel: empty pixels in the last sixel row doesn’t contribute to the image height
All-empty pixels rows in the last sixel row should not be included in
the final sixel image.

This allows applications to emit sixels whose height is not a multiple
of 6, and is how XTerm works.

This is done by tracking the largest row number that contains
non-empty pixels.

In unhook, when emitting the image, the image height is adjusted based
on this value.
2021-03-11 17:32:58 +01:00
Daniel Eklöf
d35963f584
sixel: resize: width is no longer a multiple of 6 2021-03-11 17:32:58 +01:00
Daniel Eklöf
6ab7052be4
sixel: set ‘col’ outside image boundaries when we’ve reached max height
This is to optimize sixel_add(). It already checks ‘pos’, to see if it
needs to resize the image, and if the resize fails (either due to
allocation failures, or because we’ve reached the maximum width), we
bail out.

We need to do the same thing for height. But, we don’t want to add
another check to sixel_add() since its’s performance critical.

By setting ‘col’ outside the image boundaries when ‘row’ reaches the
maximum image height, we can “re-use” the existing code in
sixel_add().
2021-03-11 17:32:58 +01:00
Daniel Eklöf
4b0e9a6bee
sixel: remove ‘max_col’
The image width *is* the maximum number of columns we’ve seen.
2021-03-11 17:32:57 +01:00
Daniel Eklöf
1c9c1aafc8
sixel: adjust image height when processing ‘-’ 2021-03-11 17:32:57 +01:00
Daniel Eklöf
891e0819f0
sixel: resize: check new width/height against max geometry early 2021-03-11 17:32:57 +01:00
Daniel Eklöf
6416319a99
Revert "sixel: resize: always round up height to a multiple of 6"
This reverts commit 5a9d70da837c20a9641d6cbadccc962a8e5a4283.

This broke jexer.

Comparing with what XTerm does, we can see that it updates its image
height for *each* pixel in *each* sixel. I.e. empty pixels at the
bottom of a sixel will not increase the image size.

Foot currently bumps the image height 6 pixels at a time, i.e. always
a whole pixel.

Given this, always rounding up the height to the nearest multiple of
6 (say, for example, when responding to a DECGRA command), is wrong.

Now, we use the image size specified in DECGRA as is, while still
allowing the image to grow beyond that if necessary.

What’s left to do, if we want to behave *exactly* like XTerm, is stop
growing the image with 6 pixels at a time when dynamically adjusting
the image size.
2021-03-11 17:32:57 +01:00
Daniel Eklöf
ab70b4f16a
sixel: add: use de-reference the term struct for each access to the backing image 2021-03-11 17:32:57 +01:00
Daniel Eklöf
8c65c68b73
sixel: get rid of an ‘imul’ in sixel_add()
By storing the current row’s byte offset into the backing image in the
terminal struct.

This replaces the ‘imul’ with a load, which can potentially be
slow. But, this data should already be in the cache.
2021-03-11 17:32:57 +01:00
Daniel Eklöf
dfdb42138d
sixel: add: resize is already checking against the current max geometry 2021-03-11 17:32:56 +01:00
Daniel Eklöf
839b7dd32e
sixel: resize: don’t resize beyond the current max geometry 2021-03-11 17:32:56 +01:00
Daniel Eklöf
8ec0f15a34
sixel: unhook: make sure image height is within bounds
When we allocate the backing buffer, the number of allocated rows is a
multiple of 6.

When persisting the image, make sure its height does not exceed the
current maximum height.
2021-03-11 17:32:56 +01:00
Daniel Eklöf
add30a38f3
scripts: generate-alt-random: sixel: emit DECGRI - Repeat Character 2021-03-11 17:32:56 +01:00
Daniel Eklöf
5a93fc30ca
sixel: add: simplify check for resize needed
Since the image height is always a multiple of 6, there’s no need to
round up the image height.
2021-03-11 17:32:56 +01:00
Daniel Eklöf
e94f108572
sixel: resize: always round up height to a multiple of 6
Sixels are always a multiple of six.
2021-03-11 17:32:56 +01:00
Daniel Eklöf
f175575c09
sixel: fixup row is multiple of 6 2021-03-11 17:32:55 +01:00
Daniel Eklöf
f143efb999
sixel: calculate alpha when updating the palette
Calculate color, with alpha, when updating the palette instead of
every time we *use* the palette.
2021-03-11 17:32:55 +01:00
Daniel Eklöf
869743060e
sixel: pre-calculate color before calling sixel_add()
This improves performance of DECGRI, since we now only need to
calculate the color once for the entire repeat sequence.
2021-03-11 17:32:55 +01:00
Daniel Eklöf
47e4cfbf5c
sixel: ignore invalid sixel characters in DECGRI (repeat) 2021-03-11 17:32:55 +01:00
Daniel Eklöf
7603ae5dc3
sixel: avoid multiplication inside the inner sixel emitter loop 2021-03-11 17:32:55 +01:00
Daniel Eklöf
6658740982
sixel: store current row position in pixels, not characters 2021-03-11 17:32:55 +01:00
Daniel Eklöf
928b819934
meson: SOURCE_DIR is not a valid macro in custom_target()
But appears to have been allowed in older versions of meson.

Fixes an issue where foot’s version was always reported as the last
stable release, even though it was a git build.
2021-03-11 17:30:00 +01:00
Daniel Eklöf
098bc2771b
Merge branch 'consume-modifiers-for-client-application'
Closes #376
2021-03-08 20:30:33 +01:00
Daniel Eklöf
e4f164d958
keymap: handle shift+tab combos correctly, after consuming modifiers
Shift+Tab is an odd bird in XKB; it produces a shifted variant of tab,
ISO_Left_Tab, with Shift being a consumed modifier.

From a terminal perspective, Tab and ISO_Left_Tab are the same key,
with Shift+Tab generating ‘CSI Z’, and all other combos generating a
‘CSI 27;mods;9~’ escape.

Before, when we didn’t filter out consumed modifiers, we could simply
re-use the keymap for Tab when translating ISO_Left_Tab.

This is no longer possible, since shift has been filtered out. As a
result, Shift+Tab no longer generated ‘CSI Z’, but ‘\t’. I.e as if
shift wasn’t being pressed.

This patch adds a separate keymap table for ISO_Left_Tab. It’s MOD_ANY
entry corresponds to Shift+Tab, and emits ‘CSI Z’. All its other
entries *exclude* shift (since it has been consumed), *but*, the
encoded modifier (in the escape sequences) *include* shift.
2021-03-08 20:30:25 +01:00
Daniel Eklöf
6cd72bdee6
input: do not include consumed modifiers in the set sent to the client
When sending a key escape sequence to the client application, do not
include consumed modifiers.

Fixes part of #376
2021-03-08 20:30:23 +01:00
Daniel Eklöf
a8696b567e
Merge branch 'xkbcommon-bump'
Closes #389
2021-03-08 20:29:01 +01:00
Craig Barnes
2e31a1ec7a meson: bump minimum xkbcommon version to 1.0.0
This requirement is due to the recently added maybe_repair_key_combo()
function, which is making use of xkb_keymap_key_get_mods_for_level().

See also: commit a5b554761a.
2021-03-07 19:28:17 +00:00