<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/sixel.c, branch 1.15.0</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.15.0</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.15.0'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2023-07-10T16:51:32Z</updated>
<entry>
<title>sixel: fix regression for DECGRI with a repeat count of 0</title>
<updated>2023-07-10T16:51:32Z</updated>
<author>
<name>CismonX</name>
<email>admin@cismon.net</email>
</author>
<published>2023-07-10T16:51:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=dbee099eebc46bd6a72f4be1b65c5552f02d471a'/>
<id>urn:sha1:dbee099eebc46bd6a72f4be1b65c5552f02d471a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: re-scale images when the cell dimensions change</title>
<updated>2023-06-30T06:29:35Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-29T12:49:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=49fb0cf359bb2486bbdf58df62c66c890d7e31cd'/>
<id>urn:sha1:49fb0cf359bb2486bbdf58df62c66c890d7e31cd</id>
<content type='text'>
Before this patch, when the cell dimensions changed (i.e. when the
font size changes), sixel images were either removed (the new cell
dimensions are smaller than the old), or simply kept at their original
size (new cell dimensions are larger).

With this patch, sixels are instead resized. This means a
sixel *always* occupies the same number of rows and columns,
regardless of how much the font size is changed.

This is done by maintaining two sets of image data and pixman images,
as well as their dimensions. These two sets are the new ‘original’ and
‘scaled’ members of the sixel struct.

The "top-level" pixman image pointer, and the ‘width’ and ‘height’
members either point to the "original", or the "scaled" version.

They are invalidated as soon as the cell dimensions change. They, and
the ‘scaled’ image is updated on-demand (when we need to render a
sixel).

Note that the ‘scaled’ image is always NULL when the current cell
dimensions matches the ones used when emitting the sixel (to save
run-time memory).

Closes #1383
</content>
</entry>
<entry>
<title>sixel: add_ar_11(): manually unroll loop</title>
<updated>2023-06-29T13:40:00Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-27T14:21:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5e9d68695c05d4be03ac7b83dd0eabc42bb7fefd'/>
<id>urn:sha1:5e9d68695c05d4be03ac7b83dd0eabc42bb7fefd</id>
<content type='text'>
This generates both smaller, and faster code
</content>
</entry>
<entry>
<title>sixel: refactor: shorten very verbose switch case statements</title>
<updated>2023-06-29T13:40:00Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-27T13:39:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=75f9bed6b6fc7bc97927d70e9e7df75dcea621c4'/>
<id>urn:sha1:75f9bed6b6fc7bc97927d70e9e7df75dcea621c4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: special case parsing of images with an aspect ratio of 1:1</title>
<updated>2023-06-29T13:40:00Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-27T12:25:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=3555e81fee4a069bf4886007082f676b8777f6f9'/>
<id>urn:sha1:3555e81fee4a069bf4886007082f676b8777f6f9</id>
<content type='text'>
Images with an aspect ratio of 1:1 are by far the most common (though
not the default).

It makes a lot of sense, performance wise, to special case
them.

Specifically, the sixel_add() function benefits greatly from this, as
it is the inner most, most heavily executed function when parsing a
sixel image.

sixel_add_many() also benefits, since allows us to drop a
multiplication. Since sixel_add_many() always called first (no other
call sites call sixel_add() directly), this has a noticeable effect on
performance.

Another thing that helps (though not as much), and not specifically
with AR 1:1 images, is special casing DECGRI a bit.

Up until now, it simply updated the current sixel parameter value. The
problem is that the default parameter value is 0. But, a value of 0
should be treated as 1. By adding a special ‘repeat_count’ variable to
the sixel struct, we can initialize it to ‘1’ when we see DECGRI, and
then simply overwrite it as the parameter value gets updated. This
allows us to drop an if..else when emitting the sixel.
</content>
</entry>
<entry>
<title>sixel: assert upper pixel of last sixel maps to last image row, *or lower*</title>
<updated>2023-06-24T05:31:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-22T20:12:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=2388015b105f420f42161b5a625dda8f6b9ebdb6'/>
<id>urn:sha1:2388015b105f420f42161b5a625dda8f6b9ebdb6</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: ensure enough rows have been scrolled in, to fit the image</title>
<updated>2023-06-24T05:31:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-22T20:01:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c15e75357a3823f264c798e87cf4d7fa802e4c92'/>
<id>urn:sha1:c15e75357a3823f264c798e87cf4d7fa802e4c92</id>
<content type='text'>
When emitting a sixel, we need to:

a) scroll terminal content to ensure the new image fits
b) position the text cursor

Recent changes in the cursor positioning logic meant we reduced the
number of linefeeds, to ensure 1) sixels could be printed to the
bottom row without scrolling the terminal contents, and 2) the cursor
was positioned on the last sixel row.

Except, we’re not actually positioning the cursor on the last sixel
row. We’re positioning it on the text row that maps to the *upper*
pixel of the last sixel.

In most cases, this _is_ the last row of the sixel. But for certain
combinations of font and image sizes, it may be higher up.

This patch fixes a regression, where the terminal contents weren’t
scrolled up enough for certain images, causing a crash when trying to
dirty a not-yet scrolled in row.

The fix is this:

* Always scroll by the number of rows occupied by the image, minus
  one. This ensures the image "fits".
* Adjust the cursor position, if necessary.
</content>
</entry>
<entry>
<title>sixel: resize(): handle no size change</title>
<updated>2023-06-24T05:31:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-21T09:39:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=425cf894d4db5401e069d5f1c76652eb822c131c'/>
<id>urn:sha1:425cf894d4db5401e069d5f1c76652eb822c131c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: regression: linefeed count for chunked up sixel image</title>
<updated>2023-06-24T05:31:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-20T12:52:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5d576fccbaef3e413bcb5b7a98708d2f1904f5d7'/>
<id>urn:sha1:5d576fccbaef3e413bcb5b7a98708d2f1904f5d7</id>
<content type='text'>
All image chunks but the last *should* scroll the screen content.
</content>
</entry>
<entry>
<title>sixel: minor fixes after implementing support for non-1:1 aspect ratios</title>
<updated>2023-06-24T05:31:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-20T10:58:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1eb90b2405a010a6e545ef4160cbfdb2fc3e503b'/>
<id>urn:sha1:1eb90b2405a010a6e545ef4160cbfdb2fc3e503b</id>
<content type='text'>
* Lazy initialize image height. This is necessary to prevent garbage
  from being rendered for "empty" sixels.
* Fix plotting of non-1:1 pixels
* Fix calculation of height in resize(), for non-1:1 aspect ratios
</content>
</entry>
<entry>
<title>sixel: stop cropping images to the last non-transparent row</title>
<updated>2023-06-24T05:31:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-19T17:09:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=774570ec41a3c585f40b03467eaada786a2e97d3'/>
<id>urn:sha1:774570ec41a3c585f40b03467eaada786a2e97d3</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: respect sixel aspect ratio</title>
<updated>2023-06-24T05:31:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-19T17:06:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=d6d143e2a6916178d1ea74551617cf8a5cddc39e'/>
<id>urn:sha1:d6d143e2a6916178d1ea74551617cf8a5cddc39e</id>
<content type='text'>
That is, parse P1 when initializing a new sixel, and don’t ignore
pad/pad in the raster attributes command.

The default aspect ratio is 2:1, but most sixels will override it in
the raster attributes command (to 1:1).
</content>
</entry>
<entry>
<title>sixel: fix cursor positioning logic</title>
<updated>2023-06-24T05:31:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-16T14:20:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=66d9b8da604e4fd3aa6ee96da3609ff6b9896f50'/>
<id>urn:sha1:66d9b8da604e4fd3aa6ee96da3609ff6b9896f50</id>
<content type='text'>
This adjusts the logic that positions the text cursor after emitting a
sixel, when sixel scrolling mode is *enabled*.

