CI / test (push) Canceled after 0s
- Add chandra-camera-isp.c (C/OpenMP) for Quad-Bayer unpack, CCM, and tone mapping, with a NumPy fallback when it is not built - Add non-blocking contrast-detection VCM autofocus, with lens subdev discovery on the sensor's I2C bus - Tune Quad-Bayer AE: a video-mode vblank cap, damped steps, and full analog gain before extending blanking - Record variable-frame-rate video through a streaming Matroska muxer, and count dropped frames - Ship libcamera IPA tuning files for imx376, imx519, and uncalibrated sensors - Map camera buffers by fd and sync them with dma-buf ioctls
79 lines
1.9 KiB
MoonBit
79 lines
1.9 KiB
MoonBit
///| Native font backend: glyphs from stb_truetype through a C shim (font_stub.c).
|
|
|
|
///|
|
|
#borrow(path)
|
|
extern "C" fn c_font_load(slot : Int, path : Bytes) -> Int = "mp_font_load"
|
|
|
|
///|
|
|
#borrow(info)
|
|
extern "C" fn c_font_metrics(
|
|
slot : Int,
|
|
cp : Int,
|
|
size : Int,
|
|
info : FixedArray[Int],
|
|
) = "mp_font_metrics"
|
|
|
|
///|
|
|
#borrow(buf)
|
|
extern "C" fn c_font_bitmap(
|
|
slot : Int,
|
|
cp : Int,
|
|
size : Int,
|
|
w : Int,
|
|
h : Int,
|
|
buf : Bytes,
|
|
) = "mp_font_bitmap"
|
|
|
|
///|
|
|
extern "C" fn c_font_has_glyph(slot : Int, cp : Int) -> Int = "mp_font_has_glyph"
|
|
|
|
///|
|
|
fn utf8(s : String) -> Bytes {
|
|
let out : Array[Byte] = []
|
|
for ch in s {
|
|
let c = ch.to_int()
|
|
if c < 0x80 {
|
|
out.push(c.to_byte())
|
|
} else if c < 0x800 {
|
|
out.push((0xC0 | (c >> 6)).to_byte())
|
|
out.push((0x80 | (c & 0x3F)).to_byte())
|
|
} else if c < 0x10000 {
|
|
out.push((0xE0 | (c >> 12)).to_byte())
|
|
out.push((0x80 | ((c >> 6) & 0x3F)).to_byte())
|
|
out.push((0x80 | (c & 0x3F)).to_byte())
|
|
} else {
|
|
out.push((0xF0 | (c >> 18)).to_byte())
|
|
out.push((0x80 | ((c >> 12) & 0x3F)).to_byte())
|
|
out.push((0x80 | ((c >> 6) & 0x3F)).to_byte())
|
|
out.push((0x80 | (c & 0x3F)).to_byte())
|
|
}
|
|
}
|
|
Bytes::from_array(out)
|
|
}
|
|
|
|
///| Load a TTF file into `slot`.
|
|
fn b_load(slot : Int, path : String) -> Bool {
|
|
c_font_load(slot, utf8(path)) == 0
|
|
}
|
|
|
|
///| Rasterise one glyph.
|
|
fn b_glyph(slot : Int, cp : Int, size : Int) -> RawGlyph {
|
|
let info : FixedArray[Int] = FixedArray::make(5, 0)
|
|
c_font_metrics(slot, cp, size, info)
|
|
let w = info[0]
|
|
let h = info[1]
|
|
let buf = if w > 0 && h > 0 {
|
|
let b = Bytes::make(w * h, b'\x00')
|
|
c_font_bitmap(slot, cp, size, w, h, b)
|
|
b
|
|
} else {
|
|
Bytes::make(0, b'\x00')
|
|
}
|
|
{ w, h, xoff: info[2], yoff: info[3], advance: info[4], coverage: buf }
|
|
}
|
|
|
|
///| Whether `slot` has a glyph for `cp` (not `.notdef`).
|
|
fn b_has_glyph(slot : Int, cp : Int) -> Bool {
|
|
c_font_has_glyph(slot, cp) != 0
|
|
}
|