46 Commits

Author SHA1 Message Date
Mitchell Hashimoto
de612934a0 some tweaks for wuffs 2024-09-02 20:47:07 -07:00
Jeffrey C. Ollie
6edeb45e7e kitty graphics: address review comments
- move wuffs code from src/ to pkg/
- eliminate stray debug logs
- make logs a warning instead of an error
- remove initialization of some structs to zero
2024-09-02 20:47:07 -07:00
Jeffrey C. Ollie
6dbb82c259 kitty graphics: performance enhancements
Improve the performance of Kitty graphics by switching to the WUFFS
library for decoding PNG images and for "swizzling" G, GA, and RGB data
to RGBA formats needed by the renderers.

WUFFS claims 2-3x performance benefits over other implementations, as
well as memory-safe operations.

Although not thorougly benchmarked, performance is on par with Kitty's
graphics decoding.

https://github.com/google/wuffs
2024-09-02 20:45:08 -07:00
Qwerasd
37872afbce kitty graphics: support loading 1 channel grayscale images 2024-08-15 21:38:46 -04:00
Qwerasd
10b8ca3c69 spelling: normalize grey -> gray 2024-08-11 18:31:01 -04:00
Mitchell Hashimoto
b368702a9d terminal/kitty: shared memory size may be larger than expected for pages
The shared memory segment size must be a multiple of page size. This
means that it may be larger than our expected image size. In this case,
we trim the padding at the end.
2024-08-09 20:33:39 -07:00
Mitchell Hashimoto
c114979ee3 terminal/kitty: minor stylistic changes to shm 2024-08-08 14:35:30 -07:00
Jeffrey C. Ollie
e2fe6bf74b kitty graphics: add support for shared memory transfer medium
Adds support for using shared memory to transfer images between
the CLI and Ghostty using the Kitty image protocol. This should be
the fastest way to transfer images if the CLI program and Ghostty are
running on the same system.

Works for single image transfer using `kitten icat`:

```
kitten icat --transfer-mode=memory images/icons/icon_256x256.png
```

However trying to play a movie with `mpv` fails in Ghostty (although it
works in Kitty):

```
mpv --vo=kitty --vo-kitty-use-shm=yes --profile=sw-fast --really-quiet video.mp4
```

`mpv` appears to be sending frames using the normal image transfer
commands but always setting `more_chunks` to `true` which results in an
image never being shown by Ghostty.

Shared memory transfer on Windows remains to be implemented.
2024-08-08 15:38:54 -05:00
multifred
72c672adb7 Fix multiple deprecated names for zig lib/std 2024-07-22 00:07:17 +02:00
Mitchell Hashimoto
53423f1071 0.13 conversions 2024-06-24 15:16:24 -07:00
Qwerasd
04ec859925 terminal/kitty_graphics: update tests
Kitty Graphics command structures have been changed to hold decoded payloads not base64 strings.
2024-03-31 22:28:53 -04:00
Qwerasd
ca4b55b486 terminal/kitty_graphics: ignore base64 padding
Also move all base64 decoding to inside of the command parser.
2024-03-31 21:09:37 -04:00
Mitchell Hashimoto
9b4ab0e209 zig build test with renamed terminal package 2024-03-22 20:27:44 -07:00
Mitchell Hashimoto
b7bf59d772 update zig 2024-03-22 11:15:26 -07:00
Krzysztof Wolicki
4add6889d8 Update to new compress.zlib API 2024-02-20 16:43:02 -08:00
Mitchell Hashimoto
6acf2b40af terminal/kitty-gfx: mistaken logic 2024-02-12 19:35:02 -08:00
Mitchell Hashimoto
9193cfa6d2 style nit 2024-02-12 19:31:58 -08:00
Nameless
28ff9f7310 bug: std.os.realpath on non-windows asserts no nulls, make an error 2024-02-12 19:31:17 -08:00
Jonathan Marler
e1996ad1e5 os: remove UB, tmpDir is returning stack memory on Windows
On Windows, the tmpDir function is currently using a buffer on the stack
to convert the WTF16-encoded environment variable value "TMP" to utf8
and then returns it as a slice...but that stack buffer is no longer valid
when the function returns.  This was causing the "image load...temporary
file" test to fail on Windows.

