summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-15 19:14:59 +0200
committeruser <user@clank>2026-08-15 19:14:59 +0200
commit2f0b3426d0f40d2cf53740cb597495af2c45bc2e (patch)
tree1969c511f2ec69e234e4eb8b2ba1aa2bf78c7904 /Makefile
parentsl0ppty: measure chrome in columns, not characters (diff)
downloadslosh-2f0b3426d0f40d2cf53740cb597495af2c45bc2e.tar.gz
slosh-2f0b3426d0f40d2cf53740cb597495af2c45bc2e.tar.xz
slosh-2f0b3426d0f40d2cf53740cb597495af2c45bc2e.zip
sl0ppty: decode the PNGs programs actually send
Kitty graphics were green in the suite and a real program still drew nothing. libghostty-vt ships no image codec: built as a library it sets its `sys.decode_png` hook to null, and a null hook rejects every `f=100` transmission outright -- no image stored, so no placement exists, so the re-emission layer this project is mostly *about* is never reached. The program gets no error and no picture. Raw RGB worked throughout, which is why it looked done: every test here sent raw pixels, because that is what is easy to write in a test. It is the same lesson the last kitty graphics bug taught -- write the test the way a program actually behaves -- and a program with a picture on disk has a PNG. Found because ida-tui's startup logo never appeared, and its detection probe answers `OK` first, so it fails silently rather than falling back to its block art. PNG is the whole of the gap and cannot grow: the protocol has exactly three formats (`f=24`, `f=32`, `f=100`), the first two are raw pixels lib-vt already handles, and `decode_png` is the only codec hook it has. Decoding only, never encoding. The decoder is the stb_image lib-vt already vendors and we already commit -- upstream compiles that same header with the same `STBI_ONLY_PNG` for this same purpose, it is just not in the `-Demit-lib-vt` build. So nothing new is pulled in; a file we already ship is finally compiled. src/png.c is the hook, a header pre-check and a copy: dimensions are read before decoding because the buffer we return is allocated through lib-vt's limited allocator but stb's own working allocation is plain malloc and answers to nothing. Tests cover a PNG placed at the size it asked for (RGB and RGBA sources, both normalised to RGBA), the client being handed `f=32` rather than the png it was given, and a malformed png placing nothing without taking the pane with it. They fail on the previous binary.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile6
1 files changed, 6 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 7174c5c..76df199 100644
--- a/Makefile
+++ b/Makefile
@@ -53,6 +53,12 @@ $(BIN): $(OBJ) $(VT_LIB)
build/%.o: src/%.c build/version.h $(VT_LIB) | build
$(CC) $(CFLAGS) -c $< -o $@
+# stb_image comes with the vendored libghostty-vt, which is where the include
+# path points. It is third-party and does not build clean under our warnings,
+# so it gets its own rule rather than every file paying for it.
+build/png.o: src/png.c build/version.h $(VT_LIB) | build
+ $(CC) $(CFLAGS) -I$(VT)/src/stb -Wno-unused-function -c $< -o $@
+
# Rewritten only when the value actually changes, so `make` after a commit
# rebuilds, and `make` twice in a row does not.
.PHONY: FORCE