<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/sixel.c, branch 1.7.0</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.7.0</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.7.0'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2021-03-16T07:45:18Z</updated>
<entry>
<title>term: runtime switch between a ‘fast’ and a ‘generic’ ASCII print function</title>
<updated>2021-03-16T07:45:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-14T18:19:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=60b3ccc64115fb7e4b303eb1b93ba16d10fff1b5'/>
<id>urn:sha1:60b3ccc64115fb7e4b303eb1b93ba16d10fff1b5</id>
<content type='text'>
term_print() is called whenever the client application “prints”
something to the grid. It is called for both ASCII and UTF-8
characters, and needs to handle sixels, insert mode and ASCII
vs. graphical charsets.

Since it’s on the hot path, this becomes unnecessarily slow.

This patch adds a “fast” version of term_print(), tailored for the
common case: ASCII characters in non-insert mode, without any sixels
and non-graphical charsets.

A new function, term_update_ascii_printer(), has been added, and must
be called whenever:

* The currently selected charset *index* changes
* The currently selected charset changes (from ASCII to graphical, or
  vice verse)
* Sixels are added to the grid
* Sixels are removed from the grid
* Insert mode is enabled/disabled
</content>
</entry>
<entry>
<title>sixel: sixel_overwrite_at_cursor(): early exit when the image list is empty</title>
<updated>2021-03-14T13:19:12Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-14T13:19:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c5c3447ca8a71ab3cfd84a2b5fd2c193ef5b4fb4'/>
<id>urn:sha1:c5c3447ca8a71ab3cfd84a2b5fd2c193ef5b4fb4</id>
<content type='text'>
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().
</content>
</entry>
<entry>
<title>sixel: max geometry should be max geometry, not current window size</title>
<updated>2021-03-14T09:58:13Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-14T09:58:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6eb68ffbd99cc48aa688e59a230b4fca98fe0cb5'/>
<id>urn:sha1:6eb68ffbd99cc48aa688e59a230b4fca98fe0cb5</id>
<content type='text'>
“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.
</content>
</entry>
<entry>
<title>sixel: implement P2=1 - transparent pixels</title>
<updated>2021-03-11T16:34:19Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-09T16:23:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7d315d7bf9ab0376468929f0e41fbac98370e035'/>
<id>urn:sha1:7d315d7bf9ab0376468929f0e41fbac98370e035</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>sixel: decgra: set max-non-empty-row-no when resizing the image</title>
<updated>2021-03-11T16:33:01Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-10T19:31:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6f6bcbc1bc5a9378bd16bd300ec89ddb35d9f863'/>
<id>urn:sha1:6f6bcbc1bc5a9378bd16bd300ec89ddb35d9f863</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>sixel: decgri: handle a repeat count of 0, by ignoring it</title>
<updated>2021-03-11T16:32:59Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T15:53:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ae86043780df36d4dce8f38effd5023c4605b4ec'/>
<id>urn:sha1:ae86043780df36d4dce8f38effd5023c4605b4ec</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: add: add sixel_add_many(), improving performance of DECGRI</title>
<updated>2021-03-11T16:32:59Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T15:30:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6d208fa5e0dbb603ef87f83b825de36e35f7c1a3'/>
<id>urn:sha1:6d208fa5e0dbb603ef87f83b825de36e35f7c1a3</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>sixel: add: calculate absolute row no inside the loop</title>
<updated>2021-03-11T16:32:59Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T14:45:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6e963dbf6837094f93921f47cdc83aada244be6d'/>
<id>urn:sha1:6e963dbf6837094f93921f47cdc83aada244be6d</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>sixel: add: increase data pointer instead of offset</title>
<updated>2021-03-11T16:32:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T14:44:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=751ccf53162db0daf1f0318e421da31e337041e7'/>
<id>urn:sha1:751ccf53162db0daf1f0318e421da31e337041e7</id>
<content type='text'>
Same ‘add’ instruction to increase the offset, but simpler ‘mov’
instruction when writing the pixel data.
</content>
</entry>
<entry>
<title>sixel: decgri: avoid load inside for-loop</title>
<updated>2021-03-11T16:32:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T13:59:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=777576b66b1fff8d6da5696aac062aaa0dea1bb4'/>
<id>urn:sha1:777576b66b1fff8d6da5696aac062aaa0dea1bb4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: add optimized resize_horizontally() and resize_vertically()</title>
<updated>2021-03-11T16:32:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T13:44:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9f224a13df87d0c2db9057ce2ab531013c2ae6f6'/>
<id>urn:sha1:9f224a13df87d0c2db9057ce2ab531013c2ae6f6</id>
<content type='text'>
The resize operations performed in the “hot” path either change the
width, or the height, but not both at the same time.
</content>
</entry>
<entry>
<title>sixel: empty pixels in the last sixel row doesn’t contribute to the image height</title>
<updated>2021-03-11T16:32:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T13:44:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c181eb2bf68e2e776cff96b36489de5d45e67fe9'/>
<id>urn:sha1:c181eb2bf68e2e776cff96b36489de5d45e67fe9</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>sixel: resize: width is no longer a multiple of 6</title>
<updated>2021-03-11T16:32:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T11:02:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=d35963f584acce3d2493e24348215d60345c861e'/>
<id>urn:sha1:d35963f584acce3d2493e24348215d60345c861e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: set ‘col’ outside image boundaries when we’ve reached max height</title>
<updated>2021-03-11T16:32:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T10:51:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6ab7052be4932ae52df9aea550c2a8c5d1373f87'/>
<id>urn:sha1:6ab7052be4932ae52df9aea550c2a8c5d1373f87</id>
<content type='text'>
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().
</content>
</entry>
<entry>
<title>sixel: remove ‘max_col’</title>
<updated>2021-03-11T16:32:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T10:49:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=4b0e9a6bee9699b9edce6b9afc6a66734ce00a49'/>
<id>urn:sha1:4b0e9a6bee9699b9edce6b9afc6a66734ce00a49</id>
<content type='text'>
The image width *is* the maximum number of columns we’ve seen.
</content>
</entry>
<entry>
<title>sixel: adjust image height when processing ‘-’</title>
<updated>2021-03-11T16:32:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T10:22:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1c9c1aafc892a50300f3cfc81c06d107fbe6d840'/>
<id>urn:sha1:1c9c1aafc892a50300f3cfc81c06d107fbe6d840</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: resize: check new width/height against max geometry early</title>
<updated>2021-03-11T16:32:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-07T10:08:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=891e0819f0ed1f3812cf54c9071c7ff38715610c'/>
<id>urn:sha1:891e0819f0ed1f3812cf54c9071c7ff38715610c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Revert "sixel: resize: always round up height to a multiple of 6"</title>
<updated>2021-03-11T16:32:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-06T23:03:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6416319a998917149d2fb13aea9d8ae2b86e4a86'/>
<id>urn:sha1:6416319a998917149d2fb13aea9d8ae2b86e4a86</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>sixel: add: use de-reference the term struct for each access to the backing image</title>
<updated>2021-03-11T16:32:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-06T21:07:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ab70b4f16a59aedd170b6bdc01dca971c6358df1'/>
<id>urn:sha1:ab70b4f16a59aedd170b6bdc01dca971c6358df1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: get rid of an ‘imul’ in sixel_add()</title>
<updated>2021-03-11T16:32:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-06T21:05:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8c65c68b734b3a0711e8d0a7282d6c7d9def5ddf'/>
<id>urn:sha1:8c65c68b734b3a0711e8d0a7282d6c7d9def5ddf</id>
<content type='text'>
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.
</content>
</entry>
</feed>
