2020-02-21 21:53:23 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "terminal.h"
|
|
|
|
|
|
2020-02-22 14:02:00 +01:00
|
|
|
#define SIXEL_MAX_COLORS 1024u
|
2020-11-23 20:10:55 +01:00
|
|
|
#define SIXEL_MAX_WIDTH 10000u
|
|
|
|
|
#define SIXEL_MAX_HEIGHT 10000u
|
2020-02-22 14:02:00 +01:00
|
|
|
|
sixel: special case parsing of images with an aspect ratio of 1:1
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.
2023-06-27 14:25:55 +02:00
|
|
|
typedef void (*sixel_put)(struct terminal *term, uint8_t c);
|
|
|
|
|
|
2020-06-10 18:36:54 +02:00
|
|
|
void sixel_fini(struct terminal *term);
|
|
|
|
|
|
sixel: special case parsing of images with an aspect ratio of 1:1
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.
2023-06-27 14:25:55 +02:00
|
|
|
sixel_put sixel_init(struct terminal *term, int p1, int p2, int p3);
|
2020-02-21 21:53:23 +01:00
|
|
|
void sixel_unhook(struct terminal *term);
|
2020-02-22 00:23:19 +01:00
|
|
|
|
|
|
|
|
void sixel_destroy(struct sixel *sixel);
|
2020-06-29 21:53:29 +02:00
|
|
|
void sixel_destroy_all(struct terminal *term);
|
2020-02-24 18:39:14 +01:00
|
|
|
|
2020-06-29 22:01:02 +02:00
|
|
|
void sixel_scroll_up(struct terminal *term, int rows);
|
|
|
|
|
void sixel_scroll_down(struct terminal *term, int rows);
|
2020-06-27 15:22:31 +02:00
|
|
|
|
2020-10-04 13:09:24 +02:00
|
|
|
void sixel_cell_size_changed(struct terminal *term);
|
2023-06-29 14:49:54 +02:00
|
|
|
void sixel_sync_cache(const struct terminal *term, struct sixel *sixel);
|
2022-10-09 16:01:11 +02:00
|
|
|
|
|
|
|
|
void sixel_reflow_grid(struct terminal *term, struct grid *grid);
|
|
|
|
|
|
|
|
|
|
/* Shortcut for sixel_reflow_grid(normal) + sixel_reflow_grid(alt) */
|
2020-10-04 13:12:44 +02:00
|
|
|
void sixel_reflow(struct terminal *term);
|
|
|
|
|
|
2020-06-27 15:32:33 +02:00
|
|
|
/*
|
|
|
|
|
* Remove sixel data from the specified location. Used when printing
|
|
|
|
|
* or erasing characters, and when emitting new sixel images, to
|
|
|
|
|
* remove sixel data that would otherwise be rendered on-top.
|
|
|
|
|
*
|
|
|
|
|
* Row numbers are relative to the current grid offset
|
|
|
|
|
*/
|
2020-06-27 15:29:47 +02:00
|
|
|
void sixel_overwrite_by_rectangle(
|
2020-06-27 15:22:31 +02:00
|
|
|
struct terminal *term, int row, int col, int height, int width);
|
2020-06-27 15:29:47 +02:00
|
|
|
void sixel_overwrite_by_row(struct terminal *term, int row, int col, int width);
|
2020-06-28 11:01:19 +02:00
|
|
|
void sixel_overwrite_at_cursor(struct terminal *term, int width);
|
2020-02-22 14:02:00 +01:00
|
|
|
|
|
|
|
|
void sixel_colors_report_current(struct terminal *term);
|
|
|
|
|
void sixel_colors_reset(struct terminal *term);
|
|
|
|
|
void sixel_colors_set(struct terminal *term, unsigned count);
|
|
|
|
|
void sixel_colors_report_max(struct terminal *term);
|
2020-02-22 21:03:24 +01:00
|
|
|
|
|
|
|
|
void sixel_geometry_report_current(struct terminal *term);
|
|
|
|
|
void sixel_geometry_reset(struct terminal *term);
|
|
|
|
|
void sixel_geometry_set(struct terminal *term, unsigned width, unsigned height);
|
|
|
|
|
void sixel_geometry_report_max(struct terminal *term);
|