forked from Blendman974/faceclaw
Use the texture cache to avoid resending icons and font glyphs
This commit is contained in:
1 parent
221dbb77ea
commit
83e0fa919f
26 files changed
+1724
-113
No files matched your search
@@ -9,7 +9,8 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import type { DashboardInputEvent } from "../../ui/layers";
|
||||
@@ -647,7 +648,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 { image, draws } = frameTimings.span(frameId, "flatten", () => flattenPlanesWithDraws(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
@@ -659,6 +660,7 @@ function renderAndSubmit(window: BlocksWindow, inputFrameId: number): void {
|
||||
fingerprint,
|
||||
paintMs,
|
||||
frameId,
|
||||
prepareFrameDraws(draws),
|
||||
);
|
||||
window.lastSubmittedFingerprint = fingerprint;
|
||||
} catch (error) {
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import type { DashboardInputEvent } from "../../ui/layers";
|
||||
@@ -752,7 +753,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 { image, draws } = frameTimings.span(frameId, "flatten", () => flattenPlanesWithDraws(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
@@ -764,6 +765,7 @@ function renderAndSubmit(window: FreecellWindow, inputFrameId: number): void {
|
||||
fingerprint,
|
||||
paintMs,
|
||||
frameId,
|
||||
prepareFrameDraws(draws),
|
||||
);
|
||||
window.lastSubmittedFingerprint = fingerprint;
|
||||
} catch (error) {
|
||||
|
||||
@@ -287,11 +287,17 @@ class LauncherGridLayer implements Layer {
|
||||
: renderIcon("folder-filled", ICON_SIZE);
|
||||
if (icon) {
|
||||
// Clip the icon at the grid bottom so a peeking row shows only its top.
|
||||
// A fully visible icon goes through the deferred-image path (texture
|
||||
// cacheable); the clipped peeking row falls back to a raster blit,
|
||||
// since cached draws are whole-image only.
|
||||
const clipHeight = Math.min(icon.height, Math.floor(gridBottom - blockTop));
|
||||
image.bitBlt(icon, Math.round(centerX - icon.width / 2), Math.round(blockTop), {
|
||||
height: clipHeight,
|
||||
transparentZero: true,
|
||||
});
|
||||
const iconX = Math.round(centerX - icon.width / 2);
|
||||
const iconY = Math.round(blockTop);
|
||||
if (clipHeight >= icon.height) {
|
||||
image.drawImage(icon, iconX, iconY);
|
||||
} else {
|
||||
image.bitBlt(icon, iconX, iconY, { height: clipHeight, transparentZero: true });
|
||||
}
|
||||
}
|
||||
const labelY = Math.round(blockTop + ICON_SIZE + LABEL_GAP);
|
||||
if (labelY + font.lineHeight <= gridBottom) {
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import type { DashboardInputEvent } from "../../ui/layers";
|
||||
@@ -711,7 +712,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 { image, draws } = frameTimings.span(frameId, "flatten", () => flattenPlanesWithDraws(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
@@ -723,6 +724,7 @@ function renderAndSubmit(window: MinesweeperWindow, inputFrameId: number): void
|
||||
fingerprint,
|
||||
paintMs,
|
||||
frameId,
|
||||
prepareFrameDraws(draws),
|
||||
);
|
||||
window.lastSubmittedFingerprint = fingerprint;
|
||||
} catch (error) {
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import type { DashboardInputEvent } from "../../ui/layers";
|
||||
@@ -873,7 +874,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 { image, draws } = frameTimings.span(frameId, "flatten", () => flattenPlanesWithDraws(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
@@ -885,6 +886,7 @@ function renderAndSubmit(win: NavWindow, inputFrameId: number): void {
|
||||
fingerprint,
|
||||
paintMs,
|
||||
frameId,
|
||||
prepareFrameDraws(draws),
|
||||
);
|
||||
win.lastSubmittedFingerprint = fingerprint;
|
||||
} catch (error) {
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import { getStringSetting, setStringSetting } from "../../native/settings-store";
|
||||
@@ -1040,7 +1041,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 { image, draws } = frameTimings.span(frameId, "flatten", () => flattenPlanesWithDraws(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
@@ -1052,6 +1053,7 @@ function renderAndSubmit(window: PinballWindow, inputFrameId: number): void {
|
||||
fingerprint,
|
||||
paintMs,
|
||||
frameId,
|
||||
prepareFrameDraws(draws),
|
||||
);
|
||||
window.lastSubmittedFingerprint = fingerprint;
|
||||
} catch (error) {
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getDefaultSmallFont } from "../../graphics/bdffont";
|
||||
import { truncateText, wrapText } from "../../graphics/textwrap";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
@@ -593,7 +594,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 { image, draws } = frameTimings.span(frameId, "flatten", () => flattenPlanesWithDraws(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
@@ -605,6 +606,7 @@ function renderAndSubmit(win: RoamWindow, inputFrameId: number): void {
|
||||
fingerprint,
|
||||
paintMs,
|
||||
frameId,
|
||||
prepareFrameDraws(draws),
|
||||
);
|
||||
win.lastSubmittedFingerprint = fingerprint;
|
||||
} catch (error) {
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getFont } from "../../graphics/bdffont";
|
||||
import { TERMINAL_ICON_GLYPHS } from "../../graphics/icons";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
@@ -1561,7 +1562,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 { image, draws } = frameTimings.span(frameId, "flatten", () => flattenPlanesWithDraws(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
@@ -1573,6 +1574,7 @@ function renderAndSubmit(window: TerminalWindow, inputFrameId: number): void {
|
||||
fingerprint,
|
||||
paintMs,
|
||||
frameId,
|
||||
prepareFrameDraws(draws),
|
||||
);
|
||||
window.lastSubmittedFingerprint = fingerprint;
|
||||
} catch (error) {
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
*/
|
||||
import "@nativescript/core/globals";
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { flattenPlanes, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, singlePlane, type Plane } from "../../graphics/plane";
|
||||
import { prepareFrameDraws } from "../../graphics/glyph-wire";
|
||||
import { getDefaultSmallFont, getFont } from "../../graphics/bdffont";
|
||||
import * as frameTimings from "../../native/frame-timings";
|
||||
import {
|
||||
@@ -660,7 +661,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 { image, draws } = frameTimings.span(frameId, "flatten", () => flattenPlanesWithDraws(planes));
|
||||
const buffer = image.to8bppBuffer();
|
||||
communicator.submitSurfaceFrame(
|
||||
buffer.buffer,
|
||||
@@ -672,6 +673,7 @@ function renderAndSubmit(window: TimerWindow, inputFrameId: number): void {
|
||||
fingerprint,
|
||||
paintMs,
|
||||
frameId,
|
||||
prepareFrameDraws(draws),
|
||||
);
|
||||
window.lastSubmittedFingerprint = fingerprint;
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user