I've updated the function to take an allocator but it only uses
the allocator on Windows.  No allocation is needed on other platforms
because they return environment variables that are already utf8 (ascii)
encoded, and the OS pre-allocates all environment variables in the process.
To keep the conditional that determines when allocation is required, I
added the `freeTmpDir` function.
2024-02-10 21:09:05 -07:00
Mitchell Hashimoto
7c8b156960 kitty images: support pngs with greyscale/alpha (bpp=2)
Fixes #1355
2024-01-22 14:32:27 -08:00
Krzysztof Wolicki
44a48f62f1 change unmodified vars to consts in anticipation of zig changes 2023-11-17 15:46:46 +01:00
Mitchell Hashimoto
bf7054eeb6 terminal/kitty-gfx: ignore extra base64 padding 2023-08-23 21:52:50 -07:00
Mitchell Hashimoto
21ce787cff terminal/kitty-gfx: data chunk can be zero size 2023-08-23 19:31:46 -07:00
Mitchell Hashimoto
53452bab78 terminal/kitty-gfx: chunked transmit and display 2023-08-23 17:55:41 -07:00
Mitchell Hashimoto
83e396044b terminal/kitty-gfx: add per-screen storage limit 2023-08-23 14:14:31 -07:00
Mitchell Hashimoto
91a4be4ca1 terminal/kitty-gfx: add file loading safety checks from Kitty 2023-08-23 11:52:31 -07:00
Mitchell Hashimoto
c0b58802ba terminal/kitty-gfx: images store transmit time 2023-08-23 11:17:58 -07:00
Mitchell Hashimoto
6f7a9c4523 terminal/kitty-gfx: we need to use rect, not sel 2023-08-23 11:07:48 -07:00
Mitchell Hashimoto
a02fa4e705 terminal/kitty-gfx: png decoding 2023-08-21 15:09:42 -07:00
Mitchell Hashimoto
a5a977be9f terminal/kitty-gfx: file medium 2023-08-21 14:52:46 -07:00
Mitchell Hashimoto
5bb99efb84 terminal/kitty-gfx: temporary file medium 2023-08-21 14:43:24 -07:00
Mitchell Hashimoto
d821e023f3 terminal/kitty-gfx: test chunked loads 2023-08-21 12:06:26 -07:00
Mitchell Hashimoto
53c39c39d6 terminal/kitty-gfx: move all image decompression to loadingimage 2023-08-21 11:52:12 -07:00
Mitchell Hashimoto
fe79bd5cc9 terminal/kitty-gfx: centralize all image loading on LoadingImage 2023-08-21 11:40:03 -07:00
Mitchell Hashimoto
e56bc01c7e terminal/kitty-gfx: base64 decode data as it comes in 2023-08-21 11:19:22 -07:00
Mitchell Hashimoto
9c9a62bf3c terminal/kitty-gfx: test for non-compressed rgb image 2023-08-21 08:50:51 -07:00
Mitchell Hashimoto
a239f1198a terminal/kitty-gfx: decompress as part of image completion, tests 2023-08-21 08:48:30 -07:00
Mitchell Hashimoto
b2432a672f terminal/kitty-gfx: add debug function to dump image data 2023-08-21 08:28:20 -07:00
Mitchell Hashimoto
89dfe85740 terminal/kitty-gfx: the data is base64 encoded! 2023-08-20 22:03:22 -07:00
Mitchell Hashimoto
c96fa2e85f terminal/kitty-gfx: fix broken tests 2023-08-20 22:03:22 -07:00
Mitchell Hashimoto
03e0ba9081 terminal/kitty-gfx: zlib decompression for data validation 2023-08-20 22:03:21 -07:00
Mitchell Hashimoto
bbcb2f96c8 terminal/kitty-gfx: huge progress on chunked transfers, lots of issues 2023-08-20 22:03:21 -07:00
Mitchell Hashimoto
7bec2820a7 terminal/kitty-gfx: start working on placements 2023-08-20 22:03:21 -07:00
Mitchell Hashimoto
f82899bd58 terminal/kitty-gfx: better memory ownership semantics around func calls 2023-08-20 22:03:21 -07:00
Mitchell Hashimoto
1b7fbd00d1 terminal/kitty-gfx: add some validation from Kitty 2023-08-20 22:03:21 -07:00
Mitchell Hashimoto
c7658df978 terminal/kitty-gfx: support "query", loading images, tests 2023-08-20 22:03:20 -07:00