Fixed the partial-dirty blanking regression

This commit is contained in:
Gregor Lohaus
2026-05-31 17:48:04 +02:00
parent 494d2c40cf
commit 586150de59

View File

@@ -101,7 +101,9 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
if (dirty == DIRTY_FULL) { if (dirty == DIRTY_FULL) {
software.paintFullOrShifted(gc, target.snapshotFull(), px, py, width, height, active); software.paintFullOrShifted(gc, target.snapshotFull(), px, py, width, height, active);
} else if (dirty == DIRTY_PARTIAL) { } else if (dirty == DIRTY_PARTIAL) {
if (snapshot != null && snapshot.renderRows().size() == snapshot.rows()) { if (!software.canPaintDirty(snapshot)) {
software.paintFullOrShifted(gc, target.snapshotFull(), px, py, width, height, active);
} else if (snapshot != null && snapshot.renderRows().size() == snapshot.rows()) {
software.paintFullOrShifted(gc, snapshot, px, py, width, height, active); software.paintFullOrShifted(gc, snapshot, px, py, width, height, active);
} else { } else {
software.paintDirty(gc, snapshot, px, py, width, height, active); software.paintDirty(gc, snapshot, px, py, width, height, active);
@@ -679,10 +681,16 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
private long[] rowHashes = new long[0]; private long[] rowHashes = new long[0];
private CursorState lastCursor = CursorState.none(); private CursorState lastCursor = CursorState.none();
private GlyphCache glyphs; private GlyphCache glyphs;
private boolean valid;
private void invalidate() { private void invalidate() {
rowHashes = new long[0]; rowHashes = new long[0];
lastCursor = CursorState.none(); lastCursor = CursorState.none();
valid = false;
}
private boolean canPaintDirty(RenderStateSnapshot snapshot) {
return valid && snapshot != null && rowHashes.length == snapshot.rows();
} }
private void paintFull(GraphicsContext gc, RenderStateSnapshot snapshot, private void paintFull(GraphicsContext gc, RenderStateSnapshot snapshot,
@@ -693,6 +701,7 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
paintSnapshot(snapshot); paintSnapshot(snapshot);
drawCursor(snapshot); drawCursor(snapshot);
rememberSnapshot(snapshot); rememberSnapshot(snapshot);
valid = true;
} else { } else {
invalidate(); invalidate();
} }
@@ -730,6 +739,7 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
} }
} }
lastCursor = cursor; lastCursor = cursor;
valid = true;
drawCursor(snapshot); drawCursor(snapshot);
drawBorder(active); drawBorder(active);
present(gc, px, py); present(gc, px, py);
@@ -738,14 +748,9 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
private void paintDirty(GraphicsContext gc, RenderStateSnapshot snapshot, private void paintDirty(GraphicsContext gc, RenderStateSnapshot snapshot,
double px, double py, double paneWidth, double paneHeight, boolean active) { double px, double py, double paneWidth, double paneHeight, boolean active) {
ensure(paneWidth, paneHeight); ensure(paneWidth, paneHeight);
if (snapshot == null) { if (!canPaintDirty(snapshot)) {
return; return;
} }
if (rowHashes.length != snapshot.rows()) {
paintFull(gc, snapshot, px, py, paneWidth, paneHeight, active);
return;
}
CursorState cursor = CursorState.from(snapshot); CursorState cursor = CursorState.from(snapshot);
int oldCursorRow = lastCursor.viewportRow(); int oldCursorRow = lastCursor.viewportRow();
int newCursorRow = cursor.viewportRow(); int newCursorRow = cursor.viewportRow();
@@ -766,6 +771,7 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
} }
repaintCursorRow(snapshot, newCursorRow, repainted); repaintCursorRow(snapshot, newCursorRow, repainted);
lastCursor = cursor; lastCursor = cursor;
valid = true;
drawCursor(snapshot); drawCursor(snapshot);
drawBorder(active); drawBorder(active);
present(gc, px, py); present(gc, px, py);
@@ -856,13 +862,11 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
continue; continue;
} }
int score = 0; int score = 0;
int overlap = 0;
for (int row = 0; row < rows; row++) { for (int row = 0; row < rows; row++) {
int previous = row - delta; int previous = row - delta;
if (previous < 0 || previous >= rows) { if (previous < 0 || previous >= rows) {
continue; continue;
} }
overlap++;
if (currentHashes[row] == rowHashes[previous]) { if (currentHashes[row] == rowHashes[previous]) {
score++; score++;
} }