fixup apis to use traits

This commit is contained in:
bunnie 2025-02-21 23:42:01 +08:00
parent 8acb9e7521
commit cc8a0a57a7

View file

@ -128,7 +128,7 @@ impl ComposedType {
/// Note: it is up to the caller to ensure that clip_rect is within the renderable screen area. We do no /// Note: it is up to the caller to ensure that clip_rect is within the renderable screen area. We do no
/// additional checks around this. /// additional checks around this.
pub fn render(&self, frbuf: &mut [u32], offset: Point, invert: bool, clip_rect: Rectangle) { pub fn render<T: FrameBuffer>(&self, frbuf: &mut T, offset: Point, invert: bool, clip_rect: Rectangle) {
const MAX_GLYPH_MARGIN: isize = 16; const MAX_GLYPH_MARGIN: isize = 16;
// let mut strpos; // just for debugging insertion points // let mut strpos; // just for debugging insertion points
for word in self.words.iter() { for word in self.words.iter() {
@ -159,18 +159,19 @@ impl ComposedType {
} else { } else {
let cr = let cr =
ClipRect::new(clip_rect.tl().x, clip_rect.tl().y, clip_rect.br().x, clip_rect.br().y); ClipRect::new(clip_rect.tl().x, clip_rect.tl().y, clip_rect.br().x, clip_rect.br().y);
let rawbuf = unsafe { frbuf.raw_mut() };
if glyph.large { if glyph.large {
blitstr2::xor_glyph_large( blitstr2::xor_glyph_large(
frbuf, rawbuf,
(maybe_x, maybe_y), (maybe_x, maybe_y),
*glyph, *glyph,
glyph.invert ^ invert, glyph.invert ^ invert,
cr, cr,
); );
} else if !glyph.double { } else if !glyph.double {
blitstr2::xor_glyph(frbuf, (maybe_x, maybe_y), *glyph, glyph.invert ^ invert, cr); blitstr2::xor_glyph(rawbuf, (maybe_x, maybe_y), *glyph, glyph.invert ^ invert, cr);
} else { } else {
blitstr2::xor_glyph_2x(frbuf, (maybe_x, maybe_y), *glyph, glyph.invert ^ invert, cr); blitstr2::xor_glyph_2x(rawbuf, (maybe_x, maybe_y), *glyph, glyph.invert ^ invert, cr);
} }
if glyph.insert { if glyph.insert {
// log::info!("insert at {},{}", glyph.ch, strpos - 1); // log::info!("insert at {},{}", glyph.ch, strpos - 1);