aboutsummaryrefslogtreecommitdiff
path: root/sixel.h (follow)
Commit message (Collapse)AuthorAgeLines
* sixel: re-scale images when the cell dimensions changeDaniel Eklöf2023-06-30-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* sixel: special case parsing of images with an aspect ratio of 1:1Daniel Eklöf2023-06-29-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* sixel: add sixel_reflow_grid()Daniel Eklöf2022-10-10-0/+4
| | | | | | | | | This function reflows all sixels in the specified grid. The pre-existing sixel_reflow() function is a shortcut for sixel_reflow_grid(term, &term->normal) sixel_reflow_grid(term, &term->alt);
* sixel: implement P2=1 - transparent pixelsDaniel Eklöf2021-03-11-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* sixel: change default max size to 10000x10000Daniel Eklöf2020-11-23-0/+2
| | | | | 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.
* sixel: implement reflowDaniel Eklöf2020-10-09-0/+2
| | | | | | | 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.
* sixel: add sixel_cell_size_changed()Daniel Eklöf2020-10-09-0/+1
| | | | | This function should be called *after* the cell dimensions have changed, but *before* resizing/reflowing the grids.
* Merge branch 'master' into sixel-performanceDaniel Eklöf2020-06-29-0/+1
|\
| * sixel: destroy all sixels when font size is decreasedDaniel Eklöf2020-06-29-0/+1
| | | | | | | | | | | | 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.
* | scroll: destroy scrolled out sixels before scroll is appliedDaniel Eklöf2020-06-29-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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).
* | sixel: overwrite: pass 'width' to sixel_overwrite_at_cursor()Daniel Eklöf2020-06-28-1/+1
|/ | | | This is necessary to handle multi-column characters correctly.
* sixel: improve descriptions of sixel_delete_* and sixel_overwrite_*Daniel Eklöf2020-06-27-4/+14
|
* sixel: split -> overwriteDaniel Eklöf2020-06-27-4/+7
|
* term: erasing characters now splits sixels instead of deleting themDaniel Eklöf2020-06-27-0/+4
|
* sixel: refactor handling of wrap-around delete- and split regionsDaniel Eklöf2020-06-27-2/+3
| | | | | | | | | 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.
* sixel: add sixel_split_by_rectangle()Daniel Eklöf2020-06-27-1/+0
| | | | | | | | | 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().
* sixel: wip: split up image being overwritten, rather than erasing itDaniel Eklöf2020-06-23-0/+1
| | | | | | | | | | 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.
* sixel: do not reset palette after each imageDaniel Eklöf2020-06-10-0/+2
| | | | | | | | 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).
* sixel: add sixel_delete_at_row and sixel_delete_in_rangeDaniel Eklöf2020-02-24-0/+3
| | | | | These are utility functions to erase sixel images that are at the specified row, or in a row range.
* sixel: rename: purge_at_cursor() -> delete_at_cursor()Daniel Eklöf2020-02-22-1/+1
|
* sixel: purge images at current cursor rowDaniel Eklöf2020-02-22-0/+1
| | | | | When printing a character, or starting a new sixel image, purge all images that cover the cursor's current row.
* sixel: application configurable image max width/heightDaniel Eklöf2020-02-22-0/+5
|
* sixel: application configurable palette size (color count)Daniel Eklöf2020-02-22-0/+7
| | | | | This implements the CSI escapes for retrieving and (re)setting the palette size.
* sixel: add sixel_destroy()Daniel Eklöf2020-02-21-0/+2
|
* sixel: initial supportDaniel Eklöf2020-02-21-0/+7
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