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
138 lines
3.5 KiB
MoonBit
138 lines
3.5 KiB
MoonBit
///| Real text rendering: Allo Variable (UI text, falling back to Adwaita Sans) and Adwaita Mono
|
|
/// (code), rasterised and plugged into the renderer's glyph hook. The pure-MoonBit renderer keeps its
|
|
/// bitmap font when no hook is set. Two backends supply the glyphs: font_native.mbt (stb_truetype
|
|
/// through a C shim) and font_wasm.mbt (the host's `chandra:host/font` import).
|
|
|
|
///| A rasterised glyph as a backend returns it: 8-bit coverage `w` x `h` whose top-left is at
|
|
/// (`xoff`, `yoff`) from the pen on the baseline, and the pen `advance`.
|
|
pub(all) struct RawGlyph {
|
|
w : Int
|
|
h : Int
|
|
xoff : Int
|
|
yoff : Int
|
|
advance : Int
|
|
coverage : Bytes
|
|
}
|
|
|
|
///| Where to look for each face: bundled copy first, then the system one.
|
|
let regular_paths : Array[String] = [
|
|
"assets/fonts/AdwaitaMono-Regular.ttf",
|
|
"/usr/share/fonts/Adwaita/AdwaitaMono-Regular.ttf",
|
|
]
|
|
|
|
///|
|
|
let sans_paths : Array[String] = [
|
|
"assets/fonts/AlloVariable.ttf",
|
|
"/usr/local/share/fonts/a/AlloVariable.ttf",
|
|
"assets/fonts/AdwaitaSans-Regular.ttf",
|
|
"/usr/share/fonts/Adwaita/AdwaitaSans-Regular.ttf",
|
|
]
|
|
|
|
///|
|
|
let bold_paths : Array[String] = [
|
|
"assets/fonts/AdwaitaMono-Bold.ttf",
|
|
"/usr/share/fonts/Adwaita/AdwaitaMono-Bold.ttf",
|
|
]
|
|
|
|
///|
|
|
fn load_first(slot : Int, paths : Array[String]) -> Bool {
|
|
for p in paths {
|
|
if b_load(slot, p) {
|
|
return true
|
|
}
|
|
}
|
|
false
|
|
}
|
|
|
|
///|
|
|
let cache : Map[Int, @renderer.Glyph] = {}
|
|
|
|
///|
|
|
fn rasterise(slot : Int, cp : Int, size : Int, embolden : Bool) -> @renderer.Glyph {
|
|
let key = cp + 0x110000 * (size + 256 * (slot * 2 + (if embolden { 1 } else { 0 })))
|
|
match cache.get(key) {
|
|
Some(g) => g
|
|
None => {
|
|
let r = b_glyph(slot, cp, size)
|
|
let g : @renderer.Glyph = {
|
|
w: r.w,
|
|
h: r.h,
|
|
xoff: r.xoff,
|
|
yoff: r.yoff,
|
|
advance: r.advance,
|
|
coverage: r.coverage,
|
|
embolden,
|
|
}
|
|
cache.set(key, g)
|
|
g
|
|
}
|
|
}
|
|
}
|
|
|
|
///|
|
|
let loaded : FixedArray[Bool] = FixedArray::make(4, false)
|
|
|
|
///|
|
|
fn pick_slot(bold : Bool, mono : Bool) -> Int {
|
|
let has_mono = loaded[0]
|
|
let has_sans = loaded[2]
|
|
if !has_mono && !has_sans {
|
|
return -1
|
|
}
|
|
let has_bold = has_mono && loaded[1]
|
|
if mono && has_mono {
|
|
if bold && has_bold {
|
|
1
|
|
} else {
|
|
0
|
|
}
|
|
} else if has_sans {
|
|
2
|
|
} else {
|
|
0
|
|
}
|
|
}
|
|
|
|
///| Whether the face used for (`bold`, `mono`) has a glyph for `cp`.
|
|
pub fn has_glyph(cp : Int, bold : Bool, mono : Bool) -> Bool {
|
|
let slot = pick_slot(bold, mono)
|
|
if slot < 0 {
|
|
false
|
|
} else {
|
|
b_has_glyph(slot, cp)
|
|
}
|
|
}
|
|
|
|
///| Install Allo Variable (UI text, falling back to Adwaita Sans) and Adwaita Mono (code) as the renderer's
|
|
/// faces. Returns false (keeping the bitmap font) when no face can be found.
|
|
/// Slots: 0 mono, 1 mono bold, 2 sans. Sans is a variable font whose bold
|
|
/// instance stb_truetype can't select, so bold sans is emboldened.
|
|
pub fn install() -> Bool {
|
|
let has_mono = load_first(0, regular_paths)
|
|
let has_sans = load_first(2, sans_paths)
|
|
if !has_mono && !has_sans {
|
|
loaded[0] = false
|
|
loaded[1] = false
|
|
loaded[2] = false
|
|
return false
|
|
}
|
|
let has_bold = has_mono && load_first(1, bold_paths)
|
|
loaded[0] = has_mono
|
|
loaded[1] = has_bold
|
|
loaded[2] = has_sans
|
|
@renderer.set_glyph_source(fn(cp, size, bold, mono) {
|
|
if mono && has_mono {
|
|
if bold && has_bold {
|
|
rasterise(1, cp, size, false)
|
|
} else {
|
|
rasterise(0, cp, size, bold)
|
|
}
|
|
} else if has_sans {
|
|
rasterise(2, cp, size, bold)
|
|
} else {
|
|
rasterise(0, cp, size, bold)
|
|
}
|
|
})
|
|
true
|
|
}
|