@weasel-js/renderer 1.9.4 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/paintResources.ts","../src/shaders/ShaderProgram.ts","../src/shaders/pathFill.ts","../src/shaders/gradFill.ts","../src/shaders/patternFill.ts","../src/shaders/glyphPaint.ts","../src/paintScratch.ts","../src/cache/GLMeshCache.ts","../src/cache/GLTextureCache.ts","../src/cache/GradientRampAtlas.ts","../src/state/GroupState.ts","../src/effects/effectPrelude.ts","../src/effects/composite.ts","../src/draw/drawTriangles.ts","../src/draw/stencil.ts","../src/draw/customShader.ts","../src/draw/uniforms.ts","../src/draw/effects.ts","../src/draw/mesh.ts","../src/draw/flushBatch.ts","../src/draw/clip.ts","../src/strokeLengths.ts","../src/draw/gradient.ts","../src/draw/batch.ts","../src/math/patternSpace.ts","../src/draw/paintBind.ts","../src/draw/pathPaint.ts","../src/glyphOutlineMesh.ts","../src/draw/scratchPass.ts","../src/draw/text.ts","../src/DrawCommand.ts","../src/draw/image.ts","../src/draw.ts","../src/shaders/customPrelude.ts","../src/effects/EffectTargets.ts","../src/shaders/extractUniformNames.ts","../src/WeaselRenderer.ts","../src/spriteSheet.ts","../src/cullDrawCommands.ts","../src/effects/types.ts","../src/effects/builtins.ts","../src/textCommand.ts"],"names":["fragSrc","ramp","mat3","resolveColor","isSolid","resolveStrokeWidth","strokeSpaceOf","prog","SYNTHETIC_ITALIC_RADIANS","depth","v","resolveTextStyle"],"mappings":";;;;;;;;;;;;;;;;;AAUO,SAAS,oBAAA,GAA4C;AAC1D,EAAA,IAAI,WAAqC,EAAC;AAC1C,EAAA,OAAO;AAAA,IACL,UAAU,OAAA,EAAS;AACjB,MAAA,IAAI,QAAA,EAAU,QAAA,CAAS,IAAA,CAAK,OAAO,CAAA;AAAA,WAC9B,OAAA,EAAQ;AAAA,IACf,CAAA;AAAA,I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O,KAAA,IAAS,IAAA,IAAA,CAAS,KAAA,CAAM,IAAA,IAAQ,OAAA,MAAa,OAAA;AACtD","file":"index.js","sourcesContent":["import type { PaintResources } from './paintKinds';\n\n/** A {@link PaintResources} with the end of its lifetime in the owner's hands. */\nexport interface OwnedPaintResources extends PaintResources {\n /** Run every registered release, once. Idempotent. */\n release(): void;\n}\n\n/** A fresh paint-resource lifetime. The renderer opens one per context\n * generation and releases it on dispose or context restore. */\nexport function createPaintResources(): OwnedPaintResources {\n let releases: Array<() => void> | null = [];\n return {\n onRelease(release) {\n if (releases) releases.push(release);\n else release();\n },\n release() {\n const pending = releases;\n releases = null;\n for (const release of pending ?? []) release();\n },\n };\n}\n","/**\n * Minimal compile/link/lookup wrapper for a GL program. Throws\n * `ShaderCompileError` on compile or link failure with the GL info log\n * embedded in the error message — never returns a half-initialized program.\n *\n * Designed so test code can stub `getShaderParameter` / `getProgramParameter`\n * via the recorder Proxy without further special-casing.\n */\n\nexport type Stage = 'vertex' | 'fragment' | 'link';\n\n/** Thrown when a shader fails to compile or link, carrying which stage failed\n * and the driver's log. */\nexport class ShaderCompileError extends Error {\n constructor(public readonly stage: Stage, public readonly log: string) {\n super(`shader ${stage} failure: ${log}`);\n this.name = 'ShaderCompileError';\n }\n}\n\n/** An array uniform a program can be written as a whole: its element type as\n * declared, its declared length, and the location of slot 0. */\nexport interface UniformArray {\n readonly type: string;\n readonly size: number;\n readonly location: WebGLUniformLocation;\n}\n\n/** Where every program links `a_position`. A mesh VAO is built once and drawn\n * with whichever fill program its paint picks, so the location cannot be\n * left to each program's linker. */\nexport const POSITION_ATTRIBUTE_LOCATION = 0;\n\n/** A linked GL program with its uniform and attribute locations cached by name. */\nexport class ShaderProgram {\n readonly handle: WebGLProgram;\n private readonly uniforms = new Map<string, WebGLUniformLocation>();\n private readonly arrays = new Map<string, UniformArray>();\n private readonly attributes = new Map<string, number>();\n\n constructor(\n private readonly gl: WebGL2RenderingContext,\n vertSrc: string,\n fragSrc: string,\n ) {\n const vs = this.compile(gl.VERTEX_SHADER, vertSrc, 'vertex');\n let fs: WebGLShader;\n try {\n fs = this.compile(gl.FRAGMENT_SHADER, fragSrc, 'fragment');\n } catch (e) {\n gl.deleteShader(vs);\n throw e;\n }\n const program = gl.createProgram();\n if (!program) {\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n throw new Error('createProgram returned null');\n }\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.bindAttribLocation(program, POSITION_ATTRIBUTE_LOCATION, 'a_position');\n gl.linkProgram(program);\n // Flagged for deletion, attached shaders live exactly as long as the\n // program, so `deleteProgram` frees them too.\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program) ?? '';\n gl.deleteProgram(program);\n throw new ShaderCompileError('link', log);\n }\n this.handle = program;\n }\n\n private compile(type: number, source: string, stage: Stage): WebGLShader {\n const gl = this.gl;\n const shader = gl.createShader(type);\n if (!shader) throw new Error('createShader returned null');\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader) ?? '';\n gl.deleteShader(shader);\n throw new ShaderCompileError(stage, log);\n }\n return shader;\n }\n\n lookupUniforms(names: readonly string[]): void {\n for (const name of names) {\n const loc = this.gl.getUniformLocation(this.handle, name);\n if (loc !== null) this.uniforms.set(name, loc);\n }\n }\n\n /** Record each array's slot-0 location under its bare name. An array the\n * driver optimized away has no location and is left out. */\n lookupUniformArrays(decls: ReadonlyMap<string, { type: string; size: number }>): void {\n for (const [name, { type, size }] of decls) {\n const base = `${name}[0]`;\n const location = this.uniforms.get(base) ?? this.gl.getUniformLocation(this.handle, base);\n if (location !== null) this.arrays.set(name, { type, size, location });\n }\n }\n\n lookupAttributes(names: readonly string[]): void {\n for (const name of names) {\n const loc = this.gl.getAttribLocation(this.handle, name);\n if (loc >= 0) this.attributes.set(name, loc);\n }\n }\n\n uniform(name: string): WebGLUniformLocation | undefined {\n return this.uniforms.get(name);\n }\n\n uniformArray(name: string): UniformArray | undefined {\n return this.arrays.get(name);\n }\n\n attribute(name: string): number | undefined {\n return this.attributes.get(name);\n }\n}\n","/**\n * GLSL ES 3.0 sources for the built-in solid-fill path shader.\n *\n * Two variants:\n * - Flat: VERT_SRC + FRAG_SRC, uses uniform color only.\n * - VColor: VCOLOR_VERT_SRC + VCOLOR_FRAG_SRC, multiplies a per-vertex\n * `a_vertexColor` attribute with `u_color`.\n *\n * Both variants take `u_colorMatrix` (mat4) + `u_colorBias` (vec4); the\n * color transform is applied to the straight-alpha SRC color BEFORE\n * premultiplication. Identity matrix + zero bias = pass-through.\n *\n * Output (both variants): PREMULTIPLIED alpha.\n * Blend: caller sets `gl.blendFunc(ONE, ONE_MINUS_SRC_ALPHA)`.\n */\n\nexport const VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform vec2 u_origin;\nvoid main() {\n vec3 screen = u_model * vec3(a_position - u_origin, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n}\n`;\n\nexport const FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nuniform vec4 u_color;\nuniform float u_alpha;\nuniform mat4 u_colorMatrix;\nuniform vec4 u_colorBias;\nout vec4 outColor;\nvoid main() {\n vec4 mapped = clamp(u_colorMatrix * u_color + u_colorBias, 0.0, 1.0);\n float a = mapped.a * u_alpha;\n outColor = vec4(mapped.rgb * a, a);\n}\n`;\n\nexport const VCOLOR_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nin vec4 a_vertexColor;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform vec2 u_origin;\nout vec4 v_vertexColor;\nvoid main() {\n vec3 screen = u_model * vec3(a_position - u_origin, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n v_vertexColor = a_vertexColor;\n}\n`;\n\nexport const VCOLOR_FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nin vec4 v_vertexColor;\nuniform vec4 u_color;\nuniform float u_alpha;\nuniform mat4 u_colorMatrix;\nuniform vec4 u_colorBias;\nout vec4 outColor;\nvoid main() {\n vec4 src = u_color * v_vertexColor;\n vec4 mapped = clamp(u_colorMatrix * src + u_colorBias, 0.0, 1.0);\n float a = mapped.a * u_alpha;\n outColor = vec4(mapped.rgb * a, a);\n}\n`;\n\n/** Uniforms shared between flat and vertex-color variants. */\nexport const PATH_FILL_UNIFORMS = [\n 'u_proj', 'u_model', 'u_origin', 'u_color', 'u_alpha',\n 'u_colorMatrix', 'u_colorBias',\n] as const;\n\n/** Attributes for the flat variant. */\nexport const PATH_FILL_ATTRIBUTES = ['a_position'] as const;\n\n/** Attributes for the vertex-color variant. */\nexport const PATH_FILL_VCOLOR_ATTRIBUTES = ['a_position', 'a_vertexColor'] as const;\n","/**\n * GLSL ES 3.0 sources for gradient-fill paths (linear, radial, conic).\n *\n * Three gradient kinds via u_gradKind (0=linear, 1=radial, 2=conic).\n * The branch value is uniform across all fragments in one draw call — GPU\n * branch predictor handles uniform-value branches without warp divergence.\n *\n * Output convention §2: PREMULTIPLIED alpha.\n *\n * `u_ramp` is `GradientRampAtlas`'s texture, which holds every baked ramp in\n * the frame, one per row; `u_rampV` picks this fill's row.\n */\n\nexport const GRAD_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform vec2 u_origin;\nuniform mat3 u_worldInv;\nout vec2 v_world;\nvoid main() {\n vec3 screen = u_model * vec3(a_position - u_origin, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n vec3 world = u_worldInv * vec3(screen.xy, 1.0);\n v_world = world.xy;\n}\n`;\n\n/**\n * The gradient's color at a gradient-space point, premultiplied — the whole\n * of the fragment stage but the point it is asked about, so the glyph program\n * can mask the same paint the path program draws.\n */\nexport const GRAD_PAINT_GLSL = /* glsl */ `\nuniform sampler2D u_ramp;\nuniform float u_rampV;\nuniform float u_alpha;\nuniform mat4 u_colorMatrix;\nuniform vec4 u_colorBias;\nuniform float u_opacity;\nuniform int u_gradKind;\nuniform vec2 u_gradP0;\nuniform vec2 u_gradDir;\nuniform float u_gradLen;\nuniform float u_gradRadius;\nuniform float u_gradAngle;\n\nconst float PI = 3.14159265358979323846;\n\nvec4 shadePaint(vec2 world) {\n float t;\n if (u_gradKind == 0) {\n vec2 d = world - u_gradP0;\n t = dot(d, u_gradDir) / max(u_gradLen, 0.0001);\n } else if (u_gradKind == 1) {\n t = length(world - u_gradP0) / max(u_gradRadius, 0.0001);\n } else {\n float a = atan(world.y - u_gradP0.y, world.x - u_gradP0.x) - u_gradAngle;\n t = fract(a / (2.0 * PI));\n }\n t = clamp(t, 0.0, 1.0);\n vec4 rampColor = texture(u_ramp, vec2(t, u_rampV));\n // Fill opacity into the alpha channel before the matrix, which is where the\n // batch program's vertex alpha sits. The two have to agree, since a linear\n // gradient goes through that one and a radial through this.\n vec4 src = vec4(rampColor.rgb, rampColor.a * u_opacity);\n vec4 mapped = clamp(u_colorMatrix * src + u_colorBias, 0.0, 1.0);\n float a = mapped.a * u_alpha;\n return vec4(mapped.rgb * a, a);\n}\n`;\n\nexport const GRAD_FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_world;\n${GRAD_PAINT_GLSL}\nout vec4 outColor;\nvoid main() {\n outColor = shadePaint(v_world);\n}\n`;\n\nexport const GRAD_FILL_UNIFORMS = [\n 'u_proj', 'u_model', 'u_origin', 'u_worldInv', 'u_ramp', 'u_rampV',\n 'u_alpha', 'u_opacity', 'u_colorMatrix', 'u_colorBias',\n 'u_gradKind', 'u_gradP0', 'u_gradDir', 'u_gradLen', 'u_gradRadius', 'u_gradAngle',\n] as const;\n\nexport const GRAD_FILL_ATTRIBUTES = ['a_position'] as const;\n","/**\n * GLSL ES 3.0 sources for pattern-fill paths.\n *\n * The vertex stage is `gradFill`'s: a path fill mesh carries `a_position`\n * only, so tile-space coordinates are recovered per fragment from the\n * screen position via `u_worldInv` rather than read from a UV attribute.\n * That matrix also carries the tile's origin and transform\n * (`patternTileSpace`). `u_tileSize` then converts to texture space, and\n * `REPEAT` wrapping (set at upload) tiles the result.\n *\n * Output convention §2: PREMULTIPLIED alpha.\n */\n\nexport const PATTERN_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform vec2 u_origin;\nuniform mat3 u_worldInv;\nout vec2 v_world;\nvoid main() {\n vec3 screen = u_model * vec3(a_position - u_origin, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n vec3 world = u_worldInv * vec3(screen.xy, 1.0);\n v_world = world.xy;\n}\n`;\n\n/**\n * The pattern's color at a paint-space point, premultiplied — the whole of the\n * fragment stage but the point it is asked about, so the glyph program can\n * mask the same paint the path program draws.\n */\nexport const PATTERN_PAINT_GLSL = /* glsl */ `\nuniform sampler2D u_sampler;\nuniform vec2 u_tileSize;\nuniform float u_opacity;\nuniform float u_alpha;\nuniform mat4 u_colorMatrix;\nuniform vec4 u_colorBias;\nvec4 shadePaint(vec2 world) {\n vec2 uv = world / max(u_tileSize, vec2(0.0001));\n vec4 texel = texture(u_sampler, uv);\n vec4 mapped = clamp(u_colorMatrix * texel + u_colorBias, 0.0, 1.0);\n float a = mapped.a * u_opacity * u_alpha;\n return vec4(mapped.rgb * a, a);\n}\n`;\n\nexport const PATTERN_FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_world;\n${PATTERN_PAINT_GLSL}\nout vec4 outColor;\nvoid main() {\n outColor = shadePaint(v_world);\n}\n`;\n\nexport const PATTERN_FILL_UNIFORMS = [\n 'u_proj', 'u_model', 'u_origin', 'u_worldInv', 'u_sampler',\n 'u_tileSize', 'u_opacity', 'u_alpha',\n 'u_colorMatrix', 'u_colorBias',\n] as const;\n\nexport const PATTERN_FILL_ATTRIBUTES = ['a_position'] as const;\n","/**\n * GLSL ES 3.0 sources for atlas glyphs filled by a texture paint — a pattern, a\n * gradient or a registered kind — rather than one color.\n *\n * **The glyph is a mask over the paint.** The fragment takes its coverage from\n * the distance field exactly as the batch program does, and its color from the\n * same `shadePaint` the path program for that paint runs, at the same\n * paint-space point: `u_worldInv` applied to the screen position. An outline\n * glyph is a path, so it goes through that path program — which is what makes\n * a paint read the same on either side of the outline-tier threshold.\n *\n * **The vertices are the batch's.** A glyph run stages into `DrawBatch` as\n * usual and this program draws it in place of the batch program, so the\n * attribute locations are pinned to the batch shader's and one VAO serves\n * both. Positions arrive already in screen space, so `u_model` is identity.\n *\n * Coverage is taken before `shadePaint` runs, and outside any branch: `fwidth`\n * in non-uniform control flow is undefined. The gradient's branches are on a\n * uniform, so they could not make it so, but the order keeps it from mattering.\n *\n * Output: PREMULTIPLIED alpha, the paint's own scaled by coverage.\n */\n\nimport { GLYPH_COVERAGE_GLSL } from '@weasel-js/font';\nimport { BATCH_ATTRIBUTE_LOCATIONS, BATCH_TEXTURE_SLOTS } from './batchFill';\nimport { GRAD_FILL_UNIFORMS, GRAD_PAINT_GLSL } from './gradFill';\nimport { PATTERN_FILL_UNIFORMS, PATTERN_PAINT_GLSL } from './patternFill';\n\nconst L = BATCH_ATTRIBUTE_LOCATIONS;\n\nexport const GLYPH_PAINT_VERT_SRC = /* glsl */ `#version 300 es\nlayout(location = ${L.a_position}) in vec2 a_position;\nlayout(location = ${L.a_uv}) in vec2 a_uv;\nlayout(location = ${L.a_texSlot}) in float a_texSlot;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform mat3 u_worldInv;\nout vec2 v_world;\nout vec2 v_uv;\nflat out float v_glyphMode;\nvoid main() {\n vec3 screen = u_model * vec3(a_position, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n v_world = (u_worldInv * vec3(screen.xy, 1.0)).xy;\n v_uv = a_uv;\n v_glyphMode = float(int(a_texSlot + 0.5) / ${BATCH_TEXTURE_SLOTS});\n}\n`;\n\nfunction fragSrc(paintGlsl: string): string {\n return /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_world;\nin vec2 v_uv;\nflat in float v_glyphMode;\nuniform sampler2D u_atlas;\nuniform float u_synthBold;\nuniform vec2 u_fieldScale;\n${paintGlsl}\n${GLYPH_COVERAGE_GLSL}\nout vec4 outColor;\nvoid main() {\n float coverage = glyphCoverage(texture(u_atlas, v_uv), v_glyphMode, u_synthBold, v_uv, u_fieldScale);\n outColor = shadePaint(v_world) * coverage;\n}\n`;\n}\n\n/**\n * A registered paint kind binds a whole program of its own, which nothing can\n * wrap in a mask, so it renders into an offscreen buffer first and the glyphs\n * sample that. `u_worldInv` takes the screen position straight to the\n * buffer's texture coordinate, and the texel is already premultiplied and\n * faded — the kind's own program did both.\n */\nconst TEXTURE_PAINT_GLSL = /* glsl */ `\nuniform sampler2D u_sampler;\nvec4 shadePaint(vec2 uv) {\n return texture(u_sampler, uv);\n}\n`;\n\nexport const GLYPH_PATTERN_FRAG_SRC = fragSrc(PATTERN_PAINT_GLSL);\nexport const GLYPH_GRAD_FRAG_SRC = fragSrc(GRAD_PAINT_GLSL);\nexport const GLYPH_TEXTURE_FRAG_SRC = fragSrc(TEXTURE_PAINT_GLSL);\n\nconst GLYPH_UNIFORMS = ['u_atlas', 'u_synthBold', 'u_fieldScale'] as const;\n// `u_origin` belongs to the path vertex stage, which these programs replace.\nconst notOrigin = (name: string): boolean => name !== 'u_origin';\nexport const GLYPH_PATTERN_UNIFORMS: readonly string[] = [\n ...PATTERN_FILL_UNIFORMS.filter(notOrigin), ...GLYPH_UNIFORMS,\n];\nexport const GLYPH_GRAD_UNIFORMS: readonly string[] = [\n ...GRAD_FILL_UNIFORMS.filter(notOrigin), ...GLYPH_UNIFORMS,\n];\nexport const GLYPH_TEXTURE_UNIFORMS = [\n 'u_proj', 'u_model', 'u_worldInv', 'u_sampler', ...GLYPH_UNIFORMS,\n] as const;\nexport const GLYPH_PAINT_ATTRIBUTES = ['a_position', 'a_uv', 'a_texSlot'] as const;\n","/**\n * The offscreen color buffer a registered paint kind renders into when what it\n * fills is not a path: atlas glyphs, whose coverage then masks what it drew.\n *\n * One per renderer, grown in powers of two to the largest region asked of it\n * and never shrunk, so a frame of differently sized text groups reallocates a\n * few times and then not at all. The region is clamped to the drawing buffer,\n * which bounds the buffer too. It has no stencil: nothing drawn into it is\n * clipped — the clip applies to the glyphs sampling it.\n */\n\nexport interface PaintScratchTarget {\n readonly fbo: WebGLFramebuffer;\n readonly texture: WebGLTexture;\n /** Texture size, at least the region asked for. */\n readonly width: number;\n readonly height: number;\n}\n\nconst MIN_SIDE = 64;\n\nexport class PaintScratch {\n private readonly gl: WebGL2RenderingContext;\n private target: PaintScratchTarget | null = null;\n\n constructor(gl: WebGL2RenderingContext) {\n this.gl = gl;\n }\n\n /** A buffer at least `width` × `height` device pixels. Its contents are\n * whatever the last user left; the caller clears the region it uses. */\n acquire(width: number, height: number): PaintScratchTarget {\n const have = this.target;\n if (have && have.width >= width && have.height >= height) return have;\n const w = Math.max(have?.width ?? 0, pow2(width));\n const h = Math.max(have?.height ?? 0, pow2(height));\n this.release();\n this.target = this.create(w, h);\n return this.target;\n }\n\n /** Drop the buffer. Called on dispose and on context restore, where the\n * handles are already dead and only the bookkeeping has to go. */\n release(): void {\n if (!this.target) return;\n this.gl.deleteFramebuffer(this.target.fbo);\n this.gl.deleteTexture(this.target.texture);\n this.target = null;\n }\n\n private create(width: number, height: number): PaintScratchTarget {\n const gl = this.gl;\n const texture = gl.createTexture()!;\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n // The region is laid on the device-pixel grid, so every fragment reading\n // it lands on a texel center and NEAREST is exact.\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n\n const fbo = gl.createFramebuffer()!;\n gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n return { fbo, texture, width, height };\n }\n}\n\nfunction pow2(n: number): number {\n let side = MIN_SIDE;\n while (side < n) side *= 2;\n return side;\n}\n","import type { Mesh } from '@weasel-js/geom/tessellate';\nimport { POSITION_ATTRIBUTE_LOCATION } from '../shaders/ShaderProgram';\n\nexport interface GLMeshHandle {\n readonly vao: WebGLVertexArrayObject;\n readonly indexCount: number;\n readonly requiresStencil: boolean;\n readonly anchorA?: Uint32Array;\n readonly anchorB?: Uint32Array;\n readonly anchorT?: Float32Array;\n}\n\n/** Resources to release when a Mesh is reclaimed by GC. */\ninterface MeshResources {\n vao: WebGLVertexArrayObject;\n vbo: WebGLBuffer;\n ibo: WebGLBuffer;\n}\n\n/**\n * Caches GL-side buffers + VAO per `Mesh` identity. Upload happens lazily\n * on first `handleFor(mesh)` call.\n *\n * **GC-aware cleanup (deferred-delete queue):** when a Mesh becomes\n * unreachable, the WeakMap entry is dropped automatically — but the\n * underlying GL resources (VAO, VBO, IBO) would leak forever without an\n * explicit `gl.delete*` call. We register each Mesh with a\n * `FinalizationRegistry`; when the Mesh is reclaimed, the finalizer pushes\n * the resources onto an internal queue. The renderer drains this queue at\n * the start of each `render()` call (via `drainPendingDeletes()`), when GL\n * is in a known state — no VAO bound, no draw mid-flight. Deleting from the\n * finalizer directly was racy (it could fire between two `gl.bindVertexArray`\n * calls inside `dispatch()`, sometimes corrupting the next draw); deferring\n * the actual delete to a known-safe point keeps the use-after-free risk to\n * zero.\n *\n * Caveats:\n * - Finalizer timing is non-deterministic; resources may live for a frame\n * or two beyond their Mesh, but they will be reclaimed.\n * - If the GL context is lost between finalizer and drain, the drain\n * no-ops safely (`gl.isContextLost()` makes deletes no-ops, and\n * `gl.deleteBuffer(null)` is allowed).\n *\n * The cache is GL-context-bound; if the context is lost and re-created, the\n * renderer should construct a new GLMeshCache. (Context loss handling lives\n * in `WeaselRenderer`.)\n */\nexport class GLMeshCache {\n private readonly map = new WeakMap<Mesh, GLMeshHandle>();\n /** Meshes this context has drawn at least once; see `uploadRecurring`. */\n private readonly seen = new WeakSet<Mesh>();\n private readonly finalizer: FinalizationRegistry<MeshResources>;\n /** Every persistent upload not yet freed, so `dispose` can reach them. */\n private readonly persistent = new Set<MeshResources>();\n private readonly pendingDeletes: MeshResources[] = [];\n private disposed = false;\n /** Transient resources allocated this frame; freed at end of render(). */\n private readonly transientThisFrame: MeshResources[] = [];\n\n constructor(\n private readonly gl: WebGL2RenderingContext,\n ) {\n this.finalizer = new FinalizationRegistry<MeshResources>((resources) => {\n // Defer the actual gl.delete* until the renderer's next render(),\n // when no VAO/buffer is bound mid-draw. Direct deletion from the\n // finalizer caused use-after-free crashes when GC fired between\n // bindVertexArray and drawElements inside dispatch().\n if (!this.persistent.delete(resources)) return;\n this.pendingDeletes.push(resources);\n });\n }\n\n handleFor(mesh: Mesh): GLMeshHandle {\n const cached = this.map.get(mesh);\n if (cached) return cached;\n const { handle, vbo, ibo } = this.upload(mesh);\n this.map.set(mesh, handle);\n const resources = { vao: handle.vao, vbo, ibo };\n this.persistent.add(resources);\n // Register so the GL resources get freed when `mesh` is GC'd. The\n // unregister token (mesh) lets us cancel if the Mesh is somehow\n // re-uploaded under a different cache, though that's not a normal flow.\n this.finalizer.register(mesh, resources, mesh);\n return handle;\n }\n\n /**\n * Upload a Mesh that the caller knows is single-use (e.g. the per-frame\n * stroke ribbon from `tessellateStroke`). Returns a handle backed by fresh\n * GL resources that the renderer will free deterministically at the end\n * of the current frame via `freeTransient()`. Bypasses the WeakMap cache\n * and the FinalizationRegistry, so transient meshes never wait on GC.\n */\n uploadTransient(mesh: Mesh): GLMeshHandle {\n const { handle, vbo, ibo } = this.upload(mesh);\n this.transientThisFrame.push({ vao: handle.vao, vbo, ibo });\n return handle;\n }\n\n /**\n * Upload a Mesh that may or may not recur across frames. Its first sight in\n * *this* context takes `uploadTransient`; every later one takes the\n * persistent handle. One transient upload to find out is cheaper than\n * stranding a persistent VAO on a mesh that never returns, whose release\n * would wait on GC. The transient upload does not populate the persistent\n * map, so steady-state reuse begins on the third frame.\n */\n uploadRecurring(mesh: Mesh): GLMeshHandle {\n if (this.seen.has(mesh)) return this.handleFor(mesh);\n this.seen.add(mesh);\n return this.uploadTransient(mesh);\n }\n\n /**\n * Free all transient resources allocated since the last call. Called by\n * the renderer at the end of each `render()`. Safe under context loss.\n */\n freeTransient(): void {\n if (this.transientThisFrame.length === 0) return;\n const gl = this.gl;\n if (gl.isContextLost()) {\n this.transientThisFrame.length = 0;\n return;\n }\n for (const r of this.transientThisFrame) {\n gl.deleteVertexArray(r.vao);\n gl.deleteBuffer(r.vbo);\n gl.deleteBuffer(r.ibo);\n }\n this.transientThisFrame.length = 0;\n }\n\n /** @internal — for tests asserting the transient-list size. */\n _transientCount(): number {\n return this.transientThisFrame.length;\n }\n\n /**\n * Free GL resources whose Mesh has been GC'd since the last drain.\n * Called by the renderer at the top of each `render()`, before any draws.\n */\n drainPendingDeletes(): void {\n if (this.pendingDeletes.length === 0) return;\n const gl = this.gl;\n if (gl.isContextLost()) {\n this.pendingDeletes.length = 0;\n return;\n }\n for (const r of this.pendingDeletes) {\n gl.deleteVertexArray(r.vao);\n gl.deleteBuffer(r.vbo);\n gl.deleteBuffer(r.ibo);\n }\n this.pendingDeletes.length = 0;\n }\n\n /**\n * Free every GL resource this cache holds — persistent, pending and\n * transient — and ignore finalizers from here on. Idempotent. Unlike the\n * other paths this does not wait on GC, which is what lets a renderer on a\n * context it does not own give back everything it uploaded.\n */\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n this.freeTransient();\n for (const r of this.persistent) this.pendingDeletes.push(r);\n this.persistent.clear();\n this.drainPendingDeletes();\n }\n\n /** @internal — for tests asserting the queue size. */\n _pendingDeleteCount(): number {\n return this.pendingDeletes.length;\n }\n\n /** @internal — for tests that need to simulate the finalizer firing. */\n _enqueueDeleteForTest(resources: MeshResources): void {\n this.pendingDeletes.push(resources);\n }\n\n private upload(mesh: Mesh): { handle: GLMeshHandle; vbo: WebGLBuffer; ibo: WebGLBuffer } {\n const gl = this.gl;\n const vao = gl.createVertexArray();\n if (!vao) throw new Error('createVertexArray returned null');\n gl.bindVertexArray(vao);\n\n const vbo = gl.createBuffer();\n if (!vbo) throw new Error('createBuffer (VBO) returned null');\n gl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n gl.bufferData(gl.ARRAY_BUFFER, mesh.vertices, gl.STATIC_DRAW);\n\n gl.enableVertexAttribArray(POSITION_ATTRIBUTE_LOCATION);\n gl.vertexAttribPointer(POSITION_ATTRIBUTE_LOCATION, 2, gl.FLOAT, false, 0, 0);\n\n const ibo = gl.createBuffer();\n if (!ibo) throw new Error('createBuffer (IBO) returned null');\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ibo);\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, mesh.indices, gl.STATIC_DRAW);\n\n gl.bindVertexArray(null);\n\n return {\n handle: {\n vao,\n indexCount: mesh.indices.length,\n requiresStencil: mesh.requiresStencil ?? false,\n anchorA: mesh.anchorA,\n anchorB: mesh.anchorB,\n anchorT: mesh.anchorT,\n },\n vbo,\n ibo,\n };\n }\n}\n","/**\n * GL texture upload + cache for MSDF font atlases (and future images).\n *\n * Textures are keyed by a string id (the font family name or image id).\n * Pixels are uploaded once per id; a later upload of the same id reuses the\n * texture and only re-applies its wrap mode when that changed.\n * The cache is GL-context-bound; discard and create a new one on context loss.\n *\n * Atlas format: RGBA UNSIGNED_BYTE, linear filtering, no mipmaps.\n * Mipmap generation is deliberately skipped — MSDF works correctly with\n * linear filtering, and mipmap resampling corrupts the multi-channel SDF signal.\n */\n\ntype TexSource = HTMLImageElement | ImageBitmap | ImageData | HTMLCanvasElement;\n\n/** How a texture samples outside `0..1`. Pattern tiles need `'repeat'`;\n * everything else clamps. WebGL2 allows `REPEAT` on NPOT textures, so a\n * tile of any size tiles correctly. */\nexport type TextureWrap = 'clamp' | 'repeat';\n\n/** The part of the texture registry a sweep reads. */\nexport interface RegisteredTextureIds {\n getVersion(): number;\n has(id: string): boolean;\n}\n\nexport class GLTextureCache {\n private readonly map = new Map<string, WebGLTexture>();\n private readonly wraps = new Map<string, TextureWrap>();\n /** The source each registry-backed id was last uploaded from. */\n private readonly registered = new Map<string, TexSource>();\n private sweptVersion = -1;\n\n constructor(private readonly gl: WebGL2RenderingContext) {}\n\n has(id: string): boolean {\n return this.map.has(id);\n }\n\n /** Uploads the pixels once per id. `wrap` is re-applied whenever it differs\n * from what the id was last uploaded under: the same registered image can\n * be a clamped shader texture in one draw and a repeating pattern tile in\n * the next, and first-upload-wins gave the second one the first one's mode. */\n upload(id: string, source: TexSource, wrap: TextureWrap = 'clamp'): string {\n const cached = this.map.get(id);\n if (cached) {\n if (this.wraps.get(id) !== wrap) this.applyWrap(id, cached, wrap);\n return id;\n }\n\n const gl = this.gl;\n const tex = gl.createTexture();\n if (!tex) throw new Error(`GLTextureCache: createTexture failed for id=\"${id}\"`);\n\n const wrapMode = wrap === 'repeat' ? gl.REPEAT : gl.CLAMP_TO_EDGE;\n\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source as TexImageSource);\n\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapMode);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapMode);\n\n gl.bindTexture(gl.TEXTURE_2D, null);\n\n this.map.set(id, tex);\n this.wraps.set(id, wrap);\n return id;\n }\n\n /** `upload` for an id from the texture registry, whose image can be replaced\n * under the same id: a changed source sends its pixels again. */\n uploadRegistered(id: string, source: TexSource, wrap: TextureWrap = 'clamp'): string {\n const cached = this.map.get(id);\n if (cached && this.registered.get(id) !== source) {\n const gl = this.gl;\n gl.bindTexture(gl.TEXTURE_2D, cached);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source as TexImageSource);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n this.registered.set(id, source);\n return this.upload(id, source, wrap);\n }\n\n /**\n * Delete the texture of every registry-backed id the registry has dropped.\n * The renderer calls this at the top of `render()`, before any draw, so a\n * texture is never deleted under a draw that has it bound.\n */\n sweep(registry: RegisteredTextureIds): void {\n const version = registry.getVersion();\n if (version === this.sweptVersion) return;\n this.sweptVersion = version;\n for (const id of this.registered.keys()) {\n if (registry.has(id)) continue;\n this.gl.deleteTexture(this.map.get(id) ?? null);\n this.map.delete(id);\n this.wraps.delete(id);\n this.registered.delete(id);\n }\n }\n\n private applyWrap(id: string, tex: WebGLTexture, wrap: TextureWrap): void {\n const gl = this.gl;\n const mode = wrap === 'repeat' ? gl.REPEAT : gl.CLAMP_TO_EDGE;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, mode);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, mode);\n gl.bindTexture(gl.TEXTURE_2D, null);\n this.wraps.set(id, wrap);\n }\n\n /** Create a single-channel R8 texture from raw bytes (full upload).\n * No-op if `id` already exists. Same LINEAR/CLAMP params as `upload`;\n * UNPACK_ALIGNMENT dropped to 1 for non-4-aligned row widths. */\n uploadR8(id: string, width: number, height: number, data: Uint8Array): void {\n if (this.map.has(id)) return;\n const gl = this.gl;\n const tex = gl.createTexture();\n if (!tex) throw new Error(`GLTextureCache: createTexture failed for id=\"${id}\"`);\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.R8, width, height, 0, gl.RED, gl.UNSIGNED_BYTE, data);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n this.map.set(id, tex);\n this.wraps.set(id, 'clamp');\n }\n\n /** Patch a rect of an existing R8 texture with tightly-packed w×h bytes. */\n subImageR8(id: string, x: number, y: number, w: number, h: number, data: Uint8Array): void {\n const tex = this.map.get(id);\n if (!tex) throw new Error(`GLTextureCache: texture \"${id}\" not uploaded`);\n const gl = this.gl;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\n gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, w, h, gl.RED, gl.UNSIGNED_BYTE, data);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n\n bind(id: string, unit: number): void {\n const tex = this.map.get(id);\n if (!tex) throw new Error(`GLTextureCache: texture \"${id}\" not uploaded`);\n const gl = this.gl;\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, tex);\n }\n\n /**\n * Delete every uploaded GL texture and clear the map. Called by\n * `WeaselRenderer.dispose()`. The cache is unusable but refillable\n * afterward — a subsequent `upload()` for a previously-seen id re-creates\n * the texture rather than restoring the deleted one.\n */\n free(): void {\n const gl = this.gl;\n for (const tex of this.map.values()) {\n gl.deleteTexture(tex);\n }\n this.map.clear();\n this.wraps.clear();\n this.registered.clear();\n }\n}\n","/**\n * CPU gradient-ramp builder + the GL texture every baked ramp lives in.\n *\n * Each unique stop list is baked once into a 256-texel strip and written to its\n * own **row** of one RGBA texture, keyed by `JSON.stringify(stops)`. One\n * texture rather than one per ramp is what lets a gradient take a batch texture\n * slot the way a bitmap or a font atlas does: every gradient in a frame samples\n * the same unit, so a run does not break per gradient. The atlas is\n * GL-context-bound; discard and recreate on context loss.\n *\n * Output convention §2: texels are stored as straight RGBA. The fragment\n * shader applies premultiplication before writing outColor.\n */\n\nimport type { ColorSpace, GradStop } from '@weasel-js/paint';\nimport { resolveGradientStops, sampleResolvedStops } from '@weasel-js/paint';\n\n/** Texels across one ramp — the resolution a gradient is sampled at. */\nexport const RAMP_WIDTH = 256;\n\n/** Rows the atlas starts at, doubling from there. */\nconst INITIAL_ROWS = 16;\n\n/**\n * Rows the atlas stops growing at, past which the least recently used row is\n * recycled.\n *\n * WebGL2 guarantees `MAX_TEXTURE_SIZE` of at least 2048, so this is available\n * everywhere without a `getParameter` — which the GL recorder would answer with\n * a recording function rather than a number. A cap is also what bounds an\n * animating gradient, which mints a new stop list every frame and would\n * otherwise grow the atlas until it could not grow again.\n */\nexport const RAMP_ATLAS_MAX_ROWS = 1024;\n\n/** Bake gradient stops into a 256-entry RGBA lookup strip, which the shader\n * samples instead of evaluating stops per fragment. `space` is the gradient's\n * `interpolate` — the ramp is where a non-sRGB blend is paid for, once. */\nexport function buildGradientRamp(stops: GradStop[], space: ColorSpace = 'rgb'): Uint8ClampedArray {\n const data = new Uint8ClampedArray(RAMP_WIDTH * 4);\n if (stops.length === 0) return data;\n\n const resolved = resolveGradientStops(stops);\n for (let i = 0; i < RAMP_WIDTH; i++) {\n const [r, g, b, a] = sampleResolvedStops(resolved, i / (RAMP_WIDTH - 1), space);\n data[i * 4] = r * 255;\n data[i * 4 + 1] = g * 255;\n data[i * 4 + 2] = b * 255;\n data[i * 4 + 3] = a * 255;\n }\n\n return data;\n}\n\n/** The row identity. Two gradients with the same stops and different\n * `interpolate` bake to different texels, so the space is part of the key. */\nfunction rampKey(stops: GradStop[], space: ColorSpace): string {\n return `${space}|${JSON.stringify(stops)}`;\n}\n\nexport class GradientRampAtlas {\n /** Row per stop list, in least-recently-used order: a hit re-inserts, so the\n * first entry is the row a full atlas recycles. */\n private readonly rowByKey = new Map<string, number>();\n private texture: WebGLTexture | null = null;\n private rows = 0;\n /** Mirror of the texture, so growth can respecify it without re-baking every\n * ramp it already holds. */\n private pixels = new Uint8ClampedArray(0);\n private totalQueries = 0;\n private cacheHits = 0;\n\n constructor(private readonly gl: WebGL2RenderingContext) {}\n\n /** Rows the atlas currently holds — its texture height. */\n get height(): number {\n return this.rows;\n }\n\n /**\n * Bake `stops` into a row and return it, reusing the row an identical stop\n * list already holds.\n *\n * **A returned row outlives the frame only while the atlas has room.** Past\n * `RAMP_ATLAS_MAX_ROWS` an upload recycles the least recently used row, which\n * rewrites texels a row handed out earlier still names. Nothing that defers\n * its draw past this call may hold a row across another `upload` without\n * arranging to be flushed first.\n */\n upload(stops: GradStop[], space: ColorSpace = 'rgb'): number {\n const key = rampKey(stops, space);\n this.totalQueries++;\n const existing = this.rowByKey.get(key);\n if (existing !== undefined) {\n this.cacheHits++;\n this.rowByKey.delete(key);\n this.rowByKey.set(key, existing);\n return existing;\n }\n\n const row = this.claimRow();\n this.writeRow(row, buildGradientRamp(stops, space));\n this.rowByKey.set(key, row);\n return row;\n }\n\n /**\n * Whether uploading `stops` would move where existing rows sit — by growing\n * the atlas, which changes every row's `v`, or by recycling one, which\n * rewrites its texels.\n *\n * Anything holding a row past this call asks first and gets itself out of\n * the way, because neither can be undone once it has happened.\n */\n wouldReshape(stops: GradStop[], space: ColorSpace = 'rgb'): boolean {\n // An atlas holding nothing has no row to move, so its first growth is free.\n if (this.rowByKey.size === 0) return false;\n return !this.rowByKey.has(rampKey(stops, space))\n && this.rowByKey.size >= this.rows;\n }\n\n /**\n * The `v` a row is sampled at — its center.\n *\n * The center is load-bearing: the atlas filters LINEAR, so a `v` anywhere\n * else blends the ramp beside it into this one. At the center the neighbor's\n * weight is exactly zero.\n */\n rowV(row: number): number {\n return (row + 0.5) / (this.rows || 1);\n }\n\n bind(unit: number): void {\n const gl = this.gl;\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n }\n\n hitRate(): number {\n if (this.totalQueries === 0) return 0;\n return this.cacheHits / this.totalQueries;\n }\n\n resetStats(): void {\n this.totalQueries = 0;\n this.cacheHits = 0;\n }\n\n /**\n * Delete the atlas texture and forget every row in it. Called by\n * `WeaselRenderer.dispose()`. The CPU mirror goes with it, so the atlas is\n * unusable but refillable afterward (stats are left as-is; call\n * `resetStats()` separately if desired).\n */\n free(): void {\n if (this.texture) this.gl.deleteTexture(this.texture);\n this.texture = null;\n this.rows = 0;\n this.pixels = new Uint8ClampedArray(0);\n this.rowByKey.clear();\n }\n\n /** The row the next ramp is written to: a free one, a taller atlas, or the\n * least recently used row of a full one. */\n private claimRow(): number {\n if (this.rowByKey.size < this.rows) return this.rowByKey.size;\n if (this.rows < RAMP_ATLAS_MAX_ROWS) {\n this.resize(this.rows === 0 ? INITIAL_ROWS : this.rows * 2);\n return this.rowByKey.size;\n }\n const [lruKey, lruRow] = this.rowByKey.entries().next().value as [string, number];\n this.rowByKey.delete(lruKey);\n return lruRow;\n }\n\n /** Grow to `rows`, keeping every row at the index it already had — a row\n * index is a stable name, and callers hold them. */\n private resize(rows: number): void {\n const gl = this.gl;\n const next = new Uint8ClampedArray(RAMP_WIDTH * rows * 4);\n next.set(this.pixels);\n this.pixels = next;\n this.rows = rows;\n\n if (!this.texture) {\n const tex = gl.createTexture();\n if (!tex) throw new Error('GradientRampAtlas: createTexture failed');\n this.texture = tex;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n }\n gl.texImage2D(\n gl.TEXTURE_2D, 0, gl.RGBA,\n RAMP_WIDTH, rows, 0,\n gl.RGBA, gl.UNSIGNED_BYTE, this.pixels,\n );\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n\n private writeRow(row: number, ramp: Uint8ClampedArray): void {\n const gl = this.gl;\n this.pixels.set(ramp, row * RAMP_WIDTH * 4);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n gl.texSubImage2D(\n gl.TEXTURE_2D, 0, 0, row,\n RAMP_WIDTH, 1,\n gl.RGBA, gl.UNSIGNED_BYTE, ramp,\n );\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n}\n","import { mat3, type GlMat3 } from '@weasel-js/geom';\n\n/** Row-major 4×5 color matrix identity. */\nexport const IDENTITY_COLOR_MATRIX = new Float32Array([\n 1, 0, 0, 0, 0,\n 0, 1, 0, 0, 0,\n 0, 0, 1, 0, 0,\n 0, 0, 0, 1, 0,\n]);\n\nexport interface GroupFrame {\n transform?: GlMat3;\n alpha?: number;\n /** Row-major 4×5 color matrix (20 floats). Absent leaves the stack unchanged. */\n colorMatrix?: Float32Array | number[];\n}\n\n/**\n * Compose two 4×5 color matrices: out = outer ∘ inner (inner applied first).\n *\n * composed(x) = M_outer * (M_inner * x + b_inner) + b_outer\n * = (M_outer * M_inner) * x + (M_outer * b_inner + b_outer)\n *\n * Each matrix is row-major. The 4×4 portion occupies indices\n * [0..3, 5..8, 10..13, 15..18]; bias column at [4, 9, 14, 19].\n */\nfunction compose4x5(outer: Float32Array, inner: Float32Array): Float32Array {\n const result = new Float32Array(20);\n for (let row = 0; row < 4; row++) {\n for (let col = 0; col < 4; col++) {\n let sum = 0;\n for (let k = 0; k < 4; k++) {\n sum += outer[row * 5 + k] * inner[k * 5 + col];\n }\n result[row * 5 + col] = sum;\n }\n let biasSum = outer[row * 5 + 4];\n for (let k = 0; k < 4; k++) {\n biasSum += outer[row * 5 + k] * inner[k * 5 + 4];\n }\n result[row * 5 + 4] = biasSum;\n }\n return result;\n}\n\nexport class GroupState {\n private transformStack: GlMat3[] = [mat3.identity()];\n private alphaStack: number[] = [1];\n private colorMatrixStack: Float32Array[] = [IDENTITY_COLOR_MATRIX];\n\n get transform(): GlMat3 {\n return this.transformStack[this.transformStack.length - 1];\n }\n\n get alpha(): number {\n return this.alphaStack[this.alphaStack.length - 1];\n }\n\n get colorMatrix(): Float32Array {\n return this.colorMatrixStack[this.colorMatrixStack.length - 1];\n }\n\n push(frame: GroupFrame): void {\n const current = this.transform;\n const nextTransform = frame.transform ? mat3.multiply(current, frame.transform) : current;\n const nextAlpha = frame.alpha !== undefined ? this.alpha * frame.alpha : this.alpha;\n const nextCM = frame.colorMatrix\n ? compose4x5(\n this.colorMatrix,\n frame.colorMatrix instanceof Float32Array\n ? frame.colorMatrix\n : new Float32Array(frame.colorMatrix),\n )\n : this.colorMatrix;\n this.transformStack.push(nextTransform);\n this.alphaStack.push(nextAlpha);\n this.colorMatrixStack.push(nextCM);\n }\n\n /**\n * Push a frame whose children paint into a surface of their own.\n *\n * The transform still accumulates — the children draw where they would have\n * drawn. Alpha and colour do not: they describe how the finished surface\n * joins the frame, and applying them on the way in as well would fade the\n * pixels an effect is about to read, then fade them again on the way out.\n *\n * Returns the pair the caller must apply at composite time — what `push`\n * would have left on the stack — so the composition rules live here and not\n * in the dispatcher.\n */\n pushIsolated(frame: GroupFrame): { alpha: number; colorMatrix: Float32Array } {\n this.push(frame);\n const composited = { alpha: this.alpha, colorMatrix: this.colorMatrix };\n this.pop();\n const current = this.transform;\n this.transformStack.push(frame.transform ? mat3.multiply(current, frame.transform) : current);\n this.alphaStack.push(1);\n this.colorMatrixStack.push(IDENTITY_COLOR_MATRIX);\n return composited;\n }\n\n /** Drop every pushed frame, leaving the root. A frame that throws part-way\n * down the tree never pops, and the next frame would draw under leftovers. */\n reset(): void {\n this.transformStack.length = 1;\n this.alphaStack.length = 1;\n this.colorMatrixStack.length = 1;\n }\n\n pop(): void {\n if (this.transformStack.length <= 1) {\n throw new Error('GroupState.pop: cannot pop root frame');\n }\n this.transformStack.pop();\n this.alphaStack.pop();\n this.colorMatrixStack.pop();\n }\n}\n","/**\n * Kit-supplied vertex shader for a full-screen effect pass.\n *\n * Distinct from `CUSTOM_VERT_SRC` on purpose. That one places its quad through\n * `u_bounds` and `u_proj`, so its `v_uv` runs top-down in *screen* space; an\n * effect samples a texture the scene was just rendered into, whose v axis runs\n * the other way. Passing `a_position` straight to `gl_Position` and `a_uv`\n * straight out keeps the two aligned — `QUAD_VERTICES` already carries\n * `a_uv == (a_position + 1) / 2` on both axes.\n *\n * PUBLIC CONTRACT — what every effect fragment shader may read:\n *\n * in vec2 v_uv 0..1 across the source texture\n * uniform sampler2D u_source what has been drawn so far\n * uniform vec2 u_resolution source size in device pixels\n * uniform vec2 u_texel 1.0 / u_resolution — one texel step\n *\n * PREMULTIPLIED ALPHA: `u_source` holds premultiplied RGBA, because that is\n * what the scene blends into it. An effect that weights neighbouring samples\n * (a blur) is doing the right thing on premultiplied values; one that\n * manipulates rgb against a must premultiply its own output the same way the\n * custom-shader prelude requires.\n */\nexport const EFFECT_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nin vec2 a_uv;\nout vec2 v_uv;\n\nvoid main() {\n v_uv = a_uv;\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n`;\n\n/** Attribute names the effect vertex shader binds. Same layout as the custom\n * prelude's, so `QUAD_VERTICES` serves both. */\nexport const EFFECT_ATTRIBUTES = ['a_position', 'a_uv'] as const;\n\n/** Uniforms the renderer sets on every effect pass. An effect must not\n * redeclare them with different meanings; it may leave any of them out. */\nexport const EFFECT_KIT_UNIFORMS = ['u_source', 'u_resolution', 'u_texel'] as const;\n\n/** The pass that puts a group's finished texture back into its parent. Not an\n * effect — no consumer registers it — but it runs on the same quad and the\n * same vertex shader. `u_alpha` and the colour matrix are the parent group's,\n * applied here rather than inside the offscreen render, so an effect samples\n * the group's own pixels rather than pixels the parent has already faded. */\nexport const COMPOSITE_FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_uv;\nuniform sampler2D u_source;\nuniform float u_alpha;\nuniform mat4 u_colorMatrix;\nuniform vec4 u_colorBias;\nout vec4 outColor;\n\nvoid main() {\n vec4 src = texture(u_source, v_uv);\n // Undo premultiplication before the colour matrix, which is defined on\n // straight alpha, then put it back for the blend.\n float a = src.a;\n vec3 rgb = a > 0.0 ? src.rgb / a : vec3(0.0);\n vec4 c = u_colorMatrix * vec4(rgb, a) + u_colorBias;\n c.a *= u_alpha;\n outColor = vec4(clamp(c.rgb, 0.0, 1.0) * c.a, c.a);\n}\n`;\n","/**\n * The pass that puts a group's finished texture back into its parent, and the\n * shared mechanics every effect pass uses to draw a full-screen quad.\n *\n * Registered as an ordinary program so it compiles through the same\n * `ensureProgram` path a consumer's effect does — one compile path, one place\n * a compile failure is reported.\n */\nimport { getProgramSource, registerProgram } from '../shaders/registerProgram';\nimport { EFFECT_VERT_SRC, COMPOSITE_FRAG_SRC } from './effectPrelude';\n\n/** Reserved id. The `weasel:` prefix is not enforced anywhere; it is here so a\n * consumer reading a shader-compile error knows whose program it is. */\nexport const COMPOSITE_PROGRAM_ID = 'weasel:effect-composite';\n\n/**\n * The composite program's id, registering the program on first ask. Not done\n * at module load: a bundler may drop an import kept only for its side effect.\n */\nexport function compositeProgramId(): string {\n if (!getProgramSource(COMPOSITE_PROGRAM_ID)) {\n registerProgram(COMPOSITE_PROGRAM_ID, EFFECT_VERT_SRC, COMPOSITE_FRAG_SRC);\n }\n return COMPOSITE_PROGRAM_ID;\n}\n","import type { DrawContext } from './drawContext';\n\n/** Every GL draw the renderer issues goes through here, so the frame's\n * draw-call count cannot miss one. */\nexport function drawTriangles(ctx: DrawContext, count: number, type: number): void {\n ctx.gl.drawElements(ctx.gl.TRIANGLES, count, type, 0);\n if (ctx.stats) ctx.stats.drawCalls++;\n}\n","import type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\n\n// ─── Per-fragment clip test ───────────────────────────────────────────────────\n\n/**\n * Set the stencil test for the current clip depth. Called by every\n * fragment-producing draw before its drawElements call when clipDepth > 0.\n * At clipDepth = 0, disables STENCIL_TEST (zero-overhead common case).\n *\n * Note: not called by drawPathFillStencil / drawPathStrokeStenciled, which\n * manage their own stencil state (evenodd / inner-outer stencil). Those paths\n * coexist with clip bits because they use bit 0 exclusively while clip levels\n * occupy bits 1-7.\n */\nexport function applyClipTest(ctx: DrawContext, depth: number = ctx.clipDepth): void {\n const gl = ctx.gl;\n if (depth === 0) {\n gl.disable(gl.STENCIL_TEST);\n return;\n }\n const mask = ancestorMask(depth);\n gl.enable(gl.STENCIL_TEST);\n gl.stencilFunc(gl.EQUAL, mask, mask);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);\n}\n\n// ─── Clip-stencil helpers ────────────────────────────────────────────────────\n\n/**\n * Bit-mask for ancestor clip levels.\n * Returns bits 1..depth (inclusive).\n * depth=0 → 0x00; depth=1 → 0x02; depth=3 → 0x0E.\n */\nexport function ancestorMask(depth: number): number {\n return depth === 0 ? 0 : ((1 << (depth + 1)) - 1) & 0xFE;\n}\n\n/**\n * Write the bound even-odd mesh's parity to stencil bit 0, then leave the\n * test passing where that parity is odd and every enclosing clip holds. The\n * program, VAO, and model are the caller's, already bound.\n */\nexport function beginParityMask(ctx: DrawContext, indexCount: number): void {\n const gl = ctx.gl;\n gl.enable(gl.STENCIL_TEST);\n gl.colorMask(false, false, false, false);\n gl.stencilMask(0x01);\n gl.stencilFunc(gl.ALWAYS, 0, 0x01);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.INVERT);\n drawTriangles(ctx, indexCount, ctx.gl.UNSIGNED_INT);\n\n const clipMask = ancestorMask(ctx.clipDepth);\n gl.colorMask(true, true, true, true);\n gl.stencilFunc(gl.EQUAL, clipMask | 0x01, clipMask | 0x01);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);\n}\n\nexport function endParityMask(ctx: DrawContext): void {\n const gl = ctx.gl;\n // Narrow to bit 0 first: clear only zeroes bits the mask enables, and\n // pushClip owns bits 1-7.\n gl.stencilMask(0x01);\n gl.clear(gl.STENCIL_BUFFER_BIT);\n gl.disable(gl.STENCIL_TEST);\n}\n","import type { ShaderDrawCommand } from '../DrawCommand';\nimport { getTexture, type TextureHandle } from '../textures/registerTexture';\nimport type { ShaderUniform } from '../shaders/registerProgram';\nimport type { GLTextureCache } from '../cache/GLTextureCache';\nimport type { ShaderProgram, UniformArray } from '../shaders/ShaderProgram';\nimport { mat3 } from '@weasel-js/geom';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { applyClipTest } from './stencil';\n\nconst warnedUniforms = new Set<string>();\n\nexport function warnOnceUniform(programId: string, name: string): void {\n const key = `${programId}:${name}`;\n if (warnedUniforms.has(key)) return;\n warnedUniforms.add(key);\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n if (isDev) {\n console.warn(`weasel drawShader: uniform \"${name}\" not found in program \"${programId}\". ` +\n `Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`);\n }\n}\n\n/**\n * Bind a single ShaderUniform value to a GL uniform location.\n *\n * Type detection order:\n * 1. TextureHandle (object with string `.id`) — bind to next tex unit, set sampler.\n * 2. Float32Array — length 9 → mat3, length 16 → mat4. Other lengths throw in dev.\n * 3. Array — uniform2fv / uniform3fv / uniform4fv based on length.\n * 4. number — uniform1f.\n */\nexport function setUniform(\n gl: WebGL2RenderingContext,\n loc: WebGLUniformLocation,\n value: ShaderUniform,\n textureCache: GLTextureCache,\n nextTexUnit: { value: number },\n): void {\n if (value !== null && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Float32Array)\n && 'id' in value && typeof (value as TextureHandle).id === 'string') {\n const handle = value as TextureHandle;\n const entry = getTexture(handle.id);\n if (!entry) {\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n if (isDev) console.warn(`weasel setUniform: TextureHandle \"${handle.id}\" not registered`);\n return;\n }\n const unit = nextTexUnit.value++;\n // An upload binds and unbinds on the active unit, so it has to be this\n // uniform's own unit and not one an earlier sampler already holds.\n gl.activeTexture(gl.TEXTURE0 + unit);\n textureCache.uploadRegistered(handle.id, entry.source);\n textureCache.bind(handle.id, unit);\n gl.uniform1i(loc, unit);\n return;\n }\n\n // A kit matrix is in doubles; GL wants float32.\n if (value instanceof Float64Array) value = Float32Array.from(value);\n\n if (value instanceof Float32Array) {\n if (value.length === 9) {\n gl.uniformMatrix3fv(loc, false, value);\n } else if (value.length === 16) {\n gl.uniformMatrix4fv(loc, false, value);\n } else {\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n if (isDev) throw new TypeError(`weasel setUniform: Float32Array must be length 9 (mat3) or 16 (mat4), got ${value.length}`);\n }\n return;\n }\n\n if (Array.isArray(value)) {\n const arr = value as readonly number[];\n switch (arr.length) {\n case 2: gl.uniform2fv(loc, arr as [number, number]); break;\n case 3: gl.uniform3fv(loc, arr as [number, number, number]); break;\n case 4: gl.uniform4fv(loc, arr as [number, number, number, number]); break;\n default: {\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n if (isDev) throw new TypeError(`weasel setUniform: array length ${arr.length} not supported`);\n }\n }\n return;\n }\n\n if (typeof value === 'number') {\n gl.uniform1f(loc, value);\n return;\n }\n}\n\n/** How an array's element type is uploaded: the `uniform*v` call and the\n * number of components per element. */\nconst ARRAY_UPLOADS: Readonly<Record<string, { fn: string; n: number; matrix?: true }>> = {\n float: { fn: 'uniform1fv', n: 1 }, vec2: { fn: 'uniform2fv', n: 2 },\n vec3: { fn: 'uniform3fv', n: 3 }, vec4: { fn: 'uniform4fv', n: 4 },\n int: { fn: 'uniform1iv', n: 1 }, ivec2: { fn: 'uniform2iv', n: 2 },\n ivec3: { fn: 'uniform3iv', n: 3 }, ivec4: { fn: 'uniform4iv', n: 4 },\n bool: { fn: 'uniform1iv', n: 1 }, bvec2: { fn: 'uniform2iv', n: 2 },\n bvec3: { fn: 'uniform3iv', n: 3 }, bvec4: { fn: 'uniform4iv', n: 4 },\n uint: { fn: 'uniform1uiv', n: 1 }, uvec2: { fn: 'uniform2uiv', n: 2 },\n uvec3: { fn: 'uniform3uiv', n: 3 }, uvec4: { fn: 'uniform4uiv', n: 4 },\n mat2: { fn: 'uniformMatrix2fv', n: 4, matrix: true },\n mat3: { fn: 'uniformMatrix3fv', n: 9, matrix: true },\n mat4: { fn: 'uniformMatrix4fv', n: 16, matrix: true },\n mat2x2: { fn: 'uniformMatrix2fv', n: 4, matrix: true },\n mat3x3: { fn: 'uniformMatrix3fv', n: 9, matrix: true },\n mat4x4: { fn: 'uniformMatrix4fv', n: 16, matrix: true },\n mat2x3: { fn: 'uniformMatrix2x3fv', n: 6, matrix: true },\n mat2x4: { fn: 'uniformMatrix2x4fv', n: 8, matrix: true },\n mat3x2: { fn: 'uniformMatrix3x2fv', n: 6, matrix: true },\n mat3x4: { fn: 'uniformMatrix3x4fv', n: 12, matrix: true },\n mat4x2: { fn: 'uniformMatrix4x2fv', n: 8, matrix: true },\n mat4x3: { fn: 'uniformMatrix4x3fv', n: 12, matrix: true },\n};\n\ntype ArrayValue = readonly number[] | Float32Array | Int32Array | Uint32Array;\n\nfunction isArrayValue(value: ShaderUniform): value is ArrayValue {\n return Array.isArray(value) || value instanceof Float32Array\n || value instanceof Int32Array || value instanceof Uint32Array;\n}\n\n/** Fill an array uniform from slot 0 with one call. Throws in dev on a value\n * that is not a whole number of elements or overruns the declaration. */\nfunction setUniformArray(\n gl: WebGL2RenderingContext,\n name: string,\n arr: UniformArray,\n value: ArrayValue,\n): void {\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n const upload = ARRAY_UPLOADS[arr.type];\n if (!upload) {\n if (isDev) console.warn(`weasel setUniform: array uniform \"${name}\" has type ${arr.type}, which cannot be written as a whole`);\n return;\n }\n if (value.length % upload.n !== 0 || value.length > upload.n * arr.size) {\n if (isDev) {\n throw new TypeError(\n `weasel setUniform: \"${name}\" is ${arr.type}[${arr.size}], so its value must hold a multiple of ${upload.n} `\n + `numbers, at most ${upload.n * arr.size}; got ${value.length}`,\n );\n }\n return;\n }\n if (value.length === 0) return;\n const fn = (gl as unknown as Record<string, (...args: unknown[]) => void>)[upload.fn];\n if (upload.matrix) fn.call(gl, arr.location, false, value);\n else fn.call(gl, arr.location, value);\n}\n\n/** Write every entry of a command's `uniforms` map. A key naming an array\n * uniform with an array value fills the array; anything else goes to the\n * location of that exact name. */\nexport function setUniforms(\n gl: WebGL2RenderingContext,\n program: ShaderProgram,\n programId: string,\n uniforms: Record<string, ShaderUniform>,\n textureCache: GLTextureCache,\n nextTexUnit: { value: number },\n): void {\n for (const [name, value] of Object.entries(uniforms)) {\n const arr = program.uniformArray(name);\n if (arr && isArrayValue(value)) {\n setUniformArray(gl, name, arr, value);\n continue;\n }\n const loc = program.uniform(name);\n if (loc === undefined) {\n warnOnceUniform(programId, name);\n continue;\n }\n setUniform(gl, loc, value, textureCache, nextTexUnit);\n }\n}\n\nexport function drawShader(ctx: DrawContext, cmd: ShaderDrawCommand): void {\n const { gl, programRegistry, quadVbo, quadIbo, textureCache } = ctx;\n\n const program = programRegistry.get(cmd.program.id);\n if (!program) {\n console.warn(\n `weasel drawShader: program \"${cmd.program.id}\" not compiled on this renderer. ` +\n `Call renderer.registerProgram(handle) after the module-level registerProgram().`,\n );\n return;\n }\n if (!quadVbo || !quadIbo) {\n console.warn('weasel drawShader: quad geometry not initialized');\n return;\n }\n\n gl.useProgram(program.handle);\n\n const aPosLoc = program.attribute('a_position');\n const aUvLoc = program.attribute('a_uv');\n\n gl.bindBuffer(gl.ARRAY_BUFFER, quadVbo);\n if (aPosLoc !== undefined) {\n gl.enableVertexAttribArray(aPosLoc);\n gl.vertexAttribPointer(aPosLoc, 2, gl.FLOAT, false, 16, 0);\n }\n if (aUvLoc !== undefined) {\n gl.enableVertexAttribArray(aUvLoc);\n gl.vertexAttribPointer(aUvLoc, 2, gl.FLOAT, false, 16, 8);\n }\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, quadIbo);\n\n const proj = mat3.screenToClip(ctx.widthCss, ctx.heightCss);\n const uProj = program.uniform('u_proj');\n if (uProj !== undefined) gl.uniformMatrix3fv(uProj, false, mat3.toUniform(proj));\n\n const uBounds = program.uniform('u_bounds');\n if (uBounds !== undefined) {\n gl.uniform4f(uBounds, cmd.bounds.x, cmd.bounds.y, cmd.bounds.w, cmd.bounds.h);\n }\n\n const uView = program.uniform('u_view');\n if (uView !== undefined) gl.uniformMatrix3fv(uView, false, mat3.toUniform(ctx.state.transform));\n\n setUniforms(gl, program, cmd.program.id, cmd.uniforms, textureCache, { value: 1 });\n\n applyClipTest(ctx);\n drawTriangles(ctx, 6, ctx.gl.UNSIGNED_SHORT);\n\n if (aPosLoc !== undefined) gl.disableVertexAttribArray(aPosLoc);\n if (aUvLoc !== undefined) gl.disableVertexAttribArray(aUvLoc);\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n}\n","import type { ShaderProgram } from '../shaders/ShaderProgram';\nimport { mat3, type GlMat3 } from '@weasel-js/geom';\nimport { resolveColor } from '@weasel-js/paint';\nimport type { DrawContext } from './drawContext';\n\n/**\n * Uniform values a program already holds this frame.\n *\n * GL keeps uniform state per program object, so re-sending a value the program\n * already has buys nothing. `u_proj` is constant for the whole frame and\n * `u_colorMatrix` is the identity in every scene that does not use one, yet\n * both were re-sent for every command: at a few thousand commands the two were\n * most of the frame.\n *\n * Keyed on the `DrawContext`, which `WeaselRenderer.render` builds fresh per\n * frame, so the cache cannot outlive a frame and go stale against GL state\n * that changed between them.\n *\n * **Only for uniforms this module is the sole writer of.** `u_color` and\n * `u_alpha` qualify because every write of them goes through `setColorUniform`\n * / `setAlphaUniform` — keep it that way. A `gl.uniform4f(… 'u_color' …)` added\n * anywhere else leaves the cache believing a value the program no longer has,\n * and the wrong color is drawn until something else moves it.\n */\ninterface UploadedUniforms {\n proj?: Float32Array;\n model?: Float32Array;\n colorMatrix?: Float32Array;\n colorBias?: Float32Array;\n originX?: number;\n originY?: number;\n /** Held as plain numbers, not a `Float32Array`: the caller's values are\n * doubles, and round-tripping them through float32 would compare unequal\n * every time and never skip an upload. */\n color?: [number, number, number, number];\n alpha?: number;\n}\n\nconst FRAME_UPLOADS = new WeakMap<DrawContext, WeakMap<ShaderProgram, UploadedUniforms>>();\n\nconst FRAME_PROJ = new WeakMap<DrawContext, GlMat3>();\n\nfunction uploadedFor(ctx: DrawContext, prog: ShaderProgram): UploadedUniforms {\n let byProgram = FRAME_UPLOADS.get(ctx);\n if (!byProgram) {\n byProgram = new WeakMap();\n FRAME_UPLOADS.set(ctx, byProgram);\n }\n let uploaded = byProgram.get(prog);\n if (!uploaded) {\n uploaded = {};\n byProgram.set(prog, uploaded);\n }\n return uploaded;\n}\n\n/** Element-wise, so a caller that mutates a shared array in place is still\n * compared by value. A NaN anywhere compares unequal and re-uploads, which is\n * the safe direction. */\nexport function sameValues(prev: Float32Array | undefined, next: ArrayLike<number>): boolean {\n if (prev === undefined || prev.length !== next.length) return false;\n for (let i = 0; i < prev.length; i++) if (prev[i] !== next[i]) return false;\n return true;\n}\n\n/**\n * `u_color`, skipped when the program already holds it.\n *\n * Every writer of `u_color` goes through here — see `UploadedUniforms`. The\n * solid batch is what makes it worth caching: it holds the uniform at white\n * forever and flushed once per state change, so a mixed document re-sent the\n * same white a few hundred times a frame.\n */\nexport function setColorUniform(\n ctx: DrawContext, prog: ShaderProgram,\n r: number, g: number, b: number, a: number,\n): void {\n const loc = prog.uniform('u_color');\n if (loc === undefined) return;\n const uploaded = uploadedFor(ctx, prog);\n const prev = uploaded.color;\n if (prev !== undefined && prev[0] === r && prev[1] === g && prev[2] === b && prev[3] === a) {\n return;\n }\n ctx.gl.uniform4f(loc, r, g, b, a);\n uploaded.color = [r, g, b, a];\n}\n\n/** `u_alpha`, on the same terms as `setColorUniform`. */\nexport function setAlphaUniform(ctx: DrawContext, prog: ShaderProgram, alpha: number): void {\n const loc = prog.uniform('u_alpha');\n if (loc === undefined) return;\n const uploaded = uploadedFor(ctx, prog);\n if (uploaded.alpha === alpha) return;\n ctx.gl.uniform1f(loc, alpha);\n uploaded.alpha = alpha;\n}\n\n/** The screen→clip matrix depends only on the frame's dimensions. */\nfunction projFor(ctx: DrawContext): GlMat3 {\n let proj = FRAME_PROJ.get(ctx);\n if (!proj) {\n proj = mat3.toUniform(mat3.screenToClip(ctx.widthCss, ctx.heightCss));\n FRAME_PROJ.set(ctx, proj);\n }\n return proj;\n}\n\n/** Reused across draws: the transpose below rebuilt this every command. */\nconst COLOR_MATRIX_SCRATCH = new Float32Array(16);\n\nexport function setColorMatrixUniforms(\n ctx: DrawContext, prog: ShaderProgram,\n cm: Float32Array = ctx.state.colorMatrix, // row-major 4×5\n): void {\n const gl = ctx.gl;\n const uploaded = uploadedFor(ctx, prog);\n\n const mLoc = prog.uniform('u_colorMatrix');\n if (mLoc !== undefined) {\n for (let row = 0; row < 4; row++) {\n for (let col = 0; col < 4; col++) {\n COLOR_MATRIX_SCRATCH[col * 4 + row] = cm[row * 5 + col];\n }\n }\n if (!sameValues(uploaded.colorMatrix, COLOR_MATRIX_SCRATCH)) {\n gl.uniformMatrix4fv(mLoc, false, COLOR_MATRIX_SCRATCH);\n uploaded.colorMatrix = Float32Array.from(COLOR_MATRIX_SCRATCH);\n }\n }\n\n const bLoc = prog.uniform('u_colorBias');\n if (bLoc !== undefined) {\n const bias = [cm[4], cm[9], cm[14], cm[19]];\n if (!sameValues(uploaded.colorBias, bias)) {\n gl.uniform4f(bLoc, bias[0], bias[1], bias[2], bias[3]);\n uploaded.colorBias = Float32Array.from(bias);\n }\n }\n}\n\n/** A model translation at or past this many pixels is rebased before upload:\n * a float32 there is coarser than 1/128 px, and at 2^24 than a whole one. */\nexport const REBASE_TRANSLATION_PX = 65536;\n\nconst MODEL_SCRATCH = new Float32Array(9);\nconst PROJ_SCRATCH = new Float32Array(9);\n\n/**\n * `u_proj` and `u_model`, each skipped when the program already holds it.\n *\n * `model` is in doubles and the uniform is not. Far from the origin at high\n * zoom its translation is millions of pixels, which a float32 holds to a\n * whole pixel at best, and the shader then adds that to vertex coordinates\n * just as large. A program that declares `u_origin` computes\n * `u_model * (a_position - u_origin)`, so for a large translation this sends\n * the local point that lands on the screen's corner as `u_origin` and a model\n * whose translation is what is left over, a few pixels. Any origin draws the\n * same place; this one keeps every number the GPU touches screen-sized.\n */\nexport function setProjAndModel(\n ctx: DrawContext, prog: ShaderProgram,\n model: GlMat3 = ctx.state.transform,\n proj: GlMat3 = projFor(ctx),\n): void {\n const gl = ctx.gl;\n const uploaded = uploadedFor(ctx, prog);\n\n PROJ_SCRATCH.set(proj);\n if (!sameValues(uploaded.proj, PROJ_SCRATCH)) {\n gl.uniformMatrix3fv(prog.uniform('u_proj')!, false, PROJ_SCRATCH);\n uploaded.proj = Float32Array.from(PROJ_SCRATCH);\n }\n\n MODEL_SCRATCH.set(model);\n const originLoc = prog.uniform('u_origin');\n if (originLoc !== undefined) {\n let ox = 0;\n let oy = 0;\n const tx = model[6], ty = model[7];\n if (Math.abs(tx) >= REBASE_TRANSLATION_PX || Math.abs(ty) >= REBASE_TRANSLATION_PX) {\n const a = model[0], b = model[1], c = model[3], d = model[4];\n const det = a * d - b * c;\n // Rounded first: the shader subtracts the float32 it was sent.\n const lx = Math.fround((c * ty - d * tx) / det);\n const ly = Math.fround((b * tx - a * ty) / det);\n if (Number.isFinite(lx) && Number.isFinite(ly)) {\n ox = lx;\n oy = ly;\n MODEL_SCRATCH[6] = a * ox + c * oy + tx;\n MODEL_SCRATCH[7] = b * ox + d * oy + ty;\n }\n }\n if (uploaded.originX !== ox || uploaded.originY !== oy) {\n gl.uniform2f(originLoc, ox, oy);\n uploaded.originX = ox;\n uploaded.originY = oy;\n }\n }\n\n if (!sameValues(uploaded.model, MODEL_SCRATCH)) {\n gl.uniformMatrix3fv(prog.uniform('u_model')!, false, MODEL_SCRATCH);\n uploaded.model = Float32Array.from(MODEL_SCRATCH);\n }\n}\n\nexport function setSolidPaintUniforms(\n ctx: DrawContext, prog: ShaderProgram,\n color: string, opacity: number | undefined,\n): void {\n const [r, g, b, a] = resolveColor(color);\n setColorUniform(ctx, prog, r, g, b, a * (opacity ?? 1));\n setAlphaUniform(ctx, prog, ctx.state.alpha);\n}\n","import type { ShaderUniform } from '../shaders/registerProgram';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { setColorMatrixUniforms } from './uniforms';\nimport { setUniforms } from './customShader';\n\n/** Rebind `ctx.renderTarget` after an offscreen pass: a pooled target takes\n * the whole `width` × `height` buffer, the default framebuffer the renderer's\n * own rect and the scissor it had. */\nexport function returnToRenderTarget(\n ctx: DrawContext, width: number, height: number, scissorWasOn: boolean,\n): void {\n const gl = ctx.gl;\n const target = ctx.renderTarget ?? null;\n gl.bindFramebuffer(gl.FRAMEBUFFER, target ? target.fbo : null);\n if (target) {\n gl.viewport(0, 0, width, height);\n } else {\n ctx.restoreTargetRect?.();\n if (scissorWasOn) gl.enable(gl.SCISSOR_TEST);\n }\n}\n\n/** One pass: the kit quad, `u_source` bound to `texture`, and whatever else\n * the caller supplies. Leaves no attribute arrays or buffers bound. */\nexport function drawFullscreenQuad(\n ctx: DrawContext,\n program: ShaderProgram,\n texture: WebGLTexture,\n width: number,\n height: number,\n uniforms?: Record<string, ShaderUniform>,\n composite?: { alpha: number; colorMatrix: Float32Array },\n programId?: string,\n): void {\n const gl = ctx.gl;\n gl.useProgram(program.handle);\n\n const aPos = program.attribute('a_position');\n const aUv = program.attribute('a_uv');\n gl.bindBuffer(gl.ARRAY_BUFFER, ctx.quadVbo);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ctx.quadIbo);\n if (aPos !== undefined && aPos >= 0) {\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);\n }\n if (aUv !== undefined && aUv >= 0) {\n gl.enableVertexAttribArray(aUv);\n gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);\n }\n\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n const source = program.uniform('u_source');\n if (source !== undefined) gl.uniform1i(source, 0);\n const resolution = program.uniform('u_resolution');\n if (resolution !== undefined) gl.uniform2f(resolution, width, height);\n const texel = program.uniform('u_texel');\n if (texel !== undefined) gl.uniform2f(texel, 1 / width, 1 / height);\n\n if (composite) {\n const alpha = program.uniform('u_alpha');\n if (alpha !== undefined) gl.uniform1f(alpha, composite.alpha);\n setColorMatrixUniforms(ctx, program, composite.colorMatrix);\n }\n\n // Unit 0 is `u_source`; a consumer texture starts above it.\n if (uniforms) setUniforms(gl, program, programId ?? 'effect', uniforms, ctx.textureCache, { value: 1 });\n\n drawTriangles(ctx, 6, ctx.gl.UNSIGNED_SHORT);\n\n if (aPos !== undefined && aPos >= 0) gl.disableVertexAttribArray(aPos);\n if (aUv !== undefined && aUv >= 0) gl.disableVertexAttribArray(aUv);\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n}\n","import type { Path } from '@weasel-js/geom';\nimport type { GLMeshHandle } from '../cache/GLMeshCache';\nimport { getMesh } from '../cache/cache';\nimport { tessellate, type Mesh } from '@weasel-js/geom/tessellate';\nimport type { DrawContext } from './drawContext';\n\n/**\n * Tessellate a fill honoring ctx.flattenTolerance: default route is the\n * persistent Path-identity cache; a custom tolerance tessellates fresh, because\n * the persistent cache's key does not include tolerance.\n */\nexport function fillMesh(ctx: DrawContext, path: Path): Mesh {\n if (ctx.flattenTolerance !== undefined) {\n return tessellate(path, { flattenTolerance: ctx.flattenTolerance });\n }\n return getMesh(path);\n}\n\n/** Upload a mesh for its own draw. A freshly tessellated one rides the\n * transient pool, freed at end of frame. */\nexport function meshHandle(ctx: DrawContext, mesh: Mesh): GLMeshHandle {\n if (ctx.flattenTolerance !== undefined) return ctx.meshCache.uploadTransient(mesh);\n return ctx.meshCache.handleFor(mesh);\n}\n\nexport function fillMeshHandle(ctx: DrawContext, path: Path): GLMeshHandle {\n return meshHandle(ctx, fillMesh(ctx, path));\n}\n","import { mat3 } from '@weasel-js/geom';\nimport { BATCH_TEXTURE_SLOTS } from '../shaders/batchFill';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport {\n setColorUniform,\n setAlphaUniform,\n setColorMatrixUniforms,\n setProjAndModel,\n} from './uniforms';\nimport { applyClipTest } from './stencil';\n\n/** The rect batch transforms its own corners, so it draws at model identity. */\nexport const BATCH_MODEL = mat3.identity();\n\n/** `u_samplers[i] = i`, uploaded whole per flush. Built once: the mapping from\n * slot to texture unit is the identity and never varies. */\nconst SAMPLER_UNITS = new Int32Array(\n Array.from({ length: BATCH_TEXTURE_SLOTS }, (_, i) => i),\n);\n\n/** `u_fieldScale`, per slot: an atlas slot's `glyphFieldScale`. Slots that are\n * not atlases keep whatever a previous flush wrote, which nothing reads. */\nconst FIELD_SCALES = new Float32Array(2 * BATCH_TEXTURE_SLOTS);\n\n/**\n * Draw the staged run as one `drawElements`, under the state it was staged\n * under. Callers that are about to bind a different program, or paint anything\n * that must land on top of the run, call this first; a group that only changes\n * the color matrix does not, because `pushRect` notices and flushes then, and\n * one that only changes transform or alpha does not break the run at all.\n *\n * Stencil clips are the exception: the stencil is real GL state that the\n * staged values cannot reconstruct, so `pushClip` flushes *before* writing a\n * bit, and `popClip` before clearing one a staged run tests. Rect clips never\n * reach the stencil while only staged geometry is inside them — see\n * `enterClip`.\n *\n * `u_color` stays white: the vertex-color program multiplies it by the\n * per-vertex color, so white makes the result bit-identical to the flat\n * program's `u_color`-only math. `u_model` stays identity for the same reason —\n * the corners arrive already transformed.\n */\nexport function flushBatch(ctx: DrawContext): void {\n const batch = ctx.drawBatch;\n const staged = ctx.batchState;\n if (batch.length === 0 || staged === undefined) {\n // An empty run's state still names a clip depth, and an item refused by\n // the CPU cut is about to be staged again under a different one.\n ctx.batchState = undefined;\n return;\n }\n const gl = ctx.gl;\n const prog = ctx.batchFill;\n gl.useProgram(prog.handle);\n const indexCount = batch.uploadAndBind();\n setProjAndModel(ctx, prog, BATCH_MODEL);\n setColorUniform(ctx, prog, 1, 1, 1, 1);\n setAlphaUniform(ctx, prog, staged.alpha);\n gl.uniform1f(prog.uniform('u_synthBold')!, staged.synthBold);\n setColorMatrixUniforms(ctx, prog, staged.colorMatrix);\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, ctx.whiteTexture);\n for (let i = 0; i < staged.textures.length; i++) {\n const entry = staged.textures[i];\n if (entry.kind === 'atlas') {\n ctx.textureCache.bind(entry.id, i + 1);\n FIELD_SCALES[2 * (i + 1)] = entry.fieldScale[0];\n FIELD_SCALES[2 * (i + 1) + 1] = entry.fieldScale[1];\n continue;\n }\n if (entry.kind === 'ramps') {\n ctx.gradRamps.bind(i + 1);\n continue;\n }\n ctx.imageCache.bind(entry.image, i + 1);\n // Per flush, not at upload: the same bitmap can be drawn at both filters in\n // one frame. The cache skips the write when the texture already carries the\n // value, which is most flushes.\n ctx.imageCache.setMagFilter(\n entry.image,\n entry.sampling === 'nearest' ? gl.NEAREST : gl.LINEAR,\n );\n }\n gl.uniform1iv(prog.uniform('u_samplers')!, SAMPLER_UNITS);\n gl.uniform2fv(prog.uniform('u_fieldScale')!, FIELD_SCALES);\n applyClipTest(ctx, staged.clipDepth);\n drawTriangles(ctx, indexCount, ctx.gl.UNSIGNED_INT);\n // Everything else in the renderer binds its texture to unit 0 and some of it\n // does so without an `activeTexture` of its own, so leaving unit 6 selected\n // sends the next such bind to a unit nothing samples.\n gl.activeTexture(gl.TEXTURE0);\n // Not redundant: `drawShader` binds no VAO and points attributes at whatever\n // is current, so a slot left bound here comes back corrupted a ring later.\n gl.bindVertexArray(null);\n batch.reset();\n ctx.batchState = undefined;\n}\n","import type { Path, GlMat3 } from '@weasel-js/geom';\nimport { axisAlignedClipRect, intersectClipRects, type ClipRect } from '../batchClip';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { fillMeshHandle } from './mesh';\nimport { setProjAndModel } from './uniforms';\nimport { ancestorMask } from './stencil';\nimport { flushBatch } from './flushBatch';\n\n/** `enterClip` for a group command, refusing one past the stencil's budget. */\nexport function enterGroupClip(ctx: DrawContext, clip: Path): void {\n const pending = ctx.clipStack.reduce((n, e) => n + (e.depth === 0 ? 1 : 0), 0);\n if (ctx.clipDepth + pending + 1 > 7) {\n throw new Error(\n 'weasel: clip nesting depth exceeded (max 7). You can\\'t nest more than 7 levels ' +\n 'of clipped containers in a single draw tree. Flatten the hierarchy or compose ' +\n 'poses outside the scene graph.',\n );\n }\n enterClip(ctx, clip);\n}\n\n/**\n * Push a group's clip.\n *\n * A clip only the stencil can express takes its bit now. An axis-aligned rect\n * takes none: staged geometry is cut to it on the CPU (`batchClip.ts`), so\n * content inside it joins the run outside it instead of costing a flush on\n * the way in and another on the way out. It takes a bit only if something that\n * draws for itself turns up inside it — see `flushForOwnDraw`.\n */\nfunction enterClip(ctx: DrawContext, path: Path): void {\n const transform = ctx.state.transform;\n const rect = axisAlignedClipRect(path, transform);\n if (rect === null) {\n // Bits nest in stack order, so any rect clip still without one takes it\n // first.\n materializeClips(ctx);\n const depth = ctx.clipDepth + 1;\n pushClip(ctx, path, depth);\n ctx.clipDepth = depth;\n ctx.clipStack.push({ path, transform, rect: null, depth });\n } else {\n ctx.clipStack.push({ path, transform, rect, depth: 0 });\n }\n syncBatchClip(ctx);\n}\n\nexport function leaveClip(ctx: DrawContext): void {\n const entry = ctx.clipStack.pop()!;\n if (entry.depth > 0) {\n popClip(ctx, entry.path, entry.depth - 1, entry.transform);\n ctx.clipDepth = entry.depth - 1;\n }\n syncBatchClip(ctx);\n}\n\n/** Give every rect clip on the stack its stencil bit, for a draw the CPU cut\n * cannot reach. */\nfunction materializeClips(ctx: DrawContext): void {\n for (const entry of ctx.clipStack) {\n if (entry.depth !== 0) continue;\n const depth = ctx.clipDepth + 1;\n pushClip(ctx, entry.path, depth, entry.transform);\n entry.depth = depth;\n ctx.clipDepth = depth;\n }\n}\n\nfunction syncBatchClip(ctx: DrawContext): void {\n let rect: ClipRect | null = null;\n for (const entry of ctx.clipStack) {\n if (entry.rect) rect = rect ? intersectClipRects(rect, entry.rect) : entry.rect;\n }\n ctx.drawBatch.clip = rect;\n}\n\n/**\n * The clip depth a run is staged and drawn at: the innermost clip only the\n * stencil can express. Rect clips are left out whether or not they hold a bit,\n * because the CPU cut already applies them — which is what lets a run cross\n * them.\n */\nexport function runClipDepth(ctx: DrawContext): number {\n const stack = ctx.clipStack;\n if (stack.length === 0 || ctx.uncut) return ctx.clipDepth;\n for (let i = stack.length - 1; i >= 0; i--) {\n if (stack[i].rect === null) return stack[i].depth;\n }\n // Only rect clips: whatever depth held before the first of them took a bit.\n for (const entry of stack) if (entry.depth > 0) return entry.depth - 1;\n return ctx.clipDepth;\n}\n\n/**\n * Put the rect clips on the stencil and stop cutting, for an item the batch\n * refused to cut — one with a slanted edge across a clip (see\n * `DrawBatch.clipQuad`). Staged again between this and `leaveUncut`, the item\n * sees the full stencil depth and lands in a run of its own under every clip.\n * Returns the cut to hand back.\n *\n * A pair rather than a callback: the staging paths are hot, and a closure\n * over their arguments would cost an allocation on every call, refused or not.\n */\nexport function enterUncut(ctx: DrawContext): ClipRect | null {\n materializeClips(ctx);\n const cut = ctx.drawBatch.clip;\n ctx.drawBatch.clip = null;\n ctx.uncut = true;\n return cut;\n}\n\nexport function leaveUncut(ctx: DrawContext, cut: ClipRect | null): void {\n ctx.drawBatch.clip = cut;\n ctx.uncut = false;\n}\n\n/** `fn(ctx, a, b)` again, uncut — for the stage-and-push helpers, which pass\n * themselves. */\nexport function retryUncut<A, B>(\n ctx: DrawContext, a: A, b: B, fn: (ctx: DrawContext, a: A, b: B) => void,\n): void {\n const cut = enterUncut(ctx);\n fn(ctx, a, b);\n leaveUncut(ctx, cut);\n}\n\n/**\n * Drain the run before a draw that does not go through it, and give that draw\n * the stencil it tests against. Every such draw starts here or behind a\n * `tryStageFill` that returned `false`, which ends the same way.\n */\nexport function flushForOwnDraw(ctx: DrawContext): void {\n flushBatch(ctx);\n if (ctx.clipStack.length > 0) materializeClips(ctx);\n}\n\n/**\n * Rasterize a path into the stencil buffer using the pathFill shader geometry.\n * The caller is responsible for setting stencilFunc / stencilOp / stencilMask\n * and colorMask before calling.\n */\nfunction rasterizePathToStencil(ctx: DrawContext, path: Path, model: GlMat3): void {\n const gl = ctx.gl;\n const handle = fillMeshHandle(ctx, path);\n gl.useProgram(ctx.pathFill.handle);\n gl.bindVertexArray(handle.vao);\n setProjAndModel(ctx, ctx.pathFill, model);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n gl.bindVertexArray(null);\n}\n\n/**\n * Push a clip level. Rasterizes the clip path into the stencil buffer,\n * setting bit `newDepth` where (a) the path's fragment passes AND (b) all\n * ancestor clip bits are already set.\n *\n * Invariant: restores stencilMask(0xFF) on exit so callers (draw functions)\n * can rely on an unnarrowed mask after clip ops complete.\n */\nexport function pushClip(\n ctx: DrawContext, path: Path, newDepth: number, model: GlMat3 = ctx.state.transform,\n): void {\n // First, not last: a run staged outside the clip would otherwise draw under\n // a mask it never had.\n flushBatch(ctx);\n const gl = ctx.gl;\n const ancestors = ancestorMask(newDepth - 1);\n const newBit = 1 << newDepth;\n const ref = ancestors | newBit;\n\n gl.enable(gl.STENCIL_TEST);\n gl.colorMask(false, false, false, false);\n if (fillMeshHandle(ctx, path).requiresStencil) {\n // Fans, one per contour: their union is not the path. Parity goes on\n // bit 0, the clip bit is written where parity is odd, and drawing the\n // fans a third time returns bit 0 to zero.\n gl.stencilMask(0x01);\n gl.stencilFunc(gl.ALWAYS, 0, 0x01);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.INVERT);\n rasterizePathToStencil(ctx, path, model);\n gl.stencilMask(newBit);\n gl.stencilFunc(gl.EQUAL, ref | 0x01, ancestors | 0x01);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);\n rasterizePathToStencil(ctx, path, model);\n gl.stencilMask(0x01);\n gl.stencilFunc(gl.ALWAYS, 0, 0x01);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.INVERT);\n rasterizePathToStencil(ctx, path, model);\n } else {\n gl.stencilMask(newBit);\n gl.stencilFunc(gl.EQUAL, ref, ancestors);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);\n rasterizePathToStencil(ctx, path, model);\n }\n\n gl.colorMask(true, true, true, true);\n // Restore full mask so subsequent draw functions don't inherit a narrowed mask.\n gl.stencilMask(0xFF);\n}\n\n/**\n * Pop a clip level. Rasterizes the same path again, clearing bit\n * `oldDepth + 1` where it was set during the matching push.\n *\n * Must re-enable STENCIL_TEST because child draw functions (drawPathFillStencil,\n * drawPathStrokeStenciled) call gl.disable(STENCIL_TEST) at their end. If\n * one of those was the last child before popClip runs, the test would be off\n * and rasterizePathToStencil would write nothing.\n *\n * Invariant: restores stencilMask(0xFF) on exit so callers are not left with\n * a narrowed mask.\n */\nexport function popClip(\n ctx: DrawContext, path: Path, oldDepth: number, model: GlMat3 = ctx.state.transform,\n): void {\n // First, not last: past here the mask is gone, and these pixels belonged\n // inside it. A run staged below this bit does not test it, so it lives on.\n if (ctx.batchState !== undefined && ctx.batchState.clipDepth > oldDepth) flushBatch(ctx);\n const gl = ctx.gl;\n // Re-enable stencil: child draw functions (evenodd/stenciled-stroke) disable\n // it at their end; we must set it before writing the clear pass.\n gl.enable(gl.STENCIL_TEST);\n\n const oldBit = 1 << (oldDepth + 1);\n const ref = ancestorMask(oldDepth) | oldBit;\n\n gl.colorMask(false, false, false, false);\n gl.stencilMask(oldBit);\n gl.stencilFunc(gl.EQUAL, ref, ref);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.ZERO);\n\n rasterizePathToStencil(ctx, path, model);\n\n gl.colorMask(true, true, true, true);\n // Restore full mask so subsequent draw functions don't inherit a narrowed mask.\n gl.stencilMask(0xFF);\n}\n","import type { CommandFill, MarkerRef, CommandStroke } from '@weasel-js/paint';\nimport type { PathDrawCommand } from './DrawCommand';\nimport type { GlMat3 } from '@weasel-js/geom';\nimport { resolveStrokeWidth } from '@weasel-js/stroke';\nimport {\n strokeSpaceOf, type ScreenSpace, type StrokeSpaces,\n} from '@weasel-js/stroke';\nimport { quantizeStrokeScale } from './cache/strokeMeshCache';\nimport { resolveMarkerSize } from '@weasel-js/stroke';\n\n/** A path command whose stroke paints. */\nexport type StrokedPathCommand = PathDrawCommand & { stroke: CommandStroke & { paint: CommandFill } };\n\n/** A stroke command ready to tessellate, and the spaces to tessellate it in. */\nexport interface ResolvedStrokeCommand {\n cmd: StrokedPathCommand;\n /** Where the ribbon and each head are built; every length in `cmd` is\n * measured in the space of the part it belongs to. */\n spaces: StrokeSpaces;\n}\n\nconst WORLD: StrokeSpaces = {};\n\n/**\n * `cmd` with its `{ px }` lengths — the stroke width, any marker size, and on a\n * `{ px }` stroke its dashes — resolved against the accumulated transform's\n * quantized scale, so everything downstream (the ribbon cache key, the insets,\n * the heads) sees plain numbers.\n *\n * Under a transform that stretches one direction more than another, each\n * screen-sized part is also built in the transform's stretch, where lengths\n * measure as they do on screen, so it is exact across, down and on every\n * diagonal rather than right only on average. World-sized parts stay in world.\n */\nexport function resolveStrokeLengths(transform: GlMat3, cmd: StrokedPathCommand): ResolvedStrokeCommand {\n const stroke = cmd.stroke;\n const { markerStart, markerMid, markerEnd } = stroke;\n if (typeof stroke.width !== 'object' && !isPxMarker(markerStart)\n && !isPxMarker(markerMid) && !isPxMarker(markerEnd)) {\n return { cmd, spaces: WORLD };\n }\n const resolved: CommandStroke & { paint: CommandFill } = { ...stroke };\n const { scale, metric } = strokeSpaceOf(transform[0], transform[1], transform[3], transform[4]);\n const screen = (pxPerUnit: number): ScreenSpace | undefined =>\n metric === null ? undefined : { metric, pxPerUnit };\n let ribbon: ScreenSpace | undefined;\n if (typeof stroke.width === 'object') {\n const pxPerUnit = quantizeStrokeScale(stroke.width.px, scale);\n resolved.width = resolveStrokeWidth(stroke.width, pxPerUnit);\n if (stroke.dash && pxPerUnit > 0) resolved.dash = stroke.dash.map((d) => d / pxPerUnit);\n ribbon = screen(pxPerUnit);\n }\n const head = (ref: MarkerRef | undefined): ScreenSpace | undefined => {\n if (ref === undefined || typeof ref === 'string' || ref.size === undefined) return ribbon;\n if (typeof ref.size === 'number') return undefined;\n return screen(quantizeStrokeScale(ref.size.px, scale));\n };\n const spaces = { ribbon, start: head(markerStart), mid: head(markerMid), end: head(markerEnd) };\n if (isPxMarker(markerStart)) resolved.markerStart = resolvedMarker(markerStart, scale);\n if (isPxMarker(markerMid)) resolved.markerMid = resolvedMarker(markerMid, scale);\n if (isPxMarker(markerEnd)) resolved.markerEnd = resolvedMarker(markerEnd, scale);\n return { cmd: { ...cmd, stroke: resolved }, spaces };\n}\n\ntype PxMarker = Exclude<MarkerRef, string> & { size: { px: number } };\n\nfunction isPxMarker(ref: MarkerRef | undefined): ref is PxMarker {\n return typeof ref === 'object' && typeof ref.size === 'object';\n}\n\nfunction resolvedMarker(ref: PxMarker, scale: number): MarkerRef {\n return { ...ref, size: resolveMarkerSize(ref, 0, quantizeStrokeScale(ref.size.px, scale)) };\n}\n","import type { ColorSpace, FillStyle, GradientUnits, GradStop } from '@weasel-js/paint';\nimport { mat3, type GlMat3 } from '@weasel-js/geom';\nimport type { GradientUV } from '../drawBatch';\nimport { PAINT_MODE_PLAIN, PAINT_MODE_RADIAL, PAINT_MODE_CONIC } from '../shaders/batchFill';\nimport type { DrawContext } from './drawContext';\n\n/** A paint a run can express, resolved from a `FillStyle` by `batchPaint`. */\nexport type BatchPaint =\n | { kind: 'solid'; color: string; opacity?: number }\n | {\n kind: 'ramp'; stops: GradStop[]; space: ColorSpace; opacity?: number;\n /** `PAINT_MODE_PLAIN` for a linear gradient, whose ramp position a vertex\n * carries outright; `PAINT_MODE_RADIAL` / `PAINT_MODE_CONIC` otherwise. */\n mode: number;\n uv: GradientUV;\n };\n\n/**\n * `fill` as something a run can carry, or `undefined` for a paint no run can\n * express — a pattern, a shader, per-vertex colors — and `null` for a gradient\n * whose space has no inverse under this transform, which draws nothing.\n *\n * **All three gradients qualify, and for the same reason,** which is not that\n * their ramp position is affine in position — only a linear gradient's is. It\n * is that the *coordinate* the ramp position is computed from is affine in all\n * three, so a vertex can carry that and the rasterizer's interpolation across a\n * triangle is exact. A linear gradient's coordinate is the ramp position\n * itself, which is why it needs no paint mode; the other two carry a\n * gradient-space point and the shader takes a `length` or an `atan` of it.\n */\nexport function batchPaint(\n ctx: DrawContext, fill: FillStyle, hasVColors: boolean,\n): BatchPaint | undefined | null {\n if (hasVColors) return undefined;\n const kind = fill.fill ?? 'solid';\n if (kind === 'solid') {\n const solid = fill as { color: string; opacity?: number };\n return { kind: 'solid', color: solid.color, opacity: solid.opacity };\n }\n if (kind !== 'linear-gradient' && kind !== 'radial-gradient' && kind !== 'conic-gradient') {\n return undefined;\n }\n const grad = fill as Extract<FillStyle, { fill: 'linear-gradient' | 'radial-gradient' | 'conic-gradient' }>;\n const g = gradientMap(ctx, grad.units);\n if (!g) return null;\n if (grad.fill === 'linear-gradient') return ramp(grad, PAINT_MODE_PLAIN, linearRampUV(g, grad));\n if (grad.fill === 'radial-gradient') return ramp(grad, PAINT_MODE_RADIAL, radialRampUV(g, grad));\n return ramp(grad, PAINT_MODE_CONIC, conicRampUV(g, grad));\n}\n\nfunction ramp(\n fill: { stops: GradStop[]; interpolate?: ColorSpace; opacity?: number },\n mode: number, uv: GradientUV,\n): BatchPaint {\n return {\n kind: 'ramp', stops: fill.stops, space: fill.interpolate ?? 'rgb',\n opacity: fill.opacity, mode, uv,\n };\n}\n\n/**\n * Geometry-space → gradient-space, as the one matrix a vertex is measured\n * through.\n *\n * `gradientSpaceInverse` maps a screen position back into the gradient's space\n * and the batch's vertices arrive before the model transform, so the two\n * compose. This is the composition `gradFill`'s vertex shader does in two\n * steps, and the pair have to agree: a radial gradient goes through that one\n * and a linear one through this.\n */\nfunction gradientMap(ctx: DrawContext, units: GradientUnits | undefined): GlMat3 | null {\n const inverse = gradientSpaceInverse(ctx, units);\n return inverse && mat3.multiply(inverse, ctx.state.transform);\n}\n\n/**\n * The gradient shader's `dot(p - from, dir) / len` folded into `u`, with `v`\n * left for the atlas row `stageRamps` fills in.\n */\nfunction linearRampUV(\n g: GlMat3, fill: Extract<FillStyle, { fill: 'linear-gradient' }>,\n): GradientUV {\n const dx = fill.to.x - fill.from.x;\n const dy = fill.to.y - fill.from.y;\n const len = Math.hypot(dx, dy) || 1;\n // dir is (dx, dy)/len and the divisor is len, so the pair is 1/len².\n const k = 1 / (len * len);\n return {\n ux: (g[0] * dx + g[1] * dy) * k,\n uy: (g[3] * dx + g[4] * dy) * k,\n u0: ((g[6] - fill.from.x) * dx + (g[7] - fill.from.y) * dy) * k,\n vx: 0, vy: 0, v0: 0,\n };\n}\n\n/** The gradient-space point scaled so its distance from the center *is* the\n * ramp position, which is what makes the shader's half a `length`. */\nfunction radialRampUV(\n g: GlMat3, fill: Extract<FillStyle, { fill: 'radial-gradient' }>,\n): GradientUV {\n // The floor is `gradFill`'s own `max(u_gradRadius, 0.0001)`.\n const k = 1 / Math.max(fill.radius, 1e-4);\n return {\n ux: g[0] * k, uy: g[3] * k, u0: (g[6] - fill.center.x) * k,\n vx: g[1] * k, vy: g[4] * k, v0: (g[7] - fill.center.y) * k,\n };\n}\n\n/**\n * The gradient-space point about the center, turned by `-angle` so the shader's\n * half is an `atan` of it and nothing else.\n *\n * `gradFill` subtracts the angle from the arctangent instead. The two agree\n * because rotating a point turns its arctangent by the same amount, and the\n * `fract` that follows takes care of the wrap either way.\n */\nfunction conicRampUV(\n g: GlMat3, fill: Extract<FillStyle, { fill: 'conic-gradient' }>,\n): GradientUV {\n const cos = Math.cos(fill.angle);\n const sin = Math.sin(fill.angle);\n const dx0 = g[6] - fill.center.x;\n const dy0 = g[7] - fill.center.y;\n return {\n ux: cos * g[0] + sin * g[1],\n uy: cos * g[3] + sin * g[4],\n u0: cos * dx0 + sin * dy0,\n vx: cos * g[1] - sin * g[0],\n vy: cos * g[4] - sin * g[3],\n v0: cos * dy0 - sin * dx0,\n };\n}\n\n/**\n * What a gradient's vertices carry once its row is known.\n *\n * A linear gradient's `a_uv` is (ramp position, row) and its `a_post` is the\n * plain 1, because that is what the plain paint mode already samples. A radial\n * or conic one needs both `a_uv` channels for its coordinate, so its row goes\n * in `a_post` — which no gradient uses for alpha, its opacity riding the vertex\n * color instead.\n */\nexport function rampVertices(\n paint: Extract<BatchPaint, { kind: 'ramp' }>, rowV: number,\n): { uv: GradientUV; post: number } {\n return paint.mode === PAINT_MODE_PLAIN\n ? { uv: { ...paint.uv, v0: rowV }, post: 1 }\n : { uv: paint.uv, post: rowV };\n}\n\n/**\n * Screen→gradient-space matrix for `u_worldInv`, which the vertex shader\n * applies to each fragment's screen position to recover the coordinates the\n * gradient's geometry is expressed in.\n *\n * `'world'` silently degrades to screen space when no view matrix reached\n * the renderer — `render(commands)` without a view is a supported call, and\n * a missing view is not worth a thrown frame. `null` when the space has no\n * inverse; a paint measured in it draws nothing.\n */\nexport function gradientSpaceInverse(ctx: DrawContext, units: GradientUnits | undefined): GlMat3 | null {\n if (units === 'local') return mat3.invert(ctx.state.transform);\n if (units === 'world' && ctx.viewMatrix) return mat3.invert(ctx.viewMatrix);\n return mat3.identity();\n}\n\n/** The paint space `units` names → device pixels: the forward transform\n * `gradientSpaceInverse` undoes, scaled by the target's pixel ratio. */\nexport function spaceToDevice(ctx: DrawContext, units: GradientUnits | undefined): GlMat3 | null {\n const inverse = gradientSpaceInverse(ctx, units);\n const toScreen = inverse && mat3.invert(inverse);\n if (!toScreen) return null;\n const ratio = ctx.deviceWidth && ctx.widthCss > 0 ? ctx.deviceWidth / ctx.widthCss : 1;\n return mat3.multiply(mat3.scaled(mat3.identity(), ratio, ratio), toScreen);\n}\n","import type { ColorSpace, GradStop } from '@weasel-js/paint';\nimport { IDENTITY_COLOR_MATRIX } from '../state/GroupState';\nimport type { Mesh } from '@weasel-js/geom/tessellate';\nimport { resolveColor } from '@weasel-js/paint';\nimport { BATCH_TEXTURE_SLOTS } from '../shaders/batchFill';\nimport type { DrawContext } from './drawContext';\nimport { sameValues } from './uniforms';\nimport { runClipDepth, retryUncut, flushForOwnDraw } from './clip';\nimport { flushBatch } from './flushBatch';\nimport { type BatchPaint, rampVertices } from './gradient';\n\n/**\n * The group state a staged run was built under.\n *\n * A run outlives the group it started in, so the state live when the flush\n * happens is not the state the rects belong to — the flush draws with these\n * values instead. Transform is absent because it rides the vertices; `alpha`\n * is 1 whenever it rode them too.\n */\nexport interface StagedBatchState {\n alpha: number;\n colorMatrix: Float32Array;\n clipDepth: number;\n /**\n * The SDF threshold shift `u_synthBold` draws this run under.\n *\n * A uniform rather than a vertex attribute, and so a thing that breaks a run.\n * A per-vertex float costs every rect and quad in the run (see \"Mode and slot\n * share one attribute\" in `shaders/batchFill.ts`): the batch's whole point is\n * one cheap buffer write a frame, and a float only glyphs read still widens the write\n * for every rect and quad beside them. What it costs instead is a break\n * wherever faked-bold text meets text that is not, which is a fallback path:\n * a registered bold face never sets this at all.\n */\n synthBold: number;\n /** Whether group alpha folded into the vertex colors. */\n foldsAlpha: boolean;\n /**\n * The textures this run samples, in the order they joined. A quad's vertices\n * carry `index + 1`, because slot 0 is the white texel every solid samples.\n *\n * Two kinds, because two caches own them: an image quad names an\n * `ImageBitmap` that `GLImageCache` keys by identity, a glyph names the\n * string id of a font atlas in `GLTextureCache`. They share the slot list so\n * a caption and the thumbnail above it share a draw.\n *\n * A bitmap's `sampling` is per entry and set per flush rather than at upload:\n * MAG_FILTER is state on the texture object, so the same bitmap drawn at both\n * filters in one frame needs two flushes, not two slots. An atlas carries no\n * sampling because `GLTextureCache` owns its filtering — and must keep\n * owning it: filtering a distance field destroys it, so a font atlas is\n * never mipmapped and never joins a shared image atlas.\n */\n textures: BatchTexture[];\n}\n\n/** One entry in a run's slot list. */\ntype BatchTexture =\n | { kind: 'bitmap'; image: ImageBitmap; sampling: 'linear' | 'nearest' }\n | { kind: 'atlas'; id: string; fieldScale: readonly [number, number] }\n | { kind: 'ramps' };\n\n/** Identity in row-major 4×5 leaves `src` untouched *and* leaves the shader's\n * clamp with nothing to do, which is what makes the alpha fold exact. */\nfunction isIdentityColorMatrix(cm: Float32Array): boolean {\n return cm === IDENTITY_COLOR_MATRIX || sameValues(IDENTITY_COLOR_MATRIX, cm);\n}\n\n/**\n * Whether the live group state would draw the staged run identically.\n *\n * By value, not by reference: a group carrying an identity color matrix still\n * goes through `compose4x5`, which allocates a new array holding equal numbers.\n * Twenty float compares are nothing against the draw call they save.\n */\nfunction stagedStateIsLive(\n ctx: DrawContext, staged: StagedBatchState,\n image?: ImageBitmap, sampling?: 'linear' | 'nearest',\n synthBold = 0,\n): boolean {\n if (staged.clipDepth !== (ctx.clipStack.length === 0 ? ctx.clipDepth : runClipDepth(ctx))) return false;\n // Solids and image quads ask with 0, which is what a run of them carries, so\n // this only ever breaks between two kinds of glyph.\n if (staged.synthBold !== synthBold) return false;\n if (!staged.foldsAlpha && staged.alpha !== ctx.state.alpha) return false;\n if (image !== undefined && slotForBitmap(staged, image, sampling!) < 0) return false;\n const colorMatrix = ctx.state.colorMatrix;\n return staged.colorMatrix === colorMatrix || sameValues(staged.colorMatrix, colorMatrix);\n}\n\n/**\n * The slot `image` would sample from in this run, or -1 if it cannot join.\n *\n * A bitmap already in the run reuses its slot — but only at the filter it went\n * in under, since MAG_FILTER belongs to the texture object and one draw cannot\n * have it both ways. Otherwise it takes the next free slot, and a run with none\n * left is a run this quad has to break.\n */\nfunction slotForBitmap(\n staged: StagedBatchState, image: ImageBitmap, sampling: 'linear' | 'nearest',\n): number {\n for (let i = 0; i < staged.textures.length; i++) {\n const entry = staged.textures[i];\n if (entry.kind !== 'bitmap' || entry.image !== image) continue;\n return entry.sampling === sampling ? i + 1 : -1;\n }\n return nextFreeSlot(staged);\n}\n\n/** The same for the ramp atlas, of which there is one — so every gradient in a\n * run shares the slot, however many distinct ramps they are. */\nfunction slotForRamps(staged: StagedBatchState): number {\n for (let i = 0; i < staged.textures.length; i++) {\n if (staged.textures[i].kind === 'ramps') return i + 1;\n }\n return nextFreeSlot(staged);\n}\n\n/** The same for a font atlas, which has no filter to disagree about. */\nfunction slotForAtlas(staged: StagedBatchState, id: string): number {\n for (let i = 0; i < staged.textures.length; i++) {\n const entry = staged.textures[i];\n if (entry.kind === 'atlas' && entry.id === id) return i + 1;\n }\n return nextFreeSlot(staged);\n}\n\n/** The slot a texture new to this run would take, or -1 if it is full. */\nfunction nextFreeSlot(staged: StagedBatchState): number {\n return staged.textures.length + 1 < BATCH_TEXTURE_SLOTS ? staged.textures.length + 1 : -1;\n}\n\n/**\n * Vertices above which a mesh keeps its own draw, by whether a run is open.\n *\n * Batching trades a draw call for copying and re-uploading the mesh every\n * frame, where a mesh already in the persistent cache costs nothing per frame\n * beyond the draw. Drawn alone with a run open, a mesh also closes that run and\n * switches program twice, so it breaks even far later there. Both values sit\n * below what `tests/perf/mesh-batch.spec.ts` measured, recorded in\n * `docs/TODO.md`: being wrong on the open-run side costs ten times more.\n */\nconst MAX_BATCHED_MESH_VERTICES = 96;\n\nconst MAX_BATCHED_MESH_VERTICES_IN_RUN = 1024;\n\n/** The caps {@link canBatchMesh} reads. Mutable only so `mesh-batch.spec.ts`\n * can time both sides of them in one page; the barrel does not export it. */\nexport const meshBatching = {\n maxVertices: MAX_BATCHED_MESH_VERTICES,\n maxVerticesInRun: MAX_BATCHED_MESH_VERTICES_IN_RUN,\n};\n\n/** Whether a mesh can join a run. Stencil fills need their own two-pass dance,\n * and a mesh past the cap is cheaper as its own draw. */\nfunction canBatchMesh(ctx: DrawContext, mesh: Mesh): boolean {\n if (mesh.requiresStencil) return false;\n const cap = ctx.drawBatch.length > 0 ? meshBatching.maxVerticesInRun : meshBatching.maxVertices;\n return (mesh.vertices.length >> 1) <= cap;\n}\n\n/**\n * Open or continue a run for `vertices` more, flushing first if the run would\n * overflow or if the live group state no longer matches what it was staged\n * under. Returns the staged state, which the caller reads to resolve alpha.\n *\n * Fill opacity folds into the vertex alpha, exactly as `u_color` carried it\n * when each shape was its own draw. Group alpha folds in too, but only under an\n * identity color matrix: the shader is `a = clamp(CM * src + bias).a * u_alpha`,\n * so with a real matrix between them a pre-multiplied vertex alpha is a\n * different number. There it stays a uniform, and a differing alpha breaks the\n * run as before.\n */\nexport function stageSolid(ctx: DrawContext, vertices: number): StagedBatchState {\n if (ctx.batchState !== undefined && !stagedStateIsLive(ctx, ctx.batchState)) flushBatch(ctx);\n if (ctx.drawBatch.wouldOverflow(vertices)) flushBatch(ctx);\n return openRun(ctx);\n}\n\n/** The staged state, opening a run under the live group state if none is. */\nfunction openRun(ctx: DrawContext): StagedBatchState {\n if (ctx.batchState === undefined) {\n const colorMatrix = ctx.state.colorMatrix;\n const foldsAlpha = isIdentityColorMatrix(colorMatrix);\n ctx.batchState = {\n alpha: foldsAlpha ? 1 : ctx.state.alpha,\n colorMatrix,\n clipDepth: runClipDepth(ctx),\n synthBold: 0,\n foldsAlpha,\n textures: [],\n };\n }\n return ctx.batchState;\n}\n\n/**\n * Open or continue a run for one more image quad, flushing first if the run\n * would overflow or cannot give this bitmap a slot.\n *\n * A run adopts a bitmap it has not seen rather than breaking, which is what\n * lets a wall's ground rect and its atlas quad share a draw, and what lets a\n * cell's art and its badge share one too. Returns the staged state and the slot\n * the quad's vertices must carry.\n */\nexport function stageImage(\n ctx: DrawContext, image: ImageBitmap, sampling: 'linear' | 'nearest',\n): { staged: StagedBatchState; slot: number } {\n if (ctx.batchState !== undefined\n && !stagedStateIsLive(ctx, ctx.batchState, image, sampling)) {\n flushBatch(ctx);\n }\n if (ctx.drawBatch.wouldOverflow(4)) flushBatch(ctx);\n const staged = openRun(ctx);\n let slot = slotForBitmap(staged, image, sampling);\n if (slot > staged.textures.length) {\n staged.textures.push({ kind: 'bitmap', image, sampling });\n slot = staged.textures.length;\n }\n return { staged, slot };\n}\n\n/**\n * Open or continue a run for a glyph off the font atlas `atlasId`, flushing\n * first if the run would overflow or has no slot left for it.\n *\n * The atlas is the unit of coalescing the way a sprite sheet is: every glyph a\n * face contributes to a frame shares one texture, so a paragraph is one run\n * however many glyphs it is, and a second face costs one more slot rather than\n * a flush per word.\n */\nexport function stageGlyphs(\n ctx: DrawContext, atlasId: string, fieldScale: readonly [number, number], synthBold: number,\n): { staged: StagedBatchState; slot: number } {\n if (ctx.batchState !== undefined\n && (!stagedStateIsLive(ctx, ctx.batchState, undefined, undefined, synthBold)\n || slotForAtlas(ctx.batchState, atlasId) < 0)) {\n flushBatch(ctx);\n }\n if (ctx.drawBatch.wouldOverflow(4)) flushBatch(ctx);\n const staged = openRun(ctx);\n // An empty run adopts the threshold; one that already has vertices agreed to\n // it above, since a mismatch flushed.\n staged.synthBold = synthBold;\n let slot = slotForAtlas(staged, atlasId);\n if (slot > staged.textures.length) {\n staged.textures.push({ kind: 'atlas', id: atlasId, fieldScale });\n slot = staged.textures.length;\n }\n return { staged, slot };\n}\n\n/**\n * Open or continue a run for geometry filled from the ramp atlas, flushing\n * first if the run would overflow, has no slot left, or if baking `stops` would\n * move the rows already staged.\n *\n * **That last one is the trap.** A staged vertex names its ramp by where the\n * row sits, so growing the atlas — which changes every row's `v` — or recycling\n * a row repaints geometry already staged with somebody else's gradient. Both\n * are irreversible once done, so the question is asked before the bake, not\n * after.\n */\nfunction stageRamps(\n ctx: DrawContext, stops: GradStop[], space: ColorSpace, vertices: number,\n): { staged: StagedBatchState; slot: number; rowV: number } {\n if (ctx.gradRamps.wouldReshape(stops, space)) flushBatch(ctx);\n if (ctx.batchState !== undefined\n && (!stagedStateIsLive(ctx, ctx.batchState) || slotForRamps(ctx.batchState) < 0)) {\n flushBatch(ctx);\n }\n if (ctx.drawBatch.wouldOverflow(vertices)) flushBatch(ctx);\n const staged = openRun(ctx);\n let slot = slotForRamps(staged);\n if (slot > staged.textures.length) {\n staged.textures.push({ kind: 'ramps' });\n slot = staged.textures.length;\n }\n return { staged, slot, rowV: ctx.gradRamps.rowV(ctx.gradRamps.upload(stops, space)) };\n}\n\n/** Alpha a batched paint's vertices carry: its own opacity, and the group's\n * under an identity color matrix. */\nfunction stagedAlpha(\n ctx: DrawContext, staged: StagedBatchState, opacity: number | undefined,\n): number {\n return (opacity ?? 1) * (staged.foldsAlpha ? ctx.state.alpha : 1);\n}\n\n/** Straight-alpha rgba for a solid paint under the staged state. */\nfunction stagedColor(\n ctx: DrawContext, staged: StagedBatchState,\n paint: { color: string; opacity?: number },\n): [number, number, number, number] {\n const [r, g, b, a] = resolveColor(paint.color);\n return [r, g, b, a * stagedAlpha(ctx, staged, paint.opacity)];\n}\n\nexport function pushRect(\n ctx: DrawContext,\n rect: { x: number; y: number; width: number; height: number },\n fill: { color: string; opacity?: number },\n): void {\n const staged = stageSolid(ctx, 4);\n const [r, g, b, a] = stagedColor(ctx, staged, fill);\n if (!ctx.drawBatch.pushRect(\n rect.x, rect.y, rect.width, rect.height, ctx.state.transform, r, g, b, a,\n )) retryUncut(ctx, rect, fill, pushRect);\n}\n\nfunction pushMesh(\n ctx: DrawContext,\n mesh: Mesh,\n paint: { color: string; opacity?: number },\n): void {\n const staged = stageSolid(ctx, mesh.vertices.length >> 1);\n const [r, g, b, a] = stagedColor(ctx, staged, paint);\n if (!ctx.drawBatch.pushMesh(mesh, ctx.state.transform, r, g, b, a)) {\n retryUncut(ctx, mesh, paint, pushMesh);\n }\n}\n\nexport function pushRampRect(\n ctx: DrawContext,\n rect: { x: number; y: number; width: number; height: number },\n paint: Extract<BatchPaint, { kind: 'ramp' }>,\n): void {\n const { staged, slot, rowV } = stageRamps(ctx, paint.stops, paint.space, 4);\n const { uv, post } = rampVertices(paint, rowV);\n // White vertices, so the ramp texel passes through as its own color and the\n // alpha channel carries what `u_opacity` and `u_alpha` used to.\n if (!ctx.drawBatch.pushGradientRect(\n rect.x, rect.y, rect.width, rect.height, ctx.state.transform,\n uv, post, slot, paint.mode, 1, 1, 1, stagedAlpha(ctx, staged, paint.opacity),\n )) retryUncut(ctx, rect, paint, pushRampRect);\n}\n\nfunction pushRampMesh(\n ctx: DrawContext, mesh: Mesh, paint: Extract<BatchPaint, { kind: 'ramp' }>,\n): void {\n const { staged, slot, rowV } = stageRamps(ctx, paint.stops, paint.space, mesh.vertices.length >> 1);\n const { uv, post } = rampVertices(paint, rowV);\n if (!ctx.drawBatch.pushGradientMesh(\n mesh, ctx.state.transform,\n uv, post, slot, paint.mode, 1, 1, 1, stagedAlpha(ctx, staged, paint.opacity),\n )) retryUncut(ctx, mesh, paint, pushRampMesh);\n}\n\n/**\n * Stage `mesh` into the run, or drain the run so the caller can draw it itself.\n *\n * `true` means the mesh is in the batch and the caller is done. `false` comes\n * back only *after* a flush, so an emitter cannot earn permission to draw for\n * itself without also draining the batch. `paint` is `undefined` when it is one\n * no run can express — see `batchPaint`.\n */\nexport function tryStageFill(\n ctx: DrawContext,\n mesh: Mesh,\n paint: BatchPaint | undefined,\n): boolean {\n if (paint !== undefined && canBatchMesh(ctx, mesh)) {\n if (paint.kind === 'ramp') pushRampMesh(ctx, mesh, paint);\n else pushMesh(ctx, mesh, paint);\n return true;\n }\n flushForOwnDraw(ctx);\n return false;\n}\n","import type { PatternTransform } from '@weasel-js/paint';\nimport { mat3, type GlMat3 } from '@weasel-js/geom';\n\n/**\n * Screen → tile-space matrix for a pattern fill: `spaceInverse` takes a screen\n * position into the paint's `units` space, then this undoes the tile's\n * placement there, `origin + transform · tile`. Tile space is in paint units,\n * so the shader divides by the tile's size to get a texture coordinate.\n *\n * `null` when `transform` is singular — a tile collapsed to a line has no\n * point to sample for most of the plane, and a paint with no inverse draws\n * nothing, as gradients do.\n */\nexport function patternTileSpace(\n spaceInverse: GlMat3,\n origin: { x: number; y: number },\n transform: PatternTransform | undefined,\n): GlMat3 | null {\n const [a, b, c, d] = transform ?? [1, 0, 0, 1];\n const placement = mat3.fromAffine([a, b, c, d, origin.x, origin.y]);\n const unplace = mat3.invert(placement);\n return unplace && mat3.multiply(unplace, spaceInverse);\n}\n","import type { FillStyle } from '@weasel-js/paint';\nimport type { PaintBindContext, PaintResources } from '../paintKinds';\nimport { createPaintResources } from '../paintResources';\nimport { getTexture, type TextureHandle } from '../textures/registerTexture';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport { mat3, type GlMat3 } from '@weasel-js/geom';\nimport { patternTileSpace } from '../math/patternSpace';\nimport type { DrawContext } from './drawContext';\nimport { setAlphaUniform, setColorMatrixUniforms, setProjAndModel } from './uniforms';\nimport { gradientSpaceInverse, spaceToDevice } from './gradient';\n\n/** The narrow renderer surface a registered paint kind binds against, built\n * once per frame context. `DrawContext` is not consumer surface. */\nexport function paintBindContext(ctx: DrawContext): PaintBindContext {\n const cached = BIND_CONTEXTS.get(ctx);\n if (cached) return cached;\n const made: PaintBindContext = {\n gl: ctx.gl,\n get alpha() { return ctx.state.alpha; },\n program: (id) => ctx.ensureProgram?.(id) ?? ctx.programRegistry.get(id) ?? null,\n setProjAndModel: (prog) => setProjAndModel(ctx, prog),\n spaceInverse: (units) => gradientSpaceInverse(ctx, units),\n spaceToDevice: (units) => spaceToDevice(ctx, units),\n get maxTextureSize() { return ctx.imageCache.maxTextureSide; },\n resources: ctx.paintResources ?? unownedPaintResources(ctx.gl),\n bindRamp: (stops, unit, space) => {\n const row = ctx.gradRamps.upload(stops, space);\n ctx.gradRamps.bind(unit);\n return ctx.gradRamps.rowV(row);\n },\n };\n BIND_CONTEXTS.set(ctx, made);\n return made;\n}\n\nconst BIND_CONTEXTS = new WeakMap<DrawContext, PaintBindContext>();\n\nconst UNOWNED_RESOURCES = new WeakMap<WebGL2RenderingContext, PaintResources>();\n\nfunction unownedPaintResources(gl: WebGL2RenderingContext): PaintResources {\n let made = UNOWNED_RESOURCES.get(gl);\n if (!made) {\n made = createPaintResources();\n UNOWNED_RESOURCES.set(gl, made);\n }\n return made;\n}\n\n/** Bind `prog` — the path program or the glyph one, which share every paint\n * uniform — to draw `fill` under `model`. */\nexport function bindPattern(\n ctx: DrawContext,\n prog: ShaderProgram,\n fill: Extract<FillStyle, { fill: 'pattern' }>,\n model: GlMat3,\n): ShaderProgram | null {\n const tex = fill.pattern as TextureHandle;\n const entry = getTexture(tex.id);\n if (!entry) {\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n if (isDev) console.warn(`weasel: pattern TextureHandle \"${tex.id}\" not registered`);\n return null;\n }\n const inverse = gradientSpaceInverse(ctx, fill.units);\n if (!inverse) return null;\n const tileSpace = patternTileSpace(inverse, fill.origin ?? { x: 0, y: 0 }, fill.transform);\n if (!tileSpace) return null;\n ctx.textureCache.uploadRegistered(tex.id, entry.source, 'repeat');\n\n // A path fill mesh carries a_position only, so the tile coordinate is\n // recovered per fragment from the screen position — the same route\n // gradients take through `u_worldInv`, and the reason this can't reuse\n // the image-fill shader, whose a_uv such a mesh leaves unbound.\n const gl = ctx.gl;\n gl.useProgram(prog.handle);\n setProjAndModel(ctx, prog, model);\n setColorMatrixUniforms(ctx, prog);\n gl.uniformMatrix3fv(prog.uniform('u_worldInv')!, false, mat3.toUniform(tileSpace));\n const [tw, th] = textureSize(entry.source);\n gl.uniform2f(prog.uniform('u_tileSize')!, tw, th);\n ctx.textureCache.bind(tex.id, 0);\n gl.uniform1i(prog.uniform('u_sampler')!, 0);\n gl.uniform1f(prog.uniform('u_opacity')!, fill.opacity ?? 1);\n setAlphaUniform(ctx, prog, ctx.state.alpha);\n return prog;\n}\n\n/** Tile extent in paint-space units — one tile spans this many units of\n * whatever space `units` names. */\nfunction textureSize(source: HTMLImageElement | ImageBitmap): [number, number] {\n const w = 'naturalWidth' in source ? source.naturalWidth : source.width;\n const h = 'naturalHeight' in source ? source.naturalHeight : source.height;\n return [w || 1, h || 1];\n}\n\n/** The gradient counterpart of `bindPattern`. */\nexport function bindGradient(\n ctx: DrawContext,\n prog: ShaderProgram,\n fill: Extract<FillStyle, { fill: 'linear-gradient' | 'radial-gradient' | 'conic-gradient' }>,\n model: GlMat3,\n): ShaderProgram | null {\n const inverse = gradientSpaceInverse(ctx, fill.units);\n if (!inverse) return null;\n const gl = ctx.gl;\n const row = ctx.gradRamps.upload(fill.stops, fill.interpolate ?? 'rgb');\n\n gl.useProgram(prog.handle);\n setProjAndModel(ctx, prog, model);\n\n gl.uniformMatrix3fv(prog.uniform('u_worldInv')!, false, mat3.toUniform(inverse));\n setColorMatrixUniforms(ctx, prog);\n\n ctx.gradRamps.bind(0);\n gl.uniform1i(prog.uniform('u_ramp')!, 0);\n gl.uniform1f(prog.uniform('u_rampV')!, ctx.gradRamps.rowV(row));\n setAlphaUniform(ctx, prog, ctx.state.alpha);\n gl.uniform1f(prog.uniform('u_opacity')!, fill.opacity ?? 1);\n\n if (fill.fill === 'linear-gradient') {\n gl.uniform1i(prog.uniform('u_gradKind')!, 0);\n const dx = fill.to.x - fill.from.x;\n const dy = fill.to.y - fill.from.y;\n const len = Math.hypot(dx, dy) || 1;\n gl.uniform2f(prog.uniform('u_gradP0')!, fill.from.x, fill.from.y);\n gl.uniform2f(prog.uniform('u_gradDir')!, dx / len, dy / len);\n gl.uniform1f(prog.uniform('u_gradLen')!, len);\n gl.uniform1f(prog.uniform('u_gradRadius')!, 0);\n gl.uniform1f(prog.uniform('u_gradAngle')!, 0);\n } else if (fill.fill === 'radial-gradient') {\n gl.uniform1i(prog.uniform('u_gradKind')!, 1);\n gl.uniform2f(prog.uniform('u_gradP0')!, fill.center.x, fill.center.y);\n gl.uniform2f(prog.uniform('u_gradDir')!, 0, 0);\n gl.uniform1f(prog.uniform('u_gradLen')!, 0);\n gl.uniform1f(prog.uniform('u_gradRadius')!, fill.radius);\n gl.uniform1f(prog.uniform('u_gradAngle')!, 0);\n } else {\n // conic\n gl.uniform1i(prog.uniform('u_gradKind')!, 2);\n gl.uniform2f(prog.uniform('u_gradP0')!, fill.center.x, fill.center.y);\n gl.uniform2f(prog.uniform('u_gradDir')!, 0, 0);\n gl.uniform1f(prog.uniform('u_gradLen')!, 0);\n gl.uniform1f(prog.uniform('u_gradRadius')!, 0);\n gl.uniform1f(prog.uniform('u_gradAngle')!, fill.angle);\n }\n\n return prog;\n}\n","import type { Stroke, FillStyle } from '@weasel-js/paint';\nimport { getPaintDrawKind } from '../paintKinds';\nimport type { PathDrawCommand } from '../DrawCommand';\nimport type { GLMeshHandle } from '../cache/GLMeshCache';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport { resolveStrokeWidth } from '@weasel-js/stroke';\nimport { strokeMesh } from '../cache/strokeMeshCache';\nimport { resolveStrokeLengths, type StrokedPathCommand } from '../strokeLengths';\nimport { metricKeepsRects, type StrokeSpaces } from '@weasel-js/stroke';\nimport { cachedMarkerCommands } from '../cache/markerCommandCache';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { fillMesh, meshHandle, fillMeshHandle } from './mesh';\nimport { setColorMatrixUniforms, setProjAndModel, setSolidPaintUniforms } from './uniforms';\nimport { applyClipTest, ancestorMask, beginParityMask, endParityMask } from './stencil';\nimport { flushForOwnDraw } from './clip';\nimport { pushRect, pushRampRect, tryStageFill } from './batch';\nimport { batchPaint } from './gradient';\nimport { paintBindContext, bindPattern, bindGradient } from './paintBind';\n\nexport function drawPath(ctx: DrawContext, cmd: PathDrawCommand): void {\n if (cmd.fill) drawPathFill(ctx, cmd);\n // A stroke with no `paint` paints nothing, the way a node's `fill: null`\n // does. Commands arriving from a consumer painter or overlay can carry one.\n if (cmd.stroke?.paint) drawPathStroke(ctx, cmd as StrokedPathCommand);\n}\n\nfunction drawPathFill(ctx: DrawContext, cmd: PathDrawCommand): void {\n const fill = cmd.fill!;\n // Batchable: see `batchPaint`. A rect skips tessellation entirely; anything\n // else stages its mesh. Both also keep animated demos that mint a fresh Path\n // every frame from allocating a GL buffer per frame.\n const isSolid = fill.fill === undefined || fill.fill === 'solid';\n const hasVColors = !!(cmd.vertexColors && cmd.vertexColors.length > 0);\n const solid = fill as { color: string; opacity?: number };\n const paint = batchPaint(ctx, fill, hasVColors);\n if (paint === null) return;\n\n if (paint !== undefined && cmd.path.kind === 'rect') {\n if (paint.kind === 'ramp') pushRampRect(ctx, cmd.path, paint);\n else pushRect(ctx, cmd.path, paint);\n return;\n }\n\n const mesh = fillMesh(ctx, cmd.path);\n if (tryStageFill(ctx, mesh, paint)) return;\n\n const handle = meshHandle(ctx, mesh);\n if (isSolid && hasVColors) {\n drawPathFillVColor(ctx, cmd, solid, handle);\n } else if (handle.requiresStencil) {\n drawPathFillStencil(ctx, fill, handle);\n } else {\n drawPathFillByKind(ctx, fill, handle);\n }\n}\n\ninterface VertexColorBinding { vbo: WebGLBuffer; location: number | undefined }\n\n/** Point the bound mesh VAO's a_vertexColor at a fresh buffer of per-vertex\n * colors. Pair with `detachVertexColors` before the VAO is unbound. */\nfunction attachVertexColors(\n gl: WebGL2RenderingContext, prog: ShaderProgram, perAnchor: number[], handle: GLMeshHandle,\n): VertexColorBinding {\n const vbo = gl.createBuffer();\n if (!vbo) throw new Error('attachVertexColors: createBuffer returned null');\n gl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n gl.bufferData(gl.ARRAY_BUFFER, expandAnchorColors(perAnchor, handle), gl.DYNAMIC_DRAW);\n const location = prog.attribute('a_vertexColor');\n if (location !== undefined) {\n gl.enableVertexAttribArray(location);\n gl.vertexAttribPointer(location, 4, gl.FLOAT, false, 0, 0);\n }\n return { vbo, location };\n}\n\n// Order matters: a buffer deleted after its VAO is unbound stays attached to\n// that VAO and is not freed until the mesh is, and one deleted while its\n// attribute is still enabled leaves the VAO unable to draw.\nfunction detachVertexColors(gl: WebGL2RenderingContext, { vbo, location }: VertexColorBinding): void {\n if (location !== undefined) gl.disableVertexAttribArray(location);\n gl.deleteBuffer(vbo);\n}\n\nfunction expandAnchorColors(perAnchor: number[], handle: GLMeshHandle): Float32Array {\n const aA = handle.anchorA;\n const aB = handle.anchorB;\n const aT = handle.anchorT;\n if (!aA || !aB || !aT) {\n // Legacy fallback: mesh lacks anchor params (e.g. non-path mesh). Treat\n // the caller-provided array as already per-vertex.\n return new Float32Array(perAnchor);\n }\n const n = aA.length;\n const out = new Float32Array(n * 4);\n for (let i = 0; i < n; i++) {\n const a4 = aA[i] * 4;\n const b4 = aB[i] * 4;\n const t = aT[i];\n out[i * 4 + 0] = perAnchor[a4 + 0] + (perAnchor[b4 + 0] - perAnchor[a4 + 0]) * t;\n out[i * 4 + 1] = perAnchor[a4 + 1] + (perAnchor[b4 + 1] - perAnchor[a4 + 1]) * t;\n out[i * 4 + 2] = perAnchor[a4 + 2] + (perAnchor[b4 + 2] - perAnchor[a4 + 2]) * t;\n out[i * 4 + 3] = perAnchor[a4 + 3] + (perAnchor[b4 + 3] - perAnchor[a4 + 3]) * t;\n }\n return out;\n}\n\nfunction drawPathFillVColor(\n ctx: DrawContext,\n cmd: PathDrawCommand,\n fill: { color: string; opacity?: number },\n handle: GLMeshHandle,\n): void {\n const gl = ctx.gl;\n const prog = ctx.pathFillVColor;\n gl.useProgram(prog.handle);\n gl.bindVertexArray(handle.vao);\n setProjAndModel(ctx, prog);\n setSolidPaintUniforms(ctx, prog, fill.color, fill.opacity);\n setColorMatrixUniforms(ctx, prog);\n\n const colors = attachVertexColors(gl, prog, cmd.vertexColors!, handle);\n\n if (handle.requiresStencil) {\n beginParityMask(ctx, handle.indexCount);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n endParityMask(ctx);\n } else {\n applyClipTest(ctx);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n }\n detachVertexColors(gl, colors);\n gl.bindVertexArray(null);\n}\n\n/**\n * Bind the program, uniforms and textures for `fill`, and return the program.\n *\n * Split from the draw so a caller owning its own stencil state can paint\n * without `applyClipTest` clobbering it — `drawPathStrokeStenciled` clips a\n * doubled ribbon to one side of the silhouette, and `applyClipTest` at depth 0\n * disables the stencil test outright.\n */\nfunction bindPathFillByKind(ctx: DrawContext, fill: FillStyle): ShaderProgram | null {\n const kind = fill.fill ?? 'solid';\n if (kind === 'solid') return bindPathFillSolid(ctx, fill as { color: string; opacity?: number });\n if (kind === 'pattern') return bindPathFillPattern(ctx, fill as Extract<FillStyle, { fill: 'pattern' }>);\n if (kind === 'linear-gradient' || kind === 'radial-gradient' || kind === 'conic-gradient') {\n return bindPathFillGradient(ctx, fill as Extract<FillStyle, { fill: 'linear-gradient' | 'radial-gradient' | 'conic-gradient' }>);\n }\n const bind = getPaintDrawKind(kind)?.bind;\n return bind ? bind(paintBindContext(ctx), fill) : null;\n}\n\nexport function drawPathFillByKind(ctx: DrawContext, fill: FillStyle, handle: GLMeshHandle): void {\n const prog = bindPathFillByKind(ctx, fill);\n if (!prog) return;\n const gl = ctx.gl;\n gl.bindVertexArray(handle.vao);\n applyClipTest(ctx);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n gl.bindVertexArray(null);\n}\n\nfunction bindPathFillSolid(\n ctx: DrawContext,\n fill: { color: string; opacity?: number },\n): ShaderProgram {\n const prog = ctx.pathFill;\n ctx.gl.useProgram(prog.handle);\n setProjAndModel(ctx, prog);\n setSolidPaintUniforms(ctx, prog, fill.color, fill.opacity);\n setColorMatrixUniforms(ctx, prog);\n return prog;\n}\n\nfunction bindPathFillPattern(\n ctx: DrawContext,\n fill: Extract<FillStyle, { fill: 'pattern' }>,\n): ShaderProgram | null {\n return bindPattern(ctx, ctx.patternFill, fill, ctx.state.transform);\n}\n\nfunction bindPathFillGradient(\n ctx: DrawContext,\n fill: Extract<FillStyle, { fill: 'linear-gradient' | 'radial-gradient' | 'conic-gradient' }>,\n): ShaderProgram | null {\n return bindGradient(ctx, ctx.gradFill, fill, ctx.state.transform);\n}\n\nfunction drawPathFillStencil(ctx: DrawContext, fill: FillStyle, handle: GLMeshHandle): void {\n const gl = ctx.gl;\n gl.useProgram(ctx.pathFill.handle);\n gl.bindVertexArray(handle.vao);\n setProjAndModel(ctx, ctx.pathFill);\n\n beginParityMask(ctx, handle.indexCount);\n // The paint binds here, not above: pass 1 runs under a false colorMask, so a\n // uniform missed here renders black while the GL-recorder tests still pass.\n // Not `drawPathFillByKind` — its `applyClipTest` would disable this stencil.\n if (bindPathFillByKind(ctx, fill)) {\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n }\n\n endParityMask(ctx);\n gl.bindVertexArray(null);\n}\n\nfunction drawPathStroke(ctx: DrawContext, rawCmd: StrokedPathCommand): void {\n const { cmd, spaces } = resolveStrokeLengths(ctx.state.transform, rawCmd);\n const stroke = cmd.stroke;\n const align = stroke.align ?? 'center';\n const metric = spaces.ribbon?.metric;\n // A rect the metric turns is no longer a rect in the space its ribbon is\n // built in, so it aligns through the stencil like any polygon.\n const stenciled = cmd.path.kind === 'polygon' || (metric !== undefined && !metricKeepsRects(metric));\n if (stenciled && align !== 'center') {\n flushForOwnDraw(ctx);\n drawPathStrokeStenciled(ctx, cmd, align, spaces);\n } else {\n drawPathStrokeUnclipped(ctx, cmd, spaces);\n }\n // After the ribbon, so a head sits on top of the line it caps.\n const width = resolveStrokeWidth(stroke.width ?? 1, 1);\n const heads = cachedMarkerCommands(cmd.path, rawCmd.stroke, stroke, width, ctx.flattenTolerance, spaces);\n for (const marker of heads) drawPath(ctx, marker);\n}\n\nfunction drawPathStrokeUnclipped(ctx: DrawContext, cmd: StrokedPathCommand, spaces: StrokeSpaces): void {\n const stroke = cmd.stroke;\n const paint = stroke.paint;\n const isSolid = paint.fill === undefined || paint.fill === 'solid';\n const solid = paint as { color: string; opacity?: number };\n const mesh = strokeMesh(cmd.path, stroke, ctx.flattenTolerance, spaces);\n if (mesh.indices.length === 0) return;\n\n // Staged, a ribbon allocates nothing and joins the fill it sits on.\n const hasVColors = !!(stroke.vertexColors && stroke.vertexColors.length > 0);\n const batched = batchPaint(ctx, paint, hasVColors);\n if (batched === null) return;\n if (tryStageFill(ctx, mesh, batched)) return;\n\n // The VAO records the per-draw color attribute, so a vertex-colored draw\n // cannot share a persistent one with a draw that has no vertex colors.\n const handle = hasVColors\n ? ctx.meshCache.uploadTransient(mesh)\n : ctx.meshCache.uploadRecurring(mesh);\n\n if (!isSolid && !hasVColors) {\n drawPathFillByKind(ctx, paint, handle);\n return;\n }\n\n const gl = ctx.gl;\n if (hasVColors) {\n const prog = ctx.pathFillVColor;\n gl.useProgram(prog.handle);\n gl.bindVertexArray(handle.vao);\n setProjAndModel(ctx, prog);\n // Per-vertex colors are the paint here; a non-solid base has no single\n // color to multiply by, so white leaves the vertex colors unmodified.\n setSolidPaintUniforms(ctx, prog, isSolid ? solid.color : '#ffffff', paint.opacity);\n setColorMatrixUniforms(ctx, prog);\n\n const colors = attachVertexColors(gl, prog, stroke.vertexColors!, handle);\n applyClipTest(ctx);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n detachVertexColors(gl, colors);\n gl.bindVertexArray(null);\n return;\n }\n\n gl.useProgram(ctx.pathFill.handle);\n gl.bindVertexArray(handle.vao);\n setProjAndModel(ctx, ctx.pathFill);\n setSolidPaintUniforms(ctx, ctx.pathFill, solid.color, solid.opacity);\n setColorMatrixUniforms(ctx, ctx.pathFill);\n applyClipTest(ctx);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n gl.bindVertexArray(null);\n}\n\n/** The ribbon cache compares `vertexWidths` by reference, so the doubled copy\n * has to be the same array on every frame the source array is. */\nconst DOUBLED_VERTEX_WIDTHS = new WeakMap<number[], number[]>();\n\nfunction doubledVertexWidths(widths: number[]): number[] {\n let doubled = DOUBLED_VERTEX_WIDTHS.get(widths);\n if (doubled === undefined) {\n doubled = widths.map((w) => w * 2);\n DOUBLED_VERTEX_WIDTHS.set(widths, doubled);\n }\n return doubled;\n}\n\nfunction drawPathStrokeStenciled(\n ctx: DrawContext,\n cmd: StrokedPathCommand,\n align: 'inner' | 'outer',\n spaces: StrokeSpaces,\n): void {\n const stroke = cmd.stroke;\n const paint = stroke.paint;\n const isSolid = paint.fill === undefined || paint.fill === 'solid';\n const solid = paint as { color: string; opacity?: number };\n const widerStroke: Stroke = {\n ...stroke,\n width: resolveStrokeWidth(stroke.width ?? 1, 1) * 2,\n ...(stroke.vertexWidths ? { vertexWidths: doubledVertexWidths(stroke.vertexWidths) } : {}),\n align: 'center',\n };\n\n const useVColor = !!(stroke.vertexColors && stroke.vertexColors.length > 0);\n\n const fillHandle = fillMeshHandle(ctx, cmd.path);\n const ribbonMesh = strokeMesh(cmd.path, widerStroke, ctx.flattenTolerance, spaces);\n if (ribbonMesh.indices.length === 0) return;\n // The VAO records the per-draw color attribute, so a vertex-colored draw\n // cannot share a persistent one with a draw that has no vertex colors.\n const ribbonHandle = useVColor\n ? ctx.meshCache.uploadTransient(ribbonMesh)\n : ctx.meshCache.uploadRecurring(ribbonMesh);\n\n const gl = ctx.gl;\n const prog = useVColor ? ctx.pathFillVColor : ctx.pathFill;\n gl.useProgram(prog.handle);\n setProjAndModel(ctx, prog);\n\n gl.enable(gl.STENCIL_TEST);\n gl.colorMask(false, false, false, false);\n gl.stencilMask(0x01);\n gl.stencilFunc(gl.ALWAYS, 1, 0x01);\n // An even-odd fill is one fan per contour, and only parity cuts its holes.\n gl.stencilOp(gl.KEEP, gl.KEEP, fillHandle.requiresStencil ? gl.INVERT : gl.REPLACE);\n gl.bindVertexArray(fillHandle.vao);\n drawTriangles(ctx, fillHandle.indexCount, ctx.gl.UNSIGNED_INT);\n\n const clipMask = ancestorMask(ctx.clipDepth);\n gl.colorMask(true, true, true, true);\n if (align === 'inner') {\n gl.stencilFunc(gl.EQUAL, clipMask | 0x01, clipMask | 0x01);\n } else {\n gl.stencilFunc(gl.EQUAL, clipMask, clipMask | 0x01);\n }\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);\n // Bind the paint here rather than through `drawPathFillByKind`: that calls\n // `applyClipTest`, which at clip depth 0 disables the stencil test this\n // function just set up to clip the ribbon to one side.\n let ribbonProg: ShaderProgram | null = prog;\n if (useVColor) {\n // Per-vertex colors are the paint here; a non-solid base has no single\n // color to multiply by, so white leaves the vertex colors unmodified.\n setSolidPaintUniforms(ctx, prog, isSolid ? solid.color : '#ffffff', paint.opacity);\n setColorMatrixUniforms(ctx, prog);\n } else {\n ribbonProg = bindPathFillByKind(ctx, paint);\n }\n if (!ribbonProg) {\n gl.stencilMask(0x01);\n gl.clear(gl.STENCIL_BUFFER_BIT);\n gl.disable(gl.STENCIL_TEST);\n gl.bindVertexArray(null);\n return;\n }\n gl.bindVertexArray(ribbonHandle.vao);\n\n const colors = useVColor\n ? attachVertexColors(gl, ribbonProg, stroke.vertexColors!, ribbonHandle)\n : null;\n\n drawTriangles(ctx, ribbonHandle.indexCount, ctx.gl.UNSIGNED_INT);\n\n // Narrow to bit 0 first: clear only zeroes bits the mask enables, and\n // pushClip owns bits 1-7.\n gl.stencilMask(0x01);\n gl.clear(gl.STENCIL_BUFFER_BIT);\n gl.disable(gl.STENCIL_TEST);\n if (colors) detachVertexColors(gl, colors);\n gl.bindVertexArray(null);\n}\n","/**\n * Glyph outlines as world-space meshes: each glyph's em-space fill or stroke\n * mesh, placed and concatenated so a run of outlined text is one draw.\n */\nimport type { Mesh } from '@weasel-js/geom/tessellate';\nimport type { LaidOutGroup, LaidOutOutlineGlyph } from '@weasel-js/text';\nimport { strokeSpaceOf } from '@weasel-js/stroke';\nimport type { GlMat3 } from '@weasel-js/geom';\nimport { quantizeStrokeScale } from './cache/strokeMeshCache';\nimport { outlineMesh } from './cache/outlineMeshCache';\nimport { outlineStrokeMesh, quantizeEmWidth } from './cache/outlineStrokeMeshCache';\nimport { SYNTHETIC_ITALIC_RADIANS } from '@weasel-js/text';\n\n/**\n * Merge a group's glyphs into one world-space mesh, or `null` when nothing in\n * it has area.\n *\n * Every glyph mesh here is `'nonzero'` (that is what `pathFromD` produces and\n * what a font outline means), so none of them sets `requiresStencil` and\n * concatenating their triangles is sound — an even-odd mesh would be a naive\n * per-contour fan that only resolves correctly through a stencil pass, and\n * merging one into a batch would fill its counters solid.\n */\nexport function outlineGroupMesh(group: LaidOutGroup, dx: number, dy: number): Mesh | null {\n return mergeGlyphMeshes(group, dx, dy, (glyph) => outlineMesh(glyph.key, glyph.d));\n}\n\n/**\n * The same merge for the group's stroke: one ribbon per glyph, tessellated in\n * em space and batched into one buffer, so a stroked paragraph is one extra\n * draw call rather than one per glyph.\n *\n * A world width crosses into em space by dividing by the glyph's `scale`,\n * which is world units per em — so `stroke.width` stays a world-unit measure\n * and does not grow with `fontSize`, matching every other stroke in the kit.\n * Dashes cross with it.\n *\n * A synthetic oblique shears a world-width ribbon along with the glyph. That\n * is a real (small) distortion — a sheared circle is an ellipse, so the\n * outline is marginally thicker across the lean than along it — and it is\n * deliberate: shearing the finished ribbon is what keeps the outline glued to\n * the glyph it outlines, which re-tessellating in sheared space would not.\n *\n * A `{ px }` ribbon is built in the stretch of the whole em-to-screen map,\n * shear included, as a path's is in its transform's (see `metric.ts`), so it\n * is that many pixels wide in every direction on every glyph.\n */\nexport function outlineGroupStrokeMesh(\n group: LaidOutGroup,\n dx: number,\n dy: number,\n transform: GlMat3,\n): Mesh | null {\n const stroke = group.stroke;\n if (!stroke) return null;\n const width = stroke.width ?? 1;\n if (typeof width === 'object') {\n if (!(width.px > 0)) return null;\n const shear = shearOf(group);\n const [a, b, c, d] = [transform[0], transform[1], transform[3], transform[4]];\n return mergeGlyphMeshes(group, dx, dy, (glyph) => {\n if (!(glyph.scale > 0)) return null;\n const s = glyph.scale;\n const space = strokeSpaceOf(s * a, s * b, s * (c - a * shear), s * (d - b * shear));\n const pxPerEm = quantizeStrokeScale(width.px, space.scale);\n if (!(pxPerEm > 0)) return null;\n const dash = stroke.dash?.map((v) => v / pxPerEm);\n return outlineStrokeMesh(\n glyph.key, glyph.d, width.px / pxPerEm, { ...stroke, dash }, space.metric ?? undefined,\n );\n });\n }\n if (!(width > 0)) return null;\n return mergeGlyphMeshes(group, dx, dy, (glyph) =>\n glyph.scale > 0\n ? outlineStrokeMesh(\n glyph.key, glyph.d, quantizeEmWidth(width / glyph.scale),\n { ...stroke, dash: stroke.dash?.map((v) => v / glyph.scale) },\n )\n : null);\n}\n\nconst shearOf = (group: LaidOutGroup): number =>\n group.synthetic.italic ? Math.tan(SYNTHETIC_ITALIC_RADIANS) : 0;\n\n/**\n * Transform each glyph's em-space mesh into world space and concatenate.\n * Shared by the fill and stroke paths, which differ only in which mesh they\n * ask for per glyph — the placement math must not fork, or an outline would\n * drift off the glyph it outlines.\n */\nfunction mergeGlyphMeshes(\n group: LaidOutGroup,\n dx: number,\n dy: number,\n meshFor: (glyph: LaidOutOutlineGlyph) => Mesh | null,\n): Mesh | null {\n const parts: { mesh: Mesh; glyph: LaidOutOutlineGlyph }[] = [];\n let vertexFloats = 0;\n let indexCount = 0;\n for (const glyph of group.glyphs) {\n const mesh = meshFor(glyph);\n if (!mesh || mesh.indices.length === 0) continue;\n parts.push({ mesh, glyph });\n vertexFloats += mesh.vertices.length;\n indexCount += mesh.indices.length;\n }\n if (parts.length === 0) return null;\n\n // Matches the SDF vertex shader's skew exactly: x moves by\n // `(baselineY - y) * tan(angle)`, and in em space `baselineY - y` is\n // `-ey * scale`, so above-baseline vertices (negative ey) lean right.\n const shear = shearOf(group);\n\n const vertices = new Float32Array(vertexFloats);\n const indices = new Uint32Array(indexCount);\n let vi = 0;\n let ii = 0;\n let base = 0;\n for (const { mesh, glyph } of parts) {\n const { x, baselineY, scale } = glyph;\n for (let k = 0; k < mesh.vertices.length; k += 2) {\n const ex = mesh.vertices[k];\n const ey = mesh.vertices[k + 1];\n vertices[vi++] = x + dx + (ex - ey * shear) * scale;\n vertices[vi++] = baselineY + dy + ey * scale;\n }\n for (let k = 0; k < mesh.indices.length; k++) indices[ii++] = base + mesh.indices[k];\n base += mesh.vertices.length / 2;\n }\n return { vertices, indices };\n}\n","import type { FillStyle } from '@weasel-js/paint';\nimport { getPaintDrawKind, type PaintBindContext } from '../paintKinds';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport type { GlMat3 } from '@weasel-js/geom';\nimport type { Mesh } from '@weasel-js/geom/tessellate';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { setProjAndModel } from './uniforms';\nimport { returnToRenderTarget } from './effects';\nimport { BATCH_MODEL } from './flushBatch';\nimport { paintBindContext } from './paintBind';\n\nexport interface ScreenRect { x0: number; y0: number; x1: number; y1: number }\n\n/** The unit square, stretched over the region a scratch paint covers. */\nconst UNIT_QUAD: Mesh = {\n vertices: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),\n indices: new Uint32Array([0, 1, 2, 0, 2, 3]),\n};\n\ninterface ScratchPaint {\n texture: WebGLTexture;\n /** Screen position → the texture coordinate the paint landed at there. */\n uvFromScreen: GlMat3;\n}\n\n/**\n * Render a registered kind's paint over `rect` (screen px) into the renderer's\n * scratch buffer, through the kind's own `bind` — so any kind that paints a\n * path paints this, with nothing asked of it beyond what a path asks.\n *\n * The region is snapped out to the device-pixel grid and clamped to the\n * drawing buffer, so each texel is one device pixel of the target and a glyph\n * fragment reads its own. The kind sees the same transform, alpha and paint\n * space it would for a path here; only the projection differs, aimed at the\n * scratch buffer instead of the target. No clip and no scissor apply inside:\n * the glyphs that sample the result are drawn under both.\n *\n * `null` when there is no scratch buffer, the region is empty, or the kind\n * declines the paint — and the glyphs then draw nothing, as the outline tier\n * does for a paint no kind binds.\n */\nexport function renderPaintToScratch(ctx: DrawContext, fill: FillStyle, rect: ScreenRect): ScratchPaint | null {\n const scratch = ctx.paintScratch;\n const bind = getPaintDrawKind(fill.fill)?.bind;\n if (!scratch || !bind) return null;\n const ratio = ctx.deviceWidth && ctx.widthCss > 0 ? ctx.deviceWidth / ctx.widthCss : 1;\n const deviceW = ctx.deviceWidth ?? Math.round(ctx.widthCss);\n const deviceH = ctx.deviceHeight ?? Math.round(ctx.heightCss);\n const px0 = Math.max(0, Math.floor(rect.x0 * ratio));\n const py0 = Math.max(0, Math.floor(rect.y0 * ratio));\n const maxSide = ctx.imageCache.maxTextureSide;\n const pw = Math.min(maxSide, Math.min(deviceW, Math.ceil(rect.x1 * ratio)) - px0);\n const ph = Math.min(maxSide, Math.min(deviceH, Math.ceil(rect.y1 * ratio)) - py0);\n if (!(pw > 0 && ph > 0)) return null;\n\n // The region in screen px, and the two matrices a kind's vertex stage\n // multiplies: the unit quad onto it, and it onto the whole of clip space.\n const x0 = px0 / ratio, y0 = py0 / ratio, w = pw / ratio, h = ph / ratio;\n const model = new Float32Array([w, 0, 0, 0, h, 0, x0, y0, 1]);\n const proj = new Float32Array([2 / w, 0, 0, 0, 2 / h, 0, -1 - (2 * x0) / w, -1 - (2 * y0) / h, 1]);\n const base = paintBindContext(ctx);\n const bindCtx: PaintBindContext = {\n ...base,\n alpha: ctx.state.alpha,\n maxTextureSize: base.maxTextureSize,\n setProjAndModel: (prog) => setProjAndModel(ctx, prog, model, proj),\n };\n\n const gl = ctx.gl;\n const target = scratch.acquire(pw, ph);\n const scissorWasOn = gl.isEnabled(gl.SCISSOR_TEST);\n // The last glyph pass left this texture bound to unit 0; a kind sampling a\n // unit it never binds would read the buffer it is drawing into.\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.bindFramebuffer(gl.FRAMEBUFFER, target.fbo);\n gl.viewport(0, 0, pw, ph);\n gl.disable(gl.SCISSOR_TEST);\n gl.disable(gl.STENCIL_TEST);\n gl.clear(gl.COLOR_BUFFER_BIT);\n gl.disable(gl.BLEND);\n\n const prog = bind(bindCtx, fill);\n if (prog) {\n gl.bindVertexArray(ctx.meshCache.uploadRecurring(UNIT_QUAD).vao);\n drawTriangles(ctx, UNIT_QUAD.indices.length, gl.UNSIGNED_INT);\n gl.bindVertexArray(null);\n }\n\n gl.enable(gl.BLEND);\n returnToRenderTarget(ctx, deviceW, deviceH, scissorWasOn);\n if (!prog) return null;\n return {\n texture: target.texture,\n uvFromScreen: new Float32Array([\n ratio / target.width, 0, 0,\n 0, ratio / target.height, 0,\n -px0 / target.width, -py0 / target.height, 1,\n ]),\n };\n}\n\n/** Bind the glyph program to sample `painted` as its paint. */\nexport function bindScratchPaint(ctx: DrawContext, prog: ShaderProgram, painted: ScratchPaint): ShaderProgram {\n const gl = ctx.gl;\n gl.useProgram(prog.handle);\n setProjAndModel(ctx, prog, BATCH_MODEL);\n gl.uniformMatrix3fv(prog.uniform('u_worldInv')!, false, painted.uvFromScreen);\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, painted.texture);\n gl.uniform1i(prog.uniform('u_sampler')!, 0);\n return prog;\n}\n","import type { FillStyle } from '@weasel-js/paint';\nimport {\n resolveTextStyle,\n type LaidOutGroup,\n type LaidOutDecoration,\n verticalAlignOffset,\n cachedLayoutRuns,\n} from '@weasel-js/text';\nimport type { TextDrawCommand } from '../DrawCommand';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport type { GlMat3 } from '@weasel-js/geom';\nimport type { Mesh } from '@weasel-js/geom/tessellate';\nimport { resolveColor } from '@weasel-js/paint';\nimport {\n ensureFontTexture,\n textureCacheKey,\n syncDynamicPageTexture,\n dynamicPageTextureId,\n GLYPH_MODE_MSDF,\n GLYPH_MODE_R8,\n glyphFieldScale,\n} from '@weasel-js/font';\nimport { outlineGroupMesh, outlineGroupStrokeMesh } from '../glyphOutlineMesh';\nimport type { ClipRect } from '../batchClip';\nimport { SYNTHETIC_ITALIC_RADIANS } from '@weasel-js/text';\nimport type { DrawContext, GlyphPaintKind } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { applyClipTest } from './stencil';\nimport { enterUncut, leaveUncut, flushForOwnDraw } from './clip';\nimport { BATCH_MODEL, flushBatch } from './flushBatch';\nimport { stageSolid, stageGlyphs, tryStageFill } from './batch';\nimport { batchPaint } from './gradient';\nimport { bindPattern, bindGradient } from './paintBind';\nimport { drawPathFillByKind } from './pathPaint';\nimport { type ScreenRect, renderPaintToScratch, bindScratchPaint } from './scratchPass';\n\n/**\n * On-screen glyph size (CSS px) at or above which a face with registered\n * outlines is drawn as geometry instead of sampled from a distance field.\n *\n * 48 is the dynamic tier's own `BAKE_SIZE`, which makes it the size at which\n * that tier stops being an interpolation and starts being a magnification:\n * `glyphRasterizer.ts` measures coverage error bottoming out *at* the bake\n * size and rising on both sides, and past a few times it the reconstructed\n * field shows the raster as contour wobble. The same number is a safe\n * crossing for the baked MSDF atlas, which is still crisp here — outlines are\n * exact, so switching early costs nothing but the tessellation, and the\n * hinting the atlas has and outlines don't stopped mattering well below this.\n */\nexport const OUTLINE_MIN_SCREEN_PX = 48;\n\n/**\n * Uniform scale the model matrix applies, as the geometric mean of its two\n * axis lengths. Used to turn a screen-pixel threshold into the world-space\n * size layout compares against.\n *\n * The mean rather than either axis alone so a non-uniform scale answers with\n * something between the two instead of picking a side; anisotropy that\n * extreme is not a case this threshold needs to be exact about, since being\n * one glyph-size late or early only changes which of two correct renderings\n * is used.\n */\nfunction modelScale(m: GlMat3): number {\n const sx = Math.hypot(m[0], m[1]);\n const sy = Math.hypot(m[3], m[4]);\n return Math.sqrt(sx * sy) || 1;\n}\n\nexport function drawText(ctx: DrawContext, cmd: TextDrawCommand): void {\n const style = resolveTextStyle(cmd.style);\n const lineHeight = style.lineHeight;\n const align = cmd.align ?? style.align;\n const direction = cmd.direction ?? style.direction;\n const maxWidth = cmd.maxWidth ?? Infinity;\n\n // Screen threshold → world threshold. Zooming in lowers the world size that\n // qualifies, which is the whole point: a 12px label at 8× zoom is 96 screen\n // pixels of text and wants outlines exactly as much as a 96px heading does.\n const minScreen = ctx.textOutlineMinScreenSize ?? OUTLINE_MIN_SCREEN_PX;\n const outlineMinSize = Number.isFinite(minScreen)\n ? minScreen / modelScale(ctx.state.transform)\n : undefined;\n\n const laid = cachedLayoutRuns(cmd.runs, {\n maxWidth, alignWidth: cmd.width, lineHeight, align, direction, tabSize: style.tabSize, justify: cmd.justify, outlineMinSize,\n });\n // Decorations are checked too: text whose glyphs are all ink-free — every\n // one still awaiting a dynamic-atlas bake, say — produces no groups at all\n // while still carrying a rule that has to be drawn.\n if (laid.groups.length === 0 && laid.decorations.length === 0) return;\n\n // `laid` is origin-relative, so this is the command's position plus the\n // verticalAlign shift. Applied at upload time, not baked in: the layout is\n // shared and not ours to edit — a cached layout that absorbed either offset\n // would gain another one every frame and slide off the page. Every consumer\n // below adds them while packing vertices, which costs one addition inside\n // loops that are already walking every vertex.\n const dx = cmd.x;\n const dy = cmd.y + verticalAlignOffset(cmd.verticalAlign, cmd.height, laid.bounds.height);\n\n for (const group of laid.groups) {\n if (group.source === 'outline') drawTextOutlineGroup(ctx, group, dx, dy);\n else drawTextGroup(ctx, group, dx, dy);\n }\n\n drawTextDecorations(ctx, laid.decorations, dx, dy);\n}\n\n/**\n * Paint one group of tessellated glyph outlines.\n *\n * The whole group becomes a single mesh: cached em-space triangles are\n * transformed on the CPU into world space and appended to one buffer, so a\n * paragraph set in one face and color is one draw call — the same batching\n * the atlas tier gets from packing glyphs into one texture. The alternative,\n * a model matrix per glyph, would be a draw call per glyph.\n *\n * Going through `drawPathFillByKind` rather than straight to `pathFill` is\n * what makes gradient- and pattern-filled text fall out for free: a glyph\n * here is geometry like any other, and those programs shade in world space,\n * so they need nothing from the text pipeline.\n */\nfunction drawTextOutlineGroup(ctx: DrawContext, group: LaidOutGroup, dx: number, dy: number): void {\n const fill = group.fill;\n if (fill !== null) {\n const mesh = outlineGroupMesh(group, dx, dy);\n if (mesh) drawOutlineMesh(ctx, fill, mesh);\n }\n\n // Stroke after fill — Canvas2D's fillText-then-strokeText convention, and\n // SVG's default paint-order. A second batched draw call over the same\n // group, not a call per glyph.\n const strokePaint = group.stroke?.paint;\n if (!strokePaint) return;\n const ribbon = outlineGroupStrokeMesh(group, dx, dy, ctx.state.transform);\n if (ribbon) drawOutlineMesh(ctx, strokePaint, ribbon);\n}\n\n/**\n * Paint one merged glyph-outline mesh, staging it where it fits.\n *\n * Through `tryStageFill` rather than straight to `drawPathFillByKind`,\n * because a paragraph can mix tiers: a heading drawn as outlines and a caption\n * drawn from the atlas are groups of one command, and the atlas half now\n * stages. An outline that painted itself while glyphs sat staged behind it\n * would come out under them.\n */\nfunction drawOutlineMesh(ctx: DrawContext, fill: FillStyle, mesh: Mesh): void {\n const paint = batchPaint(ctx, fill, false);\n if (paint === null) return;\n if (tryStageFill(ctx, mesh, paint)) return;\n drawPathFillByKind(ctx, fill, ctx.meshCache.uploadTransient(mesh));\n}\n\n/**\n * Stage the rules an underline, strikethrough or overline asks for.\n *\n * Color resolution matches `drawTextGroup` exactly — including its ignoring\n * of `fill.opacity` — so a rule can never disagree with the glyphs it\n * underlines. They stage as ordinary rects, which is what keeps them in the\n * run their glyphs are in. A rule under a texture paint is geometry under it,\n * the way an outline glyph is.\n */\nfunction drawTextDecorations(\n ctx: DrawContext, decorations: readonly LaidOutDecoration[], dx: number, dy: number,\n): void {\n for (const d of decorations) {\n if (glyphPaintKindOf(d.fill) !== null) {\n drawOutlineMesh(ctx, d.fill, ruleMesh(d.x0 + dx, d.y0 + dy, d.x1 + dx, d.y1 + dy));\n continue;\n }\n const [r, g, b, a] = 'color' in d.fill ? resolveColor(d.fill.color) : [0, 0, 0, 1];\n let cut: ClipRect | null | undefined;\n for (;;) {\n const staged = stageSolid(ctx, 4);\n if (ctx.drawBatch.pushRect(\n d.x0 + dx, d.y0 + dy, d.x1 - d.x0, d.y1 - d.y0, ctx.state.transform,\n r, g, b, a * (staged.foldsAlpha ? ctx.state.alpha : 1),\n )) break;\n cut = enterUncut(ctx);\n }\n if (cut !== undefined) leaveUncut(ctx, cut);\n }\n}\n\nfunction ruleMesh(x0: number, y0: number, x1: number, y1: number): Mesh {\n return {\n vertices: new Float32Array([x0, y0, x1, y0, x1, y1, x0, y1]),\n indices: new Uint32Array([0, 1, 2, 0, 2, 3]),\n };\n}\n\n/**\n * Amount `a_synthBold` shifts the SDF threshold by when the resolver fell back\n * from a missing bold variant to the regular atlas. Tuned on Inter: it\n * thickens strokes about a pixel at 16px without breaking glyph topology.\n */\nconst SYNTH_BOLD_AMOUNT = 0.08;\n\n/**\n * Stage one group of atlas glyphs into the batch.\n *\n * Everything that used to be a uniform per group rides the vertices instead —\n * the text color, and the atlas as a slot index packed with the paint mode — so\n * a run off a baked MSDF atlas and one off the runtime canvas bake belong to\n * the same draw, and so does whatever else the page put around them. The\n * synthetic-bold threshold is the exception, and `StagedBatchState.synthBold`\n * says why.\n *\n * The synthetic oblique is the one that changes shape rather than home: the\n * old program skewed in the vertex stage against `u_synthItalic`, and the\n * batch places its own corners, so `pushGlyph` shears them as it places them.\n */\nfunction drawTextGroup(\n ctx: DrawContext, group: LaidOutGroup, dx: number, dy: number,\n): void {\n if (group.source === 'canvas') {\n if (!syncDynamicPageTexture(ctx.textureCache, group.page)) return;\n } else {\n if (!ensureFontTexture(group.family, group.weight, group.style, ctx.textureCache)) return;\n }\n if (group.quads.length === 0) return;\n\n const atlasId = group.source === 'canvas'\n ? dynamicPageTextureId(group.page)\n : textureCacheKey(group.family, group.weight, group.style);\n const mode = group.source === 'canvas' ? GLYPH_MODE_R8 : GLYPH_MODE_MSDF;\n const fieldScale = glyphFieldScale(\n group.source === 'canvas' ? 'canvas' : 'atlas', group.family, group.weight, group.style,\n );\n if (!fieldScale) return;\n const bold = group.synthetic.bold ? SYNTH_BOLD_AMOUNT : 0;\n const tanItalic = group.synthetic.italic ? Math.tan(SYNTHETIC_ITALIC_RADIANS) : 0;\n const paintKind = glyphPaintKindOf(group.fill);\n if (paintKind !== null) {\n drawPaintedGlyphs(ctx, group, dx, dy, paintKind, atlasId, mode, bold, tanItalic, fieldScale);\n return;\n }\n const color = group.fill !== null && 'color' in group.fill\n ? resolveColor(group.fill.color)\n : [0, 0, 0, 1];\n\n const batch = ctx.drawBatch;\n const m = ctx.state.transform;\n let { staged, slot } = stageGlyphs(ctx, atlasId, fieldScale, bold);\n let alpha = color[3] * (staged.foldsAlpha ? ctx.state.alpha : 1);\n\n for (const q of group.quads) {\n if (batch.wouldOverflow(4)) {\n flushBatch(ctx);\n ({ staged, slot } = stageGlyphs(ctx, atlasId, fieldScale, bold));\n alpha = color[3] * (staged.foldsAlpha ? ctx.state.alpha : 1);\n }\n let cut: ClipRect | null | undefined;\n while (!batch.pushGlyph(\n q.x0 + dx, q.y0 + dy, q.x1 + dx, q.y1 + dy, q.baselineY + dy, tanItalic, m,\n q.u0, q.v0, q.u1, q.v1,\n color[0], color[1], color[2], alpha,\n slot, mode,\n )) {\n cut = enterUncut(ctx);\n ({ staged, slot } = stageGlyphs(ctx, atlasId, fieldScale, bold));\n alpha = color[3] * (staged.foldsAlpha ? ctx.state.alpha : 1);\n }\n if (cut !== undefined) {\n leaveUncut(ctx, cut);\n ({ staged, slot } = stageGlyphs(ctx, atlasId, fieldScale, bold));\n alpha = color[3] * (staged.foldsAlpha ? ctx.state.alpha : 1);\n }\n }\n}\n\n/** Which glyph-paint program `fill` needs, or `null` for a paint the batch\n * draws as one color. */\nfunction glyphPaintKindOf(fill: FillStyle | null): GlyphPaintKind | null {\n const kind = fill?.fill ?? 'solid';\n if (kind === 'pattern') return 'pattern';\n if (kind === 'linear-gradient' || kind === 'radial-gradient' || kind === 'conic-gradient') {\n return 'gradient';\n }\n return kind === 'solid' ? null : 'texture';\n}\n\n/** The atlas's unit while a glyph-paint run draws; the paint has unit 0. */\nconst GLYPH_PAINT_ATLAS_UNIT = 1;\n\n/**\n * Draw one group of atlas glyphs with a texture paint, its coverage masking\n * the paint — see `shaders/glyphPaint.ts`.\n *\n * Its own draw, as a pattern-filled path is: the glyph vertex has no room for\n * a paint coordinate beside its atlas one, and widening it would cost every\n * vertex in every run. The quads still stage through `DrawBatch`, drained\n * first, and are drawn from it here before anything else can stage behind\n * them, so no run ever holds them and nothing outside this function has to\n * know they exist.\n */\nfunction drawPaintedGlyphs(\n ctx: DrawContext, group: LaidOutGroup, dx: number, dy: number,\n kind: GlyphPaintKind, atlasId: string, mode: number, bold: number, tanItalic: number,\n fieldScale: readonly [number, number],\n): void {\n const prog = ctx.glyphPaintProgram?.(kind);\n if (!prog) return;\n flushForOwnDraw(ctx);\n const fill = group.fill!;\n const m = ctx.state.transform;\n let bound: ShaderProgram | null;\n if (kind === 'pattern') {\n bound = bindPattern(ctx, prog, fill as Extract<FillStyle, { fill: 'pattern' }>, BATCH_MODEL);\n } else if (kind === 'gradient') {\n bound = bindGradient(ctx, prog, fill as Extract<FillStyle, { fill: 'linear-gradient' | 'radial-gradient' | 'conic-gradient' }>, BATCH_MODEL);\n } else {\n const painted = renderPaintToScratch(ctx, fill, glyphScreenBounds(group, dx, dy, tanItalic, m));\n bound = painted && bindScratchPaint(ctx, prog, painted);\n }\n if (!bound) return;\n const gl = ctx.gl;\n ctx.textureCache.bind(atlasId, GLYPH_PAINT_ATLAS_UNIT);\n gl.uniform1i(prog.uniform('u_atlas')!, GLYPH_PAINT_ATLAS_UNIT);\n gl.uniform1f(prog.uniform('u_synthBold')!, bold);\n gl.uniform2f(prog.uniform('u_fieldScale')!, fieldScale[0], fieldScale[1]);\n applyClipTest(ctx);\n\n const batch = ctx.drawBatch;\n // `flushForOwnDraw` put every clip on the stencil, which this draw tests.\n const cut = batch.clip;\n batch.clip = null;\n for (const q of group.quads) {\n if (batch.wouldOverflow(4)) drawStagedGlyphs(ctx);\n batch.pushGlyph(\n q.x0 + dx, q.y0 + dy, q.x1 + dx, q.y1 + dy, q.baselineY + dy, tanItalic, m,\n q.u0, q.v0, q.u1, q.v1,\n 1, 1, 1, 1,\n GLYPH_PAINT_ATLAS_UNIT, mode,\n );\n }\n drawStagedGlyphs(ctx);\n batch.clip = cut;\n gl.activeTexture(gl.TEXTURE0);\n gl.bindVertexArray(null);\n}\n\nfunction drawStagedGlyphs(ctx: DrawContext): void {\n const batch = ctx.drawBatch;\n if (batch.length === 0) return;\n drawTriangles(ctx, batch.uploadAndBind(), ctx.gl.UNSIGNED_INT);\n batch.reset();\n}\n\n/** The screen-space box of a group's glyph quads, corner for corner as\n * `DrawBatch.pushGlyph` places them. */\nfunction glyphScreenBounds(\n group: LaidOutGroup, dx: number, dy: number, tanItalic: number, m: GlMat3,\n): ScreenRect {\n const b = { x0: Infinity, y0: Infinity, x1: -Infinity, y1: -Infinity };\n const add = (x: number, y: number) => {\n const sx = m[0] * x + m[3] * y + m[6];\n const sy = m[1] * x + m[4] * y + m[7];\n if (sx < b.x0) b.x0 = sx;\n if (sx > b.x1) b.x1 = sx;\n if (sy < b.y0) b.y0 = sy;\n if (sy > b.y1) b.y1 = sy;\n };\n for (const q of group.quads) {\n const x0 = q.x0 + dx, x1 = q.x1 + dx, y0 = q.y0 + dy, y1 = q.y1 + dy;\n const base = q.baselineY + dy;\n const top = (base - y0) * tanItalic;\n const bottom = (base - y1) * tanItalic;\n add(x0 + top, y0);\n add(x1 + top, y0);\n add(x1 + bottom, y1);\n add(x0 + bottom, y1);\n }\n return b;\n}\n","import type { Path, GlMat3 } from '@weasel-js/geom';\nimport type { CommandFill, CommandStroke } from '@weasel-js/paint';\nimport type { TextAlign, TextDirection, TextStyle } from '@weasel-js/text';\nimport type { ResolvedRun } from '@weasel-js/text';\nimport type { TextVerticalAlign } from '@weasel-js/text';\nimport type { ShaderProgramHandle, ShaderUniform } from './shaders/registerProgram';\nimport type { Effect } from './effects/types';\n\n/**\n * Solid-fill paint variant (subset of the full `FillStyle` union from\n * `@weasel-js/paint`). Kept for back-compat with step-1/2 consumers and\n * because some code reads `fill.color` directly. Through step 4, fills can\n * be any `FillStyle` variant — solid, pattern, or gradient.\n */\nexport interface SolidPaint {\n fill?: 'solid';\n /** Any CSS color string accepted by `parseColor`: hex, `rgb()`/`rgba()`, `hsl()`/`hsla()`, named, or `transparent`. */\n color: string;\n opacity?: number;\n}\n\n/** DrawCommand variants implemented through step 6. */\nexport type DrawCommand =\n | PathDrawCommand\n | GroupDrawCommand\n | TextDrawCommand\n | ImageDrawCommand\n | SpritesDrawCommand\n | ShaderDrawCommand;\n\n/** Draw a path, filled and/or stroked. The workhorse command: every shape the\n * kit draws that is not text, an image, or a custom shader is one of these. */\nexport interface PathDrawCommand {\n kind: 'path';\n path: Path;\n /** Solid, pattern, or gradient (linear/radial/conic), resolved for the\n * renderer: `commandFill` makes one from a node's `FillStyle`. */\n fill?: CommandFill;\n /** Stroke spec. Its `paint` takes what `fill` does. */\n stroke?: CommandStroke;\n /**\n * Optional flat RGBA-per-path-anchor color array (length =\n * `4 × countPathAnchors(path)`, floats in 0..1). The renderer\n * arc-length-interpolates these per-anchor colors across the\n * flattened/triangulated mesh between consecutive anchors using the\n * mesh's `anchorA` / `anchorB` / `anchorT` parameterization.\n *\n * **`fill` must also be set when using `vertexColors`.** The renderer\n * only enters the per-vertex shader path when the command has a fill\n * (the fill provides the opacity uniform; the vertex colors override\n * the fill's color). Pass any solid `fill` (e.g. `{ color: '#fff' }`)\n * as the placeholder; the per-vertex colors win in the shader.\n */\n vertexColors?: number[];\n}\n\n/** Draw a list of commands under a shared transform, opacity, color matrix\n * and clip. Groups nest, and their effects accumulate down the stack — this\n * is how a container node's transform reaches its descendants. */\nexport interface GroupDrawCommand {\n kind: 'group';\n transform?: GlMat3;\n alpha?: number;\n /**\n * Optional 4×5 color matrix (row-major, 20 numbers) — `out = M₄ₓ₄ * in + bias`.\n * Accumulated multiplicatively down the group stack. Defaults to identity.\n */\n colorMatrix?: number[];\n /** Optional clip path. When set, the renderer rasterizes this path into\n * the stencil buffer before drawing `children`; the children paint only\n * where the clip covers. Nested groups with clips intersect — a child\n * cannot escape an ancestor's clip. Max 7 nesting levels; the renderer\n * throws if exceeded. */\n clip?: Path;\n /**\n * Full-screen passes run over this group's own pixels, in order, before it\n * is composited into its parent.\n *\n * Unlike every other field here, this does not accumulate down the group\n * stack — it is a render-target boundary. The children draw into a buffer of\n * their own, each effect reads the previous one's output, and the result is\n * composited back under this group's `transform`, `alpha`, `colorMatrix` and\n * whatever clip encloses it. So a blur here blurs this group and nothing\n * around it, which is what a CSS `filter` on the canvas cannot do.\n *\n * An empty or absent list costs nothing: no buffer is allocated until a\n * group asks for one.\n */\n effects?: readonly Effect[];\n children: DrawCommand[];\n}\n\n/**\n * Text draw command. Renders one or more runs at (`x`, `y`) in screen\n * space, optionally word-wrapping at `maxWidth`. The renderer resolves\n * each run's `(fontFamily, fontWeight, fontStyle)` to an MSDF atlas via\n * `resolveFontVariant` and bucket-draws by atlas + color group.\n *\n * `style` carries node-level defaults (`lineHeight`, anti-alias width)\n * that don't belong on individual runs.\n */\nexport interface TextDrawCommand {\n kind: 'text';\n x: number;\n y: number;\n runs: ResolvedRun[];\n /** Wrap width. Absent never wraps. */\n maxWidth?: number;\n align?: TextAlign;\n /** What `start` / `end` resolve against, and the base direction of bidi\n * reordering — see `LayoutRunsOpts.direction`. Default `style`'s. */\n direction?: TextDirection | 'auto';\n /** Spread each wrapped line across `width` — see `LayoutRunsOpts.justify`.\n * `align` then sets only the lines it does not spread. Default `false`. */\n justify?: boolean;\n /** Box width `align` resolves within, from `x`. Default `maxWidth`; with\n * neither, `x` is the line's left edge, midpoint or right edge. */\n width?: number;\n style: TextStyle;\n /** Box height for vertical alignment. When set with `verticalAlign`,\n * the laid-out block shifts within `[y, y+height]`. */\n height?: number;\n /** Default 'top' — the legacy top-anchored behavior. */\n verticalAlign?: TextVerticalAlign;\n}\n\n/**\n * Image draw command — renders `image` at screen-space rect (x, y, w, h).\n * The image is stretched to fit; no tiling. Use a pattern FillStyle on a path\n * for tiling.\n */\nexport interface ImageDrawCommand {\n kind: 'image';\n image: ImageBitmap;\n x: number;\n y: number;\n w: number;\n h: number;\n opacity?: number;\n /** Magnification filter. `'linear'` (default) smooths; `'nearest'` shows\n * device pixels as hard squares — required by anything magnifying a\n * framebuffer readback, where blur destroys the point of the readback. */\n sampling?: 'linear' | 'nearest';\n /** Sub-rectangle of `image` to draw, in bitmap pixels from the top-left.\n * Omitted draws the whole bitmap. Not range-checked: a rect past the edge\n * samples outside [0..1], which CLAMP_TO_EDGE smears. With\n * `sampling: 'linear'` the filter reaches half a texel beyond `source`, so\n * atlas frames need a gutter (see `SpriteSheet.spacing`) or `'nearest'`. */\n source?: { x: number; y: number; w: number; h: number };\n /** Mirror the sampled region within the destination rect. The quad does not\n * move — a flipped draw covers exactly the pixels an unflipped one does. */\n flipX?: boolean;\n flipY?: boolean;\n}\n\n/** Floats per sprite in `SpritesDrawCommand.sprites`. */\nexport const SPRITE_STRIDE = 9;\n\n/**\n * Draw many quads sampling one bitmap — an atlas, a sprite sheet, a wall of\n * thumbnails. The same picture as a run of `ImageDrawCommand`s the renderer\n * would coalesce anyway, handed over already packed so it never walks a\n * command object per quad.\n *\n * Reach for it past a few thousand sprites. Below that a plain run of image\n * commands merges into the same single draw and reads better; the packed form\n * exists because at 20,000 the object walk is about half the frame.\n *\n * The sprites are one run: they share a texture, a filter, and whatever group\n * transform, alpha, color matrix and clip are live, exactly as a merged run of\n * image commands would. Anything varying per sprite is in the array.\n */\nexport interface SpritesDrawCommand {\n kind: 'sprites';\n image: ImageBitmap;\n /** Magnification filter for the whole run, as `ImageDrawCommand.sampling`. */\n sampling?: 'linear' | 'nearest';\n /**\n * `SPRITE_STRIDE` floats per sprite:\n * `dx, dy, dw, dh, sx, sy, sw, sh, opacity`.\n *\n * Destination is in the group's coordinates; source is in bitmap pixels,\n * like `ImageDrawCommand.source`. A negative `sw` or `sh` mirrors that axis\n * within the source rect, which is what `flipX` / `flipY` do. A trailing\n * partial sprite is ignored.\n */\n sprites: Float32Array;\n}\n\n/**\n * Custom shader draw command. The renderer generates a quad over `bounds`\n * and dispatches the consumer's fragment shader with the kit's vertex prelude.\n *\n * `uniforms` keys must match names declared in the consumer's fragment shader.\n * The kit automatically sets `u_bounds`, `u_view`, and `u_proj` — do not\n * declare those in `uniforms`.\n *\n * @experimental API may change before v2.\n */\nexport interface ShaderDrawCommand {\n kind: 'shader';\n program: ShaderProgramHandle;\n uniforms: Record<string, ShaderUniform>;\n /** Screen-space bounding rect in CSS pixels. */\n bounds: { x: number; y: number; w: number; h: number };\n}\n","import { type ImageDrawCommand, type SpritesDrawCommand, SPRITE_STRIDE } from '../DrawCommand';\nimport type { ClipRect } from '../batchClip';\nimport type { DrawContext } from './drawContext';\nimport { enterUncut, leaveUncut, retryUncut } from './clip';\nimport { flushBatch } from './flushBatch';\nimport { stageImage } from './batch';\n\n/**\n * Stage one image quad. Nothing reaches the GPU here — `flushBatch` draws the\n * run this joins.\n *\n * The upload has to happen now rather than at flush: a run is keyed on bitmap\n * identity, and `flushBatch` binds a texture it assumes already exists.\n */\nexport function drawImage(ctx: DrawContext, cmd: ImageDrawCommand): void {\n ctx.imageCache.upload(cmd.image, cmd.image);\n const { staged, slot } = stageImage(ctx, cmd.image, cmd.sampling ?? 'linear');\n\n // Sampling window: the whole bitmap unless `source` narrows it, with the\n // flips applied by swapping the ends rather than moving the quad.\n const src = cmd.source;\n let u0 = 0, v0 = 0, u1 = 1, v1 = 1;\n if (src) {\n const tw = cmd.image.width, th = cmd.image.height;\n u0 = src.x / tw; u1 = (src.x + src.w) / tw;\n v0 = src.y / th; v1 = (src.y + src.h) / th;\n }\n if (cmd.flipX) { const t = u0; u0 = u1; u1 = t; }\n if (cmd.flipY) { const t = v0; v0 = v1; v1 = t; }\n\n if (!ctx.drawBatch.pushQuad(\n cmd.x, cmd.y, cmd.w, cmd.h, ctx.state.transform,\n u0, v0, u1, v1,\n // Group alpha rides the vertices only where it rode the solid colors too:\n // with a real color matrix in the run it is `u_alpha`, and folding it here\n // as well would apply it twice.\n (cmd.opacity ?? 1) * (staged.foldsAlpha ? ctx.state.alpha : 1),\n slot,\n )) retryUncut(ctx, cmd, undefined, drawImage);\n}\n\n/**\n * Stage a packed run of sprites. The same staging `drawImage` does, minus a\n * command object per quad — see `SpritesDrawCommand`.\n *\n * The run is opened once and reopened only when the per-flush cap forces a\n * chunk, so the state check that costs a command its own run happens twice in\n * a frame rather than twenty thousand times.\n */\nexport function drawSprites(ctx: DrawContext, cmd: SpritesDrawCommand): void {\n const data = cmd.sprites;\n const count = Math.floor(data.length / SPRITE_STRIDE);\n if (count === 0) return;\n\n ctx.imageCache.upload(cmd.image, cmd.image);\n const sampling = cmd.sampling ?? 'linear';\n let { staged, slot } = stageImage(ctx, cmd.image, sampling);\n\n const batch = ctx.drawBatch;\n const m = ctx.state.transform;\n let groupAlpha = staged.foldsAlpha ? ctx.state.alpha : 1;\n const tw = cmd.image.width;\n const th = cmd.image.height;\n\n for (let s = 0, i = 0; s < count; s++, i += SPRITE_STRIDE) {\n if (batch.wouldOverflow(4)) {\n flushBatch(ctx);\n ({ staged, slot } = stageImage(ctx, cmd.image, sampling));\n groupAlpha = staged.foldsAlpha ? ctx.state.alpha : 1;\n }\n const sx = data[i + 4], sy = data[i + 5], sw = data[i + 6], sh = data[i + 7];\n let cut: ClipRect | null | undefined;\n while (!batch.pushQuad(\n data[i], data[i + 1], data[i + 2], data[i + 3], m,\n sx / tw, sy / th, (sx + sw) / tw, (sy + sh) / th,\n data[i + 8] * groupAlpha, slot,\n )) {\n cut = enterUncut(ctx);\n ({ staged, slot } = stageImage(ctx, cmd.image, sampling));\n groupAlpha = staged.foldsAlpha ? ctx.state.alpha : 1;\n }\n if (cut !== undefined) {\n leaveUncut(ctx, cut);\n ({ staged, slot } = stageImage(ctx, cmd.image, sampling));\n groupAlpha = staged.foldsAlpha ? ctx.state.alpha : 1;\n }\n }\n}\n","import type { DrawCommand, GroupDrawCommand } from './DrawCommand';\nimport { mat3 } from '@weasel-js/geom';\nimport { getMesh } from './cache/cache';\nimport type { EffectTargets } from './effects/EffectTargets';\nimport { compositeProgramId } from './effects/composite';\nimport type { DrawContext } from './draw/drawContext';\nimport { warnOnceUniform, drawShader } from './draw/customShader';\nimport { returnToRenderTarget, drawFullscreenQuad } from './draw/effects';\nimport { applyClipTest } from './draw/stencil';\nimport { enterGroupClip, leaveClip, flushForOwnDraw } from './draw/clip';\nimport { flushBatch } from './draw/flushBatch';\nimport { drawPath } from './draw/pathPaint';\nimport { drawText } from './draw/text';\nimport { drawImage, drawSprites } from './draw/image';\n\nexport function dispatch(ctx: DrawContext, cmd: DrawCommand): void {\n switch (cmd.kind) {\n case 'group': return drawGroup(ctx, cmd);\n case 'path': return drawPath(ctx, cmd);\n case 'text': return drawText(ctx, cmd);\n case 'image': return drawImage(ctx, cmd);\n case 'sprites': return drawSprites(ctx, cmd);\n case 'shader': flushForOwnDraw(ctx); return drawShader(ctx, cmd);\n }\n}\n\n/**\n * Draw a group's children into a buffer of their own, run its effects over\n * that buffer, and composite the result back where the group sits.\n *\n * Three things are deliberately not inherited by the offscreen render:\n *\n * - **The clip.** A fresh buffer's stencil is empty, so a child drawn at the\n * enclosing clip depth would test against bits that were never written and\n * paint nothing. The enclosing clip belongs on the composite anyway — it\n * clips the group's result, not the pixels an effect reads — so `clipDepth`\n * restarts at 0 inside, which also hands nested clips a fresh budget.\n * - **Alpha and color**, for the same reason from the other end: fading on\n * the way in would give the effect faded pixels to read, and fade them\n * again on the way out. `pushIsolated` returns what the composite owes.\n * - **The scissor**, which belongs to the renderer's sub-rect within the\n * default framebuffer and means nothing in a buffer sized to the whole\n * drawing buffer.\n */\nfunction drawGroupWithEffects(\n ctx: DrawContext,\n cmd: GroupDrawCommand,\n targets: EffectTargets,\n width: number,\n height: number,\n): void {\n const gl = ctx.gl;\n // Anything staged belongs to the parent's buffer, not this one, and the\n // composite below draws under the parent's clips.\n flushForOwnDraw(ctx);\n\n const parentTarget = ctx.renderTarget ?? null;\n const parentClipDepth = ctx.clipDepth;\n const parentClipStack = ctx.clipStack;\n const parentBatchClip = ctx.drawBatch.clip;\n const scissorWasOn = gl.isEnabled(gl.SCISSOR_TEST);\n\n let front = targets.acquire(width, height);\n const composited = ctx.state.pushIsolated({\n transform: cmd.transform,\n alpha: cmd.alpha,\n colorMatrix: cmd.colorMatrix,\n });\n ctx.clipDepth = 0;\n ctx.clipStack = [];\n ctx.drawBatch.clip = null;\n\n gl.bindFramebuffer(gl.FRAMEBUFFER, front.fbo);\n ctx.renderTarget = front;\n gl.viewport(0, 0, width, height);\n gl.disable(gl.SCISSOR_TEST);\n gl.stencilMask(0xFF);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);\n\n for (const child of cmd.children) dispatch(ctx, child);\n flushBatch(ctx);\n\n // Passes replace rather than blend: each writes every texel of its target\n // from the whole of its source. A child that ended by popping a stencil\n // clip leaves the test on, and no pass target has that clip's bits.\n gl.disable(gl.BLEND);\n gl.disable(gl.STENCIL_TEST);\n for (const effect of cmd.effects!) {\n const program = ctx.ensureProgram?.(effect.program.id) ?? null;\n if (!program) {\n warnOnceUniform(effect.program.id, '(program)');\n continue;\n }\n const back = targets.acquire(width, height);\n gl.bindFramebuffer(gl.FRAMEBUFFER, back.fbo);\n gl.viewport(0, 0, width, height);\n gl.clear(gl.COLOR_BUFFER_BIT);\n drawFullscreenQuad(ctx, program, front.texture, width, height, effect.uniforms,\n undefined, effect.program.id);\n targets.release(front);\n front = back;\n }\n gl.enable(gl.BLEND);\n\n // Back to the parent's buffer, and back under its rules.\n ctx.state.pop();\n ctx.clipDepth = parentClipDepth;\n ctx.clipStack = parentClipStack;\n ctx.drawBatch.clip = parentBatchClip;\n ctx.renderTarget = parentTarget;\n returnToRenderTarget(ctx, width, height, scissorWasOn);\n\n const composite = ctx.ensureProgram?.(compositeProgramId()) ?? null;\n if (composite) {\n applyClipTest(ctx);\n drawFullscreenQuad(ctx, composite, front.texture, width, height, undefined, {\n alpha: composited.alpha,\n colorMatrix: composited.colorMatrix,\n });\n }\n targets.release(front);\n}\n\nexport function drawGroup(ctx: DrawContext, cmd: GroupDrawCommand): void {\n // A group with effects is a render-target boundary rather than another\n // accumulating frame. Without a renderer's buffer pool behind the context\n // there is nowhere to draw, so the effects are skipped and the children\n // paint straight through — a frame missing its blur, not a frame missing.\n if (cmd.effects && cmd.effects.length > 0 && ctx.effectTargets\n && ctx.deviceWidth && ctx.deviceHeight) {\n // The clip cuts the composite, so it goes on the parent's buffer, in the\n // group's own space.\n if (cmd.clip) {\n ctx.state.push({ transform: cmd.transform });\n try {\n enterGroupClip(ctx, cmd.clip);\n } finally {\n ctx.state.pop();\n }\n }\n drawGroupWithEffects(ctx, cmd, ctx.effectTargets, ctx.deviceWidth, ctx.deviceHeight);\n if (cmd.clip) leaveClip(ctx);\n return;\n }\n ctx.state.push({\n transform: cmd.transform,\n alpha: cmd.alpha,\n colorMatrix: cmd.colorMatrix,\n });\n if (cmd.clip) {\n try {\n enterGroupClip(ctx, cmd.clip);\n } catch (err) {\n ctx.state.pop();\n throw err;\n }\n }\n for (const child of cmd.children) dispatch(ctx, child);\n if (cmd.clip) leaveClip(ctx);\n ctx.state.pop();\n}\n\nexport { mat3, getMesh };\nexport type { DrawContext, ClipEntry, GlyphPaintKind } from './draw/drawContext';\nexport { setUniform } from './draw/customShader';\nexport { meshBatching, tryStageFill } from './draw/batch';\nexport { flushBatch } from './draw/flushBatch';\nexport { pushClip, popClip } from './draw/clip';\nexport { OUTLINE_MIN_SCREEN_PX } from './draw/text';\n","/**\n * Kit-supplied vertex shader for kind:'shader' DrawCommands.\n *\n * Consumers write only fragment shaders. The vertex shader is fixed:\n * it generates a quad covering the DrawCommand's `bounds` rect and\n * exposes three varyings the fragment shader can consume.\n *\n * PUBLIC CONTRACT (varyings and kit uniforms):\n *\n * in vec2 a_position -1..1 NDC quad (set by the kit)\n * in vec2 a_uv 0..1 across the bounds rect\n *\n * uniform vec4 u_bounds x, y, w, h in screen-space CSS pixels (set by kit)\n * uniform mat3 u_view weasel View matrix, world→screen (set by kit)\n * uniform mat3 u_proj screen→clip projection (internal, not documented)\n *\n * out vec2 v_uv 0..1 across the bounds rect (top-left origin)\n * out vec2 v_screen screen-space pixel coordinate of this fragment\n * out vec2 v_world approximate world-space coordinate (via view inverse)\n *\n * PREMULTIPLIED ALPHA REQUIREMENT:\n * The canvas uses premultipliedAlpha:true (the WebGL2 default). Consumer\n * fragment shaders MUST output premultiplied alpha:\n *\n * outColor = vec4(rgb * a, a); // CORRECT\n * outColor = vec4(rgb, a); // WRONG — over-brightens translucent pixels\n *\n * The renderer uses gl.blendFunc(ONE, ONE_MINUS_SRC_ALPHA) to match.\n */\n\n/**\n * Kit-supplied vertex shader source for custom programs.\n *\n * @remarks\n * **PREMULTIPLIED ALPHA:** Your fragment shader MUST output `vec4(rgb * a, a)`,\n * not `vec4(rgb, a)`. The canvas is composited with premultipliedAlpha:true;\n * straight-alpha output causes over-bright rendering for any fragment with a < 1.\n */\nexport const CUSTOM_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nin vec2 a_uv;\nuniform vec4 u_bounds;\nuniform mat3 u_view;\nuniform mat3 u_proj;\nout vec2 v_uv;\nout vec2 v_screen;\nout vec2 v_world;\n\nvoid main() {\n float sx = u_bounds.x + a_uv.x * u_bounds.z;\n float sy = u_bounds.y + a_uv.y * u_bounds.w;\n v_screen = vec2(sx, sy);\n v_uv = a_uv;\n\n float det = u_view[0][0] * u_view[1][1] - u_view[0][1] * u_view[1][0];\n // A flat view has no inverse: every fragment reads the world origin, not a plausible wrong mapping.\n float invDet = det != 0.0 ? 1.0 / det : 0.0;\n v_world = vec2(\n ((sx - u_view[2][0]) * u_view[1][1] + (sy - u_view[2][1]) * -u_view[0][1]) * invDet,\n ((sx - u_view[2][0]) * -u_view[1][0] + (sy - u_view[2][1]) * u_view[0][0]) * invDet\n );\n\n vec3 clip = u_proj * vec3(sx, sy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n}\n`;\n\n/**\n * Attribute names used by the custom vertex shader.\n * The renderer looks these up after compile.\n */\nexport const CUSTOM_ATTRIBUTES = ['a_position', 'a_uv'] as const;\n\n/**\n * Kit-managed uniform names for custom shader programs.\n * These are set per-draw by drawShader(); consumers must NOT redeclare them.\n */\nexport const CUSTOM_KIT_UNIFORMS = ['u_bounds', 'u_view', 'u_proj'] as const;\n\n/**\n * Auto-quad geometry: 4 vertices covering NDC (-1..1) and UV (0..1).\n *\n * Layout per vertex: [a_position.x, a_position.y, a_uv.x, a_uv.y]\n *\n * Vertex order (UV space, screen y-down):\n * 0: top-left (-1, -1, 0, 0)\n * 1: top-right ( 1, -1, 1, 0)\n * 2: bottom-right ( 1, 1, 1, 1)\n * 3: bottom-left (-1, 1, 0, 1)\n */\nexport const QUAD_VERTICES = new Float32Array([\n -1, -1, 0, 0,\n 1, -1, 1, 0,\n 1, 1, 1, 1,\n -1, 1, 0, 1,\n]);\n\nexport const QUAD_INDICES = new Uint16Array([0, 1, 2, 0, 2, 3]);\n","/**\n * Offscreen colour buffers for effect passes, pooled per renderer.\n *\n * Nothing is allocated until a group with effects asks for one, so a canvas\n * with no effects pays nothing — which is the whole cost story for a feature\n * that would otherwise carry a device-resolution buffer per frame.\n *\n * Every target is the size of the drawing buffer. A group's effects run in\n * screen space, so a smaller buffer would have to reason about where the\n * group's content lands and how far a kernel reaches past it; that is a real\n * optimisation and not the first version of one.\n *\n * The stencil is the part that is easy to get wrong. Clips and even-odd fills\n * live in the stencil buffer, and an FBO does not inherit the default\n * framebuffer's — one without its own attachment renders even-odd paths with\n * their holes filled and clips that do not clip, with no GL error and nothing\n * in a call-sequence test to catch it. Every target here gets a\n * DEPTH24_STENCIL8 renderbuffer of its own.\n */\n\nexport interface EffectTarget {\n readonly fbo: WebGLFramebuffer;\n readonly texture: WebGLTexture;\n /** @internal — the pool's own bookkeeping. */\n readonly stencil: WebGLRenderbuffer;\n}\n\nexport class EffectTargets {\n private readonly gl: WebGL2RenderingContext;\n private readonly all: EffectTarget[] = [];\n private free: EffectTarget[] = [];\n private width = 0;\n private height = 0;\n\n constructor(gl: WebGL2RenderingContext) {\n this.gl = gl;\n }\n\n /** True once anything has been allocated — what a test asks instead of\n * reaching for the private arrays. */\n get allocated(): boolean {\n return this.all.length > 0;\n }\n\n /**\n * Borrow a target sized `width` × `height` device pixels. A size change\n * drops every pooled buffer rather than resizing in place: a borrowed one\n * cannot be resized under its holder, and a resize is not a per-frame event.\n */\n acquire(width: number, height: number): EffectTarget {\n if (width !== this.width || height !== this.height) {\n this.free = [];\n this.releaseAll();\n this.width = width;\n this.height = height;\n }\n const pooled = this.free.pop();\n if (pooled) return pooled;\n const made = this.create(width, height);\n this.all.push(made);\n return made;\n }\n\n /** Hand one back. Order does not matter — every target is interchangeable. */\n release(target: EffectTarget): void {\n this.free.push(target);\n }\n\n /** Take back every target still out on loan. A frame that threw inside a\n * group with effects never released the one it was drawing into. */\n reclaim(): void {\n if (this.free.length !== this.all.length) this.free = [...this.all];\n }\n\n /** Drop every buffer. Called on dispose and on context loss, where the\n * handles are already invalid and only the bookkeeping has to go. */\n releaseAll(): void {\n const gl = this.gl;\n for (const t of this.all) {\n gl.deleteFramebuffer(t.fbo);\n gl.deleteTexture(t.texture);\n gl.deleteRenderbuffer(t.stencil);\n }\n this.all.length = 0;\n this.free = [];\n this.width = 0;\n this.height = 0;\n }\n\n private create(width: number, height: number): EffectTarget {\n const gl = this.gl;\n const texture = gl.createTexture()!;\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n // LINEAR so an effect can sample between texels; CLAMP_TO_EDGE so a kernel\n // reaching past the edge repeats the border instead of wrapping the\n // opposite side of the screen into frame.\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n\n const stencil = gl.createRenderbuffer()!;\n gl.bindRenderbuffer(gl.RENDERBUFFER, stencil);\n gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH24_STENCIL8, width, height);\n gl.bindRenderbuffer(gl.RENDERBUFFER, null);\n\n const fbo = gl.createFramebuffer()!;\n gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, stencil);\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n\n return { fbo, texture, stencil };\n }\n}\n","/** Qualifiers GLSL allows between `uniform` and the type name, and before a\n * struct member's type. */\nconst QUALIFIERS = new Set([\n 'lowp', 'mediump', 'highp', 'precise', 'invariant',\n 'centroid', 'flat', 'smooth', 'noperspective',\n]);\n\nconst IDENT = /^[A-Za-z_]\\w*$/;\nconst MAX_DEPTH = 16;\n\ninterface Member {\n readonly type: string | readonly Member[];\n readonly name: string;\n /** `null` for a non-array. */\n readonly size: number | null;\n}\n\n/**\n * The names a program's uniforms answer to in `getUniformLocation`: array\n * uniforms per slot (`u_ripples[0]`), struct uniforms per leaf\n * (`u_lights[1].pos`), nested structs and array members included.\n *\n * A declaration scanner over a token stream, not a GLSL parser. Comments are\n * stripped; interface blocks are skipped, since a UBO's members are bound\n * through a buffer rather than a location. Array sizes resolve through integer\n * literals, `#define`s and top-level `const int`s, with `+ - * / %` between\n * them; a size it cannot resolve drops that declarator, and a later write to\n * it warns.\n */\nexport function extractUniformNames(glsl: string): string[] {\n return [...scanUniforms(glsl).names];\n}\n\n/** An array uniform of a basic type: its element type as spelled (`vec3`,\n * `int`, `mat4`) and its declared length. */\nexport interface UniformArrayDecl {\n readonly type: string;\n readonly size: number;\n}\n\n/**\n * Every array of a basic type a program declares, keyed by the name its slots\n * hang off (`u_ripples` for `u_ripples[0]`). An array inside a struct is keyed\n * by its full path (`u_lights[1].weights`); an array of structs is not an\n * entry, since it has no single element type.\n */\nexport function extractUniformArrays(glsl: string): Map<string, UniformArrayDecl> {\n return scanUniforms(glsl).arrays;\n}\n\nfunction scanUniforms(glsl: string): { names: Set<string>; arrays: Map<string, UniformArrayDecl> } {\n const { code, defines } = preprocess(glsl);\n const toks = tokenize(code);\n const consts = new Map<string, number>();\n const structs = new Map<string, Member[]>();\n const out = new Set<string>();\n const arrays = new Map<string, UniformArrayDecl>();\n\n const resolveName = (name: string, depth: number): number | null => {\n if (depth > MAX_DEPTH) return null;\n let best: number | null = null;\n for (const body of defines.get(name) ?? []) {\n const v = evalInt(tokenize(body), (n) => resolveName(n, depth + 1));\n if (v !== null && (best === null || v > best)) best = v;\n }\n return best ?? consts.get(name) ?? null;\n };\n const evalSize = (from: number, to: number) => evalInt(toks.slice(from, to), (n) => resolveName(n, 0));\n\n /** Index of the token closing the bracket opened at `open`. */\n const closer = (open: number): number => {\n let depth = 0;\n for (let k = open; k < toks.length; k++) {\n if (toks[k] === '(' || toks[k] === '[' || toks[k] === '{') depth++;\n else if (toks[k] === ')' || toks[k] === ']' || toks[k] === '}') {\n if (--depth === 0) return k;\n }\n }\n return toks.length;\n };\n\n /** Parses `[size]` at `j` if present: the size (undefined if absent, null\n * if unresolvable) and where scanning resumes. */\n const arraySuffix = (j: number): [number | null | undefined, number] => {\n if (toks[j] !== '[') return [undefined, j];\n const end = closer(j);\n return [evalSize(j + 1, end), end + 1];\n };\n\n /** Declarators `a, b[2], c` up to the terminating `;` (or `}`), after the\n * type at `j`. Returns them and the index of the terminator. */\n const declarators = (\n j: number,\n typeSize: number | null | undefined,\n ): [{ name: string; size: number | null | undefined }[], number] => {\n const found: { name: string; size: number | null | undefined }[] = [];\n while (j < toks.length && toks[j] !== ';' && toks[j] !== '}') {\n const name = toks[j];\n const [size, next] = arraySuffix(j + 1);\n j = next;\n if (IDENT.test(name)) found.push({ name, size: size === undefined ? typeSize : size });\n // Skip an initializer, or anything else, to the next declarator.\n while (j < toks.length && toks[j] !== ',' && toks[j] !== ';' && toks[j] !== '}') {\n j = toks[j] === '(' || toks[j] === '[' || toks[j] === '{' ? closer(j) + 1 : j + 1;\n }\n if (toks[j] === ',') j++;\n }\n return [found, j];\n };\n\n /** `struct Name? { members }` at `i`; records a named struct. */\n const structSpecifier = (i: number): [Member[], number] => {\n let j = i + 1;\n const name = toks[j] !== '{' ? toks[j++] : undefined;\n const members: Member[] = [];\n if (toks[j] !== '{') return [members, j];\n const end = closer(j);\n j++;\n while (j < end) {\n while (QUALIFIERS.has(toks[j])) j++;\n let type: string | Member[];\n if (toks[j] === 'struct') [type, j] = structSpecifier(j);\n else type = toks[j++];\n const [typeSize, afterType] = arraySuffix(j);\n const [decls, term] = declarators(afterType, typeSize);\n for (const d of decls) if (d.size !== null) members.push({ type, name: d.name, size: d.size ?? null });\n j = term + 1;\n }\n if (name) {\n // A struct redefined in another preprocessor branch keeps both members lists.\n const prior = structs.get(name) ?? [];\n for (const m of members) if (!prior.some((p) => p.name === m.name)) prior.push(m);\n structs.set(name, prior);\n }\n return [members, end + 1];\n };\n\n const expand = (name: string, type: string | readonly Member[], size: number | null, depth: number): void => {\n if (depth > MAX_DEPTH) return;\n if (size !== null) {\n if (typeof type === 'string' && !structs.has(type)) {\n const prior = arrays.get(name);\n if (!prior || size > prior.size) arrays.set(name, { type, size });\n }\n for (let k = 0; k < size; k++) expand(`${name}[${k}]`, type, null, depth + 1);\n return;\n }\n const members = typeof type === 'string' ? structs.get(type) : type;\n if (!members) {\n out.add(name);\n return;\n }\n for (const m of members) expand(`${name}.${m.name}`, m.type, m.size, depth + 1);\n };\n\n let depth = 0;\n for (let i = 0; i < toks.length; i++) {\n const t = toks[i];\n if (t === '{') depth++;\n else if (t === '}') depth--;\n else if (t === 'struct') i = structSpecifier(i)[1] - 1;\n else if (depth === 0 && t === 'const') {\n let j = i + 1;\n while (QUALIFIERS.has(toks[j])) j++;\n if ((toks[j] === 'int' || toks[j] === 'uint') && IDENT.test(toks[j + 1] ?? '') && toks[j + 2] === '=') {\n let end = j + 3;\n while (end < toks.length && toks[end] !== ';') end++;\n const v = evalSize(j + 3, end);\n const prior = consts.get(toks[j + 1]);\n if (v !== null && (prior === undefined || v > prior)) consts.set(toks[j + 1], v);\n }\n } else if (depth === 0 && t === 'uniform') {\n let j = i + 1;\n while (QUALIFIERS.has(toks[j])) j++;\n let type: string | Member[];\n if (toks[j] === 'struct') {\n [type, j] = structSpecifier(j);\n } else if (toks[j + 1] === '{') {\n // An interface block: skip it and its instance name.\n j = closer(j + 1) + 1;\n while (j < toks.length && toks[j] !== ';') j++;\n i = j;\n continue;\n } else {\n type = toks[j++];\n }\n const [typeSize, afterType] = arraySuffix(j);\n const [decls, term] = declarators(afterType, typeSize);\n for (const d of decls) if (d.size !== null) expand(d.name, type, d.size ?? null, 0);\n i = term;\n }\n }\n return { names: out, arrays };\n}\n\n/** Comments stripped and directives removed. Every conditional branch is kept:\n * an extra name only looks up a null location, a missing one drops writes. */\nfunction preprocess(glsl: string): { code: string; defines: Map<string, string[]> } {\n const spliced = glsl.replace(/\\\\\\r?\\n/g, '');\n let stripped = '';\n for (let k = 0; k < spliced.length; k++) {\n if (spliced[k] === '/' && spliced[k + 1] === '/') {\n while (k < spliced.length && spliced[k] !== '\\n') k++;\n stripped += '\\n';\n } else if (spliced[k] === '/' && spliced[k + 1] === '*') {\n const end = spliced.indexOf('*/', k + 2);\n k = end < 0 ? spliced.length : end + 1;\n stripped += ' ';\n } else {\n stripped += spliced[k];\n }\n }\n const defines = new Map<string, string[]>();\n const lines = stripped.split('\\n').map((line) => {\n if (!/^\\s*#/.test(line)) return line;\n const def = /^\\s*#\\s*define\\s+([A-Za-z_]\\w*)(\\(?)(.*)$/.exec(line);\n if (def && !def[2]) defines.set(def[1], [...(defines.get(def[1]) ?? []), def[3].trim()]);\n return '';\n });\n return { code: lines.join('\\n'), defines };\n}\n\nfunction tokenize(src: string): string[] {\n return src.match(/[A-Za-z_]\\w*|\\d[\\w.]*|\\S/g) ?? [];\n}\n\nfunction intLiteral(tok: string): number | null {\n const m = /^(?:0[xX]([0-9a-fA-F]+)|(0[0-7]*)|([1-9]\\d*))[uU]?$/.exec(tok);\n if (!m) return null;\n if (m[1] !== undefined) return parseInt(m[1], 16);\n if (m[2] !== undefined) return parseInt(m[2], 8);\n return parseInt(m[3], 10);\n}\n\n/** Integer constant expression over `+ - * / %` and parentheses. */\nfunction evalInt(toks: readonly string[], lookup: (name: string) => number | null): number | null {\n let p = 0;\n const primary = (): number | null => {\n const t = toks[p++];\n if (t === '(') {\n const v = sum();\n return toks[p++] === ')' ? v : null;\n }\n if (t === '-') {\n const v = primary();\n return v === null ? null : -v;\n }\n if (t === '+') return primary();\n if (t === undefined) return null;\n return intLiteral(t) ?? (IDENT.test(t) ? lookup(t) : null);\n };\n const product = (): number | null => {\n let v = primary();\n while (v !== null && (toks[p] === '*' || toks[p] === '/' || toks[p] === '%')) {\n const op = toks[p++];\n const r = primary();\n if (r === null || (op !== '*' && r === 0)) return null;\n v = op === '*' ? v * r : op === '/' ? Math.trunc(v / r) : v % r;\n }\n return v;\n };\n const sum = (): number | null => {\n let v = product();\n while (v !== null && (toks[p] === '+' || toks[p] === '-')) {\n const op = toks[p++];\n const r = product();\n if (r === null) return null;\n v = op === '+' ? v + r : v - r;\n }\n return v;\n };\n const v = sum();\n return p === toks.length && v !== null && v >= 0 ? v : null;\n}\n","import { createPaintResources, type OwnedPaintResources } from './paintResources';\nimport { ShaderProgram } from './shaders/ShaderProgram';\nimport {\n VERT_SRC,\n FRAG_SRC,\n VCOLOR_VERT_SRC,\n VCOLOR_FRAG_SRC,\n PATH_FILL_UNIFORMS,\n PATH_FILL_ATTRIBUTES,\n PATH_FILL_VCOLOR_ATTRIBUTES,\n} from './shaders/pathFill';\nimport {\n markAllFontsNotUploaded,\n resetBakeBudget,\n DEFAULT_BAKE_BUDGET,\n} from '@weasel-js/font';\nimport {\n BATCH_VERT_SRC,\n BATCH_FRAG_SRC,\n BATCH_FILL_UNIFORMS,\n BATCH_FILL_ATTRIBUTES,\n} from './shaders/batchFill';\nimport {\n GRAD_VERT_SRC,\n GRAD_FRAG_SRC,\n GRAD_FILL_UNIFORMS,\n GRAD_FILL_ATTRIBUTES,\n} from './shaders/gradFill';\nimport {\n PATTERN_VERT_SRC,\n PATTERN_FRAG_SRC,\n PATTERN_FILL_UNIFORMS,\n PATTERN_FILL_ATTRIBUTES,\n} from './shaders/patternFill';\nimport {\n GLYPH_PAINT_VERT_SRC,\n GLYPH_PATTERN_FRAG_SRC,\n GLYPH_GRAD_FRAG_SRC,\n GLYPH_TEXTURE_FRAG_SRC,\n GLYPH_PATTERN_UNIFORMS,\n GLYPH_GRAD_UNIFORMS,\n GLYPH_TEXTURE_UNIFORMS,\n GLYPH_PAINT_ATTRIBUTES,\n} from './shaders/glyphPaint';\nimport { PaintScratch } from './paintScratch';\nimport { GLMeshCache } from './cache/GLMeshCache';\nimport { GLTextureCache } from './cache/GLTextureCache';\nimport { textureRegistry } from './textures/registerTexture';\nimport { GLImageCache, type ImageMinification } from './cache/GLImageCache';\nimport { GradientRampAtlas } from './cache/GradientRampAtlas';\nimport { GroupState } from './state/GroupState';\nimport type { DrawCommand } from './DrawCommand';\nimport type { GlMat3 } from '@weasel-js/geom';\nimport {\n dispatch, flushBatch, OUTLINE_MIN_SCREEN_PX, type DrawContext, type GlyphPaintKind,\n} from './draw';\nimport { DrawBatch } from './drawBatch';\nimport {\n CUSTOM_VERT_SRC, CUSTOM_ATTRIBUTES, CUSTOM_KIT_UNIFORMS,\n QUAD_VERTICES, QUAD_INDICES,\n} from './shaders/customPrelude';\nimport { getProgramSource, type ProgramSource, type ShaderProgramHandle } from './shaders/registerProgram';\nimport { EffectTargets } from './effects/EffectTargets';\nimport { extractUniformArrays, extractUniformNames } from './shaders/extractUniformNames';\n\n/** Every uniform a custom program may be written through. Both stages, not\n * just the fragment one: a name never looked up is written through `null`,\n * which GL accepts silently, so the uniform keeps its zero default. */\nfunction customUniformNames(vertSrc: string, fragSrc: string): string[] {\n return [...CUSTOM_KIT_UNIFORMS, ...extractUniformNames(vertSrc), ...extractUniformNames(fragSrc)];\n}\n\n/** Compile a registered program's source against `gl`, with every uniform\n * location and array base it may be written through. */\nfunction compileCustomProgram(gl: WebGL2RenderingContext, src: ProgramSource): ShaderProgram {\n const vertSrc = src.vert === '' ? CUSTOM_VERT_SRC : src.vert;\n const program = new ShaderProgram(gl, vertSrc, src.frag);\n program.lookupUniforms(customUniformNames(vertSrc, src.frag));\n program.lookupUniformArrays(new Map([...extractUniformArrays(vertSrc), ...extractUniformArrays(src.frag)]));\n program.lookupAttributes(CUSTOM_ATTRIBUTES);\n return program;\n}\n\n/** A run of top-level commands, `[start, end)` by index, that\n * {@link WeaselRenderer.lastFrameStats} accounts for separately — one render\n * layer's commands, say. Spans are in order and do not overlap. */\nexport interface RenderSpan {\n id: string;\n start: number;\n end: number;\n}\n\n/** Per-frame options for {@link WeaselRenderer.render}. */\nexport interface RenderOptions {\n spans?: readonly RenderSpan[];\n}\n\n/** What one span cost. A batched run is drawn when something closes it, so\n * its draw call counts toward the span that closed it. */\nexport interface RenderSpanStats {\n id: string;\n drawCalls: number;\n ms: number;\n}\n\n/** What one `render()` cost. See {@link WeaselRenderer.lastFrameStats}. */\nexport interface RenderStats {\n drawCalls: number;\n ms: number;\n spans: RenderSpanStats[];\n}\n\nfunction now(): number {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n\n/** Construction options for {@link WeaselRenderer}. Pass `gl` or `canvas`;\n * a context passed in must have a stencil buffer. */\nexport interface WeaselRendererOptions {\n /** A WebGL2 context to draw with. Wins over `canvas`. */\n gl?: WebGL2RenderingContext;\n /** A canvas to open a stencil-backed WebGL2 context on, when `gl` is absent. */\n canvas?: HTMLCanvasElement;\n /** Drawing size in CSS pixels. */\n width: number;\n /** Drawing size in CSS pixels. */\n height: number;\n /** Device pixels per CSS pixel. */\n dpr: number;\n /** MIN_FILTER strategy for image/pattern textures (`GLImageCache`).\n * Default `'linear'` — the existing screen behavior. The headless\n * `renderSceneToPixels` path passes `'mipmap'` for print-quality\n * minification. Explicitly passing `'linear'` is always valid. */\n imageMinification?: ImageMinification;\n /** Flatness tolerance for curve tessellation, in WORLD units (see\n * `TessellateOptions.flattenTolerance`). When set, path fills are\n * tessellated fresh at this tolerance per frame (transient pool) instead\n * of served from the Path-identity mesh cache — the cache key does not\n * include tolerance. Default: unset — the existing cached behavior at\n * `DEFAULT_FLATTEN_TOLERANCE`. The headless path derives this from the\n * requested output scale; screen callers normally leave it unset. */\n flattenTolerance?: number;\n /** Per-render synchronous bake budget for dynamic canvas-SDF glyphs.\n * Default DEFAULT_BAKE_BUDGET (16). The headless renderSceneToPixels\n * path passes Infinity so print never defers a glyph. */\n bakeBudget?: number;\n /** On-screen glyph size, in CSS pixels, at or above which text renders from\n * tessellated font outlines instead of a distance field — see\n * `OUTLINE_MIN_SCREEN_PX`. Only faces registered with\n * `registerFontOutlines` are affected; everything else keeps its SDF tier\n * whatever this says. Pass `Infinity` to disable the tier outright, or 0\n * to use outlines wherever they exist (what the headless path does, since\n * print has no reason to sample a field it could evaluate exactly). */\n textOutlineMinScreenSize?: number;\n}\n\n/** Where a renderer draws inside a buffer it does not own.\n *\n * The rect's SIZE is the renderer's own `width`/`height` — `resize()` owns\n * that, and a second copy here could disagree with the one `DrawContext`\n * reports to screen-space layers. */\nexport interface RenderTarget {\n /** Top-left of this renderer's output within the drawing buffer, in CSS\n * pixels, with the origin at the buffer's top-left. GL's bottom-left origin\n * is handled internally. */\n origin: { x: number; y: number };\n /** Clear colour and stencil within the rect before drawing. Default true.\n * Pass false only when the caller clears the whole buffer itself on behalf\n * of every co-tenant — a frame that clears neither inherits its neighbour's\n * stencil bits, and even-odd fills then fill their holes. */\n clear?: boolean;\n}\n\n/** Each glyph-paint program's fragment stage and the uniforms it looks up. */\nconst GLYPH_PAINT_SOURCES: Record<GlyphPaintKind, readonly [string, readonly string[]]> = {\n pattern: [GLYPH_PATTERN_FRAG_SRC, GLYPH_PATTERN_UNIFORMS],\n gradient: [GLYPH_GRAD_FRAG_SRC, GLYPH_GRAD_UNIFORMS],\n texture: [GLYPH_TEXTURE_FRAG_SRC, GLYPH_TEXTURE_UNIFORMS],\n};\n\n/**\n * The WebGL2 renderer: takes a list of draw commands and paints them.\n *\n * It knows nothing about the scene — commands are the whole interface, which\n * is what lets layers, HUD widgets and overlays all draw through the same\n * pipeline. GPU resources (meshes, textures, gradient ramps) are cached across\n * frames and keyed by identity, so re-issuing the same command is cheap.\n */\nexport class WeaselRenderer {\n private readonly gl: WebGL2RenderingContext;\n private stats: RenderStats = { drawCalls: 0, ms: 0, spans: [] };\n private pathFill: ShaderProgram;\n private pathFillVColor: ShaderProgram;\n private batchFill: ShaderProgram;\n private gradFill: ShaderProgram;\n private patternFill: ShaderProgram;\n /** Compiled on first use: only atlas text under a texture paint needs one. */\n private glyphPaintPrograms = new Map<GlyphPaintKind, ShaderProgram>();\n private meshCache: GLMeshCache;\n private textureCache: GLTextureCache;\n private imageCache: GLImageCache;\n private gradRamps: GradientRampAtlas;\n private programRegistry = new Map<string, ShaderProgram>();\n /** The source each compiled custom program was built from — or, after a\n * failed recompile, the source that failed, so it is not retried every frame. */\n private programSources = new Map<string, ProgramSource>();\n private quadVbo: WebGLBuffer | null = null;\n private quadIbo: WebGLBuffer | null = null;\n private drawBatch: DrawBatch;\n /** 1x1 white, so a batch flush sampling no image still samples something —\n * see `shaders/batchFill.ts`. */\n private whiteTexture: WebGLTexture | null = null;\n private readonly groupState = new GroupState();\n private widthCss: number;\n private heightCss: number;\n private dpr: number;\n private canvas: HTMLCanvasElement | null = null;\n /** Where context loss is announced: the context's own canvas, which the\n * renderer need not own the size of. */\n private lossTarget: EventTarget | null = null;\n private target: RenderTarget | null = null;\n /** Offscreen buffers for group effects. Allocates nothing until a group\n * with effects asks, so a canvas without them pays no memory. */\n private readonly effectTargets: EffectTargets;\n private readonly paintScratch: PaintScratch;\n private readonly imageMinification: ImageMinification;\n private flattenTolerance?: number;\n private readonly bakeBudget: number;\n private readonly textOutlineMinScreenSize: number;\n private contextLost = false;\n private boundOnLost = (e: Event) => this.onContextLost(e);\n private boundOnRestored = () => this.onContextRestored();\n /** True after `dispose()`. A disposed renderer ignores further `render()`\n * calls and `registerProgram()` calls. */\n private disposed = false;\n /** What registered paint kinds hang their GPU state on. One per context\n * generation: a restore releases it and opens the next. */\n private paintResources: OwnedPaintResources = createPaintResources();\n\n constructor(opts: WeaselRendererOptions) {\n if (!opts.gl && !opts.canvas) {\n throw new Error('WeaselRenderer requires either gl or canvas');\n }\n const gl = opts.gl ?? opts.canvas!.getContext('webgl2', { stencil: true });\n if (!gl) throw new Error('WeaselRenderer: WebGL2 not available');\n this.gl = gl as WebGL2RenderingContext;\n this.effectTargets = new EffectTargets(this.gl);\n this.paintScratch = new PaintScratch(this.gl);\n\n // Bits 0-7 are load-bearing: bit 0 for even-odd fills and stenciled\n // strokes, bits 1-7 for clip depth (`renderer/draw.ts`). Without a stencil\n // buffer both render wrong rather than not at all, so refuse the context\n // instead of painting a plausible lie. A stub that cannot answer is not a\n // stencil-less context — only an explicit `false` is.\n const attrs = typeof this.gl.getContextAttributes === 'function'\n ? this.gl.getContextAttributes()\n : null;\n if (attrs && attrs.stencil === false) {\n throw new Error(\n 'WeaselRenderer: the supplied WebGL2 context has no stencil buffer. '\n + 'Create it with { stencil: true } — clips and even-odd fills need one.',\n );\n }\n\n this.widthCss = opts.width;\n this.heightCss = opts.height;\n this.dpr = opts.dpr;\n this.imageMinification = opts.imageMinification ?? 'linear';\n this.flattenTolerance = opts.flattenTolerance;\n this.bakeBudget = opts.bakeBudget ?? DEFAULT_BAKE_BUDGET;\n this.textOutlineMinScreenSize = opts.textOutlineMinScreenSize ?? OUTLINE_MIN_SCREEN_PX;\n\n this.canvas = opts.canvas ?? null;\n if (this.canvas) {\n this.canvas.width = Math.round(opts.width * opts.dpr);\n this.canvas.height = Math.round(opts.height * opts.dpr);\n if (this.canvas.style) {\n this.canvas.style.width = `${opts.width}px`;\n this.canvas.style.height = `${opts.height}px`;\n }\n }\n const lossTarget: Partial<EventTarget> | null = this.canvas ?? this.gl.canvas ?? null;\n if (lossTarget && typeof lossTarget.addEventListener === 'function') {\n this.lossTarget = lossTarget as EventTarget;\n this.lossTarget.addEventListener('webglcontextlost', this.boundOnLost);\n this.lossTarget.addEventListener('webglcontextrestored', this.boundOnRestored);\n }\n\n this.applyGlState();\n this.applyTarget();\n\n this.pathFill = new ShaderProgram(this.gl, VERT_SRC, FRAG_SRC);\n this.pathFill.lookupUniforms(PATH_FILL_UNIFORMS);\n this.pathFill.lookupAttributes(PATH_FILL_ATTRIBUTES);\n\n this.pathFillVColor = new ShaderProgram(this.gl, VCOLOR_VERT_SRC, VCOLOR_FRAG_SRC);\n this.pathFillVColor.lookupUniforms(PATH_FILL_UNIFORMS);\n this.pathFillVColor.lookupAttributes(PATH_FILL_VCOLOR_ATTRIBUTES);\n\n this.batchFill = new ShaderProgram(this.gl, BATCH_VERT_SRC, BATCH_FRAG_SRC);\n this.batchFill.lookupUniforms(BATCH_FILL_UNIFORMS);\n this.batchFill.lookupAttributes(BATCH_FILL_ATTRIBUTES);\n\n this.gradFill = new ShaderProgram(this.gl, GRAD_VERT_SRC, GRAD_FRAG_SRC);\n this.gradFill.lookupUniforms(GRAD_FILL_UNIFORMS);\n this.gradFill.lookupAttributes(GRAD_FILL_ATTRIBUTES);\n\n this.patternFill = new ShaderProgram(this.gl, PATTERN_VERT_SRC, PATTERN_FRAG_SRC);\n this.patternFill.lookupUniforms(PATTERN_FILL_UNIFORMS);\n this.patternFill.lookupAttributes(PATTERN_FILL_ATTRIBUTES);\n\n this.meshCache = new GLMeshCache(this.gl);\n this.textureCache = new GLTextureCache(this.gl);\n this.imageCache = new GLImageCache(this.gl, this.imageMinification);\n this.gradRamps = new GradientRampAtlas(this.gl);\n this.uploadQuadGeometry();\n this.drawBatch = new DrawBatch(this.gl, this.batchFill);\n this.whiteTexture = createWhiteTexture(this.gl);\n }\n\n private uploadQuadGeometry(): void {\n const gl = this.gl;\n this.quadVbo = gl.createBuffer();\n this.quadIbo = gl.createBuffer();\n if (!this.quadVbo || !this.quadIbo) {\n throw new Error('WeaselRenderer: failed to create quad geometry buffers');\n }\n gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVbo);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD_VERTICES, gl.STATIC_DRAW);\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.quadIbo);\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, QUAD_INDICES, gl.STATIC_DRAW);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n }\n\n /**\n * Compile a consumer-registered shader program against this renderer's GL context.\n *\n * Call once per renderer after the module-level `registerProgram()`.\n * Throws `ShaderCompileError` if compilation fails.\n *\n * In dev mode, calling again with the same handle replaces the compiled program.\n *\n * @experimental\n */\n registerProgram(handle: ShaderProgramHandle): void {\n // A disposed renderer must not compile programs into the cleared registry.\n if (this.disposed) return;\n const src = getProgramSource(handle.id);\n if (!src) {\n throw new Error(\n `WeaselRenderer.registerProgram: program \"${handle.id}\" not found in source registry. ` +\n `Call the module-level registerProgram() first.`,\n );\n }\n this.installProgram(handle.id, src, compileCustomProgram(this.gl, src));\n }\n\n private installProgram(id: string, src: ProgramSource, program: ShaderProgram): void {\n const previous = this.programRegistry.get(id);\n if (previous) this.gl.deleteProgram(previous.handle);\n this.programRegistry.set(id, program);\n this.programSources.set(id, src);\n }\n\n /** Recompile every program whose module-level source was re-registered\n * since it was compiled. A source that fails keeps the old program drawing. */\n private refreshPrograms(): void {\n for (const [id, compiled] of this.programSources) {\n const src = getProgramSource(id);\n if (!src || src === compiled) continue;\n if (src.vert === compiled.vert && src.frag === compiled.frag) {\n this.programSources.set(id, src);\n continue;\n }\n try {\n this.installProgram(id, src, compileCustomProgram(this.gl, src));\n } catch (e) {\n this.programSources.set(id, src);\n console.error(`weasel: failed to recompile re-registered program \"${id}\"; still drawing the previous one:`, e);\n }\n }\n }\n\n /**\n * The compiled program for `id`, compiling it against this context on first\n * use. Unlike {@link registerProgram} this neither throws on a missing\n * source nor on a compile failure: a paint kind asking for a program it\n * never registered must decline the paint, not take down the frame.\n */\n private ensureProgram(id: string): ShaderProgram | null {\n const existing = this.programRegistry.get(id);\n if (existing) return existing;\n if (this.disposed || !getProgramSource(id)) return null;\n try {\n this.registerProgram({ id });\n } catch (e) {\n console.error(`weasel: failed to compile paint program \"${id}\":`, e);\n return null;\n }\n return this.programRegistry.get(id) ?? null;\n }\n\n private glyphPaintProgram(kind: GlyphPaintKind): ShaderProgram {\n const existing = this.glyphPaintPrograms.get(kind);\n if (existing) return existing;\n const [frag, uniforms] = GLYPH_PAINT_SOURCES[kind];\n const program = new ShaderProgram(this.gl, GLYPH_PAINT_VERT_SRC, frag);\n program.lookupUniforms(uniforms);\n program.lookupAttributes(GLYPH_PAINT_ATTRIBUTES);\n this.glyphPaintPrograms.set(kind, program);\n return program;\n }\n\n /** The blend, depth, cull, clear-color, color-mask, VAO, and unpack-flip\n * state every frame assumes.\n * Applied per `render()` rather than once at construction because a\n * co-tenant sharing this context moves all of it between our frames. */\n private applyGlState(): void {\n const gl = this.gl;\n gl.enable(gl.BLEND);\n gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);\n gl.disable(gl.DEPTH_TEST);\n gl.disable(gl.CULL_FACE);\n gl.clearColor(0, 0, 0, 0);\n gl.colorMask(true, true, true, true);\n gl.bindVertexArray(null);\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);\n }\n\n /** Viewport and scissor for this frame. Re-applied inside `render()` because\n * a co-tenant on the same context moves both between our frames. */\n /** This renderer's rect in device pixels, top-left origin. A tile rounds its\n * edges rather than its size, so two that share a CSS edge share a device one. */\n private deviceRect(): { x: number; y: number; width: number; height: number } {\n const ox = this.target?.origin.x ?? 0;\n const oy = this.target?.origin.y ?? 0;\n const x = Math.round(ox * this.dpr);\n const y = Math.round(oy * this.dpr);\n return {\n x,\n y,\n width: Math.round((ox + this.widthCss) * this.dpr) - x,\n height: Math.round((oy + this.heightCss) * this.dpr) - y,\n };\n }\n\n private applyTarget(): void {\n const gl = this.gl;\n const { x, y, width, height } = this.deviceRect();\n if (!this.target) {\n gl.disable(gl.SCISSOR_TEST);\n gl.viewport(0, 0, width, height);\n return;\n }\n const glY = gl.drawingBufferHeight - y - height;\n gl.viewport(x, glY, width, height);\n gl.scissor(x, glY, width, height);\n gl.enable(gl.SCISSOR_TEST);\n }\n\n /** Confine this renderer to a rect of its drawing buffer, or pass null to\n * give it the whole buffer back. Takes effect from the next `render()`. */\n setTarget(target: RenderTarget | null): void {\n this.target = target;\n this.applyTarget();\n }\n\n getTarget(): RenderTarget | null {\n return this.target;\n }\n\n isContextLost(): boolean {\n return this.contextLost;\n }\n\n private onContextLost(e: Event): void {\n e.preventDefault();\n this.contextLost = true;\n }\n\n private onContextRestored(): void {\n this.contextLost = false;\n this.applyGlState();\n this.applyTarget();\n // Every framebuffer, texture and renderbuffer the pool held died with the\n // context. `releaseAll` deletes handles that are already gone, which is a\n // no-op, and drops the bookkeeping that would otherwise hand a dead FBO to\n // the next group with effects.\n this.effectTargets.releaseAll();\n this.paintScratch.release();\n this.paintResources.release();\n this.paintResources = createPaintResources();\n this.pathFill = new ShaderProgram(this.gl, VERT_SRC, FRAG_SRC);\n this.pathFill.lookupUniforms(PATH_FILL_UNIFORMS);\n this.pathFill.lookupAttributes(PATH_FILL_ATTRIBUTES);\n this.pathFillVColor = new ShaderProgram(this.gl, VCOLOR_VERT_SRC, VCOLOR_FRAG_SRC);\n this.pathFillVColor.lookupUniforms(PATH_FILL_UNIFORMS);\n this.pathFillVColor.lookupAttributes(PATH_FILL_VCOLOR_ATTRIBUTES);\n\n this.batchFill = new ShaderProgram(this.gl, BATCH_VERT_SRC, BATCH_FRAG_SRC);\n this.batchFill.lookupUniforms(BATCH_FILL_UNIFORMS);\n this.batchFill.lookupAttributes(BATCH_FILL_ATTRIBUTES);\n this.gradFill = new ShaderProgram(this.gl, GRAD_VERT_SRC, GRAD_FRAG_SRC);\n this.gradFill.lookupUniforms(GRAD_FILL_UNIFORMS);\n this.gradFill.lookupAttributes(GRAD_FILL_ATTRIBUTES);\n\n this.patternFill = new ShaderProgram(this.gl, PATTERN_VERT_SRC, PATTERN_FRAG_SRC);\n this.patternFill.lookupUniforms(PATTERN_FILL_UNIFORMS);\n this.patternFill.lookupAttributes(PATTERN_FILL_ATTRIBUTES);\n this.glyphPaintPrograms.clear();\n this.meshCache = new GLMeshCache(this.gl);\n this.textureCache = new GLTextureCache(this.gl);\n this.imageCache.abandon();\n this.imageCache = new GLImageCache(this.gl, this.imageMinification);\n this.gradRamps = new GradientRampAtlas(this.gl);\n markAllFontsNotUploaded();\n\n this.uploadQuadGeometry();\n this.drawBatch = new DrawBatch(this.gl, this.batchFill);\n this.whiteTexture = createWhiteTexture(this.gl);\n for (const id of this.programRegistry.keys()) {\n const src = getProgramSource(id);\n if (!src) continue;\n try {\n this.programRegistry.set(id, compileCustomProgram(this.gl, src));\n this.programSources.set(id, src);\n } catch (e) {\n console.error(`weasel: failed to recompile program \"${id}\" after context restore:`, e);\n }\n }\n }\n\n /** Free every GL resource this renderer created and detach its\n * context-loss listeners. Idempotent.\n *\n * That covers the built-in and consumer-registered programs (their shaders\n * go with them), the shared quad geometry, the batch, the effect targets,\n * and every cache: atlas and gradient-ramp textures, bitmap and pattern\n * textures, and meshes — transient, persistent, and those whose Path was\n * already collected. The context itself is left alone, so a caller-owned\n * context can host renderer after renderer without accumulating anything.\n *\n * A disposed renderer ignores further `render()` and `registerProgram()`\n * calls. */\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n const gl = this.gl;\n if (this.lossTarget) {\n this.lossTarget.removeEventListener('webglcontextlost', this.boundOnLost);\n this.lossTarget.removeEventListener('webglcontextrestored', this.boundOnRestored);\n }\n this.meshCache.dispose();\n this.paintResources.release();\n for (const prog of [\n this.pathFill, this.pathFillVColor, this.batchFill, this.gradFill, this.patternFill,\n ...this.glyphPaintPrograms.values(),\n ]) {\n gl.deleteProgram(prog.handle);\n }\n this.glyphPaintPrograms.clear();\n for (const prog of this.programRegistry.values()) {\n gl.deleteProgram(prog.handle);\n }\n this.programRegistry.clear();\n this.programSources.clear();\n this.textureCache.free();\n this.imageCache.dispose();\n this.gradRamps.free();\n if (this.quadVbo) gl.deleteBuffer(this.quadVbo);\n if (this.quadIbo) gl.deleteBuffer(this.quadIbo);\n this.drawBatch.dispose();\n if (this.whiteTexture) gl.deleteTexture(this.whiteTexture);\n this.whiteTexture = null;\n this.effectTargets.releaseAll();\n this.paintScratch.release();\n }\n\n /**\n * Draw one frame.\n *\n * `viewMatrix` is the frame's world→screen transform. It is only consulted\n * by `units: 'world'` gradients, which fall back to screen space without\n * it — every other command carries its own transform in the stream, so\n * callers with no view concept can keep calling `render(commands)`.\n */\n render(commands: DrawCommand[], viewMatrix?: GlMat3, opts?: RenderOptions): void {\n if (this.contextLost || this.disposed) return;\n const t0 = now();\n const counters = { drawCalls: 0 };\n const spanStats: RenderSpanStats[] = [];\n this.stats = { drawCalls: 0, ms: 0, spans: spanStats };\n const gl = this.gl;\n // Free GL resources whose Mesh was GC'd since the last frame. Done here\n // (top of render, before any draws) because GL state is known clean —\n // no VAO bound, no draw in flight. Deleting from the FinalizationRegistry\n // callback directly was racy and caused mid-draw crashes.\n this.meshCache.drainPendingDeletes();\n this.imageCache.drainPendingDeletes();\n this.textureCache.sweep(textureRegistry);\n this.refreshPrograms();\n // New frame: refill the dynamic-glyph synchronous bake budget.\n resetBakeBudget(this.bakeBudget);\n // A frame that threw part-way never unwound: its group stack, its staged\n // vertices, the effect buffer it was drawing into, and whichever\n // offscreen buffer it had bound are all still here.\n this.groupState.reset();\n this.drawBatch.reset();\n this.effectTargets.reclaim();\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n this.applyGlState();\n this.applyTarget();\n // Ensure all stencil bits are cleared regardless of any mask left over\n // from the previous frame's clip ops.\n if (this.target?.clear !== false) {\n gl.stencilMask(0xFF);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);\n }\n const device = this.deviceRect();\n const ctx: DrawContext = {\n gl,\n pathFill: this.pathFill,\n pathFillVColor: this.pathFillVColor,\n batchFill: this.batchFill,\n gradFill: this.gradFill,\n patternFill: this.patternFill,\n meshCache: this.meshCache,\n textureCache: this.textureCache,\n imageCache: this.imageCache,\n gradRamps: this.gradRamps,\n programRegistry: this.programRegistry,\n ensureProgram: (id) => this.ensureProgram(id),\n glyphPaintProgram: (kind) => this.glyphPaintProgram(kind),\n quadVbo: this.quadVbo,\n quadIbo: this.quadIbo,\n drawBatch: this.drawBatch,\n whiteTexture: this.whiteTexture,\n state: this.groupState,\n widthCss: this.widthCss,\n heightCss: this.heightCss,\n clipDepth: 0,\n clipStack: [],\n flattenTolerance: this.flattenTolerance,\n textOutlineMinScreenSize: this.textOutlineMinScreenSize,\n viewMatrix,\n effectTargets: this.effectTargets,\n paintScratch: this.paintScratch,\n renderTarget: null,\n deviceWidth: device.width,\n deviceHeight: device.height,\n restoreTargetRect: () => this.applyTarget(),\n paintResources: this.paintResources,\n stats: counters,\n };\n // A frame that threw part-way left its clip here.\n this.drawBatch.clip = null;\n const spans = opts?.spans ?? [];\n let next = 0;\n for (let si = 0; si < spans.length; si++) {\n const span = spans[si];\n for (; next < span.start; next++) dispatch(ctx, commands[next]);\n const drawsBefore = counters.drawCalls;\n const spanT0 = now();\n for (; next < span.end; next++) dispatch(ctx, commands[next]);\n // The stream's closing flush belongs to whatever it closes.\n if (si === spans.length - 1 && next >= commands.length) flushBatch(ctx);\n spanStats.push({ id: span.id, drawCalls: counters.drawCalls - drawsBefore, ms: now() - spanT0 });\n }\n for (; next < commands.length; next++) dispatch(ctx, commands[next]);\n // The stream ended, so whatever is still staged has nothing left that\n // could merge with it.\n flushBatch(ctx);\n // Free transient resources allocated during this frame (e.g. per-frame\n // stroke ribbons from tessellateStroke). Done after all draws complete\n // so we never delete a buffer that's still bound to a pending draw.\n this.meshCache.freeTransient();\n this.stats.drawCalls = counters.drawCalls;\n this.stats.ms = now() - t0;\n }\n\n /** What the last `render()` cost: GL draw calls issued and CPU milliseconds\n * spent issuing them, in total and per requested span. GPU time is not\n * measured; the GPU runs asynchronously. */\n lastFrameStats(): RenderStats {\n return this.stats;\n }\n\n /** Change the curve-flattening tolerance after construction. `undefined`\n * restores the cached `DEFAULT_FLATTEN_TOLERANCE` route. */\n setFlattenTolerance(tolerance: number | undefined): void {\n this.flattenTolerance = tolerance;\n }\n\n resize(dims: { width: number; height: number; dpr: number }): void {\n this.widthCss = dims.width;\n this.heightCss = dims.height;\n this.dpr = dims.dpr;\n if (this.canvas) {\n this.canvas.width = Math.round(dims.width * dims.dpr);\n this.canvas.height = Math.round(dims.height * dims.dpr);\n if (this.canvas.style) {\n this.canvas.style.width = `${dims.width}px`;\n this.canvas.style.height = `${dims.height}px`;\n }\n }\n this.applyTarget();\n }\n\n /** @internal */ _gl(): WebGL2RenderingContext { return this.gl; }\n /** @internal */ _pathFill(): ShaderProgram { return this.pathFill; }\n /** @internal */ _pathFillVColor(): ShaderProgram { return this.pathFillVColor; }\n /** @internal */ _drawBatch(): DrawBatch { return this.drawBatch; }\n /** @internal */ _batchFill(): ShaderProgram { return this.batchFill; }\n /** @internal */ _gradFill(): ShaderProgram { return this.gradFill; }\n /** @internal */ _patternFill(): ShaderProgram { return this.patternFill; }\n /** @internal */ _meshCache(): GLMeshCache { return this.meshCache; }\n /** @internal */ _textureCache(): GLTextureCache { return this.textureCache; }\n /** @internal */ _imageCache(): GLImageCache { return this.imageCache; }\n /** @internal */ _gradRamps(): GradientRampAtlas { return this.gradRamps; }\n /** @internal */ _groupState(): GroupState { return this.groupState; }\n /** @internal */ _widthCss(): number { return this.widthCss; }\n /** @internal */ _heightCss(): number { return this.heightCss; }\n /** @internal */ _dpr(): number { return this.dpr; }\n}\n\n/** The 1x1 opaque white texture a batch flush binds when its run samples no\n * image. NEAREST both ways: one texel, so there is nothing to filter, and a\n * mipmap filter on a texture with no mipmaps is incomplete. */\nfunction createWhiteTexture(gl: WebGL2RenderingContext): WebGLTexture | null {\n const tex = gl.createTexture();\n if (!tex) return null;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texImage2D(\n gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,\n new Uint8Array([255, 255, 255, 255]),\n );\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n return tex;\n}\n","/**\n * Uniform-grid sprite sheet layout — frame index to the source rect an\n * `ImageDrawCommand` samples. Pure arithmetic over the grid description; it\n * never touches the bitmap.\n */\n\n/** A sprite sheet's grid. `margin` and `spacing` follow the Tiled / Aseprite\n * tileset convention, so a sheet exported from either describes itself here. */\nexport interface SpriteSheet {\n frameWidth: number;\n frameHeight: number;\n columns: number;\n /** Empty pixels around the whole grid. Default 0. */\n margin?: number;\n /** Empty pixels between adjacent cells — the gutter that keeps linear\n * sampling off the neighboring frame. Default 0. */\n spacing?: number;\n}\n\n/**\n * Row-major source rect for frame `index`, counting from 0 at the top-left.\n *\n * `index` is not range-checked and does not wrap: past the last cell this\n * returns a rect below the sheet, which draws as an edge smear. Wrapping is\n * the animation's business (`frameRect(sheet, tick % count)`) — a sheet does\n * not know how many of its cells are filled.\n */\nexport function frameRect(\n sheet: SpriteSheet,\n index: number,\n): { x: number; y: number; w: number; h: number } {\n const { frameWidth, frameHeight, columns } = sheet;\n const margin = sheet.margin ?? 0;\n const spacing = sheet.spacing ?? 0;\n const col = index % columns;\n const row = Math.floor(index / columns);\n return {\n x: margin + col * (frameWidth + spacing),\n y: margin + row * (frameHeight + spacing),\n w: frameWidth,\n h: frameHeight,\n };\n}\n","import { type Path, mat3, type GlMat3 } from '@weasel-js/geom';\nimport { resolveScreenLength, type Stroke } from '@weasel-js/paint';\nimport { SPRITE_STRIDE, type DrawCommand } from './DrawCommand';\nimport { resolveStrokeWidth } from '@weasel-js/stroke';\nimport { markerReach } from '@weasel-js/stroke';\n\n/** A screen-space rectangle, CSS pixels. */\nexport interface CullRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Screen pixels added to every bound: antialiasing, and the 1/8 px a `{ px }`\n * stroke's width may drift through quantization. */\nconst SLACK_PX = 1;\n\n/** Matches the tessellator's default. */\nconst DEFAULT_MITER_LIMIT = 4;\n\n/**\n * `cmds` without the commands that cannot put a pixel inside `rect`, where\n * `transform` maps the commands' space to screen space — `viewToMat3(view)`\n * for a world-space layer.\n *\n * Conservative by construction: a command is dropped only when a bound that\n * encloses everything it can paint misses `rect`. Paths are bounded by their\n * control hull plus the farthest a stroke can reach (miter spikes and square\n * caps included), images and sprites by their quads, and every bound is taken\n * through the accumulated transform as the AABB of its corners, so rotation\n * only enlarges it. Text and shader commands are always kept, and so is a\n * group with `effects` — an effect may move pixels. Clips are ignored, which\n * can only keep more. A group whose children all go is dropped.\n *\n * Returns `cmds` itself when nothing was dropped.\n */\nexport function cullDrawCommands(\n cmds: DrawCommand[],\n transform: GlMat3,\n rect: CullRect,\n): DrawCommand[] {\n return cullList(cmds, transform, slackBox(rect));\n}\n\ninterface Box { minX: number; minY: number; maxX: number; maxY: number }\n\nfunction cullList(cmds: DrawCommand[], m: GlMat3, box: Box): DrawCommand[] {\n let out: DrawCommand[] | null = null;\n for (let i = 0; i < cmds.length; i++) {\n const cmd = cmds[i];\n const kept = cullOne(cmd, m, box);\n if (kept === cmd) {\n out?.push(cmd);\n continue;\n }\n out ??= cmds.slice(0, i);\n if (kept) out.push(kept);\n }\n return out ?? cmds;\n}\n\nfunction cullOne(cmd: DrawCommand, m: GlMat3, box: Box): DrawCommand | null {\n switch (cmd.kind) {\n case 'group': {\n if (cmd.effects && cmd.effects.length > 0) return cmd;\n const inner = cmd.transform ? mat3.multiply(m, cmd.transform) : m;\n const children = cullList(cmd.children, inner, box);\n if (children === cmd.children) return cmd;\n return children.length === 0 ? null : { ...cmd, children };\n }\n case 'path':\n return pathMisses(cmd.path, cmd.stroke, m, box) ? null : cmd;\n case 'image':\n return quadMisses(cmd.x, cmd.y, cmd.x + cmd.w, cmd.y + cmd.h, m, box) ? null : cmd;\n case 'sprites':\n return spritesMiss(cmd.sprites, m, box) ? null : cmd;\n default:\n return cmd;\n }\n}\n\nfunction pathMisses(path: Path, stroke: Stroke | undefined, m: GlMat3, box: Box): boolean {\n let minX: number, minY: number, maxX: number, maxY: number;\n if (path.kind === 'rect') {\n minX = Math.min(path.x, path.x + path.width);\n maxX = Math.max(path.x, path.x + path.width);\n minY = Math.min(path.y, path.y + path.height);\n maxY = Math.max(path.y, path.y + path.height);\n } else if (path.kind === 'polygon') {\n const c = path.coords;\n if (c.length < 2) return false;\n minX = maxX = c[0];\n minY = maxY = c[1];\n for (let i = 2; i + 1 < c.length; i += 2) {\n const x = c[i], y = c[i + 1];\n if (x < minX) minX = x; else if (x > maxX) maxX = x;\n if (y < minY) minY = y; else if (y > maxY) maxY = y;\n }\n } else {\n return false;\n }\n const reach = stroke ? strokeReach(stroke, m) : 0;\n return quadMisses(minX - reach, minY - reach, maxX + reach, maxY + reach, m, box);\n}\n\n/** How far outside the geometry a stroke can paint, in the path's own units.\n * A full width rather than half covers `'outer'` alignment, which the\n * renderer draws as a doubled ribbon; the miter limit covers every join. A\n * marker head sits on a vertex, so its reach is measured from the hull too. */\nfunction strokeReach(stroke: Stroke, m: GlMat3): number {\n return strokeReachAt(stroke, mat3.meanScaleOf(m), mat3.minScaleOf(m));\n}\n\n/**\n * {@link strokeReach} at a known world-to-screen scale — what a painter\n * bounding its own output before it paints can know. `least` is the scale\n * along the axis the transform shrinks most, where it differs from `scale`.\n *\n * A `{ px }` ribbon or head is built to its screen size in every direction,\n * so in world it reaches farthest along that axis. A head with a world size is\n * built in world, whatever the line's width is in.\n */\nexport function strokeReachAt(stroke: Stroke, scale: number, least = scale): number {\n const at = least > 0 ? least : scale;\n const base = resolveStrokeWidth(stroke.width ?? 1, typeof stroke.width === 'object' ? at : scale);\n let width = base;\n if (stroke.vertexWidths) {\n for (const v of stroke.vertexWidths) if (v > width) width = v;\n }\n const spike = Math.max(stroke.miterLimit ?? DEFAULT_MITER_LIMIT, Math.SQRT2);\n const heads = markerReach(stroke);\n return Math.max(Math.abs(width) * spike, heads.world, resolveScreenLength({ px: heads.px }, at));\n}\n\nfunction spritesMiss(sprites: Float32Array, m: GlMat3, box: Box): boolean {\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (let i = 0; i + SPRITE_STRIDE <= sprites.length; i += SPRITE_STRIDE) {\n const x0 = sprites[i], y0 = sprites[i + 1];\n const x1 = x0 + sprites[i + 2], y1 = y0 + sprites[i + 3];\n minX = Math.min(minX, x0, x1); maxX = Math.max(maxX, x0, x1);\n minY = Math.min(minY, y0, y1); maxY = Math.max(maxY, y0, y1);\n }\n if (minX === Infinity) return false;\n return quadMisses(minX, minY, maxX, maxY, m, box);\n}\n\n/**\n * True when `bounds`, taken through `transform` to screen space, cannot put a\n * pixel inside `rect` — the per-command test above, for a caller holding a box\n * rather than a command. Same slack, same NaN-keeps rule.\n */\nexport function boundsMissRect(\n bounds: { x: number; y: number; width: number; height: number },\n transform: GlMat3,\n rect: CullRect,\n): boolean {\n const x0 = Math.min(bounds.x, bounds.x + bounds.width);\n const x1 = Math.max(bounds.x, bounds.x + bounds.width);\n const y0 = Math.min(bounds.y, bounds.y + bounds.height);\n const y1 = Math.max(bounds.y, bounds.y + bounds.height);\n return quadMisses(x0, y0, x1, y1, transform, slackBox(rect));\n}\n\nfunction slackBox(rect: CullRect): Box {\n return {\n minX: rect.x - SLACK_PX,\n minY: rect.y - SLACK_PX,\n maxX: rect.x + rect.width + SLACK_PX,\n maxY: rect.y + rect.height + SLACK_PX,\n };\n}\n\n/** True when the local rect, taken through `m`, lies wholly outside `box`.\n * Any NaN makes every comparison false, so the command is kept. */\nfunction quadMisses(x0: number, y0: number, x1: number, y1: number, m: GlMat3, box: Box): boolean {\n const [ax, ay] = mat3.apply(m, x0, y0);\n const [bx, by] = mat3.apply(m, x1, y0);\n const [cx, cy] = mat3.apply(m, x1, y1);\n const [dx, dy] = mat3.apply(m, x0, y1);\n return (\n Math.max(ax, bx, cx, dx) < box.minX ||\n Math.min(ax, bx, cx, dx) > box.maxX ||\n Math.max(ay, by, cy, dy) < box.minY ||\n Math.min(ay, by, cy, dy) > box.maxY\n );\n}\n","import { registerProgram, type ShaderProgramHandle, type ShaderUniform } from '../shaders/registerProgram';\nimport { EFFECT_VERT_SRC } from './effectPrelude';\n\n/**\n * One full-screen pass over what a group has already drawn.\n *\n * The renderer runs a group's effects in order, each reading the previous\n * one's output through `u_source` and writing a whole new buffer — so an\n * effect is free to read neighbouring pixels, which is the entire point and\n * the one thing `colorMatrix` can never do.\n *\n * `uniforms` are the effect's own; `u_source`, `u_resolution` and `u_texel`\n * come from the renderer and must not be passed here.\n */\nexport interface Effect {\n program: ShaderProgramHandle;\n uniforms?: Record<string, ShaderUniform>;\n}\n\n/**\n * Register a fragment shader as an effect. Sugar over `registerProgram` with\n * the effect vertex shader, and the reason a consumer never imports the\n * prelude: an effect that registers with the *custom-shader* vertex shader\n * compiles, runs, and samples its source upside down.\n *\n * The fragment shader reads `v_uv` and `u_source`, and may declare\n * `u_resolution` / `u_texel`. See `effectPrelude.ts` for the full contract,\n * including the premultiplied-alpha requirement.\n *\n * @experimental\n */\nexport function registerEffect(id: string, frag: string): ShaderProgramHandle {\n return registerProgram(id, EFFECT_VERT_SRC, frag);\n}\n","/**\n * Effects that ship with the kit.\n *\n * Each is a function returning `Effect[]`, not a single `Effect`, because a\n * separable kernel is genuinely two passes and hiding that behind one entry\n * would make the cost invisible at the callsite:\n *\n * effects={[...blur({ radius: 4 }), ...vignette({ amount: 0.6 })]}\n */\nimport type { Effect } from './types';\nimport { registerEffect } from './types';\n\nconst BLUR_FRAG = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_uv;\nuniform sampler2D u_source;\nuniform vec2 u_texel;\nuniform vec2 u_direction;\nuniform float u_radius;\nout vec4 outColor;\n\nvoid main() {\n // Nine taps on a Gaussian, spread across the requested radius. The weights\n // are a normalized binomial row, so a radius of 0 collapses to a copy.\n const float W[5] = float[5](0.2270270, 0.1945946, 0.1216216, 0.0540541, 0.0162162);\n vec2 step = u_direction * u_texel * (u_radius / 4.0);\n vec4 sum = texture(u_source, v_uv) * W[0];\n for (int i = 1; i < 5; i++) {\n vec2 off = step * float(i);\n sum += texture(u_source, v_uv + off) * W[i];\n sum += texture(u_source, v_uv - off) * W[i];\n }\n outColor = sum;\n}\n`;\n\nconst VIGNETTE_FRAG = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_uv;\nuniform sampler2D u_source;\nuniform float u_amount;\nuniform float u_feather;\nout vec4 outColor;\n\nvoid main() {\n vec4 src = texture(u_source, v_uv);\n float d = distance(v_uv, vec2(0.5)) * 1.41421356;\n float shade = 1.0 - u_amount * smoothstep(1.0 - u_feather, 1.0, d);\n // Premultiplied in, premultiplied out: scaling all four channels darkens\n // toward transparent black, which is what a vignette over a transparent\n // canvas should do.\n outColor = src * shade;\n}\n`;\n\nconst BLUR = registerEffect('weasel:blur', BLUR_FRAG);\nconst VIGNETTE = registerEffect('weasel:vignette', VIGNETTE_FRAG);\n\n/**\n * Gaussian blur, as a horizontal pass followed by a vertical one.\n *\n * `radius` is in device pixels and is the distance of the outermost tap, not a\n * standard deviation — 0 is a copy, and the falloff is the same nine-tap\n * kernel at every radius, so a large one is a wide blur rather than a better\n * one. Two passes at O(9) beat one at O(81) and look the same.\n */\nexport function blur({ radius }: { radius: number }): Effect[] {\n return [\n { program: BLUR, uniforms: { u_direction: [1, 0], u_radius: radius } },\n { program: BLUR, uniforms: { u_direction: [0, 1], u_radius: radius } },\n ];\n}\n\n/**\n * Darken toward the corners. `amount` is how dark the corner gets (0..1) and\n * `feather` how much of the radius the falloff occupies.\n */\nexport function vignette(\n { amount, feather = 0.6 }: { amount: number; feather?: number },\n): Effect[] {\n return [{ program: VIGNETTE, uniforms: { u_amount: amount, u_feather: feather } }];\n}\n","/**\n * Build a `TextDrawCommand`. `textCommandFromPose` is the command for a text\n * node — what `kit:text` and `createTextLayer` both emit. `textCommand` takes\n * a plain string and wraps it in one run; `textCommandFromRuns` takes the\n * styled runs directly, for text that has no pose. All three\n * resolve through `resolveTextStyle` + `resolveRuns`, so every emitter of a\n * text command derives `align` and per-run resolution the same way — a\n * caller that assembles the command by hand is one field away from a\n * silently different result.\n *\n * `paint` is the node's `data.fill` / `data.stroke`. A caller with no node —\n * a HUD widget, a debug overlay — states its color on the run instead.\n *\n * `scale` is the view scale a `{ px }` `fontSize` or `letterSpacing` resolves\n * against — for a world-space layer, the mean of `view.scale.x` and\n * `view.scale.y`. It has to be applied here and not at draw time, because a\n * screen-pixel size moves the glyph advances and so the wrap points.\n */\n\nimport type { DrawCommand, TextDrawCommand } from './index';\nimport type { TextPaint, TextPose, TextStyle } from '@weasel-js/text';\nimport { resolveTextStyle, textPoseLayoutInput } from '@weasel-js/text';\nimport { resolveRuns } from '@weasel-js/text';\nimport type { StyledRun } from '@weasel-js/text';\nimport type { TextVerticalAlign, ResolvedRun } from '@weasel-js/text';\nimport type { FillStyle } from '@weasel-js/paint';\nimport type { FillPoseBox } from './fillInPoseFrame';\nimport { commandFill } from './patterns/commandPaint';\n\n/** Build a draw command from styled runs, for text with no pose. `style`\n * supplies the defaults each run inherits; the rest match `textCommand`. */\nexport function textCommandFromRuns(\n x: number,\n y: number,\n runs: readonly StyledRun[],\n style?: TextStyle,\n maxWidth?: number,\n height?: number,\n verticalAlign?: TextVerticalAlign,\n paint?: TextPaint,\n width?: number,\n scale = 1,\n): DrawCommand {\n const resolved = resolveTextStyle(style, paint, scale);\n return {\n kind: 'text',\n x,\n y,\n runs: resolveRuns(runs, resolved, scale),\n align: resolved.align,\n direction: resolved.direction,\n justify: resolved.align === 'justify',\n maxWidth,\n style: style ?? {},\n height,\n verticalAlign,\n width,\n };\n}\n\n/** Build a draw command for a single unstyled string. Text is laid out with\n * the registered font's metrics, wrapped at `maxWidth`, aligned across\n * `width` (default `maxWidth`) and within `height` when `verticalAlign` is\n * given. */\nexport function textCommand(\n x: number,\n y: number,\n text: string,\n style?: TextStyle,\n maxWidth?: number,\n height?: number,\n verticalAlign?: TextVerticalAlign,\n paint?: TextPaint,\n width?: number,\n scale = 1,\n): DrawCommand {\n return textCommandFromRuns(\n x, y, [{ text }], style, maxWidth, height, verticalAlign, paint, width, scale,\n );\n}\n\n/**\n * The draw command for a text pose. Its wrap width, alignment box and runs\n * come from `textPoseLayoutInput`, so the renderer lays it out into exactly\n * the lines `layoutTextPose` reports for the same pose.\n *\n * Each run's paints are resolved against the pose box the way every other\n * node's are — a `'bounds'` paint mapped onto it, a pattern spec swapped for\n * its texture — since the renderer can do neither.\n */\nexport function textCommandFromPose(pose: TextPose, scale = 1): TextDrawCommand {\n const { runs, opts } = textPoseLayoutInput(pose, scale);\n return {\n kind: 'text',\n x: pose.x,\n y: pose.y,\n runs: runsInPoseFrame(runs, pose),\n align: opts.align,\n direction: opts.direction,\n justify: opts.justify,\n maxWidth: opts.maxWidth,\n width: opts.alignWidth,\n style: pose.style ?? {},\n height: pose.height,\n verticalAlign: pose.verticalAlign,\n };\n}\n\nfunction runsInPoseFrame(runs: ResolvedRun[], box: FillPoseBox): ResolvedRun[] {\n if (runs.every((r) => isSolid(r.fill) && isSolid(r.stroke?.paint))) return runs;\n return runs.map((r) => {\n const fill = r.fill && commandFill(r.fill, box);\n const paint = r.stroke?.paint && commandFill(r.stroke.paint, box);\n return { ...r, fill, stroke: r.stroke && { ...r.stroke, paint: paint || undefined } };\n });\n}\n\nfunction isSolid(paint: FillStyle | null | undefined): boolean {\n return paint == null || (paint.fill ?? 'solid') === 'solid';\n}\n"]}
1
+ {"version":3,"sources":["../src/paintResources.ts","../src/shaders/ShaderProgram.ts","../src/shaders/pathFill.ts","../src/shaders/gradFill.ts","../src/shaders/patternFill.ts","../src/shaders/builtinPrograms.ts","../src/shaders/glyphPaint.ts","../src/paintScratch.ts","../src/cache/GLMeshCache.ts","../src/cache/GLTextureCache.ts","../src/cache/GradientRampAtlas.ts","../src/state/GroupState.ts","../src/effects/effectPrelude.ts","../src/effects/composite.ts","../src/effects/compositeOp.ts","../src/draw/drawTriangles.ts","../src/draw/stencil.ts","../src/draw/customShader.ts","../src/draw/uniforms.ts","../src/draw/effects.ts","../src/draw/mesh.ts","../src/draw/foldColor.ts","../src/draw/batchMatrices.ts","../src/draw/flushBatch.ts","../src/draw/clip.ts","../src/strokeLengths.ts","../src/draw/batchRun.ts","../src/draw/gradient.ts","../src/draw/batch.ts","../src/math/patternSpace.ts","../src/draw/paintBind.ts","../src/draw/pathPaint.ts","../src/glyphOutlineMesh.ts","../src/draw/colorGlyphs.ts","../src/draw/scratchPass.ts","../src/draw/text.ts","../src/DrawCommand.ts","../src/draw/image.ts","../src/draw.ts","../src/shaders/customPrelude.ts","../src/effects/EffectTargets.ts","../src/shaders/extractUniformNames.ts","../src/WeaselRenderer.ts","../src/spriteSheet.ts","../src/cullDrawCommands.ts","../src/effects/types.ts","../src/effects/builtins.ts","../src/textCommand.ts"],"names":["fragSrc","ramp","mat3","resolveColor","isSolid","resolveStrokeWidth","strokeSpaceOf","prog","isSolidPaint","SYNTHETIC_ITALIC_RADIANS","depth","v","resolveTextStyle"],"mappings":";;;;;;;;;;;;;;;;;AAUO,SAAS,oBAAA,GAA4C;AAC1D,EAAA,IAAI,WAAqC,EAAC;AAC1C,EAAA,OAAO;AAAA,IACL,UAAU,OAAA,EAAS;AACjB,MAAA,IAAI,QAAA,EAAU,QAAA,CAAS,IAAA,CAAK,OAAO,CAAA;AAAA,WAC9B,OAAA,EAAQ;AAAA,IACf,CAAA;AAAA,IACA,OAAA,GAAU;AACR,MAAA,MAAM,OAAA,GAAU,QAAA;AAChB,MAAA,QAAA,GAAW,IAAA;AACX,MAAA,KAAA,MAAW,OAAA,IAAW,OAAA,IAAW,EAAC,EAAG,OAAA,EAAQ;AAAA,IAC/C;AAAA,GACF;AACF;;;ACTO,IAAM,kBAAA,GAAN,cAAiC,KAAA,CAAM;AAAA,EAC5C,WAAA,CAA4B,OAAoC,GAAA,EAAa;AAC3E,IAAA,KAAA,CAAM,CAAA,OAAA,EAAU,KAAK,CAAA,UAAA,EAAa,GAAG,CAAA,CAAE,CAAA;AADb,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAAoC,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAE9D,IAAA,IAAA,CAAK,I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,CAAA,CAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,IAAS,QAAU,EAAE;AAAA,EACtF,CAAC,CAAA;AACH;AAEA,SAAS,QAAQ,KAAA,EAA0C;AACzD,EAAA,OAAO,KAAA,IAAS,IAAA,IAAQJ,YAAAA,CAAa,KAAK,CAAA;AAC5C","file":"index.js","sourcesContent":["import type { PaintResources } from './paintKinds';\n\n/** A {@link PaintResources} with the end of its lifetime in the owner's hands. */\nexport interface OwnedPaintResources extends PaintResources {\n /** Run every registered release, once. Idempotent. */\n release(): void;\n}\n\n/** A fresh paint-resource lifetime. The renderer opens one per context\n * generation and releases it on dispose or context restore. */\nexport function createPaintResources(): OwnedPaintResources {\n let releases: Array<() => void> | null = [];\n return {\n onRelease(release) {\n if (releases) releases.push(release);\n else release();\n },\n release() {\n const pending = releases;\n releases = null;\n for (const release of pending ?? []) release();\n },\n };\n}\n","/**\n * Minimal compile/link/lookup wrapper for a GL program. Throws\n * `ShaderCompileError` on compile or link failure with the GL info log\n * embedded in the error message — never returns a half-initialized program.\n *\n * Designed so test code can stub `getShaderParameter` / `getProgramParameter`\n * via the recorder Proxy without further special-casing.\n */\n\n/** The step of building a program that a `ShaderCompileError` came from. */\nexport type ShaderStage = 'vertex' | 'fragment' | 'link';\n\n/** Thrown when a shader fails to compile or link, carrying which stage failed\n * and the driver's log. */\nexport class ShaderCompileError extends Error {\n constructor(public readonly stage: ShaderStage, public readonly log: string) {\n super(`shader ${stage} failure: ${log}`);\n this.name = 'ShaderCompileError';\n }\n}\n\n/** An array uniform a program can be written as a whole: its element type as\n * declared, its declared length, and the location of slot 0. */\nexport interface UniformArray {\n readonly type: string;\n readonly size: number;\n readonly location: WebGLUniformLocation;\n}\n\n/** Where every program links `a_position`. A mesh VAO is built once and drawn\n * with whichever fill program its paint picks, so the location cannot be\n * left to each program's linker. */\nexport const POSITION_ATTRIBUTE_LOCATION = 0;\n\n/** A linked GL program with its uniform and attribute locations cached by name. */\nexport class ShaderProgram {\n readonly handle: WebGLProgram;\n private readonly uniforms = new Map<string, WebGLUniformLocation>();\n private readonly arrays = new Map<string, UniformArray>();\n private readonly attributes = new Map<string, number>();\n\n constructor(\n private readonly gl: WebGL2RenderingContext,\n vertSrc: string,\n fragSrc: string,\n ) {\n const vs = this.compile(gl.VERTEX_SHADER, vertSrc, 'vertex');\n let fs: WebGLShader;\n try {\n fs = this.compile(gl.FRAGMENT_SHADER, fragSrc, 'fragment');\n } catch (e) {\n gl.deleteShader(vs);\n throw e;\n }\n const program = gl.createProgram();\n if (!program) {\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n throw new Error('createProgram returned null');\n }\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.bindAttribLocation(program, POSITION_ATTRIBUTE_LOCATION, 'a_position');\n gl.linkProgram(program);\n // Flagged for deletion, attached shaders live exactly as long as the\n // program, so `deleteProgram` frees them too.\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n const log = gl.getProgramInfoLog(program) ?? '';\n gl.deleteProgram(program);\n throw new ShaderCompileError('link', log);\n }\n this.handle = program;\n }\n\n private compile(type: number, source: string, stage: ShaderStage): WebGLShader {\n const gl = this.gl;\n const shader = gl.createShader(type);\n if (!shader) throw new Error('createShader returned null');\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader) ?? '';\n gl.deleteShader(shader);\n throw new ShaderCompileError(stage, log);\n }\n return shader;\n }\n\n lookupUniforms(names: readonly string[]): void {\n for (const name of names) {\n const loc = this.gl.getUniformLocation(this.handle, name);\n if (loc !== null) this.uniforms.set(name, loc);\n }\n }\n\n /** Record each array's slot-0 location under its bare name. An array the\n * driver optimized away has no location and is left out. */\n lookupUniformArrays(decls: ReadonlyMap<string, { type: string; size: number }>): void {\n for (const [name, { type, size }] of decls) {\n const base = `${name}[0]`;\n const location = this.uniforms.get(base) ?? this.gl.getUniformLocation(this.handle, base);\n if (location !== null) this.arrays.set(name, { type, size, location });\n }\n }\n\n lookupAttributes(names: readonly string[]): void {\n for (const name of names) {\n const loc = this.gl.getAttribLocation(this.handle, name);\n if (loc >= 0) this.attributes.set(name, loc);\n }\n }\n\n uniform(name: string): WebGLUniformLocation | undefined {\n return this.uniforms.get(name);\n }\n\n uniformArray(name: string): UniformArray | undefined {\n return this.arrays.get(name);\n }\n\n attribute(name: string): number | undefined {\n return this.attributes.get(name);\n }\n}\n","/**\n * GLSL ES 3.0 sources for the built-in solid-fill path shader.\n *\n * The flat variant uses `u_color` only; the VColor variant multiplies a\n * per-vertex `a_vertexColor` with it. In both, the color transform is applied\n * to the straight-alpha color BEFORE premultiplication.\n *\n * Output (both variants): PREMULTIPLIED alpha.\n * Blend: caller sets `gl.blendFunc(ONE, ONE_MINUS_SRC_ALPHA)`.\n */\n\nexport const VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform vec2 u_origin;\nvoid main() {\n vec3 screen = u_model * vec3(a_position - u_origin, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n}\n`;\n\nexport const FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nuniform vec4 u_color;\nuniform float u_alpha;\nuniform mat4 u_colorMatrix;\nuniform vec4 u_colorBias;\nout vec4 outColor;\nvoid main() {\n vec4 mapped = clamp(u_colorMatrix * u_color + u_colorBias, 0.0, 1.0);\n float a = mapped.a * u_alpha;\n outColor = vec4(mapped.rgb * a, a);\n}\n`;\n\nexport const VCOLOR_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nin vec4 a_vertexColor;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform vec2 u_origin;\nout vec4 v_vertexColor;\nvoid main() {\n vec3 screen = u_model * vec3(a_position - u_origin, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n v_vertexColor = a_vertexColor;\n}\n`;\n\nexport const VCOLOR_FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nin vec4 v_vertexColor;\nuniform vec4 u_color;\nuniform float u_alpha;\nuniform mat4 u_colorMatrix;\nuniform vec4 u_colorBias;\nout vec4 outColor;\nvoid main() {\n vec4 src = u_color * v_vertexColor;\n vec4 mapped = clamp(u_colorMatrix * src + u_colorBias, 0.0, 1.0);\n float a = mapped.a * u_alpha;\n outColor = vec4(mapped.rgb * a, a);\n}\n`;\n\n/** Uniforms shared between flat and vertex-color variants. */\nexport const PATH_FILL_UNIFORMS = [\n 'u_proj', 'u_model', 'u_origin', 'u_color', 'u_alpha',\n 'u_colorMatrix', 'u_colorBias',\n] as const;\n\n/** Attributes for the flat variant. */\nexport const PATH_FILL_ATTRIBUTES = ['a_position'] as const;\n\n/** Attributes for the vertex-color variant. */\nexport const PATH_FILL_VCOLOR_ATTRIBUTES = ['a_position', 'a_vertexColor'] as const;\n","/**\n * GLSL ES 3.0 sources for gradient-fill paths (linear, radial, conic).\n *\n * `u_gradKind` picks the kind (0=linear, 1=radial, 2=conic). `u_ramp` is\n * `GradientRampAtlas`'s texture, which holds every baked ramp in the frame,\n * one per row; `u_rampV` picks this fill's row. `u_worldInv` takes a screen\n * position to the gradient's space measured from its own start point or\n * center, so no stage subtracts one. Output is PREMULTIPLIED alpha.\n */\n\nexport const GRAD_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform vec2 u_origin;\nuniform mat3 u_worldInv;\nout vec2 v_world;\nvoid main() {\n vec3 screen = u_model * vec3(a_position - u_origin, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n vec3 world = u_worldInv * vec3(screen.xy, 1.0);\n v_world = world.xy;\n}\n`;\n\n/**\n * The gradient's color at a gradient-space point, measured from the\n * gradient's start or center, premultiplied — the whole of the fragment stage\n * but the point it is asked about, so the glyph program\n * can mask the same paint the path program draws.\n */\nexport const GRAD_PAINT_GLSL = /* glsl */ `\nuniform sampler2D u_ramp;\nuniform float u_rampV;\nuniform float u_alpha;\nuniform mat4 u_colorMatrix;\nuniform vec4 u_colorBias;\nuniform float u_opacity;\nuniform int u_gradKind;\nuniform vec2 u_gradDir;\nuniform float u_gradLen;\nuniform float u_gradRadius;\nuniform float u_gradAngle;\n\nconst float PI = 3.14159265358979323846;\n\nvec4 shadePaint(vec2 world) {\n float t;\n if (u_gradKind == 0) {\n t = dot(world, u_gradDir) / max(u_gradLen, 0.0001);\n } else if (u_gradKind == 1) {\n t = length(world) / max(u_gradRadius, 0.0001);\n } else {\n float a = atan(world.y, world.x) - u_gradAngle;\n t = fract(a / (2.0 * PI));\n }\n t = clamp(t, 0.0, 1.0);\n vec4 rampColor = texture(u_ramp, vec2(t, u_rampV));\n // Fill opacity into the alpha channel before the matrix, which is where the\n // batch program's vertex alpha sits. The two have to agree, since a linear\n // gradient goes through that one and a radial through this.\n vec4 src = vec4(rampColor.rgb, rampColor.a * u_opacity);\n vec4 mapped = clamp(u_colorMatrix * src + u_colorBias, 0.0, 1.0);\n float a = mapped.a * u_alpha;\n return vec4(mapped.rgb * a, a);\n}\n`;\n\nexport const GRAD_FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_world;\n${GRAD_PAINT_GLSL}\nout vec4 outColor;\nvoid main() {\n outColor = shadePaint(v_world);\n}\n`;\n\nexport const GRAD_FILL_UNIFORMS = [\n 'u_proj', 'u_model', 'u_origin', 'u_worldInv', 'u_ramp', 'u_rampV',\n 'u_alpha', 'u_opacity', 'u_colorMatrix', 'u_colorBias',\n 'u_gradKind', 'u_gradDir', 'u_gradLen', 'u_gradRadius', 'u_gradAngle',\n] as const;\n\nexport const GRAD_FILL_ATTRIBUTES = ['a_position'] as const;\n","/**\n * GLSL ES 3.0 sources for pattern-fill paths.\n *\n * A path fill mesh carries `a_position` only, so tile-space coordinates are\n * recovered per fragment from the screen position via `u_worldInv`, which also\n * carries the tile's origin and transform. `u_tileSize` then converts to\n * texture space, and `REPEAT` wrapping (set at upload) tiles the result.\n * Output is PREMULTIPLIED alpha.\n */\n\nimport { STRAIGHT_RGB_GLSL } from './straightRgb';\n\nexport const PATTERN_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform vec2 u_origin;\nuniform mat3 u_worldInv;\nout vec2 v_world;\nvoid main() {\n vec3 screen = u_model * vec3(a_position - u_origin, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n vec3 world = u_worldInv * vec3(screen.xy, 1.0);\n v_world = world.xy;\n}\n`;\n\n/**\n * The pattern's color at a paint-space point, premultiplied — the whole of the\n * fragment stage but the point it is asked about, so the glyph program can\n * mask the same paint the path program draws.\n */\nexport const PATTERN_PAINT_GLSL = /* glsl */ `\nuniform sampler2D u_sampler;\nuniform vec2 u_tileSize;\nuniform float u_opacity;\nuniform float u_alpha;\nuniform mat4 u_colorMatrix;\nuniform vec4 u_colorBias;\n${STRAIGHT_RGB_GLSL}\nvec4 shadePaint(vec2 world) {\n vec2 uv = world / max(u_tileSize, vec2(0.0001));\n vec4 texel = texture(u_sampler, uv);\n vec4 mapped = clamp(u_colorMatrix * vec4(straightRgb(texel), texel.a) + u_colorBias, 0.0, 1.0);\n float a = mapped.a * u_opacity * u_alpha;\n return vec4(mapped.rgb * a, a);\n}\n`;\n\nexport const PATTERN_FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_world;\n${PATTERN_PAINT_GLSL}\nout vec4 outColor;\nvoid main() {\n outColor = shadePaint(v_world);\n}\n`;\n\nexport const PATTERN_FILL_UNIFORMS = [\n 'u_proj', 'u_model', 'u_origin', 'u_worldInv', 'u_sampler',\n 'u_tileSize', 'u_opacity', 'u_alpha',\n 'u_colorMatrix', 'u_colorBias',\n] as const;\n\nexport const PATTERN_FILL_ATTRIBUTES = ['a_position'] as const;\n","import { ShaderProgram } from './ShaderProgram';\nimport {\n VERT_SRC,\n FRAG_SRC,\n VCOLOR_VERT_SRC,\n VCOLOR_FRAG_SRC,\n PATH_FILL_UNIFORMS,\n PATH_FILL_ATTRIBUTES,\n PATH_FILL_VCOLOR_ATTRIBUTES,\n} from './pathFill';\nimport {\n BATCH_VERT_SRC,\n BATCH_FRAG_SRC,\n BATCH_MATRICES_FRAG_SRC,\n BATCH_FILL_UNIFORMS,\n BATCH_FILL_ATTRIBUTES,\n} from './batchFill';\nimport {\n GRAD_VERT_SRC,\n GRAD_FRAG_SRC,\n GRAD_FILL_UNIFORMS,\n GRAD_FILL_ATTRIBUTES,\n} from './gradFill';\nimport {\n PATTERN_VERT_SRC,\n PATTERN_FRAG_SRC,\n PATTERN_FILL_UNIFORMS,\n PATTERN_FILL_ATTRIBUTES,\n} from './patternFill';\n\n/** What a built-in program is built from. */\nexport interface ProgramSpec {\n readonly vert: string;\n readonly frag: string;\n readonly uniforms: readonly string[];\n readonly attributes: readonly string[];\n}\n\n/**\n * A built-in program compiled the first time a frame draws with it, so a\n * renderer whose frames never fill a path with a pattern never builds the\n * pattern program.\n */\nexport class LazyProgram {\n private program: ShaderProgram | null = null;\n\n constructor(private readonly gl: WebGL2RenderingContext, private readonly spec: ProgramSpec) {}\n\n get(): ShaderProgram {\n if (!this.program) {\n const { vert, frag, uniforms, attributes } = this.spec;\n const program = new ShaderProgram(this.gl, vert, frag);\n program.lookupUniforms(uniforms);\n program.lookupAttributes(attributes);\n this.program = program;\n }\n return this.program;\n }\n\n /** Delete the program if it was built. It builds again on the next `get`. */\n release(): void {\n if (this.program) this.gl.deleteProgram(this.program.handle);\n this.program = null;\n }\n\n /** Forget a program its lost context already took with it. */\n abandon(): void {\n this.program = null;\n }\n}\n\nexport const PATH_FILL_SPEC: ProgramSpec = {\n vert: VERT_SRC, frag: FRAG_SRC, uniforms: PATH_FILL_UNIFORMS, attributes: PATH_FILL_ATTRIBUTES,\n};\nexport const PATH_FILL_VCOLOR_SPEC: ProgramSpec = {\n vert: VCOLOR_VERT_SRC, frag: VCOLOR_FRAG_SRC, uniforms: PATH_FILL_UNIFORMS, attributes: PATH_FILL_VCOLOR_ATTRIBUTES,\n};\nexport const GRAD_FILL_SPEC: ProgramSpec = {\n vert: GRAD_VERT_SRC, frag: GRAD_FRAG_SRC, uniforms: GRAD_FILL_UNIFORMS, attributes: GRAD_FILL_ATTRIBUTES,\n};\nexport const BATCH_FILL_MATRICES_SPEC: ProgramSpec = {\n vert: BATCH_VERT_SRC, frag: BATCH_MATRICES_FRAG_SRC, uniforms: BATCH_FILL_UNIFORMS, attributes: BATCH_FILL_ATTRIBUTES,\n};\nexport const PATTERN_FILL_SPEC: ProgramSpec = {\n vert: PATTERN_VERT_SRC, frag: PATTERN_FRAG_SRC, uniforms: PATTERN_FILL_UNIFORMS, attributes: PATTERN_FILL_ATTRIBUTES,\n};\n\n/** Built eagerly: nearly every frame draws with it, and `DrawBatch` binds its\n * attributes at construction. */\nexport function createBatchFill(gl: WebGL2RenderingContext): ShaderProgram {\n const program = new ShaderProgram(gl, BATCH_VERT_SRC, BATCH_FRAG_SRC);\n program.lookupUniforms(BATCH_FILL_UNIFORMS);\n program.lookupAttributes(BATCH_FILL_ATTRIBUTES);\n return program;\n}\n","/**\n * GLSL ES 3.0 sources for atlas glyphs filled by a texture paint — a pattern, a\n * gradient or a registered kind — rather than one color.\n *\n * **The glyph is a mask over the paint.** The fragment takes its coverage from\n * the distance field exactly as the batch program does, and its color from the\n * same `shadePaint` the path program for that paint runs, at the same\n * paint-space point — so a paint reads the same on either side of the\n * outline-tier threshold.\n *\n * **The vertices are the batch's.** A glyph run stages into `DrawBatch` as\n * usual and this program draws it in place of the batch program, so the\n * attribute locations are pinned to the batch shader's and one VAO serves\n * both. Positions arrive already in screen space, so `u_model` is identity.\n *\n * Coverage is taken before `shadePaint` runs, and outside any branch: `fwidth`\n * in non-uniform control flow is undefined.\n *\n * Output: PREMULTIPLIED alpha, the paint's own scaled by coverage.\n */\n\nimport { GLYPH_COVERAGE_GLSL } from '@weasel-js/font';\nimport { BATCH_ATTRIBUTE_LOCATIONS, BATCH_TEXTURE_SLOTS } from './batchFill';\nimport { GRAD_FILL_UNIFORMS, GRAD_PAINT_GLSL } from './gradFill';\nimport { PATTERN_FILL_UNIFORMS, PATTERN_PAINT_GLSL } from './patternFill';\n\nconst L = BATCH_ATTRIBUTE_LOCATIONS;\n\nexport const GLYPH_PAINT_VERT_SRC = /* glsl */ `#version 300 es\nlayout(location = ${L.a_position}) in vec2 a_position;\nlayout(location = ${L.a_uv}) in vec2 a_uv;\nlayout(location = ${L.a_texSlot}) in float a_texSlot;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform mat3 u_worldInv;\nout vec2 v_world;\nout vec2 v_uv;\nflat out float v_glyphMode;\nvoid main() {\n vec3 screen = u_model * vec3(a_position, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n v_world = (u_worldInv * vec3(screen.xy, 1.0)).xy;\n v_uv = a_uv;\n v_glyphMode = float(int(a_texSlot + 0.5) / ${BATCH_TEXTURE_SLOTS});\n}\n`;\n\nfunction fragSrc(paintGlsl: string): string {\n return /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_world;\nin vec2 v_uv;\nflat in float v_glyphMode;\nuniform sampler2D u_atlas;\nuniform float u_synthBold;\nuniform vec2 u_fieldScale;\n${paintGlsl}\n${GLYPH_COVERAGE_GLSL}\nout vec4 outColor;\nvoid main() {\n float coverage = glyphCoverage(texture(u_atlas, v_uv), v_glyphMode, u_synthBold, v_uv, u_fieldScale);\n outColor = shadePaint(v_world) * coverage;\n}\n`;\n}\n\n/**\n * A registered paint kind binds a whole program of its own, which nothing can\n * wrap in a mask, so it renders into an offscreen buffer first and the glyphs\n * sample that. `u_worldInv` takes the screen position straight to the\n * buffer's texture coordinate, and the texel is already premultiplied and\n * faded — the kind's own program did both.\n */\nconst TEXTURE_PAINT_GLSL = /* glsl */ `\nuniform sampler2D u_sampler;\nvec4 shadePaint(vec2 uv) {\n return texture(u_sampler, uv);\n}\n`;\n\nexport const GLYPH_PATTERN_FRAG_SRC = fragSrc(PATTERN_PAINT_GLSL);\nexport const GLYPH_GRAD_FRAG_SRC = fragSrc(GRAD_PAINT_GLSL);\nexport const GLYPH_TEXTURE_FRAG_SRC = fragSrc(TEXTURE_PAINT_GLSL);\n\nconst GLYPH_UNIFORMS = ['u_atlas', 'u_synthBold', 'u_fieldScale'] as const;\n// `u_origin` belongs to the path vertex stage, which these programs replace.\nconst notOrigin = (name: string): boolean => name !== 'u_origin';\nexport const GLYPH_PATTERN_UNIFORMS: readonly string[] = [\n ...PATTERN_FILL_UNIFORMS.filter(notOrigin), ...GLYPH_UNIFORMS,\n];\nexport const GLYPH_GRAD_UNIFORMS: readonly string[] = [\n ...GRAD_FILL_UNIFORMS.filter(notOrigin), ...GLYPH_UNIFORMS,\n];\nexport const GLYPH_TEXTURE_UNIFORMS = [\n 'u_proj', 'u_model', 'u_worldInv', 'u_sampler', ...GLYPH_UNIFORMS,\n] as const;\nexport const GLYPH_PAINT_ATTRIBUTES = ['a_position', 'a_uv', 'a_texSlot'] as const;\n","/**\n * The offscreen color buffer a registered paint kind renders into when what it\n * fills is not a path: atlas glyphs, whose coverage then masks what it drew.\n *\n * One per renderer, grown in powers of two to the largest region asked of it\n * and never shrunk, so a frame of differently sized text groups reallocates a\n * few times and then not at all. The region is clamped to the drawing buffer,\n * which bounds the buffer too. It has no stencil: nothing drawn into it is\n * clipped — the clip applies to the glyphs sampling it.\n */\n\nexport interface PaintScratchTarget {\n readonly fbo: WebGLFramebuffer;\n readonly texture: WebGLTexture;\n /** Texture size, at least the region asked for. */\n readonly width: number;\n readonly height: number;\n}\n\nconst MIN_SIDE = 64;\n\nexport class PaintScratch {\n private readonly gl: WebGL2RenderingContext;\n private target: PaintScratchTarget | null = null;\n\n constructor(gl: WebGL2RenderingContext) {\n this.gl = gl;\n }\n\n /** A buffer at least `width` × `height` device pixels. Its contents are\n * whatever the last user left; the caller clears the region it uses. */\n acquire(width: number, height: number): PaintScratchTarget {\n const have = this.target;\n if (have && have.width >= width && have.height >= height) return have;\n const w = Math.max(have?.width ?? 0, pow2(width));\n const h = Math.max(have?.height ?? 0, pow2(height));\n this.release();\n this.target = this.create(w, h);\n return this.target;\n }\n\n /** Drop the buffer. Called on dispose and on context restore, where the\n * handles are already dead and only the bookkeeping has to go. */\n release(): void {\n if (!this.target) return;\n this.gl.deleteFramebuffer(this.target.fbo);\n this.gl.deleteTexture(this.target.texture);\n this.target = null;\n }\n\n private create(width: number, height: number): PaintScratchTarget {\n const gl = this.gl;\n const texture = gl.createTexture()!;\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n // The region is laid on the device-pixel grid, so every fragment reading\n // it lands on a texel center and NEAREST is exact.\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n\n const fbo = gl.createFramebuffer()!;\n gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n return { fbo, texture, width, height };\n }\n}\n\nfunction pow2(n: number): number {\n let side = MIN_SIDE;\n while (side < n) side *= 2;\n return side;\n}\n","import type { Mesh } from '@weasel-js/geom/tessellate';\nimport { POSITION_ATTRIBUTE_LOCATION } from '../shaders/ShaderProgram';\n\nexport interface GLMeshHandle {\n readonly vao: WebGLVertexArrayObject;\n readonly indexCount: number;\n readonly requiresStencil: boolean;\n readonly anchorA?: Uint32Array;\n readonly anchorB?: Uint32Array;\n readonly anchorT?: Float32Array;\n}\n\n/** Resources to release when a Mesh is reclaimed by GC. */\ninterface MeshResources {\n vao: WebGLVertexArrayObject;\n vbo: WebGLBuffer;\n ibo: WebGLBuffer;\n}\n\n/**\n * Caches GL-side buffers + VAO per `Mesh` identity. Upload happens lazily\n * on first `handleFor(mesh)` call.\n *\n * **GC-aware cleanup (deferred-delete queue):** we register each Mesh with a\n * `FinalizationRegistry`; when the Mesh is reclaimed, the finalizer pushes\n * its GL resources (VAO, VBO, IBO) onto an internal queue. The renderer\n * drains this queue at the start of each `render()` call (via\n * `drainPendingDeletes()`), when GL is in a known state — no VAO bound, no\n * draw mid-flight. Finalizer timing is non-deterministic; resources may live\n * for a frame or two beyond their Mesh.\n *\n * The cache is GL-context-bound; if the context is lost and re-created, the\n * renderer should construct a new GLMeshCache.\n */\nexport class GLMeshCache {\n private readonly map = new WeakMap<Mesh, GLMeshHandle>();\n /** Meshes this context has drawn at least once; see `uploadRecurring`. */\n private readonly seen = new WeakSet<Mesh>();\n private readonly finalizer: FinalizationRegistry<MeshResources>;\n /** Every persistent upload not yet freed, so `dispose` can reach them. */\n private readonly persistent = new Set<MeshResources>();\n private readonly pendingDeletes: MeshResources[] = [];\n private disposed = false;\n /** Transient resources allocated this frame; freed at end of render(). */\n private readonly transientThisFrame: MeshResources[] = [];\n\n constructor(\n private readonly gl: WebGL2RenderingContext,\n ) {\n this.finalizer = new FinalizationRegistry<MeshResources>((resources) => {\n // Defer the actual gl.delete* until the renderer's next render(): GC\n // can fire between bindVertexArray and drawElements inside dispatch().\n if (!this.persistent.delete(resources)) return;\n this.pendingDeletes.push(resources);\n });\n }\n\n handleFor(mesh: Mesh): GLMeshHandle {\n const cached = this.map.get(mesh);\n if (cached) return cached;\n const { handle, vbo, ibo } = this.upload(mesh);\n this.map.set(mesh, handle);\n const resources = { vao: handle.vao, vbo, ibo };\n this.persistent.add(resources);\n this.finalizer.register(mesh, resources, mesh);\n return handle;\n }\n\n /**\n * Upload a Mesh that the caller knows is single-use. Returns a handle backed\n * by fresh GL resources that the renderer frees at the end of the current\n * frame via `freeTransient()`, so transient meshes never wait on GC.\n */\n uploadTransient(mesh: Mesh): GLMeshHandle {\n const { handle, vbo, ibo } = this.upload(mesh);\n this.transientThisFrame.push({ vao: handle.vao, vbo, ibo });\n return handle;\n }\n\n /**\n * Upload a Mesh that may or may not recur across frames. Its first sight in\n * *this* context takes `uploadTransient`; every later one takes the\n * persistent handle. One transient upload to find out is cheaper than\n * stranding a persistent VAO on a mesh that never returns, whose release\n * would wait on GC. The transient upload does not populate the persistent\n * map, so steady-state reuse begins on the third frame.\n */\n uploadRecurring(mesh: Mesh): GLMeshHandle {\n if (this.seen.has(mesh)) return this.handleFor(mesh);\n this.seen.add(mesh);\n return this.uploadTransient(mesh);\n }\n\n /**\n * Free all transient resources allocated since the last call. Called by\n * the renderer at the end of each `render()`. Safe under context loss.\n */\n freeTransient(): void {\n if (this.transientThisFrame.length === 0) return;\n const gl = this.gl;\n if (gl.isContextLost()) {\n this.transientThisFrame.length = 0;\n return;\n }\n for (const r of this.transientThisFrame) {\n gl.deleteVertexArray(r.vao);\n gl.deleteBuffer(r.vbo);\n gl.deleteBuffer(r.ibo);\n }\n this.transientThisFrame.length = 0;\n }\n\n /** @internal — for tests asserting the transient-list size. */\n _transientCount(): number {\n return this.transientThisFrame.length;\n }\n\n /**\n * Free GL resources whose Mesh has been GC'd since the last drain.\n * Called by the renderer at the top of each `render()`, before any draws.\n */\n drainPendingDeletes(): void {\n if (this.pendingDeletes.length === 0) return;\n const gl = this.gl;\n if (gl.isContextLost()) {\n this.pendingDeletes.length = 0;\n return;\n }\n for (const r of this.pendingDeletes) {\n gl.deleteVertexArray(r.vao);\n gl.deleteBuffer(r.vbo);\n gl.deleteBuffer(r.ibo);\n }\n this.pendingDeletes.length = 0;\n }\n\n /**\n * Free every GL resource this cache holds — persistent, pending and\n * transient — and ignore finalizers from here on. Idempotent. Unlike the\n * other paths this does not wait on GC, which is what lets a renderer on a\n * context it does not own give back everything it uploaded.\n */\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n this.freeTransient();\n for (const r of this.persistent) this.pendingDeletes.push(r);\n this.persistent.clear();\n this.drainPendingDeletes();\n }\n\n /** @internal — for tests asserting the queue size. */\n _pendingDeleteCount(): number {\n return this.pendingDeletes.length;\n }\n\n /** @internal — for tests that need to simulate the finalizer firing. */\n _enqueueDeleteForTest(resources: MeshResources): void {\n this.pendingDeletes.push(resources);\n }\n\n private upload(mesh: Mesh): { handle: GLMeshHandle; vbo: WebGLBuffer; ibo: WebGLBuffer } {\n const gl = this.gl;\n const vao = gl.createVertexArray();\n if (!vao) throw new Error('createVertexArray returned null');\n gl.bindVertexArray(vao);\n\n const vbo = gl.createBuffer();\n if (!vbo) throw new Error('createBuffer (VBO) returned null');\n gl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n gl.bufferData(gl.ARRAY_BUFFER, mesh.vertices, gl.STATIC_DRAW);\n\n gl.enableVertexAttribArray(POSITION_ATTRIBUTE_LOCATION);\n gl.vertexAttribPointer(POSITION_ATTRIBUTE_LOCATION, 2, gl.FLOAT, false, 0, 0);\n\n const ibo = gl.createBuffer();\n if (!ibo) throw new Error('createBuffer (IBO) returned null');\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ibo);\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, mesh.indices, gl.STATIC_DRAW);\n\n gl.bindVertexArray(null);\n\n return {\n handle: {\n vao,\n indexCount: mesh.indices.length,\n requiresStencil: mesh.requiresStencil ?? false,\n anchorA: mesh.anchorA,\n anchorB: mesh.anchorB,\n anchorT: mesh.anchorT,\n },\n vbo,\n ibo,\n };\n }\n}\n","/**\n * GL texture upload + cache, keyed by a string id (the font family name or\n * image id). The cache is GL-context-bound; discard and create a new one on\n * context loss.\n *\n * Atlas format: RGBA UNSIGNED_BYTE, linear filtering, no mipmaps: mipmap\n * resampling corrupts the multi-channel SDF signal.\n */\n\nimport { uploadPremultiplied, type ImageTexSource } from './uploadPremultiplied';\n\ntype TexSource = ImageTexSource;\n\n/** Send a source's bytes as it holds them. A font atlas's channels are a distance field, not a color. */\nfunction uploadAsHeld(gl: WebGL2RenderingContext, source: TexSource): void {\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);\n}\n\n/** How a texture samples outside `0..1`. Pattern tiles need `'repeat'`;\n * everything else clamps. WebGL2 allows `REPEAT` on NPOT textures, so a\n * tile of any size tiles correctly. */\nexport type TextureWrap = 'clamp' | 'repeat';\n\n/** The part of the texture registry a sweep reads. */\nexport interface RegisteredTextureIds {\n getVersion(): number;\n has(id: string): boolean;\n}\n\nexport class GLTextureCache {\n private readonly map = new Map<string, WebGLTexture>();\n private readonly wraps = new Map<string, TextureWrap>();\n /** The source each registry-backed id was last uploaded from. */\n private readonly registered = new Map<string, TexSource>();\n private sweptVersion = -1;\n\n constructor(private readonly gl: WebGL2RenderingContext) {}\n\n has(id: string): boolean {\n return this.map.has(id);\n }\n\n /** Uploads the pixels once per id. `wrap` is re-applied whenever it differs\n * from what the id was last uploaded under: the same registered image can\n * be a clamped shader texture in one draw and a repeating pattern tile in\n * the next. */\n upload(id: string, source: TexSource, wrap: TextureWrap = 'clamp'): string {\n return this.ensure(id, source, wrap, uploadAsHeld);\n }\n\n private ensure(id: string, source: TexSource, wrap: TextureWrap, send: typeof uploadAsHeld): string {\n const cached = this.map.get(id);\n if (cached) {\n if (this.wraps.get(id) !== wrap) this.applyWrap(id, cached, wrap);\n return id;\n }\n\n const gl = this.gl;\n const tex = gl.createTexture();\n if (!tex) throw new Error(`GLTextureCache: createTexture failed for id=\"${id}\"`);\n\n const wrapMode = wrap === 'repeat' ? gl.REPEAT : gl.CLAMP_TO_EDGE;\n\n gl.bindTexture(gl.TEXTURE_2D, tex);\n send(gl, source);\n\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapMode);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapMode);\n\n gl.bindTexture(gl.TEXTURE_2D, null);\n\n this.map.set(id, tex);\n this.wraps.set(id, wrap);\n return id;\n }\n\n /** `upload` for an id from the texture registry, whose image can be replaced\n * under the same id: a changed source sends its pixels again. A registered\n * texture is an image, so its texels are premultiplied. */\n uploadRegistered(id: string, source: TexSource, wrap: TextureWrap = 'clamp'): string {\n const cached = this.map.get(id);\n if (cached && this.registered.get(id) !== source) {\n const gl = this.gl;\n gl.bindTexture(gl.TEXTURE_2D, cached);\n uploadPremultiplied(gl, source);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n this.registered.set(id, source);\n return this.ensure(id, source, wrap, uploadPremultiplied);\n }\n\n /**\n * Delete the texture of every registry-backed id the registry has dropped.\n * The renderer calls this at the top of `render()`, before any draw, so a\n * texture is never deleted under a draw that has it bound.\n */\n sweep(registry: RegisteredTextureIds): void {\n const version = registry.getVersion();\n if (version === this.sweptVersion) return;\n this.sweptVersion = version;\n for (const id of this.registered.keys()) {\n if (registry.has(id)) continue;\n this.gl.deleteTexture(this.map.get(id) ?? null);\n this.map.delete(id);\n this.wraps.delete(id);\n this.registered.delete(id);\n }\n }\n\n private applyWrap(id: string, tex: WebGLTexture, wrap: TextureWrap): void {\n const gl = this.gl;\n const mode = wrap === 'repeat' ? gl.REPEAT : gl.CLAMP_TO_EDGE;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, mode);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, mode);\n gl.bindTexture(gl.TEXTURE_2D, null);\n this.wraps.set(id, wrap);\n }\n\n /** Create a single-channel R8 texture from raw bytes (full upload).\n * No-op if `id` already exists. Same LINEAR/CLAMP params as `upload`;\n * UNPACK_ALIGNMENT dropped to 1 for non-4-aligned row widths. */\n uploadR8(id: string, width: number, height: number, data: Uint8Array): void {\n if (this.map.has(id)) return;\n const gl = this.gl;\n const tex = gl.createTexture();\n if (!tex) throw new Error(`GLTextureCache: createTexture failed for id=\"${id}\"`);\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.R8, width, height, 0, gl.RED, gl.UNSIGNED_BYTE, data);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n this.map.set(id, tex);\n this.wraps.set(id, 'clamp');\n }\n\n /** Patch a rect of an existing R8 texture with tightly-packed w×h bytes. */\n subImageR8(id: string, x: number, y: number, w: number, h: number, data: Uint8Array): void {\n const tex = this.map.get(id);\n if (!tex) throw new Error(`GLTextureCache: texture \"${id}\" not uploaded`);\n const gl = this.gl;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\n gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, w, h, gl.RED, gl.UNSIGNED_BYTE, data);\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n\n /** Create a texture from premultiplied RGBA bytes that are a color: a page\n * of color glyphs. Mipmapped, as a font atlas must never be, because one is\n * drawn well below the size it was baked at. No-op if `id` already exists. */\n uploadRGBA(id: string, width: number, height: number, data: Uint8Array): void {\n if (this.map.has(id)) return;\n const gl = this.gl;\n const tex = gl.createTexture();\n if (!tex) throw new Error(`GLTextureCache: createTexture failed for id=\"${id}\"`);\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);\n gl.generateMipmap(gl.TEXTURE_2D);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n this.map.set(id, tex);\n this.wraps.set(id, 'clamp');\n }\n\n /** Patch a rect of an existing RGBA texture with tightly-packed w×h texels. */\n subImageRGBA(id: string, x: number, y: number, w: number, h: number, data: Uint8Array): void {\n const tex = this.map.get(id);\n if (!tex) throw new Error(`GLTextureCache: texture \"${id}\" not uploaded`);\n const gl = this.gl;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, w, h, gl.RGBA, gl.UNSIGNED_BYTE, data);\n gl.generateMipmap(gl.TEXTURE_2D);\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n\n bind(id: string, unit: number): void {\n const tex = this.map.get(id);\n if (!tex) throw new Error(`GLTextureCache: texture \"${id}\" not uploaded`);\n const gl = this.gl;\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, tex);\n }\n\n /**\n * Delete every uploaded GL texture and clear the map. The cache is\n * refillable afterward.\n */\n free(): void {\n const gl = this.gl;\n for (const tex of this.map.values()) {\n gl.deleteTexture(tex);\n }\n this.map.clear();\n this.wraps.clear();\n this.registered.clear();\n }\n}\n","/**\n * CPU gradient-ramp builder + the GL texture every baked ramp lives in.\n *\n * Each unique stop list is baked once into a 256-texel strip and written to its\n * own **row** of one RGBA texture, keyed by `JSON.stringify(stops)`. One\n * texture rather than one per ramp is what lets a gradient take a batch texture\n * slot the way a bitmap or a font atlas does: every gradient in a frame samples\n * the same unit, so a run does not break per gradient. The atlas is\n * GL-context-bound; discard and recreate on context loss.\n *\n * Texels are stored as straight RGBA. The fragment shader applies\n * premultiplication before writing outColor.\n */\n\nimport type { ColorSpace, GradStop } from '@weasel-js/paint';\nimport { resolveGradientStops, sampleResolvedStops } from '@weasel-js/paint';\n\n/** Texels across one ramp — the resolution a gradient is sampled at. */\nexport const RAMP_WIDTH = 256;\n\n/** Rows the atlas starts at, doubling from there. */\nconst INITIAL_ROWS = 16;\n\n/**\n * Rows the atlas stops growing at, past which the least recently used row is\n * recycled.\n *\n * WebGL2 guarantees `MAX_TEXTURE_SIZE` of at least 2048, so this is available\n * everywhere without a `getParameter` — which the GL recorder would answer with\n * a recording function rather than a number. A cap is also what bounds an\n * animating gradient, which mints a new stop list every frame and would\n * otherwise grow the atlas until it could not grow again.\n */\nexport const RAMP_ATLAS_MAX_ROWS = 1024;\n\n/** Bake gradient stops into a 256-entry RGBA lookup strip, which the shader\n * samples instead of evaluating stops per fragment. `space` is the gradient's\n * `interpolate` — the ramp is where a non-sRGB blend is paid for, once. */\nexport function buildGradientRamp(stops: GradStop[], space: ColorSpace = 'rgb'): Uint8ClampedArray {\n const data = new Uint8ClampedArray(RAMP_WIDTH * 4);\n if (stops.length === 0) return data;\n\n const resolved = resolveGradientStops(stops);\n for (let i = 0; i < RAMP_WIDTH; i++) {\n const [r, g, b, a] = sampleResolvedStops(resolved, i / (RAMP_WIDTH - 1), space);\n data[i * 4] = r * 255;\n data[i * 4 + 1] = g * 255;\n data[i * 4 + 2] = b * 255;\n data[i * 4 + 3] = a * 255;\n }\n\n return data;\n}\n\n/** The row identity. Two gradients with the same stops and different\n * `interpolate` bake to different texels, so the space is part of the key. */\nfunction rampKey(stops: GradStop[], space: ColorSpace): string {\n return `${space}|${JSON.stringify(stops)}`;\n}\n\nexport class GradientRampAtlas {\n /** Row per stop list, in least-recently-used order: a hit re-inserts, so the\n * first entry is the row a full atlas recycles. */\n private readonly rowByKey = new Map<string, number>();\n private texture: WebGLTexture | null = null;\n private rows = 0;\n /** Mirror of the texture, so growth can respecify it without re-baking every\n * ramp it already holds. */\n private pixels = new Uint8ClampedArray(0);\n private totalQueries = 0;\n private cacheHits = 0;\n\n constructor(private readonly gl: WebGL2RenderingContext) {}\n\n /** Rows the atlas currently holds — its texture height. */\n get height(): number {\n return this.rows;\n }\n\n /**\n * Bake `stops` into a row and return it, reusing the row an identical stop\n * list already holds.\n *\n * **A returned row outlives the frame only while the atlas has room.** Past\n * `RAMP_ATLAS_MAX_ROWS` an upload recycles the least recently used row, which\n * rewrites texels a row handed out earlier still names. Nothing that defers\n * its draw past this call may hold a row across another `upload` without\n * arranging to be flushed first.\n */\n upload(stops: GradStop[], space: ColorSpace = 'rgb'): number {\n const key = rampKey(stops, space);\n this.totalQueries++;\n const existing = this.rowByKey.get(key);\n if (existing !== undefined) {\n this.cacheHits++;\n this.rowByKey.delete(key);\n this.rowByKey.set(key, existing);\n return existing;\n }\n\n const row = this.claimRow();\n this.writeRow(row, buildGradientRamp(stops, space));\n this.rowByKey.set(key, row);\n return row;\n }\n\n /**\n * Whether uploading `stops` would move where existing rows sit — by growing\n * the atlas, which changes every row's `v`, or by recycling one, which\n * rewrites its texels.\n *\n * Anything holding a row past this call asks first and gets itself out of\n * the way, because neither can be undone once it has happened.\n */\n wouldReshape(stops: GradStop[], space: ColorSpace = 'rgb'): boolean {\n // An atlas holding nothing has no row to move, so its first growth is free.\n if (this.rowByKey.size === 0) return false;\n return !this.rowByKey.has(rampKey(stops, space))\n && this.rowByKey.size >= this.rows;\n }\n\n /**\n * The `v` a row is sampled at — its center.\n *\n * The center is load-bearing: the atlas filters LINEAR, so a `v` anywhere\n * else blends the ramp beside it into this one. At the center the neighbor's\n * weight is exactly zero.\n */\n rowV(row: number): number {\n return (row + 0.5) / (this.rows || 1);\n }\n\n bind(unit: number): void {\n const gl = this.gl;\n gl.activeTexture(gl.TEXTURE0 + unit);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n }\n\n hitRate(): number {\n if (this.totalQueries === 0) return 0;\n return this.cacheHits / this.totalQueries;\n }\n\n resetStats(): void {\n this.totalQueries = 0;\n this.cacheHits = 0;\n }\n\n /**\n * Delete the atlas texture and forget every row in it. The CPU mirror goes\n * with it, so the atlas is refillable afterward. Stats are left as-is.\n */\n free(): void {\n if (this.texture) this.gl.deleteTexture(this.texture);\n this.texture = null;\n this.rows = 0;\n this.pixels = new Uint8ClampedArray(0);\n this.rowByKey.clear();\n }\n\n /** The row the next ramp is written to: a free one, a taller atlas, or the\n * least recently used row of a full one. */\n private claimRow(): number {\n if (this.rowByKey.size < this.rows) return this.rowByKey.size;\n if (this.rows < RAMP_ATLAS_MAX_ROWS) {\n this.resize(this.rows === 0 ? INITIAL_ROWS : this.rows * 2);\n return this.rowByKey.size;\n }\n const [lruKey, lruRow] = this.rowByKey.entries().next().value as [string, number];\n this.rowByKey.delete(lruKey);\n return lruRow;\n }\n\n /** Grow to `rows`, keeping every row at the index it already had — a row\n * index is a stable name, and callers hold them. */\n private resize(rows: number): void {\n const gl = this.gl;\n const next = new Uint8ClampedArray(RAMP_WIDTH * rows * 4);\n next.set(this.pixels);\n this.pixels = next;\n this.rows = rows;\n\n if (!this.texture) {\n const tex = gl.createTexture();\n if (!tex) throw new Error('GradientRampAtlas: createTexture failed');\n this.texture = tex;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n }\n gl.texImage2D(\n gl.TEXTURE_2D, 0, gl.RGBA,\n RAMP_WIDTH, rows, 0,\n gl.RGBA, gl.UNSIGNED_BYTE, this.pixels,\n );\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n\n private writeRow(row: number, ramp: Uint8ClampedArray): void {\n const gl = this.gl;\n this.pixels.set(ramp, row * RAMP_WIDTH * 4);\n gl.bindTexture(gl.TEXTURE_2D, this.texture);\n gl.texSubImage2D(\n gl.TEXTURE_2D, 0, 0, row,\n RAMP_WIDTH, 1,\n gl.RGBA, gl.UNSIGNED_BYTE, ramp,\n );\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n}\n","import { mat3, type GlMat3 } from '@weasel-js/geom';\n\n/** Row-major 4×5 color matrix identity. */\nexport const IDENTITY_COLOR_MATRIX = new Float32Array([\n 1, 0, 0, 0, 0,\n 0, 1, 0, 0, 0,\n 0, 0, 1, 0, 0,\n 0, 0, 0, 1, 0,\n]);\n\nexport interface GroupFrame {\n transform?: GlMat3;\n alpha?: number;\n /** Row-major 4×5 color matrix (20 floats). Absent leaves the stack unchanged. */\n colorMatrix?: Float32Array | number[];\n}\n\n/**\n * Compose two row-major 4×5 color matrices: out = outer ∘ inner (inner\n * applied first). The bias column is at [4, 9, 14, 19].\n */\nfunction compose4x5(outer: Float32Array, inner: Float32Array): Float32Array {\n const result = new Float32Array(20);\n for (let row = 0; row < 4; row++) {\n for (let col = 0; col < 4; col++) {\n let sum = 0;\n for (let k = 0; k < 4; k++) {\n sum += outer[row * 5 + k] * inner[k * 5 + col];\n }\n result[row * 5 + col] = sum;\n }\n let biasSum = outer[row * 5 + 4];\n for (let k = 0; k < 4; k++) {\n biasSum += outer[row * 5 + k] * inner[k * 5 + 4];\n }\n result[row * 5 + 4] = biasSum;\n }\n return result;\n}\n\nexport class GroupState {\n private transformStack: GlMat3[] = [mat3.identity()];\n private alphaStack: number[] = [1];\n private colorMatrixStack: Float32Array[] = [IDENTITY_COLOR_MATRIX];\n\n get transform(): GlMat3 {\n return this.transformStack[this.transformStack.length - 1];\n }\n\n get alpha(): number {\n return this.alphaStack[this.alphaStack.length - 1];\n }\n\n get colorMatrix(): Float32Array {\n return this.colorMatrixStack[this.colorMatrixStack.length - 1];\n }\n\n push(frame: GroupFrame): void {\n const current = this.transform;\n const nextTransform = frame.transform ? mat3.multiply(current, frame.transform) : current;\n const nextAlpha = frame.alpha !== undefined ? this.alpha * frame.alpha : this.alpha;\n const nextCM = frame.colorMatrix\n ? compose4x5(\n this.colorMatrix,\n frame.colorMatrix instanceof Float32Array\n ? frame.colorMatrix\n : new Float32Array(frame.colorMatrix),\n )\n : this.colorMatrix;\n this.transformStack.push(nextTransform);\n this.alphaStack.push(nextAlpha);\n this.colorMatrixStack.push(nextCM);\n }\n\n /**\n * Push a frame whose children paint into a surface of their own. The\n * transform still accumulates. Alpha and color do not: applying them on the\n * way in would fade the pixels an effect is about to read, then fade them\n * again on the way out.\n *\n * Returns the pair the caller must apply at composite time — what `push`\n * would have left on the stack.\n */\n pushIsolated(frame: GroupFrame): { alpha: number; colorMatrix: Float32Array } {\n this.push(frame);\n const composited = { alpha: this.alpha, colorMatrix: this.colorMatrix };\n this.pop();\n const current = this.transform;\n this.transformStack.push(frame.transform ? mat3.multiply(current, frame.transform) : current);\n this.alphaStack.push(1);\n this.colorMatrixStack.push(IDENTITY_COLOR_MATRIX);\n return composited;\n }\n\n /** Drop every pushed frame, leaving the root. A frame that throws part-way\n * down the tree never pops, and the next frame would draw under leftovers. */\n reset(): void {\n this.transformStack.length = 1;\n this.alphaStack.length = 1;\n this.colorMatrixStack.length = 1;\n }\n\n pop(): void {\n if (this.transformStack.length <= 1) {\n throw new Error('GroupState.pop: cannot pop root frame');\n }\n this.transformStack.pop();\n this.alphaStack.pop();\n this.colorMatrixStack.pop();\n }\n}\n","/**\n * Kit-supplied vertex shader for a full-screen effect pass.\n *\n * Distinct from `CUSTOM_VERT_SRC` on purpose. That one's `v_uv` runs top-down\n * in *screen* space; an effect samples a texture the scene was just rendered\n * into, whose v axis runs the other way.\n *\n * PUBLIC CONTRACT — what every effect fragment shader may read:\n *\n * in vec2 v_uv 0..1 across the source texture\n * uniform sampler2D u_source what has been drawn so far\n * uniform vec2 u_resolution source size in device pixels\n * uniform vec2 u_texel 1.0 / u_resolution — one texel step\n *\n * PREMULTIPLIED ALPHA: `u_source` holds premultiplied RGBA. An effect that\n * weights neighboring samples (a blur) is doing the right thing on\n * premultiplied values; one that manipulates rgb against a must premultiply\n * its own output.\n */\nexport const EFFECT_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nin vec2 a_uv;\nout vec2 v_uv;\n\nvoid main() {\n v_uv = a_uv;\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n`;\n\n/** Attribute names the effect vertex shader binds. Same layout as the custom\n * prelude's, so `QUAD_VERTICES` serves both. */\nexport const EFFECT_ATTRIBUTES = ['a_position', 'a_uv'] as const;\n\n/** Uniforms the renderer sets on every effect pass. An effect must not\n * redeclare them with different meanings; it may leave any of them out. */\nexport const EFFECT_KIT_UNIFORMS = ['u_source', 'u_resolution', 'u_texel'] as const;\n\n/** The pass that puts a group's finished texture back into its parent.\n * `u_alpha` and the color matrix are applied here rather than inside the\n * offscreen render, so an effect samples the group's own pixels rather than\n * pixels already faded. */\nexport const COMPOSITE_FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_uv;\nuniform sampler2D u_source;\nuniform float u_alpha;\nuniform mat4 u_colorMatrix;\nuniform vec4 u_colorBias;\nout vec4 outColor;\n\nvoid main() {\n vec4 src = texture(u_source, v_uv);\n // Undo premultiplication before the colour matrix, which is defined on\n // straight alpha, then put it back for the blend.\n float a = src.a;\n vec3 rgb = a > 0.0 ? src.rgb / a : vec3(0.0);\n vec4 c = u_colorMatrix * vec4(rgb, a) + u_colorBias;\n c.a *= u_alpha;\n outColor = vec4(clamp(c.rgb, 0.0, 1.0) * c.a, c.a);\n}\n`;\n","/**\n * The pass that puts a group's finished texture back into its parent, and the\n * shared mechanics every effect pass uses to draw a full-screen quad.\n *\n * Registered as an ordinary program so it compiles through the same\n * `ensureProgram` path a consumer's effect does — one compile path, one place\n * a compile failure is reported.\n */\nimport { getProgramSource, registerProgram } from '../shaders/registerProgram';\nimport { EFFECT_VERT_SRC, COMPOSITE_FRAG_SRC } from './effectPrelude';\n\n/** Reserved id. The `weasel:` prefix is not enforced anywhere; it is here so a\n * consumer reading a shader-compile error knows whose program it is. */\nexport const COMPOSITE_PROGRAM_ID = 'weasel:effect-composite';\n\n/**\n * The composite program's id, registering the program on first ask. Not done\n * at module load: a bundler may drop an import kept only for its side effect.\n */\nexport function compositeProgramId(): string {\n if (!getProgramSource(COMPOSITE_PROGRAM_ID)) {\n registerProgram(COMPOSITE_PROGRAM_ID, EFFECT_VERT_SRC, COMPOSITE_FRAG_SRC);\n }\n return COMPOSITE_PROGRAM_ID;\n}\n","/**\n * How an isolated group's finished surface joins what is already drawn.\n *\n * Every color the renderer writes is premultiplied, so each Porter-Duff\n * operator is `source * Fa + destination * Fb` with both factors read off one\n * alpha or the other, which is a blend function and needs no second pass.\n */\n\n/** A Porter-Duff operator, named as canvas 2D's `globalCompositeOperation` names it. */\nexport type CompositeOp =\n | 'source-over' | 'source-in' | 'source-out' | 'source-atop'\n | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop'\n | 'xor' | 'lighter' | 'copy';\n\n/** What one side of the blend is scaled by. */\nexport type BlendFactor =\n | 'zero' | 'one'\n | 'source-alpha' | 'one-minus-source-alpha'\n | 'destination-alpha' | 'one-minus-destination-alpha';\n\n/** An operator with no name: `source * source + destination * destination`, on premultiplied color. */\nexport interface BlendFactors {\n source: BlendFactor;\n destination: BlendFactor;\n}\n\nconst OPERATORS: Readonly<Record<CompositeOp, BlendFactors>> = {\n 'source-over': { source: 'one', destination: 'one-minus-source-alpha' },\n 'source-in': { source: 'destination-alpha', destination: 'zero' },\n 'source-out': { source: 'one-minus-destination-alpha', destination: 'zero' },\n 'source-atop': { source: 'destination-alpha', destination: 'one-minus-source-alpha' },\n 'destination-over': { source: 'one-minus-destination-alpha', destination: 'one' },\n 'destination-in': { source: 'zero', destination: 'source-alpha' },\n 'destination-out': { source: 'zero', destination: 'one-minus-source-alpha' },\n 'destination-atop': { source: 'one-minus-destination-alpha', destination: 'source-alpha' },\n xor: { source: 'one-minus-destination-alpha', destination: 'one-minus-source-alpha' },\n lighter: { source: 'one', destination: 'one' },\n copy: { source: 'one', destination: 'zero' },\n};\n\n/** The factor pair `composite` stands for. */\nexport function blendFactorsOf(composite: CompositeOp | BlendFactors): BlendFactors {\n return typeof composite === 'string' ? OPERATORS[composite] : composite;\n}\n\n/** Whether `composite` is anything but the renderer's ordinary blend. */\nexport function isOwnComposite(composite: CompositeOp | BlendFactors | undefined): boolean {\n if (composite === undefined) return false;\n const { source, destination } = blendFactorsOf(composite);\n return source !== 'one' || destination !== 'one-minus-source-alpha';\n}\n\nfunction glFactor(gl: WebGL2RenderingContext, factor: BlendFactor): number {\n switch (factor) {\n case 'zero': return gl.ZERO;\n case 'one': return gl.ONE;\n case 'source-alpha': return gl.SRC_ALPHA;\n case 'one-minus-source-alpha': return gl.ONE_MINUS_SRC_ALPHA;\n case 'destination-alpha': return gl.DST_ALPHA;\n case 'one-minus-destination-alpha': return gl.ONE_MINUS_DST_ALPHA;\n }\n}\n\n/** Set the blend function `composite` stands for. */\nexport function applyComposite(gl: WebGL2RenderingContext, composite: CompositeOp | BlendFactors): void {\n const { source, destination } = blendFactorsOf(composite);\n gl.blendFunc(glFactor(gl, source), glFactor(gl, destination));\n}\n","import type { DrawContext } from './drawContext';\n\n/** Every GL draw the renderer issues goes through here, so the frame's\n * draw-call count cannot miss one. */\nexport function drawTriangles(ctx: DrawContext, count: number, type: number): void {\n ctx.gl.drawElements(ctx.gl.TRIANGLES, count, type, 0);\n if (ctx.stats) ctx.stats.drawCalls++;\n}\n","import type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\n\n// ─── Per-fragment clip test ───────────────────────────────────────────────────\n\n/**\n * Set the stencil test for the current clip depth. Called by every\n * fragment-producing draw before its drawElements call when clipDepth > 0.\n * At clipDepth = 0, disables STENCIL_TEST (zero-overhead common case).\n *\n * Note: not called by drawPathFillStencil / drawPathStrokeStenciled, which\n * manage their own stencil state (evenodd / inner-outer stencil). Those paths\n * coexist with clip bits because they use bit 0 exclusively while clip levels\n * occupy bits 1-7.\n */\nexport function applyClipTest(ctx: DrawContext, depth: number = ctx.clipDepth): void {\n const gl = ctx.gl;\n if (depth === 0) {\n gl.disable(gl.STENCIL_TEST);\n return;\n }\n const mask = ancestorMask(depth);\n gl.enable(gl.STENCIL_TEST);\n gl.stencilFunc(gl.EQUAL, mask, mask);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);\n}\n\n// ─── Clip-stencil helpers ────────────────────────────────────────────────────\n\n/**\n * Bit-mask for ancestor clip levels.\n * Returns bits 1..depth (inclusive).\n * depth=0 → 0x00; depth=1 → 0x02; depth=3 → 0x0E.\n */\nexport function ancestorMask(depth: number): number {\n return depth === 0 ? 0 : ((1 << (depth + 1)) - 1) & 0xFE;\n}\n\n/**\n * Write the bound even-odd mesh's parity to stencil bit 0, then leave the\n * test passing where that parity is odd and every enclosing clip holds. The\n * program, VAO, and model are the caller's, already bound.\n */\nexport function beginParityMask(ctx: DrawContext, indexCount: number): void {\n const gl = ctx.gl;\n gl.enable(gl.STENCIL_TEST);\n gl.colorMask(false, false, false, false);\n gl.stencilMask(0x01);\n gl.stencilFunc(gl.ALWAYS, 0, 0x01);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.INVERT);\n drawTriangles(ctx, indexCount, ctx.gl.UNSIGNED_INT);\n\n const clipMask = ancestorMask(ctx.clipDepth);\n gl.colorMask(true, true, true, true);\n gl.stencilFunc(gl.EQUAL, clipMask | 0x01, clipMask | 0x01);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);\n}\n\nexport function endParityMask(ctx: DrawContext): void {\n const gl = ctx.gl;\n // Narrow to bit 0 first: clear only zeroes bits the mask enables, and\n // pushClip owns bits 1-7.\n gl.stencilMask(0x01);\n gl.clear(gl.STENCIL_BUFFER_BIT);\n gl.disable(gl.STENCIL_TEST);\n}\n","import type { ShaderDrawCommand } from '../DrawCommand';\nimport { getTexture, type TextureHandle } from '../textures/registerTexture';\nimport type { ShaderUniform } from '../shaders/registerProgram';\nimport type { GLTextureCache } from '../cache/GLTextureCache';\nimport type { ShaderProgram, UniformArray } from '../shaders/ShaderProgram';\nimport { mat3 } from '@weasel-js/geom';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { applyClipTest } from './stencil';\n\nconst warnedUniforms = new Set<string>();\n\nfunction warnOnce(key: string, message: string): void {\n if (warnedUniforms.has(key)) return;\n warnedUniforms.add(key);\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n if (isDev) console.warn(message);\n}\n\nexport function warnOnceUniform(programId: string, name: string): void {\n warnOnce(\n `${programId}:${name}`,\n `weasel drawShader: uniform \"${name}\" not found in program \"${programId}\". ` +\n `Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`,\n );\n}\n\n/**\n * Bind a single ShaderUniform value to a GL uniform location.\n *\n * Type detection order:\n * 1. TextureHandle (object with string `.id`) — bind to next tex unit, set sampler.\n * 2. Float32Array — length 9 → mat3, length 16 → mat4. Other lengths throw in dev.\n * 3. Array — uniform2fv / uniform3fv / uniform4fv based on length.\n * 4. number — uniform1f.\n */\nexport function setUniform(\n gl: WebGL2RenderingContext,\n loc: WebGLUniformLocation,\n value: ShaderUniform,\n textureCache: GLTextureCache,\n nextTexUnit: { value: number },\n): void {\n if (value !== null && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Float32Array)\n && 'id' in value && typeof (value as TextureHandle).id === 'string') {\n const handle = value as TextureHandle;\n const entry = getTexture(handle.id);\n if (!entry) {\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n if (isDev) console.warn(`weasel setUniform: TextureHandle \"${handle.id}\" not registered`);\n return;\n }\n const unit = nextTexUnit.value++;\n // An upload binds and unbinds on the active unit, so it has to be this\n // uniform's own unit and not one an earlier sampler already holds.\n gl.activeTexture(gl.TEXTURE0 + unit);\n textureCache.uploadRegistered(handle.id, entry.source);\n textureCache.bind(handle.id, unit);\n gl.uniform1i(loc, unit);\n return;\n }\n\n // A kit matrix is in doubles; GL wants float32.\n if (value instanceof Float64Array) value = Float32Array.from(value);\n\n if (value instanceof Float32Array) {\n if (value.length === 9) {\n gl.uniformMatrix3fv(loc, false, value);\n } else if (value.length === 16) {\n gl.uniformMatrix4fv(loc, false, value);\n } else {\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n if (isDev) throw new TypeError(`weasel setUniform: Float32Array must be length 9 (mat3) or 16 (mat4), got ${value.length}`);\n }\n return;\n }\n\n if (Array.isArray(value)) {\n const arr = value as readonly number[];\n switch (arr.length) {\n case 2: gl.uniform2fv(loc, arr as [number, number]); break;\n case 3: gl.uniform3fv(loc, arr as [number, number, number]); break;\n case 4: gl.uniform4fv(loc, arr as [number, number, number, number]); break;\n default: {\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n if (isDev) throw new TypeError(`weasel setUniform: array length ${arr.length} not supported`);\n }\n }\n return;\n }\n\n if (typeof value === 'number') {\n gl.uniform1f(loc, value);\n return;\n }\n}\n\n/** How an array's element type is uploaded: the `uniform*v` call and the\n * number of components per element. */\nconst ARRAY_UPLOADS: Readonly<Record<string, { fn: string; n: number; matrix?: true }>> = {\n float: { fn: 'uniform1fv', n: 1 }, vec2: { fn: 'uniform2fv', n: 2 },\n vec3: { fn: 'uniform3fv', n: 3 }, vec4: { fn: 'uniform4fv', n: 4 },\n int: { fn: 'uniform1iv', n: 1 }, ivec2: { fn: 'uniform2iv', n: 2 },\n ivec3: { fn: 'uniform3iv', n: 3 }, ivec4: { fn: 'uniform4iv', n: 4 },\n bool: { fn: 'uniform1iv', n: 1 }, bvec2: { fn: 'uniform2iv', n: 2 },\n bvec3: { fn: 'uniform3iv', n: 3 }, bvec4: { fn: 'uniform4iv', n: 4 },\n uint: { fn: 'uniform1uiv', n: 1 }, uvec2: { fn: 'uniform2uiv', n: 2 },\n uvec3: { fn: 'uniform3uiv', n: 3 }, uvec4: { fn: 'uniform4uiv', n: 4 },\n mat2: { fn: 'uniformMatrix2fv', n: 4, matrix: true },\n mat3: { fn: 'uniformMatrix3fv', n: 9, matrix: true },\n mat4: { fn: 'uniformMatrix4fv', n: 16, matrix: true },\n mat2x2: { fn: 'uniformMatrix2fv', n: 4, matrix: true },\n mat3x3: { fn: 'uniformMatrix3fv', n: 9, matrix: true },\n mat4x4: { fn: 'uniformMatrix4fv', n: 16, matrix: true },\n mat2x3: { fn: 'uniformMatrix2x3fv', n: 6, matrix: true },\n mat2x4: { fn: 'uniformMatrix2x4fv', n: 8, matrix: true },\n mat3x2: { fn: 'uniformMatrix3x2fv', n: 6, matrix: true },\n mat3x4: { fn: 'uniformMatrix3x4fv', n: 12, matrix: true },\n mat4x2: { fn: 'uniformMatrix4x2fv', n: 8, matrix: true },\n mat4x3: { fn: 'uniformMatrix4x3fv', n: 12, matrix: true },\n};\n\ntype ArrayValue = readonly number[] | Float32Array | Int32Array | Uint32Array;\n\nfunction isArrayValue(value: ShaderUniform): value is ArrayValue {\n return Array.isArray(value) || value instanceof Float32Array\n || value instanceof Int32Array || value instanceof Uint32Array;\n}\n\n/** Fill an array uniform from slot 0 with one call. Throws in dev on a value\n * that is not a whole number of elements or overruns the declaration. */\nfunction setUniformArray(\n gl: WebGL2RenderingContext,\n name: string,\n arr: UniformArray,\n value: ArrayValue,\n): void {\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n const upload = ARRAY_UPLOADS[arr.type];\n if (!upload) {\n if (isDev) console.warn(`weasel setUniform: array uniform \"${name}\" has type ${arr.type}, which cannot be written as a whole`);\n return;\n }\n if (value.length % upload.n !== 0 || value.length > upload.n * arr.size) {\n if (isDev) {\n throw new TypeError(\n `weasel setUniform: \"${name}\" is ${arr.type}[${arr.size}], so its value must hold a multiple of ${upload.n} `\n + `numbers, at most ${upload.n * arr.size}; got ${value.length}`,\n );\n }\n return;\n }\n if (value.length === 0) return;\n const fn = (gl as unknown as Record<string, (...args: unknown[]) => void>)[upload.fn];\n if (upload.matrix) fn.call(gl, arr.location, false, value);\n else fn.call(gl, arr.location, value);\n}\n\n/** Write every entry of a command's `uniforms` map. A key naming an array\n * uniform with an array value fills the array; anything else goes to the\n * location of that exact name. */\nexport function setUniforms(\n gl: WebGL2RenderingContext,\n program: ShaderProgram,\n programId: string,\n uniforms: Record<string, ShaderUniform>,\n textureCache: GLTextureCache,\n nextTexUnit: { value: number },\n): void {\n for (const [name, value] of Object.entries(uniforms)) {\n const arr = program.uniformArray(name);\n if (arr && isArrayValue(value)) {\n setUniformArray(gl, name, arr, value);\n continue;\n }\n const loc = program.uniform(name);\n if (loc === undefined) {\n warnOnceUniform(programId, name);\n continue;\n }\n setUniform(gl, loc, value, textureCache, nextTexUnit);\n }\n}\n\nexport function drawShader(ctx: DrawContext, cmd: ShaderDrawCommand): void {\n const { gl, programRegistry, quadVbo, quadIbo, textureCache } = ctx;\n\n const program = ctx.ensureProgram?.(cmd.program.id) ?? programRegistry.get(cmd.program.id);\n if (!program) {\n warnOnce(\n `${cmd.program.id}:(program)`,\n `weasel drawShader: program \"${cmd.program.id}\" has no compiled program on this ` +\n 'renderer. Register its source with the module-level registerProgram() first; a ' +\n 'source that failed to compile is reported above.',\n );\n return;\n }\n if (!quadVbo || !quadIbo) {\n console.warn('weasel drawShader: quad geometry not initialized');\n return;\n }\n\n gl.useProgram(program.handle);\n\n const aPosLoc = program.attribute('a_position');\n const aUvLoc = program.attribute('a_uv');\n\n gl.bindBuffer(gl.ARRAY_BUFFER, quadVbo);\n if (aPosLoc !== undefined) {\n gl.enableVertexAttribArray(aPosLoc);\n gl.vertexAttribPointer(aPosLoc, 2, gl.FLOAT, false, 16, 0);\n }\n if (aUvLoc !== undefined) {\n gl.enableVertexAttribArray(aUvLoc);\n gl.vertexAttribPointer(aUvLoc, 2, gl.FLOAT, false, 16, 8);\n }\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, quadIbo);\n\n const proj = mat3.screenToClip(ctx.widthCss, ctx.heightCss);\n const uProj = program.uniform('u_proj');\n if (uProj !== undefined) gl.uniformMatrix3fv(uProj, false, mat3.toUniform(proj));\n\n const uBounds = program.uniform('u_bounds');\n if (uBounds !== undefined) {\n gl.uniform4f(uBounds, cmd.bounds.x, cmd.bounds.y, cmd.bounds.w, cmd.bounds.h);\n }\n\n const uView = program.uniform('u_view');\n if (uView !== undefined) gl.uniformMatrix3fv(uView, false, mat3.toUniform(ctx.state.transform));\n\n setUniforms(gl, program, cmd.program.id, cmd.uniforms, textureCache, { value: 1 });\n\n applyClipTest(ctx);\n drawTriangles(ctx, 6, ctx.gl.UNSIGNED_SHORT);\n\n if (aPosLoc !== undefined) gl.disableVertexAttribArray(aPosLoc);\n if (aUvLoc !== undefined) gl.disableVertexAttribArray(aUvLoc);\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n}\n","import type { ShaderProgram } from '../shaders/ShaderProgram';\nimport { mat3, type GlMat3 } from '@weasel-js/geom';\nimport { resolveColor } from '@weasel-js/paint';\nimport type { DrawContext } from './drawContext';\n\n/**\n * Uniform values a program already holds this frame, so an unchanged one is\n * not re-sent. Keyed on the `DrawContext`, which is built fresh per frame, so\n * the cache cannot outlive a frame and go stale against GL state.\n *\n * **Only for uniforms this module is the sole writer of.** A\n * `gl.uniform4f(… 'u_color' …)` added anywhere else leaves the cache believing\n * a value the program no longer has, and the wrong color is drawn until\n * something else moves it.\n */\ninterface UploadedUniforms {\n proj?: Float32Array;\n model?: Float32Array;\n colorMatrix?: Float32Array;\n colorBias?: Float32Array;\n originX?: number;\n originY?: number;\n /** Held as plain numbers, not a `Float32Array`: the caller's values are\n * doubles, and round-tripping them through float32 would compare unequal\n * every time and never skip an upload. */\n color?: [number, number, number, number];\n alpha?: number;\n}\n\nconst FRAME_UPLOADS = new WeakMap<DrawContext, WeakMap<ShaderProgram, UploadedUniforms>>();\n\nconst FRAME_PROJ = new WeakMap<DrawContext, GlMat3>();\n\nfunction uploadedFor(ctx: DrawContext, prog: ShaderProgram): UploadedUniforms {\n let byProgram = FRAME_UPLOADS.get(ctx);\n if (!byProgram) {\n byProgram = new WeakMap();\n FRAME_UPLOADS.set(ctx, byProgram);\n }\n let uploaded = byProgram.get(prog);\n if (!uploaded) {\n uploaded = {};\n byProgram.set(prog, uploaded);\n }\n return uploaded;\n}\n\n/** Element-wise, so a caller that mutates a shared array in place is still\n * compared by value. A NaN anywhere compares unequal and re-uploads, which is\n * the safe direction. */\nexport function sameValues(prev: Float32Array | undefined, next: ArrayLike<number>): boolean {\n if (prev === undefined || prev.length !== next.length) return false;\n for (let i = 0; i < prev.length; i++) if (prev[i] !== next[i]) return false;\n return true;\n}\n\n/**\n * `u_color`, skipped when the program already holds it. Every writer of\n * `u_color` must go through here — see `UploadedUniforms`.\n */\nexport function setColorUniform(\n ctx: DrawContext, prog: ShaderProgram,\n r: number, g: number, b: number, a: number,\n): void {\n const loc = prog.uniform('u_color');\n if (loc === undefined) return;\n const uploaded = uploadedFor(ctx, prog);\n const prev = uploaded.color;\n if (prev !== undefined && prev[0] === r && prev[1] === g && prev[2] === b && prev[3] === a) {\n return;\n }\n ctx.gl.uniform4f(loc, r, g, b, a);\n uploaded.color = [r, g, b, a];\n}\n\n/** `u_alpha`, on the same terms as `setColorUniform`. */\nexport function setAlphaUniform(ctx: DrawContext, prog: ShaderProgram, alpha: number): void {\n const loc = prog.uniform('u_alpha');\n if (loc === undefined) return;\n const uploaded = uploadedFor(ctx, prog);\n if (uploaded.alpha === alpha) return;\n ctx.gl.uniform1f(loc, alpha);\n uploaded.alpha = alpha;\n}\n\n/** The screen→clip matrix depends only on the frame's dimensions. */\nfunction projFor(ctx: DrawContext): GlMat3 {\n let proj = FRAME_PROJ.get(ctx);\n if (!proj) {\n proj = mat3.toUniform(mat3.screenToClip(ctx.widthCss, ctx.heightCss));\n FRAME_PROJ.set(ctx, proj);\n }\n return proj;\n}\n\n/** Reused across draws: the transpose below rebuilt this every command. */\nconst COLOR_MATRIX_SCRATCH = new Float32Array(16);\n\nexport function setColorMatrixUniforms(\n ctx: DrawContext, prog: ShaderProgram,\n cm: Float32Array = ctx.state.colorMatrix, // row-major 4×5\n): void {\n const gl = ctx.gl;\n const uploaded = uploadedFor(ctx, prog);\n\n const mLoc = prog.uniform('u_colorMatrix');\n if (mLoc !== undefined) {\n for (let row = 0; row < 4; row++) {\n for (let col = 0; col < 4; col++) {\n COLOR_MATRIX_SCRATCH[col * 4 + row] = cm[row * 5 + col];\n }\n }\n if (!sameValues(uploaded.colorMatrix, COLOR_MATRIX_SCRATCH)) {\n gl.uniformMatrix4fv(mLoc, false, COLOR_MATRIX_SCRATCH);\n uploaded.colorMatrix = Float32Array.from(COLOR_MATRIX_SCRATCH);\n }\n }\n\n const bLoc = prog.uniform('u_colorBias');\n if (bLoc !== undefined) {\n const bias = [cm[4], cm[9], cm[14], cm[19]];\n if (!sameValues(uploaded.colorBias, bias)) {\n gl.uniform4f(bLoc, bias[0], bias[1], bias[2], bias[3]);\n uploaded.colorBias = Float32Array.from(bias);\n }\n }\n}\n\n/** A model translation at or past this many pixels is rebased before upload:\n * a float32 there is coarser than 1/128 px, and at 2^24 than a whole one. */\nexport const REBASE_TRANSLATION_PX = 65536;\n\nconst MODEL_SCRATCH = new Float32Array(9);\nconst PROJ_SCRATCH = new Float32Array(9);\n\n/**\n * `u_proj` and `u_model`, each skipped when the program already holds it.\n *\n * `model` is in doubles and the uniform is not: far from the origin at high\n * zoom its translation is millions of pixels, which a float32 holds to a\n * whole pixel at best. A program that declares `u_origin` computes\n * `u_model * (a_position - u_origin)`, so for a large translation this sends\n * the local point that lands on the screen's corner as `u_origin` and a model\n * whose translation is what is left over, a few pixels.\n */\nexport function setProjAndModel(\n ctx: DrawContext, prog: ShaderProgram,\n model: GlMat3 = ctx.state.transform,\n proj: GlMat3 = projFor(ctx),\n): void {\n const gl = ctx.gl;\n const uploaded = uploadedFor(ctx, prog);\n\n PROJ_SCRATCH.set(proj);\n if (!sameValues(uploaded.proj, PROJ_SCRATCH)) {\n gl.uniformMatrix3fv(prog.uniform('u_proj')!, false, PROJ_SCRATCH);\n uploaded.proj = Float32Array.from(PROJ_SCRATCH);\n }\n\n MODEL_SCRATCH.set(model);\n const originLoc = prog.uniform('u_origin');\n if (originLoc !== undefined) {\n let ox = 0;\n let oy = 0;\n const tx = model[6], ty = model[7];\n if (Math.abs(tx) >= REBASE_TRANSLATION_PX || Math.abs(ty) >= REBASE_TRANSLATION_PX) {\n const a = model[0], b = model[1], c = model[3], d = model[4];\n const det = a * d - b * c;\n // Rounded first: the shader subtracts the float32 it was sent.\n const lx = Math.fround((c * ty - d * tx) / det);\n const ly = Math.fround((b * tx - a * ty) / det);\n if (Number.isFinite(lx) && Number.isFinite(ly)) {\n ox = lx;\n oy = ly;\n MODEL_SCRATCH[6] = a * ox + c * oy + tx;\n MODEL_SCRATCH[7] = b * ox + d * oy + ty;\n }\n }\n if (uploaded.originX !== ox || uploaded.originY !== oy) {\n gl.uniform2f(originLoc, ox, oy);\n uploaded.originX = ox;\n uploaded.originY = oy;\n }\n }\n\n if (!sameValues(uploaded.model, MODEL_SCRATCH)) {\n gl.uniformMatrix3fv(prog.uniform('u_model')!, false, MODEL_SCRATCH);\n uploaded.model = Float32Array.from(MODEL_SCRATCH);\n }\n}\n\nexport function setSolidPaintUniforms(\n ctx: DrawContext, prog: ShaderProgram,\n color: string, opacity: number | undefined,\n): void {\n const [r, g, b, a] = resolveColor(color);\n setColorUniform(ctx, prog, r, g, b, a * (opacity ?? 1));\n setAlphaUniform(ctx, prog, ctx.state.alpha);\n}\n","import type { ShaderUniform } from '../shaders/registerProgram';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { setColorMatrixUniforms } from './uniforms';\nimport { setUniforms } from './customShader';\n\n/** Rebind `ctx.renderTarget` after an offscreen pass: a pooled target takes\n * the whole `width` × `height` buffer, the default framebuffer the renderer's\n * own rect and the scissor it had. */\nexport function returnToRenderTarget(\n ctx: DrawContext, width: number, height: number, scissorWasOn: boolean,\n): void {\n const gl = ctx.gl;\n const target = ctx.renderTarget ?? null;\n gl.bindFramebuffer(gl.FRAMEBUFFER, target ? target.fbo : null);\n if (target) {\n gl.viewport(0, 0, width, height);\n } else {\n ctx.restoreTargetRect?.();\n if (scissorWasOn) gl.enable(gl.SCISSOR_TEST);\n }\n}\n\n/** One pass: the kit quad, `u_source` bound to `texture`, and whatever else\n * the caller supplies. Leaves no attribute arrays or buffers bound. */\nexport function drawFullscreenQuad(\n ctx: DrawContext,\n program: ShaderProgram,\n texture: WebGLTexture,\n width: number,\n height: number,\n uniforms?: Record<string, ShaderUniform>,\n composite?: { alpha: number; colorMatrix: Float32Array },\n programId?: string,\n): void {\n const gl = ctx.gl;\n gl.useProgram(program.handle);\n\n const aPos = program.attribute('a_position');\n const aUv = program.attribute('a_uv');\n gl.bindBuffer(gl.ARRAY_BUFFER, ctx.quadVbo);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ctx.quadIbo);\n if (aPos !== undefined && aPos >= 0) {\n gl.enableVertexAttribArray(aPos);\n gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 16, 0);\n }\n if (aUv !== undefined && aUv >= 0) {\n gl.enableVertexAttribArray(aUv);\n gl.vertexAttribPointer(aUv, 2, gl.FLOAT, false, 16, 8);\n }\n\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n const source = program.uniform('u_source');\n if (source !== undefined) gl.uniform1i(source, 0);\n const resolution = program.uniform('u_resolution');\n if (resolution !== undefined) gl.uniform2f(resolution, width, height);\n const texel = program.uniform('u_texel');\n if (texel !== undefined) gl.uniform2f(texel, 1 / width, 1 / height);\n\n if (composite) {\n const alpha = program.uniform('u_alpha');\n if (alpha !== undefined) gl.uniform1f(alpha, composite.alpha);\n setColorMatrixUniforms(ctx, program, composite.colorMatrix);\n }\n\n // Unit 0 is `u_source`; a consumer texture starts above it.\n if (uniforms) setUniforms(gl, program, programId ?? 'effect', uniforms, ctx.textureCache, { value: 1 });\n\n drawTriangles(ctx, 6, ctx.gl.UNSIGNED_SHORT);\n\n if (aPos !== undefined && aPos >= 0) gl.disableVertexAttribArray(aPos);\n if (aUv !== undefined && aUv >= 0) gl.disableVertexAttribArray(aUv);\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n}\n","import type { Path } from '@weasel-js/geom';\nimport type { GLMeshHandle } from '../cache/GLMeshCache';\nimport { getMesh } from '../cache/cache';\nimport { tessellate, type Mesh } from '@weasel-js/geom/tessellate';\nimport type { DrawContext } from './drawContext';\n\n/**\n * Tessellate a fill honoring ctx.flattenTolerance: default route is the\n * persistent Path-identity cache; a custom tolerance tessellates fresh, because\n * the persistent cache's key does not include tolerance.\n */\nexport function fillMesh(ctx: DrawContext, path: Path): Mesh {\n if (ctx.flattenTolerance !== undefined) {\n return tessellate(path, { flattenTolerance: ctx.flattenTolerance });\n }\n return getMesh(path);\n}\n\n/** Upload a mesh for its own draw. A freshly tessellated one rides the\n * transient pool, freed at end of frame. */\nexport function meshHandle(ctx: DrawContext, mesh: Mesh): GLMeshHandle {\n if (ctx.flattenTolerance !== undefined) return ctx.meshCache.uploadTransient(mesh);\n return ctx.meshCache.handleFor(mesh);\n}\n\nexport function fillMeshHandle(ctx: DrawContext, path: Path): GLMeshHandle {\n return meshHandle(ctx, fillMesh(ctx, path));\n}\n","import { IDENTITY_COLOR_MATRIX } from '../state/GroupState';\nimport type { DrawContext } from './drawContext';\nimport { sameValues } from './uniforms';\n\n/** Identity in row-major 4×5 leaves `src` untouched *and* leaves the shader's\n * clamp with nothing to do, which is what makes the alpha fold exact. */\nfunction isIdentityColorMatrix(cm: Float32Array): boolean {\n return cm === IDENTITY_COLOR_MATRIX || sameValues(IDENTITY_COLOR_MATRIX, cm);\n}\n\n/** Whether colors are mapped here at all, and whether a run holds more than one\n * matrix. Mutable only so the perf specs that break a run with a color matrix\n * still can; the barrel does not export it. Off, a matrix breaks every run it\n * changes under, as it used to. */\nexport const colorFolding = { enabled: true };\n\nconst clamp01 = (v: number): number => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/**\n * Whether a solid or a glyph under the live group state is mapped on the CPU,\n * and so staged under an identity matrix. `foldColor` and the run's choice of\n * matrix both ask here, because they have to agree.\n */\nexport function foldsColor(ctx: DrawContext): boolean {\n return colorFolding.enabled || isIdentityColorMatrix(ctx.state.colorMatrix);\n}\n\n/**\n * The color a solid or glyph vertex carries, from its straight-alpha rgba.\n *\n * The batch shader computes `mapped = clamp(CM * src + bias)` and\n * `a = mapped.a * u_alpha`, and for a vertex whose texel is white or a\n * distance field `src` is the vertex color alone. So the same arithmetic done\n * here gives the same fragment under an identity matrix, and the group's\n * matrix and alpha need not reach the shader. With folding off and a real\n * matrix live the shader does it, and the color goes in as authored.\n */\nexport function foldColor(\n ctx: DrawContext, r: number, g: number, b: number, a: number,\n): [number, number, number, number] {\n const cm = ctx.state.colorMatrix;\n const alpha = ctx.state.alpha;\n if (isIdentityColorMatrix(cm)) return [r, g, b, a * alpha];\n if (!colorFolding.enabled) return [r, g, b, a];\n return [\n clamp01(cm[0] * r + cm[1] * g + cm[2] * b + cm[3] * a + cm[4]),\n clamp01(cm[5] * r + cm[6] * g + cm[7] * b + cm[8] * a + cm[9]),\n clamp01(cm[10] * r + cm[11] * g + cm[12] * b + cm[13] * a + cm[14]),\n clamp01(cm[15] * r + cm[16] * g + cm[17] * b + cm[18] * a + cm[19]) * alpha,\n ];\n}\n\n/** Channel scales for a textured vertex; the fourth multiplies its alpha after the texel's. */\nexport type Tint = readonly [number, number, number, number];\n\nconst NO_TINT: Tint = [1, 1, 1, 1];\nconst DIAGONAL = [0, 6, 12, 18];\n\n/**\n * The per-channel scale the live group state amounts to on a texel, group\n * alpha included, or null when the CPU cannot stand in for the shader.\n *\n * It can when the matrix has no bias and nothing off its diagonal, and every\n * scale is within 0..1: then `clamp(CM * texel)` clamps nothing, and scaling\n * the vertex color the texel is multiplied by gives the same product under\n * identity. A scale past 1 does not qualify, because the shader clamps after\n * the texel and a vertex color cannot.\n */\nexport function textureTint(ctx: DrawContext): Tint | null {\n const cm = ctx.state.colorMatrix;\n const alpha = ctx.state.alpha;\n if (isIdentityColorMatrix(cm)) return alpha === 1 ? NO_TINT : [1, 1, 1, alpha];\n if (!colorFolding.enabled) return null;\n for (let i = 0; i < 20; i++) {\n const v = cm[i];\n if (DIAGONAL.includes(i) ? v < 0 || v > 1 : v !== 0) return null;\n }\n return [cm[0], cm[6], cm[12], cm[18] * alpha];\n}\n","import { BATCH_MATRIX_SLOTS } from '../shaders/batchFill';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport type { DrawContext } from './drawContext';\nimport { colorFolding } from './foldColor';\nimport { sameValues } from './uniforms';\n\n/**\n * One color matrix and group alpha a run draws under. A vertex names its own\n * by index, so a run holds several: entry `i` is `u_colorMatrix[i]`,\n * `u_colorBias[i]`, and `u_alpha[i]`.\n */\nexport interface BatchMatrix {\n /** Row-major 4×5, as `GroupState` holds it. */\n colorMatrix: Float32Array;\n alpha: number;\n}\n\n/**\n * The index this matrix and alpha have in `matrices`, the next free one if\n * they are new to it, or -1 if it is full.\n *\n * By value, not by reference: a group carrying an identity color matrix still\n * goes through `compose4x5`, which allocates a new array holding equal numbers.\n */\nexport function matrixIndex(\n matrices: readonly BatchMatrix[], colorMatrix: Float32Array, alpha: number,\n): number {\n for (let i = 0; i < matrices.length; i++) {\n const m = matrices[i];\n if (m.alpha === alpha\n && (m.colorMatrix === colorMatrix || sameValues(m.colorMatrix, colorMatrix))) return i;\n }\n return matrices.length < (colorFolding.enabled ? BATCH_MATRIX_SLOTS : 1) ? matrices.length : -1;\n}\n\nconst MATRICES = new Float32Array(16 * BATCH_MATRIX_SLOTS);\nconst BIASES = new Float32Array(4 * BATCH_MATRIX_SLOTS);\nconst ALPHAS = new Float32Array(BATCH_MATRIX_SLOTS);\n\n/** What each batch program holds this frame. Keyed on the `DrawContext`, which\n * is built per frame, so it cannot go stale against GL state. */\nconst UPLOADED = new WeakMap<DrawContext, WeakMap<ShaderProgram, readonly BatchMatrix[]>>();\n\n/** Whether `held` already starts with `matrices`. Entries past a run's own are\n * ones no vertex of it names. */\nfunction holds(held: readonly BatchMatrix[], matrices: readonly BatchMatrix[]): boolean {\n if (held.length < matrices.length) return false;\n for (let i = 0; i < matrices.length; i++) {\n const a = held[i];\n const b = matrices[i];\n if (a.alpha !== b.alpha) return false;\n if (a.colorMatrix !== b.colorMatrix && !sameValues(a.colorMatrix, b.colorMatrix)) return false;\n }\n return true;\n}\n\n/**\n * `u_colorMatrix`, `u_colorBias`, and `u_alpha` for a run, skipped when the\n * batch program already holds them. Nothing else may write these three.\n * `prog` must declare as many entries as the run has.\n */\nexport function uploadBatchMatrices(\n ctx: DrawContext, prog: ShaderProgram, matrices: readonly BatchMatrix[],\n): void {\n let byProgram = UPLOADED.get(ctx);\n if (!byProgram) {\n byProgram = new WeakMap();\n UPLOADED.set(ctx, byProgram);\n }\n const held = byProgram.get(prog);\n if (held !== undefined && holds(held, matrices)) return;\n const n = matrices.length;\n for (let i = 0; i < n; i++) {\n const cm = matrices[i].colorMatrix;\n // Row-major 4×5 into a column-major mat4 and its bias column.\n for (let row = 0; row < 4; row++) {\n for (let col = 0; col < 4; col++) MATRICES[16 * i + col * 4 + row] = cm[row * 5 + col];\n BIASES[4 * i + row] = cm[row * 5 + 4];\n }\n ALPHAS[i] = matrices[i].alpha;\n }\n const gl = ctx.gl;\n // The entries the run has, not the whole array: the rest are ones no vertex\n // of it names.\n gl.uniformMatrix4fv(prog.uniform('u_colorMatrix')!, false, MATRICES.subarray(0, 16 * n));\n gl.uniform4fv(prog.uniform('u_colorBias')!, BIASES.subarray(0, 4 * n));\n gl.uniform1fv(prog.uniform('u_alpha')!, ALPHAS.subarray(0, n));\n byProgram.set(prog, matrices.slice());\n}\n","import { mat3 } from '@weasel-js/geom';\nimport { BATCH_TEXTURE_SLOTS, RAMP_SLOT } from '../shaders/batchFill';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { setColorUniform, setProjAndModel } from './uniforms';\nimport { uploadBatchMatrices } from './batchMatrices';\nimport { applyClipTest } from './stencil';\n\n/** The rect batch transforms its own corners, so it draws at model identity. */\nexport const BATCH_MODEL = mat3.identity();\n\n/** `u_samplers[i] = i`, uploaded whole per flush. Built once: the mapping from\n * slot to texture unit is the identity and never varies. */\nconst SAMPLER_UNITS = new Int32Array(\n Array.from({ length: BATCH_TEXTURE_SLOTS }, (_, i) => i),\n);\n\n/** `u_fieldScale`, per slot: an atlas slot's `glyphFieldScale`. Slots that are\n * not atlases keep whatever a previous flush wrote, which nothing reads. */\nconst FIELD_SCALES = new Float32Array(2 * BATCH_TEXTURE_SLOTS);\n\n/**\n * Draw the staged run as one `drawElements`, under the state it was staged\n * under. Callers that are about to bind a different program, or paint anything\n * that must land on top of the run, call this first.\n *\n * The stencil is real GL state that the staged values cannot reconstruct, so\n * `pushClip` flushes *before* writing a bit, and `popClip` before clearing one\n * a staged run tests.\n *\n * `u_color` stays white because the program multiplies it by the per-vertex\n * color, and `u_model` stays identity because the corners arrive already\n * transformed.\n */\nexport function flushBatch(ctx: DrawContext): void {\n const batch = ctx.drawBatch;\n const staged = ctx.batchState;\n if (batch.length === 0 || staged === undefined) {\n // An empty run's state still names a clip depth, and an item refused by\n // the CPU cut is about to be staged again under a different one.\n ctx.batchState = undefined;\n return;\n }\n const gl = ctx.gl;\n const prog = staged.matrices.length > 1 ? ctx.batchFillMatrices ?? ctx.batchFill : ctx.batchFill;\n gl.useProgram(prog.handle);\n const indexCount = batch.uploadAndBind();\n setProjAndModel(ctx, prog, BATCH_MODEL);\n setColorUniform(ctx, prog, 1, 1, 1, 1);\n uploadBatchMatrices(ctx, prog, staged.matrices);\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, ctx.whiteTexture);\n for (let i = 0; i < staged.textures.length; i++) {\n const entry = staged.textures[i];\n if (entry.kind === 'atlas') {\n ctx.textureCache.bind(entry.id, i + 1);\n FIELD_SCALES[2 * (i + 1)] = entry.fieldScale[0];\n FIELD_SCALES[2 * (i + 1) + 1] = entry.fieldScale[1];\n continue;\n }\n ctx.imageCache.bind(entry.image, i + 1);\n // Per flush, not at upload: the same bitmap can be drawn at both filters in\n // one frame. The cache skips the write when the texture already carries the\n // value, which is most flushes.\n ctx.imageCache.setMagFilter(\n entry.image,\n entry.sampling === 'nearest' ? gl.NEAREST : gl.LINEAR,\n );\n }\n if (staged.ramps) ctx.gradRamps.bind(RAMP_SLOT);\n gl.uniform1iv(prog.uniform('u_samplers')!, SAMPLER_UNITS);\n gl.uniform2fv(prog.uniform('u_fieldScale')!, FIELD_SCALES);\n applyClipTest(ctx, staged.clipDepth);\n drawTriangles(ctx, indexCount, ctx.gl.UNSIGNED_INT);\n // Everything else in the renderer binds its texture to unit 0 and some of it\n // does so without an `activeTexture` of its own, so leaving a high unit selected\n // sends the next such bind to a unit nothing samples.\n gl.activeTexture(gl.TEXTURE0);\n // Not redundant: `drawShader` binds no VAO and points attributes at whatever\n // is current, so a slot left bound here comes back corrupted a ring later.\n gl.bindVertexArray(null);\n batch.reset();\n ctx.batchState = undefined;\n}\n","import type { Path, GlMat3 } from '@weasel-js/geom';\nimport { axisAlignedClipRect, intersectClipRects, type ClipRect } from '../batchClip';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { fillMeshHandle } from './mesh';\nimport { setProjAndModel } from './uniforms';\nimport { ancestorMask } from './stencil';\nimport { flushBatch } from './flushBatch';\n\n/** `enterClip` for a group command, refusing one past the stencil's budget. */\nexport function enterGroupClip(ctx: DrawContext, clip: Path): void {\n const pending = ctx.clipStack.reduce((n, e) => n + (e.depth === 0 ? 1 : 0), 0);\n if (ctx.clipDepth + pending + 1 > 7) {\n throw new Error(\n 'weasel: clip nesting depth exceeded (max 7). You can\\'t nest more than 7 levels ' +\n 'of clipped containers in a single draw tree. Flatten the hierarchy or compose ' +\n 'poses outside the scene graph.',\n );\n }\n enterClip(ctx, clip);\n}\n\n/**\n * Push a group's clip. A clip only the stencil can express takes its bit now.\n * An axis-aligned rect takes none: staged geometry is cut to it on the CPU, so\n * content inside it joins the run outside it. It takes a bit only if something\n * that draws for itself turns up inside it — see `flushForOwnDraw`.\n */\nfunction enterClip(ctx: DrawContext, path: Path): void {\n const transform = ctx.state.transform;\n const rect = axisAlignedClipRect(path, transform);\n if (rect === null) {\n // Bits nest in stack order, so any rect clip still without one takes it\n // first.\n materializeClips(ctx);\n const depth = ctx.clipDepth + 1;\n pushClip(ctx, path, depth);\n ctx.clipDepth = depth;\n ctx.clipStack.push({ path, transform, rect: null, depth });\n } else {\n ctx.clipStack.push({ path, transform, rect, depth: 0 });\n }\n syncBatchClip(ctx);\n}\n\nexport function leaveClip(ctx: DrawContext): void {\n const entry = ctx.clipStack.pop()!;\n if (entry.depth > 0) {\n popClip(ctx, entry.path, entry.depth - 1, entry.transform);\n ctx.clipDepth = entry.depth - 1;\n }\n syncBatchClip(ctx);\n}\n\n/** Give every rect clip on the stack its stencil bit, for a draw the CPU cut\n * cannot reach. */\nfunction materializeClips(ctx: DrawContext): void {\n for (const entry of ctx.clipStack) {\n if (entry.depth !== 0) continue;\n const depth = ctx.clipDepth + 1;\n pushClip(ctx, entry.path, depth, entry.transform);\n entry.depth = depth;\n ctx.clipDepth = depth;\n }\n}\n\nfunction syncBatchClip(ctx: DrawContext): void {\n let rect: ClipRect | null = null;\n for (const entry of ctx.clipStack) {\n if (entry.rect) rect = rect ? intersectClipRects(rect, entry.rect) : entry.rect;\n }\n ctx.drawBatch.clip = rect;\n}\n\n/**\n * The clip depth a run is staged and drawn at: the innermost clip only the\n * stencil can express. Rect clips are left out whether or not they hold a bit,\n * because the CPU cut already applies them — which is what lets a run cross\n * them.\n */\nexport function runClipDepth(ctx: DrawContext): number {\n const stack = ctx.clipStack;\n if (stack.length === 0 || ctx.uncut) return ctx.clipDepth;\n for (let i = stack.length - 1; i >= 0; i--) {\n if (stack[i].rect === null) return stack[i].depth;\n }\n // Only rect clips: whatever depth held before the first of them took a bit.\n for (const entry of stack) if (entry.depth > 0) return entry.depth - 1;\n return ctx.clipDepth;\n}\n\n/**\n * Put the rect clips on the stencil and stop cutting, for an item the batch\n * refused to cut — one with a slanted edge across a clip (see\n * `DrawBatch.clipQuad`). Staged again between this and `leaveUncut`, the item\n * sees the full stencil depth and lands in a run of its own under every clip.\n * Returns the cut to hand back. A pair rather than a callback: the staging\n * paths are hot, and a closure would cost an allocation on every call.\n */\nexport function enterUncut(ctx: DrawContext): ClipRect | null {\n materializeClips(ctx);\n const cut = ctx.drawBatch.clip;\n ctx.drawBatch.clip = null;\n ctx.uncut = true;\n return cut;\n}\n\nexport function leaveUncut(ctx: DrawContext, cut: ClipRect | null): void {\n ctx.drawBatch.clip = cut;\n ctx.uncut = false;\n}\n\n/** `fn(ctx, a, b)` again, uncut — for the stage-and-push helpers, which pass\n * themselves. */\nexport function retryUncut<A, B>(\n ctx: DrawContext, a: A, b: B, fn: (ctx: DrawContext, a: A, b: B) => void,\n): void {\n const cut = enterUncut(ctx);\n fn(ctx, a, b);\n leaveUncut(ctx, cut);\n}\n\n/**\n * Drain the run before a draw that does not go through it, and give that draw\n * the stencil it tests against. Every such draw starts here or behind a\n * `tryStageFill` that returned `false`, which ends the same way.\n */\nexport function flushForOwnDraw(ctx: DrawContext): void {\n flushBatch(ctx);\n if (ctx.clipStack.length > 0) materializeClips(ctx);\n}\n\n/**\n * Rasterize a path into the stencil buffer. The caller sets stencilFunc /\n * stencilOp / stencilMask and colorMask before calling.\n */\nfunction rasterizePathToStencil(ctx: DrawContext, path: Path, model: GlMat3): void {\n const gl = ctx.gl;\n const handle = fillMeshHandle(ctx, path);\n gl.useProgram(ctx.pathFill.handle);\n gl.bindVertexArray(handle.vao);\n setProjAndModel(ctx, ctx.pathFill, model);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n gl.bindVertexArray(null);\n}\n\n/**\n * Push a clip level: sets stencil bit `newDepth` where the path covers and all\n * ancestor clip bits are already set. Restores stencilMask(0xFF) on exit.\n */\nexport function pushClip(\n ctx: DrawContext, path: Path, newDepth: number, model: GlMat3 = ctx.state.transform,\n): void {\n // First, not last: a run staged outside the clip would otherwise draw under\n // a mask it never had.\n flushBatch(ctx);\n const gl = ctx.gl;\n const ancestors = ancestorMask(newDepth - 1);\n const newBit = 1 << newDepth;\n const ref = ancestors | newBit;\n\n gl.enable(gl.STENCIL_TEST);\n gl.colorMask(false, false, false, false);\n if (fillMeshHandle(ctx, path).requiresStencil) {\n // Fans, one per contour: their union is not the path. Parity goes on\n // bit 0, the clip bit is written where parity is odd, and drawing the\n // fans a third time returns bit 0 to zero.\n gl.stencilMask(0x01);\n gl.stencilFunc(gl.ALWAYS, 0, 0x01);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.INVERT);\n rasterizePathToStencil(ctx, path, model);\n gl.stencilMask(newBit);\n gl.stencilFunc(gl.EQUAL, ref | 0x01, ancestors | 0x01);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);\n rasterizePathToStencil(ctx, path, model);\n gl.stencilMask(0x01);\n gl.stencilFunc(gl.ALWAYS, 0, 0x01);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.INVERT);\n rasterizePathToStencil(ctx, path, model);\n } else {\n gl.stencilMask(newBit);\n gl.stencilFunc(gl.EQUAL, ref, ancestors);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);\n rasterizePathToStencil(ctx, path, model);\n }\n\n gl.colorMask(true, true, true, true);\n // Restore full mask so subsequent draw functions don't inherit a narrowed mask.\n gl.stencilMask(0xFF);\n}\n\n/**\n * Pop a clip level: rasterizes the same path again, clearing bit\n * `oldDepth + 1` where the matching push set it. Restores stencilMask(0xFF)\n * on exit.\n */\nexport function popClip(\n ctx: DrawContext, path: Path, oldDepth: number, model: GlMat3 = ctx.state.transform,\n): void {\n // First, not last: past here the mask is gone, and these pixels belonged\n // inside it. A run staged below this bit does not test it, so it lives on.\n if (ctx.batchState !== undefined && ctx.batchState.clipDepth > oldDepth) flushBatch(ctx);\n const gl = ctx.gl;\n // Re-enable stencil: child draw functions (evenodd/stenciled-stroke) disable\n // it at their end; we must set it before writing the clear pass.\n gl.enable(gl.STENCIL_TEST);\n\n const oldBit = 1 << (oldDepth + 1);\n const ref = ancestorMask(oldDepth) | oldBit;\n\n gl.colorMask(false, false, false, false);\n gl.stencilMask(oldBit);\n gl.stencilFunc(gl.EQUAL, ref, ref);\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.ZERO);\n\n rasterizePathToStencil(ctx, path, model);\n\n gl.colorMask(true, true, true, true);\n // Restore full mask so subsequent draw functions don't inherit a narrowed mask.\n gl.stencilMask(0xFF);\n}\n","import type { CommandPaint, MarkerRef, CommandStroke } from '@weasel-js/paint';\nimport type { PathDrawCommand } from './DrawCommand';\nimport type { GlMat3 } from '@weasel-js/geom';\nimport { resolveStrokeWidth } from '@weasel-js/stroke';\nimport {\n strokeSpaceOf, type ScreenSpace, type StrokeSpaces,\n} from '@weasel-js/stroke';\nimport { quantizeStrokeScale } from './cache/strokeMeshCache';\nimport { resolveMarkerSize } from '@weasel-js/stroke';\n\n/** A path command whose stroke paints. */\nexport type StrokedPathCommand = PathDrawCommand & { stroke: CommandStroke & { paint: CommandPaint } };\n\n/** A stroke command ready to tessellate, and the spaces to tessellate it in. */\nexport interface ResolvedStrokeCommand {\n cmd: StrokedPathCommand;\n /** Where the ribbon and each head are built; every length in `cmd` is\n * measured in the space of the part it belongs to. */\n spaces: StrokeSpaces;\n}\n\nconst WORLD: StrokeSpaces = {};\n\n/**\n * `cmd` with its `{ px }` lengths — the stroke width, any marker size, and on a\n * `{ px }` stroke its dashes — resolved against the accumulated transform's\n * quantized scale, so everything downstream (the ribbon cache key, the insets,\n * the heads) sees plain numbers.\n *\n * Under a transform that stretches one direction more than another, each\n * screen-sized part is also built in the transform's stretch, where lengths\n * measure as they do on screen, so it is exact across, down and on every\n * diagonal rather than right only on average. World-sized parts stay in world.\n */\nexport function resolveStrokeLengths(transform: GlMat3, cmd: StrokedPathCommand): ResolvedStrokeCommand {\n const stroke = cmd.stroke;\n const { markerStart, markerMid, markerEnd } = stroke;\n if (typeof stroke.width !== 'object' && !isPxMarker(markerStart)\n && !isPxMarker(markerMid) && !isPxMarker(markerEnd)) {\n return { cmd, spaces: WORLD };\n }\n const resolved: CommandStroke & { paint: CommandPaint } = { ...stroke };\n const { scale, metric } = strokeSpaceOf(transform[0], transform[1], transform[3], transform[4]);\n const screen = (pxPerUnit: number): ScreenSpace | undefined =>\n metric === null ? undefined : { metric, pxPerUnit };\n let ribbon: ScreenSpace | undefined;\n if (typeof stroke.width === 'object') {\n const pxPerUnit = quantizeStrokeScale(stroke.width.px, scale);\n resolved.width = resolveStrokeWidth(stroke.width, pxPerUnit);\n if (stroke.dash && pxPerUnit > 0) resolved.dash = stroke.dash.map((d) => d / pxPerUnit);\n ribbon = screen(pxPerUnit);\n }\n const head = (ref: MarkerRef | undefined): ScreenSpace | undefined => {\n if (ref === undefined || typeof ref === 'string' || ref.size === undefined) return ribbon;\n if (typeof ref.size === 'number') return undefined;\n return screen(quantizeStrokeScale(ref.size.px, scale));\n };\n const spaces = { ribbon, start: head(markerStart), mid: head(markerMid), end: head(markerEnd) };\n if (isPxMarker(markerStart)) resolved.markerStart = resolvedMarker(markerStart, scale);\n if (isPxMarker(markerMid)) resolved.markerMid = resolvedMarker(markerMid, scale);\n if (isPxMarker(markerEnd)) resolved.markerEnd = resolvedMarker(markerEnd, scale);\n return { cmd: { ...cmd, stroke: resolved }, spaces };\n}\n\ntype PxMarker = Exclude<MarkerRef, string> & { size: { px: number } };\n\nfunction isPxMarker(ref: MarkerRef | undefined): ref is PxMarker {\n return typeof ref === 'object' && typeof ref.size === 'object';\n}\n\nfunction resolvedMarker(ref: PxMarker, scale: number): MarkerRef {\n return { ...ref, size: resolveMarkerSize(ref, 0, quantizeStrokeScale(ref.size.px, scale)) };\n}\n","import { BATCH_TEXTURE_SLOTS, RAMP_SLOT } from '../shaders/batchFill';\nimport { type BatchMatrix, matrixIndex } from './batchMatrices';\nimport { runClipDepth } from './clip';\nimport type { DrawContext } from './drawContext';\n\n/**\n * What a staged run draws under, and what it samples.\n *\n * A run outlives the group it started in, so the state live when the flush\n * happens is not the state its vertices belong to — the flush draws with these\n * values instead. Transform is absent because it rides the vertices.\n */\nexport interface StagedBatchState {\n clipDepth: number;\n /**\n * The color matrices this run draws under, in the order they joined; a\n * vertex carries the index of its own. A solid or a glyph is mapped before\n * it is staged and names an identity entry, so only a texel under a matrix\n * no vertex tint expresses adds one.\n */\n matrices: BatchMatrix[];\n /**\n * The textures this run samples, in the order they joined. A quad's vertices\n * carry `index + 1`, because slot 0 is the white texel every solid samples.\n * The ramp atlas is not among them: see `ramps`.\n *\n * Two kinds, because two caches own them: an image quad names an\n * `ImageBitmap` that `GLImageCache` keys by identity, a glyph names the\n * string id of a font atlas in `GLTextureCache`. They share the slot list so\n * a caption and the thumbnail above it share a draw.\n *\n * A bitmap's `sampling` is per entry and set per flush rather than at upload:\n * MAG_FILTER is state on the texture object, so the same bitmap drawn at both\n * filters in one frame needs two flushes, not two slots. An atlas carries no\n * sampling because `GLTextureCache` owns its filtering — and must keep\n * owning it: filtering a distance field destroys it, so a font atlas is\n * never mipmapped and never joins a shared image atlas.\n */\n textures: BatchTexture[];\n /**\n * Whether the run samples the ramp atlas, which always sits at `RAMP_SLOT`\n * rather than the next free slot. It still counts against the run's\n * textures, so the run holds as many as before; the fixed slot is what lets\n * the radial and conic arm of the batch shader fetch it directly.\n */\n ramps: boolean;\n}\n\n/** One entry in a run's slot list. */\ntype BatchTexture =\n | { kind: 'bitmap'; image: ImageBitmap; sampling: 'linear' | 'nearest' }\n | { kind: 'atlas'; id: string; fieldScale: readonly [number, number] };\n\n/**\n * The slot `image` would sample from in this run, or -1 if it cannot join.\n *\n * A bitmap already in the run reuses its slot — but only at the filter it went\n * in under, since MAG_FILTER belongs to the texture object and one draw cannot\n * have it both ways. Otherwise it takes the next free slot, and a run with none\n * left is a run this quad has to break.\n */\nexport function slotForBitmap(\n staged: StagedBatchState, image: ImageBitmap, sampling: 'linear' | 'nearest',\n): number {\n for (let i = 0; i < staged.textures.length; i++) {\n const entry = staged.textures[i];\n if (entry.kind !== 'bitmap' || entry.image !== image) continue;\n return entry.sampling === sampling ? i + 1 : -1;\n }\n return nextFreeSlot(staged);\n}\n\n/** The same for the ramp atlas, of which there is one — so every gradient in a\n * run shares the slot, however many distinct ramps they are. */\nexport function slotForRamps(staged: StagedBatchState): number {\n if (staged.ramps) return RAMP_SLOT;\n // Other textures fill from slot 1 up, so `RAMP_SLOT` is taken only once\n // every slot is.\n return nextFreeSlot(staged) < 0 ? -1 : RAMP_SLOT;\n}\n\n/** The same for a font atlas, which has no filter to disagree about. */\nexport function slotForAtlas(staged: StagedBatchState, id: string): number {\n for (let i = 0; i < staged.textures.length; i++) {\n const entry = staged.textures[i];\n if (entry.kind === 'atlas' && entry.id === id) return i + 1;\n }\n return nextFreeSlot(staged);\n}\n\n/** The slot a texture new to this run would take, or -1 if it is full. */\nfunction nextFreeSlot(staged: StagedBatchState): number {\n const taken = staged.textures.length + (staged.ramps ? 1 : 0);\n return taken + 1 < BATCH_TEXTURE_SLOTS ? staged.textures.length + 1 : -1;\n}\n\n/**\n * Whether the open run can take an item under this matrix and alpha: it was\n * staged at the live clip depth, and it holds the pair or has room for it.\n */\nexport function runTakes(\n ctx: DrawContext, staged: StagedBatchState, colorMatrix: Float32Array, alpha: number,\n): boolean {\n return staged.clipDepth === runClipDepth(ctx)\n && matrixIndex(staged.matrices, colorMatrix, alpha) >= 0;\n}\n\n/** The staged state, opening a run if none is. */\nexport function openRun(ctx: DrawContext): StagedBatchState {\n ctx.batchState ??= { clipDepth: runClipDepth(ctx), matrices: [], textures: [], ramps: false };\n return ctx.batchState;\n}\n\n/** The index of this matrix and alpha in a run that `runTakes` them, added if\n * they are new to it. */\nexport function takeMatrix(\n staged: StagedBatchState, colorMatrix: Float32Array, alpha: number,\n): number {\n const index = matrixIndex(staged.matrices, colorMatrix, alpha);\n if (index === staged.matrices.length) staged.matrices.push({ colorMatrix, alpha });\n return index;\n}\n","import type { ColorSpace, Paint, PaintUnits, GradStop } from '@weasel-js/paint';\nimport { mat3, type GlMat3 } from '@weasel-js/geom';\nimport type { GradientUV } from '../drawBatch';\nimport { PAINT_MODE_PLAIN, PAINT_MODE_RADIAL, PAINT_MODE_CONIC } from '../shaders/batchFill';\nimport type { DrawContext } from './drawContext';\n\n/** A paint a run can express, resolved from a `Paint` by `batchPaint`. */\nexport type BatchPaint =\n | { kind: 'solid'; color: string; opacity?: number }\n | {\n kind: 'ramp'; stops: GradStop[]; space: ColorSpace; opacity?: number;\n /** `PAINT_MODE_PLAIN` for a linear gradient, whose ramp position a vertex\n * carries outright; `PAINT_MODE_RADIAL` / `PAINT_MODE_CONIC` otherwise. */\n mode: number;\n uv: GradientUV;\n };\n\n/**\n * `fill` as something a run can carry, or `undefined` for a paint no run can\n * express — a pattern, a shader, per-vertex colors — and `null` for a gradient\n * whose space has no inverse under this transform, which draws nothing.\n *\n * **All three gradients qualify, and for the same reason,** which is not that\n * their ramp position is affine in position — only a linear gradient's is. It\n * is that the *coordinate* the ramp position is computed from is affine in all\n * three, so a vertex can carry that and the rasterizer's interpolation across a\n * triangle is exact. A linear gradient's coordinate is the ramp position\n * itself, which is why it needs no paint mode; the other two carry a\n * gradient-space point and the shader takes a `length` or an `atan` of it.\n */\nexport function batchPaint(\n ctx: DrawContext, fill: Paint, hasVColors: boolean,\n): BatchPaint | undefined | null {\n if (hasVColors) return undefined;\n const kind = fill.kind ?? 'solid';\n if (kind === 'solid') {\n const solid = fill as { color: string; opacity?: number };\n return { kind: 'solid', color: solid.color, opacity: solid.opacity };\n }\n if (kind !== 'linear-gradient' && kind !== 'radial-gradient' && kind !== 'conic-gradient') {\n return undefined;\n }\n const grad = fill as Extract<Paint, { kind: 'linear-gradient' | 'radial-gradient' | 'conic-gradient' }>;\n const g = gradientMap(ctx, grad.units);\n if (!g) return null;\n if (grad.kind === 'linear-gradient') return ramp(grad, PAINT_MODE_PLAIN, linearRampUV(g, grad));\n if (grad.kind === 'radial-gradient') return ramp(grad, PAINT_MODE_RADIAL, radialRampUV(g, grad));\n return ramp(grad, PAINT_MODE_CONIC, conicRampUV(g, grad));\n}\n\nfunction ramp(\n fill: { stops: GradStop[]; interpolate?: ColorSpace; opacity?: number },\n mode: number, uv: GradientUV,\n): BatchPaint {\n return {\n kind: 'ramp', stops: fill.stops, space: fill.interpolate ?? 'rgb',\n opacity: fill.opacity, mode, uv,\n };\n}\n\n/**\n * Geometry-space → gradient-space, as the one matrix a vertex is measured\n * through.\n *\n * `gradientSpaceInverse` maps a screen position back into the gradient's space\n * and the batch's vertices arrive before the model transform, so the two\n * compose. This is the composition `gradFill`'s vertex shader does in two\n * steps, and the pair have to agree: a radial gradient goes through that one\n * and a linear one through this.\n */\nfunction gradientMap(ctx: DrawContext, units: PaintUnits | undefined): GlMat3 | null {\n const inverse = gradientSpaceInverse(ctx, units);\n return inverse && mat3.multiply(inverse, ctx.state.transform);\n}\n\n/**\n * The gradient shader's `dot(p - from, dir) / len` folded into `u`, with `v`\n * left for the atlas row `stageRamps` fills in.\n */\nfunction linearRampUV(\n g: GlMat3, fill: Extract<Paint, { kind: 'linear-gradient' }>,\n): GradientUV {\n const dx = fill.to.x - fill.from.x;\n const dy = fill.to.y - fill.from.y;\n const len = Math.hypot(dx, dy) || 1;\n // dir is (dx, dy)/len and the divisor is len, so the pair is 1/len².\n const k = 1 / (len * len);\n return {\n ux: (g[0] * dx + g[1] * dy) * k,\n uy: (g[3] * dx + g[4] * dy) * k,\n u0: ((g[6] - fill.from.x) * dx + (g[7] - fill.from.y) * dy) * k,\n vx: 0, vy: 0, v0: 0,\n };\n}\n\n/** The gradient-space point scaled so its distance from the center *is* the\n * ramp position, which is what makes the shader's half a `length`. */\nfunction radialRampUV(\n g: GlMat3, fill: Extract<Paint, { kind: 'radial-gradient' }>,\n): GradientUV {\n // The floor is `gradFill`'s own `max(u_gradRadius, 0.0001)`.\n const k = 1 / Math.max(fill.radius, 1e-4);\n return {\n ux: g[0] * k, uy: g[3] * k, u0: (g[6] - fill.center.x) * k,\n vx: g[1] * k, vy: g[4] * k, v0: (g[7] - fill.center.y) * k,\n };\n}\n\n/**\n * The gradient-space point about the center, turned by `-angle` so the shader's\n * half is an `atan` of it and nothing else.\n *\n * `gradFill` subtracts the angle from the arctangent instead. The two agree\n * because rotating a point turns its arctangent by the same amount, and the\n * `fract` that follows takes care of the wrap either way.\n */\nfunction conicRampUV(\n g: GlMat3, fill: Extract<Paint, { kind: 'conic-gradient' }>,\n): GradientUV {\n const cos = Math.cos(fill.angle);\n const sin = Math.sin(fill.angle);\n const dx0 = g[6] - fill.center.x;\n const dy0 = g[7] - fill.center.y;\n return {\n ux: cos * g[0] + sin * g[1],\n uy: cos * g[3] + sin * g[4],\n u0: cos * dx0 + sin * dy0,\n vx: cos * g[1] - sin * g[0],\n vy: cos * g[4] - sin * g[3],\n v0: cos * dy0 - sin * dx0,\n };\n}\n\n/**\n * What a gradient's vertices carry once its row is known.\n *\n * A linear gradient's `a_uv` is (ramp position, row) and its `a_post` is the\n * plain 1, because that is what the plain paint mode already samples. A radial\n * or conic one needs both `a_uv` channels for its coordinate, so its row goes\n * in `a_post` — which no gradient uses for alpha, its opacity riding the vertex\n * color instead.\n */\nexport function rampVertices(\n paint: Extract<BatchPaint, { kind: 'ramp' }>, rowV: number,\n): { uv: GradientUV; post: number } {\n return paint.mode === PAINT_MODE_PLAIN\n ? { uv: { ...paint.uv, v0: rowV }, post: 1 }\n : { uv: paint.uv, post: rowV };\n}\n\n/**\n * Screen→gradient-space matrix for `u_worldInv`, which the vertex shader\n * applies to each fragment's screen position to recover the coordinates the\n * gradient's geometry is expressed in.\n *\n * `'world'` silently degrades to screen space when no view matrix reached\n * the renderer — `render(commands)` without a view is a supported call, and\n * a missing view is not worth a thrown frame. `null` when the space has no\n * inverse; a paint measured in it draws nothing.\n */\nexport function gradientSpaceInverse(ctx: DrawContext, units: PaintUnits | undefined): GlMat3 | null {\n if (units === 'local') return mat3.invert(ctx.state.transform);\n if (units === 'world' && ctx.viewMatrix) return mat3.invert(ctx.viewMatrix);\n return mat3.identity();\n}\n\n/** The paint space `units` names → device pixels: the forward transform\n * `gradientSpaceInverse` undoes, scaled by the target's pixel ratio. */\nexport function spaceToDevice(ctx: DrawContext, units: PaintUnits | undefined): GlMat3 | null {\n const inverse = gradientSpaceInverse(ctx, units);\n const toScreen = inverse && mat3.invert(inverse);\n if (!toScreen) return null;\n const ratio = ctx.deviceWidth && ctx.widthCss > 0 ? ctx.deviceWidth / ctx.widthCss : 1;\n return mat3.multiply(mat3.scaled(mat3.identity(), ratio, ratio), toScreen);\n}\n","import type { ColorSpace, GradStop } from '@weasel-js/paint';\nimport { IDENTITY_COLOR_MATRIX } from '../state/GroupState';\nimport { foldColor, foldsColor, textureTint, type Tint } from './foldColor';\nimport type { Mesh } from '@weasel-js/geom/tessellate';\nimport { resolveColor } from '@weasel-js/paint';\nimport { PAINT_MODE_PLAIN, WHITE_SLOT, packSlot, withMatrix } from '../shaders/batchFill';\nimport type { DrawContext } from './drawContext';\nimport { retryUncut, flushForOwnDraw } from './clip';\nimport { flushBatch } from './flushBatch';\nimport { openRun, runTakes, slotForAtlas, slotForBitmap, slotForRamps, takeMatrix } from './batchRun';\nimport { type BatchPaint, rampVertices } from './gradient';\n\n/**\n * Vertices above which a mesh keeps its own draw, by whether a run is open.\n *\n * Batching trades a draw call for copying and re-uploading the mesh every\n * frame, where a mesh already in the persistent cache costs nothing per frame\n * beyond the draw. Drawn alone with a run open, a mesh also closes that run and\n * switches program twice, so it breaks even far later there. Both values sit\n * below what `tests/perf/mesh-batch.spec.ts` measured: being wrong on the\n * open-run side costs ten times more.\n */\nconst MAX_BATCHED_MESH_VERTICES = 96;\n\nconst MAX_BATCHED_MESH_VERTICES_IN_RUN = 1024;\n\n/** The caps {@link canBatchMesh} reads. Mutable only so `mesh-batch.spec.ts`\n * can time both sides of them in one page; the barrel does not export it. */\nexport const meshBatching = {\n maxVertices: MAX_BATCHED_MESH_VERTICES,\n maxVerticesInRun: MAX_BATCHED_MESH_VERTICES_IN_RUN,\n};\n\n/** Whether a mesh can join a run. Stencil fills need their own two-pass dance,\n * and a mesh past the cap is cheaper as its own draw. */\nfunction canBatchMesh(ctx: DrawContext, mesh: Mesh): boolean {\n if (mesh.requiresStencil) return false;\n const cap = ctx.drawBatch.length > 0 ? meshBatching.maxVerticesInRun : meshBatching.maxVertices;\n return (mesh.vertices.length >> 1) <= cap;\n}\n\n/**\n * Open or continue a run for `vertices` more of solid geometry, flushing first\n * if the run would overflow, was staged at another clip depth, or has no room\n * for the matrix. Returns what the vertices carry in `a_texSlot`.\n *\n * Fill opacity folds into the vertex alpha, and so do the group's alpha and\n * color matrix (`foldColor`), which is why the matrix a solid asks its run for\n * is identity: a group's matrix cannot break a run of them.\n */\nexport function stageSolid(ctx: DrawContext, vertices: number): number {\n const folds = foldsColor(ctx);\n const colorMatrix = folds ? IDENTITY_COLOR_MATRIX : ctx.state.colorMatrix;\n const alpha = folds ? 1 : ctx.state.alpha;\n const open = ctx.batchState;\n if (open !== undefined && !runTakes(ctx, open, colorMatrix, alpha)) flushBatch(ctx);\n if (ctx.drawBatch.wouldOverflow(vertices)) flushBatch(ctx);\n const matrix = takeMatrix(openRun(ctx), colorMatrix, alpha);\n return packSlot(withMatrix(WHITE_SLOT, matrix), PAINT_MODE_PLAIN);\n}\n\n/**\n * What a textured vertex is staged under: the matrix and alpha its run draws\n * it by, the tint its vertices carry, and, once a stage call has filled it in,\n * the slot they name.\n */\ninterface Textured {\n colorMatrix: Float32Array;\n alpha: number;\n /** The fourth channel carries group alpha wherever the entry's does not. */\n tint: Tint;\n /** Texture slot and matrix index together; `packSlot` adds the paint mode. */\n slot: number;\n}\n\nconst UNTINTED: Tint = [1, 1, 1, 1];\n\n/**\n * A texel's color is not known until it is sampled, so the group's matrix\n * reaches it one of two ways. One that only scales channels down becomes a\n * tint on the vertices, in a run entry at identity. Any other stays a matrix\n * for the shader, as an entry of its own.\n *\n * `alphaInEntry` says where group alpha goes in that second case: into the\n * entry for a gradient, whose `a_post` may be its atlas row, and into the\n * tint's fourth channel for a quad, which multiplies its `a_post` by it.\n */\nfunction texturedUnder(ctx: DrawContext, alphaInEntry: boolean): Textured {\n const tint = textureTint(ctx);\n if (tint !== null) return { colorMatrix: IDENTITY_COLOR_MATRIX, alpha: 1, tint, slot: 0 };\n const colorMatrix = ctx.state.colorMatrix;\n const alpha = ctx.state.alpha;\n return alphaInEntry\n ? { colorMatrix, alpha, tint: UNTINTED, slot: 0 }\n : { colorMatrix, alpha: 1, tint: [1, 1, 1, alpha], slot: 0 };\n}\n\n/**\n * Open or continue a run for one more image quad, flushing first if the run\n * would overflow or cannot give this bitmap a slot. A run adopts a bitmap it\n * has not seen rather than breaking, which is what lets a ground rect and the\n * atlas quad over it share a draw. Returns the slot the quad's vertices carry\n * and their tint.\n */\nexport function stageImage(\n ctx: DrawContext, image: ImageBitmap, sampling: 'linear' | 'nearest',\n): { slot: number; tint: Tint } {\n const under = texturedUnder(ctx, false);\n const open = ctx.batchState;\n if (open !== undefined\n && (!runTakes(ctx, open, under.colorMatrix, under.alpha)\n || slotForBitmap(open, image, sampling) < 0)) {\n flushBatch(ctx);\n }\n if (ctx.drawBatch.wouldOverflow(4)) flushBatch(ctx);\n const staged = openRun(ctx);\n let slot = slotForBitmap(staged, image, sampling);\n if (slot > staged.textures.length) {\n staged.textures.push({ kind: 'bitmap', image, sampling });\n slot = staged.textures.length;\n }\n under.slot = withMatrix(slot, takeMatrix(staged, under.colorMatrix, under.alpha));\n return under;\n}\n\n/**\n * Open or continue a run for a glyph off the font atlas `atlasId`, flushing\n * first if the run would overflow or has no slot left for it. Every glyph a\n * face contributes to a frame shares one texture, so a paragraph is one run,\n * and a second face costs one more slot rather than a flush per word. Returns\n * the slot the glyph's vertices carry; its color is mapped as a solid's is.\n */\nexport function stageGlyphs(\n ctx: DrawContext, atlasId: string, fieldScale: readonly [number, number],\n): number {\n const folds = foldsColor(ctx);\n const colorMatrix = folds ? IDENTITY_COLOR_MATRIX : ctx.state.colorMatrix;\n const alpha = folds ? 1 : ctx.state.alpha;\n const open = ctx.batchState;\n if (open !== undefined\n && (!runTakes(ctx, open, colorMatrix, alpha) || slotForAtlas(open, atlasId) < 0)) {\n flushBatch(ctx);\n }\n if (ctx.drawBatch.wouldOverflow(4)) flushBatch(ctx);\n const staged = openRun(ctx);\n let slot = slotForAtlas(staged, atlasId);\n if (slot > staged.textures.length) {\n staged.textures.push({ kind: 'atlas', id: atlasId, fieldScale });\n slot = staged.textures.length;\n }\n return withMatrix(slot, takeMatrix(staged, colorMatrix, alpha));\n}\n\n/**\n * Open or continue a run for geometry filled from the ramp atlas, flushing\n * first if the run would overflow, has no slot left, or if baking `stops` would\n * move the rows already staged.\n *\n * **That last one is the trap.** A staged vertex names its ramp by where the\n * row sits, so growing the atlas — which changes every row's `v` — or recycling\n * a row repaints geometry already staged with somebody else's gradient. Both\n * are irreversible once done, so the question is asked before the bake, not\n * after.\n */\nfunction stageRamps(\n ctx: DrawContext, stops: GradStop[], space: ColorSpace, vertices: number,\n): { slot: number; tint: Tint; rowV: number } {\n if (ctx.gradRamps.wouldReshape(stops, space)) flushBatch(ctx);\n const under = texturedUnder(ctx, true);\n const open = ctx.batchState;\n if (open !== undefined\n && (!runTakes(ctx, open, under.colorMatrix, under.alpha) || slotForRamps(open) < 0)) {\n flushBatch(ctx);\n }\n if (ctx.drawBatch.wouldOverflow(vertices)) flushBatch(ctx);\n const staged = openRun(ctx);\n const slot = slotForRamps(staged);\n staged.ramps = true;\n return {\n slot: withMatrix(slot, takeMatrix(staged, under.colorMatrix, under.alpha)),\n tint: under.tint,\n rowV: ctx.gradRamps.rowV(ctx.gradRamps.upload(stops, space)),\n };\n}\n\n/** Straight-alpha rgba for a solid paint under the live group state. */\nfunction stagedColor(\n ctx: DrawContext, paint: { color: string; opacity?: number },\n): [number, number, number, number] {\n const [r, g, b, a] = resolveColor(paint.color);\n return foldColor(ctx, r, g, b, a * (paint.opacity ?? 1));\n}\n\nexport function pushRect(\n ctx: DrawContext,\n rect: { x: number; y: number; width: number; height: number },\n fill: { color: string; opacity?: number },\n): void {\n const slot = stageSolid(ctx, 4);\n const [r, g, b, a] = stagedColor(ctx, fill);\n if (!ctx.drawBatch.pushRect(\n rect.x, rect.y, rect.width, rect.height, ctx.state.transform, r, g, b, a, slot,\n )) retryUncut(ctx, rect, fill, pushRect);\n}\n\nfunction pushMesh(\n ctx: DrawContext,\n mesh: Mesh,\n paint: { color: string; opacity?: number },\n): void {\n const slot = stageSolid(ctx, mesh.vertices.length >> 1);\n const [r, g, b, a] = stagedColor(ctx, paint);\n if (!ctx.drawBatch.pushMesh(mesh, ctx.state.transform, r, g, b, a, slot)) {\n retryUncut(ctx, mesh, paint, pushMesh);\n }\n}\n\nexport function pushRampRect(\n ctx: DrawContext,\n rect: { x: number; y: number; width: number; height: number },\n paint: Extract<BatchPaint, { kind: 'ramp' }>,\n): void {\n const { slot, tint, rowV } = stageRamps(ctx, paint.stops, paint.space, 4);\n const { uv, post } = rampVertices(paint, rowV);\n // White vertices but for the tint, so the ramp texel passes through as its\n // own color, and the alpha channel carries what `u_opacity` used to.\n if (!ctx.drawBatch.pushGradientRect(\n rect.x, rect.y, rect.width, rect.height, ctx.state.transform,\n uv, post, slot, paint.mode, tint[0], tint[1], tint[2], (paint.opacity ?? 1) * tint[3],\n )) retryUncut(ctx, rect, paint, pushRampRect);\n}\n\nfunction pushRampMesh(\n ctx: DrawContext, mesh: Mesh, paint: Extract<BatchPaint, { kind: 'ramp' }>,\n): void {\n const { slot, tint, rowV } = stageRamps(ctx, paint.stops, paint.space, mesh.vertices.length >> 1);\n const { uv, post } = rampVertices(paint, rowV);\n if (!ctx.drawBatch.pushGradientMesh(\n mesh, ctx.state.transform,\n uv, post, slot, paint.mode, tint[0], tint[1], tint[2], (paint.opacity ?? 1) * tint[3],\n )) retryUncut(ctx, mesh, paint, pushRampMesh);\n}\n\n/**\n * Stage `mesh` into the run, or drain the run so the caller can draw it itself.\n *\n * `true` means the mesh is in the batch and the caller is done. `false` comes\n * back only *after* a flush, so an emitter cannot earn permission to draw for\n * itself without also draining the batch. `paint` is `undefined` when it is one\n * no run can express — see `batchPaint`.\n */\nexport function tryStageFill(\n ctx: DrawContext,\n mesh: Mesh,\n paint: BatchPaint | undefined,\n): boolean {\n if (paint !== undefined && canBatchMesh(ctx, mesh)) {\n if (paint.kind === 'ramp') pushRampMesh(ctx, mesh, paint);\n else pushMesh(ctx, mesh, paint);\n return true;\n }\n flushForOwnDraw(ctx);\n return false;\n}\n\n/** A color page has no distance field, so nothing reads its slot's scale. */\nconst NO_FIELD = [0, 0] as const;\n\n/**\n * Open or continue a run for a quad off the page of color glyphs `atlasId`.\n * The page takes a slot as a font atlas does, and the quad is staged as an\n * image's is: its texel is a color, which the group's matrix reaches as a tint\n * or in the shader.\n */\nexport function stageColorGlyphs(\n ctx: DrawContext, atlasId: string,\n): { slot: number; tint: Tint } {\n const under = texturedUnder(ctx, false);\n const open = ctx.batchState;\n if (open !== undefined\n && (!runTakes(ctx, open, under.colorMatrix, under.alpha)\n || slotForAtlas(open, atlasId) < 0)) {\n flushBatch(ctx);\n }\n if (ctx.drawBatch.wouldOverflow(4)) flushBatch(ctx);\n const staged = openRun(ctx);\n let slot = slotForAtlas(staged, atlasId);\n if (slot > staged.textures.length) {\n staged.textures.push({ kind: 'atlas', id: atlasId, fieldScale: NO_FIELD });\n slot = staged.textures.length;\n }\n under.slot = withMatrix(slot, takeMatrix(staged, under.colorMatrix, under.alpha));\n return under;\n}\n","import type { PatternTransform } from '@weasel-js/paint';\nimport { mat3, type GlMat3 } from '@weasel-js/geom';\n\n/**\n * Screen → tile-space matrix for a pattern fill: `spaceInverse` takes a screen\n * position into the paint's `units` space, then this undoes the tile's\n * placement there, `origin + transform · tile`. Tile space is in paint units,\n * so the shader divides by the tile's size to get a texture coordinate.\n *\n * `null` when `transform` is singular — a tile collapsed to a line has no\n * point to sample for most of the plane, and a paint with no inverse draws\n * nothing, as gradients do.\n */\nexport function patternTileSpace(\n spaceInverse: GlMat3,\n origin: { x: number; y: number },\n transform: PatternTransform | undefined,\n): GlMat3 | null {\n const [a, b, c, d] = transform ?? [1, 0, 0, 1];\n const placement = mat3.fromAffine([a, b, c, d, origin.x, origin.y]);\n const unplace = mat3.invert(placement);\n return unplace && mat3.multiply(unplace, spaceInverse);\n}\n","import type { Paint, TexturePaint } from '@weasel-js/paint';\nimport type { PaintBindContext, PaintResources } from '../paintKinds';\nimport { createPaintResources } from '../paintResources';\nimport { getTexture } from '../textures/registerTexture';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport { mat3, type GlMat3 } from '@weasel-js/geom';\nimport { patternTileSpace } from '../math/patternSpace';\nimport type { DrawContext } from './drawContext';\nimport { setAlphaUniform, setColorMatrixUniforms, setProjAndModel } from './uniforms';\nimport { gradientSpaceInverse, spaceToDevice } from './gradient';\n\n/** The narrow renderer surface a registered paint kind binds against, built\n * once per frame context. `DrawContext` is not consumer surface. */\nexport function paintBindContext(ctx: DrawContext): PaintBindContext {\n const cached = BIND_CONTEXTS.get(ctx);\n if (cached) return cached;\n const made: PaintBindContext = {\n gl: ctx.gl,\n get alpha() { return ctx.state.alpha; },\n program: (id) => ctx.ensureProgram?.(id) ?? ctx.programRegistry.get(id) ?? null,\n setProjAndModel: (prog) => setProjAndModel(ctx, prog),\n spaceInverse: (units) => gradientSpaceInverse(ctx, units),\n spaceToDevice: (units) => spaceToDevice(ctx, units),\n get maxTextureSize() { return ctx.imageCache.maxTextureSide; },\n resources: ctx.paintResources ?? unownedPaintResources(ctx.gl),\n bindRamp: (stops, unit, space) => {\n const row = ctx.gradRamps.upload(stops, space);\n ctx.gradRamps.bind(unit);\n return ctx.gradRamps.rowV(row);\n },\n };\n BIND_CONTEXTS.set(ctx, made);\n return made;\n}\n\nconst BIND_CONTEXTS = new WeakMap<DrawContext, PaintBindContext>();\n\nconst UNOWNED_RESOURCES = new WeakMap<WebGL2RenderingContext, PaintResources>();\n\nfunction unownedPaintResources(gl: WebGL2RenderingContext): PaintResources {\n let made = UNOWNED_RESOURCES.get(gl);\n if (!made) {\n made = createPaintResources();\n UNOWNED_RESOURCES.set(gl, made);\n }\n return made;\n}\n\n/** Bind `prog` — the path program or the glyph one, which share every paint\n * uniform — to draw `fill` under `model`. */\nexport function bindPattern(\n ctx: DrawContext,\n prog: ShaderProgram,\n fill: TexturePaint,\n model: GlMat3,\n): ShaderProgram | null {\n const tex = fill.texture;\n const entry = getTexture(tex.id);\n if (!entry) {\n const isDev = typeof process !== 'undefined' ? process.env.NODE_ENV !== 'production' : true;\n if (isDev) console.warn(`weasel: pattern TextureHandle \"${tex.id}\" not registered`);\n return null;\n }\n const inverse = gradientSpaceInverse(ctx, fill.units);\n if (!inverse) return null;\n const tileSpace = patternTileSpace(inverse, fill.origin ?? { x: 0, y: 0 }, fill.transform);\n if (!tileSpace) return null;\n ctx.textureCache.uploadRegistered(tex.id, entry.source, 'repeat');\n\n // A path fill mesh carries a_position only, so the tile coordinate is\n // recovered per fragment from the screen position — the same route\n // gradients take through `u_worldInv`, and the reason this can't reuse\n // the image-fill shader, whose a_uv such a mesh leaves unbound.\n const gl = ctx.gl;\n gl.useProgram(prog.handle);\n setProjAndModel(ctx, prog, model);\n setColorMatrixUniforms(ctx, prog);\n const [tw, th] = textureSize(entry.source);\n // The tile repeats, so whole tiles come out of the translation here, in\n // doubles: far from the origin a float32 has no bits left for the texel.\n tileSpace[6] -= Math.floor(tileSpace[6] / tw) * tw;\n tileSpace[7] -= Math.floor(tileSpace[7] / th) * th;\n gl.uniformMatrix3fv(prog.uniform('u_worldInv')!, false, mat3.toUniform(tileSpace));\n gl.uniform2f(prog.uniform('u_tileSize')!, tw, th);\n ctx.textureCache.bind(tex.id, 0);\n gl.uniform1i(prog.uniform('u_sampler')!, 0);\n gl.uniform1f(prog.uniform('u_opacity')!, fill.opacity ?? 1);\n setAlphaUniform(ctx, prog, ctx.state.alpha);\n return prog;\n}\n\n/** Tile extent in paint-space units — one tile spans this many units of\n * whatever space `units` names. */\nfunction textureSize(source: HTMLImageElement | ImageBitmap): [number, number] {\n const w = 'naturalWidth' in source ? source.naturalWidth : source.width;\n const h = 'naturalHeight' in source ? source.naturalHeight : source.height;\n return [w || 1, h || 1];\n}\n\n/** The gradient counterpart of `bindPattern`. */\nexport function bindGradient(\n ctx: DrawContext,\n prog: ShaderProgram,\n fill: Extract<Paint, { kind: 'linear-gradient' | 'radial-gradient' | 'conic-gradient' }>,\n model: GlMat3,\n): ShaderProgram | null {\n const inverse = gradientSpaceInverse(ctx, fill.units);\n if (!inverse) return null;\n // Measured from the gradient's own start, subtracted here in doubles: far\n // from the origin a float32 paint-space point is coarser than a pixel, and\n // the shader's subtraction would be of two such numbers.\n const about = fill.kind === 'linear-gradient' ? fill.from : fill.center;\n const aboutStart = mat3.multiply(mat3.translated(mat3.identity(), -about.x, -about.y), inverse);\n const gl = ctx.gl;\n const row = ctx.gradRamps.upload(fill.stops, fill.interpolate ?? 'rgb');\n\n gl.useProgram(prog.handle);\n setProjAndModel(ctx, prog, model);\n\n gl.uniformMatrix3fv(prog.uniform('u_worldInv')!, false, mat3.toUniform(aboutStart));\n setColorMatrixUniforms(ctx, prog);\n\n ctx.gradRamps.bind(0);\n gl.uniform1i(prog.uniform('u_ramp')!, 0);\n gl.uniform1f(prog.uniform('u_rampV')!, ctx.gradRamps.rowV(row));\n setAlphaUniform(ctx, prog, ctx.state.alpha);\n gl.uniform1f(prog.uniform('u_opacity')!, fill.opacity ?? 1);\n\n if (fill.kind === 'linear-gradient') {\n gl.uniform1i(prog.uniform('u_gradKind')!, 0);\n const dx = fill.to.x - fill.from.x;\n const dy = fill.to.y - fill.from.y;\n const len = Math.hypot(dx, dy) || 1;\n gl.uniform2f(prog.uniform('u_gradDir')!, dx / len, dy / len);\n gl.uniform1f(prog.uniform('u_gradLen')!, len);\n gl.uniform1f(prog.uniform('u_gradRadius')!, 0);\n gl.uniform1f(prog.uniform('u_gradAngle')!, 0);\n } else if (fill.kind === 'radial-gradient') {\n gl.uniform1i(prog.uniform('u_gradKind')!, 1);\n gl.uniform2f(prog.uniform('u_gradDir')!, 0, 0);\n gl.uniform1f(prog.uniform('u_gradLen')!, 0);\n gl.uniform1f(prog.uniform('u_gradRadius')!, fill.radius);\n gl.uniform1f(prog.uniform('u_gradAngle')!, 0);\n } else {\n // conic\n gl.uniform1i(prog.uniform('u_gradKind')!, 2);\n gl.uniform2f(prog.uniform('u_gradDir')!, 0, 0);\n gl.uniform1f(prog.uniform('u_gradLen')!, 0);\n gl.uniform1f(prog.uniform('u_gradRadius')!, 0);\n gl.uniform1f(prog.uniform('u_gradAngle')!, fill.angle);\n }\n\n return prog;\n}\n","import type { CommandPaint, Stroke, Paint, TexturePaint } from '@weasel-js/paint';\nimport { getPaintDrawKind } from '../paintKinds';\nimport type { PathDrawCommand } from '../DrawCommand';\nimport type { GLMeshHandle } from '../cache/GLMeshCache';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport { resolveStrokeWidth } from '@weasel-js/stroke';\nimport { strokeMesh } from '../cache/strokeMeshCache';\nimport { resolveStrokeLengths, type StrokedPathCommand } from '../strokeLengths';\nimport { metricKeepsRects, type StrokeSpaces } from '@weasel-js/stroke';\nimport { cachedMarkerCommands } from '../cache/markerCommandCache';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { fillMesh, meshHandle, fillMeshHandle } from './mesh';\nimport { setColorMatrixUniforms, setProjAndModel, setSolidPaintUniforms } from './uniforms';\nimport { applyClipTest, ancestorMask, beginParityMask, endParityMask } from './stencil';\nimport { flushForOwnDraw } from './clip';\nimport { pushRect, pushRampRect, tryStageFill } from './batch';\nimport { batchPaint } from './gradient';\nimport { paintBindContext, bindPattern, bindGradient } from './paintBind';\n\nexport function drawPath(ctx: DrawContext, cmd: PathDrawCommand): void {\n // A fill or a stroke with no `paint` paints nothing, the way a node's\n // `fill: null` does. Commands arriving from a consumer painter or overlay\n // can carry one.\n if (cmd.fill?.paint) drawPathFill(ctx, cmd, cmd.fill.paint);\n if (cmd.stroke?.paint) drawPathStroke(ctx, cmd as StrokedPathCommand);\n}\n\nfunction drawPathFill(ctx: DrawContext, cmd: PathDrawCommand, fill: CommandPaint): void {\n // Batchable: see `batchPaint`. A rect skips tessellation entirely; anything\n // else stages its mesh. Both also keep animated demos that mint a fresh Path\n // every frame from allocating a GL buffer per frame.\n const isSolid = fill.kind === undefined || fill.kind === 'solid';\n const hasVColors = !!(cmd.vertexColors && cmd.vertexColors.length > 0);\n const solid = fill as { color: string; opacity?: number };\n const paint = batchPaint(ctx, fill, hasVColors);\n if (paint === null) return;\n\n if (paint !== undefined && cmd.path.kind === 'rect') {\n if (paint.kind === 'ramp') pushRampRect(ctx, cmd.path, paint);\n else pushRect(ctx, cmd.path, paint);\n return;\n }\n\n const mesh = fillMesh(ctx, cmd.path);\n if (tryStageFill(ctx, mesh, paint)) return;\n\n const handle = meshHandle(ctx, mesh);\n if (isSolid && hasVColors) {\n drawPathFillVColor(ctx, cmd, solid, handle);\n } else if (handle.requiresStencil) {\n drawPathFillStencil(ctx, fill, handle);\n } else {\n drawPathFillByKind(ctx, fill, handle);\n }\n}\n\ninterface VertexColorBinding { vbo: WebGLBuffer; location: number | undefined }\n\n/** Point the bound mesh VAO's a_vertexColor at a fresh buffer of per-vertex\n * colors. Pair with `detachVertexColors` before the VAO is unbound. */\nfunction attachVertexColors(\n gl: WebGL2RenderingContext, prog: ShaderProgram, perAnchor: number[], handle: GLMeshHandle,\n): VertexColorBinding {\n const vbo = gl.createBuffer();\n if (!vbo) throw new Error('attachVertexColors: createBuffer returned null');\n gl.bindBuffer(gl.ARRAY_BUFFER, vbo);\n gl.bufferData(gl.ARRAY_BUFFER, expandAnchorColors(perAnchor, handle), gl.DYNAMIC_DRAW);\n const location = prog.attribute('a_vertexColor');\n if (location !== undefined) {\n gl.enableVertexAttribArray(location);\n gl.vertexAttribPointer(location, 4, gl.FLOAT, false, 0, 0);\n }\n return { vbo, location };\n}\n\n// Order matters: a buffer deleted after its VAO is unbound stays attached to\n// that VAO and is not freed until the mesh is, and one deleted while its\n// attribute is still enabled leaves the VAO unable to draw.\nfunction detachVertexColors(gl: WebGL2RenderingContext, { vbo, location }: VertexColorBinding): void {\n if (location !== undefined) gl.disableVertexAttribArray(location);\n gl.deleteBuffer(vbo);\n}\n\nfunction expandAnchorColors(perAnchor: number[], handle: GLMeshHandle): Float32Array {\n const aA = handle.anchorA;\n const aB = handle.anchorB;\n const aT = handle.anchorT;\n if (!aA || !aB || !aT) {\n // Legacy fallback: mesh lacks anchor params (e.g. non-path mesh). Treat\n // the caller-provided array as already per-vertex.\n return new Float32Array(perAnchor);\n }\n const n = aA.length;\n const out = new Float32Array(n * 4);\n for (let i = 0; i < n; i++) {\n const a4 = aA[i] * 4;\n const b4 = aB[i] * 4;\n const t = aT[i];\n out[i * 4 + 0] = perAnchor[a4 + 0] + (perAnchor[b4 + 0] - perAnchor[a4 + 0]) * t;\n out[i * 4 + 1] = perAnchor[a4 + 1] + (perAnchor[b4 + 1] - perAnchor[a4 + 1]) * t;\n out[i * 4 + 2] = perAnchor[a4 + 2] + (perAnchor[b4 + 2] - perAnchor[a4 + 2]) * t;\n out[i * 4 + 3] = perAnchor[a4 + 3] + (perAnchor[b4 + 3] - perAnchor[a4 + 3]) * t;\n }\n return out;\n}\n\nfunction drawPathFillVColor(\n ctx: DrawContext,\n cmd: PathDrawCommand,\n fill: { color: string; opacity?: number },\n handle: GLMeshHandle,\n): void {\n const gl = ctx.gl;\n const prog = ctx.pathFillVColor;\n gl.useProgram(prog.handle);\n gl.bindVertexArray(handle.vao);\n setProjAndModel(ctx, prog);\n setSolidPaintUniforms(ctx, prog, fill.color, fill.opacity);\n setColorMatrixUniforms(ctx, prog);\n\n const colors = attachVertexColors(gl, prog, cmd.vertexColors!, handle);\n\n if (handle.requiresStencil) {\n beginParityMask(ctx, handle.indexCount);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n endParityMask(ctx);\n } else {\n applyClipTest(ctx);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n }\n detachVertexColors(gl, colors);\n gl.bindVertexArray(null);\n}\n\n/**\n * Bind the program, uniforms and textures for `fill`, and return the program.\n *\n * Split from the draw so a caller owning its own stencil state can paint\n * without `applyClipTest` clobbering it — `drawPathStrokeStenciled` clips a\n * doubled ribbon to one side of the silhouette, and `applyClipTest` at depth 0\n * disables the stencil test outright.\n */\nfunction bindPathFillByKind(ctx: DrawContext, fill: Paint): ShaderProgram | null {\n const kind = fill.kind ?? 'solid';\n if (kind === 'solid') return bindPathFillSolid(ctx, fill as { color: string; opacity?: number });\n if (kind === 'texture') return bindPathFillPattern(ctx, fill as TexturePaint);\n if (kind === 'linear-gradient' || kind === 'radial-gradient' || kind === 'conic-gradient') {\n return bindPathFillGradient(ctx, fill as Extract<Paint, { kind: 'linear-gradient' | 'radial-gradient' | 'conic-gradient' }>);\n }\n const bind = getPaintDrawKind(kind)?.bind;\n return bind ? bind(paintBindContext(ctx), fill) : null;\n}\n\nexport function drawPathFillByKind(ctx: DrawContext, fill: Paint, handle: GLMeshHandle): void {\n const prog = bindPathFillByKind(ctx, fill);\n if (!prog) return;\n const gl = ctx.gl;\n gl.bindVertexArray(handle.vao);\n applyClipTest(ctx);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n gl.bindVertexArray(null);\n}\n\nfunction bindPathFillSolid(\n ctx: DrawContext,\n fill: { color: string; opacity?: number },\n): ShaderProgram {\n const prog = ctx.pathFill;\n ctx.gl.useProgram(prog.handle);\n setProjAndModel(ctx, prog);\n setSolidPaintUniforms(ctx, prog, fill.color, fill.opacity);\n setColorMatrixUniforms(ctx, prog);\n return prog;\n}\n\nfunction bindPathFillPattern(\n ctx: DrawContext,\n fill: TexturePaint,\n): ShaderProgram | null {\n return bindPattern(ctx, ctx.patternFill, fill, ctx.state.transform);\n}\n\nfunction bindPathFillGradient(\n ctx: DrawContext,\n fill: Extract<Paint, { kind: 'linear-gradient' | 'radial-gradient' | 'conic-gradient' }>,\n): ShaderProgram | null {\n return bindGradient(ctx, ctx.gradFill, fill, ctx.state.transform);\n}\n\nfunction drawPathFillStencil(ctx: DrawContext, fill: Paint, handle: GLMeshHandle): void {\n const gl = ctx.gl;\n gl.useProgram(ctx.pathFill.handle);\n gl.bindVertexArray(handle.vao);\n setProjAndModel(ctx, ctx.pathFill);\n\n beginParityMask(ctx, handle.indexCount);\n // The paint binds here, not above: pass 1 runs under a false colorMask, so a\n // uniform missed here renders black while the GL-recorder tests still pass.\n // Not `drawPathFillByKind` — its `applyClipTest` would disable this stencil.\n if (bindPathFillByKind(ctx, fill)) {\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n }\n\n endParityMask(ctx);\n gl.bindVertexArray(null);\n}\n\nfunction drawPathStroke(ctx: DrawContext, rawCmd: StrokedPathCommand): void {\n const { cmd, spaces } = resolveStrokeLengths(ctx.state.transform, rawCmd);\n const stroke = cmd.stroke;\n const align = stroke.align ?? 'center';\n const metric = spaces.ribbon?.metric;\n // A rect the metric turns is no longer a rect in the space its ribbon is\n // built in, so it aligns through the stencil like any polygon.\n const stenciled = cmd.path.kind === 'polygon' || (metric !== undefined && !metricKeepsRects(metric));\n if (stenciled && align !== 'center') {\n flushForOwnDraw(ctx);\n drawPathStrokeStenciled(ctx, cmd, align, spaces);\n } else {\n drawPathStrokeUnclipped(ctx, cmd, spaces);\n }\n // After the ribbon, so a head sits on top of the line it caps.\n const width = resolveStrokeWidth(stroke.width ?? 1, 1);\n const heads = cachedMarkerCommands(cmd.path, rawCmd.stroke, stroke, width, ctx.flattenTolerance, spaces);\n for (const marker of heads) drawPath(ctx, marker);\n}\n\nfunction drawPathStrokeUnclipped(ctx: DrawContext, cmd: StrokedPathCommand, spaces: StrokeSpaces): void {\n const stroke = cmd.stroke;\n const paint = stroke.paint;\n const isSolid = paint.kind === undefined || paint.kind === 'solid';\n const solid = paint as { color: string; opacity?: number };\n const mesh = strokeMesh(cmd.path, stroke, ctx.flattenTolerance, spaces);\n if (mesh.indices.length === 0) return;\n\n // Staged, a ribbon allocates nothing and joins the fill it sits on.\n const hasVColors = !!(stroke.vertexColors && stroke.vertexColors.length > 0);\n const batched = batchPaint(ctx, paint, hasVColors);\n if (batched === null) return;\n if (tryStageFill(ctx, mesh, batched)) return;\n\n // The VAO records the per-draw color attribute, so a vertex-colored draw\n // cannot share a persistent one with a draw that has no vertex colors.\n const handle = hasVColors\n ? ctx.meshCache.uploadTransient(mesh)\n : ctx.meshCache.uploadRecurring(mesh);\n\n if (!isSolid && !hasVColors) {\n drawPathFillByKind(ctx, paint, handle);\n return;\n }\n\n const gl = ctx.gl;\n if (hasVColors) {\n const prog = ctx.pathFillVColor;\n gl.useProgram(prog.handle);\n gl.bindVertexArray(handle.vao);\n setProjAndModel(ctx, prog);\n // Per-vertex colors are the paint here; a non-solid base has no single\n // color to multiply by, so white leaves the vertex colors unmodified.\n setSolidPaintUniforms(ctx, prog, isSolid ? solid.color : '#ffffff', paint.opacity);\n setColorMatrixUniforms(ctx, prog);\n\n const colors = attachVertexColors(gl, prog, stroke.vertexColors!, handle);\n applyClipTest(ctx);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n detachVertexColors(gl, colors);\n gl.bindVertexArray(null);\n return;\n }\n\n gl.useProgram(ctx.pathFill.handle);\n gl.bindVertexArray(handle.vao);\n setProjAndModel(ctx, ctx.pathFill);\n setSolidPaintUniforms(ctx, ctx.pathFill, solid.color, solid.opacity);\n setColorMatrixUniforms(ctx, ctx.pathFill);\n applyClipTest(ctx);\n drawTriangles(ctx, handle.indexCount, ctx.gl.UNSIGNED_INT);\n gl.bindVertexArray(null);\n}\n\n/** The ribbon cache compares `vertexWidths` by reference, so the doubled copy\n * has to be the same array on every frame the source array is. */\nconst DOUBLED_VERTEX_WIDTHS = new WeakMap<number[], number[]>();\n\nfunction doubledVertexWidths(widths: number[]): number[] {\n let doubled = DOUBLED_VERTEX_WIDTHS.get(widths);\n if (doubled === undefined) {\n doubled = widths.map((w) => w * 2);\n DOUBLED_VERTEX_WIDTHS.set(widths, doubled);\n }\n return doubled;\n}\n\nfunction drawPathStrokeStenciled(\n ctx: DrawContext,\n cmd: StrokedPathCommand,\n align: 'inner' | 'outer',\n spaces: StrokeSpaces,\n): void {\n const stroke = cmd.stroke;\n const paint = stroke.paint;\n const isSolid = paint.kind === undefined || paint.kind === 'solid';\n const solid = paint as { color: string; opacity?: number };\n const widerStroke: Stroke = {\n ...stroke,\n width: resolveStrokeWidth(stroke.width ?? 1, 1) * 2,\n ...(stroke.vertexWidths ? { vertexWidths: doubledVertexWidths(stroke.vertexWidths) } : {}),\n align: 'center',\n };\n\n const useVColor = !!(stroke.vertexColors && stroke.vertexColors.length > 0);\n\n const fillHandle = fillMeshHandle(ctx, cmd.path);\n const ribbonMesh = strokeMesh(cmd.path, widerStroke, ctx.flattenTolerance, spaces);\n if (ribbonMesh.indices.length === 0) return;\n // The VAO records the per-draw color attribute, so a vertex-colored draw\n // cannot share a persistent one with a draw that has no vertex colors.\n const ribbonHandle = useVColor\n ? ctx.meshCache.uploadTransient(ribbonMesh)\n : ctx.meshCache.uploadRecurring(ribbonMesh);\n\n const gl = ctx.gl;\n const prog = useVColor ? ctx.pathFillVColor : ctx.pathFill;\n gl.useProgram(prog.handle);\n setProjAndModel(ctx, prog);\n\n gl.enable(gl.STENCIL_TEST);\n gl.colorMask(false, false, false, false);\n gl.stencilMask(0x01);\n gl.stencilFunc(gl.ALWAYS, 1, 0x01);\n // An even-odd fill is one fan per contour, and only parity cuts its holes.\n gl.stencilOp(gl.KEEP, gl.KEEP, fillHandle.requiresStencil ? gl.INVERT : gl.REPLACE);\n gl.bindVertexArray(fillHandle.vao);\n drawTriangles(ctx, fillHandle.indexCount, ctx.gl.UNSIGNED_INT);\n\n const clipMask = ancestorMask(ctx.clipDepth);\n gl.colorMask(true, true, true, true);\n if (align === 'inner') {\n gl.stencilFunc(gl.EQUAL, clipMask | 0x01, clipMask | 0x01);\n } else {\n gl.stencilFunc(gl.EQUAL, clipMask, clipMask | 0x01);\n }\n gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);\n // Bind the paint here rather than through `drawPathFillByKind`: that calls\n // `applyClipTest`, which at clip depth 0 disables the stencil test this\n // function just set up to clip the ribbon to one side.\n let ribbonProg: ShaderProgram | null = prog;\n if (useVColor) {\n // Per-vertex colors are the paint here; a non-solid base has no single\n // color to multiply by, so white leaves the vertex colors unmodified.\n setSolidPaintUniforms(ctx, prog, isSolid ? solid.color : '#ffffff', paint.opacity);\n setColorMatrixUniforms(ctx, prog);\n } else {\n ribbonProg = bindPathFillByKind(ctx, paint);\n }\n if (!ribbonProg) {\n gl.stencilMask(0x01);\n gl.clear(gl.STENCIL_BUFFER_BIT);\n gl.disable(gl.STENCIL_TEST);\n gl.bindVertexArray(null);\n return;\n }\n gl.bindVertexArray(ribbonHandle.vao);\n\n const colors = useVColor\n ? attachVertexColors(gl, ribbonProg, stroke.vertexColors!, ribbonHandle)\n : null;\n\n drawTriangles(ctx, ribbonHandle.indexCount, ctx.gl.UNSIGNED_INT);\n\n // Narrow to bit 0 first: clear only zeroes bits the mask enables, and\n // pushClip owns bits 1-7.\n gl.stencilMask(0x01);\n gl.clear(gl.STENCIL_BUFFER_BIT);\n gl.disable(gl.STENCIL_TEST);\n if (colors) detachVertexColors(gl, colors);\n gl.bindVertexArray(null);\n}\n","/**\n * Glyph outlines as world-space meshes: each glyph's em-space fill or stroke\n * mesh, placed and concatenated so a run of outlined text is one draw.\n */\nimport type { Mesh } from '@weasel-js/geom/tessellate';\nimport type { LaidOutGroup, LaidOutOutlineGlyph } from '@weasel-js/text';\nimport { strokeHasInk } from '@weasel-js/paint';\nimport { strokeSpaceOf } from '@weasel-js/stroke';\nimport type { GlMat3 } from '@weasel-js/geom';\nimport { quantizeStrokeScale } from './cache/strokeMeshCache';\nimport { outlineMesh } from './cache/outlineMeshCache';\nimport { outlineStrokeMesh, quantizeEmWidth } from './cache/outlineStrokeMeshCache';\nimport { SYNTHETIC_ITALIC_RADIANS } from '@weasel-js/text';\n\n/**\n * Merge a group's glyphs into one world-space mesh, or `null` when nothing in\n * it has area.\n *\n * Every glyph mesh here is `'nonzero'`, so concatenating their triangles is\n * sound — an even-odd mesh only resolves correctly through a stencil pass, and\n * merging one into a batch would fill its counters solid.\n */\nexport function outlineGroupMesh(group: LaidOutGroup, dx: number, dy: number): Mesh | null {\n return mergeGlyphMeshes(group, dx, dy, (glyph) => outlineMesh(glyph.key, glyph.d));\n}\n\n/**\n * The same merge for the group's stroke: one ribbon per glyph, tessellated in\n * em space.\n *\n * `stroke.width` is a world-unit measure and does not grow with `fontSize`;\n * dashes likewise. A synthetic oblique shears a world-width ribbon along with\n * the glyph, so the outline is marginally thicker across the lean than along\n * it — deliberate, because it keeps the outline glued to the glyph.\n *\n * A `{ px }` ribbon is built in the stretch of the whole em-to-screen map,\n * shear included, so it is that many pixels wide in every direction.\n */\nexport function outlineGroupStrokeMesh(\n group: LaidOutGroup,\n dx: number,\n dy: number,\n transform: GlMat3,\n): Mesh | null {\n const stroke = group.stroke;\n if (!strokeHasInk(stroke)) return null;\n const width = stroke.width ?? 1;\n if (typeof width === 'object') {\n const shear = shearOf(group);\n const [a, b, c, d] = [transform[0], transform[1], transform[3], transform[4]];\n return mergeGlyphMeshes(group, dx, dy, (glyph) => {\n if (!(glyph.scale > 0)) return null;\n const s = glyph.scale;\n const space = strokeSpaceOf(s * a, s * b, s * (c - a * shear), s * (d - b * shear));\n const pxPerEm = quantizeStrokeScale(width.px, space.scale);\n if (!(pxPerEm > 0)) return null;\n const dash = stroke.dash?.map((v) => v / pxPerEm);\n return outlineStrokeMesh(\n glyph.key, glyph.d, width.px / pxPerEm, { ...stroke, dash }, space.metric ?? undefined,\n );\n });\n }\n return mergeGlyphMeshes(group, dx, dy, (glyph) =>\n glyph.scale > 0\n ? outlineStrokeMesh(\n glyph.key, glyph.d, quantizeEmWidth(width / glyph.scale),\n { ...stroke, dash: stroke.dash?.map((v) => v / glyph.scale) },\n )\n : null);\n}\n\nconst shearOf = (group: LaidOutGroup): number =>\n group.synthetic.italic ? Math.tan(SYNTHETIC_ITALIC_RADIANS) : 0;\n\n/**\n * Transform each glyph's em-space mesh into world space and concatenate. The\n * fill and stroke paths share the placement math: it must not fork, or an\n * outline would drift off the glyph it outlines.\n */\nfunction mergeGlyphMeshes(\n group: LaidOutGroup,\n dx: number,\n dy: number,\n meshFor: (glyph: LaidOutOutlineGlyph) => Mesh | null,\n): Mesh | null {\n const parts: { mesh: Mesh; glyph: LaidOutOutlineGlyph }[] = [];\n let vertexFloats = 0;\n let indexCount = 0;\n for (const glyph of group.glyphs) {\n const mesh = meshFor(glyph);\n if (!mesh || mesh.indices.length === 0) continue;\n parts.push({ mesh, glyph });\n vertexFloats += mesh.vertices.length;\n indexCount += mesh.indices.length;\n }\n if (parts.length === 0) return null;\n\n // Matches the SDF vertex shader's skew exactly: x moves by\n // `(baselineY - y) * tan(angle)`, and in em space `baselineY - y` is\n // `-ey * scale`, so above-baseline vertices (negative ey) lean right.\n const shear = shearOf(group);\n\n const vertices = new Float32Array(vertexFloats);\n const indices = new Uint32Array(indexCount);\n let vi = 0;\n let ii = 0;\n let base = 0;\n for (const { mesh, glyph } of parts) {\n const { x, baselineY, scale } = glyph;\n for (let k = 0; k < mesh.vertices.length; k += 2) {\n const ex = mesh.vertices[k];\n const ey = mesh.vertices[k + 1];\n vertices[vi++] = x + dx + (ex - ey * shear) * scale;\n vertices[vi++] = baselineY + dy + ey * scale;\n }\n for (let k = 0; k < mesh.indices.length; k++) indices[ii++] = base + mesh.indices[k];\n base += mesh.vertices.length / 2;\n }\n return { vertices, indices };\n}\n","import { isSolidPaint, resolveColor } from '@weasel-js/paint';\nimport { colorPageTextureId, syncColorPageTexture } from '@weasel-js/font';\nimport type { LaidOutGroup } from '@weasel-js/text';\nimport type { ClipRect } from '../batchClip';\nimport type { DrawContext } from './drawContext';\nimport { enterUncut, leaveUncut } from './clip';\nimport { flushBatch } from './flushBatch';\nimport { stageColorGlyphs } from './batch';\n\n/**\n * Stage one group of color glyphs: emoji, each a quad off a page of the\n * dynamic atlas that holds its own colors. They are sampled as an image is and\n * take nothing from the text's fill but its opacity, the way a browser paints\n * them.\n */\nexport function drawColorGlyphs(ctx: DrawContext, group: LaidOutGroup, dx: number, dy: number): void {\n const fill = group.fill?.paint;\n if (fill === undefined || group.quads.length === 0) return;\n if (!syncColorPageTexture(ctx.textureCache, group.page)) return;\n const opacity = isSolidPaint(fill) ? resolveColor(fill.color)[3] : 1;\n const atlasId = colorPageTextureId(group.page);\n\n const batch = ctx.drawBatch;\n const m = ctx.state.transform;\n let { slot, tint } = stageColorGlyphs(ctx, atlasId);\n const restage = (): void => {\n ({ slot, tint } = stageColorGlyphs(ctx, atlasId));\n };\n\n for (const q of group.quads) {\n if (batch.wouldOverflow(4)) {\n flushBatch(ctx);\n restage();\n }\n let cut: ClipRect | null | undefined;\n while (!batch.pushQuad(\n q.x0 + dx, q.y0 + dy, q.x1 - q.x0, q.y1 - q.y0, m,\n q.u0, q.v0, q.u1, q.v1, opacity * tint[3], slot, tint[0], tint[1], tint[2],\n )) {\n cut = enterUncut(ctx);\n restage();\n }\n if (cut !== undefined) {\n leaveUncut(ctx, cut);\n restage();\n }\n }\n}\n","import type { Paint } from '@weasel-js/paint';\nimport { getPaintDrawKind, type PaintBindContext } from '../paintKinds';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport type { GlMat3 } from '@weasel-js/geom';\nimport type { Mesh } from '@weasel-js/geom/tessellate';\nimport type { DrawContext } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { setProjAndModel } from './uniforms';\nimport { returnToRenderTarget } from './effects';\nimport { BATCH_MODEL } from './flushBatch';\nimport { paintBindContext } from './paintBind';\n\nexport interface ScreenRect { x0: number; y0: number; x1: number; y1: number }\n\n/** The unit square, stretched over the region a scratch paint covers. */\nconst UNIT_QUAD: Mesh = {\n vertices: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),\n indices: new Uint32Array([0, 1, 2, 0, 2, 3]),\n};\n\ninterface ScratchPaint {\n texture: WebGLTexture;\n /** Screen position → the texture coordinate the paint landed at there. */\n uvFromScreen: GlMat3;\n}\n\n/**\n * Render a registered kind's paint over `rect` (screen px) into the renderer's\n * scratch buffer, through the kind's own `bind` — so any kind that paints a\n * path paints this, with nothing asked of it beyond what a path asks.\n *\n * The region is snapped out to the device-pixel grid and clamped to the\n * drawing buffer, so each texel is one device pixel of the target and a glyph\n * fragment reads its own. The kind sees the same transform, alpha and paint\n * space it would for a path here; only the projection differs, aimed at the\n * scratch buffer instead of the target. No clip and no scissor apply inside:\n * the glyphs that sample the result are drawn under both.\n *\n * `null` when there is no scratch buffer, the region is empty, or the kind\n * declines the paint — and the glyphs then draw nothing, as the outline tier\n * does for a paint no kind binds.\n */\nexport function renderPaintToScratch(ctx: DrawContext, fill: Paint, rect: ScreenRect): ScratchPaint | null {\n const scratch = ctx.paintScratch;\n const bind = getPaintDrawKind(fill.kind)?.bind;\n if (!scratch || !bind) return null;\n const ratio = ctx.deviceWidth && ctx.widthCss > 0 ? ctx.deviceWidth / ctx.widthCss : 1;\n const deviceW = ctx.deviceWidth ?? Math.round(ctx.widthCss);\n const deviceH = ctx.deviceHeight ?? Math.round(ctx.heightCss);\n const px0 = Math.max(0, Math.floor(rect.x0 * ratio));\n const py0 = Math.max(0, Math.floor(rect.y0 * ratio));\n const maxSide = ctx.imageCache.maxTextureSide;\n const pw = Math.min(maxSide, Math.min(deviceW, Math.ceil(rect.x1 * ratio)) - px0);\n const ph = Math.min(maxSide, Math.min(deviceH, Math.ceil(rect.y1 * ratio)) - py0);\n if (!(pw > 0 && ph > 0)) return null;\n\n // The region in screen px, and the two matrices a kind's vertex stage\n // multiplies: the unit quad onto it, and it onto the whole of clip space.\n const x0 = px0 / ratio, y0 = py0 / ratio, w = pw / ratio, h = ph / ratio;\n const model = new Float32Array([w, 0, 0, 0, h, 0, x0, y0, 1]);\n const proj = new Float32Array([2 / w, 0, 0, 0, 2 / h, 0, -1 - (2 * x0) / w, -1 - (2 * y0) / h, 1]);\n const base = paintBindContext(ctx);\n const bindCtx: PaintBindContext = {\n ...base,\n alpha: ctx.state.alpha,\n maxTextureSize: base.maxTextureSize,\n setProjAndModel: (prog) => setProjAndModel(ctx, prog, model, proj),\n };\n\n const gl = ctx.gl;\n const target = scratch.acquire(pw, ph);\n const scissorWasOn = gl.isEnabled(gl.SCISSOR_TEST);\n // The last glyph pass left this texture bound to unit 0; a kind sampling a\n // unit it never binds would read the buffer it is drawing into.\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.bindFramebuffer(gl.FRAMEBUFFER, target.fbo);\n gl.viewport(0, 0, pw, ph);\n gl.disable(gl.SCISSOR_TEST);\n gl.disable(gl.STENCIL_TEST);\n gl.clear(gl.COLOR_BUFFER_BIT);\n gl.disable(gl.BLEND);\n\n const prog = bind(bindCtx, fill);\n if (prog) {\n gl.bindVertexArray(ctx.meshCache.uploadRecurring(UNIT_QUAD).vao);\n drawTriangles(ctx, UNIT_QUAD.indices.length, gl.UNSIGNED_INT);\n gl.bindVertexArray(null);\n }\n\n gl.enable(gl.BLEND);\n returnToRenderTarget(ctx, deviceW, deviceH, scissorWasOn);\n if (!prog) return null;\n return {\n texture: target.texture,\n uvFromScreen: new Float32Array([\n ratio / target.width, 0, 0,\n 0, ratio / target.height, 0,\n -px0 / target.width, -py0 / target.height, 1,\n ]),\n };\n}\n\n/** Bind the glyph program to sample `painted` as its paint. */\nexport function bindScratchPaint(ctx: DrawContext, prog: ShaderProgram, painted: ScratchPaint): ShaderProgram {\n const gl = ctx.gl;\n gl.useProgram(prog.handle);\n setProjAndModel(ctx, prog, BATCH_MODEL);\n gl.uniformMatrix3fv(prog.uniform('u_worldInv')!, false, painted.uvFromScreen);\n gl.activeTexture(gl.TEXTURE0);\n gl.bindTexture(gl.TEXTURE_2D, painted.texture);\n gl.uniform1i(prog.uniform('u_sampler')!, 0);\n return prog;\n}\n","import type { Paint, TexturePaint } from '@weasel-js/paint';\nimport {\n resolveTextStyle,\n type LaidOutGroup,\n type LaidOutDecoration,\n verticalAlignOffset,\n cachedLayoutRuns,\n cachedPaintRuns,\n} from '@weasel-js/text';\nimport type { TextDrawCommand } from '../DrawCommand';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport type { GlMat3 } from '@weasel-js/geom';\nimport type { Mesh } from '@weasel-js/geom/tessellate';\nimport { isSolidPaint, resolveColor } from '@weasel-js/paint';\nimport {\n ensureFontTexture,\n textureCacheKey,\n syncDynamicPageTexture,\n dynamicPageTextureId,\n GLYPH_MODE_MSDF,\n GLYPH_MODE_R8,\n glyphFieldScale,\n} from '@weasel-js/font';\nimport { outlineGroupMesh, outlineGroupStrokeMesh } from '../glyphOutlineMesh';\nimport type { ClipRect } from '../batchClip';\nimport { SYNTHETIC_ITALIC_RADIANS } from '@weasel-js/text';\nimport type { DrawContext, GlyphPaintKind } from './drawContext';\nimport { drawTriangles } from './drawTriangles';\nimport { drawColorGlyphs } from './colorGlyphs';\nimport { applyClipTest } from './stencil';\nimport { enterUncut, leaveUncut, flushForOwnDraw } from './clip';\nimport { BATCH_MODEL, flushBatch } from './flushBatch';\nimport { stageSolid, stageGlyphs, tryStageFill } from './batch';\nimport { foldColor } from './foldColor';\nimport { batchPaint } from './gradient';\nimport { bindPattern, bindGradient } from './paintBind';\nimport { drawPathFillByKind } from './pathPaint';\nimport { type ScreenRect, renderPaintToScratch, bindScratchPaint } from './scratchPass';\n\n/**\n * On-screen glyph size (CSS px) at or above which a face with registered\n * outlines is drawn as geometry instead of sampled from a distance field.\n *\n * 48 is the dynamic tier's own `BAKE_SIZE`, which makes it the size at which\n * that tier stops being an interpolation and starts being a magnification:\n * `glyphRasterizer.ts` measures coverage error bottoming out *at* the bake\n * size and rising on both sides, and past a few times it the reconstructed\n * field shows the raster as contour wobble. The same number is a safe\n * crossing for the baked MSDF atlas, which is still crisp here — outlines are\n * exact, so switching early costs nothing but the tessellation, and the\n * hinting the atlas has and outlines don't stopped mattering well below this.\n */\nexport const OUTLINE_MIN_SCREEN_PX = 48;\n\n/**\n * Uniform scale the model matrix applies, as the geometric mean of its two\n * axis lengths, so a non-uniform scale answers with something between the\n * two. Being one glyph-size late or early only changes which of two correct\n * renderings is used.\n */\nfunction modelScale(m: GlMat3): number {\n const sx = Math.hypot(m[0], m[1]);\n const sy = Math.hypot(m[3], m[4]);\n return Math.sqrt(sx * sy) || 1;\n}\n\nexport function drawText(ctx: DrawContext, cmd: TextDrawCommand): void {\n const style = resolveTextStyle(cmd.style);\n const lineHeight = style.lineHeight;\n const align = cmd.align ?? style.align;\n const direction = cmd.direction ?? style.direction;\n const maxWidth = cmd.maxWidth ?? Infinity;\n\n // Screen threshold → world threshold: a 12px label at 8× zoom is 96 screen\n // pixels of text and wants outlines exactly as much as a 96px heading does.\n const minScreen = ctx.textOutlineMinScreenSize ?? OUTLINE_MIN_SCREEN_PX;\n const outlineMinSize = Number.isFinite(minScreen)\n ? minScreen / modelScale(ctx.state.transform)\n : undefined;\n\n const laid = cachedLayoutRuns(cmd.runs, {\n maxWidth, alignWidth: cmd.width, lineHeight, align, direction, tabSize: style.tabSize, justify: cmd.justify,\n });\n const { groups, decorations } = cachedPaintRuns(laid, cmd.runs, { outlineMinSize });\n // Decorations are checked too: text whose glyphs are all ink-free — every\n // one still awaiting a dynamic-atlas bake, say — produces no groups at all\n // while still carrying a rule that has to be drawn.\n if (groups.length === 0 && decorations.length === 0) return;\n\n // `laid` is origin-relative, so this is the command's position plus the\n // verticalAlign shift. Applied at upload time, not baked in: a cached layout\n // that absorbed either offset would gain another one every frame and slide\n // off the page.\n const dx = cmd.x;\n const dy = cmd.y + verticalAlignOffset(cmd.verticalAlign, cmd.height, laid.bounds.height);\n\n for (const group of groups) {\n if (group.source === 'outline') drawTextOutlineGroup(ctx, group, dx, dy);\n else if (group.source === 'color') drawColorGlyphs(ctx, group, dx, dy);\n else drawTextGroup(ctx, group, dx, dy);\n }\n\n drawTextDecorations(ctx, decorations, dx, dy);\n}\n\n/**\n * Paint one group of tessellated glyph outlines as a single mesh: cached\n * em-space triangles are transformed on the CPU into world space and appended\n * to one buffer, so a paragraph set in one face and color is one draw call\n * rather than one per glyph.\n */\nfunction drawTextOutlineGroup(ctx: DrawContext, group: LaidOutGroup, dx: number, dy: number): void {\n const fill = group.fill?.paint;\n if (fill !== undefined) {\n const mesh = outlineGroupMesh(group, dx, dy);\n if (mesh) drawOutlineMesh(ctx, fill, mesh);\n }\n\n // Stroke after fill — Canvas2D's fillText-then-strokeText convention, and\n // SVG's default paint-order. A second batched draw call over the same\n // group, not a call per glyph.\n const strokePaint = group.stroke?.paint;\n if (!strokePaint) return;\n const ribbon = outlineGroupStrokeMesh(group, dx, dy, ctx.state.transform);\n if (ribbon) drawOutlineMesh(ctx, strokePaint, ribbon);\n}\n\n/**\n * Paint one merged glyph-outline mesh, staging it where it fits. A paragraph\n * can mix tiers — a heading drawn as outlines and a caption drawn from the\n * atlas are groups of one command — and an outline that painted itself while\n * glyphs sat staged behind it would come out under them.\n */\nfunction drawOutlineMesh(ctx: DrawContext, fill: Paint, mesh: Mesh): void {\n const paint = batchPaint(ctx, fill, false);\n if (paint === null) return;\n if (tryStageFill(ctx, mesh, paint)) return;\n drawPathFillByKind(ctx, fill, ctx.meshCache.uploadTransient(mesh));\n}\n\n/**\n * Stage the rules an underline, strikethrough or overline asks for.\n *\n * Color resolution matches `drawTextGroup` exactly — including its ignoring\n * of `fill.opacity` — so a rule can never disagree with the glyphs it\n * underlines. They stage as ordinary rects, which is what keeps them in the\n * run their glyphs are in. A rule under a texture paint is geometry under it,\n * the way an outline glyph is.\n */\nfunction drawTextDecorations(\n ctx: DrawContext, decorations: readonly LaidOutDecoration[], dx: number, dy: number,\n): void {\n for (const d of decorations) {\n const paint = d.fill.paint;\n if (paint === undefined) continue;\n if (glyphPaintKindOf(paint) !== null) {\n drawOutlineMesh(ctx, paint, ruleMesh(d.x0 + dx, d.y0 + dy, d.x1 + dx, d.y1 + dy));\n continue;\n }\n const [r, g, b, a] = isSolidPaint(paint) ? resolveColor(paint.color) : [0, 0, 0, 1];\n let cut: ClipRect | null | undefined;\n for (;;) {\n const slot = stageSolid(ctx, 4);\n const rgba = foldColor(ctx, r, g, b, a);\n if (ctx.drawBatch.pushRect(\n d.x0 + dx, d.y0 + dy, d.x1 - d.x0, d.y1 - d.y0, ctx.state.transform,\n rgba[0], rgba[1], rgba[2], rgba[3], slot,\n )) break;\n cut = enterUncut(ctx);\n }\n if (cut !== undefined) leaveUncut(ctx, cut);\n }\n}\n\nfunction ruleMesh(x0: number, y0: number, x1: number, y1: number): Mesh {\n return {\n vertices: new Float32Array([x0, y0, x1, y0, x1, y1, x0, y1]),\n indices: new Uint32Array([0, 1, 2, 0, 2, 3]),\n };\n}\n\n/**\n * Amount the SDF threshold shifts by when the resolver fell back\n * from a missing bold variant to the regular atlas. Tuned on Inter: it\n * thickens strokes about a pixel at 16px without breaking glyph topology.\n */\nconst SYNTH_BOLD_AMOUNT = 0.08;\n\n/**\n * Stage one group of atlas glyphs into the batch.\n *\n * The text color and the atlas (a slot index packed with the paint mode) ride\n * the vertices, so a run off a baked MSDF atlas and one off the runtime canvas\n * bake belong to the same draw, and so does whatever else the page put around\n * them. The synthetic-bold threshold rides them too, and the synthetic\n * oblique is sheared into the corners as `pushGlyph` places them.\n */\nfunction drawTextGroup(\n ctx: DrawContext, group: LaidOutGroup, dx: number, dy: number,\n): void {\n if (group.source === 'canvas') {\n if (!syncDynamicPageTexture(ctx.textureCache, group.page)) return;\n } else {\n if (!ensureFontTexture(group.family, group.weight, group.style, ctx.textureCache)) return;\n }\n if (group.quads.length === 0) return;\n\n const atlasId = group.source === 'canvas'\n ? dynamicPageTextureId(group.page)\n : textureCacheKey(group.family, group.weight, group.style);\n const mode = group.source === 'canvas' ? GLYPH_MODE_R8 : GLYPH_MODE_MSDF;\n const fieldScale = glyphFieldScale(\n group.source === 'canvas' ? 'canvas' : 'atlas', group.family, group.weight, group.style,\n );\n if (!fieldScale) return;\n const bold = group.synthetic.bold ? SYNTH_BOLD_AMOUNT : 0;\n const tanItalic = group.synthetic.italic ? Math.tan(SYNTHETIC_ITALIC_RADIANS) : 0;\n const fill = group.fill?.paint;\n if (fill === undefined) return;\n const paintKind = glyphPaintKindOf(fill);\n if (paintKind !== null) {\n drawPaintedGlyphs(ctx, group, dx, dy, paintKind, atlasId, mode, bold, tanItalic, fieldScale);\n return;\n }\n const color = isSolidPaint(fill)\n ? resolveColor(fill.color)\n : [0, 0, 0, 1];\n\n const batch = ctx.drawBatch;\n const m = ctx.state.transform;\n let slot = stageGlyphs(ctx, atlasId, fieldScale);\n const rgba = foldColor(ctx, color[0], color[1], color[2], color[3]);\n\n for (const q of group.quads) {\n if (batch.wouldOverflow(4)) {\n flushBatch(ctx);\n slot = stageGlyphs(ctx, atlasId, fieldScale);\n }\n let cut: ClipRect | null | undefined;\n while (!batch.pushGlyph(\n q.x0 + dx, q.y0 + dy, q.x1 + dx, q.y1 + dy, q.baselineY + dy, tanItalic, m,\n q.u0, q.v0, q.u1, q.v1,\n rgba[0], rgba[1], rgba[2], rgba[3],\n slot, mode, bold,\n )) {\n cut = enterUncut(ctx);\n slot = stageGlyphs(ctx, atlasId, fieldScale);\n }\n if (cut !== undefined) {\n leaveUncut(ctx, cut);\n slot = stageGlyphs(ctx, atlasId, fieldScale);\n }\n }\n}\n\n/** Which glyph-paint program `fill` needs, or `null` for a paint the batch\n * draws as one color. */\nfunction glyphPaintKindOf(fill: Paint): GlyphPaintKind | null {\n const kind = fill.kind ?? 'solid';\n if (kind === 'texture') return 'pattern';\n if (kind === 'linear-gradient' || kind === 'radial-gradient' || kind === 'conic-gradient') {\n return 'gradient';\n }\n return kind === 'solid' ? null : 'texture';\n}\n\n/** The atlas's unit while a glyph-paint run draws; the paint has unit 0. */\nconst GLYPH_PAINT_ATLAS_UNIT = 1;\n\n/**\n * Draw one group of atlas glyphs with a texture paint, its coverage masking\n * the paint — see `shaders/glyphPaint.ts`.\n *\n * Its own draw, as a pattern-filled path is: the glyph vertex has no room for\n * a paint coordinate beside its atlas one, and widening it would cost every\n * vertex in every run. The quads still stage through `DrawBatch`, drained\n * first, and are drawn from it here before anything else can stage behind\n * them, so no run ever holds them and nothing outside this function has to\n * know they exist.\n */\nfunction drawPaintedGlyphs(\n ctx: DrawContext, group: LaidOutGroup, dx: number, dy: number,\n kind: GlyphPaintKind, atlasId: string, mode: number, bold: number, tanItalic: number,\n fieldScale: readonly [number, number],\n): void {\n const prog = ctx.glyphPaintProgram?.(kind);\n if (!prog) return;\n flushForOwnDraw(ctx);\n const fill = group.fill!.paint!;\n const m = ctx.state.transform;\n let bound: ShaderProgram | null;\n if (kind === 'pattern') {\n bound = bindPattern(ctx, prog, fill as TexturePaint, BATCH_MODEL);\n } else if (kind === 'gradient') {\n bound = bindGradient(ctx, prog, fill as Extract<Paint, { kind: 'linear-gradient' | 'radial-gradient' | 'conic-gradient' }>, BATCH_MODEL);\n } else {\n const painted = renderPaintToScratch(ctx, fill, glyphScreenBounds(group, dx, dy, tanItalic, m));\n bound = painted && bindScratchPaint(ctx, prog, painted);\n }\n if (!bound) return;\n const gl = ctx.gl;\n ctx.textureCache.bind(atlasId, GLYPH_PAINT_ATLAS_UNIT);\n gl.uniform1i(prog.uniform('u_atlas')!, GLYPH_PAINT_ATLAS_UNIT);\n gl.uniform1f(prog.uniform('u_synthBold')!, bold);\n gl.uniform2f(prog.uniform('u_fieldScale')!, fieldScale[0], fieldScale[1]);\n applyClipTest(ctx);\n\n const batch = ctx.drawBatch;\n // `flushForOwnDraw` put every clip on the stencil, which this draw tests.\n const cut = batch.clip;\n batch.clip = null;\n for (const q of group.quads) {\n if (batch.wouldOverflow(4)) drawStagedGlyphs(ctx);\n batch.pushGlyph(\n q.x0 + dx, q.y0 + dy, q.x1 + dx, q.y1 + dy, q.baselineY + dy, tanItalic, m,\n q.u0, q.v0, q.u1, q.v1,\n 1, 1, 1, 1,\n GLYPH_PAINT_ATLAS_UNIT, mode, 0,\n );\n }\n drawStagedGlyphs(ctx);\n batch.clip = cut;\n gl.activeTexture(gl.TEXTURE0);\n gl.bindVertexArray(null);\n}\n\nfunction drawStagedGlyphs(ctx: DrawContext): void {\n const batch = ctx.drawBatch;\n if (batch.length === 0) return;\n drawTriangles(ctx, batch.uploadAndBind(), ctx.gl.UNSIGNED_INT);\n batch.reset();\n}\n\n/** The screen-space box of a group's glyph quads, corner for corner as\n * `DrawBatch.pushGlyph` places them. */\nfunction glyphScreenBounds(\n group: LaidOutGroup, dx: number, dy: number, tanItalic: number, m: GlMat3,\n): ScreenRect {\n const b = { x0: Infinity, y0: Infinity, x1: -Infinity, y1: -Infinity };\n const add = (x: number, y: number) => {\n const sx = m[0] * x + m[3] * y + m[6];\n const sy = m[1] * x + m[4] * y + m[7];\n if (sx < b.x0) b.x0 = sx;\n if (sx > b.x1) b.x1 = sx;\n if (sy < b.y0) b.y0 = sy;\n if (sy > b.y1) b.y1 = sy;\n };\n for (const q of group.quads) {\n const x0 = q.x0 + dx, x1 = q.x1 + dx, y0 = q.y0 + dy, y1 = q.y1 + dy;\n const base = q.baselineY + dy;\n const top = (base - y0) * tanItalic;\n const bottom = (base - y1) * tanItalic;\n add(x0 + top, y0);\n add(x1 + top, y0);\n add(x1 + bottom, y1);\n add(x0 + bottom, y1);\n }\n return b;\n}\n","import type { Path, GlMat3 } from '@weasel-js/geom';\nimport type { CommandStroke, CommandFill } from '@weasel-js/paint';\nimport type { TextAlign, TextDirection, TextStyle } from '@weasel-js/text';\nimport type { ResolvedRun } from '@weasel-js/text';\nimport type { TextVerticalAlign } from '@weasel-js/text';\nimport type { ShaderProgramHandle, ShaderUniform } from './shaders/registerProgram';\nimport type { Effect } from './effects/types';\nimport type { BlendFactors, CompositeOp } from './effects/compositeOp';\n\n/** DrawCommand variants implemented through step 6. */\nexport type DrawCommand =\n | PathDrawCommand\n | GroupDrawCommand\n | TextDrawCommand\n | ImageDrawCommand\n | SpritesDrawCommand\n | ShaderDrawCommand;\n\n/** Draw a path, filled and/or stroked. The workhorse command: every shape the\n * kit draws that is not text, an image, or a custom shader is one of these. */\nexport interface PathDrawCommand {\n kind: 'path';\n path: Path;\n /** Solid, pattern, or gradient (linear/radial/conic), resolved for the\n * renderer: `commandPaint` makes one from a node's `Paint`. */\n fill?: CommandFill;\n /** Stroke spec. Its `paint` takes what `fill` does. */\n stroke?: CommandStroke;\n /**\n * Optional flat RGBA-per-path-anchor color array (length =\n * `4 × countPathAnchors(path)`, floats in 0..1), arc-length-interpolated\n * across the mesh between consecutive anchors.\n *\n * **`fill` must also be set when using `vertexColors`.** The renderer\n * only enters the per-vertex shader path when the command has a fill\n * (the fill provides the opacity uniform). Pass any solid `fill` (e.g.\n * `{ paint: { color: '#fff' } }`) as the placeholder; the per-vertex colors\n * win in the shader.\n */\n vertexColors?: number[];\n}\n\n/** Draw a list of commands under a shared transform, opacity, color matrix\n * and clip. Groups nest, and their effects accumulate down the stack — this\n * is how a container node's transform reaches its descendants. */\nexport interface GroupDrawCommand {\n kind: 'group';\n transform?: GlMat3;\n alpha?: number;\n /**\n * Optional 4×5 color matrix (row-major, 20 numbers) — `out = M₄ₓ₄ * in + bias`.\n * Accumulated multiplicatively down the group stack. Defaults to identity.\n */\n colorMatrix?: number[];\n /** Optional clip path. When set, the renderer rasterizes this path into\n * the stencil buffer before drawing `children`; the children paint only\n * where the clip covers. Nested groups with clips intersect — a child\n * cannot escape an ancestor's clip. Max 7 nesting levels; the renderer\n * throws if exceeded. */\n clip?: Path;\n /**\n * Full-screen passes run over this group's own pixels, in order, before it\n * is composited into its parent.\n *\n * Unlike every other field here, this does not accumulate down the group\n * stack — it is a render-target boundary. The children draw into a buffer of\n * their own, each effect reads the previous one's output, and the result is\n * composited back under this group's `transform`, `alpha`, `colorMatrix` and\n * whatever clip encloses it. So a blur here blurs this group and nothing\n * around it, which is what a CSS `filter` on the canvas cannot do.\n *\n * An empty or absent list costs nothing: no buffer is allocated until a\n * group asks for one.\n */\n effects?: readonly Effect[];\n /**\n * Draw the children into a buffer of their own and composite it once, the\n * render-target boundary `effects` makes, with no pass run over it. `alpha`\n * and `colorMatrix` then apply to the finished surface, so overlapping\n * children do not show through each other as they do when each is faded on\n * its own. Costs a device-resolution buffer and a full-screen composite.\n */\n isolate?: boolean;\n /**\n * How the group's finished surface joins what is already drawn. Default\n * `source-over`. Any other operator isolates the group, and its composite\n * covers the whole target inside the enclosing clip, so an operator that\n * scales the destination by the source's alpha (`source-in`,\n * `destination-in`, `destination-atop`, `copy`) also clears everything the\n * group left empty. Operators reading the destination's alpha need a target\n * that has one: a context created with `alpha: false` reads as opaque.\n */\n composite?: CompositeOp | BlendFactors;\n children: DrawCommand[];\n}\n\n/**\n * Text draw command. Renders one or more runs at (`x`, `y`) in screen\n * space, optionally word-wrapping at `maxWidth`. `style` carries node-level\n * defaults (`lineHeight`, anti-alias width) that don't belong on individual\n * runs.\n */\nexport interface TextDrawCommand {\n kind: 'text';\n x: number;\n y: number;\n runs: ResolvedRun[];\n /** Wrap width. Absent never wraps. */\n maxWidth?: number;\n align?: TextAlign;\n /** What `start` / `end` resolve against, and the base direction of bidi\n * reordering — see `LayoutRunsOpts.direction`. Default `style`'s. */\n direction?: TextDirection | 'auto';\n /** Spread each wrapped line across `width` — see `LayoutRunsOpts.justify`.\n * `align` then sets only the lines it does not spread. Default `false`. */\n justify?: boolean;\n /** Box width `align` resolves within, from `x`. Default `maxWidth`; with\n * neither, `x` is the line's left edge, midpoint or right edge. */\n width?: number;\n style: TextStyle;\n /** Box height for vertical alignment. When set with `verticalAlign`,\n * the laid-out block shifts within `[y, y+height]`. */\n height?: number;\n /** Default 'top' — the legacy top-anchored behavior. */\n verticalAlign?: TextVerticalAlign;\n}\n\n/**\n * Image draw command — renders `image` at screen-space rect (x, y, w, h).\n * The image is stretched to fit; no tiling. Use a pattern Paint on a path\n * for tiling.\n */\nexport interface ImageDrawCommand {\n kind: 'image';\n /** A bitmap holding premultiplied pixels, which is what `createImageBitmap`\n * makes unless told otherwise. One made with `premultiplyAlpha: 'none'`\n * draws too bright wherever it is translucent: a browser uploads a bitmap\n * as it stands, and nothing reports which kind it is. */\n image: ImageBitmap;\n x: number;\n y: number;\n w: number;\n h: number;\n opacity?: number;\n /** Magnification filter. `'linear'` (default) smooths; `'nearest'` shows\n * device pixels as hard squares — required by anything magnifying a\n * framebuffer readback, where blur destroys the point of the readback. */\n sampling?: 'linear' | 'nearest';\n /** Sub-rectangle of `image` to draw, in bitmap pixels from the top-left.\n * Omitted draws the whole bitmap. Not range-checked: a rect past the edge\n * samples outside [0..1], which CLAMP_TO_EDGE smears. With\n * `sampling: 'linear'` the filter reaches half a texel beyond `source`, so\n * atlas frames need a gutter (see `SpriteSheet.spacing`) or `'nearest'`. */\n source?: { x: number; y: number; w: number; h: number };\n /** Mirror the sampled region within the destination rect. The quad does not\n * move — a flipped draw covers exactly the pixels an unflipped one does. */\n flipX?: boolean;\n flipY?: boolean;\n}\n\n/** Floats per sprite in `SpritesDrawCommand.sprites`. */\nexport const SPRITE_STRIDE = 9;\n\n/**\n * Draw many quads sampling one bitmap — an atlas, a sprite sheet, a wall of\n * thumbnails. The same picture as a run of `ImageDrawCommand`s the renderer\n * would coalesce anyway, handed over already packed so it never walks a\n * command object per quad. Reach for it past a few thousand sprites: at\n * 20,000 the object walk is about half the frame.\n *\n * The sprites are one run: they share a texture, a filter, and whatever group\n * transform, alpha, color matrix and clip are live. Anything varying per\n * sprite is in the array.\n */\nexport interface SpritesDrawCommand {\n kind: 'sprites';\n image: ImageBitmap;\n /** Magnification filter for the whole run, as `ImageDrawCommand.sampling`. */\n sampling?: 'linear' | 'nearest';\n /**\n * `SPRITE_STRIDE` floats per sprite:\n * `dx, dy, dw, dh, sx, sy, sw, sh, opacity`.\n *\n * Destination is in the group's coordinates; source is in bitmap pixels,\n * like `ImageDrawCommand.source`. A negative `sw` or `sh` mirrors that axis\n * within the source rect, which is what `flipX` / `flipY` do. A trailing\n * partial sprite is ignored.\n */\n sprites: Float32Array;\n}\n\n/**\n * Custom shader draw command. The renderer generates a quad over `bounds`\n * and dispatches the consumer's fragment shader with the kit's vertex prelude.\n *\n * `uniforms` keys must match names declared in the consumer's fragment shader.\n * The kit automatically sets `u_bounds`, `u_view`, and `u_proj` — do not\n * declare those in `uniforms`.\n *\n * `program` is the handle the module-level `registerProgram()` returned. Each\n * renderer compiles it the first time it draws one, so a layer emits this\n * command with nothing set up on the canvas or the renderer beforehand.\n */\nexport interface ShaderDrawCommand {\n kind: 'shader';\n program: ShaderProgramHandle;\n uniforms: Record<string, ShaderUniform>;\n /** Screen-space bounding rect in CSS pixels. */\n bounds: { x: number; y: number; w: number; h: number };\n}\n","import { type ImageDrawCommand, type SpritesDrawCommand, SPRITE_STRIDE } from '../DrawCommand';\nimport type { ClipRect } from '../batchClip';\nimport type { DrawContext } from './drawContext';\nimport { enterUncut, leaveUncut, retryUncut } from './clip';\nimport { flushBatch } from './flushBatch';\nimport { stageImage } from './batch';\n\n/**\n * Stage one image quad. Nothing reaches the GPU here — `flushBatch` draws the\n * run this joins.\n *\n * The upload has to happen now rather than at flush: a run is keyed on bitmap\n * identity, and `flushBatch` binds a texture it assumes already exists.\n */\n/** Texels per device pixel at which a mipmap starts to beat one bilinear tap. */\nconst MINIFIED = 2;\n\n/**\n * How many device pixels a group unit covers on each axis, squared and scaled\n * by {@link MINIFIED}: a quad is minified on x when\n * `sourceWidth² ≥ limit[0] * drawnWidth²`.\n */\nfunction minifiedLimits(ctx: DrawContext): [number, number] {\n const m = ctx.state.transform;\n const dpr = ctx.deviceWidth && ctx.widthCss ? ctx.deviceWidth / ctx.widthCss : 1;\n const k = (MINIFIED * dpr) ** 2;\n return [k * (m[0] * m[0] + m[1] * m[1]), k * (m[3] * m[3] + m[4] * m[4])];\n}\n\nconst isMinified = (limit: [number, number], sw: number, sh: number, dw: number, dh: number): boolean =>\n sw * sw >= limit[0] * dw * dw || sh * sh >= limit[1] * dh * dh;\n\nexport function drawImage(ctx: DrawContext, cmd: ImageDrawCommand): void {\n ctx.imageCache.upload(cmd.image, cmd.image);\n if (ctx.imageCache.lacksMipmaps(cmd.image)) {\n const sw = cmd.source?.w ?? cmd.image.width;\n const sh = cmd.source?.h ?? cmd.image.height;\n if (isMinified(minifiedLimits(ctx), sw, sh, cmd.w, cmd.h)) ctx.imageCache.buildMipmaps(cmd.image);\n }\n const { slot, tint } = stageImage(ctx, cmd.image, cmd.sampling ?? 'linear');\n\n // Sampling window: the whole bitmap unless `source` narrows it, with the\n // flips applied by swapping the ends rather than moving the quad.\n const src = cmd.source;\n let u0 = 0, v0 = 0, u1 = 1, v1 = 1;\n if (src) {\n const tw = cmd.image.width, th = cmd.image.height;\n u0 = src.x / tw; u1 = (src.x + src.w) / tw;\n v0 = src.y / th; v1 = (src.y + src.h) / th;\n }\n if (cmd.flipX) { const t = u0; u0 = u1; u1 = t; }\n if (cmd.flipY) { const t = v0; v0 = v1; v1 = t; }\n\n if (!ctx.drawBatch.pushQuad(\n cmd.x, cmd.y, cmd.w, cmd.h, ctx.state.transform,\n u0, v0, u1, v1,\n // Group alpha rides here with the opacity, in the tint's fourth channel.\n (cmd.opacity ?? 1) * tint[3],\n slot, tint[0], tint[1], tint[2],\n )) retryUncut(ctx, cmd, undefined, drawImage);\n}\n\n/**\n * Stage a packed run of sprites. The same staging `drawImage` does, minus a\n * command object per quad — see `SpritesDrawCommand`.\n *\n * The run is opened once and reopened only when the per-flush cap forces a\n * chunk, so the state check that costs a command its own run happens twice in\n * a frame rather than twenty thousand times.\n */\nexport function drawSprites(ctx: DrawContext, cmd: SpritesDrawCommand): void {\n const data = cmd.sprites;\n const count = Math.floor(data.length / SPRITE_STRIDE);\n if (count === 0) return;\n\n ctx.imageCache.upload(cmd.image, cmd.image);\n if (ctx.imageCache.lacksMipmaps(cmd.image)) {\n const limit = minifiedLimits(ctx);\n for (let i = 0; i < count * SPRITE_STRIDE; i += SPRITE_STRIDE) {\n if (!isMinified(limit, data[i + 6], data[i + 7], data[i + 2], data[i + 3])) continue;\n ctx.imageCache.buildMipmaps(cmd.image);\n break;\n }\n }\n const sampling = cmd.sampling ?? 'linear';\n let { slot, tint } = stageImage(ctx, cmd.image, sampling);\n\n const batch = ctx.drawBatch;\n const m = ctx.state.transform;\n const tw = cmd.image.width;\n const th = cmd.image.height;\n\n for (let s = 0, i = 0; s < count; s++, i += SPRITE_STRIDE) {\n if (batch.wouldOverflow(4)) {\n flushBatch(ctx);\n ({ slot, tint } = stageImage(ctx, cmd.image, sampling));\n }\n const sx = data[i + 4], sy = data[i + 5], sw = data[i + 6], sh = data[i + 7];\n let cut: ClipRect | null | undefined;\n while (!batch.pushQuad(\n data[i], data[i + 1], data[i + 2], data[i + 3], m,\n sx / tw, sy / th, (sx + sw) / tw, (sy + sh) / th,\n data[i + 8] * tint[3], slot, tint[0], tint[1], tint[2],\n )) {\n cut = enterUncut(ctx);\n ({ slot, tint } = stageImage(ctx, cmd.image, sampling));\n }\n if (cut !== undefined) {\n leaveUncut(ctx, cut);\n ({ slot, tint } = stageImage(ctx, cmd.image, sampling));\n }\n }\n}\n","import type { DrawCommand, GroupDrawCommand } from './DrawCommand';\nimport { mat3 } from '@weasel-js/geom';\nimport { getMesh } from './cache/cache';\nimport type { EffectTargets } from './effects/EffectTargets';\nimport { compositeProgramId } from './effects/composite';\nimport { applyComposite, isOwnComposite } from './effects/compositeOp';\nimport type { DrawContext } from './draw/drawContext';\nimport { warnOnceUniform, drawShader } from './draw/customShader';\nimport { returnToRenderTarget, drawFullscreenQuad } from './draw/effects';\nimport { applyClipTest } from './draw/stencil';\nimport { enterGroupClip, leaveClip, flushForOwnDraw } from './draw/clip';\nimport { flushBatch } from './draw/flushBatch';\nimport { drawPath } from './draw/pathPaint';\nimport { drawText } from './draw/text';\nimport { drawImage, drawSprites } from './draw/image';\n\nexport function dispatch(ctx: DrawContext, cmd: DrawCommand): void {\n switch (cmd.kind) {\n case 'group': return drawGroup(ctx, cmd);\n case 'path': return drawPath(ctx, cmd);\n case 'text': return drawText(ctx, cmd);\n case 'image': return drawImage(ctx, cmd);\n case 'sprites': return drawSprites(ctx, cmd);\n case 'shader': flushForOwnDraw(ctx); return drawShader(ctx, cmd);\n }\n}\n\n/**\n * Draw a group's children into a buffer of their own, run its effects over\n * that buffer, and composite the result back where the group sits.\n *\n * Three things are deliberately not inherited by the offscreen render:\n *\n * - **The clip.** A fresh buffer's stencil is empty, so a child drawn at the\n * enclosing clip depth would test against bits that were never written and\n * paint nothing. The enclosing clip belongs on the composite anyway — it\n * clips the group's result, not the pixels an effect reads — so `clipDepth`\n * restarts at 0 inside, which also hands nested clips a fresh budget.\n * - **Alpha and color**, for the same reason from the other end: fading on\n * the way in would give the effect faded pixels to read, and fade them\n * again on the way out. `pushIsolated` returns what the composite owes.\n * - **The scissor**, which belongs to the renderer's sub-rect within the\n * default framebuffer and means nothing in a buffer sized to the whole\n * drawing buffer.\n */\nfunction drawGroupWithEffects(\n ctx: DrawContext,\n cmd: GroupDrawCommand,\n targets: EffectTargets,\n width: number,\n height: number,\n): void {\n const gl = ctx.gl;\n // Anything staged belongs to the parent's buffer, not this one, and the\n // composite below draws under the parent's clips.\n flushForOwnDraw(ctx);\n\n const parentTarget = ctx.renderTarget ?? null;\n const parentClipDepth = ctx.clipDepth;\n const parentClipStack = ctx.clipStack;\n const parentBatchClip = ctx.drawBatch.clip;\n const scissorWasOn = gl.isEnabled(gl.SCISSOR_TEST);\n\n let front = targets.acquire(width, height);\n const composited = ctx.state.pushIsolated({\n transform: cmd.transform,\n alpha: cmd.alpha,\n colorMatrix: cmd.colorMatrix,\n });\n ctx.clipDepth = 0;\n ctx.clipStack = [];\n ctx.drawBatch.clip = null;\n\n gl.bindFramebuffer(gl.FRAMEBUFFER, front.fbo);\n ctx.renderTarget = front;\n gl.viewport(0, 0, width, height);\n gl.disable(gl.SCISSOR_TEST);\n gl.stencilMask(0xFF);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);\n\n for (const child of cmd.children) dispatch(ctx, child);\n flushBatch(ctx);\n\n // Passes replace rather than blend: each writes every texel of its target\n // from the whole of its source. A child that ended by popping a stencil\n // clip leaves the test on, and no pass target has that clip's bits.\n gl.disable(gl.BLEND);\n gl.disable(gl.STENCIL_TEST);\n for (const effect of cmd.effects ?? []) {\n const program = ctx.ensureProgram?.(effect.program.id) ?? null;\n if (!program) {\n warnOnceUniform(effect.program.id, '(program)');\n continue;\n }\n const back = targets.acquire(width, height);\n gl.bindFramebuffer(gl.FRAMEBUFFER, back.fbo);\n gl.viewport(0, 0, width, height);\n gl.clear(gl.COLOR_BUFFER_BIT);\n drawFullscreenQuad(ctx, program, front.texture, width, height, effect.uniforms,\n undefined, effect.program.id);\n targets.release(front);\n front = back;\n }\n gl.enable(gl.BLEND);\n\n // Back to the parent's buffer, and back under its rules.\n ctx.state.pop();\n ctx.clipDepth = parentClipDepth;\n ctx.clipStack = parentClipStack;\n ctx.drawBatch.clip = parentBatchClip;\n ctx.renderTarget = parentTarget;\n returnToRenderTarget(ctx, width, height, scissorWasOn);\n\n const composite = ctx.ensureProgram?.(compositeProgramId()) ?? null;\n if (composite) {\n applyClipTest(ctx);\n const ownBlend = isOwnComposite(cmd.composite);\n if (ownBlend) applyComposite(gl, cmd.composite!);\n drawFullscreenQuad(ctx, composite, front.texture, width, height, undefined, {\n alpha: composited.alpha,\n colorMatrix: composited.colorMatrix,\n });\n if (ownBlend) applyComposite(gl, 'source-over');\n }\n targets.release(front);\n}\n\n/** Whether `cmd` draws into a buffer of its own before joining its parent. */\nfunction ownsSurface(cmd: GroupDrawCommand): boolean {\n return cmd.isolate === true || isOwnComposite(cmd.composite)\n || (cmd.effects !== undefined && cmd.effects.length > 0);\n}\n\nexport function drawGroup(ctx: DrawContext, cmd: GroupDrawCommand): void {\n // A group with effects, or an isolated one, is a render-target boundary\n // rather than another accumulating frame. Without a renderer's buffer pool behind the context\n // there is nowhere to draw, so the effects are skipped and the children\n // paint straight through — a frame missing its blur, not a frame missing.\n if (ownsSurface(cmd) && ctx.effectTargets && ctx.deviceWidth && ctx.deviceHeight) {\n // The clip cuts the composite, so it goes on the parent's buffer, in the\n // group's own space.\n if (cmd.clip) {\n ctx.state.push({ transform: cmd.transform });\n try {\n enterGroupClip(ctx, cmd.clip);\n } finally {\n ctx.state.pop();\n }\n }\n drawGroupWithEffects(ctx, cmd, ctx.effectTargets, ctx.deviceWidth, ctx.deviceHeight);\n if (cmd.clip) leaveClip(ctx);\n return;\n }\n ctx.state.push({\n transform: cmd.transform,\n alpha: cmd.alpha,\n colorMatrix: cmd.colorMatrix,\n });\n if (cmd.clip) {\n try {\n enterGroupClip(ctx, cmd.clip);\n } catch (err) {\n ctx.state.pop();\n throw err;\n }\n }\n for (const child of cmd.children) dispatch(ctx, child);\n if (cmd.clip) leaveClip(ctx);\n ctx.state.pop();\n}\n\nexport { mat3, getMesh };\nexport type { DrawContext, ClipEntry, GlyphPaintKind } from './draw/drawContext';\nexport { setUniform } from './draw/customShader';\nexport { meshBatching, tryStageFill } from './draw/batch';\nexport { colorFolding } from './draw/foldColor';\nexport { flushBatch } from './draw/flushBatch';\nexport { pushClip, popClip } from './draw/clip';\nexport { OUTLINE_MIN_SCREEN_PX } from './draw/text';\n","/**\n * Kit-supplied vertex shader for kind:'shader' DrawCommands.\n *\n * Consumers write only fragment shaders. The vertex shader is fixed:\n * it generates a quad covering the DrawCommand's `bounds` rect and\n * exposes three varyings the fragment shader can consume.\n *\n * PUBLIC CONTRACT (varyings and kit uniforms):\n *\n * in vec2 a_position -1..1 NDC quad (set by the kit)\n * in vec2 a_uv 0..1 across the bounds rect\n *\n * uniform vec4 u_bounds x, y, w, h in screen-space CSS pixels (set by kit)\n * uniform mat3 u_view weasel View matrix, world→screen (set by kit)\n * uniform mat3 u_proj screen→clip projection (internal, not documented)\n *\n * out vec2 v_uv 0..1 across the bounds rect (top-left origin)\n * out vec2 v_screen screen-space pixel coordinate of this fragment\n * out vec2 v_world approximate world-space coordinate (via view inverse)\n */\n\n/**\n * Kit-supplied vertex shader source for custom programs.\n *\n * @remarks\n * **PREMULTIPLIED ALPHA:** Your fragment shader MUST output `vec4(rgb * a, a)`,\n * not `vec4(rgb, a)`. The canvas is composited with premultipliedAlpha:true;\n * straight-alpha output causes over-bright rendering for any fragment with a < 1.\n */\nexport const CUSTOM_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nin vec2 a_uv;\nuniform vec4 u_bounds;\nuniform mat3 u_view;\nuniform mat3 u_proj;\nout vec2 v_uv;\nout vec2 v_screen;\nout vec2 v_world;\n\nvoid main() {\n float sx = u_bounds.x + a_uv.x * u_bounds.z;\n float sy = u_bounds.y + a_uv.y * u_bounds.w;\n v_screen = vec2(sx, sy);\n v_uv = a_uv;\n\n float det = u_view[0][0] * u_view[1][1] - u_view[0][1] * u_view[1][0];\n // A flat view has no inverse: every fragment reads the world origin, not a plausible wrong mapping.\n float invDet = det != 0.0 ? 1.0 / det : 0.0;\n v_world = vec2(\n ((sx - u_view[2][0]) * u_view[1][1] + (sy - u_view[2][1]) * -u_view[0][1]) * invDet,\n ((sx - u_view[2][0]) * -u_view[1][0] + (sy - u_view[2][1]) * u_view[0][0]) * invDet\n );\n\n vec3 clip = u_proj * vec3(sx, sy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n}\n`;\n\n/**\n * Attribute names used by the custom vertex shader.\n * The renderer looks these up after compile.\n */\nexport const CUSTOM_ATTRIBUTES = ['a_position', 'a_uv'] as const;\n\n/**\n * Kit-managed uniform names for custom shader programs.\n * These are set per-draw by drawShader(); consumers must NOT redeclare them.\n */\nexport const CUSTOM_KIT_UNIFORMS = ['u_bounds', 'u_view', 'u_proj'] as const;\n\n/**\n * Auto-quad geometry: 4 vertices covering NDC (-1..1) and UV (0..1), each\n * [a_position.x, a_position.y, a_uv.x, a_uv.y], in the order top-left,\n * top-right, bottom-right, bottom-left (UV space, screen y-down).\n */\nexport const QUAD_VERTICES = new Float32Array([\n -1, -1, 0, 0,\n 1, -1, 1, 0,\n 1, 1, 1, 1,\n -1, 1, 0, 1,\n]);\n\nexport const QUAD_INDICES = new Uint16Array([0, 1, 2, 0, 2, 3]);\n","/**\n * Offscreen color buffers for effect passes, pooled per renderer. Nothing is\n * allocated until a group with effects asks for one, and every target is the\n * size of the drawing buffer.\n *\n * Clips and even-odd fills live in the stencil buffer, and an FBO does not\n * inherit the default framebuffer's — one without its own attachment renders\n * even-odd paths with their holes filled and clips that do not clip, with no\n * GL error. Every target here gets a DEPTH24_STENCIL8 renderbuffer of its own.\n */\n\nexport interface EffectTarget {\n readonly fbo: WebGLFramebuffer;\n readonly texture: WebGLTexture;\n /** @internal — the pool's own bookkeeping. */\n readonly stencil: WebGLRenderbuffer;\n}\n\nexport class EffectTargets {\n private readonly gl: WebGL2RenderingContext;\n private readonly all: EffectTarget[] = [];\n private free: EffectTarget[] = [];\n private width = 0;\n private height = 0;\n\n constructor(gl: WebGL2RenderingContext) {\n this.gl = gl;\n }\n\n /** True once anything has been allocated — what a test asks instead of\n * reaching for the private arrays. */\n get allocated(): boolean {\n return this.all.length > 0;\n }\n\n /**\n * Borrow a target sized `width` × `height` device pixels. A size change\n * drops every pooled buffer, borrowed ones included.\n */\n acquire(width: number, height: number): EffectTarget {\n if (width !== this.width || height !== this.height) {\n this.free = [];\n this.releaseAll();\n this.width = width;\n this.height = height;\n }\n const pooled = this.free.pop();\n if (pooled) return pooled;\n const made = this.create(width, height);\n this.all.push(made);\n return made;\n }\n\n /** Hand one back. Order does not matter — every target is interchangeable. */\n release(target: EffectTarget): void {\n this.free.push(target);\n }\n\n /** Take back every target still out on loan. A frame that threw inside a\n * group with effects never released the one it was drawing into. */\n reclaim(): void {\n if (this.free.length !== this.all.length) this.free = [...this.all];\n }\n\n /** Drop every buffer. Called on dispose and on context loss, where the\n * handles are already invalid and only the bookkeeping has to go. */\n releaseAll(): void {\n const gl = this.gl;\n for (const t of this.all) {\n gl.deleteFramebuffer(t.fbo);\n gl.deleteTexture(t.texture);\n gl.deleteRenderbuffer(t.stencil);\n }\n this.all.length = 0;\n this.free = [];\n this.width = 0;\n this.height = 0;\n }\n\n private create(width: number, height: number): EffectTarget {\n const gl = this.gl;\n const texture = gl.createTexture()!;\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n // CLAMP_TO_EDGE so a kernel reaching past the edge repeats the border\n // instead of wrapping the opposite side of the screen into frame.\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n\n const stencil = gl.createRenderbuffer()!;\n gl.bindRenderbuffer(gl.RENDERBUFFER, stencil);\n gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH24_STENCIL8, width, height);\n gl.bindRenderbuffer(gl.RENDERBUFFER, null);\n\n const fbo = gl.createFramebuffer()!;\n gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, stencil);\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n\n return { fbo, texture, stencil };\n }\n}\n","/** Qualifiers GLSL allows between `uniform` and the type name, and before a\n * struct member's type. */\nconst QUALIFIERS = new Set([\n 'lowp', 'mediump', 'highp', 'precise', 'invariant',\n 'centroid', 'flat', 'smooth', 'noperspective',\n]);\n\nconst IDENT = /^[A-Za-z_]\\w*$/;\nconst MAX_DEPTH = 16;\n\ninterface Member {\n readonly type: string | readonly Member[];\n readonly name: string;\n /** `null` for a non-array. */\n readonly size: number | null;\n}\n\n/**\n * The names a program's uniforms answer to in `getUniformLocation`: array\n * uniforms per slot (`u_ripples[0]`), struct uniforms per leaf\n * (`u_lights[1].pos`), nested structs and array members included.\n *\n * A declaration scanner over a token stream, not a GLSL parser. Comments are\n * stripped; interface blocks are skipped, since a UBO's members are bound\n * through a buffer rather than a location. Array sizes resolve through integer\n * literals, `#define`s and top-level `const int`s, with `+ - * / %` between\n * them; a size it cannot resolve drops that declarator, and a later write to\n * it warns.\n */\nexport function extractUniformNames(glsl: string): string[] {\n return [...scanUniforms(glsl).names];\n}\n\n/** An array uniform of a basic type: its element type as spelled (`vec3`,\n * `int`, `mat4`) and its declared length. */\nexport interface UniformArrayDecl {\n readonly type: string;\n readonly size: number;\n}\n\n/**\n * Every array of a basic type a program declares, keyed by the name its slots\n * hang off (`u_ripples` for `u_ripples[0]`). An array inside a struct is keyed\n * by its full path (`u_lights[1].weights`); an array of structs is not an\n * entry, since it has no single element type.\n */\nexport function extractUniformArrays(glsl: string): Map<string, UniformArrayDecl> {\n return scanUniforms(glsl).arrays;\n}\n\nfunction scanUniforms(glsl: string): { names: Set<string>; arrays: Map<string, UniformArrayDecl> } {\n const { code, defines } = preprocess(glsl);\n const toks = tokenize(code);\n const consts = new Map<string, number>();\n const structs = new Map<string, Member[]>();\n const out = new Set<string>();\n const arrays = new Map<string, UniformArrayDecl>();\n\n const resolveName = (name: string, depth: number): number | null => {\n if (depth > MAX_DEPTH) return null;\n let best: number | null = null;\n for (const body of defines.get(name) ?? []) {\n const v = evalInt(tokenize(body), (n) => resolveName(n, depth + 1));\n if (v !== null && (best === null || v > best)) best = v;\n }\n return best ?? consts.get(name) ?? null;\n };\n const evalSize = (from: number, to: number) => evalInt(toks.slice(from, to), (n) => resolveName(n, 0));\n\n /** Index of the token closing the bracket opened at `open`. */\n const closer = (open: number): number => {\n let depth = 0;\n for (let k = open; k < toks.length; k++) {\n if (toks[k] === '(' || toks[k] === '[' || toks[k] === '{') depth++;\n else if (toks[k] === ')' || toks[k] === ']' || toks[k] === '}') {\n if (--depth === 0) return k;\n }\n }\n return toks.length;\n };\n\n /** Parses `[size]` at `j` if present: the size (undefined if absent, null\n * if unresolvable) and where scanning resumes. */\n const arraySuffix = (j: number): [number | null | undefined, number] => {\n if (toks[j] !== '[') return [undefined, j];\n const end = closer(j);\n return [evalSize(j + 1, end), end + 1];\n };\n\n /** Declarators `a, b[2], c` up to the terminating `;` (or `}`), after the\n * type at `j`. Returns them and the index of the terminator. */\n const declarators = (\n j: number,\n typeSize: number | null | undefined,\n ): [{ name: string; size: number | null | undefined }[], number] => {\n const found: { name: string; size: number | null | undefined }[] = [];\n while (j < toks.length && toks[j] !== ';' && toks[j] !== '}') {\n const name = toks[j];\n const [size, next] = arraySuffix(j + 1);\n j = next;\n if (IDENT.test(name)) found.push({ name, size: size === undefined ? typeSize : size });\n // Skip an initializer, or anything else, to the next declarator.\n while (j < toks.length && toks[j] !== ',' && toks[j] !== ';' && toks[j] !== '}') {\n j = toks[j] === '(' || toks[j] === '[' || toks[j] === '{' ? closer(j) + 1 : j + 1;\n }\n if (toks[j] === ',') j++;\n }\n return [found, j];\n };\n\n /** `struct Name? { members }` at `i`; records a named struct. */\n const structSpecifier = (i: number): [Member[], number] => {\n let j = i + 1;\n const name = toks[j] !== '{' ? toks[j++] : undefined;\n const members: Member[] = [];\n if (toks[j] !== '{') return [members, j];\n const end = closer(j);\n j++;\n while (j < end) {\n while (QUALIFIERS.has(toks[j])) j++;\n let type: string | Member[];\n if (toks[j] === 'struct') [type, j] = structSpecifier(j);\n else type = toks[j++];\n const [typeSize, afterType] = arraySuffix(j);\n const [decls, term] = declarators(afterType, typeSize);\n for (const d of decls) if (d.size !== null) members.push({ type, name: d.name, size: d.size ?? null });\n j = term + 1;\n }\n if (name) {\n // A struct redefined in another preprocessor branch keeps both members lists.\n const prior = structs.get(name) ?? [];\n for (const m of members) if (!prior.some((p) => p.name === m.name)) prior.push(m);\n structs.set(name, prior);\n }\n return [members, end + 1];\n };\n\n const expand = (name: string, type: string | readonly Member[], size: number | null, depth: number): void => {\n if (depth > MAX_DEPTH) return;\n if (size !== null) {\n if (typeof type === 'string' && !structs.has(type)) {\n const prior = arrays.get(name);\n if (!prior || size > prior.size) arrays.set(name, { type, size });\n }\n for (let k = 0; k < size; k++) expand(`${name}[${k}]`, type, null, depth + 1);\n return;\n }\n const members = typeof type === 'string' ? structs.get(type) : type;\n if (!members) {\n out.add(name);\n return;\n }\n for (const m of members) expand(`${name}.${m.name}`, m.type, m.size, depth + 1);\n };\n\n let depth = 0;\n for (let i = 0; i < toks.length; i++) {\n const t = toks[i];\n if (t === '{') depth++;\n else if (t === '}') depth--;\n else if (t === 'struct') i = structSpecifier(i)[1] - 1;\n else if (depth === 0 && t === 'const') {\n let j = i + 1;\n while (QUALIFIERS.has(toks[j])) j++;\n if ((toks[j] === 'int' || toks[j] === 'uint') && IDENT.test(toks[j + 1] ?? '') && toks[j + 2] === '=') {\n let end = j + 3;\n while (end < toks.length && toks[end] !== ';') end++;\n const v = evalSize(j + 3, end);\n const prior = consts.get(toks[j + 1]);\n if (v !== null && (prior === undefined || v > prior)) consts.set(toks[j + 1], v);\n }\n } else if (depth === 0 && t === 'uniform') {\n let j = i + 1;\n while (QUALIFIERS.has(toks[j])) j++;\n let type: string | Member[];\n if (toks[j] === 'struct') {\n [type, j] = structSpecifier(j);\n } else if (toks[j + 1] === '{') {\n // An interface block: skip it and its instance name.\n j = closer(j + 1) + 1;\n while (j < toks.length && toks[j] !== ';') j++;\n i = j;\n continue;\n } else {\n type = toks[j++];\n }\n const [typeSize, afterType] = arraySuffix(j);\n const [decls, term] = declarators(afterType, typeSize);\n for (const d of decls) if (d.size !== null) expand(d.name, type, d.size ?? null, 0);\n i = term;\n }\n }\n return { names: out, arrays };\n}\n\n/** Comments stripped and directives removed. Every conditional branch is kept:\n * an extra name only looks up a null location, a missing one drops writes. */\nfunction preprocess(glsl: string): { code: string; defines: Map<string, string[]> } {\n const spliced = glsl.replace(/\\\\\\r?\\n/g, '');\n let stripped = '';\n for (let k = 0; k < spliced.length; k++) {\n if (spliced[k] === '/' && spliced[k + 1] === '/') {\n while (k < spliced.length && spliced[k] !== '\\n') k++;\n stripped += '\\n';\n } else if (spliced[k] === '/' && spliced[k + 1] === '*') {\n const end = spliced.indexOf('*/', k + 2);\n k = end < 0 ? spliced.length : end + 1;\n stripped += ' ';\n } else {\n stripped += spliced[k];\n }\n }\n const defines = new Map<string, string[]>();\n const lines = stripped.split('\\n').map((line) => {\n if (!/^\\s*#/.test(line)) return line;\n const def = /^\\s*#\\s*define\\s+([A-Za-z_]\\w*)(\\(?)(.*)$/.exec(line);\n if (def && !def[2]) defines.set(def[1], [...(defines.get(def[1]) ?? []), def[3].trim()]);\n return '';\n });\n return { code: lines.join('\\n'), defines };\n}\n\nfunction tokenize(src: string): string[] {\n return src.match(/[A-Za-z_]\\w*|\\d[\\w.]*|\\S/g) ?? [];\n}\n\nfunction intLiteral(tok: string): number | null {\n const m = /^(?:0[xX]([0-9a-fA-F]+)|(0[0-7]*)|([1-9]\\d*))[uU]?$/.exec(tok);\n if (!m) return null;\n if (m[1] !== undefined) return parseInt(m[1], 16);\n if (m[2] !== undefined) return parseInt(m[2], 8);\n return parseInt(m[3], 10);\n}\n\n/** Integer constant expression over `+ - * / %` and parentheses. */\nfunction evalInt(toks: readonly string[], lookup: (name: string) => number | null): number | null {\n let p = 0;\n const primary = (): number | null => {\n const t = toks[p++];\n if (t === '(') {\n const v = sum();\n return toks[p++] === ')' ? v : null;\n }\n if (t === '-') {\n const v = primary();\n return v === null ? null : -v;\n }\n if (t === '+') return primary();\n if (t === undefined) return null;\n return intLiteral(t) ?? (IDENT.test(t) ? lookup(t) : null);\n };\n const product = (): number | null => {\n let v = primary();\n while (v !== null && (toks[p] === '*' || toks[p] === '/' || toks[p] === '%')) {\n const op = toks[p++];\n const r = primary();\n if (r === null || (op !== '*' && r === 0)) return null;\n v = op === '*' ? v * r : op === '/' ? Math.trunc(v / r) : v % r;\n }\n return v;\n };\n const sum = (): number | null => {\n let v = product();\n while (v !== null && (toks[p] === '+' || toks[p] === '-')) {\n const op = toks[p++];\n const r = product();\n if (r === null) return null;\n v = op === '+' ? v + r : v - r;\n }\n return v;\n };\n const v = sum();\n return p === toks.length && v !== null && v >= 0 ? v : null;\n}\n","import { createPaintResources, type OwnedPaintResources } from './paintResources';\nimport { ShaderProgram } from './shaders/ShaderProgram';\nimport {\n LazyProgram, PATH_FILL_SPEC, PATH_FILL_VCOLOR_SPEC, GRAD_FILL_SPEC, PATTERN_FILL_SPEC,\n BATCH_FILL_MATRICES_SPEC, createBatchFill,\n} from './shaders/builtinPrograms';\nimport {\n markAllFontsNotUploaded,\n resetBakeBudget,\n DEFAULT_BAKE_BUDGET,\n} from '@weasel-js/font';\nimport {\n GLYPH_PAINT_VERT_SRC,\n GLYPH_PATTERN_FRAG_SRC,\n GLYPH_GRAD_FRAG_SRC,\n GLYPH_TEXTURE_FRAG_SRC,\n GLYPH_PATTERN_UNIFORMS,\n GLYPH_GRAD_UNIFORMS,\n GLYPH_TEXTURE_UNIFORMS,\n GLYPH_PAINT_ATTRIBUTES,\n} from './shaders/glyphPaint';\nimport { PaintScratch } from './paintScratch';\nimport { GLMeshCache } from './cache/GLMeshCache';\nimport { GLTextureCache } from './cache/GLTextureCache';\nimport { textureRegistry } from './textures/registerTexture';\nimport { GLImageCache, type ImageMinification } from './cache/GLImageCache';\nimport { GradientRampAtlas } from './cache/GradientRampAtlas';\nimport { GroupState } from './state/GroupState';\nimport type { DrawCommand } from './DrawCommand';\nimport type { GlMat3 } from '@weasel-js/geom';\nimport {\n dispatch, flushBatch, OUTLINE_MIN_SCREEN_PX, type DrawContext, type GlyphPaintKind,\n} from './draw';\nimport { DrawBatch } from './drawBatch';\nimport {\n CUSTOM_VERT_SRC, CUSTOM_ATTRIBUTES, CUSTOM_KIT_UNIFORMS,\n QUAD_VERTICES, QUAD_INDICES,\n} from './shaders/customPrelude';\nimport { getProgramSource, type ProgramSource, type ShaderProgramHandle } from './shaders/registerProgram';\nimport { EffectTargets } from './effects/EffectTargets';\nimport { extractUniformArrays, extractUniformNames } from './shaders/extractUniformNames';\n\n/** Every uniform a custom program may be written through. Both stages, not\n * just the fragment one: a name never looked up is written through `null`,\n * which GL accepts silently, so the uniform keeps its zero default. */\nfunction customUniformNames(vertSrc: string, fragSrc: string): string[] {\n return [...CUSTOM_KIT_UNIFORMS, ...extractUniformNames(vertSrc), ...extractUniformNames(fragSrc)];\n}\n\n/** Compile a registered program's source against `gl`, with every uniform\n * location and array base it may be written through. */\nfunction compileCustomProgram(gl: WebGL2RenderingContext, src: ProgramSource): ShaderProgram {\n const vertSrc = src.vert === '' ? CUSTOM_VERT_SRC : src.vert;\n const program = new ShaderProgram(gl, vertSrc, src.frag);\n program.lookupUniforms(customUniformNames(vertSrc, src.frag));\n program.lookupUniformArrays(new Map([...extractUniformArrays(vertSrc), ...extractUniformArrays(src.frag)]));\n program.lookupAttributes(CUSTOM_ATTRIBUTES);\n return program;\n}\n\n/** A run of top-level commands, `[start, end)` by index, that\n * {@link WeaselRenderer.lastFrameStats} accounts for separately — one render\n * layer's commands, say. Spans are in order and do not overlap. */\nexport interface RenderSpan {\n id: string;\n start: number;\n end: number;\n}\n\n/** Per-frame options for {@link WeaselRenderer.render}. */\nexport interface RenderOptions {\n spans?: readonly RenderSpan[];\n}\n\n/** What one span cost. A batched run is drawn when something closes it, so\n * its draw call counts toward the span that closed it. */\nexport interface RenderSpanStats {\n id: string;\n drawCalls: number;\n ms: number;\n}\n\n/** What one `render()` cost. See {@link WeaselRenderer.lastFrameStats}. */\nexport interface RenderStats {\n drawCalls: number;\n ms: number;\n spans: RenderSpanStats[];\n}\n\nfunction now(): number {\n return typeof performance !== 'undefined' ? performance.now() : Date.now();\n}\n\n/** Construction options for {@link WeaselRenderer}. Pass `gl` or `canvas`;\n * a context passed in must have a stencil buffer. */\nexport interface WeaselRendererOptions {\n /** A WebGL2 context to draw with. Wins over `canvas`. */\n gl?: WebGL2RenderingContext;\n /** A canvas to open a stencil-backed WebGL2 context on, when `gl` is absent.\n * The renderer sets its drawing buffer and never its CSS size. */\n canvas?: HTMLCanvasElement;\n /** Drawing size in CSS pixels. */\n width: number;\n /** Drawing size in CSS pixels. */\n height: number;\n /** Device pixels per CSS pixel. */\n dpr: number;\n /** MIN_FILTER strategy for image textures (`GLImageCache`). Default\n * `'linear'`. `'mipmap'` builds mipmaps for every image at upload, as\n * the headless `renderSceneToPixels` path does; `'auto'` builds them\n * for an image the first time a frame draws it at half size or smaller. */\n imageMinification?: ImageMinification;\n /** Flatness tolerance for curve tessellation, in WORLD units (see\n * `TessellateOptions.flattenTolerance`). When set, path fills are\n * tessellated fresh at this tolerance per frame (transient pool) instead\n * of served from the Path-identity mesh cache — the cache key does not\n * include tolerance. Default: unset — the existing cached behavior at\n * `DEFAULT_FLATTEN_TOLERANCE`. The headless path derives this from the\n * requested output scale; screen callers normally leave it unset. */\n flattenTolerance?: number;\n /** Per-render synchronous bake budget for dynamic canvas-SDF glyphs.\n * Default DEFAULT_BAKE_BUDGET (16). The headless renderSceneToPixels\n * path passes Infinity so print never defers a glyph. */\n bakeBudget?: number;\n /** On-screen glyph size, in CSS pixels, at or above which text renders from\n * tessellated font outlines instead of a distance field — see\n * `OUTLINE_MIN_SCREEN_PX`. Only faces registered with\n * `registerFontOutlines` are affected; everything else keeps its SDF tier\n * whatever this says. Pass `Infinity` to disable the tier outright, or 0\n * to use outlines wherever they exist (what the headless path does, since\n * print has no reason to sample a field it could evaluate exactly). */\n textOutlineMinScreenSize?: number;\n}\n\n/** Where a renderer draws inside a buffer it does not own.\n *\n * The rect's SIZE is the renderer's own `width`/`height` — `resize()` owns\n * that, and a second copy here could disagree with the one `DrawContext`\n * reports to screen-space layers. */\nexport interface RenderTarget {\n /** Top-left of this renderer's output within the drawing buffer, in CSS\n * pixels, with the origin at the buffer's top-left. GL's bottom-left origin\n * is handled internally. */\n origin: { x: number; y: number };\n /** Clear colour and stencil within the rect before drawing. Default true.\n * Pass false only when the caller clears the whole buffer itself on behalf\n * of every co-tenant — a frame that clears neither inherits its neighbour's\n * stencil bits, and even-odd fills then fill their holes. */\n clear?: boolean;\n}\n\n/** Each glyph-paint program's fragment stage and the uniforms it looks up. */\nconst GLYPH_PAINT_SOURCES: Record<GlyphPaintKind, readonly [string, readonly string[]]> = {\n pattern: [GLYPH_PATTERN_FRAG_SRC, GLYPH_PATTERN_UNIFORMS],\n gradient: [GLYPH_GRAD_FRAG_SRC, GLYPH_GRAD_UNIFORMS],\n texture: [GLYPH_TEXTURE_FRAG_SRC, GLYPH_TEXTURE_UNIFORMS],\n};\n\n/**\n * The WebGL2 renderer: takes a list of draw commands and paints them.\n *\n * It knows nothing about the scene — commands are the whole interface, which\n * is what lets layers, HUD widgets and overlays all draw through the same\n * pipeline. GPU resources (meshes, textures, gradient ramps) are cached across\n * frames and keyed by identity, so re-issuing the same command is cheap.\n */\nexport class WeaselRenderer {\n private readonly gl: WebGL2RenderingContext;\n private stats: RenderStats = { drawCalls: 0, ms: 0, spans: [] };\n /** Built on the first frame that draws with each, so a one-shot render of\n * plain shapes builds the batch program alone. */\n private readonly pathFill: LazyProgram;\n private readonly pathFillVColor: LazyProgram;\n private batchFill: ShaderProgram;\n private readonly batchFillMatrices: LazyProgram;\n private readonly gradFill: LazyProgram;\n private readonly patternFill: LazyProgram;\n /** Compiled on first use: only atlas text under a texture paint needs one. */\n private glyphPaintPrograms = new Map<GlyphPaintKind, ShaderProgram>();\n private meshCache: GLMeshCache;\n private textureCache: GLTextureCache;\n private imageCache: GLImageCache;\n private gradRamps: GradientRampAtlas;\n private programRegistry = new Map<string, ShaderProgram>();\n /** The source each compiled custom program was built from — or, after a\n * failed recompile, the source that failed, so it is not retried every frame. */\n private programSources = new Map<string, ProgramSource>();\n private quadVbo: WebGLBuffer | null = null;\n private quadIbo: WebGLBuffer | null = null;\n private drawBatch: DrawBatch;\n /** 1x1 white, so a batch flush sampling no image still samples something —\n * see `shaders/batchFill.ts`. */\n private whiteTexture: WebGLTexture | null = null;\n private readonly groupState = new GroupState();\n private widthCss: number;\n private heightCss: number;\n private dpr: number;\n private canvas: HTMLCanvasElement | null = null;\n /** Where context loss is announced: the context's own canvas, which the\n * renderer need not own the size of. */\n private lossTarget: EventTarget | null = null;\n private target: RenderTarget | null = null;\n /** Offscreen buffers for group effects. Allocates nothing until a group\n * with effects asks, so a canvas without them pays no memory. */\n private readonly effectTargets: EffectTargets;\n private readonly paintScratch: PaintScratch;\n private readonly imageMinification: ImageMinification;\n private flattenTolerance?: number;\n private readonly bakeBudget: number;\n private readonly textOutlineMinScreenSize: number;\n private contextLost = false;\n private boundOnLost = (e: Event) => this.onContextLost(e);\n private boundOnRestored = () => this.onContextRestored();\n /** True after `dispose()`. A disposed renderer ignores further `render()`\n * calls and `registerProgram()` calls. */\n private disposed = false;\n /** What registered paint kinds hang their GPU state on. One per context\n * generation: a restore releases it and opens the next. */\n private paintResources: OwnedPaintResources = createPaintResources();\n\n constructor(opts: WeaselRendererOptions) {\n if (!opts.gl && !opts.canvas) {\n throw new Error('WeaselRenderer requires either gl or canvas');\n }\n const gl = opts.gl ?? opts.canvas!.getContext('webgl2', { stencil: true });\n if (!gl) throw new Error('WeaselRenderer: WebGL2 not available');\n this.gl = gl as WebGL2RenderingContext;\n this.effectTargets = new EffectTargets(this.gl);\n this.paintScratch = new PaintScratch(this.gl);\n\n // Bits 0-7 are load-bearing: bit 0 for even-odd fills and stenciled\n // strokes, bits 1-7 for clip depth (`renderer/draw.ts`). Without a stencil\n // buffer both render wrong rather than not at all, so refuse the context\n // instead of painting a plausible lie. A stub that cannot answer is not a\n // stencil-less context — only an explicit `false` is.\n const attrs = typeof this.gl.getContextAttributes === 'function'\n ? this.gl.getContextAttributes()\n : null;\n if (attrs && attrs.stencil === false) {\n throw new Error(\n 'WeaselRenderer: the supplied WebGL2 context has no stencil buffer. '\n + 'Create it with { stencil: true } — clips and even-odd fills need one.',\n );\n }\n\n this.widthCss = opts.width;\n this.heightCss = opts.height;\n this.dpr = opts.dpr;\n this.imageMinification = opts.imageMinification ?? 'linear';\n this.flattenTolerance = opts.flattenTolerance;\n this.bakeBudget = opts.bakeBudget ?? DEFAULT_BAKE_BUDGET;\n this.textOutlineMinScreenSize = opts.textOutlineMinScreenSize ?? OUTLINE_MIN_SCREEN_PX;\n\n this.canvas = opts.canvas ?? null;\n if (this.canvas) {\n this.canvas.width = Math.round(opts.width * opts.dpr);\n this.canvas.height = Math.round(opts.height * opts.dpr);\n }\n const lossTarget: Partial<EventTarget> | null = this.canvas ?? this.gl.canvas ?? null;\n if (lossTarget && typeof lossTarget.addEventListener === 'function') {\n this.lossTarget = lossTarget as EventTarget;\n this.lossTarget.addEventListener('webglcontextlost', this.boundOnLost);\n this.lossTarget.addEventListener('webglcontextrestored', this.boundOnRestored);\n }\n\n this.applyGlState();\n this.applyTarget();\n\n this.pathFill = new LazyProgram(this.gl, PATH_FILL_SPEC);\n this.pathFillVColor = new LazyProgram(this.gl, PATH_FILL_VCOLOR_SPEC);\n this.gradFill = new LazyProgram(this.gl, GRAD_FILL_SPEC);\n this.patternFill = new LazyProgram(this.gl, PATTERN_FILL_SPEC);\n this.batchFillMatrices = new LazyProgram(this.gl, BATCH_FILL_MATRICES_SPEC);\n this.batchFill = createBatchFill(this.gl);\n\n this.meshCache = new GLMeshCache(this.gl);\n this.textureCache = new GLTextureCache(this.gl);\n this.imageCache = new GLImageCache(this.gl, this.imageMinification);\n this.gradRamps = new GradientRampAtlas(this.gl);\n this.uploadQuadGeometry();\n this.drawBatch = new DrawBatch(this.gl, this.batchFill);\n this.whiteTexture = createWhiteTexture(this.gl);\n }\n\n private lazyPrograms(): LazyProgram[] {\n return [this.pathFill, this.pathFillVColor, this.gradFill, this.patternFill, this.batchFillMatrices];\n }\n\n private uploadQuadGeometry(): void {\n const gl = this.gl;\n this.quadVbo = gl.createBuffer();\n this.quadIbo = gl.createBuffer();\n if (!this.quadVbo || !this.quadIbo) {\n throw new Error('WeaselRenderer: failed to create quad geometry buffers');\n }\n gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVbo);\n gl.bufferData(gl.ARRAY_BUFFER, QUAD_VERTICES, gl.STATIC_DRAW);\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.quadIbo);\n gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, QUAD_INDICES, gl.STATIC_DRAW);\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n }\n\n /**\n * Compile a consumer-registered shader program against this renderer's GL context.\n *\n * Optional: a program compiles on the first frame that draws with it. Call\n * this after the module-level `registerProgram()` to pay for the compile\n * before that frame, or to catch the `ShaderCompileError` it throws.\n *\n * In dev mode, calling again with the same handle replaces the compiled program.\n */\n registerProgram(handle: ShaderProgramHandle): void {\n // A disposed renderer must not compile programs into the cleared registry.\n if (this.disposed) return;\n const src = getProgramSource(handle.id);\n if (!src) {\n throw new Error(\n `WeaselRenderer.registerProgram: program \"${handle.id}\" not found in source registry. ` +\n `Call the module-level registerProgram() first.`,\n );\n }\n this.installProgram(handle.id, src, compileCustomProgram(this.gl, src));\n }\n\n private installProgram(id: string, src: ProgramSource, program: ShaderProgram): void {\n const previous = this.programRegistry.get(id);\n if (previous) this.gl.deleteProgram(previous.handle);\n this.programRegistry.set(id, program);\n this.programSources.set(id, src);\n }\n\n /** Recompile every program whose module-level source was re-registered\n * since it was compiled. A source that fails keeps the old program drawing. */\n private refreshPrograms(): void {\n for (const [id, compiled] of this.programSources) {\n const src = getProgramSource(id);\n if (!src || src === compiled) continue;\n if (src.vert === compiled.vert && src.frag === compiled.frag) {\n this.programSources.set(id, src);\n continue;\n }\n try {\n this.installProgram(id, src, compileCustomProgram(this.gl, src));\n } catch (e) {\n this.programSources.set(id, src);\n console.error(`weasel: failed to recompile re-registered program \"${id}\"; still drawing the previous one:`, e);\n }\n }\n }\n\n /**\n * The compiled program for `id`, compiling it against this context on first\n * use. Unlike {@link registerProgram} this neither throws on a missing\n * source nor on a compile failure: a paint kind asking for a program it\n * never registered must decline the paint, not take down the frame.\n */\n private ensureProgram(id: string): ShaderProgram | null {\n const existing = this.programRegistry.get(id);\n if (existing) return existing;\n if (this.disposed || !getProgramSource(id)) return null;\n try {\n this.registerProgram({ id });\n } catch (e) {\n console.error(`weasel: failed to compile paint program \"${id}\":`, e);\n return null;\n }\n return this.programRegistry.get(id) ?? null;\n }\n\n private glyphPaintProgram(kind: GlyphPaintKind): ShaderProgram {\n const existing = this.glyphPaintPrograms.get(kind);\n if (existing) return existing;\n const [frag, uniforms] = GLYPH_PAINT_SOURCES[kind];\n const program = new ShaderProgram(this.gl, GLYPH_PAINT_VERT_SRC, frag);\n program.lookupUniforms(uniforms);\n program.lookupAttributes(GLYPH_PAINT_ATTRIBUTES);\n this.glyphPaintPrograms.set(kind, program);\n return program;\n }\n\n /** The blend, depth, cull, clear-color, color-mask, VAO, and unpack-flip\n * state every frame assumes.\n * Applied per `render()` rather than once at construction because a\n * co-tenant sharing this context moves all of it between our frames. */\n private applyGlState(): void {\n const gl = this.gl;\n gl.enable(gl.BLEND);\n gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);\n gl.disable(gl.DEPTH_TEST);\n gl.disable(gl.CULL_FACE);\n gl.clearColor(0, 0, 0, 0);\n gl.colorMask(true, true, true, true);\n gl.bindVertexArray(null);\n gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);\n }\n\n /** This renderer's rect in device pixels, top-left origin. A tile rounds its\n * edges rather than its size, so two that share a CSS edge share a device one. */\n private deviceRect(): { x: number; y: number; width: number; height: number } {\n const ox = this.target?.origin.x ?? 0;\n const oy = this.target?.origin.y ?? 0;\n const x = Math.round(ox * this.dpr);\n const y = Math.round(oy * this.dpr);\n return {\n x,\n y,\n width: Math.round((ox + this.widthCss) * this.dpr) - x,\n height: Math.round((oy + this.heightCss) * this.dpr) - y,\n };\n }\n\n /** Viewport and scissor for this frame. Re-applied inside `render()` because\n * a co-tenant on the same context moves both between our frames. */\n private applyTarget(): void {\n const gl = this.gl;\n const { x, y, width, height } = this.deviceRect();\n if (!this.target) {\n gl.disable(gl.SCISSOR_TEST);\n gl.viewport(0, 0, width, height);\n return;\n }\n const glY = gl.drawingBufferHeight - y - height;\n gl.viewport(x, glY, width, height);\n gl.scissor(x, glY, width, height);\n gl.enable(gl.SCISSOR_TEST);\n }\n\n /** Confine this renderer to a rect of its drawing buffer, or pass null to\n * give it the whole buffer back. Takes effect from the next `render()`. */\n setTarget(target: RenderTarget | null): void {\n this.target = target;\n this.applyTarget();\n }\n\n getTarget(): RenderTarget | null {\n return this.target;\n }\n\n isContextLost(): boolean {\n return this.contextLost;\n }\n\n private onContextLost(e: Event): void {\n e.preventDefault();\n this.contextLost = true;\n }\n\n private onContextRestored(): void {\n this.contextLost = false;\n this.applyGlState();\n this.applyTarget();\n // Every framebuffer, texture and renderbuffer the pool held died with the\n // context. `releaseAll` deletes handles that are already gone, which is a\n // no-op, and drops the bookkeeping that would otherwise hand a dead FBO to\n // the next group with effects.\n this.effectTargets.releaseAll();\n this.paintScratch.release();\n this.paintResources.release();\n this.paintResources = createPaintResources();\n for (const lazy of this.lazyPrograms()) lazy.abandon();\n this.batchFill = createBatchFill(this.gl);\n this.glyphPaintPrograms.clear();\n this.meshCache = new GLMeshCache(this.gl);\n this.textureCache = new GLTextureCache(this.gl);\n this.imageCache.abandon();\n this.imageCache = new GLImageCache(this.gl, this.imageMinification);\n this.gradRamps = new GradientRampAtlas(this.gl);\n markAllFontsNotUploaded();\n\n this.uploadQuadGeometry();\n this.drawBatch = new DrawBatch(this.gl, this.batchFill);\n this.whiteTexture = createWhiteTexture(this.gl);\n for (const id of this.programRegistry.keys()) {\n const src = getProgramSource(id);\n if (!src) continue;\n try {\n this.programRegistry.set(id, compileCustomProgram(this.gl, src));\n this.programSources.set(id, src);\n } catch (e) {\n console.error(`weasel: failed to recompile program \"${id}\" after context restore:`, e);\n }\n }\n }\n\n /** Free every GL resource this renderer created and detach its\n * context-loss listeners. Idempotent. The context itself is left alone, so\n * a caller-owned context can host renderer after renderer without\n * accumulating anything.\n *\n * A disposed renderer ignores further `render()` and `registerProgram()`\n * calls. */\n dispose(): void {\n if (this.disposed) return;\n this.disposed = true;\n const gl = this.gl;\n if (this.lossTarget) {\n this.lossTarget.removeEventListener('webglcontextlost', this.boundOnLost);\n this.lossTarget.removeEventListener('webglcontextrestored', this.boundOnRestored);\n }\n this.meshCache.dispose();\n this.paintResources.release();\n for (const lazy of this.lazyPrograms()) lazy.release();\n for (const prog of [this.batchFill, ...this.glyphPaintPrograms.values()]) {\n gl.deleteProgram(prog.handle);\n }\n this.glyphPaintPrograms.clear();\n for (const prog of this.programRegistry.values()) {\n gl.deleteProgram(prog.handle);\n }\n this.programRegistry.clear();\n this.programSources.clear();\n this.textureCache.free();\n this.imageCache.dispose();\n this.gradRamps.free();\n if (this.quadVbo) gl.deleteBuffer(this.quadVbo);\n if (this.quadIbo) gl.deleteBuffer(this.quadIbo);\n this.drawBatch.dispose();\n if (this.whiteTexture) gl.deleteTexture(this.whiteTexture);\n this.whiteTexture = null;\n this.effectTargets.releaseAll();\n this.paintScratch.release();\n }\n\n /**\n * Draw one frame.\n *\n * `viewMatrix` is the frame's world→screen transform. It is only consulted\n * by `units: 'world'` gradients, which fall back to screen space without\n * it — every other command carries its own transform in the stream, so\n * callers with no view concept can keep calling `render(commands)`.\n */\n render(commands: DrawCommand[], viewMatrix?: GlMat3, opts?: RenderOptions): void {\n if (this.contextLost || this.disposed) return;\n const t0 = now();\n const counters = { drawCalls: 0 };\n const spanStats: RenderSpanStats[] = [];\n this.stats = { drawCalls: 0, ms: 0, spans: spanStats };\n const gl = this.gl;\n // Free GL resources whose Mesh was GC'd since the last frame. Done here,\n // before any draws, because GL state is known clean — deleting from the\n // FinalizationRegistry callback directly races a draw in flight.\n this.meshCache.drainPendingDeletes();\n this.imageCache.beginFrame();\n this.textureCache.sweep(textureRegistry);\n this.refreshPrograms();\n // New frame: refill the dynamic-glyph synchronous bake budget.\n resetBakeBudget(this.bakeBudget);\n // A frame that threw part-way never unwound: its group stack, its staged\n // vertices, the effect buffer it was drawing into, and whichever\n // offscreen buffer it had bound are all still here.\n this.groupState.reset();\n this.drawBatch.reset();\n this.effectTargets.reclaim();\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n this.applyGlState();\n this.applyTarget();\n // Ensure all stencil bits are cleared regardless of any mask left over\n // from the previous frame's clip ops.\n if (this.target?.clear !== false) {\n gl.stencilMask(0xFF);\n gl.clear(gl.COLOR_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);\n }\n const device = this.deviceRect();\n const { pathFill, pathFillVColor, gradFill, patternFill, batchFillMatrices } = this;\n const ctx: DrawContext = {\n gl,\n get pathFill() { return pathFill.get(); },\n get pathFillVColor() { return pathFillVColor.get(); },\n batchFill: this.batchFill,\n get batchFillMatrices() { return batchFillMatrices.get(); },\n get gradFill() { return gradFill.get(); },\n get patternFill() { return patternFill.get(); },\n meshCache: this.meshCache,\n textureCache: this.textureCache,\n imageCache: this.imageCache,\n gradRamps: this.gradRamps,\n programRegistry: this.programRegistry,\n ensureProgram: (id) => this.ensureProgram(id),\n glyphPaintProgram: (kind) => this.glyphPaintProgram(kind),\n quadVbo: this.quadVbo,\n quadIbo: this.quadIbo,\n drawBatch: this.drawBatch,\n whiteTexture: this.whiteTexture,\n state: this.groupState,\n widthCss: this.widthCss,\n heightCss: this.heightCss,\n clipDepth: 0,\n clipStack: [],\n flattenTolerance: this.flattenTolerance,\n textOutlineMinScreenSize: this.textOutlineMinScreenSize,\n viewMatrix,\n effectTargets: this.effectTargets,\n paintScratch: this.paintScratch,\n renderTarget: null,\n deviceWidth: device.width,\n deviceHeight: device.height,\n restoreTargetRect: () => this.applyTarget(),\n paintResources: this.paintResources,\n stats: counters,\n };\n // A frame that threw part-way left its clip here.\n this.drawBatch.clip = null;\n const spans = opts?.spans ?? [];\n let next = 0;\n for (let si = 0; si < spans.length; si++) {\n const span = spans[si];\n for (; next < span.start; next++) dispatch(ctx, commands[next]);\n const drawsBefore = counters.drawCalls;\n const spanT0 = now();\n for (; next < span.end; next++) dispatch(ctx, commands[next]);\n // The stream's closing flush belongs to whatever it closes.\n if (si === spans.length - 1 && next >= commands.length) flushBatch(ctx);\n spanStats.push({ id: span.id, drawCalls: counters.drawCalls - drawsBefore, ms: now() - spanT0 });\n }\n for (; next < commands.length; next++) dispatch(ctx, commands[next]);\n // The stream ended, so whatever is still staged has nothing left that\n // could merge with it.\n flushBatch(ctx);\n // Free transient resources allocated during this frame (e.g. per-frame\n // stroke ribbons from tessellateStroke). Done after all draws complete\n // so we never delete a buffer that's still bound to a pending draw.\n this.meshCache.freeTransient();\n this.stats.drawCalls = counters.drawCalls;\n this.stats.ms = now() - t0;\n }\n\n /** What the last `render()` cost: GL draw calls issued and CPU milliseconds\n * spent issuing them, in total and per requested span. GPU time is not\n * measured; the GPU runs asynchronously. */\n lastFrameStats(): RenderStats {\n return this.stats;\n }\n\n /** Change the curve-flattening tolerance after construction. `undefined`\n * restores the cached `DEFAULT_FLATTEN_TOLERANCE` route. */\n setFlattenTolerance(tolerance: number | undefined): void {\n this.flattenTolerance = tolerance;\n }\n\n resize(dims: { width: number; height: number; dpr: number }): void {\n this.widthCss = dims.width;\n this.heightCss = dims.height;\n this.dpr = dims.dpr;\n if (this.canvas) {\n this.canvas.width = Math.round(dims.width * dims.dpr);\n this.canvas.height = Math.round(dims.height * dims.dpr);\n }\n this.applyTarget();\n }\n\n /** @internal */ _gl(): WebGL2RenderingContext { return this.gl; }\n /** @internal */ _pathFill(): ShaderProgram { return this.pathFill.get(); }\n /** @internal */ _pathFillVColor(): ShaderProgram { return this.pathFillVColor.get(); }\n /** @internal */ _drawBatch(): DrawBatch { return this.drawBatch; }\n /** @internal */ _batchFill(): ShaderProgram { return this.batchFill; }\n /** @internal */ _batchFillMatrices(): ShaderProgram { return this.batchFillMatrices.get(); }\n /** @internal */ _gradFill(): ShaderProgram { return this.gradFill.get(); }\n /** @internal */ _patternFill(): ShaderProgram { return this.patternFill.get(); }\n /** @internal */ _meshCache(): GLMeshCache { return this.meshCache; }\n /** @internal */ _textureCache(): GLTextureCache { return this.textureCache; }\n /** @internal */ _imageCache(): GLImageCache { return this.imageCache; }\n /** @internal */ _gradRamps(): GradientRampAtlas { return this.gradRamps; }\n /** @internal */ _groupState(): GroupState { return this.groupState; }\n /** @internal */ _widthCss(): number { return this.widthCss; }\n /** @internal */ _heightCss(): number { return this.heightCss; }\n /** @internal */ _dpr(): number { return this.dpr; }\n}\n\n/** The 1x1 opaque white texture a batch flush binds when its run samples no\n * image. NEAREST both ways: one texel, so there is nothing to filter, and a\n * mipmap filter on a texture with no mipmaps is incomplete. */\nfunction createWhiteTexture(gl: WebGL2RenderingContext): WebGLTexture | null {\n const tex = gl.createTexture();\n if (!tex) return null;\n gl.bindTexture(gl.TEXTURE_2D, tex);\n gl.texImage2D(\n gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,\n new Uint8Array([255, 255, 255, 255]),\n );\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.bindTexture(gl.TEXTURE_2D, null);\n return tex;\n}\n","/**\n * Uniform-grid sprite sheet layout — frame index to the source rect an\n * `ImageDrawCommand` samples. Pure arithmetic over the grid description; it\n * never touches the bitmap.\n */\n\n/** A sprite sheet's grid. `margin` and `spacing` follow the Tiled / Aseprite\n * tileset convention, so a sheet exported from either describes itself here. */\nexport interface SpriteSheet {\n frameWidth: number;\n frameHeight: number;\n columns: number;\n /** Empty pixels around the whole grid. Default 0. */\n margin?: number;\n /** Empty pixels between adjacent cells — the gutter that keeps linear\n * sampling off the neighboring frame. Default 0. */\n spacing?: number;\n}\n\n/**\n * Row-major source rect for frame `index`, counting from 0 at the top-left.\n *\n * `index` is not range-checked and does not wrap: past the last cell this\n * returns a rect below the sheet, which draws as an edge smear. Wrapping is\n * the animation's business (`frameRect(sheet, tick % count)`) — a sheet does\n * not know how many of its cells are filled.\n */\nexport function frameRect(\n sheet: SpriteSheet,\n index: number,\n): { x: number; y: number; w: number; h: number } {\n const { frameWidth, frameHeight, columns } = sheet;\n const margin = sheet.margin ?? 0;\n const spacing = sheet.spacing ?? 0;\n const col = index % columns;\n const row = Math.floor(index / columns);\n return {\n x: margin + col * (frameWidth + spacing),\n y: margin + row * (frameHeight + spacing),\n w: frameWidth,\n h: frameHeight,\n };\n}\n","import { type Path, mat3, type GlMat3 } from '@weasel-js/geom';\nimport { resolveScreenLength, type Stroke } from '@weasel-js/paint';\nimport { SPRITE_STRIDE, type DrawCommand } from './DrawCommand';\nimport { resolveStrokeWidth } from '@weasel-js/stroke';\nimport { markerReach } from '@weasel-js/stroke';\nimport { isOwnComposite } from './effects/compositeOp';\n\n/** A screen-space rectangle, CSS pixels. */\nexport interface CullRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Screen pixels added to every bound: antialiasing, and the 1/8 px a `{ px }`\n * stroke's width may drift through quantization. */\nconst SLACK_PX = 1;\n\n/** Matches the tessellator's default. */\nconst DEFAULT_MITER_LIMIT = 4;\n\n/**\n * `cmds` without the commands that cannot put a pixel inside `rect`, where\n * `transform` maps the commands' space to screen space — `viewToMat3(view)`\n * for a world-space layer.\n *\n * Conservative by construction: a command is dropped only when a bound that\n * encloses everything it can paint misses `rect`. Paths are bounded by their\n * control hull plus the farthest a stroke can reach (miter spikes and square\n * caps included), images and sprites by their quads, and every bound is taken\n * through the accumulated transform as the AABB of its corners, so rotation\n * only enlarges it. Text and shader commands are always kept, and so is a\n * group with `effects` — an effect may move pixels — or its own `composite`,\n * which changes the destination even where the group drew nothing. Clips are ignored, which\n * can only keep more. A group whose children all go is dropped.\n *\n * Returns `cmds` itself when nothing was dropped.\n */\nexport function cullDrawCommands(\n cmds: DrawCommand[],\n transform: GlMat3,\n rect: CullRect,\n): DrawCommand[] {\n return cullList(cmds, transform, slackBox(rect));\n}\n\ninterface Box { minX: number; minY: number; maxX: number; maxY: number }\n\nfunction cullList(cmds: DrawCommand[], m: GlMat3, box: Box): DrawCommand[] {\n let out: DrawCommand[] | null = null;\n for (let i = 0; i < cmds.length; i++) {\n const cmd = cmds[i];\n const kept = cullOne(cmd, m, box);\n if (kept === cmd) {\n out?.push(cmd);\n continue;\n }\n out ??= cmds.slice(0, i);\n if (kept) out.push(kept);\n }\n return out ?? cmds;\n}\n\nfunction cullOne(cmd: DrawCommand, m: GlMat3, box: Box): DrawCommand | null {\n switch (cmd.kind) {\n case 'group': {\n if (cmd.effects && cmd.effects.length > 0) return cmd;\n if (isOwnComposite(cmd.composite)) return cmd;\n const inner = cmd.transform ? mat3.multiply(m, cmd.transform) : m;\n const children = cullList(cmd.children, inner, box);\n if (children === cmd.children) return cmd;\n return children.length === 0 ? null : { ...cmd, children };\n }\n case 'path':\n return pathMisses(cmd.path, cmd.stroke, m, box) ? null : cmd;\n case 'image':\n return quadMisses(cmd.x, cmd.y, cmd.x + cmd.w, cmd.y + cmd.h, m, box) ? null : cmd;\n case 'sprites':\n return spritesMiss(cmd.sprites, m, box) ? null : cmd;\n default:\n return cmd;\n }\n}\n\nfunction pathMisses(path: Path, stroke: Stroke | undefined, m: GlMat3, box: Box): boolean {\n let minX: number, minY: number, maxX: number, maxY: number;\n if (path.kind === 'rect') {\n minX = Math.min(path.x, path.x + path.width);\n maxX = Math.max(path.x, path.x + path.width);\n minY = Math.min(path.y, path.y + path.height);\n maxY = Math.max(path.y, path.y + path.height);\n } else if (path.kind === 'polygon') {\n const c = path.coords;\n if (c.length < 2) return false;\n minX = maxX = c[0];\n minY = maxY = c[1];\n for (let i = 2; i + 1 < c.length; i += 2) {\n const x = c[i], y = c[i + 1];\n if (x < minX) minX = x; else if (x > maxX) maxX = x;\n if (y < minY) minY = y; else if (y > maxY) maxY = y;\n }\n } else {\n return false;\n }\n const reach = stroke ? strokeReach(stroke, m) : 0;\n return quadMisses(minX - reach, minY - reach, maxX + reach, maxY + reach, m, box);\n}\n\n/** How far outside the geometry a stroke can paint, in the path's own units.\n * A full width rather than half covers `'outer'` alignment, which the\n * renderer draws as a doubled ribbon; the miter limit covers every join. A\n * marker head sits on a vertex, so its reach is measured from the hull too. */\nfunction strokeReach(stroke: Stroke, m: GlMat3): number {\n return strokeReachAt(stroke, mat3.meanScaleOf(m), mat3.minScaleOf(m));\n}\n\n/**\n * How far a stroke reaches past its geometry at a known world-to-screen scale — what a painter\n * bounding its own output before it paints can know. `least` is the scale\n * along the axis the transform shrinks most, where it differs from `scale`.\n *\n * A `{ px }` ribbon or head is built to its screen size in every direction,\n * so in world it reaches farthest along that axis. A head with a world size is\n * built in world, whatever the line's width is in.\n */\nexport function strokeReachAt(stroke: Stroke, scale: number, least = scale): number {\n const at = least > 0 ? least : scale;\n const base = resolveStrokeWidth(stroke.width ?? 1, typeof stroke.width === 'object' ? at : scale);\n let width = base;\n if (stroke.vertexWidths) {\n for (const v of stroke.vertexWidths) if (v > width) width = v;\n }\n const spike = Math.max(stroke.miterLimit ?? DEFAULT_MITER_LIMIT, Math.SQRT2);\n const heads = markerReach(stroke);\n return Math.max(Math.abs(width) * spike, heads.world, resolveScreenLength({ px: heads.px }, at));\n}\n\nfunction spritesMiss(sprites: Float32Array, m: GlMat3, box: Box): boolean {\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (let i = 0; i + SPRITE_STRIDE <= sprites.length; i += SPRITE_STRIDE) {\n const x0 = sprites[i], y0 = sprites[i + 1];\n const x1 = x0 + sprites[i + 2], y1 = y0 + sprites[i + 3];\n minX = Math.min(minX, x0, x1); maxX = Math.max(maxX, x0, x1);\n minY = Math.min(minY, y0, y1); maxY = Math.max(maxY, y0, y1);\n }\n if (minX === Infinity) return false;\n return quadMisses(minX, minY, maxX, maxY, m, box);\n}\n\n/**\n * True when `bounds`, taken through `transform` to screen space, cannot put a\n * pixel inside `rect` — the per-command test above, for a caller holding a box\n * rather than a command. Same slack, same NaN-keeps rule.\n */\nexport function boundsMissRect(\n bounds: { x: number; y: number; width: number; height: number },\n transform: GlMat3,\n rect: CullRect,\n): boolean {\n const x0 = Math.min(bounds.x, bounds.x + bounds.width);\n const x1 = Math.max(bounds.x, bounds.x + bounds.width);\n const y0 = Math.min(bounds.y, bounds.y + bounds.height);\n const y1 = Math.max(bounds.y, bounds.y + bounds.height);\n return quadMisses(x0, y0, x1, y1, transform, slackBox(rect));\n}\n\nfunction slackBox(rect: CullRect): Box {\n return {\n minX: rect.x - SLACK_PX,\n minY: rect.y - SLACK_PX,\n maxX: rect.x + rect.width + SLACK_PX,\n maxY: rect.y + rect.height + SLACK_PX,\n };\n}\n\n/** True when the local rect, taken through `m`, lies wholly outside `box`.\n * Any NaN makes every comparison false, so the command is kept. */\nfunction quadMisses(x0: number, y0: number, x1: number, y1: number, m: GlMat3, box: Box): boolean {\n const [ax, ay] = mat3.apply(m, x0, y0);\n const [bx, by] = mat3.apply(m, x1, y0);\n const [cx, cy] = mat3.apply(m, x1, y1);\n const [dx, dy] = mat3.apply(m, x0, y1);\n return (\n Math.max(ax, bx, cx, dx) < box.minX ||\n Math.min(ax, bx, cx, dx) > box.maxX ||\n Math.max(ay, by, cy, dy) < box.minY ||\n Math.min(ay, by, cy, dy) > box.maxY\n );\n}\n","import { registerProgram, type ShaderProgramHandle, type ShaderUniform } from '../shaders/registerProgram';\nimport { EFFECT_VERT_SRC } from './effectPrelude';\n\n/**\n * One full-screen pass over what a group has already drawn. A group's effects\n * run in order, each reading the previous one's output through `u_source`.\n *\n * `uniforms` are the effect's own; `u_source`, `u_resolution`, and `u_texel`\n * come from the renderer and must not be passed here.\n */\nexport interface Effect {\n program: ShaderProgramHandle;\n uniforms?: Record<string, ShaderUniform>;\n}\n\n/**\n * Register a fragment shader as an effect. An effect registered through\n * `registerProgram` with the *custom-shader* vertex shader compiles, runs, and\n * samples its source upside down.\n *\n * The fragment shader reads `v_uv` and `u_source`, may declare `u_resolution` /\n * `u_texel`, and must write premultiplied alpha. See `effectPrelude.ts`.\n *\n * @experimental\n */\nexport function registerEffect(id: string, frag: string): ShaderProgramHandle {\n return registerProgram(id, EFFECT_VERT_SRC, frag);\n}\n","/**\n * Effects that ship with the kit.\n *\n * Each is a function returning `Effect[]`, not a single `Effect`, because a\n * separable kernel is genuinely two passes and hiding that behind one entry\n * would make the cost invisible at the callsite:\n *\n * effects={[...blur({ radius: 4 }), ...vignette({ amount: 0.6 })]}\n */\nimport type { Effect } from './types';\nimport { registerEffect } from './types';\n\nconst BLUR_FRAG = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_uv;\nuniform sampler2D u_source;\nuniform vec2 u_texel;\nuniform vec2 u_direction;\nuniform float u_radius;\nout vec4 outColor;\n\nvoid main() {\n // Nine taps on a Gaussian, spread across the requested radius. The weights\n // are a normalized binomial row, so a radius of 0 collapses to a copy.\n const float W[5] = float[5](0.2270270, 0.1945946, 0.1216216, 0.0540541, 0.0162162);\n vec2 step = u_direction * u_texel * (u_radius / 4.0);\n vec4 sum = texture(u_source, v_uv) * W[0];\n for (int i = 1; i < 5; i++) {\n vec2 off = step * float(i);\n sum += texture(u_source, v_uv + off) * W[i];\n sum += texture(u_source, v_uv - off) * W[i];\n }\n outColor = sum;\n}\n`;\n\nconst VIGNETTE_FRAG = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_uv;\nuniform sampler2D u_source;\nuniform float u_amount;\nuniform float u_feather;\nout vec4 outColor;\n\nvoid main() {\n vec4 src = texture(u_source, v_uv);\n float d = distance(v_uv, vec2(0.5)) * 1.41421356;\n float shade = 1.0 - u_amount * smoothstep(1.0 - u_feather, 1.0, d);\n // Premultiplied in, premultiplied out: scaling all four channels darkens\n // toward transparent black, which is what a vignette over a transparent\n // canvas should do.\n outColor = src * shade;\n}\n`;\n\nconst BLUR = registerEffect('weasel:blur', BLUR_FRAG);\nconst VIGNETTE = registerEffect('weasel:vignette', VIGNETTE_FRAG);\n\n/**\n * Gaussian blur, as a horizontal pass followed by a vertical one.\n *\n * `radius` is in device pixels and is the distance of the outermost tap, not a\n * standard deviation — 0 is a copy, and the falloff is the same nine-tap\n * kernel at every radius, so a large one is a wide blur rather than a better\n * one. Two passes at O(9) beat one at O(81) and look the same.\n */\nexport function blur({ radius }: { radius: number }): Effect[] {\n return [\n { program: BLUR, uniforms: { u_direction: [1, 0], u_radius: radius } },\n { program: BLUR, uniforms: { u_direction: [0, 1], u_radius: radius } },\n ];\n}\n\n/**\n * Darken toward the corners. `amount` is how dark the corner gets (0..1) and\n * `feather` how much of the radius the falloff occupies.\n */\nexport function vignette(\n { amount, feather = 0.6 }: { amount: number; feather?: number },\n): Effect[] {\n return [{ program: VIGNETTE, uniforms: { u_amount: amount, u_feather: feather } }];\n}\n","/**\n * Build a `TextDrawCommand`. `textCommandFromPose` is the command for a text\n * node; `textCommand` takes a plain string and wraps it in one run;\n * `textCommandFromRuns` takes the styled runs directly, for text that has no\n * pose. All three resolve through `resolveTextStyle` + `resolveRuns` — a\n * caller that assembles the command by hand is one field away from a\n * silently different result.\n *\n * `paint` is the node's `data.fill` / `data.stroke`. A caller with no node —\n * a HUD widget, a debug overlay — states its color on the run instead.\n *\n * `scale` is the view scale a `{ px }` `fontSize` or `letterSpacing` resolves\n * against — for a world-space layer, the mean of `view.scale.x` and\n * `view.scale.y`. It has to be applied here and not at draw time, because a\n * screen-pixel size moves the glyph advances and so the wrap points.\n */\n\nimport type { DrawCommand, TextDrawCommand } from './index';\nimport type { TextPaint, TextPose, TextStyle } from '@weasel-js/text';\nimport { resolveTextStyle, textPoseLayoutInput } from '@weasel-js/text';\nimport { resolveRuns } from '@weasel-js/text';\nimport type { StyledRun } from '@weasel-js/text';\nimport type { TextVerticalAlign, ResolvedRun } from '@weasel-js/text';\nimport { isSolidPaint, type Paint } from '@weasel-js/paint';\nimport type { FillPoseBox } from './fillInPoseFrame';\nimport { commandFill, commandPaint } from './patterns/commandPaint';\n\n/** Build a draw command from styled runs, for text with no pose. `style`\n * supplies the defaults each run inherits; the rest match `textCommand`. */\nexport function textCommandFromRuns(\n x: number,\n y: number,\n runs: readonly StyledRun[],\n style?: TextStyle,\n maxWidth?: number,\n height?: number,\n verticalAlign?: TextVerticalAlign,\n paint?: TextPaint,\n width?: number,\n scale = 1,\n): DrawCommand {\n const resolved = resolveTextStyle(style, paint, scale);\n return {\n kind: 'text',\n x,\n y,\n runs: resolveRuns(runs, resolved, scale),\n align: resolved.align,\n direction: resolved.direction,\n justify: resolved.align === 'justify',\n maxWidth,\n style: style ?? {},\n height,\n verticalAlign,\n width,\n };\n}\n\n/** Build a draw command for a single unstyled string. Text is laid out with\n * the registered font's metrics, wrapped at `maxWidth`, aligned across\n * `width` (default `maxWidth`) and within `height` when `verticalAlign` is\n * given. */\nexport function textCommand(\n x: number,\n y: number,\n text: string,\n style?: TextStyle,\n maxWidth?: number,\n height?: number,\n verticalAlign?: TextVerticalAlign,\n paint?: TextPaint,\n width?: number,\n scale = 1,\n): DrawCommand {\n return textCommandFromRuns(\n x, y, [{ text }], style, maxWidth, height, verticalAlign, paint, width, scale,\n );\n}\n\n/**\n * The draw command for a text pose. Its wrap width, alignment box and runs\n * come from `textPoseLayoutInput`, so the renderer lays it out into exactly\n * the lines `layoutTextPose` reports for the same pose.\n *\n * Each run's paints are resolved against the pose box the way every other\n * node's are — a `'bounds'` paint mapped onto it, a pattern spec swapped for\n * its texture — since the renderer can do neither.\n */\nexport function textCommandFromPose(pose: TextPose, scale = 1): TextDrawCommand {\n const { runs, opts } = textPoseLayoutInput(pose, scale);\n return {\n kind: 'text',\n x: pose.x,\n y: pose.y,\n runs: runsInPoseFrame(runs, pose),\n align: opts.align,\n direction: opts.direction,\n justify: opts.justify,\n maxWidth: opts.maxWidth,\n width: opts.alignWidth,\n style: pose.style ?? {},\n height: pose.height,\n verticalAlign: pose.verticalAlign,\n };\n}\n\nfunction runsInPoseFrame(runs: ResolvedRun[], box: FillPoseBox): ResolvedRun[] {\n if (runs.every((r) => isSolid(r.fill?.paint) && isSolid(r.stroke?.paint))) return runs;\n return runs.map((r) => {\n const fill = r.fill && commandFill(r.fill, box);\n const paint = r.stroke?.paint && commandPaint(r.stroke.paint, box);\n return { ...r, fill, stroke: r.stroke && { ...r.stroke, paint: paint || undefined } };\n });\n}\n\nfunction isSolid(paint: Paint | null | undefined): boolean {\n return paint == null || isSolidPaint(paint);\n}\n"]}