128 lines
5.7 KiB
Diff
128 lines
5.7 KiB
Diff
diff --git a/drivers/graphics/fbcond/src/text.rs b/drivers/graphics/fbcond/src/text.rs
|
|
index 4130b05f..a71a9f51 100644
|
|
--- a/drivers/graphics/fbcond/src/text.rs
|
|
+++ b/drivers/graphics/fbcond/src/text.rs
|
|
@@ -128,2 +128 @@ impl TextScreen {
|
|
- match &mut self.display.map {
|
|
- Some(DisplayMap::Drm(map)) => {
|
|
+ if let Some(map) = &mut self.display.map {
|
|
@@ -130,0 +130 @@ impl TextScreen {
|
|
+ }
|
|
@@ -131,0 +132,2 @@ impl TextScreen {
|
|
+ match &mut self.display.map {
|
|
+ Some(DisplayMap::Drm(map)) => {
|
|
@@ -146 +148,7 @@ impl TextScreen {
|
|
- self.write_direct(direct_map, buf);
|
|
+ Self::write_direct(
|
|
+ direct_map,
|
|
+ buf,
|
|
+ &mut self.direct_console,
|
|
+ &mut self.direct_initialized,
|
|
+ &mut self.scrollback,
|
|
+ );
|
|
@@ -164 +172,7 @@ impl TextScreen {
|
|
- fn write_direct(&mut self, direct_map: &mut DirectFbMap, buf: &[u8]) {
|
|
+ fn write_direct(
|
|
+ direct_map: &mut DirectFbMap,
|
|
+ buf: &[u8],
|
|
+ direct_console: &mut ransid::Console,
|
|
+ direct_initialized: &mut bool,
|
|
+ scrollback: &mut VecDeque<Vec<u8>>,
|
|
+ ) {
|
|
@@ -172,3 +186,3 @@ impl TextScreen {
|
|
- if !self.direct_initialized {
|
|
- self.direct_console.resize(width / CHAR_WIDTH, height / CHAR_HEIGHT);
|
|
- self.direct_initialized = true;
|
|
+ if !*direct_initialized {
|
|
+ direct_console.resize(width / CHAR_WIDTH, height / CHAR_HEIGHT);
|
|
+ *direct_initialized = true;
|
|
@@ -177,5 +191,3 @@ impl TextScreen {
|
|
- let console = &mut self.direct_console;
|
|
-
|
|
- if console.state.cursor
|
|
- && console.state.x < console.state.w
|
|
- && console.state.y < console.state.h
|
|
+ if direct_console.state.cursor
|
|
+ && direct_console.state.x < direct_console.state.w
|
|
+ && direct_console.state.y < direct_console.state.h
|
|
@@ -183,2 +195,2 @@ impl TextScreen {
|
|
- let x = console.state.x;
|
|
- let y = console.state.y;
|
|
+ let x = direct_console.state.x;
|
|
+ let y = direct_console.state.y;
|
|
@@ -188 +200,2 @@ impl TextScreen {
|
|
- let pixels = direct_map.pixel_slice();
|
|
+ // Extract stride before pixel_slice: borrow sequence must be
|
|
+ // width/height → stride → pixel_slice to avoid E0502/E0500.
|
|
@@ -189,0 +203,3 @@ impl TextScreen {
|
|
+ let pixels = direct_map.pixel_slice();
|
|
+ let fb_width = width;
|
|
+ let fb_height = height;
|
|
@@ -191 +207,4 @@ impl TextScreen {
|
|
- console.write(buf, |event| match event {
|
|
+ // Use pixels/stride inside the closure — direct_map is already mutably
|
|
+ // borrowed via pixel_slice, so we cannot call Self::char_direct etc.
|
|
+ // which would re-borrow direct_map.
|
|
+ direct_console.write(buf, |event| match event {
|
|
@@ -197 +216 @@ impl TextScreen {
|
|
- bold,
|
|
+ bold: _,
|
|
@@ -200 +219,13 @@ impl TextScreen {
|
|
- Self::char_direct(direct_map, x * CHAR_WIDTH, y * CHAR_HEIGHT, c, color.as_rgb(), bold);
|
|
+ let cx = x * CHAR_WIDTH;
|
|
+ let cy = y * CHAR_HEIGHT;
|
|
+ if cx + CHAR_WIDTH <= fb_width && cy + CHAR_HEIGHT <= fb_height {
|
|
+ let font_i = CHAR_HEIGHT * (c as usize);
|
|
+ if font_i + CHAR_HEIGHT <= orbclient::FONT.len() {
|
|
+ for row in 0..CHAR_HEIGHT {
|
|
+ let row_data = orbclient::FONT[font_i + row];
|
|
+ let offset = (cy + row) * stride + cx;
|
|
+ for col in 0..CHAR_WIDTH {
|
|
+ if (row_data >> (7 - col)) & 1 == 1 {
|
|
+ pixels[offset + col] = color.as_rgb();
|
|
+ }
|
|
+ }
|
|
@@ -202 +233,4 @@ impl TextScreen {
|
|
- ransid::Event::Input { data } => self.input.extend(data),
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ ransid::Event::Input { .. } => (),
|
|
@@ -204 +238,15 @@ impl TextScreen {
|
|
- Self::rect_direct(direct_map, x * CHAR_WIDTH, y * CHAR_HEIGHT, w * CHAR_WIDTH, h * CHAR_HEIGHT, color.as_rgb());
|
|
+ let rx = x * CHAR_WIDTH;
|
|
+ let ry = y * CHAR_HEIGHT;
|
|
+ let rw = w * CHAR_WIDTH;
|
|
+ let rh = h * CHAR_HEIGHT;
|
|
+ let start_y = ry.min(fb_height);
|
|
+ let end_y = (ry + rh).min(fb_height);
|
|
+ let start_x = rx.min(fb_width);
|
|
+ let len = (rx + rw).min(fb_width) - start_x;
|
|
+ let rgb = color.as_rgb();
|
|
+ for row in start_y..end_y {
|
|
+ let offset = row * stride + start_x;
|
|
+ for i in 0..len {
|
|
+ pixels[offset + i] = rgb;
|
|
+ }
|
|
+ }
|
|
@@ -239,3 +287,3 @@ impl TextScreen {
|
|
- if console.state.cursor
|
|
- && console.state.x < console.state.w
|
|
- && console.state.y < console.state.h
|
|
+ if direct_console.state.cursor
|
|
+ && direct_console.state.x < direct_console.state.w
|
|
+ && direct_console.state.y < direct_console.state.h
|
|
@@ -243,2 +291,2 @@ impl TextScreen {
|
|
- let x = console.state.x;
|
|
- let y = console.state.y;
|
|
+ let x = direct_console.state.x;
|
|
+ let y = direct_console.state.y;
|
|
@@ -251 +299 @@ impl TextScreen {
|
|
- self.scrollback.push_back(v);
|
|
+ scrollback.push_back(v);
|
|
@@ -253,2 +301,2 @@ impl TextScreen {
|
|
- while self.scrollback.len() > SCROLLBACK_LINES {
|
|
- self.scrollback.pop_front();
|
|
+ while scrollback.len() > SCROLLBACK_LINES {
|
|
+ scrollback.pop_front();
|