Refactor Java to shared kotlin

This commit is contained in:
James Babcock committed 2026-09-18 22:48:20 -07:00
1 parent bc8e80c533
commit 68810197a8
173 files changed
+9855 -6252

No files matched your search

+4 -4
View File
@@ -116,7 +116,7 @@ function prepareFwTextRun(placed: PlacedFwText): boolean {
bytes.set(entry.data.nibbles, offset + 10);
offset += 10 + entry.data.nibbles.length;
}
com.faceclaw.app.FwGlyphAtlas.register(buffer);
com.faceclaw.app.FwGlyphAtlas.register(new com.faceclaw.app.AndroidByteReader(buffer));
}
return true;
}
@@ -130,7 +130,7 @@ function imageId(placed: PlacedImage): number | null {
let id: number | null = null;
if (source.width > 0 && source.width <= 255 && source.height > 0 && source.height <= 255) {
const key = `img:${source.width}x${source.height}:${source.contentHash32().toString(16)}`;
id = com.faceclaw.app.ImageAtlas.ensure(key, source.width, source.height, source.pixels.buffer);
id = com.faceclaw.app.ImageAtlas.ensure(key, source.width, source.height, new com.faceclaw.app.AndroidByteReader(source.pixels.buffer));
if (!(typeof id === "number") || id <= 0) id = null;
}
imageIds.set(source, id);
@@ -184,9 +184,9 @@ export function prepareFrameDraws(draws: readonly DeferredDraw[]): ArrayBuffer |
}
if (registration) {
const plainBuffer = buildRegistrationBuffer(registration);
if (plainBuffer) com.faceclaw.app.GlyphAtlas.register(plainBuffer);
if (plainBuffer) com.faceclaw.app.GlyphAtlas.register(new com.faceclaw.app.AndroidByteReader(plainBuffer));
const aaBuffer = buildAaRegistrationBuffer(registration);
if (aaBuffer) com.faceclaw.app.GlyphAtlas.registerAa(aaBuffer);
if (aaBuffer) com.faceclaw.app.GlyphAtlas.registerAa(new com.faceclaw.app.AndroidByteReader(aaBuffer));
}
if (bytes === 0) return null;
+30
View File
@@ -0,0 +1,30 @@
import { fromData, toData } from '../native/kotlin-data'
import type { SurfaceConfiguration, SurfaceRect } from './surface-compositor'
export type { SurfaceConfiguration, SurfaceRect } from './surface-compositor'
declare const FaceclawKitIosSurfaceCompositor: any
/** Retained pixels, clipping, layers and composition live in shared Kotlin. */
export class SurfaceCompositor {
private native: any
constructor(readonly width: number, readonly height: number) {
if (!Number.isInteger(width) || !Number.isInteger(height) || width <= 0 || height <= 0) throw new Error('Invalid compositor size')
this.native = FaceclawKitIosSurfaceCompositor.alloc().initWithWidthHeight(width, height)
}
configureSurface(id: string, options: SurfaceConfiguration): void {
if (![options.x, options.y, options.width, options.height, options.zOrder].every(Number.isInteger)
|| options.width <= 0 || options.height <= 0) throw new Error('Invalid surface geometry')
this.native.configureIdXYWidthHeightZOrderTransparent(id, options.x, options.y, options.width, options.height, options.zOrder, options.transparency === 'color-key')
}
removeSurface(id: string): void { this.native.removeId(id) }
setSurfaceVisible(id: string, visible: boolean): void { this.native.visibleIdVisible(id, visible) }
setUnderlayDim(belowZOrder: number, factor: number): void {
if (!Number.isFinite(factor)) throw new Error('Invalid dim factor')
this.native.dimBelowFactor(belowZOrder, factor)
}
setScreenBlanked(blanked: boolean): void { this.native.blankBlanked(blanked) }
submitSurfaceFrame(id: string, pixels: Uint8Array, rect: SurfaceRect): void {
if (![rect.x, rect.y, rect.width, rect.height].every(Number.isInteger)
|| rect.width <= 0 || rect.height <= 0 || pixels.length !== rect.width * rect.height) throw new Error('Invalid frame buffer or rectangle')
this.native.submitIdDataXYWidthHeight(id, toData(pixels), rect.x, rect.y, rect.width, rect.height)
}
composite(): Uint8Array { return fromData(this.native.composite()) }
}