- 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
This commit is contained in:
1 parent
851c39d827
commit
52b42890d6
34 files changed
+2851
-364
No files matched your search
@@ -496,10 +496,99 @@ pub fn set_glyph_source(f : (Int, Int, Bool, Bool) -> Glyph) -> Unit {
|
||||
glyph_source.val = Some(f)
|
||||
}
|
||||
|
||||
///| Pixel square size for inline colour emoji at font `size` (~1.2em, matching UI line height).
|
||||
pub fn inline_emoji_px(size : Int) -> Int {
|
||||
if size <= 0 {
|
||||
0
|
||||
} else {
|
||||
(size * 6 + 4) / 5
|
||||
}
|
||||
}
|
||||
|
||||
///| Optional inline emoji matcher and image provider for general UI text.
|
||||
let emoji_match_source : Ref[((Array[Char], Int, Bool, Bool) -> (Int, String)?)?] = {
|
||||
val: None,
|
||||
}
|
||||
|
||||
///|
|
||||
let emoji_image_source : Ref[((String, Int) -> UInt)?] = { val: None }
|
||||
|
||||
///| Register inline colour emoji lookup (`match_at`) and image rasteriser (`image`).
|
||||
pub fn set_emoji_source(
|
||||
match_at : (Array[Char], Int, Bool, Bool) -> (Int, String)?,
|
||||
image : (String, Int) -> UInt,
|
||||
) -> Unit {
|
||||
emoji_match_source.val = Some(match_at)
|
||||
emoji_image_source.val = Some(image)
|
||||
}
|
||||
|
||||
///|
|
||||
priv enum TextPiece {
|
||||
TextGlyph(Glyph)
|
||||
TextEmoji(String)
|
||||
}
|
||||
|
||||
///|
|
||||
fn renderer_may_have_emoji(text : String) -> Bool {
|
||||
for ch in text {
|
||||
if ch.to_int() >= 0x203C {
|
||||
return true
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
///|
|
||||
fn renderer_ignorable_mod(cp : Int) -> Bool {
|
||||
cp == 0xFE0E || cp == 0xFE0F || cp == 0x200D
|
||||
}
|
||||
|
||||
///| Segment `text` into text glyphs and inline emoji clusters, returning `(pieces, total_w)`.
|
||||
fn layout_text(
|
||||
src : (Int, Int, Bool, Bool) -> Glyph,
|
||||
match_at : (Array[Char], Int, Bool, Bool) -> (Int, String)?,
|
||||
text : String,
|
||||
size : Int,
|
||||
bold : Bool,
|
||||
mono : Bool,
|
||||
) -> (Array[TextPiece], Int) {
|
||||
let chars = text.to_array()
|
||||
let epx = inline_emoji_px(size)
|
||||
let pieces : Array[TextPiece] = []
|
||||
let mut total_w = 0
|
||||
let mut i = 0
|
||||
while i < chars.length() {
|
||||
match match_at(chars, i, bold, mono) {
|
||||
Some((next, seq)) => {
|
||||
pieces.push(TextEmoji(seq))
|
||||
total_w = total_w + epx
|
||||
i = next
|
||||
}
|
||||
None => {
|
||||
let cp = chars[i].to_int()
|
||||
if !renderer_ignorable_mod(cp) {
|
||||
let g = src(cp, size, bold, mono)
|
||||
pieces.push(TextGlyph(g))
|
||||
total_w = total_w + g.advance + (if g.embolden { 1 } else { 0 })
|
||||
}
|
||||
i = i + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
(pieces, total_w)
|
||||
}
|
||||
|
||||
///| Pixel width `text` would occupy when drawn with the given face.
|
||||
pub fn text_width(text : String, size : Int, bold : Bool, mono : Bool) -> Int {
|
||||
match glyph_source.val {
|
||||
Some(src) => {
|
||||
match emoji_match_source.val {
|
||||
Some(match_at) if renderer_may_have_emoji(text) => {
|
||||
let (_, w) = layout_text(src, match_at, text, size, bold, mono)
|
||||
return w
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
let mut w = 0
|
||||
for ch in text {
|
||||
let g = src(ch.to_int(), size, bold, mono)
|
||||
@@ -525,12 +614,20 @@ fn draw_text_font(
|
||||
bold : Bool,
|
||||
clip : @scene.Rect?,
|
||||
) -> Unit {
|
||||
let glyphs : Array[Glyph] = []
|
||||
let mut total_w = 0
|
||||
for ch in text {
|
||||
let g = src(ch.to_int(), size, bold, mono)
|
||||
glyphs.push(g)
|
||||
total_w = total_w + g.advance + (if g.embolden { 1 } else { 0 })
|
||||
let epx = inline_emoji_px(size)
|
||||
let (pieces, total_w) = match (emoji_match_source.val, emoji_image_source.val) {
|
||||
(Some(match_at), Some(_)) if renderer_may_have_emoji(text) =>
|
||||
layout_text(src, match_at, text, size, bold, mono)
|
||||
_ => {
|
||||
let pieces : Array[TextPiece] = []
|
||||
let mut total_w = 0
|
||||
for ch in text {
|
||||
let g = src(ch.to_int(), size, bold, mono)
|
||||
pieces.push(TextGlyph(g))
|
||||
total_w = total_w + g.advance + (if g.embolden { 1 } else { 0 })
|
||||
}
|
||||
(pieces, total_w)
|
||||
}
|
||||
}
|
||||
let start_x = match align {
|
||||
Left => x
|
||||
@@ -545,21 +642,37 @@ fn draw_text_font(
|
||||
let cb = color.b.to_int()
|
||||
let ca = color.a.to_int()
|
||||
let mut pen = start_x
|
||||
for g in glyphs {
|
||||
for row = 0; row < g.h; row = row + 1 {
|
||||
for col = 0; col < g.w; col = col + 1 {
|
||||
let cov = g.coverage[row * g.w + col].to_int()
|
||||
if cov > 0 {
|
||||
let px = pen + g.xoff + col
|
||||
let py = baseline + g.yoff + row
|
||||
blend_pixel(dst, px, py, cr, cg, cb, ca * cov / 255, clip)
|
||||
if g.embolden {
|
||||
blend_pixel(dst, px + 1, py, cr, cg, cb, ca * cov / 255, clip)
|
||||
for piece in pieces {
|
||||
match piece {
|
||||
TextGlyph(g) => {
|
||||
for row = 0; row < g.h; row = row + 1 {
|
||||
for col = 0; col < g.w; col = col + 1 {
|
||||
let cov = g.coverage[row * g.w + col].to_int()
|
||||
if cov > 0 {
|
||||
let px = pen + g.xoff + col
|
||||
let py = baseline + g.yoff + row
|
||||
blend_pixel(dst, px, py, cr, cg, cb, ca * cov / 255, clip)
|
||||
if g.embolden {
|
||||
blend_pixel(dst, px + 1, py, cr, cg, cb, ca * cov / 255, clip)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pen = pen + g.advance + (if g.embolden { 1 } else { 0 })
|
||||
}
|
||||
TextEmoji(seq) => {
|
||||
match emoji_image_source.val {
|
||||
Some(img_fn) if epx > 0 => {
|
||||
let h = img_fn(seq, epx)
|
||||
if h != 0U {
|
||||
draw_image(dst, h, @scene.Rect::new(pen, y - epx / 2, epx, epx), clip)
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
pen = pen + epx
|
||||
}
|
||||
}
|
||||
pen = pen + g.advance + (if g.embolden { 1 } else { 0 })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user