mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
sixel: re-scale images when the cell dimensions change
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
This commit is contained in:
parent
7a37e6891f
commit
49fb0cf359
7 changed files with 295 additions and 112 deletions
36
terminal.h
36
terminal.h
|
|
@ -126,14 +126,48 @@ struct row {
|
|||
};
|
||||
|
||||
struct sixel {
|
||||
void *data;
|
||||
/*
|
||||
* These three members reflect the "current", maybe scaled version
|
||||
* of the image.
|
||||
*
|
||||
* The values will either be NULL/-1/-1, or match either the
|
||||
* values in "original", or "scaled".
|
||||
*
|
||||
* They are typically reset when we need to invalidate the cached
|
||||
* version (e.g. when the cell dimensions change).
|
||||
*/
|
||||
pixman_image_t *pix;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
int rows;
|
||||
int cols;
|
||||
struct coord pos;
|
||||
bool opaque;
|
||||
|
||||
/*
|
||||
* We store the cell dimensions of the time the sixel was emitted.
|
||||
*
|
||||
* If the font size is changed, we rescale the image accordingly,
|
||||
* to ensure it stays within its cell boundaries. ‘scaled’ is a
|
||||
* cached, rescaled version of ‘data’ + ‘pix’.
|
||||
*/
|
||||
int cell_width;
|
||||
int cell_height;
|
||||
|
||||
struct {
|
||||
void *data;
|
||||
pixman_image_t *pix;
|
||||
int width;
|
||||
int height;
|
||||
} original;
|
||||
|
||||
struct {
|
||||
void *data;
|
||||
pixman_image_t *pix;
|
||||
int width;
|
||||
int height;
|
||||
} scaled;
|
||||
};
|
||||
|
||||
enum kitty_kbd_flags {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue