sixel: performance improvements

* Store pointer to current pixel (i.e. pixel we're about to write to),
  instead of a row-byte-offset. This way, we don't have to calculate the
  offset into the backing image every time we emit a sixel band.

* Pass data pointer directly to sixel_add_*(), to avoid having to
  calculate an offset into the backing image.

* Special case adding a single 1:1 sixel. This removes a for loop, and
  simplifies state (position) updates. It is likely LTO does this for
  us, but this way, we get it optimized in non-LTO builds as well.
This commit is contained in:
Daniel Eklöf 2024-03-04 16:40:16 +01:00
parent 8ff8ec5b70
commit 1568518ab3
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 61 additions and 29 deletions

View file

@ -666,7 +666,6 @@ struct terminal {
} state;
struct coord pos; /* Current sixel coordinate */
size_t row_byte_ofs; /* Byte position into image, for current row */
int color_idx; /* Current palette index */
uint32_t *private_palette; /* Private palette, used when private mode 1070 is enabled */
uint32_t *shared_palette; /* Shared palette, used when private mode 1070 is disabled */
@ -675,6 +674,7 @@ struct terminal {
struct {
uint32_t *data; /* Raw image data, in ARGB */
uint32_t *p; /* Pointer into data, for current position */
int width; /* Image width, in pixels */
int height; /* Image height, in pixels */
} image;