<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/sixel.c, branch 1.10.1</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.10.1</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.10.1'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2021-11-20T15:46:38Z</updated>
<entry>
<title>term: track cell color source</title>
<updated>2021-11-20T15:46:38Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-20T15:29:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=d46af6bd7ac7606bf99d63b2453b656a5defb892'/>
<id>urn:sha1:d46af6bd7ac7606bf99d63b2453b656a5defb892</id>
<content type='text'>
Each cell now tracks it’s current color source:

* default fg/bg
* base16 fg/bg (maps to *both* the regular and bright colors)
* base256 fg/bg
* RGB

Note that we don’t have enough bits to separate the regular from the
bright colors. These _shouldn’t_ be the same, so we ought to be
fine...
</content>
</entry>
<entry>
<title>sixel: call decsixel() directly, instead of going through sixel_put()</title>
<updated>2021-09-05T09:09:45Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-09-05T09:09:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=b1a4d4384571a6aa2bfc97644a6dff7066afef0b'/>
<id>urn:sha1:b1a4d4384571a6aa2bfc97644a6dff7066afef0b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: avoid looking up color from palette for each sixel</title>
<updated>2021-09-05T09:08:13Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-09-05T09:08:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=47c32d5913044912f5e0974ab6554de1f2a62b3b'/>
<id>urn:sha1:47c32d5913044912f5e0974ab6554de1f2a62b3b</id>
<content type='text'>
Instead, do the palette lookup when we receive the DECGCI (i.e. when
the palette entry is selected), and store the actual color value in
our sixel struct.
</content>
</entry>
<entry>
<title>sixel: calculate default bg once, in init</title>
<updated>2021-09-05T08:27:13Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-09-05T08:27:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f9642e959725fc43ad7dac0e3c8be842d53aa903'/>
<id>urn:sha1:f9642e959725fc43ad7dac0e3c8be842d53aa903</id>
<content type='text'>
We have all information we need to calculate the default background
color in sixel_init():

* Whether the image have transparency or not
* The current ANSI background color
</content>
</entry>
<entry>
<title>sixel: destroy(): don’t unref a NULL pixman image</title>
<updated>2021-07-18T14:30:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-18T14:30:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f65e062ce4defaa647b43927e462eaf2d683942b'/>
<id>urn:sha1:f65e062ce4defaa647b43927e462eaf2d683942b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: fix crash when splitting up an image across the scrollback</title>
<updated>2021-06-24T15:08:33Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-24T15:08:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a52d8679472f3695394d6e718bd85c4d204c4523'/>
<id>urn:sha1:a52d8679472f3695394d6e718bd85c4d204c4523</id>
<content type='text'>
If an image was split up across the scrollback, and the first image
chunk was resized due to it being blended with an already existing
sixel, we crashed.

The reason being the second chunk, emitted *after* the scrollback,
tried to memcpy() image data from a now-free:d image buffer.

The fix is pretty simple: create copies for *all* chunks when an image
has to be split up across the scrollback. Previously, the first chunk
re-used the source image buffer.

Closes #608
</content>
</entry>
<entry>
<title>sixel: add support for overlapping sixels</title>
<updated>2021-06-09T08:00:19Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-06T19:38:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6d336fcadd08ebbf19e63a32fa5be3fbfdc2ae59'/>
<id>urn:sha1:6d336fcadd08ebbf19e63a32fa5be3fbfdc2ae59</id>
<content type='text'>
Writing a sixel on top of an already existing sixel currently has the
following limitations in foot:

* The parts of the first sixel that is covered by the new sixel are
  removed, completely. Even if the new sixel has transparent
  areas. I.e. writing a transparent sixel on top of another
  sixel *replaces* the first sixel with the new sixel, instead of
  layering them on top of each other.

* The second sixel erases the first sixel cell-wise. That is, a sixel
  whose size isn’t a multiple of the cell dimensions will leave
  unsightly holes in the first sixel.

This patch takes care of both issues.

The first one is actually the easiest one: all we need to do is
calculate the intersection, and blend the two images. To keep things
relatively simple, we use the pixman image from the *new* image, and
use the ‘OVER_REVERSE’ operation to blend the new image over the old
one.

That is, the old image is still split into four tiles (top, left,
right, bottom), just like before. But instead of throwing away the
fifth middle tile, we blend it with the new image. As an optimization,
this is only done if the new image has transparency (P1=1).

The second problem is solved by detecting when we’re erasing an area
from the second image that is larger than the new image. In this case,
we enlarge the new image, and copy the old image into the new one.

Finally, when we enlarge the new image, there may be areas in the new
image that is *not* covered by the old image. These areas are made
transparent.

