about summary refs log tree commit diff stats
path: root/src/local/client.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-19 17:46:27 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-22 22:44:53 +0200
commit080493c058f52a5c20638f1b975d032af45f4d3f (patch)
tree60e6ba6b3cb967d29d349018b3f315e7637b4b9e /src/local/client.nim
parente23fa780cf2fff7146efcd64b2806ce428858b80 (diff)
downloadchawan-080493c058f52a5c20638f1b975d032af45f4d3f.tar.gz
loader: mmap intermediate image files, misc refactoring
* refactor parseHeader
* optimize response blob()
* add direct "to cache" mode for loader requests which sets stdout to a
  file, and use it for image processing
* move image resizing into a separate process
* mmap cache files in between processing steps when possible

At last, resize is no longer a part of image decoding. Also, it feels
much nicer to keep encoded image data in the same cache as everything
else.

The mmap operations *should* be more efficient than copying the whole
RGBA data through a pipe. In practice, it only makes a difference for
loading (well, now just mmapping) the encoded image into the pager,
where it singlehandedly speeds up image display by 10x on my test image.

For the other steps, the unfortunate fact that "tocache" must delay the
next fork/exec in the pipeline until the entire image is processed seems
to equal out any wins we might have gotten from skipping a single raw
RGBA copy.

I have tried moving the delay before the exec (it's possible with yet
another pipe), but it didn't help much and made the code much
uglier. (Not that tocache didn't, but I can live with this...)
Diffstat (limited to 'src/local/client.nim')
-rw-r--r--src/local/client.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/local/client.nim b/src/local/client.nim
index c8bf9b24..c20a460b 100644
--- a/src/local/client.nim
+++ b/src/local/client.nim
@@ -356,7 +356,7 @@ proc input(client: Client): EmptyPromise =
     p.resolve()
   return p
 
-when not defined(android):
+when ioselSupportedPlatform:
   let SIGWINCH {.importc, header: "<signal.h>", nodecl.}: cint
 
 proc showConsole(client: Client) {.jsfunc.} =
@@ -542,7 +542,7 @@ proc handleError(client: Client; fd: int) =
 proc inputLoop(client: Client) =
   let selector = client.selector
   selector.registerHandle(int(client.pager.term.istream.fd), {Read}, 0)
-  when not defined(android):
+  when ioselSupportedPlatform:
     let sigwinch = selector.registerSignal(int(SIGWINCH), 0)
   var keys: array[64, ReadyKey]
   while true:
@@ -554,7 +554,7 @@ proc inputLoop(client: Client) =
         client.handleWrite(event.fd)
       if Error in event.events:
         client.handleError(event.fd)
-      when not defined(android):
+      when ioselSupportedPlatform:
         if Signal in event.events:
           assert event.fd == sigwinch
           client.pager.windowChange()