import { type PreparedRenderTimelineContext } from "#render-preparation/prepared-render-window"; import { IdMaskTextureFormat, type PreparedIdMaskFrame, type PreparedRegionMaskCoverageEntry, type PreparedRegionMaskCoverageFrame } from "#render-preparation/mask-frame-artifact"; import type { BufferedDetectionTimeline } from "supervision-js-core"; import type { DetectionPickOptions, DetectionPickPoint, DetectionPickResult } from "supervision-js-core"; import type { MaskHaloStyle, MaskStyle } from "supervision-js-core"; import { RenderPreparationArtifactKind } from "#types/render-preparation"; import type { RenderPreparationMaskFrameOptions, RenderPreparationOptions, ResolvedRenderPreparationGateThresholds } from "#types/render-preparation"; import type { InjectedMeshConstructor, InjectedMeshGeometryConstructor, InjectedShaderFactory } from "#renderers/injected-pixi"; import type { PresentedFrameId } from "./presented-frame-channel"; import type { SerializableMaskInstruction } from "#render-preparation/mask-preparation-worker-protocol"; import type { BufferImageSource as PixiBufferImageSource, Container as PixiContainer, Graphics as PixiGraphics, ImageSource as PixiImageSource, Mesh as PixiMesh, Sprite as PixiSprite, Texture as PixiTexture, UniformGroup as PixiUniformGroup } from "pixi.js"; type ImageSourceConstructor = new (options: { autoGenerateMipmaps?: boolean; dynamic: boolean; height: number; resource: HTMLCanvasElement | ImageBitmap; scaleMode?: "linear" | "nearest"; width: number; }) => PixiImageSource; export type BufferImageSourceConstructor = new (options: { autoGenerateMipmaps?: boolean; dynamic: boolean; format: IdMaskTextureFormat; height: number; resource: Uint8Array; scaleMode?: "linear" | "nearest"; width: number; }) => PixiBufferImageSource; type TextureConstructor = new (options: { dynamic: boolean; source: PixiImageSource | PixiBufferImageSource; }) => PixiTexture; type TextureConstructorWithEmpty = TextureConstructor & { readonly EMPTY: PixiTexture; }; type SpriteConstructor = new (options?: { texture?: PixiTexture; }) => PixiSprite; type ContainerConstructor = new () => PixiContainer; type UniformGroupConstructor = new (uniforms: Record" | "vec4"; value: Float32Array; }>) => PixiUniformGroup; /** * Whether the frame on screen can answer for detection ids. Hover, selection * and focus highlighting all cut their shapes out of the id raster, so a frame * that reaches the screen without one draws its whole picture while those three * have nothing to cut from. */ export declare enum PixiMaskLayerIdMaskStatus { /** A mask frame is on screen and carries no id raster. */ Absent = "absent", /** No mask frame is on screen. */ None = "none", /** The id raster is on screen. */ Present = "present" } /** * What the mask layer has on screen after its last draw. * * `drawnFrameTime` is the detection frame the visible raster belongs to, and it * is the frame the rest of the present drew or the layer draws nothing. * `drawnFrameId` names the producer frame that raster was accepted for, and is * null on a draw the producer did not drive: a pull-path sample and a redraw at * a resting playhead both carry a media time and no frame identity. */ export interface PixiMaskLayerState { readonly drawnFrameTime: number | null; readonly drawnFrameKey: string | null; readonly drawnFrameId: PresentedFrameId | null; readonly idMaskStatus: PixiMaskLayerIdMaskStatus; } export interface PixiMaskLayer { createSprite(dimensions: { width: number; height: number; }): PixiContainer | PixiSprite; drawFrame(mediaTime: number, presentedFrameId?: PresentedFrameId | null, viewportScale?: number): void; redrawViewportStyles(viewportScale: number): void; /** The state the last drawFrame or clearFrame left on screen. */ getDrawnState(): PixiMaskLayerState; /** Puts the media time in front of the cook without drawing it. */ prepareFrame(mediaTime: number): void; clearFrame(): void; isArtifactPrepared(mediaTime: number): boolean; getArtifactRevision(mediaTime: number): number; /** Frames this layer's preparation has finished, counted up over its life. */ getPreparationProgress(): number; /** Whether `waitForRenderPreparation` would wait, scheduling nothing. */ needsRenderPreparationWait(mediaTime: number, options: ResolvedRenderPreparationGateThresholds): boolean; waitForRenderPreparation(mediaTime: number, options: ResolvedRenderPreparationGateThresholds, signal?: AbortSignal): Promise; pickDetectionAtPoint(point: DetectionPickPoint, mediaTime: number, options?: DetectionPickOptions): DetectionPickResult | null; /** * The raster on screen, for a caller drawing the same detection frame it * belongs to. Both of these are read by layers that pair the raster to * detections by position, so a raster from any other frame pairs one frame's * silhouettes to another frame's detections. */ getActiveIdMaskFrameTexture(detectionFrameTime: number | null): PixiActiveIdMaskFrameTexture | null; getActiveRegionMaskCoverage(detectionFrameTime: number | null): PixiActiveRegionMaskCoverage | null; setPlaybackActive(active: boolean): void; setTimelineContext(context: PreparedRenderTimelineContext): void; setRasterDisplay(display: IdMaskDisplayBox, resolutionScale?: number): void; setViewportScale(scale: number): void; setMaskStyle(maskStyle: MaskStyle | null | undefined): void; setMaskHaloStyle(maskHaloStyle: MaskHaloStyle | null | undefined): void; /** * Whether the mask fill reaches the screen. Preparation runs either way, so * consumers of the id raster still get an artifact while the fill is off. */ setFillVisible(visible: boolean): void; destroy(): void; } /** * Cook-only style for consumers that read detection ids out of the raster * instead of drawing the fill. Ids come from the detection index, so the colour * and alpha here never reach the screen. */ export declare const ID_MASK_PREPARATION_STYLE: MaskStyle; export type IdMaskDisplayBox = NonNullable; export interface PixiActiveIdMaskFrameTexture { readonly frame: PreparedIdMaskFrame; readonly texture: PixiTexture; } export interface PixiActiveRegionMaskCoverage { readonly frame: PreparedRegionMaskCoverageFrame; getTexture(entry: PreparedRegionMaskCoverageEntry): PixiTexture | undefined; } export declare function createPixiMaskLayer(options: { readonly artifactKind?: RenderPreparationArtifactKind; readonly orderedContainer?: PixiContainer; readonly BufferImageSource?: BufferImageSourceConstructor; readonly Container?: ContainerConstructor; readonly Graphics?: new () => PixiGraphics; readonly ImageSource: ImageSourceConstructor; readonly Mesh?: InjectedMeshConstructor; readonly MeshGeometry?: InjectedMeshGeometryConstructor; readonly Shader?: InjectedShaderFactory; readonly Sprite: SpriteConstructor; readonly Texture: TextureConstructorWithEmpty; readonly UniformGroup?: UniformGroupConstructor; readonly Rectangle?: new (x: number, y: number, width: number, height: number) => unknown; readonly BlurFilter?: new (options: { strength: number; quality?: number; }) => { strength: number; }; readonly detectionTimeline: BufferedDetectionTimeline; readonly maskHaloStyle?: MaskHaloStyle | null; readonly maskStyle: MaskStyle; readonly onPreparedWindowChange?: () => void; /** Detaches other layers borrowing a mask texture before its owner releases it. */ readonly onTextureEvicted?: (texture: PixiTexture) => void; /** * Whether the renderer takes a single-channel upload whose rows are not on a * four-byte boundary. Answered when the first raster is uploaded, since the * renderer this scene ends up with is not known when the layer is built. */ readonly acceptsUnalignedTextureRows?: () => boolean; readonly renderPreparation?: RenderPreparationOptions; readonly resolveInstructions?: (options: { readonly frame: import("supervision-js-core").DetectionFrame; readonly maskStyle: MaskStyle; readonly mediaTime: number; }) => readonly SerializableMaskInstruction[]; }): PixiMaskLayer; export {}; //# sourceMappingURL=pixi-mask-layer.d.ts.map