forked from Blendman974/faceclaw
Apps submit mutli-plane images with glyphs, rather than mere images
This commit is contained in:
1 parent
df85fb4072
commit
fdf683761e
22 files changed
+348
-101
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { GrayImage } from "../graphics/image";
|
||||
import { type Plane } from "../graphics/plane";
|
||||
import { type IconName } from "../graphics/icons";
|
||||
import { type LayerActions } from "../ui/layers";
|
||||
import { type InProcessAppOptions, type InProcessWindow } from "../ui/shell/in-process-window";
|
||||
@@ -60,8 +60,8 @@ export type AppContext = {
|
||||
) => Promise<void>;
|
||||
/** Get this app's shared worker host, spawning the worker on first use. */
|
||||
ensureWorkerHost: (createWorker: () => Worker) => WorkerAppHost;
|
||||
/** Submit a painted frame for a window surface (windows created outside launchInProcessApp). */
|
||||
submitWindowFrame: (surfaceId: string, image: GrayImage, paintMs: number, frameId: number) => Promise<void>;
|
||||
/** Submit a window surface's painted frame, as planes (windows created outside launchInProcessApp). */
|
||||
submitWindowFrame: (surfaceId: string, planes: Plane[], paintMs: number, frameId: number) => Promise<void>;
|
||||
setWindowSurfaceVisible: (surfaceId: string, visible: boolean) => void;
|
||||
requestShellRender: () => void;
|
||||
appendLog: (message: string) => void;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import type { DashboardInputEvent } from "../../ui/layers";
|
||||
@@ -527,11 +528,11 @@ function updateTickTimer(window: BlocksWindow): void {
|
||||
}
|
||||
}
|
||||
|
||||
function paint(window: BlocksWindow): GrayImage {
|
||||
function paint(window: BlocksWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return paintContent(window);
|
||||
return singlePlane(paintContent(window));
|
||||
}
|
||||
|
||||
function paintContent(window: BlocksWindow): GrayImage {
|
||||
@@ -632,11 +633,11 @@ function renderAndSubmit(window: BlocksWindow, inputFrameId: number): void {
|
||||
const frameId = inputFrameId > 0 ? inputFrameId : frameTimings.startFrame(`render:${window.windowId}`);
|
||||
try {
|
||||
const paintStartedAtMs = Date.now();
|
||||
const image = frameTimings.span(frameId, "paint", () =>
|
||||
const planes = frameTimings.span(frameId, "paint", () =>
|
||||
frameTimings.runWithFrame(frameId, () => paint(window)),
|
||||
);
|
||||
const paintMs = Date.now() - paintStartedAtMs;
|
||||
const fingerprint = image.fingerprint();
|
||||
const fingerprint = planesFingerprint(planes);
|
||||
if (fingerprint === window.lastSubmittedFingerprint) {
|
||||
frameTimings.finishFrame(frameId, "discarded: blocks content unchanged");
|
||||
return;
|
||||
@@ -646,6 +647,7 @@ function renderAndSubmit(window: BlocksWindow, inputFrameId: number): void {
|
||||
frameTimings.finishFrame(frameId, "discarded: no active communicator");
|
||||
return;
|
||||
}
|
||||
const image = frameTimings.span(frameId, "flatten", () => flattenPlanes(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import type { DashboardInputEvent } from "../../ui/layers";
|
||||
@@ -598,11 +599,20 @@ function layoutFor(window: FreecellWindow): Layout {
|
||||
};
|
||||
}
|
||||
|
||||
function paint(window: FreecellWindow): GrayImage {
|
||||
function paint(window: FreecellWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return paintContent(window);
|
||||
const planes = singlePlane(paintContent(window));
|
||||
if (window.phase === "won") {
|
||||
// The win box goes on its own plane: card labels are deferred glyphs that
|
||||
// render above their own image's raster, so an overlay drawn into the
|
||||
// board image could not cover them.
|
||||
const overlay = new GrayImage(window.viewportWidth, window.viewportHeight, 0);
|
||||
paintWinOverlay(overlay, window);
|
||||
planes.push({ image: overlay, x: 0, y: 0 });
|
||||
}
|
||||
return planes;
|
||||
}
|
||||
|
||||
function paintContent(window: FreecellWindow): GrayImage {
|
||||
@@ -635,7 +645,7 @@ function paintContent(window: FreecellWindow): GrayImage {
|
||||
paintCascade(image, window, layout, i);
|
||||
}
|
||||
paintCursor(image, window, layout);
|
||||
if (window.phase === "won") paintWinOverlay(image, window);
|
||||
// The win overlay is painted onto its own plane by paint(), not here.
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -702,7 +712,9 @@ function paintWinOverlay(image: GrayImage, window: FreecellWindow): void {
|
||||
const height = 120;
|
||||
const x = Math.round((window.viewportWidth - width) / 2);
|
||||
const y = Math.round((window.viewportHeight - height) / 2);
|
||||
image.fillRoundedRect(x, y, width, height, 0, 8);
|
||||
// Fill 1, not 0: identical after 4bpp quantization, but 0 is transparent
|
||||
// when this overlay composites as its own plane over the board.
|
||||
image.fillRoundedRect(x, y, width, height, 1, 8);
|
||||
image.drawRoundedRect(x, y, width, height, 200, 8);
|
||||
drawCenteredIn(image, largeFont, x, width, y + 14, "You win!", 255);
|
||||
drawCenteredIn(image, smallFont, x, width, y + 56, `${window.moves} moves`, 170);
|
||||
@@ -726,11 +738,11 @@ function renderAndSubmit(window: FreecellWindow, inputFrameId: number): void {
|
||||
const frameId = inputFrameId > 0 ? inputFrameId : frameTimings.startFrame(`render:${window.windowId}`);
|
||||
try {
|
||||
const paintStartedAtMs = Date.now();
|
||||
const image = frameTimings.span(frameId, "paint", () =>
|
||||
const planes = frameTimings.span(frameId, "paint", () =>
|
||||
frameTimings.runWithFrame(frameId, () => paint(window)),
|
||||
);
|
||||
const paintMs = Date.now() - paintStartedAtMs;
|
||||
const fingerprint = image.fingerprint();
|
||||
const fingerprint = planesFingerprint(planes);
|
||||
if (fingerprint === window.lastSubmittedFingerprint) {
|
||||
frameTimings.finishFrame(frameId, "discarded: freecell content unchanged");
|
||||
return;
|
||||
@@ -740,6 +752,7 @@ function renderAndSubmit(window: FreecellWindow, inputFrameId: number): void {
|
||||
frameTimings.finishFrame(frameId, "discarded: no active communicator");
|
||||
return;
|
||||
}
|
||||
const image = frameTimings.span(frameId, "flatten", () => flattenPlanes(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
|
||||
@@ -37,7 +37,7 @@ const launcherApp: AppDefinition = {
|
||||
],
|
||||
launchApp: (appId) => ctx.launchApp(appId),
|
||||
uninstallApp: (appId) => ctx.uninstallApp(appId),
|
||||
submitFrame: (image, paintMs, frameId) => ctx.submitWindowFrame(LAUNCHER_SURFACE_ID, image, paintMs, frameId),
|
||||
submitFrame: (planes, paintMs, frameId) => ctx.submitWindowFrame(LAUNCHER_SURFACE_ID, planes, paintMs, frameId),
|
||||
setSurfaceVisible: (visible) => ctx.setWindowSurfaceVisible(LAUNCHER_SURFACE_ID, visible),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { getDefaultSmallFont, type BdfFont } from "../../graphics/bdffont";
|
||||
import { truncateText } from "../../graphics/textwrap";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { type Plane } from "../../graphics/plane";
|
||||
import { renderIcon, type IconName } from "../../graphics/icons";
|
||||
import { clamp } from "../../util/numeric-util";
|
||||
import {
|
||||
@@ -37,8 +38,8 @@ export type LauncherOptions = {
|
||||
apps: () => LauncherAppEntry[];
|
||||
launchApp: (appId: string) => Promise<void> | void;
|
||||
uninstallApp: (appId: string) => Promise<void> | void;
|
||||
/** Submit a painted viewport-sized frame to this window's surface. */
|
||||
submitFrame: (image: GrayImage, paintMs: number, frameId: number) => Promise<void>;
|
||||
/** Submit a painted viewport-sized frame (as planes) to this window's surface. */
|
||||
submitFrame: (planes: Plane[], paintMs: number, frameId: number) => Promise<void>;
|
||||
/** Flip the launcher's compositor surface visibility on foreground changes. */
|
||||
setSurfaceVisible: (visible: boolean) => void;
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import type { DashboardInputEvent } from "../../ui/layers";
|
||||
@@ -552,11 +553,11 @@ function elapsedMs(window: MinesweeperWindow): number {
|
||||
return window.elapsedMs + runningMs;
|
||||
}
|
||||
|
||||
function paint(window: MinesweeperWindow): GrayImage {
|
||||
function paint(window: MinesweeperWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return paintContent(window);
|
||||
return singlePlane(paintContent(window));
|
||||
}
|
||||
|
||||
function paintContent(window: MinesweeperWindow): GrayImage {
|
||||
@@ -696,11 +697,11 @@ function renderAndSubmit(window: MinesweeperWindow, inputFrameId: number): void
|
||||
const frameId = inputFrameId > 0 ? inputFrameId : frameTimings.startFrame(`render:${window.windowId}`);
|
||||
try {
|
||||
const paintStartedAtMs = Date.now();
|
||||
const image = frameTimings.span(frameId, "paint", () =>
|
||||
const planes = frameTimings.span(frameId, "paint", () =>
|
||||
frameTimings.runWithFrame(frameId, () => paint(window)),
|
||||
);
|
||||
const paintMs = Date.now() - paintStartedAtMs;
|
||||
const fingerprint = image.fingerprint();
|
||||
const fingerprint = planesFingerprint(planes);
|
||||
if (fingerprint === window.lastSubmittedFingerprint) {
|
||||
frameTimings.finishFrame(frameId, "discarded: minesweeper content unchanged");
|
||||
return;
|
||||
@@ -710,6 +711,7 @@ function renderAndSubmit(window: MinesweeperWindow, inputFrameId: number): void
|
||||
frameTimings.finishFrame(frameId, "discarded: no active communicator");
|
||||
return;
|
||||
}
|
||||
const image = frameTimings.span(frameId, "flatten", () => flattenPlanes(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import type { DashboardInputEvent } from "../../ui/layers";
|
||||
@@ -667,9 +668,9 @@ function handleInput(win: NavWindow, event: DashboardInputEvent, frameId: number
|
||||
// ---------------------------------------------------------------------------
|
||||
// Painting
|
||||
|
||||
function paint(win: NavWindow): GrayImage {
|
||||
function paint(win: NavWindow): Plane[] {
|
||||
if (win.menu?.isOpen()) return win.menu.paint();
|
||||
return paintContent(win);
|
||||
return singlePlane(paintContent(win));
|
||||
}
|
||||
|
||||
function paintContent(win: NavWindow): GrayImage {
|
||||
@@ -858,11 +859,11 @@ function renderAndSubmit(win: NavWindow, inputFrameId: number): void {
|
||||
const frameId = inputFrameId > 0 ? inputFrameId : frameTimings.startFrame(`render:${win.windowId}`);
|
||||
try {
|
||||
const paintStartedAtMs = Date.now();
|
||||
const image = frameTimings.span(frameId, "paint", () =>
|
||||
const planes = frameTimings.span(frameId, "paint", () =>
|
||||
frameTimings.runWithFrame(frameId, () => paint(win)),
|
||||
);
|
||||
const paintMs = Date.now() - paintStartedAtMs;
|
||||
const fingerprint = image.fingerprint();
|
||||
const fingerprint = planesFingerprint(planes);
|
||||
if (fingerprint === win.lastSubmittedFingerprint) {
|
||||
frameTimings.finishFrame(frameId, "discarded: navigate content unchanged");
|
||||
return;
|
||||
@@ -872,6 +873,7 @@ function renderAndSubmit(win: NavWindow, inputFrameId: number): void {
|
||||
frameTimings.finishFrame(frameId, "discarded: no active communicator");
|
||||
return;
|
||||
}
|
||||
const image = frameTimings.span(frameId, "flatten", () => flattenPlanes(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import { getStringSetting, setStringSetting } from "../../native/settings-store";
|
||||
@@ -907,11 +908,11 @@ function drawFlipper(image: GrayImage, flipper: Flipper): void {
|
||||
}
|
||||
}
|
||||
|
||||
function paint(window: PinballWindow): GrayImage {
|
||||
function paint(window: PinballWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return paintContent(window);
|
||||
return singlePlane(paintContent(window));
|
||||
}
|
||||
|
||||
function paintContent(window: PinballWindow): GrayImage {
|
||||
@@ -1025,11 +1026,11 @@ function renderAndSubmit(window: PinballWindow, inputFrameId: number): void {
|
||||
const frameId = inputFrameId > 0 ? inputFrameId : frameTimings.startFrame(`render:${window.windowId}`);
|
||||
try {
|
||||
const paintStartedAtMs = Date.now();
|
||||
const image = frameTimings.span(frameId, "paint", () =>
|
||||
const planes = frameTimings.span(frameId, "paint", () =>
|
||||
frameTimings.runWithFrame(frameId, () => paint(window)),
|
||||
);
|
||||
const paintMs = Date.now() - paintStartedAtMs;
|
||||
const fingerprint = image.fingerprint();
|
||||
const fingerprint = planesFingerprint(planes);
|
||||
if (fingerprint === window.lastSubmittedFingerprint) {
|
||||
frameTimings.finishFrame(frameId, "discarded: pinball content unchanged");
|
||||
return;
|
||||
@@ -1039,6 +1040,7 @@ function renderAndSubmit(window: PinballWindow, inputFrameId: number): void {
|
||||
frameTimings.finishFrame(frameId, "discarded: no active communicator");
|
||||
return;
|
||||
}
|
||||
const image = frameTimings.span(frameId, "flatten", () => flattenPlanes(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { getDefaultSmallFont } from "../../graphics/bdffont";
|
||||
import { truncateText, wrapText } from "../../graphics/textwrap";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
@@ -513,9 +514,9 @@ async function handleRoamTool(name: string, args: any): Promise<ToolResult> {
|
||||
// ---------------------------------------------------------------------------
|
||||
// Painting
|
||||
|
||||
function paint(win: RoamWindow): GrayImage {
|
||||
function paint(win: RoamWindow): Plane[] {
|
||||
if (win.menu?.isOpen()) return win.menu.paint();
|
||||
return paintContent(win);
|
||||
return singlePlane(paintContent(win));
|
||||
}
|
||||
|
||||
function paintContent(win: RoamWindow): GrayImage {
|
||||
@@ -578,11 +579,11 @@ function renderAndSubmit(win: RoamWindow, inputFrameId: number): void {
|
||||
const frameId = inputFrameId > 0 ? inputFrameId : frameTimings.startFrame(`render:${win.windowId}`);
|
||||
try {
|
||||
const paintStartedAtMs = Date.now();
|
||||
const image = frameTimings.span(frameId, "paint", () =>
|
||||
const planes = frameTimings.span(frameId, "paint", () =>
|
||||
frameTimings.runWithFrame(frameId, () => paint(win)),
|
||||
);
|
||||
const paintMs = Date.now() - paintStartedAtMs;
|
||||
const fingerprint = image.fingerprint();
|
||||
const fingerprint = planesFingerprint(planes);
|
||||
if (fingerprint === win.lastSubmittedFingerprint) {
|
||||
frameTimings.finishFrame(frameId, "discarded: roam content unchanged");
|
||||
return;
|
||||
@@ -592,6 +593,7 @@ function renderAndSubmit(win: RoamWindow, inputFrameId: number): void {
|
||||
frameTimings.finishFrame(frameId, "discarded: no active communicator");
|
||||
return;
|
||||
}
|
||||
const image = frameTimings.span(frameId, "flatten", () => flattenPlanes(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { type Plane } from "../../graphics/plane";
|
||||
import { LayerActions } from "../../ui/layers";
|
||||
import { EditTextSettingLayer } from "../../ui/dashboard-settings";
|
||||
import { createSettingsPanelLayer } from "../../ui/dashboard/settings-menus";
|
||||
@@ -10,7 +10,7 @@ export const SETTINGS_SURFACE_ID = "window:settings";
|
||||
|
||||
export type SettingsAppOptions = {
|
||||
actions: LayerActions;
|
||||
submitFrame: (image: GrayImage, paintMs: number, frameId: number) => Promise<void>;
|
||||
submitFrame: (planes: Plane[], paintMs: number, frameId: number) => Promise<void>;
|
||||
setSurfaceVisible: (visible: boolean) => void;
|
||||
removeSurface: () => void;
|
||||
onClosed: () => void;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { getFont } from "../../graphics/bdffont";
|
||||
import { TERMINAL_ICON_GLYPHS } from "../../graphics/icons";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
@@ -1367,11 +1368,11 @@ async function launchAndOpenView(control: ControlConnection, preset: string): Pr
|
||||
return socket;
|
||||
}
|
||||
|
||||
function paint(window: TerminalWindow): GrayImage {
|
||||
function paint(window: TerminalWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return paintContent(window);
|
||||
return singlePlane(paintContent(window));
|
||||
}
|
||||
|
||||
function paintContent(window: TerminalWindow): GrayImage {
|
||||
@@ -1486,7 +1487,17 @@ function paintView(window: ViewWindow): GrayImage {
|
||||
image.fillRect(window.emulator.cursorCol() * CELL_WIDTH, cursorScreenRow * CELL_HEIGHT, CELL_WIDTH, CELL_HEIGHT, 70);
|
||||
}
|
||||
|
||||
// Stale content stays visible across a disconnect, so flag it: a status
|
||||
// line over the bottom row whenever the session isn't actually attached.
|
||||
// Text is deferred glyphs (always on top of raster), so the covered rows
|
||||
// must be suppressed rather than painted over.
|
||||
const statusBannerY = window.client.state().phase !== "attached"
|
||||
? window.viewportHeight - CELL_HEIGHT
|
||||
: null;
|
||||
|
||||
for (let row = 0; row < rows; row++) {
|
||||
const rowY = row * CELL_HEIGHT;
|
||||
if (statusBannerY !== null && rowY + CELL_HEIGHT > statusBannerY) continue;
|
||||
const absolute = top + row;
|
||||
let text = "";
|
||||
if (absolute >= historyNext) {
|
||||
@@ -1495,18 +1506,15 @@ function paintView(window: ViewWindow): GrayImage {
|
||||
} else if (absolute >= window.archiveStart) {
|
||||
text = window.archive[absolute - window.archiveStart] ?? "";
|
||||
}
|
||||
if (text.length) image.drawText(terminalFont, 0, row * CELL_HEIGHT, text, 200);
|
||||
if (text.length) image.drawText(terminalFont, 0, rowY, text, 200);
|
||||
}
|
||||
|
||||
if (!following) {
|
||||
drawScrollIndicator(image, top, window.archiveStart, bottomTop);
|
||||
}
|
||||
// Stale content stays visible across a disconnect, so flag it: a status
|
||||
// line over the bottom row whenever the session isn't actually attached.
|
||||
if (window.client.state().phase !== "attached") {
|
||||
const y = window.viewportHeight - CELL_HEIGHT;
|
||||
image.fillRect(0, y, window.viewportWidth, CELL_HEIGHT, 0);
|
||||
image.drawText(terminalFont, 0, y, window.status, 170);
|
||||
if (statusBannerY !== null) {
|
||||
image.fillRect(0, statusBannerY, window.viewportWidth, CELL_HEIGHT, 0);
|
||||
image.drawText(terminalFont, 0, statusBannerY, window.status, 170);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
@@ -1539,11 +1547,11 @@ function renderAndSubmit(window: TerminalWindow, inputFrameId: number): void {
|
||||
const frameId = inputFrameId > 0 ? inputFrameId : frameTimings.startFrame(`render:${window.windowId}`);
|
||||
try {
|
||||
const paintStartedAtMs = Date.now();
|
||||
const image = frameTimings.span(frameId, "paint", () =>
|
||||
const planes = frameTimings.span(frameId, "paint", () =>
|
||||
frameTimings.runWithFrame(frameId, () => paint(window)),
|
||||
);
|
||||
const paintMs = Date.now() - paintStartedAtMs;
|
||||
const fingerprint = image.fingerprint();
|
||||
const fingerprint = planesFingerprint(planes);
|
||||
if (fingerprint === window.lastSubmittedFingerprint) {
|
||||
frameTimings.finishFrame(frameId, "discarded: terminal content unchanged");
|
||||
return;
|
||||
@@ -1553,6 +1561,7 @@ function renderAndSubmit(window: TerminalWindow, inputFrameId: number): void {
|
||||
frameTimings.finishFrame(frameId, "discarded: no active communicator");
|
||||
return;
|
||||
}
|
||||
const image = frameTimings.span(frameId, "flatten", () => flattenPlanes(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import {
|
||||
@@ -498,11 +499,11 @@ function updateRenderTimer(window: TimerWindow): void {
|
||||
}
|
||||
}
|
||||
|
||||
function paint(window: TimerWindow): GrayImage {
|
||||
function paint(window: TimerWindow): Plane[] {
|
||||
if (window.menu?.isOpen()) {
|
||||
return window.menu.paint();
|
||||
}
|
||||
return paintContent(window);
|
||||
return singlePlane(paintContent(window));
|
||||
}
|
||||
|
||||
function paintContent(window: TimerWindow): GrayImage {
|
||||
@@ -645,11 +646,11 @@ function renderAndSubmit(window: TimerWindow, inputFrameId: number): void {
|
||||
const frameId = inputFrameId > 0 ? inputFrameId : frameTimings.startFrame(`render:${window.windowId}`);
|
||||
try {
|
||||
const paintStartedAtMs = Date.now();
|
||||
const image = frameTimings.span(frameId, "paint", () =>
|
||||
const planes = frameTimings.span(frameId, "paint", () =>
|
||||
frameTimings.runWithFrame(frameId, () => paint(window)),
|
||||
);
|
||||
const paintMs = Date.now() - paintStartedAtMs;
|
||||
const fingerprint = image.fingerprint();
|
||||
const fingerprint = planesFingerprint(planes);
|
||||
if (fingerprint === window.lastSubmittedFingerprint) {
|
||||
frameTimings.finishFrame(frameId, "discarded: timer content unchanged");
|
||||
return;
|
||||
@@ -659,6 +660,7 @@ function renderAndSubmit(window: TimerWindow, inputFrameId: number): void {
|
||||
frameTimings.finishFrame(frameId, "discarded: no active communicator");
|
||||
return;
|
||||
}
|
||||
const image = frameTimings.span(frameId, "flatten", () => flattenPlanes(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
|
||||
Reference in new issue
Block a user