Skip to content

Commit 15f8830

Browse files
committed
drop snapshots
1 parent 83fbdf2 commit 15f8830

File tree

5 files changed

+48
-153
lines changed

5 files changed

+48
-153
lines changed

frontends/rioterm/src/application.rs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -226,45 +226,7 @@ impl ApplicationHandler<EventPayload> for Application<'_> {
226226
}
227227
}
228228
}
229-
RioEventType::Rio(RioEvent::TerminalDamaged { route_id, damage }) => {
230-
if self.config.renderer.strategy.is_event_based() {
231-
if let Some(route) = self.router.routes.get_mut(&window_id) {
232-
// Skip rendering for unfocused windows if configured
233-
if self.config.renderer.disable_unfocused_render
234-
&& !route.window.is_focused
235-
{
236-
return;
237-
}
238-
239-
// Skip rendering for occluded windows if configured
240-
if self.config.renderer.disable_occluded_render
241-
&& route.window.is_occluded
242-
&& !route.window.needs_render_after_occlusion
243-
{
244-
return;
245-
}
246-
247-
// We received a damage event, so we should render
248-
// Don't second-guess the damage event by checking needs_render()
249229

250-
// Clear the one-time render flag if it was set
251-
if route.window.needs_render_after_occlusion {
252-
route.window.needs_render_after_occlusion = false;
253-
}
254-
255-
if let Some(ctx_item) =
256-
route.window.screen.ctx_mut().get_mut(route_id)
257-
{
258-
ctx_item
259-
.val
260-
.renderable_content
261-
.pending_update
262-
.invalidate(damage, &ctx_item.val.terminal);
263-
route.schedule_redraw(&mut self.scheduler, route_id);
264-
}
265-
}
266-
}
267-
}
268230
RioEventType::Rio(RioEvent::Wakeup(route_id)) => {
269231
if self.config.renderer.strategy.is_event_based() {
270232
if let Some(route) = self.router.routes.get_mut(&window_id) {

frontends/rioterm/src/context/renderable.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,7 @@ impl PendingUpdate {
114114
self.dirty = true;
115115
}
116116

117-
/// Clear the dirty flag
118-
pub fn clear_dirty(&mut self) {
119-
self.dirty = false;
120-
}
117+
121118

122119
/// Mark as needing update.
123120
/// The actual snapshot will be computed at render time.
@@ -372,9 +369,8 @@ mod tests {
372369
.invalidate(TerminalDamage::Full, &terminal);
373370
assert!(content.pending_update.is_dirty());
374371

375-
// Take snapshot - should clear dirty flag
376-
let snapshot1 = content.pending_update.take_snapshot();
377-
assert!(snapshot1.is_some());
372+
// Reset dirty flag - simulating render
373+
content.pending_update.reset();
378374
assert!(!content.pending_update.is_dirty());
379375

380376
// Second update
@@ -385,9 +381,8 @@ mod tests {
385381
.invalidate(TerminalDamage::Partial(damaged_lines), &terminal);
386382
assert!(content.pending_update.is_dirty());
387383

388-
// Take second snapshot
389-
let snapshot2 = content.pending_update.take_snapshot();
390-
assert!(snapshot2.is_some());
384+
// Reset dirty flag again
385+
content.pending_update.reset();
391386
assert!(!content.pending_update.is_dirty());
392387
}
393388
}

frontends/rioterm/src/renderer/mod.rs

Lines changed: 39 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -846,65 +846,45 @@ impl Renderer {
846846
let force_full_damage = has_active_changed || self.is_game_mode_enabled;
847847

848848
// Check if we need to render
849-
// if !context.renderable_content.pending_update.is_dirty() && !force_full_damage
850-
// {
851-
// println!("NAUM tem");
852-
// // No updates pending, skip rendering
853-
// continue;
854-
// }
855-
856-
// Take the pending snapshot
857-
let terminal_snapshot =
858-
// match context.renderable_content.pending_update.take_snapshot() {
859-
// (Some(snapshot), _) => snapshot,
860-
// (None, was_wakeup) if was_wakeup => {
861-
// // This was a Wakeup event - check the terminal for damage
862-
// let mut terminal = context.terminal.lock();
863-
864-
// // Get the damage from the terminal
865-
// if let Some(damage) = terminal.peek_damage_event() {
866-
// let snapshot = TerminalSnapshot {
867-
// colors: terminal.colors,
868-
// display_offset: terminal.display_offset(),
869-
// blinking_cursor: terminal.blinking_cursor,
870-
// visible_rows: terminal.visible_rows(),
871-
// cursor: terminal.cursor(),
872-
// damage: damage.clone(),
873-
// columns: terminal.columns(),
874-
// screen_lines: terminal.screen_lines(),
875-
// };
876-
// terminal.reset_damage();
877-
// drop(terminal);
878-
879-
// snapshot
880-
// } else {
881-
// // No damage found, skip rendering
882-
// drop(terminal);
883-
// continue;
884-
// }
885-
// }
886-
{
887-
// Force full damage case - create a fresh snapshot
888-
let mut terminal = context.terminal.lock();
889-
let snapshot = TerminalSnapshot {
890-
colors: terminal.colors,
891-
display_offset: terminal.display_offset(),
892-
blinking_cursor: terminal.blinking_cursor,
893-
visible_rows: terminal.visible_rows(),
894-
cursor: terminal.cursor(),
895-
damage: TerminalDamage::Full,
896-
columns: terminal.columns(),
897-
screen_lines: terminal.screen_lines(),
898-
};
899-
terminal.reset_damage();
900-
drop(terminal);
901-
snapshot
902-
};
903-
// (None, _) => {
904-
// // No pending update and not forcing
905-
// continue;
906-
// }
907-
// };
849+
if !context.renderable_content.pending_update.is_dirty() && !force_full_damage
850+
{
851+
// No updates pending, skip rendering
852+
continue;
853+
}
854+
855+
context.renderable_content.pending_update.reset();
856+
857+
// Compute snapshot at render time
858+
let terminal_snapshot = {
859+
let mut terminal = context.terminal.lock();
860+
861+
// Get damage from terminal or use full damage if forced
862+
let damage = if force_full_damage {
863+
TerminalDamage::Full
864+
} else if let Some(damage) = terminal.peek_damage_event() {
865+
damage
866+
} else {
867+
TerminalDamage::Full
868+
};
869+
870+
let snapshot = TerminalSnapshot {
871+
colors: terminal.colors,
872+
display_offset: terminal.display_offset(),
873+
blinking_cursor: terminal.blinking_cursor,
874+
visible_rows: terminal.visible_rows(),
875+
cursor: terminal.cursor(),
876+
damage,
877+
columns: terminal.columns(),
878+
screen_lines: terminal.screen_lines(),
879+
};
880+
terminal.reset_damage();
881+
drop(terminal);
882+
883+
// Clear the dirty flag after computing snapshot
884+
context.renderable_content.pending_update.reset();
885+
886+
snapshot
887+
};
908888

909889
// Get hint matches from renderable content
910890
let hint_matches = context.renderable_content.hint_matches.as_deref();

rio-backend/src/crosswords/mod.rs

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -487,18 +487,8 @@ impl<U: EventListener> Crosswords<U> {
487487

488488
pub fn mark_fully_damaged(&mut self) {
489489
// Only emit event if we weren't already fully damaged
490-
let was_damaged = self.damage.full;
490+
let _was_damaged = self.damage.full;
491491
self.damage.full = true;
492-
493-
if !was_damaged {
494-
self.event_proxy.send_event(
495-
RioEvent::TerminalDamaged {
496-
route_id: self.route_id,
497-
damage: TerminalDamage::Full,
498-
},
499-
self.window_id,
500-
);
501-
}
502492
}
503493

504494
#[inline]
@@ -561,7 +551,7 @@ impl<U: EventListener> Crosswords<U> {
561551
/// Emit damage event based on current damage state
562552
pub fn emit_damage_event(&self) {
563553
let display_offset = self.grid.display_offset();
564-
let damage = if self.damage.full {
554+
let _damage = if self.damage.full {
565555
TerminalDamage::Full
566556
} else {
567557
// Collect damaged lines
@@ -584,14 +574,6 @@ impl<U: EventListener> Crosswords<U> {
584574
TerminalDamage::Partial(damaged_lines)
585575
}
586576
};
587-
588-
self.event_proxy.send_event(
589-
RioEvent::TerminalDamaged {
590-
route_id: self.route_id,
591-
damage,
592-
},
593-
self.window_id,
594-
);
595577
}
596578

597579
/// Peek damage event based on current damage state
@@ -1263,14 +1245,8 @@ impl<U: EventListener> Crosswords<U> {
12631245

12641246
// Only emit event if line wasn't already damaged
12651247
if !was_damaged {
1266-
let damaged_line = LineDamage::new(line_idx, true);
1267-
self.event_proxy.send_event(
1268-
RioEvent::TerminalDamaged {
1269-
route_id: self.route_id,
1270-
damage: TerminalDamage::Partial([damaged_line].into_iter().collect()),
1271-
},
1272-
self.window_id,
1273-
);
1248+
let _damaged_line = LineDamage::new(line_idx, true);
1249+
// Event removed - damage is tracked internally
12741250
}
12751251
}
12761252

rio-backend/src/event/mod.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ pub enum RioEvent {
6868
RenderRoute(usize),
6969
/// Wake up and check for terminal updates.
7070
Wakeup(usize),
71-
/// Terminal content has changed with specific damage information.
72-
TerminalDamaged {
73-
route_id: usize,
74-
damage: TerminalDamage,
75-
},
7671
/// Graphics update available from terminal.
7772
UpdateGraphics {
7873
route_id: usize,
@@ -196,19 +191,6 @@ impl Debug for RioEvent {
196191
RioEvent::Wakeup(route) => {
197192
write!(f, "Wakeup route {route}")
198193
}
199-
RioEvent::TerminalDamaged { route_id, damage } => match damage {
200-
TerminalDamage::Full => {
201-
write!(f, "TerminalDamaged route {route_id} (Full)")
202-
}
203-
TerminalDamage::Partial(lines) => write!(
204-
f,
205-
"TerminalDamaged route {route_id} ({} lines)",
206-
lines.len()
207-
),
208-
TerminalDamage::CursorOnly => {
209-
write!(f, "TerminalDamaged route {route_id} (CursorOnly)")
210-
}
211-
},
212194
RioEvent::Scroll(scroll) => write!(f, "Scroll {scroll:?}"),
213195
RioEvent::Bell => write!(f, "Bell"),
214196
RioEvent::Exit => write!(f, "Exit"),

0 commit comments

Comments
 (0)