We’ve always mimicked XTerm’s behavior. However, XTerm recently
changed its behavior, to better match that of an VT382.

Now, the cursor is placed *on* the last row of the sixel, instead of
on a new row after the sixel.

This allows applications to print sixels to the bottom row of the
terminal, without causing the content to scroll.

Finally, there was a bug in the horizontal positioning of the cursor;
it was placed on the *first* column of the row, instead of on the
first column of the sixel.
</content>
</entry>
<entry>
<title>sixel: apply background alpha when P2=0 or P2=2, and current bg color is the default bg color</title>
<updated>2023-05-31T14:27:48Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-05-31T14:27:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1433a81c08d696cad8c5460ca739bc0cd97a9a5c'/>
<id>urn:sha1:1433a81c08d696cad8c5460ca739bc0cd97a9a5c</id>
<content type='text'>
Closes #1360
</content>
</entry>
<entry>
<title>Tag a couple variables with UNUSED, to fix warnings with clang-15</title>
<updated>2023-02-12T18:09:48Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-02-12T18:09:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1c16e4a575713581140b81198c0a57dbbf5c0cc6'/>
<id>urn:sha1:1c16e4a575713581140b81198c0a57dbbf5c0cc6</id>
<content type='text'>
Closes #1278
</content>
</entry>
<entry>
<title>sixel: don’t crash when sixel image exceeds current sixel max height</title>
<updated>2022-10-13T15:52:34Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-13T15:52:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=43a48f53d42a5de21e0a6eb6783863051ad8862a'/>
<id>urn:sha1:43a48f53d42a5de21e0a6eb6783863051ad8862a</id>
<content type='text'>
When we try to resize a sixel past the current max height, we set
col &gt; image-width to signal this.

This means ‘width’ could be smaller than ‘col’. When calculating how
many sixels to emit in sixel_add_many(), we didnt’ account for this.

The resulting value was -1, converted to ‘unsigned’. I.e. a very large
value. This resulted in an assert triggering in sixel_add() in debug
builds, and a crash in release builds.
</content>
</entry>
<entry>
<title>sixel: add sixel_reflow_grid()</title>
<updated>2022-10-10T15:19:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-09T14:01:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f70c34c5a8c6e89f6591e08fe3e26b9f0f44e6d2'/>
<id>urn:sha1:f70c34c5a8c6e89f6591e08fe3e26b9f0f44e6d2</id>
<content type='text'>
This function reflows all sixels in the specified grid.

The pre-existing sixel_reflow() function is a shortcut for

  sixel_reflow_grid(term, &amp;term-&gt;normal)
  sixel_reflow_grid(term, &amp;term-&gt;alt);
</content>
</entry>
<entry>
<title>sixel/terminal: use the new grid and selection APIs</title>
<updated>2022-04-25T18:00:14Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-25T18:00:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1d4e1b921d351da349ccfbc5d587489d7b77e690'/>
<id>urn:sha1:1d4e1b921d351da349ccfbc5d587489d7b77e690</id>
<content type='text'>
Use grid_row_abs_to_sb() instead of manually “rebasing” row numbers.

Use selection_get_{start,end}() to retrieve the current selection
coordinates.
</content>
</entry>
<entry>
<title>sixel: revert to default state when an invalid DECGRI character is received</title>
<updated>2022-02-04T17:14:25Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-02-03T18:24:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=58bbbb0a319687774e7c06edf52b17bb79d6085a'/>
<id>urn:sha1:58bbbb0a319687774e7c06edf52b17bb79d6085a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: DECGRI (repeat) with a count of 0 should emit a single sixel</title>
<updated>2022-02-04T17:14:24Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-02-03T18:23:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9e8d553a21c3a96ede2c830de695f6a255538cdd'/>
<id>urn:sha1:9e8d553a21c3a96ede2c830de695f6a255538cdd</id>
<content type='text'>
</content>
</entry>
</feed>
