finalize
This commit is contained in:
@@ -22,24 +22,32 @@ public final class RenderState implements AutoCloseable {
|
||||
library.renderStateUpdate(handle, terminal.handleForPackage());
|
||||
}
|
||||
|
||||
/** Snapshot with every row's cells fully populated. */
|
||||
public RenderStateSnapshot snapshot() {
|
||||
return buildSnapshot(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Snapshot in which cells are marshalled only for rows ghostty flagged dirty; clean
|
||||
* rows get an empty cell list. Intended for a render state reused across frames (paired
|
||||
* with {@link #resetDirty}) so unchanged rows skip the per-cell marshalling cost. The
|
||||
* global {@link RenderStateSnapshot#dirty()} still reports FALSE / PARTIAL / FULL.
|
||||
*/
|
||||
public RenderStateSnapshot snapshotIncremental() {
|
||||
return buildSnapshot(true);
|
||||
}
|
||||
|
||||
private RenderStateSnapshot buildSnapshot(boolean dirtyRowsOnly) {
|
||||
ensureOpen();
|
||||
boolean cursorViewportHasValue = library.renderStateGetBoolean(
|
||||
handle,
|
||||
GhosttyLibrary.RENDER_STATE_DATA_CURSOR_VIEWPORT_HAS_VALUE
|
||||
);
|
||||
|
||||
// When only some rows changed (PARTIAL), skip marshalling cells for clean rows;
|
||||
// FULL means the whole frame must be redrawn, so every row's cells are needed. A
|
||||
// throwaway render state (a single update) always reports FULL, so callers that do
|
||||
// not keep the state around keep getting fully-populated rows exactly as before.
|
||||
int dirty = library.renderStateGetI32(handle, GhosttyLibrary.RENDER_STATE_DATA_DIRTY);
|
||||
boolean dirtyRowsOnly = dirty != GhosttyLibrary.RENDER_STATE_DIRTY_FULL;
|
||||
|
||||
return new RenderStateSnapshot(
|
||||
library.renderStateGetU16(handle, GhosttyLibrary.RENDER_STATE_DATA_COLS),
|
||||
library.renderStateGetU16(handle, GhosttyLibrary.RENDER_STATE_DATA_ROWS),
|
||||
dirty,
|
||||
library.renderStateGetI32(handle, GhosttyLibrary.RENDER_STATE_DATA_DIRTY),
|
||||
RenderCursorStyle.fromNative(
|
||||
library.renderStateGetI32(handle, GhosttyLibrary.RENDER_STATE_DATA_CURSOR_VISUAL_STYLE)
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user