Commit graph

22 commits

Author SHA1 Message Date
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
ba8b15d675
sixel: change default max size to 10000x10000
It used to be the size of the window. This caused images to be cropped
when the application emitting them didn’t change the max size.
2020-11-23 20:10:55 +01:00
Daniel Eklöf
dbfc636ade
sixel: implement reflow
Move sixel reflow from grid_reflow() to sixel_reflow(). This lets us
use internal sixel functions to update the sixels.

Note that grid_reflow() still needs to remap the sixelss coordinates.
2020-10-09 07:44:16 +02:00
Daniel Eklöf
52a7155897
sixel: add sixel_cell_size_changed()
This function should be called *after* the cell dimensions have
changed, but *before* resizing/reflowing the grids.
2020-10-09 07:44:16 +02:00
Daniel Eklöf
fad5838dba
Merge branch 'master' into sixel-performance 2020-06-29 22:03:26 +02:00
Daniel Eklöf
62be729c45
scroll: destroy scrolled out sixels before scroll is applied
The logic that breaks out of sixel loops does not work for rows that
has already wrapped around.

Thus, we need to destroy sixels that are about to be scrolled
out *before* we actually scroll.

Since this is the *only* time we destroy sixels (instead of
overwriting it), rename the sixel functions. And, since they now do a
very specific thing, they can be greatly simplified (and thus faster).
2020-06-29 22:01:02 +02:00
Daniel Eklöf
8f5e6e85e0
sixel: destroy all sixels when font size is decreased
If changing the font size causes the cell size to decrease, either
horizontally or vertically (or both), then delete all sixels since the
grid space they allocated no longer is enough to hold the images.
2020-06-29 21:53:29 +02:00
Daniel Eklöf
4006fc86e4
sixel: overwrite: pass 'width' to sixel_overwrite_at_cursor()
This is necessary to handle multi-column characters correctly.
2020-06-28 11:01:19 +02:00
Daniel Eklöf
1915e53629
sixel: improve descriptions of sixel_delete_* and sixel_overwrite_* 2020-06-27 15:32:33 +02:00
Daniel Eklöf
186a07c364
sixel: split -> overwrite 2020-06-27 15:29:47 +02:00
Daniel Eklöf
ae727e372a
term: erasing characters now splits sixels instead of deleting them 2020-06-27 15:22:31 +02:00
Daniel Eklöf
e896c2fa55
sixel: refactor handling of wrap-around delete- and split regions
Handle these on a higher abstraction level. The low level functions
that detect sixel intersections now assume the specified rectangle (or
line region) does *not* cross the wrap-around.

This is ensured by detecting a wrap-around region before hand, and
splitting it up into two, non wrapping regions.
2020-06-27 13:56:13 +02:00
Daniel Eklöf
dfc205e706
sixel: add sixel_split_by_rectangle()
This function splits a sixel image into up to four pieces. The four
pieces correspond to the relative complement (set difference) of the
sixel image and the specified rectangle.

Use this function when (possibly) overwriting existing sixel images
when generating a new one, i.e. in sixel_unhook().
2020-06-27 12:45:22 +02:00
Daniel Eklöf
bc82d4ee28
sixel: wip: split up image being overwritten, rather than erasing it
Instead of completely erasing a sixel image when it is being
"overwritten" (text is printed somewhere within the image, or another
sixel image is emitted within the first image), split it up into up to
four pieces: 'above', 'below', 'to-the-left' and 'to-the-right'.

This is currently very un-optimized, but seems to produce correct
results.
2020-06-23 21:07:12 +02:00
Daniel Eklöf
cc5dedc259
sixel: do not reset palette after each image
A client can re-use the palette between images. Resetting the palette
breaks this.

Now we initialize the palette on demand, and resets it when the
palette size is changed (by the client).
2020-06-10 18:38:46 +02:00
Daniel Eklöf
95f7c5586c
sixel: add sixel_delete_at_row and sixel_delete_in_range
These are utility functions to erase sixel images that are at the
specified row, or in a row range.
2020-02-24 18:42:32 +01:00
Daniel Eklöf
86d640ef71
sixel: rename: purge_at_cursor() -> delete_at_cursor() 2020-02-22 23:06:11 +01:00
Daniel Eklöf
80361ca04e
sixel: purge images at current cursor row
When printing a character, or starting a new sixel image, purge all
images that cover the cursor's current row.
2020-02-22 21:35:45 +01:00
Daniel Eklöf
25b09b909c
sixel: application configurable image max width/height 2020-02-22 21:03:24 +01:00
Daniel Eklöf
8e37a18083
sixel: application configurable palette size (color count)
This implements the CSI escapes for retrieving and (re)setting the
palette size.
2020-02-22 14:02:00 +01:00
Daniel Eklöf
bb82b9fabc
sixel: add sixel_destroy() 2020-02-22 00:23:19 +01:00
Daniel Eklöf
9e3bfb1eab
sixel: initial support
This implements basic parsing of sixel data. Lots of limitations and
temporary solutions as this is still work-in-progress:

* Maximum image size hardcoded to 800x800
* No HLS color format support
* Image is always rendered at 0x0 in the terminal
2020-02-21 21:53:23 +01:00