ultra-text 1.0.1 → 1.0.3
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/README.md +339 -1039
- package/dist/assets/cpuSdf.worker-Dy4P5_TI.js +466 -0
- package/dist/assets/cpuSdf.worker-Dy4P5_TI.js.map +1 -0
- package/dist/assets/traceOutline.worker-B5uVKmR4.js +1725 -0
- package/dist/assets/traceOutline.worker-B5uVKmR4.js.map +1 -0
- package/dist/atlas/appendAtlas.js +97 -31
- package/dist/atlas/appendAtlas.js.map +1 -1
- package/dist/atlas/buildAtlas.js +4 -3
- package/dist/atlas/buildAtlas.js.map +1 -1
- package/dist/atlas/colorGlyphs.d.ts +0 -10
- package/dist/atlas/colorGlyphs.js +97 -155
- package/dist/atlas/colorGlyphs.js.map +1 -1
- package/dist/atlas/colorTexture.d.ts +1 -0
- package/dist/atlas/colorTexture.js +64 -0
- package/dist/atlas/colorTexture.js.map +1 -0
- package/dist/atlas/cpuAtlas.d.ts +4 -1
- package/dist/atlas/cpuAtlas.js +14 -7
- package/dist/atlas/cpuAtlas.js.map +1 -1
- package/dist/atlas/cpuSdf.d.ts +1 -1
- package/dist/atlas/cpuSdf.js +235 -68
- package/dist/atlas/cpuSdf.js.map +1 -1
- package/dist/atlas/cpuWorker.d.ts +11 -3
- package/dist/atlas/cpuWorker.js +179 -22
- package/dist/atlas/cpuWorker.js.map +1 -1
- package/dist/atlas/gpuAtlas.js +188 -287
- package/dist/atlas/gpuAtlas.js.map +1 -1
- package/dist/atlas/gpuCommon.d.ts +257 -0
- package/dist/atlas/gpuCommon.js +845 -0
- package/dist/atlas/gpuCommon.js.map +1 -0
- package/dist/atlas/jfaWgsl.d.ts +1 -1
- package/dist/atlas/jfaWgsl.js +226 -249
- package/dist/atlas/jfaWgsl.js.map +1 -1
- package/dist/atlas/rasterize.d.ts +22 -0
- package/dist/atlas/rasterize.js +329 -158
- package/dist/atlas/rasterize.js.map +1 -1
- package/dist/atlas/shapeRaster.js +2 -1
- package/dist/atlas/shapeRaster.js.map +1 -1
- package/dist/atlas/vanillaBounds.d.ts +64 -0
- package/dist/atlas/vanillaBounds.js +42 -0
- package/dist/atlas/vanillaBounds.js.map +1 -0
- package/dist/atlas/vanillaCore.d.ts +100 -0
- package/dist/atlas/vanillaCore.js +1065 -0
- package/dist/atlas/vanillaCore.js.map +1 -0
- package/dist/atlas/vanillaCpuAtlas.d.ts +9 -0
- package/dist/atlas/vanillaCpuAtlas.js +72 -0
- package/dist/atlas/vanillaCpuAtlas.js.map +1 -0
- package/dist/atlas/vanillaExtras.d.ts +8 -0
- package/dist/atlas/vanillaExtras.js +167 -0
- package/dist/atlas/vanillaExtras.js.map +1 -0
- package/dist/atlas/vanillaGpuHelpers.d.ts +295 -0
- package/dist/atlas/vanillaGpuHelpers.js +354 -0
- package/dist/atlas/vanillaGpuHelpers.js.map +1 -0
- package/dist/dom/DomSdf.js +243 -297
- package/dist/dom/DomSdf.js.map +1 -1
- package/dist/dom/DomSlug.js +94 -165
- package/dist/dom/DomSlug.js.map +1 -1
- package/dist/dom/Text.d.ts +4 -1
- package/dist/dom/Text.js +5 -1
- package/dist/dom/Text.js.map +1 -1
- package/dist/dom/browserShaping.js +31 -14
- package/dist/dom/browserShaping.js.map +1 -1
- package/dist/dom/clusters.js +13 -2
- package/dist/dom/clusters.js.map +1 -1
- package/dist/dom/cssEffects.d.ts +4 -0
- package/dist/dom/cssEffects.js +72 -0
- package/dist/dom/cssEffects.js.map +1 -0
- package/dist/dom/domAnalytic.d.ts +53 -0
- package/dist/dom/domAnalytic.js +282 -0
- package/dist/dom/domAnalytic.js.map +1 -0
- package/dist/dom/domExtras.d.ts +27 -0
- package/dist/dom/domExtras.js +137 -0
- package/dist/dom/domExtras.js.map +1 -0
- package/dist/dom/fontCanvas.d.ts +16 -0
- package/dist/dom/fontCanvas.js +31 -13
- package/dist/dom/fontCanvas.js.map +1 -1
- package/dist/dom/layoutSignature.js +175 -57
- package/dist/dom/layoutSignature.js.map +1 -1
- package/dist/dom/markup.d.ts +10 -0
- package/dist/dom/markup.js +16 -1
- package/dist/dom/markup.js.map +1 -1
- package/dist/dom/pretextLayout.js +78 -28
- package/dist/dom/pretextLayout.js.map +1 -1
- package/dist/dom/snapshot.d.ts +4 -0
- package/dist/dom/snapshot.js +891 -484
- package/dist/dom/snapshot.js.map +1 -1
- package/dist/dom/snapshotsEqual.d.ts +7 -0
- package/dist/dom/snapshotsEqual.js +68 -0
- package/dist/dom/snapshotsEqual.js.map +1 -0
- package/dist/dom/svgCapture.d.ts +8 -1
- package/dist/dom/svgCapture.js +105 -28
- package/dist/dom/svgCapture.js.map +1 -1
- package/dist/dom/textTransform.d.ts +13 -1
- package/dist/dom/textTransform.js +31 -13
- package/dist/dom/textTransform.js.map +1 -1
- package/dist/dom/tone.js +91 -44
- package/dist/dom/tone.js.map +1 -1
- package/dist/index.js +4 -3
- package/dist/slug/SlugMaterial.d.ts +17 -3
- package/dist/slug/SlugMaterial.js +98 -26
- package/dist/slug/SlugMaterial.js.map +1 -1
- package/dist/slug/cff.d.ts +5 -0
- package/dist/slug/cff.js +780 -0
- package/dist/slug/cff.js.map +1 -0
- package/dist/slug/coverage.d.ts +19 -15
- package/dist/slug/coverage.js +380 -225
- package/dist/slug/coverage.js.map +1 -1
- package/dist/slug/preprocessCore.d.ts +6 -2
- package/dist/slug/preprocessCore.js +199 -148
- package/dist/slug/preprocessCore.js.map +1 -1
- package/dist/slug/runtime.d.ts +1 -0
- package/dist/slug/runtime.js +113 -74
- package/dist/slug/runtime.js.map +1 -1
- package/dist/slug/standaloneRuntime.d.ts +3 -2
- package/dist/slug/standaloneRuntime.js +112 -67
- package/dist/slug/standaloneRuntime.js.map +1 -1
- package/dist/slug/truetype.d.ts +14 -6
- package/dist/slug/truetype.js +356 -255
- package/dist/slug/truetype.js.map +1 -1
- package/dist/slug/vanillaCore.d.ts +410 -0
- package/dist/slug/vanillaCore.js +1630 -0
- package/dist/slug/vanillaCore.js.map +1 -0
- package/dist/slug-vanilla.d.ts +13 -364
- package/dist/slug-vanilla.js +7 -1454
- package/dist/slug.d.ts +2 -2
- package/dist/slug.js +7 -7
- package/dist/text/GlyphTextMaterial.d.ts +6 -1
- package/dist/text/GlyphTextMaterial.js +16 -12
- package/dist/text/GlyphTextMaterial.js.map +1 -1
- package/dist/text/RectMaterial.js +6 -10
- package/dist/text/RectMaterial.js.map +1 -1
- package/dist/text/SdfTextMaterial.d.ts +9 -3
- package/dist/text/SdfTextMaterial.js +125 -38
- package/dist/text/SdfTextMaterial.js.map +1 -1
- package/dist/text/decorations.d.ts +7 -2
- package/dist/text/decorations.js +187 -79
- package/dist/text/decorations.js.map +1 -1
- package/dist/text/geometry.d.ts +3 -22
- package/dist/text/geometryUtils.d.ts +16 -1
- package/dist/text/geometryUtils.js +83 -8
- package/dist/text/geometryUtils.js.map +1 -1
- package/dist/text/glyphGeometry.d.ts +9 -0
- package/dist/text/glyphGeometry.js +434 -0
- package/dist/text/glyphGeometry.js.map +1 -0
- package/dist/text/index.d.ts +2 -1
- package/dist/text/rectGeometry.d.ts +13 -0
- package/dist/text/rectGeometry.js +101 -0
- package/dist/text/rectGeometry.js.map +1 -0
- package/dist/text/reflow.d.ts +23 -1
- package/dist/text/reflow.js +223 -94
- package/dist/text/reflow.js.map +1 -1
- package/dist/text/snap.d.ts +15 -0
- package/dist/text/snap.js +26 -0
- package/dist/text/snap.js.map +1 -0
- package/dist/text/tone.js +2 -2
- package/dist/text/tone.js.map +1 -1
- package/dist/types.d.ts +23 -7
- package/dist/vanilla.d.ts +13 -363
- package/dist/vanilla.js +7 -1474
- package/dist/windfoil/WindfoilCompositeMaterial.d.ts +1 -1
- package/dist/windfoil/WindfoilCompositeMaterial.js +10 -3
- package/dist/windfoil/WindfoilCompositeMaterial.js.map +1 -1
- package/dist/windfoil/WindfoilMaterial.d.ts +12 -5
- package/dist/windfoil/WindfoilMaterial.js +71 -8
- package/dist/windfoil/WindfoilMaterial.js.map +1 -1
- package/dist/windfoil/compositeGeometry.js +12 -5
- package/dist/windfoil/compositeGeometry.js.map +1 -1
- package/dist/windfoil/coverage.d.ts +10 -2
- package/dist/windfoil/coverage.js +147 -59
- package/dist/windfoil/coverage.js.map +1 -1
- package/dist/windfoil/geometry.d.ts +17 -2
- package/dist/windfoil/geometry.js +220 -57
- package/dist/windfoil/geometry.js.map +1 -1
- package/dist/windfoil/layerGrid.js +8 -8
- package/dist/windfoil/layerGrid.js.map +1 -1
- package/dist/windfoil/mixed.d.ts +1 -0
- package/dist/windfoil/mixed.js +57 -29
- package/dist/windfoil/mixed.js.map +1 -1
- package/dist/windfoil/preprocess.js +2 -2
- package/dist/windfoil/preprocessCore.d.ts +2 -0
- package/dist/windfoil/preprocessCore.js +69 -37
- package/dist/windfoil/preprocessCore.js.map +1 -1
- package/dist/windfoil/requests.d.ts +1 -1
- package/dist/windfoil/requests.js +11 -4
- package/dist/windfoil/requests.js.map +1 -1
- package/dist/windfoil/resolveOutline.d.ts +9 -0
- package/dist/windfoil/resolveOutline.js +20 -0
- package/dist/windfoil/resolveOutline.js.map +1 -0
- package/dist/windfoil/runtime.d.ts +4 -1
- package/dist/windfoil/runtime.js +69 -63
- package/dist/windfoil/runtime.js.map +1 -1
- package/dist/windfoil/shapeGeometry.js +80 -34
- package/dist/windfoil/shapeGeometry.js.map +1 -1
- package/dist/windfoil/sizeSwitch.d.ts +1 -1
- package/dist/windfoil/sizeSwitch.js +13 -8
- package/dist/windfoil/sizeSwitch.js.map +1 -1
- package/dist/windfoil/storage.d.ts +78 -6
- package/dist/windfoil/storage.js +166 -11
- package/dist/windfoil/storage.js.map +1 -1
- package/dist/windfoil/svg/curves.d.ts +20 -0
- package/dist/windfoil/svg/curves.js +145 -42
- package/dist/windfoil/svg/curves.js.map +1 -1
- package/dist/windfoil/svg/document.js +10 -1
- package/dist/windfoil/svg/document.js.map +1 -1
- package/dist/windfoil/svg/pathConverter.js +66 -50
- package/dist/windfoil/svg/pathConverter.js.map +1 -1
- package/dist/windfoil/svg/pathData.d.ts +9 -0
- package/dist/windfoil/svg/pathData.js +142 -109
- package/dist/windfoil/svg/pathData.js.map +1 -1
- package/dist/windfoil/svg/winding.js +34 -10
- package/dist/windfoil/svg/winding.js.map +1 -1
- package/dist/windfoil/trace/contours.d.ts +5 -0
- package/dist/windfoil/trace/contours.js +256 -62
- package/dist/windfoil/trace/contours.js.map +1 -1
- package/dist/windfoil/trace/fit.d.ts +3 -1
- package/dist/windfoil/trace/fit.js +915 -265
- package/dist/windfoil/trace/fit.js.map +1 -1
- package/dist/windfoil/trace/outline.js +55 -30
- package/dist/windfoil/trace/outline.js.map +1 -1
- package/dist/windfoil/trace/traceOutline.worker.d.ts +24 -0
- package/dist/windfoil/trace/traceWorker.d.ts +13 -0
- package/dist/windfoil/trace/traceWorker.js +192 -0
- package/dist/windfoil/trace/traceWorker.js.map +1 -0
- package/dist/windfoil/trace/types.d.ts +10 -0
- package/dist/windfoil/tracedOutlines.d.ts +2 -0
- package/dist/windfoil/tracedOutlines.js +393 -103
- package/dist/windfoil/tracedOutlines.js.map +1 -1
- package/package.json +48 -29
- package/skills/ultra-text/SKILL.md +9 -10
- package/skills/ultra-text/references/frameworks.md +46 -2
- package/skills/ultra-text/references/three-tsl.md +27 -25
- package/skills/ultra-text/references/vanilla-webgpu.md +5 -2
- package/dist/assets/cpuSdf.worker-xS57yQbP.js +0 -322
- package/dist/assets/cpuSdf.worker-xS57yQbP.js.map +0 -1
- package/dist/slug-vanilla.js.map +0 -1
- package/dist/text/geometry.js +0 -348
- package/dist/text/geometry.js.map +0 -1
- package/dist/vanilla.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sizeSwitch.js","names":[],"sources":["../../src/windfoil/sizeSwitch.ts"],"sourcesContent":["import type { Node } from 'three/webgpu'\nimport {\n Fn,\n cameraProjectionMatrix,\n float,\n length,\n modelViewMatrix,\n uniform,\n vec2,\n vec4,\n viewportSize,\n} from 'three/tsl'\n\nimport { isEmojiCandidate } from '../dom/clusters.js'\nimport type { GlyphKeepHook } from '../text/GlyphTextMaterial.js'\nimport type {\n DomLayoutSnapshot,\n GlyphLayout,\n GlyphRequest,\n SdfAtlas,\n WindfoilGlyphOutline,\n} from '../types.js'\nimport { windfoilGlyphRect } from './geometry.js'\nimport type { WindfoilGlyphHeader } from './preprocessCore.js'\n\n/**\n * Both batches keep a glyph whose projected em lies in [T, T·OVERLAP). The two pipelines\n * evaluate the same function on bit-identical inputs, but compilers may contract or\n * reassociate differently. While their results agree within 2^-12, a glyph can be drawn twice\n * for a moment but never dropped; on an Apple M3 Max they agreed to about 1e-7 near the\n * origin and 7e-5 a million units out.\n */\nconst OVERLAP = 1 + 2 ** -12\n/** Anchors on or behind the eye plane go to Windfoil; WGSL has no infinity literal. */\nconst BEHIND_EYE = 3e38\n\nexport interface WindfoilSizeSwitch {\n /** Glyph keys drawn by the SDF companion when small and by Windfoil when large. */\n readonly keys: ReadonlySet<string>\n readonly sdf: GlyphKeepHook\n readonly windfoil: GlyphKeepHook\n /** The layout both batches draw: shared motion anchors plus each glyph's switch em. */\n layout(snapshot: DomLayoutSnapshot): DomLayoutSnapshot\n}\n\nexport function assertThreshold(value: unknown): void {\n // Beyond the sentinel the f32 uniforms stop separating anchors behind the eye.\n if (!(typeof value === 'number' && value > 0 && value * OVERLAP < BEHIND_EYE))\n throw new RangeError('DomSdf: windfoil.sdfBelowPx must be a finite number of pixels above 0')\n}\n\n/**\n * The companion atlas as the size switch draws it: glyphs without outlines plus the\n * switchable ones. A switchable glyph whose raster came back as colour ink would change\n * artwork at the switch, so it is left to Windfoil alone. The view shares the atlas, which\n * stays owned by its builder; a null view means nothing is left to draw.\n */\nexport function companionView(\n atlas: SdfAtlas,\n missing: readonly string[],\n switchable: readonly GlyphRequest[],\n): { readonly atlas: SdfAtlas | null; readonly keys: ReadonlySet<string> } {\n const keys = new Set(\n switchable\n .map((request) => request.key)\n .filter((key) => {\n const slot = atlas.glyphs.get(key)\n return !!slot && slot.color !== true\n }),\n )\n const kept = new Set([...missing, ...keys])\n return {\n keys,\n atlas: kept.size\n ? {\n ...atlas,\n glyphs: new Map([...atlas.glyphs].filter(([key]) => kept.has(key))),\n dispose() {\n /* Released by the builder that owns the atlas. */\n },\n }\n : null,\n }\n}\n\n/** Plain, drawable, single-paint outlines whose SDF raster shows the same artwork. */\nexport function switchableRequests(\n resolved: readonly {\n readonly request: GlyphRequest\n readonly outline: WindfoilGlyphOutline | null\n }[],\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n): GlyphRequest[] {\n return resolved.flatMap(({ request, outline }) => {\n const header = outline ? glyphs.get(request.key) : undefined\n return header &&\n header.monotonePieceCount > 0 &&\n !header.layers &&\n !header.clipBox &&\n !isEmojiCandidate(request.character)\n ? [request]\n : []\n })\n}\n\nexport function createSizeSwitch(\n threshold: number,\n keys: ReadonlySet<string>,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n ordinalsOf: (snapshot: DomLayoutSnapshot) => Float32Array,\n): WindfoilSizeSwitch {\n const below = uniform(threshold)\n const belowWithOverlap = uniform(threshold * OVERLAP)\n // One layout function, so both pipelines compile the same WGSL for the decision.\n const projectedEm = Fn<\n [Node<'vec4'>, Node<'vec4'>, Node<'vec4'>, Node<'vec2'>, Node<'float'>],\n Node<'float'>\n >(([clip, axisX, axisY, halfViewport, em]) => {\n const w = clip.w\n // Pixels per local unit along each axis (scaled by w²): the quotient rule on clip.xy / clip.w,\n // exact in orthographic and perspective views. Since w² > 0 on the taken branch, factoring\n // 1 / w² outside length() is exact and avoids scaling both 2-vectors before their norms.\n const jx = axisX.xy.mul(w).sub(clip.xy.mul(axisX.w)).mul(halfViewport).toConst()\n const jy = axisY.xy.mul(w).sub(clip.xy.mul(axisY.w)).mul(halfViewport).toConst()\n // The largest singular value of [jx jy]: independent of roll, mirroring and shear, and\n // free of the cancellation in the eigenvalue formula.\n const stretch = length(vec2(jx.x.add(jy.y), jx.y.sub(jy.x)))\n .add(length(vec2(jx.x.sub(jy.y), jx.y.add(jy.x))))\n .mul(0.5)\n return w.greaterThan(0).select(stretch.mul(em).div(w.mul(w)), float(BEHIND_EYE))\n }).setLayout({\n name: 'ultraProjectedEm',\n type: 'float',\n inputs: [\n { name: 'clip', type: 'vec4' },\n { name: 'axisX', type: 'vec4' },\n { name: 'axisY', type: 'vec4' },\n { name: 'halfViewport', type: 'vec2' },\n { name: 'em', type: 'float' },\n ],\n })\n const emPixels = (anchor: Node<'vec2'>, meta: Node<'vec3'>): Node<'float'> => {\n const modelViewProjection = cameraProjectionMatrix.mul(modelViewMatrix)\n return projectedEm(\n modelViewProjection.mul(vec4(anchor, meta.y, 1)),\n modelViewProjection.mul(vec4(1, 0, 0, 0)),\n modelViewProjection.mul(vec4(0, 1, 0, 0)),\n viewportSize.mul(0.5),\n meta.z,\n ).toConst()\n }\n // A zero em marks glyphs that never switch: missing outlines, colour and layered glyphs.\n const fixed = (meta: Node<'vec3'>): Node<'bool'> => meta.z.lessThanEqual(0)\n const derived = new WeakMap<DomLayoutSnapshot, DomLayoutSnapshot>()\n return {\n keys,\n // A NaN em compares false: the SDF batch drops it and Windfoil keeps it.\n sdf: (anchor, meta) => fixed(meta).or(emPixels(anchor, meta).lessThan(belowWithOverlap)),\n windfoil: (anchor, meta) => fixed(meta).or(emPixels(anchor, meta).lessThan(below).not()),\n layout(snapshot) {\n const cached = derived.get(snapshot)\n if (cached) return cached\n const ordinals = ordinalsOf(snapshot)\n const result: DomLayoutSnapshot = {\n ...snapshot,\n sizeSwitched: true,\n glyphs: snapshot.glyphs.map((glyph, index): GlyphLayout => {\n const header = keys.has(glyph.glyphKey) ? glyphs.get(glyph.glyphKey) : undefined\n // Zero or below never switches; a dilating tone still reads the magnitude as the em.\n if (!header) return { ...glyph, switchEm: glyph.switchEm ? -Math.abs(glyph.switchEm) : 0 }\n const rect = windfoilGlyphRect(glyph, header)\n return {\n ...glyph,\n // Clamped above zero so a degenerate size still switches instead of meaning\n // \"never\", which would let both batches draw it.\n switchEm: Math.max(glyph.fontSize, 1e-30),\n motionOrigin: glyph.motionOrigin ?? [\n (rect[0] + rect[2]) / 2,\n (rect[1] + rect[3]) / 2,\n ordinals[index]!,\n ],\n }\n }),\n }\n derived.set(snapshot, result)\n return result\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAgCA,IAAM,UAAU,IAAI,KAAK;;AAEzB,IAAM,aAAa;AAWnB,SAAgB,gBAAgB,OAAsB;CAEpD,IAAI,EAAE,OAAO,UAAU,YAAY,QAAQ,KAAK,QAAQ,UAAU,aAChE,MAAM,IAAI,WAAW,uEAAuE;AAChG;;;;;;;AAQA,SAAgB,cACd,OACA,SACA,YACyE;CACzE,MAAM,OAAO,IAAI,IACf,WACG,KAAK,YAAY,QAAQ,GAAG,CAAC,CAC7B,QAAQ,QAAQ;EACf,MAAM,OAAO,MAAM,OAAO,IAAI,GAAG;EACjC,OAAO,CAAC,CAAC,QAAQ,KAAK,UAAU;CAClC,CAAC,CACL;CACA,MAAM,uBAAO,IAAI,IAAI,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;CAC1C,OAAO;EACL;EACA,OAAO,KAAK,OACR;GACE,GAAG;GACH,QAAQ,IAAI,IAAI,CAAC,GAAG,MAAM,MAAM,CAAC,CAAC,QAAQ,CAAC,SAAS,KAAK,IAAI,GAAG,CAAC,CAAC;GAClE,UAAU,CAEV;EACF,IACA;CACN;AACF;;AAGA,SAAgB,mBACd,UAIA,QACgB;CAChB,OAAO,SAAS,SAAS,EAAE,SAAS,cAAc;EAChD,MAAM,SAAS,UAAU,OAAO,IAAI,QAAQ,GAAG,IAAI,KAAA;EACnD,OAAO,UACL,OAAO,qBAAqB,KAC5B,CAAC,OAAO,UACR,CAAC,OAAO,WACR,CAAC,iBAAiB,QAAQ,SAAS,IACjC,CAAC,OAAO,IACR,CAAC;CACP,CAAC;AACH;AAEA,SAAgB,iBACd,WACA,MACA,QACA,YACoB;CACpB,MAAM,QAAQ,QAAQ,SAAS;C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"],"sourcesContent":["import type { Node } from 'three/webgpu'\nimport {\n Fn,\n cameraProjectionMatrix,\n float,\n length,\n modelViewMatrix,\n uniform,\n vec2,\n vec4,\n viewportSize,\n} from 'three/tsl'\n\nimport { isEmojiCandidate } from '../dom/clusters.js'\nimport type { GlyphKeepHook } from '../text/GlyphTextMaterial.js'\nimport type {\n DomLayoutSnapshot,\n GlyphLayout,\n GlyphRequest,\n SdfAtlas,\n WindfoilGlyphOutline,\n} from '../types.js'\nimport { fixedGlyphEm, windfoilGlyphRect } from './geometry.js'\nimport type { WindfoilGlyphHeader } from './preprocessCore.js'\n\n/**\n * Both batches keep a glyph whose projected em lies in [T, T·OVERLAP). The two pipelines\n * evaluate the same function on bit-identical inputs, but compilers may contract or\n * reassociate differently. While their results agree within 2^-12, a glyph can be drawn twice\n * for a moment but never dropped; on an Apple M3 Max they agreed to about 1e-7 near the\n * origin and 7e-5 a million units out.\n */\nconst OVERLAP = 1 + 2 ** -12\n/** Anchors on or behind the eye plane go to Windfoil; WGSL has no infinity literal. */\nconst BEHIND_EYE = 3e38\n\nexport interface WindfoilSizeSwitch {\n /** Glyph keys drawn by the SDF companion when small and by Windfoil when large. */\n readonly keys: ReadonlySet<string>\n readonly sdf: GlyphKeepHook\n readonly windfoil: GlyphKeepHook\n /** The layout both batches draw: shared motion anchors plus each glyph's switch em. */\n layout(snapshot: DomLayoutSnapshot, fontEm?: boolean): DomLayoutSnapshot\n}\n\nexport function assertThreshold(value: unknown): void {\n // Beyond the sentinel the f32 uniforms stop separating anchors behind the eye.\n if (!(typeof value === 'number' && value > 0 && value * OVERLAP < BEHIND_EYE))\n throw new RangeError('DomSdf: windfoil.sdfBelowPx must be a finite number of pixels above 0')\n}\n\n/**\n * The companion atlas as the size switch draws it: glyphs without outlines plus the\n * switchable ones. A switchable glyph whose raster came back as colour ink would change\n * artwork at the switch, so it is left to Windfoil alone. The view shares the atlas, which\n * stays owned by its builder; a null view means nothing is left to draw.\n */\nexport function companionView(\n atlas: SdfAtlas,\n missing: readonly string[],\n switchable: readonly GlyphRequest[],\n): { readonly atlas: SdfAtlas | null; readonly keys: ReadonlySet<string> } {\n const keys = new Set(\n switchable\n .map((request) => request.key)\n .filter((key) => {\n const slot = atlas.glyphs.get(key)\n return !!slot && slot.color !== true\n }),\n )\n const kept = new Set([...missing, ...keys])\n return {\n keys,\n atlas: kept.size\n ? {\n ...atlas,\n glyphs: new Map([...atlas.glyphs].filter(([key]) => kept.has(key))),\n dispose() {\n /* Released by the builder that owns the atlas. */\n },\n }\n : null,\n }\n}\n\n/** Plain, drawable, single-paint outlines whose SDF raster shows the same artwork. */\nexport function switchableRequests(\n resolved: readonly {\n readonly request: GlyphRequest\n readonly outline: WindfoilGlyphOutline | null\n }[],\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n): GlyphRequest[] {\n return resolved.flatMap(({ request, outline }) => {\n const header = outline ? glyphs.get(request.key) : undefined\n return header &&\n header.monotonePieceCount > 0 &&\n !header.layers &&\n !header.clipBox &&\n !isEmojiCandidate(request.character)\n ? [request]\n : []\n })\n}\n\nexport function createSizeSwitch(\n threshold: number,\n keys: ReadonlySet<string>,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n ordinalsOf: (snapshot: DomLayoutSnapshot) => Float32Array,\n): WindfoilSizeSwitch {\n const below = uniform(threshold)\n const belowWithOverlap = uniform(threshold * OVERLAP)\n // One layout function, so both pipelines compile the same WGSL for the decision.\n const projectedEm = Fn<\n [Node<'vec4'>, Node<'vec4'>, Node<'vec4'>, Node<'vec2'>, Node<'float'>],\n Node<'float'>\n >(([clip, axisX, axisY, halfViewport, em]) => {\n const w = clip.w\n // Pixels per local unit along each axis (scaled by w²): the quotient rule on clip.xy / clip.w,\n // exact in orthographic and perspective views. Since w² > 0 on the taken branch, factoring\n // 1 / w² outside length() is exact and avoids scaling both 2-vectors before their norms.\n const jx = axisX.xy.mul(w).sub(clip.xy.mul(axisX.w)).mul(halfViewport).toConst()\n const jy = axisY.xy.mul(w).sub(clip.xy.mul(axisY.w)).mul(halfViewport).toConst()\n // The largest singular value of [jx jy]: independent of roll, mirroring and shear, and\n // free of the cancellation in the eigenvalue formula.\n const stretch = length(vec2(jx.x.add(jy.y), jx.y.sub(jy.x)))\n .add(length(vec2(jx.x.sub(jy.y), jx.y.add(jy.x))))\n .mul(0.5)\n return w.greaterThan(0).select(stretch.mul(em).div(w.mul(w)), float(BEHIND_EYE))\n }).setLayout({\n name: 'ultraProjectedEm',\n type: 'float',\n inputs: [\n { name: 'clip', type: 'vec4' },\n { name: 'axisX', type: 'vec4' },\n { name: 'axisY', type: 'vec4' },\n { name: 'halfViewport', type: 'vec2' },\n { name: 'em', type: 'float' },\n ],\n })\n const emPixels = (anchor: Node<'vec2'>, meta: Node<'vec3'>): Node<'float'> => {\n const modelViewProjection = cameraProjectionMatrix.mul(modelViewMatrix)\n return projectedEm(\n modelViewProjection.mul(vec4(anchor, meta.y, 1)),\n modelViewProjection.mul(vec4(1, 0, 0, 0)),\n modelViewProjection.mul(vec4(0, 1, 0, 0)),\n viewportSize.mul(0.5),\n meta.z,\n ).toConst()\n }\n // A zero em marks glyphs that never switch: missing outlines, colour and layered glyphs.\n const fixed = (meta: Node<'vec3'>): Node<'bool'> => meta.z.lessThanEqual(0)\n const derived = new WeakMap<DomLayoutSnapshot, DomLayoutSnapshot>()\n let withFontEm: WeakMap<DomLayoutSnapshot, DomLayoutSnapshot> | undefined\n return {\n keys,\n // A NaN em compares false: the SDF batch drops it and Windfoil keeps it.\n sdf: (anchor, meta) => fixed(meta).or(emPixels(anchor, meta).lessThan(belowWithOverlap)),\n windfoil: (anchor, meta) => fixed(meta).or(emPixels(anchor, meta).lessThan(below).not()),\n layout(snapshot, fontEm = false) {\n const layouts = fontEm ? (withFontEm ??= new WeakMap()) : derived\n const cached = layouts.get(snapshot)\n if (cached) return cached\n const ordinals = ordinalsOf(snapshot)\n const result: DomLayoutSnapshot = {\n ...snapshot,\n sizeSwitched: true,\n glyphs: snapshot.glyphs.map((glyph, index): GlyphLayout => {\n const header = keys.has(glyph.glyphKey) ? glyphs.get(glyph.glyphKey) : undefined\n // Zero or below never switches; a dilating tone still reads the magnitude as the em.\n if (!header) {\n const em = fontEm ? fixedGlyphEm(glyph) : glyph.switchEm\n return { ...glyph, switchEm: em ? -Math.abs(em) : 0 }\n }\n const rect = windfoilGlyphRect(glyph, header)\n return {\n ...glyph,\n // Clamped above zero so a degenerate size still switches instead of meaning\n // \"never\", which would let both batches draw it.\n switchEm: Math.max(glyph.fontSize, 1e-30),\n motionOrigin: glyph.motionOrigin ?? [\n (rect[0] + rect[2]) / 2,\n (rect[1] + rect[3]) / 2,\n ordinals[index]!,\n ],\n }\n }),\n }\n layouts.set(snapshot, result)\n return result\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAgCA,IAAM,UAAU,IAAI,KAAK;;AAEzB,IAAM,aAAa;AAWnB,SAAgB,gBAAgB,OAAsB;CAEpD,IAAI,EAAE,OAAO,UAAU,YAAY,QAAQ,KAAK,QAAQ,UAAU,aAChE,MAAM,IAAI,WAAW,uEAAuE;AAChG;;;;;;;AAQA,SAAgB,cACd,OACA,SACA,YACyE;CACzE,MAAM,OAAO,IAAI,IACf,WACG,KAAK,YAAY,QAAQ,GAAG,CAAC,CAC7B,QAAQ,QAAQ;EACf,MAAM,OAAO,MAAM,OAAO,IAAI,GAAG;EACjC,OAAO,CAAC,CAAC,QAAQ,KAAK,UAAU;CAClC,CAAC,CACL;CACA,MAAM,uBAAO,IAAI,IAAI,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;CAC1C,OAAO;EACL;EACA,OAAO,KAAK,OACR;GACE,GAAG;GACH,QAAQ,IAAI,IAAI,CAAC,GAAG,MAAM,MAAM,CAAC,CAAC,QAAQ,CAAC,SAAS,KAAK,IAAI,GAAG,CAAC,CAAC;GAClE,UAAU,CAEV;EACF,IACA;CACN;AACF;;AAGA,SAAgB,mBACd,UAIA,QACgB;CAChB,OAAO,SAAS,SAAS,EA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OAAO,UAAU,KAAK,CAAC,KAAK,IAAI,EAAE,IAAI;MAAE;KACtD;KACA,MAAM,OAAO,kBAAkB,OAAO,MAAM;KAC5C,OAAO;MACL,GAAG;MAGH,UAAU,KAAK,IAAI,MAAM,UAAU,KAAK;MACxC,cAAc,MAAM,gBAAgB;QACjC,KAAK,KAAK,KAAK,MAAM;QACrB,KAAK,KAAK,KAAK,MAAM;OACtB,SAAS;MACX;KACF;IACF,CAAC;GACH;GACA,QAAQ,IAAI,UAAU,MAAM;GAC5B,OAAO;EACT;CACF;AACF"}
|
|
@@ -1,17 +1,57 @@
|
|
|
1
|
-
import { type BufferAttribute, type WebGPURenderer } from 'three/webgpu';
|
|
2
|
-
import type { DomSdfOptions } from '../types.js';
|
|
1
|
+
import { type BufferAttribute, type StorageBufferNode, type WebGPURenderer } from 'three/webgpu';
|
|
2
|
+
import type { DomSdfOptions, GlyphRequest, SdfDropShadowOptions, SdfOutlineOptions, WindfoilOptions, WindfoilOutlineProvider } from '../types.js';
|
|
3
3
|
import { abortable, throwIfAborted } from './abortable.js';
|
|
4
|
+
import { type ResolvedOutline } from './resolveOutline.js';
|
|
5
|
+
import type * as WindfoilRequests from './requests.js';
|
|
4
6
|
import type { WindfoilStorage } from './WindfoilMaterial.js';
|
|
5
7
|
export { abortable, throwIfAborted };
|
|
8
|
+
export interface WindfoilStorageHeadroom {
|
|
9
|
+
readonly minCurveFloats?: number;
|
|
10
|
+
readonly minRowUints?: number;
|
|
11
|
+
readonly rowAlign?: number;
|
|
12
|
+
readonly maxCurveFloats?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface RetainedWindfoilStorage extends WindfoilStorage {
|
|
15
|
+
readonly storageBytes: number;
|
|
16
|
+
readonly curveCapacityFloats: number;
|
|
17
|
+
readonly rowCapacityUints: number;
|
|
18
|
+
writeCurves(offsetFloats: number, source: Float32Array): void;
|
|
19
|
+
writeRows(offsetUints: number, source: Uint32Array): void;
|
|
20
|
+
dispose(): void;
|
|
21
|
+
}
|
|
22
|
+
/** Storage buffers retained by one vec4-packed Slug outline atlas. */
|
|
23
|
+
export interface SlugStorage {
|
|
24
|
+
readonly curves: StorageBufferNode<'vec4'>;
|
|
25
|
+
readonly rows: StorageBufferNode<'uint'>;
|
|
26
|
+
}
|
|
27
|
+
export interface RetainedSlugStorage extends SlugStorage {
|
|
28
|
+
readonly storageBytes: number;
|
|
29
|
+
readonly curveCapacityFloats: number;
|
|
30
|
+
readonly rowCapacityUints: number;
|
|
31
|
+
writeCurves(offsetFloats: number, source: Float32Array): void;
|
|
32
|
+
writeRows(offsetUints: number, source: Uint32Array): void;
|
|
33
|
+
dispose(): void;
|
|
34
|
+
}
|
|
6
35
|
/** The text effects of `DomSdfOptions` that an SDF underlay draws for analytic text. */
|
|
7
36
|
export type TextEffects = Pick<DomSdfOptions, 'outline' | 'dropShadow'>;
|
|
8
37
|
/**
|
|
9
|
-
* The effects that draw anything, or null: an outline unless its width
|
|
10
|
-
* at most zero, a drop shadow unless its opacity is at most zero. Values the SDF
|
|
11
|
-
* rejects, such as a negative width or a NaN, stay for it to reject.
|
|
38
|
+
* The effects that draw anything, or null: an outline unless both its width and blur are zero
|
|
39
|
+
* or its opacity at most zero, a drop shadow unless its opacity is at most zero. Values the SDF
|
|
40
|
+
* material rejects, such as a negative width or a NaN, stay for it to reject.
|
|
12
41
|
*/
|
|
13
|
-
export declare function drawnEffects({ outline, dropShadow }: TextEffects):
|
|
42
|
+
export declare function drawnEffects({ outline, dropShadow, }: TextEffects): {
|
|
43
|
+
outline?: SdfOutlineOptions;
|
|
44
|
+
dropShadow?: SdfDropShadowOptions;
|
|
45
|
+
} | null;
|
|
14
46
|
export declare function disposeWindfoilStorage(renderer: WebGPURenderer, attribute: BufferAttribute): void;
|
|
47
|
+
export declare function createRetainedWindfoilStorage(renderer: WebGPURenderer, data: {
|
|
48
|
+
curves: Float32Array;
|
|
49
|
+
rows: Uint32Array;
|
|
50
|
+
}, headroom?: WindfoilStorageHeadroom | false): RetainedWindfoilStorage;
|
|
51
|
+
export declare function createRetainedSlugStorage(renderer: WebGPURenderer, data: {
|
|
52
|
+
curves: Float32Array;
|
|
53
|
+
rows: Uint32Array;
|
|
54
|
+
}, headroom?: WindfoilStorageHeadroom | false): RetainedSlugStorage;
|
|
15
55
|
export declare function createWindfoilStorage(renderer: WebGPURenderer, data: {
|
|
16
56
|
curves: Float32Array;
|
|
17
57
|
rows: Uint32Array;
|
|
@@ -19,3 +59,35 @@ export declare function createWindfoilStorage(renderer: WebGPURenderer, data: {
|
|
|
19
59
|
storageBytes: number;
|
|
20
60
|
dispose(): void;
|
|
21
61
|
};
|
|
62
|
+
export declare function createSlugStorage(renderer: WebGPURenderer, data: {
|
|
63
|
+
curves: Float32Array;
|
|
64
|
+
rows: Uint32Array;
|
|
65
|
+
}): SlugStorage & {
|
|
66
|
+
storageBytes: number;
|
|
67
|
+
dispose(): void;
|
|
68
|
+
};
|
|
69
|
+
export type ResolvedOutlineRecord = ResolvedOutline;
|
|
70
|
+
export declare function resolveOutlineRequestsFast(requests: readonly GlyphRequest[], options: WindfoilOptions & {
|
|
71
|
+
readonly outlineProvider: WindfoilOutlineProvider;
|
|
72
|
+
}, signal: AbortSignal, extensions: typeof WindfoilRequests | null): ResolvedOutline[] | Promise<ResolvedOutline[]>;
|
|
73
|
+
export interface PartitionedOutlines {
|
|
74
|
+
readonly missing: ResolvedOutlineRecord[];
|
|
75
|
+
readonly nonNull: (ResolvedOutlineRecord & {
|
|
76
|
+
outline: NonNullable<ResolvedOutlineRecord['outline']>;
|
|
77
|
+
})[];
|
|
78
|
+
readonly hasLayers: boolean;
|
|
79
|
+
readonly hasClipBox: boolean;
|
|
80
|
+
}
|
|
81
|
+
export declare function partitionResolvedOutlines(resolved: readonly ResolvedOutlineRecord[]): PartitionedOutlines;
|
|
82
|
+
export declare function resolveOutlineRequests(requests: readonly GlyphRequest[], options: WindfoilOptions & {
|
|
83
|
+
readonly outlineProvider: WindfoilOutlineProvider;
|
|
84
|
+
}, signal: AbortSignal, extensions: typeof WindfoilRequests | null): Promise<ResolvedOutlineRecord[]>;
|
|
85
|
+
export declare function collectMissingRequests(requests: readonly GlyphRequest[], covered: (key: string) => boolean): GlyphRequest[];
|
|
86
|
+
export declare function mergePreprocessStats<T extends {
|
|
87
|
+
readonly paintLayers: number;
|
|
88
|
+
readonly uniqueGlyphs: number;
|
|
89
|
+
readonly monotonePieces: number;
|
|
90
|
+
readonly bandCount: number;
|
|
91
|
+
readonly bandedPieces: number;
|
|
92
|
+
readonly duplication: number;
|
|
93
|
+
}>(current: T, delta: T, uniqueGlyphs: number): T;
|
package/dist/windfoil/storage.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { abortable, throwIfAborted } from "./abortable.js";
|
|
2
|
+
import { storeOutline } from "./resolveOutline.js";
|
|
2
3
|
import { StorageBufferAttribute } from "three/webgpu";
|
|
3
4
|
import { storage } from "three/tsl";
|
|
4
5
|
// src/windfoil/storage.ts
|
|
5
6
|
/**
|
|
6
|
-
* The effects that draw anything, or null: an outline unless its width
|
|
7
|
-
* at most zero, a drop shadow unless its opacity is at most zero. Values the SDF
|
|
8
|
-
* rejects, such as a negative width or a NaN, stay for it to reject.
|
|
7
|
+
* The effects that draw anything, or null: an outline unless both its width and blur are zero
|
|
8
|
+
* or its opacity at most zero, a drop shadow unless its opacity is at most zero. Values the SDF
|
|
9
|
+
* material rejects, such as a negative width or a NaN, stay for it to reject.
|
|
9
10
|
*/
|
|
10
11
|
function drawnEffects({ outline, dropShadow }) {
|
|
11
12
|
const drawn = {};
|
|
12
|
-
if (outline && outline.width !== 0 && !((outline.opacity ?? 1) <= 0)) drawn.outline = outline;
|
|
13
|
-
if (dropShadow && !((dropShadow.opacity ?? .5) <= 0)) drawn.dropShadow = dropShadow;
|
|
13
|
+
if (typeof outline === "object" && (outline.width !== 0 || (outline.blur ?? 0) > 0) && !((outline.opacity ?? 1) <= 0)) drawn.outline = outline;
|
|
14
|
+
if (typeof dropShadow === "object" && !((dropShadow.opacity ?? .5) <= 0)) drawn.dropShadow = dropShadow;
|
|
14
15
|
return drawn.outline ?? drawn.dropShadow ? drawn : null;
|
|
15
16
|
}
|
|
16
17
|
function disposeWindfoilStorage(renderer, attribute) {
|
|
@@ -21,7 +22,20 @@ function disposeWindfoilStorage(renderer, attribute) {
|
|
|
21
22
|
renderer.info.destroyAttribute(attribute);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
+
function backendHas(renderer, attribute) {
|
|
26
|
+
return renderer.backend.has?.(attribute) === true;
|
|
27
|
+
}
|
|
28
|
+
function alignUp(value, align) {
|
|
29
|
+
const rem = value % align;
|
|
30
|
+
return rem === 0 ? value : value + align - rem;
|
|
31
|
+
}
|
|
32
|
+
function headroomCapacity(used, minExtra, align, maxAllowed, minNonEmpty) {
|
|
33
|
+
const alignedMax = Math.max(align, Math.floor(maxAllowed / align) * align);
|
|
34
|
+
if (used >= alignedMax) return Math.max(used, minNonEmpty);
|
|
35
|
+
const target = alignUp(Math.max(Math.ceil(used * 1.5), used + minExtra, minNonEmpty), align);
|
|
36
|
+
return Math.max(used, minNonEmpty, Math.min(target, alignedMax));
|
|
37
|
+
}
|
|
38
|
+
function createRetainedCurveStorage(renderer, data, curveType, curveComponents, headroom) {
|
|
25
39
|
const attributes = [];
|
|
26
40
|
let disposed = false;
|
|
27
41
|
const dispose = () => {
|
|
@@ -30,14 +44,61 @@ function createWindfoilStorage(renderer, data) {
|
|
|
30
44
|
for (const attribute of attributes) disposeWindfoilStorage(renderer, attribute);
|
|
31
45
|
};
|
|
32
46
|
try {
|
|
33
|
-
|
|
47
|
+
let curvesData;
|
|
48
|
+
let rowsData;
|
|
49
|
+
if (headroom) {
|
|
50
|
+
const limits = renderer.backend.device?.limits;
|
|
51
|
+
const maxBindingBytes = Math.min(limits?.maxStorageBufferBindingSize ?? 134217728, limits?.maxBufferSize ?? 268435456);
|
|
52
|
+
const curveBytesPerItem = curveComponents * 4;
|
|
53
|
+
const maxCurveFloats = Math.min(Math.floor(maxBindingBytes / curveBytesPerItem) * curveComponents, headroom.maxCurveFloats ?? Number.POSITIVE_INFINITY);
|
|
54
|
+
const rowAlign = headroom.rowAlign ?? 1;
|
|
55
|
+
const maxRowUints = Math.floor(maxBindingBytes / (4 * rowAlign)) * rowAlign;
|
|
56
|
+
const capCurves = headroomCapacity(data.curves.length, headroom.minCurveFloats ?? 4096, curveComponents, maxCurveFloats, curveComponents);
|
|
57
|
+
const capRows = headroomCapacity(data.rows.length, headroom.minRowUints ?? 512, rowAlign, maxRowUints, 1);
|
|
58
|
+
if (capCurves === data.curves.length && data.curves.length > 0) curvesData = data.curves;
|
|
59
|
+
else {
|
|
60
|
+
curvesData = new Float32Array(capCurves);
|
|
61
|
+
if (data.curves.length > 0) curvesData.set(data.curves);
|
|
62
|
+
}
|
|
63
|
+
if (capRows === data.rows.length && data.rows.length > 0) rowsData = data.rows;
|
|
64
|
+
else {
|
|
65
|
+
rowsData = new Uint32Array(capRows);
|
|
66
|
+
if (data.rows.length > 0) rowsData.set(data.rows);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
if (data.curves.length === 0) curvesData = new Float32Array(curveComponents);
|
|
70
|
+
else if (data.curves.length % curveComponents !== 0) {
|
|
71
|
+
curvesData = new Float32Array(alignUp(data.curves.length, curveComponents));
|
|
72
|
+
curvesData.set(data.curves);
|
|
73
|
+
} else curvesData = data.curves;
|
|
74
|
+
rowsData = data.rows.length ? data.rows : /* @__PURE__ */ new Uint32Array(1);
|
|
75
|
+
}
|
|
76
|
+
const curveAttribute = new StorageBufferAttribute(curvesData, curveComponents);
|
|
34
77
|
attributes.push(curveAttribute);
|
|
35
|
-
const rowAttribute = new StorageBufferAttribute(
|
|
78
|
+
const rowAttribute = new StorageBufferAttribute(rowsData, 1);
|
|
36
79
|
attributes.push(rowAttribute);
|
|
37
80
|
return {
|
|
38
|
-
storageBytes: data.curves.byteLength + data.rows.byteLength,
|
|
39
|
-
|
|
81
|
+
storageBytes: headroom ? curvesData.byteLength + rowsData.byteLength : data.curves.byteLength + data.rows.byteLength,
|
|
82
|
+
curveCapacityFloats: curvesData.length,
|
|
83
|
+
rowCapacityUints: rowsData.length,
|
|
84
|
+
curves: storage(curveAttribute, curveType, curveAttribute.count).toReadOnly().setName("ultraWindfoilCurves"),
|
|
40
85
|
rows: storage(rowAttribute, "uint", rowAttribute.count).toReadOnly().setName("ultraWindfoilRows"),
|
|
86
|
+
writeCurves(offsetFloats, source) {
|
|
87
|
+
if (source.length === 0) return;
|
|
88
|
+
curvesData.set(source, offsetFloats);
|
|
89
|
+
if (backendHas(renderer, curveAttribute)) {
|
|
90
|
+
curveAttribute.addUpdateRange(offsetFloats, source.length);
|
|
91
|
+
curveAttribute.needsUpdate = true;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
writeRows(offsetUints, source) {
|
|
95
|
+
if (source.length === 0) return;
|
|
96
|
+
rowsData.set(source, offsetUints);
|
|
97
|
+
if (backendHas(renderer, rowAttribute)) {
|
|
98
|
+
rowAttribute.addUpdateRange(offsetUints, source.length);
|
|
99
|
+
rowAttribute.needsUpdate = true;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
41
102
|
dispose
|
|
42
103
|
};
|
|
43
104
|
} catch (error) {
|
|
@@ -45,6 +106,100 @@ function createWindfoilStorage(renderer, data) {
|
|
|
45
106
|
throw error;
|
|
46
107
|
}
|
|
47
108
|
}
|
|
48
|
-
|
|
109
|
+
var VEC2_CURVES_SYM = Symbol.for("ultraTextVec2Curves");
|
|
110
|
+
function createRetainedWindfoilStorage(renderer, data, headroom) {
|
|
111
|
+
const isVec2 = data[VEC2_CURVES_SYM] === true;
|
|
112
|
+
return createRetainedCurveStorage(renderer, data, isVec2 ? "vec2" : "vec4", isVec2 ? 2 : 4, headroom);
|
|
113
|
+
}
|
|
114
|
+
function createRetainedSlugStorage(renderer, data, headroom) {
|
|
115
|
+
return createRetainedCurveStorage(renderer, data, "vec4", 4, headroom);
|
|
116
|
+
}
|
|
117
|
+
function createWindfoilStorage(renderer, data) {
|
|
118
|
+
const retained = createRetainedWindfoilStorage(renderer, data);
|
|
119
|
+
return {
|
|
120
|
+
storageBytes: retained.storageBytes,
|
|
121
|
+
curves: retained.curves,
|
|
122
|
+
rows: retained.rows,
|
|
123
|
+
dispose: () => {
|
|
124
|
+
retained.dispose();
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function createSlugStorage(renderer, data) {
|
|
129
|
+
const retained = createRetainedSlugStorage(renderer, data);
|
|
130
|
+
return {
|
|
131
|
+
storageBytes: retained.storageBytes,
|
|
132
|
+
curves: retained.curves,
|
|
133
|
+
rows: retained.rows,
|
|
134
|
+
dispose: () => {
|
|
135
|
+
retained.dispose();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function resolveOutlineRequestsFast(requests, options, signal, extensions) {
|
|
140
|
+
const resolved = new Array(requests.length);
|
|
141
|
+
let pending = null;
|
|
142
|
+
try {
|
|
143
|
+
for (let i = 0; i < requests.length; i++) {
|
|
144
|
+
const request = requests[i];
|
|
145
|
+
const outline = extensions ? extensions.resolveShapeRequest(request, options, signal) : options.outlineProvider(request, signal);
|
|
146
|
+
const wait = storeOutline(resolved, i, request, outline);
|
|
147
|
+
if (wait) (pending ??= []).push(wait);
|
|
148
|
+
}
|
|
149
|
+
if (!pending) return resolved;
|
|
150
|
+
throwIfAborted(signal);
|
|
151
|
+
return abortable(Promise.all(pending).then(() => resolved), signal);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
if (pending) Promise.allSettled(pending);
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function partitionResolvedOutlines(resolved) {
|
|
158
|
+
const missing = [];
|
|
159
|
+
const nonNull = [];
|
|
160
|
+
let hasLayers = false;
|
|
161
|
+
let hasClipBox = false;
|
|
162
|
+
for (const item of resolved) {
|
|
163
|
+
const outline = item.outline;
|
|
164
|
+
if (outline === null) missing.push(item);
|
|
165
|
+
else {
|
|
166
|
+
nonNull.push(item);
|
|
167
|
+
if (outline.layers !== void 0) hasLayers = true;
|
|
168
|
+
if (outline.clipBox !== void 0) hasClipBox = true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
missing,
|
|
173
|
+
nonNull,
|
|
174
|
+
hasLayers,
|
|
175
|
+
hasClipBox
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
async function resolveOutlineRequests(requests, options, signal, extensions) {
|
|
179
|
+
return resolveOutlineRequestsFast(requests, options, signal, extensions);
|
|
180
|
+
}
|
|
181
|
+
function collectMissingRequests(requests, covered) {
|
|
182
|
+
const missing = [];
|
|
183
|
+
const seen = /* @__PURE__ */ new Set();
|
|
184
|
+
for (const req of requests) {
|
|
185
|
+
if (seen.has(req.key) || covered(req.key)) continue;
|
|
186
|
+
seen.add(req.key);
|
|
187
|
+
missing.push(req);
|
|
188
|
+
}
|
|
189
|
+
return missing;
|
|
190
|
+
}
|
|
191
|
+
function mergePreprocessStats(current, delta, uniqueGlyphs) {
|
|
192
|
+
const monotonePieces = current.monotonePieces + delta.monotonePieces;
|
|
193
|
+
const bandedPieces = current.bandedPieces + delta.bandedPieces;
|
|
194
|
+
return {
|
|
195
|
+
paintLayers: current.paintLayers + delta.paintLayers,
|
|
196
|
+
uniqueGlyphs,
|
|
197
|
+
monotonePieces,
|
|
198
|
+
bandCount: current.bandCount + delta.bandCount,
|
|
199
|
+
bandedPieces,
|
|
200
|
+
duplication: monotonePieces > 0 ? bandedPieces / monotonePieces : current.duplication
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
export { abortable, collectMissingRequests, createRetainedSlugStorage, createRetainedWindfoilStorage, createSlugStorage, createWindfoilStorage, disposeWindfoilStorage, drawnEffects, mergePreprocessStats, partitionResolvedOutlines, resolveOutlineRequests, resolveOutlineRequestsFast, throwIfAborted };
|
|
49
204
|
|
|
50
205
|
//# sourceMappingURL=storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","names":[],"sources":["../../src/windfoil/storage.ts"],"sourcesContent":["import { StorageBufferAttribute, type BufferAttribute, type WebGPURenderer } from 'three/webgpu'\nimport { storage } from 'three/tsl'\nimport type { DomSdfOptions } from '../types.js'\nimport { abortable, throwIfAborted } from './abortable.js'\nimport type { WindfoilStorage } from './WindfoilMaterial.js'\n\nexport { abortable, throwIfAborted }\n\n/** The text effects of `DomSdfOptions` that an SDF underlay draws for analytic text. */\nexport type TextEffects = Pick<DomSdfOptions, 'outline' | 'dropShadow'>\n/**\n * The effects that draw anything, or null: an outline unless its width is zero or its opacity\n * at most zero, a drop shadow unless its opacity is at most zero. Values the SDF material\n * rejects, such as a negative width or a NaN, stay for it to reject.\n */\nexport function drawnEffects({ outline, dropShadow }: TextEffects): TextEffects | null {\n const drawn: TextEffects = {}\n if (outline && outline.width !== 0 && !((outline.opacity ?? 1) <= 0)) drawn.outline = outline\n if (dropShadow && !((dropShadow.opacity ?? 0.5) <= 0)) drawn.dropShadow = dropShadow\n return (drawn.outline ?? drawn.dropShadow) ? drawn : null\n}\nexport function disposeWindfoilStorage(renderer: WebGPURenderer, attribute: BufferAttribute): void {\n attribute.dispose()\n const backend = renderer.backend as unknown as {\n has(object: object): boolean\n destroyAttribute(attribute: BufferAttribute): void\n }\n if (backend.has(attribute)) {\n backend.destroyAttribute(attribute)\n renderer.info.destroyAttribute(attribute)\n }\n}\nexport function createWindfoilStorage(\n renderer: WebGPURenderer,\n data: { curves: Float32Array; rows: Uint32Array },\n): WindfoilStorage & { storageBytes: number; dispose(): void } {\n const attributes: StorageBufferAttribute[] = []\n let disposed = false\n const dispose = (): void => {\n if (disposed) return\n disposed = true\n for (const attribute of attributes) disposeWindfoilStorage(renderer, attribute)\n }\n try {\n const curveAttribute = new StorageBufferAttribute(\n data.curves.length ? data.curves : new Float32Array(2),\n 2,\n )\n attributes.push(curveAttribute)\n const rowAttribute = new StorageBufferAttribute(\n data.rows.length ? data.rows : new Uint32Array(1),\n 1,\n )\n attributes.push(rowAttribute)\n return {\n storageBytes: data.curves.byteLength + data.rows.byteLength,\n curves: storage(curveAttribute, 'vec2', curveAttribute.count)\n .toReadOnly()\n .setName('ultraWindfoilCurves'),\n rows: storage(rowAttribute, 'uint', rowAttribute.count)\n .toReadOnly()\n .setName('ultraWindfoilRows'),\n dispose,\n }\n } catch (error) {\n dispose()\n throw error\n }\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,aAAa,EAAE,SAAS,cAA+C;CACrF,MAAM,QAAqB,CAAC;CAC5B,IAAI,WAAW,QAAQ,UAAU,KAAK,GAAG,QAAQ,WAAW,MAAM,IAAI,MAAM,UAAU;CACtF,IAAI,cAAc,GAAG,WAAW,WAAW,OAAQ,IAAI,MAAM,aAAa;CAC1E,OAAQ,MAAM,WAAW,MAAM,aAAc,QAAQ;AACvD;AACA,SAAgB,uBAAuB,UAA0B,WAAkC;CACjG,UAAU,QAAQ;CAClB,MAAM,UAAU,SAAS;CAIzB,IAAI,QAAQ,IAAI,SAAS,GAAG;EAC1B,QAAQ,iBAAiB,SAAS;EAClC,SAAS,KAAK,iBAAiB,SAAS;CAC1C;AACF;AACA,SAAgB,sBACd,UACA,MAC6D;CAC7D,MAAM,aAAuC,CAAC;CAC9C,IAAI,WAAW;CACf,MAAM,gBAAsB;EAC1B,IAAI,UAAU;EACd,WAAW;EACX,KAAK,MAAM,aAAa,YAAY,uBAAuB,UAAU,SAAS;CAChF;CACA,IAAI;EACF,MAAM,iBAAiB,IAAI,uBACzB,KAAK,OAAO,SAAS,KAAK,yBAAS,IAAI,aAAa,CAAC,GACrD,CACF;EACA,WAAW,KAAK,cAAc;EAC9B,MAAM,eAAe,IAAI,uBACvB,KAAK,KAAK,SAAS,KAAK,uBAAO,IAAI,YAAY,CAAC,GAChD,CACF;EACA,WAAW,KAAK,YAAY;EAC5B,OAAO;GACL,cAAc,KAAK,OAAO,aAAa,KAAK,KAAK;GACjD,QAAQ,QAAQ,gBAAgB,QAAQ,eAAe,KAAK,CAAC,CAC1D,WAAW,CAAC,CACZ,QAAQ,qBAAqB;GAChC,MAAM,QAAQ,cAAc,QAAQ,aAAa,KAAK,CAAC,CACpD,WAAW,CAAC,CACZ,QAAQ,mBAAmB;GAC9B;EACF;CACF,SAAS,OAAO;EACd,QAAQ;EACR,MAAM;CACR;AACF"}
|
|
1
|
+
{"version":3,"file":"storage.js","names":[],"sources":["../../src/windfoil/storage.ts"],"sourcesContent":["import {\n StorageBufferAttribute,\n type BufferAttribute,\n type StorageBufferNode,\n type WebGPURenderer,\n} from 'three/webgpu'\nimport { storage } from 'three/tsl'\nimport type {\n DomSdfOptions,\n GlyphRequest,\n SdfDropShadowOptions,\n SdfOutlineOptions,\n WindfoilOptions,\n WindfoilOutlineProvider,\n} from '../types.js'\nimport { abortable, throwIfAborted } from './abortable.js'\nimport { storeOutline, type ResolvedOutline } from './resolveOutline.js'\nimport type * as WindfoilRequests from './requests.js'\nimport type { WindfoilStorage } from './WindfoilMaterial.js'\n\nexport { abortable, throwIfAborted }\n\nexport interface WindfoilStorageHeadroom {\n readonly minCurveFloats?: number\n readonly minRowUints?: number\n readonly rowAlign?: number\n readonly maxCurveFloats?: number\n}\n\nexport interface RetainedWindfoilStorage extends WindfoilStorage {\n readonly storageBytes: number\n readonly curveCapacityFloats: number\n readonly rowCapacityUints: number\n writeCurves(offsetFloats: number, source: Float32Array): void\n writeRows(offsetUints: number, source: Uint32Array): void\n dispose(): void\n}\n\n/** Storage buffers retained by one vec4-packed Slug outline atlas. */\nexport interface SlugStorage {\n readonly curves: StorageBufferNode<'vec4'>\n readonly rows: StorageBufferNode<'uint'>\n}\n\nexport interface RetainedSlugStorage extends SlugStorage {\n readonly storageBytes: number\n readonly curveCapacityFloats: number\n readonly rowCapacityUints: number\n writeCurves(offsetFloats: number, source: Float32Array): void\n writeRows(offsetUints: number, source: Uint32Array): void\n dispose(): void\n}\n\n/** The text effects of `DomSdfOptions` that an SDF underlay draws for analytic text. */\nexport type TextEffects = Pick<DomSdfOptions, 'outline' | 'dropShadow'>\n/**\n * The effects that draw anything, or null: an outline unless both its width and blur are zero\n * or its opacity at most zero, a drop shadow unless its opacity is at most zero. Values the SDF\n * material rejects, such as a negative width or a NaN, stay for it to reject.\n */\nexport function drawnEffects({\n outline,\n dropShadow,\n}: TextEffects): { outline?: SdfOutlineOptions; dropShadow?: SdfDropShadowOptions } | null {\n const drawn: { outline?: SdfOutlineOptions; dropShadow?: SdfDropShadowOptions } = {}\n if (\n typeof outline === 'object' &&\n (outline.width !== 0 || (outline.blur ?? 0) > 0) &&\n !((outline.opacity ?? 1) <= 0)\n ) {\n drawn.outline = outline\n }\n if (typeof dropShadow === 'object' && !((dropShadow.opacity ?? 0.5) <= 0)) {\n drawn.dropShadow = dropShadow\n }\n return (drawn.outline ?? drawn.dropShadow) ? drawn : null\n}\nexport function disposeWindfoilStorage(renderer: WebGPURenderer, attribute: BufferAttribute): void {\n attribute.dispose()\n const backend = renderer.backend as unknown as {\n has(object: object): boolean\n destroyAttribute(attribute: BufferAttribute): void\n }\n if (backend.has(attribute)) {\n backend.destroyAttribute(attribute)\n renderer.info.destroyAttribute(attribute)\n }\n}\nfunction backendHas(renderer: WebGPURenderer, attribute: BufferAttribute): boolean {\n return (\n (renderer.backend as unknown as { has?(object: object): boolean }).has?.(attribute) === true\n )\n}\n\nfunction alignUp(value: number, align: number): number {\n const rem = value % align\n return rem === 0 ? value : value + align - rem\n}\n\nfunction headroomCapacity(\n used: number,\n minExtra: number,\n align: number,\n maxAllowed: number,\n minNonEmpty: number,\n): number {\n const alignedMax = Math.max(align, Math.floor(maxAllowed / align) * align)\n if (used >= alignedMax) return Math.max(used, minNonEmpty)\n const target = alignUp(Math.max(Math.ceil(used * 1.5), used + minExtra, minNonEmpty), align)\n return Math.max(used, minNonEmpty, Math.min(target, alignedMax))\n}\n\nfunction createRetainedCurveStorage<T extends 'vec2' | 'vec4'>(\n renderer: WebGPURenderer,\n data: { curves: Float32Array; rows: Uint32Array },\n curveType: T,\n curveComponents: 2 | 4,\n headroom?: WindfoilStorageHeadroom | false,\n): {\n readonly storageBytes: number\n readonly curveCapacityFloats: number\n readonly rowCapacityUints: number\n readonly curves: StorageBufferNode<T>\n readonly rows: StorageBufferNode<'uint'>\n writeCurves(offsetFloats: number, source: Float32Array): void\n writeRows(offsetUints: number, source: Uint32Array): void\n dispose(): void\n} {\n const attributes: StorageBufferAttribute[] = []\n let disposed = false\n const dispose = (): void => {\n if (disposed) return\n disposed = true\n for (const attribute of attributes) disposeWindfoilStorage(renderer, attribute)\n }\n try {\n let curvesData: Float32Array\n let rowsData: Uint32Array\n if (headroom) {\n const limits = (\n renderer.backend as unknown as {\n device?: { limits?: { maxStorageBufferBindingSize?: number; maxBufferSize?: number } }\n }\n ).device?.limits\n const maxBindingBytes = Math.min(\n limits?.maxStorageBufferBindingSize ?? 128 * 1024 * 1024,\n limits?.maxBufferSize ?? 256 * 1024 * 1024,\n )\n const curveBytesPerItem = curveComponents * 4\n const maxCurveFloats = Math.min(\n Math.floor(maxBindingBytes / curveBytesPerItem) * curveComponents,\n headroom.maxCurveFloats ?? Number.POSITIVE_INFINITY,\n )\n const rowAlign = headroom.rowAlign ?? 1\n const maxRowUints = Math.floor(maxBindingBytes / (4 * rowAlign)) * rowAlign\n const capCurves = headroomCapacity(\n data.curves.length,\n headroom.minCurveFloats ?? 4096,\n curveComponents,\n maxCurveFloats,\n curveComponents,\n )\n const capRows = headroomCapacity(\n data.rows.length,\n headroom.minRowUints ?? 512,\n rowAlign,\n maxRowUints,\n 1,\n )\n if (capCurves === data.curves.length && data.curves.length > 0) {\n curvesData = data.curves\n } else {\n curvesData = new Float32Array(capCurves)\n if (data.curves.length > 0) curvesData.set(data.curves)\n }\n if (capRows === data.rows.length && data.rows.length > 0) {\n rowsData = data.rows\n } else {\n rowsData = new Uint32Array(capRows)\n if (data.rows.length > 0) rowsData.set(data.rows)\n }\n } else {\n if (data.curves.length === 0) {\n curvesData = new Float32Array(curveComponents)\n } else if (data.curves.length % curveComponents !== 0) {\n curvesData = new Float32Array(alignUp(data.curves.length, curveComponents))\n curvesData.set(data.curves)\n } else {\n curvesData = data.curves\n }\n rowsData = data.rows.length ? data.rows : new Uint32Array(1)\n }\n const curveAttribute = new StorageBufferAttribute(curvesData, curveComponents)\n attributes.push(curveAttribute)\n const rowAttribute = new StorageBufferAttribute(rowsData, 1)\n attributes.push(rowAttribute)\n return {\n storageBytes: headroom\n ? curvesData.byteLength + rowsData.byteLength\n : data.curves.byteLength + data.rows.byteLength,\n curveCapacityFloats: curvesData.length,\n rowCapacityUints: rowsData.length,\n curves: storage(curveAttribute, curveType, curveAttribute.count)\n .toReadOnly()\n .setName('ultraWindfoilCurves'),\n rows: storage(rowAttribute, 'uint', rowAttribute.count)\n .toReadOnly()\n .setName('ultraWindfoilRows'),\n writeCurves(offsetFloats, source) {\n if (source.length === 0) return\n curvesData.set(source, offsetFloats)\n if (backendHas(renderer, curveAttribute)) {\n curveAttribute.addUpdateRange(offsetFloats, source.length)\n curveAttribute.needsUpdate = true\n }\n },\n writeRows(offsetUints, source) {\n if (source.length === 0) return\n rowsData.set(source, offsetUints)\n if (backendHas(renderer, rowAttribute)) {\n rowAttribute.addUpdateRange(offsetUints, source.length)\n rowAttribute.needsUpdate = true\n }\n },\n dispose,\n }\n } catch (error) {\n dispose()\n throw error\n }\n}\n\nconst VEC2_CURVES_SYM = Symbol.for('ultraTextVec2Curves')\n\nexport function createRetainedWindfoilStorage(\n renderer: WebGPURenderer,\n data: { curves: Float32Array; rows: Uint32Array },\n headroom?: WindfoilStorageHeadroom | false,\n): RetainedWindfoilStorage {\n const isVec2 = (data as { readonly [VEC2_CURVES_SYM]?: boolean })[VEC2_CURVES_SYM] === true\n return createRetainedCurveStorage(\n renderer,\n data,\n isVec2 ? 'vec2' : 'vec4',\n isVec2 ? 2 : 4,\n headroom,\n )\n}\n\nexport function createRetainedSlugStorage(\n renderer: WebGPURenderer,\n data: { curves: Float32Array; rows: Uint32Array },\n headroom?: WindfoilStorageHeadroom | false,\n): RetainedSlugStorage {\n return createRetainedCurveStorage(renderer, data, 'vec4', 4, headroom)\n}\n\nexport function createWindfoilStorage(\n renderer: WebGPURenderer,\n data: { curves: Float32Array; rows: Uint32Array },\n): WindfoilStorage & { storageBytes: number; dispose(): void } {\n const retained = createRetainedWindfoilStorage(renderer, data)\n return {\n storageBytes: retained.storageBytes,\n curves: retained.curves,\n rows: retained.rows,\n dispose: (): void => {\n retained.dispose()\n },\n }\n}\n\nexport function createSlugStorage(\n renderer: WebGPURenderer,\n data: { curves: Float32Array; rows: Uint32Array },\n): SlugStorage & { storageBytes: number; dispose(): void } {\n const retained = createRetainedSlugStorage(renderer, data)\n return {\n storageBytes: retained.storageBytes,\n curves: retained.curves,\n rows: retained.rows,\n dispose: (): void => {\n retained.dispose()\n },\n }\n}\n\nexport type ResolvedOutlineRecord = ResolvedOutline\n\nexport function resolveOutlineRequestsFast(\n requests: readonly GlyphRequest[],\n options: WindfoilOptions & { readonly outlineProvider: WindfoilOutlineProvider },\n signal: AbortSignal,\n extensions: typeof WindfoilRequests | null,\n): ResolvedOutline[] | Promise<ResolvedOutline[]> {\n const resolved = new Array<ResolvedOutline>(requests.length)\n let pending: Promise<void>[] | null = null\n try {\n for (let i = 0; i < requests.length; i++) {\n const request = requests[i]!\n const outline = extensions\n ? extensions.resolveShapeRequest(request, options, signal)\n : options.outlineProvider(request, signal)\n const wait = storeOutline(resolved, i, request, outline)\n if (wait) (pending ??= []).push(wait)\n }\n if (!pending) return resolved\n throwIfAborted(signal)\n return abortable(\n Promise.all(pending).then(() => resolved),\n signal,\n )\n } catch (error) {\n // A later provider can throw while earlier promises are still outstanding.\n if (pending) void Promise.allSettled(pending)\n throw error\n }\n}\n\nexport interface PartitionedOutlines {\n readonly missing: ResolvedOutlineRecord[]\n readonly nonNull: (ResolvedOutlineRecord & {\n outline: NonNullable<ResolvedOutlineRecord['outline']>\n })[]\n readonly hasLayers: boolean\n readonly hasClipBox: boolean\n}\n\nexport function partitionResolvedOutlines(\n resolved: readonly ResolvedOutlineRecord[],\n): PartitionedOutlines {\n const missing: ResolvedOutlineRecord[] = []\n const nonNull: (ResolvedOutlineRecord & {\n outline: NonNullable<ResolvedOutlineRecord['outline']>\n })[] = []\n let hasLayers = false\n let hasClipBox = false\n for (const item of resolved) {\n const outline = item.outline\n if (outline === null) {\n missing.push(item)\n } else {\n nonNull.push(\n item as ResolvedOutlineRecord & { outline: NonNullable<ResolvedOutlineRecord['outline']> },\n )\n if (outline.layers !== undefined) hasLayers = true\n if (outline.clipBox !== undefined) hasClipBox = true\n }\n }\n return { missing, nonNull, hasLayers, hasClipBox }\n}\n\nexport async function resolveOutlineRequests(\n requests: readonly GlyphRequest[],\n options: WindfoilOptions & { readonly outlineProvider: WindfoilOutlineProvider },\n signal: AbortSignal,\n extensions: typeof WindfoilRequests | null,\n): Promise<ResolvedOutlineRecord[]> {\n return resolveOutlineRequestsFast(requests, options, signal, extensions)\n}\n\nexport function collectMissingRequests(\n requests: readonly GlyphRequest[],\n covered: (key: string) => boolean,\n): GlyphRequest[] {\n const missing: GlyphRequest[] = []\n const seen = new Set<string>()\n for (const req of requests) {\n if (seen.has(req.key) || covered(req.key)) continue\n seen.add(req.key)\n missing.push(req)\n }\n return missing\n}\n\nexport function mergePreprocessStats<\n T extends {\n readonly paintLayers: number\n readonly uniqueGlyphs: number\n readonly monotonePieces: number\n readonly bandCount: number\n readonly bandedPieces: number\n readonly duplication: number\n },\n>(current: T, delta: T, uniqueGlyphs: number): T {\n const monotonePieces = current.monotonePieces + delta.monotonePieces\n const bandedPieces = current.bandedPieces + delta.bandedPieces\n return {\n paintLayers: current.paintLayers + delta.paintLayers,\n uniqueGlyphs,\n monotonePieces,\n bandCount: current.bandCount + delta.bandCount,\n bandedPieces,\n duplication: monotonePieces > 0 ? bandedPieces / monotonePieces : current.duplication,\n } as T\n}\n"],"mappings":";;;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,eAAsB,uBACpB,UACA,SACA,QACA,YACkC;CAClC,OAAO,2BAA2B,UAAU,SAAS,QAAQ,UAAU;AACzE;AAEA,SAAgB,uBACd,UACA,SACgB;CAChB,MAAM,UAA0B,CAAC;CACjC,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,OAAO,UAAU;EAC1B,IAAI,KAAK,IAAI,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG;EAC3C,KAAK,IAAI,IAAI,GAAG;EAChB,QAAQ,KAAK,GAAG;CAClB;CACA,OAAO;AACT;AAEA,SAAgB,qBASd,SAAY,OAAU,cAAyB;CAC/C,MAAM,iBAAiB,QAAQ,iBAAiB,MAAM;CACtD,MAAM,eAAe,QAAQ,eAAe,MAAM;CAClD,OAAO;EACL,aAAa,QAAQ,cAAc,MAAM;EACzC;EACA;EACA,WAAW,QAAQ,YAAY,MAAM;EACrC;EACA,aAAa,iBAAiB,IAAI,eAAe,iBAAiB,QAAQ;CAC5E;AACF"}
|
|
@@ -11,6 +11,7 @@ export declare function cubicToQuadratics(p: Cubic, tolerance: number): {
|
|
|
11
11
|
quads: WindfoilQuadratic[];
|
|
12
12
|
capped: boolean;
|
|
13
13
|
};
|
|
14
|
+
export declare function emitArcCubics(sx: number, sy: number, rawRx: number, rawRy: number, rotation: number, large: boolean, sweep: boolean, ex: number, ey: number, sigmaMax: number, tolerance: number, emit: (p0: number, p1: number, p2: number, p3: number, p4: number, p5: number, p6: number, p7: number) => void): void;
|
|
14
15
|
export declare function arcToCubics(start: Point, arc: Extract<Segment, {
|
|
15
16
|
type: 'arc';
|
|
16
17
|
}>, sigmaMax: number, tolerance: number): Cubic[];
|
|
@@ -27,4 +28,23 @@ export declare class ContourBuilder {
|
|
|
27
28
|
cubic(r0: number, r1: number, r2: number, r3: number, r4: number, r5: number, r6: number, r7: number, tolerance: number): boolean;
|
|
28
29
|
close(): void;
|
|
29
30
|
}
|
|
31
|
+
export declare class ContourBoundsBuilder {
|
|
32
|
+
minX: number;
|
|
33
|
+
minY: number;
|
|
34
|
+
maxX: number;
|
|
35
|
+
maxY: number;
|
|
36
|
+
hasCurve: boolean;
|
|
37
|
+
private startX;
|
|
38
|
+
private startY;
|
|
39
|
+
private pointX;
|
|
40
|
+
private pointY;
|
|
41
|
+
private open;
|
|
42
|
+
move(x: number, y: number): void;
|
|
43
|
+
line(x: number, y: number): void;
|
|
44
|
+
quad(cx: number, cy: number, x: number, y: number): void;
|
|
45
|
+
cubic(r0: number, r1: number, r2: number, r3: number, r4: number, r5: number, r6: number, r7: number, tolerance: number): boolean;
|
|
46
|
+
close(): void;
|
|
47
|
+
bounds(): WindfoilBoundingBox;
|
|
48
|
+
}
|
|
49
|
+
export declare function transformedQuadraticBounds(quadratics: readonly WindfoilQuadratic[], m: WindfoilAffine): WindfoilBoundingBox;
|
|
30
50
|
export declare function quadraticBounds(quadratics: readonly WindfoilQuadratic[]): WindfoilBoundingBox;
|