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
/// 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;
// let mut strpos; // just for debugging insertion points
for word in self.words.iter() {
@ -159,18 +159,19 @@ impl ComposedType {
} else {
let cr =
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 {
blitstr2::xor_glyph_large(
frbuf,
rawbuf,
(maybe_x, maybe_y),
*glyph,
glyph.invert ^ invert,
cr,
);
} 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 {
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 {
// log::info!("insert at {},{}", glyph.ch, strpos - 1);