forked from Blendman974/faceclaw
Depth effects
This commit is contained in:
1 parent
4320021222
commit
392554dd37
26 files changed
+623
-136
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { encodePresentation } from "./presentation-wire";
|
||||
/**
|
||||
* Marshals deferred-draw identity (text glyphs and icon images) to the Kotlin
|
||||
* side for the texture-cache pipeline (CFW modes 18/19/20; see
|
||||
@@ -84,6 +85,7 @@ const fwRegistered = new Set<string>();
|
||||
* unseen ink members' rasters with the Kotlin FwGlyphAtlas as a side effect.
|
||||
*/
|
||||
function prepareFwTextRun(placed: PlacedFwText): boolean {
|
||||
if (!textureAtlasAvailable()) return false;
|
||||
if (!inRange16(placed.x) || !inRange16(placed.y)) return false;
|
||||
if (placed.glyphs.length === 0 || placed.glyphs.length > 255) return false;
|
||||
let registration: Array<{ cp: number; data: NonNullable<ReturnType<PlacedFwText["font"]["fwGlyphWireData"]>> }> | null = null;
|
||||
@@ -152,7 +154,7 @@ function inRange16(v: number): boolean {
|
||||
* in draw order. Returns null when nothing is expressible (or without a native atlas).
|
||||
*/
|
||||
export function prepareFrameDraws(draws: readonly DeferredDraw[]): ArrayBuffer | null {
|
||||
if (!textureAtlasAvailable() || draws.length === 0) return null;
|
||||
if (draws.length === 0) return null;
|
||||
|
||||
// Pass 1: resolve ids, register unseen rasters, size the buffer.
|
||||
let registration: Map<FontWireState, RegistrationGroup> | null = null;
|
||||
@@ -175,7 +177,8 @@ export function prepareFrameDraws(draws: readonly DeferredDraw[]): ArrayBuffer |
|
||||
(placed.glyph.coverage ? group.aaGlyphs : group.glyphs).push(placed.glyph);
|
||||
} else if (placed.kind === "image") {
|
||||
if (!inRange16(placed.x) || !inRange16(placed.y)) continue;
|
||||
if (imageId(placed) !== null) bytes += IMAGE_RECORD_BYTES;
|
||||
if (placed.presentation) bytes += encodePresentation(placed).length;
|
||||
else if (imageId(placed) !== null) bytes += IMAGE_RECORD_BYTES;
|
||||
} else {
|
||||
const ok = prepareFwTextRun(placed);
|
||||
fwRunOk.set(placed, ok);
|
||||
@@ -207,6 +210,7 @@ export function prepareFrameDraws(draws: readonly DeferredDraw[]): ArrayBuffer |
|
||||
offset += GLYPH_RECORD_BYTES;
|
||||
} else if (placed.kind === "image") {
|
||||
if (!inRange16(placed.x) || !inRange16(placed.y)) continue;
|
||||
if (placed.presentation) { const bytes = encodePresentation(placed); new Uint8Array(out.buffer).set(bytes, offset); offset += bytes.length; continue; }
|
||||
const id = imageId(placed);
|
||||
if (id === null) continue;
|
||||
out.setUint8(offset, 1);
|
||||
|
||||
Reference in new issue
Block a user