The end result is:

* Each cell is covered by at *most* 1 sixel image. I.e. the total
  numbers of sixels are finite. This is important for the ‘mpv
  --vo=sixel’ use case - we don’t want to end up with thousands of
  sixels layered on top of each other.

* Writing an opaque sixel on top of another sixel has _almost_ zero
  performance impact. Especially if the two sixels have the same size,
  so that we don’t have to resize the new image. Again, important for
  the ‘mpv --vo=sixel’ use case.

Closes #562
</content>
</entry>
<entry>
<title>sixel: don’t *ever* shrink image below its SRA size</title>
<updated>2021-05-16T09:00:32Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-16T08:57:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e0f1a4ae33168ad1dd5d3c01fab0acadcb964943'/>
<id>urn:sha1:e0f1a4ae33168ad1dd5d3c01fab0acadcb964943</id>
<content type='text'>
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
</content>
</entry>
<entry>
<title>sixel: don’t emit sixels that will end up covering more than the entire scrollback</title>
<updated>2021-05-08T18:28:16Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-08T17:03:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ba451af5c73ae4198b354690f2f2321364367d36'/>
<id>urn:sha1:ba451af5c73ae4198b354690f2f2321364367d36</id>
<content type='text'>
This limit can be reached by the sixel alone, or the sixel + the final
newline.

Closes #494
</content>
</entry>
<entry>
<title>sixel: fix assertion: image is allowed to cover the entire scrollback</title>
<updated>2021-05-08T18:28:16Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-08T17:02:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9bd14c0fd217721d32f52808878ed7e89bb82a16'/>
<id>urn:sha1:9bd14c0fd217721d32f52808878ed7e89bb82a16</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: unhook: tighten up the condition needed for us to free image data pre-maturely</title>
<updated>2021-04-07T17:08:29Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-04-07T17:08:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5f8a8951c77abec86f81b783a955d49cc9679faf'/>
<id>urn:sha1:5f8a8951c77abec86f81b783a955d49cc9679faf</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: sixel_fini(): free image data</title>
<updated>2021-04-07T17:07:43Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-04-07T17:07:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f9a730f33b14e61bf5466f6e2361b1d74dabcada'/>
<id>urn:sha1:f9a730f33b14e61bf5466f6e2361b1d74dabcada</id>
<content type='text'>
Normally, this data is always free:d indirectly, when the sixel image
that took over ownership is destroyed. But let’s play it safe.
</content>
</entry>
<entry>
<title>sixel: fix double free caused by bad free() in sixel_colors_set()</title>
<updated>2021-03-30T09:08:03Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-30T09:08:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=00083125a12bc8809f5b6d498a85a880e268cc81'/>
<id>urn:sha1:00083125a12bc8809f5b6d498a85a880e268cc81</id>
<content type='text'>
sixel_color_set() is called when the number of (sixel) color registers
is changed.

It frees the current palette, and changes the “palette size” variable.

Originally, we only had a single palette. This is the one free:d by
sixel_color_set().

Later, we added support for private vs. shared palettes. With this
change, we now have one palette that is “never” free:d (the shared
one), and a private palette that is always free:d after a sixel has
been emitted.

‘sixel.palette’ is a pointer to the palette currently in use, and
should only be accessed **while emitting a sixel**.

This is the pointer sixel_color_set() free:d. So for example, if
‘sixel.palette’ pointed to the shared palette, we’d free the shared
palette. But, we didn’t reset ‘sixel.shared_palette’, causing a double
free later on.

Closes #427
</content>
</entry>
<entry>
<title>sixel: free backing buffer if final image size is zero</title>
<updated>2021-03-28T11:22:10Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-28T10:57:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=19289bad5ef60f4c5ca2b45c0e495db60ed34267'/>
<id>urn:sha1:19289bad5ef60f4c5ca2b45c0e495db60ed34267</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: initialize max_non_empty_row_no to -1, not 0</title>
<updated>2021-03-28T11:22:09Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-03-28T10:55:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=3566be591a971a118dca6edc263dd7eefaa5f648'/>
<id>urn:sha1:3566be591a971a118dca6edc263dd7eefaa5f648</id>
<content type='text'>
0 is a perfectly valid row number, and if max_non_empty_row_no==0,
that means we have *1* sixel row, and after trimming the image, the
image will have a height of 6 pixels.

If the sixel sequence is empty (or at least doesn’t emit any non-empty
pixels), then trimming the image should result in an image height of
0.

When max_non_empty_row_no is initialized to -1, it will still have
that value in unhook(), which makes the final image height 0.
</content>
</entry>
<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>
</feed>
