about summary refs log tree commit diff stats
path: root/src/loader/response.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-01 01:03:50 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-01 01:46:38 +0200
commit55cfd29e961488a8c1ed9eb7801d237d27bc86c7 (patch)
treec74569e15ca72d777eadcfd19a0203cbb76c3e3f /src/loader/response.nim
parente9466c4c436f964b53034e28356aa3f5c957a068 (diff)
downloadchawan-55cfd29e961488a8c1ed9eb7801d237d27bc86c7.tar.gz
canvas: move to separate CGI script
* stream: and passFd is now client-based, and accessible for buffers
* Bitmap's width & height is now int, not uint64
* no more non-network Bitmap special case in the pager for canvas

I just shoehorned it into the static image model, so it still doesn't
render changes after page load. But at least now it doesn't crash the
browser.
Diffstat (limited to 'src/loader/response.nim')
-rw-r--r--src/loader/response.nim42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/loader/response.nim b/src/loader/response.nim
index d41f62eb..1d7307cd 100644
--- a/src/loader/response.nim
+++ b/src/loader/response.nim
@@ -3,7 +3,6 @@ import std/tables
 
 import chagashi/charset
 import chagashi/decoder
-import img/bitmap
 import io/dynstream
 import io/promise
 import loader/headers
@@ -13,7 +12,6 @@ import monoucha/jserror
 import monoucha/quickjs
 import monoucha/tojs
 import types/blob
-import types/color
 import types/opt
 import types/referrer
 import types/url
@@ -228,46 +226,6 @@ proc blob*(response: Response): Promise[JSResult[Blob]] {.jsfunc.} =
   response.resume()
   return opaque.bodyRead
 
-type BitmapOpaque = ref object of RootObj
-  bmp: Bitmap
-  idx: int
-  bodyRead: EmptyPromise
-
-proc onReadBitmap(response: Response) =
-  let opaque = BitmapOpaque(response.opaque)
-  let bmp = opaque.bmp
-  while true:
-    try:
-      let p = cast[ptr UncheckedArray[uint8]](addr bmp.px[0])
-      let L = bmp.px.len * 4 - opaque.idx
-      let n = response.body.recvData(addr p[opaque.idx], L)
-      opaque.idx += n
-      if n == 0:
-        break
-    except ErrorAgain:
-      break
-
-proc onFinishBitmap(response: Response; success: bool) =
-  let opaque = BitmapOpaque(response.opaque)
-  opaque.bodyRead.resolve()
-
-proc saveToBitmap*(response: Response; bmp: Bitmap): EmptyPromise =
-  assert not response.bodyUsed
-  let opaque = BitmapOpaque(bmp: bmp, idx: 0, bodyRead: EmptyPromise())
-  let size = bmp.width * bmp.height
-  bmp.px = cast[seq[RGBAColorBE]](newSeqUninitialized[uint32](size))
-  response.opaque = opaque
-  if size > 0:
-    response.onRead = onReadBitmap
-    response.onFinish = onFinishBitmap
-  else:
-    response.unregisterFun()
-    response.body.sclose()
-    opaque.bodyRead.resolve()
-  response.bodyUsed = true
-  response.resume()
-  return opaque.bodyRead
-
 proc json(ctx: JSContext; this: Response): Promise[JSValue] {.jsfunc.} =
   return this.text().then(proc(s: JSResult[string]): JSValue =
     if s.isNone: