diff options
author | bptato <nincsnevem662@gmail.com> | 2024-06-27 21:50:31 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-06-28 21:26:33 +0200 |
commit | 8268ba2cf049be1865875e3e01305a500fa533e2 (patch) | |
tree | 7ce60624f9212e65dad0c1a2d168eb6ab7c03ec9 /src/loader/loaderhandle.nim | |
parent | f9734e2b3900781901bb5f268137bd9adbfc33ef (diff) | |
download | chawan-8268ba2cf049be1865875e3e01305a500fa533e2.tar.gz |
img, loader: add image resizing, misc fixes
* resize images with stb_image_resize * use tee for output handle redirection (redirectToFile blocks) * cache original image files * accept lseek in sandbox * misc stbi fixes For now, I just pulled in stb_image_resize v1. v2 is an extra 150K in size, not sure if it's worth the cost. (Either way, we can always switch later if needed, since the API is almost the same.) Next step: move sixel/kitty encoders to CGI, and cache their output in memory instead of the intermediate RGBA representation.
Diffstat (limited to 'src/loader/loaderhandle.nim')
-rw-r--r-- | src/loader/loaderhandle.nim | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/loader/loaderhandle.nim b/src/loader/loaderhandle.nim index 13869c8f..b1b04dee 100644 --- a/src/loader/loaderhandle.nim +++ b/src/loader/loaderhandle.nim @@ -108,10 +108,11 @@ proc bufferCleared*(output: OutputHandle) = else: output.currentBuffer = nil -proc tee*(outputIn: OutputHandle; ostream: PosixStream; outputId, pid: int) = - let parent = outputIn.parent - parent.outputs.add(OutputHandle( - parent: parent, +proc tee*(outputIn: OutputHandle; ostream: PosixStream; outputId, pid: int): + OutputHandle = + assert outputIn.suspended + let output = OutputHandle( + parent: outputIn.parent, ostream: ostream, currentBuffer: outputIn.currentBuffer, currentBufferIdx: outputIn.currentBufferIdx, @@ -120,7 +121,13 @@ proc tee*(outputIn: OutputHandle; ostream: PosixStream; outputId, pid: int) = outputId: outputId, ownerPid: pid, suspended: outputIn.suspended - )) + ) + when defined(debug): + output.url = outputIn.url + if outputIn.parent != nil: + assert outputIn.parent.parser == nil + outputIn.parent.outputs.add(output) + return output template output*(handle: LoaderHandle): OutputHandle = handle.outputs[0] @@ -194,6 +201,6 @@ proc oclose*(output: OutputHandle) = proc close*(handle: LoaderHandle) = handle.iclose() for output in handle.outputs: - #TODO assert not output.registered + assert not output.registered if output.ostream != nil: output.oclose() |