aboutsummaryrefslogtreecommitdiff
path: root/sixel.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-04-15 14:07:47 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-04-15 14:07:47 +0000
commit3d2588edf8a90a7ba74d75089193a52b69905a4f (patch)
tree31e62204351876fee0406e181570e04950ed5d2b /sixel.c
parentsixel: also set 'alloc_height', when short-cutting a resize operation (diff)
sixel: don't allow pan/pad changes after sixel data has been emitted
Changing pan/pad changes the sixel's aspect ratio. While I don't know for certain what a real VT340 would do, I suspect it would change the aspect ratio of all subsequent sixels, but not those already emitted. The way we implement sixels in foot, makes this behavior hard to implement. We currently don't resize the image properly if the aspect ratio is changed, but not the RA area. We have code that assumes all sixel lines have the same aspect ratio, etc. Since no "normal" applications change the aspect ratio in the middle of a sixel, simply disallow it, and print a warning. This also fixes a crash, when writing sixels after having modified the aspect ratio.
Diffstat (limited to 'sixel.c')
-rw-r--r--sixel.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/sixel.c b/sixel.c
index 85be3608..d6bfa3a4 100644
--- a/sixel.c
+++ b/sixel.c
@@ -1852,12 +1852,32 @@ decgra(struct terminal *term, uint8_t c)
pan = pan > 0 ? pan : 1;
pad = pad > 0 ? pad : 1;
+ if (likely(term->sixel.image.width == 0 &&
+ term->sixel.image.height == 0))
+ {
+ term->sixel.pan = pan;
+ term->sixel.pad = pad;
+ } else {
+ /*
+ * Unsure what the VT340 does...
+ *
+ * We currently do *not* handle changing pan/pad in the
+ * middle of a sixel, since that means resizing/stretching
+ * the existing image.
+ *
+ * I'm *guessing* the VT340 simply changes the aspect
+ * ratio of all subsequent sixels. But, given the design
+ * of our implementation (the entire sixel is written to a
+ * single pixman image), we can't easily do that.
+ */
+ LOG_WARN("sixel: unsupported: pan/pad changed after printing sixels");
+ pan = term->sixel.pan;
+ pad = term->sixel.pad;
+ }
+
pv *= pan;
ph *= pad;
- term->sixel.pan = pan;
- term->sixel.pad = pad;
-
LOG_DBG("pan=%u, pad=%u (aspect ratio = %d:%d), size=%ux%u",
pan, pad, pan, pad, ph, pv);