/** * @copyright * Copyright 2026 Steven Roussey * All Rights Reserved */ import type { ImageChannels } from "./imageTypes"; import type { ImageValue } from "./imageValue"; export type GpuImageBackend = "webgpu" | "sharp" | "cpu"; export type GpuImageEncodeFormat = "png" | "jpeg" | "webp"; /** * `GpuImage` is a private implementation detail of image tasks: it never * crosses a task/engine/worker boundary. Lives only inside an * `ImageFilterTask.execute` method body. Cross-boundary currency is * `ImageValue`. Use `GpuImage.from(value)` at task entry and * `imageValueFromGpu(out, scale)` (or `transferToImageBitmap()` / * `toBuffer()` directly) at task exit. */ export interface GpuImage { readonly width: number; readonly height: number; readonly channels: ImageChannels; readonly backend: GpuImageBackend; /** Materialize back into a wire-form `ImageValue`. Always returns a fresh * ImageValue; the caller is the new owner. */ toImageValue(previewScale: number): Promise; /** Encode to a compressed image format (png/jpeg/webp). Implementations MAY * consume the underlying resource — treat as single-use. */ encode(format: GpuImageEncodeFormat, quality?: number): Promise; /** Early cleanup on error paths only. Required because GPU/native resources * are not held by GC. The happy path uses `toImageValue()` which transfers * ownership; this is the abort/error case. */ dispose(): void; } export interface GpuImageStatic { /** Bridge from the cross-boundary `ImageValue` to a backend-private GpuImage. */ from(value: ImageValue): Promise; } export declare function registerGpuImageFactory(key: K, fn: GpuImageStatic[K]): void; export declare function getGpuImageFactory(key: K): GpuImageStatic[K] | undefined; export declare const GpuImage: GpuImageStatic; //# sourceMappingURL=gpuImage.d.ts.map