/** * @import {Gradient} from "./gradient.js"; */ /** * Renderer-agnostic state container with a pre-allocated save/restore stack. * * Owns the mutable rendering state (color, tint, transform, scissor, blend mode) * and provides zero-allocation save()/restore() via index-based stacks. * Both CanvasRenderer and WebGLRenderer (and future WebGPU) delegate state * management here, keeping rendering-context-specific code in the renderers. */ export default class RenderState { /** * current fill & stroke style color * @type {Color} */ currentColor: Color; /** * current tint applied to sprites * @type {Color} */ currentTint: Color; /** * current transformation matrix * @type {Matrix3d} */ currentTransform: Matrix3d; /** * current scissor/clipping rectangle [x, y, width, height] * @type {Int32Array} */ currentScissor: Int32Array; /** * current gradient fill (null when using solid color) * @type {Gradient|null} */ currentGradient: Gradient | null; /** * current line dash pattern (empty array = solid line) * @type {number[]} */ lineDash: number[]; /** * current blend mode * @type {string} */ currentBlendMode: string; /** * @ignore */ _stackCapacity: number; /** * current stack depth * @ignore */ _stackDepth: number; /** @ignore */ _colorStack: Color[]; /** @ignore */ _tintStack: Color[]; /** @ignore */ _matrixStack: Matrix3d[]; /** @ignore */ _scissorStack: Int32Array[]; /** @ignore */ _lineDashStack: any[]; /** @ignore */ _scissorActive: Uint8Array; /** @ignore */ _gradientStack: any[]; /** @ignore */ _blendStack: any[]; /** * Save the current state onto the stack (zero allocations). * @param {boolean} [scissorTestActive=false] - whether scissor/clip is currently enabled */ save(scissorTestActive?: boolean): void; /** * Restore state from the stack. * Color, tint, transform, and scissor are restored in place. * Blend mode is NOT applied to `currentBlendMode` — it is returned so the * renderer can call its own `setBlendMode()` (which has context-specific side effects). * @param {number} canvasWidth - current canvas width (used when scissor was inactive) * @param {number} canvasHeight - current canvas height (used when scissor was inactive) * @returns {{ blendMode: string, scissorActive: boolean } | null} restored blend mode and scissor flag, or null if stack was empty */ restore(canvasWidth: number, canvasHeight: number): { blendMode: string; scissorActive: boolean; } | null; /** * Reset all state to defaults and clear the stack. * @param {number} width - canvas width * @param {number} height - canvas height */ reset(width: number, height: number): void; /** @private — doubles stack capacity when exceeded */ private _growStacks; } import { Color } from "./../math/color.ts"; import { Matrix3d } from "../math/matrix3d.ts"; import type { Gradient } from "./gradient.js"; //# sourceMappingURL=renderstate.d.ts.map