revert failed fixed
This commit is contained in:
@@ -101,9 +101,7 @@ 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 (!software.canPaintDirty(snapshot)) {
|
if (snapshot != null && snapshot.renderRows().size() == snapshot.rows()) {
|
||||||
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,21 +677,12 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
|
|||||||
private PixelBuffer<IntBuffer> pixelBuffer;
|
private PixelBuffer<IntBuffer> pixelBuffer;
|
||||||
private WritableImage image;
|
private WritableImage image;
|
||||||
private long[] rowHashes = new long[0];
|
private long[] rowHashes = new long[0];
|
||||||
private boolean[] paintedRows = new boolean[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];
|
||||||
paintedRows = new boolean[0];
|
|
||||||
lastCursor = CursorState.none();
|
lastCursor = CursorState.none();
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean canPaintDirty(RenderStateSnapshot snapshot) {
|
|
||||||
return valid && snapshot != null && rowHashes.length == snapshot.rows()
|
|
||||||
&& paintedRows.length == snapshot.rows() && allRowsPainted();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void paintFull(GraphicsContext gc, RenderStateSnapshot snapshot,
|
private void paintFull(GraphicsContext gc, RenderStateSnapshot snapshot,
|
||||||
@@ -701,11 +690,9 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
|
|||||||
ensure(paneWidth, paneHeight);
|
ensure(paneWidth, paneHeight);
|
||||||
fillRect(0, 0, width, height, argbPre(PANE_BACKGROUND));
|
fillRect(0, 0, width, height, argbPre(PANE_BACKGROUND));
|
||||||
if (snapshot != null) {
|
if (snapshot != null) {
|
||||||
prepareRows(snapshot.rows());
|
|
||||||
paintSnapshot(snapshot);
|
paintSnapshot(snapshot);
|
||||||
drawCursor(snapshot);
|
drawCursor(snapshot);
|
||||||
rememberSnapshot(snapshot);
|
rememberSnapshot(snapshot);
|
||||||
valid = allRowsPainted();
|
|
||||||
} else {
|
} else {
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
@@ -726,7 +713,6 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
|
|||||||
if (scroll != 0) {
|
if (scroll != 0) {
|
||||||
scrollContentPixels(scroll);
|
scrollContentPixels(scroll);
|
||||||
scrollHashes(scroll);
|
scrollHashes(scroll);
|
||||||
scrollPaintedRows(scroll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CursorState cursor = CursorState.from(snapshot);
|
CursorState cursor = CursorState.from(snapshot);
|
||||||
@@ -744,7 +730,6 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastCursor = cursor;
|
lastCursor = cursor;
|
||||||
valid = allRowsPainted();
|
|
||||||
drawCursor(snapshot);
|
drawCursor(snapshot);
|
||||||
drawBorder(active);
|
drawBorder(active);
|
||||||
present(gc, px, py);
|
present(gc, px, py);
|
||||||
@@ -753,9 +738,14 @@ 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 (!canPaintDirty(snapshot)) {
|
if (snapshot == null) {
|
||||||
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();
|
||||||
@@ -776,7 +766,6 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
|
|||||||
}
|
}
|
||||||
repaintCursorRow(snapshot, newCursorRow, repainted);
|
repaintCursorRow(snapshot, newCursorRow, repainted);
|
||||||
lastCursor = cursor;
|
lastCursor = cursor;
|
||||||
valid = allRowsPainted();
|
|
||||||
drawCursor(snapshot);
|
drawCursor(snapshot);
|
||||||
drawBorder(active);
|
drawBorder(active);
|
||||||
present(gc, px, py);
|
present(gc, px, py);
|
||||||
@@ -836,12 +825,12 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean canDiff(RenderStateSnapshot snapshot) {
|
private boolean canDiff(RenderStateSnapshot snapshot) {
|
||||||
return canPaintDirty(snapshot) && snapshot.renderRows().size() == snapshot.rows();
|
return rowHashes.length == snapshot.rows() && snapshot.renderRows().size() == snapshot.rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rememberSnapshot(RenderStateSnapshot snapshot) {
|
private void rememberSnapshot(RenderStateSnapshot snapshot) {
|
||||||
if (rowHashes.length != snapshot.rows()) {
|
if (rowHashes.length != snapshot.rows()) {
|
||||||
prepareRows(snapshot.rows());
|
rowHashes = new long[snapshot.rows()];
|
||||||
}
|
}
|
||||||
for (RenderRow row : snapshot.renderRows()) {
|
for (RenderRow row : snapshot.renderRows()) {
|
||||||
rowHashes[row.row()] = rowHash(row);
|
rowHashes[row.row()] = rowHash(row);
|
||||||
@@ -867,11 +856,13 @@ 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++;
|
||||||
}
|
}
|
||||||
@@ -905,17 +896,6 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
|
|||||||
rowHashes = shifted;
|
rowHashes = shifted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scrollPaintedRows(int rows) {
|
|
||||||
boolean[] shifted = new boolean[paintedRows.length];
|
|
||||||
for (int row = 0; row < shifted.length; row++) {
|
|
||||||
int previous = row - rows;
|
|
||||||
if (previous >= 0 && previous < paintedRows.length) {
|
|
||||||
shifted[row] = paintedRows[previous];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
paintedRows = shifted;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scrollContentPixels(int rows) {
|
private void scrollContentPixels(int rows) {
|
||||||
int dy = rows * lineHeight();
|
int dy = rows * lineHeight();
|
||||||
int top = contentTop();
|
int top = contentTop();
|
||||||
@@ -972,30 +952,6 @@ final class GhosttyTerminalRenderer extends TerminalRenderer {
|
|||||||
paintRowSidePadding(row, rowTop, rowHeight);
|
paintRowSidePadding(row, rowTop, rowHeight);
|
||||||
paintRowBackgrounds(row, rowTop, rowHeight);
|
paintRowBackgrounds(row, rowTop, rowHeight);
|
||||||
paintRowText(row, rowTop);
|
paintRowText(row, rowTop);
|
||||||
markPainted(row.row());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void prepareRows(int rows) {
|
|
||||||
rowHashes = new long[rows];
|
|
||||||
paintedRows = new boolean[rows];
|
|
||||||
}
|
|
||||||
|
|
||||||
private void markPainted(int row) {
|
|
||||||
if (row >= 0 && row < paintedRows.length) {
|
|
||||||
paintedRows[row] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean allRowsPainted() {
|
|
||||||
if (paintedRows.length == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (boolean painted : paintedRows) {
|
|
||||||
if (!painted) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void paintRowSidePadding(RenderRow row, int rowTop, int rowHeight) {
|
private void paintRowSidePadding(RenderRow row, int rowTop, int rowHeight) {
|
||||||
|
|||||||
Reference in New Issue
Block a user