Commit graph

3960 commits

Author SHA1 Message Date
Daniel Eklöf
c5c3447ca8
sixel: sixel_overwrite_at_cursor(): early exit when the image list is empty
This avoids a call to sixel_overwrite_by_row() (where we also exit
early if the image list is empty).

This saves a couple of instructions to set up the arguments for
sixel_overwrite_by_row().
2021-03-14 14:19:12 +01:00
Daniel Eklöf
2a723e1c4c
Merge branch 'sixel-fix-max-geometry' 2021-03-14 13:07:13 +01:00
Daniel Eklöf
e7a4378f18
Merge branch 'option-no-wait'
Closes #395
2021-03-14 13:05:41 +01:00
Daniel Eklöf
6eb68ffbd9
sixel: max geometry should be max geometry, not current window size
“current geometry” will report whatever value is the smallest; the max
geometry or the current window size.

But “max geometry” always returns the configured max geometry.

This aligns foot’s behavior with XTerm.
2021-03-14 10:58:13 +01:00
Daniel Eklöf
29709c6966
scripts: generate-alt-random: reduce number of emitted sixels
After emitting multiple color bands for each sixel row, the increased
amount of sixel data shifted the balance in the profiling data,
causing a performance regression in regular ASCII handling.
2021-03-14 10:40:29 +01:00
Daniel Eklöf
4fca142f71
Merge branch 'drain-pty-when-client-terminates' 2021-03-13 21:36:30 +01:00
Felipe Trzaskowski
452830bd08 add changelog entry, completions and man entry for -N, --no-wait 2021-03-13 08:07:08 -03:00
Felipe Trzaskowski
2dc13cc13b fix code style issues and memory leak 2021-03-13 08:01:38 -03:00
Felipe Trzaskowski
3ed9314266 add option to detach the client process from the terminal instance 2021-03-13 05:48:55 -03:00
Daniel Eklöf
329f2a488c
term: don’t close PTY when client application dies
Closing it as soon as we detect that the client has died, means we may
not have drained it completely.

The PTY is either closed _by_ the client application, or by us when we
shutdown the terminal. Thus, leaving it open (until we call
term_shutdown()) is fine.
2021-03-12 22:06:50 +01:00
Daniel Eklöf
464851fac1
client: repair usage output 2021-03-12 21:53:11 +01:00
Daniel Eklöf
84f840a197
client: remove excess ‘-’ from ‘--log-level’ in usage 2021-03-12 21:51:07 +01:00
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