/**
 * HDR Compositor — pixel-level compositing primitives for the HDR
 * layered render path.
 *
 * Extracted from `renderOrchestrator.ts` so the ~600 LOC of HDR-specific
 * buffer manipulation, video/image blit logic, and per-frame compositor
 * live in a focused module that can be tested and evolved independently.
 *
 * Consumers: `captureHdrStage.ts`, `captureHdrSequentialLoop.ts`,
 * `captureHdrHybridLoop.ts`, `captureHdrFrameShared.ts`,
 * `captureHdrResources.ts`.
 */
import { type CaptureSession, type BeforeCaptureHook, type HdrTransfer, type ElementStackingInfo, type HfTransitionMeta } from "@hyperframes/engine";
import type { ProducerLogger } from "../logger.js";
import { type HdrImageTransferCache } from "./hdrImageTransferCache.js";
import { type HdrPerfCollector } from "./render/hdrPerf.js";
/**
 * Metadata for a shader transition between two scenes, extracted from
 * `window.__hf.transitions`. Re-exported from the engine so the producer
 * shares the contract with composition runtime code.
 */
export type HdrTransitionMeta = HfTransitionMeta;
/** Pre-computed frame range for an active transition. */
export interface TransitionRange extends HdrTransitionMeta {
    startFrame: number;
    endFrame: number;
}
/**
 * Blit a single HDR video layer onto an rgb48le canvas.
 *
 * Shared between the normal-frame compositing path (compositeToBuffer)
 * and the transition dual-scene compositing loop to avoid duplicating
 * the frame lookup, raw read, transfer, transform, and blit logic.
 */
export interface HdrVideoFrameSource {
    dir: string;
    rawPath: string;
    fd: number;
    width: number;
    height: number;
    frameSize: number;
    frameCount: number;
    scratch: Buffer;
}
export declare function closeHdrVideoFrameSource(source: HdrVideoFrameSource, log?: ProducerLogger): void;
export declare function blitHdrVideoLayer(canvas: Buffer, el: ElementStackingInfo, time: number, fps: number, hdrVideoFrameSources: Map<string, HdrVideoFrameSource>, hdrStartTimes: Map<string, number>, width: number, height: number, log?: ProducerLogger, sourceTransfer?: HdrTransfer, targetTransfer?: HdrTransfer, hdrPerf?: HdrPerfCollector): void;
/**
 * Pre-decoded HDR image buffer with its native pixel dimensions.
 *
 * Static images decode exactly once at setup time and are blitted on every
 * visible frame, unlike video frames which are read fresh per timestamp.
 */
export interface HdrImageBuffer {
    data: Buffer;
    width: number;
    height: number;
}
/**
 * Blit a single HDR image layer onto an rgb48le canvas.
 *
 * Image-equivalent of `blitHdrVideoLayer` — the buffer is pre-decoded and
 * static, so there's no time-based frame lookup or per-frame PNG read.
 */
export declare function blitHdrImageLayer(canvas: Buffer, el: ElementStackingInfo, hdrImageBuffers: Map<string, HdrImageBuffer>, hdrImageTransferCache: HdrImageTransferCache, width: number, height: number, log?: ProducerLogger, sourceTransfer?: HdrTransfer, targetTransfer?: HdrTransfer, hdrPerf?: HdrPerfCollector): void;
/**
 * Dependencies passed to `compositeHdrFrame`.
 *
 * Every field except the per-frame arguments is captured once when the HDR
 * render path opens its `try { ... }` block and reused across every frame —
 * extracting them into an explicit struct lets the helper live at module
 * scope (no closure-over-renderJob) and keeps the per-call signature small.
 */
export type CompositeTransfer = HdrTransfer | "srgb";
export declare function shouldUseLayeredComposite(options: {
    hasHdrContent: boolean;
    hasShaderTransitions: boolean;
    isPngSequence: boolean;
}): boolean;
export declare function resolveCompositeTransfer(hasHdrContent: boolean, effectiveHdr: {
    transfer: HdrTransfer;
} | undefined): CompositeTransfer;
export interface HdrCompositeContext {
    log: ProducerLogger;
    domSession: CaptureSession;
    beforeCaptureHook: BeforeCaptureHook | null;
    width: number;
    height: number;
    fps: number;
    compositeTransfer: CompositeTransfer;
    nativeHdrImageIds: Set<string>;
    hdrImageBuffers: Map<string, HdrImageBuffer>;
    hdrImageTransferCache: HdrImageTransferCache;
    hdrVideoFrameSources: Map<string, HdrVideoFrameSource>;
    hdrVideoStartTimes: Map<string, number>;
    imageTransfers: Map<string, HdrTransfer>;
    videoTransfers: Map<string, HdrTransfer>;
    debugDumpEnabled: boolean;
    debugDumpDir: string | null;
    hdrPerf?: HdrPerfCollector;
}
/**
 * Composite a single HDR frame into a pre-allocated `rgb48le` canvas.
 *
 * Bottom-to-top z-order: HDR layers are blitted directly from cached image
 * buffers / extracted video frames; DOM layers are screenshotted with a
 * mass-hide mask (so each layer paints only its own elements) and then
 * blended into the canvas via `blitRgba8OverRgb48le` in the active HDR
 * transfer space.
 *
 * The `elementFilter` parameter exists so the transition path can composite
 * each scene independently; pass `undefined` for whole-stack rendering.
 *
 * @param ctx - Long-lived dependencies (logger, browser session, dimensions,
 *              HDR layer maps). Captured once per render — see
 *              {@link HdrCompositeContext}.
 * @param canvas - Pre-allocated `width * height * 6` byte buffer. Caller must
 *                 zero-fill before every frame (this helper does not).
 * @param time - Seek time in seconds.
 * @param fullStacking - Stacking info for ALL elements at this time. Even when
 *                       filtering, every other element id is needed to build
 *                       the DOM-layer hide-list.
 * @param elementFilter - When set, only elements whose id is in the set are
 *                        composited.
 * @param debugFrameIndex - Frame index used to label per-layer diagnostic
 *                          dumps. Pass `-1` to disable per-layer dumps even
 *                          when `KEEP_TEMP=1` (e.g. for warmup frames).
 */
export declare function compositeHdrFrame(ctx: HdrCompositeContext, canvas: Buffer, time: number, fullStacking: ElementStackingInfo[], elementFilter?: Set<string>, debugFrameIndex?: number): Promise<void>;
//# sourceMappingURL=hdrCompositor.d.ts.map