@weasel-js/core 1.9.2 → 1.9.4
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/CHANGELOG.md +393 -0
- package/README.md +2 -2
- package/dist/WeaselProvider.js +5 -5
- package/dist/affordances/composeAffordanceLayer.js +10 -20
- package/dist/affordances/composeAffordanceLayer.js.map +1 -1
- package/dist/affordances/cornerResize.js +25 -17
- package/dist/affordances/cornerResize.js.map +1 -1
- package/dist/affordances/hitAffordanceRegions.js +27 -20
- package/dist/affordances/hitAffordanceRegions.js.map +1 -1
- package/dist/affordances/rotationHandle.js +18 -18
- package/dist/affordances/rotationHandle.js.map +1 -1
- package/dist/animation/behaviors/momentum.js +93 -55
- package/dist/animation/behaviors/momentum.js.map +1 -1
- package/dist/animation/loop.js +10 -12
- package/dist/animation/loop.js.map +1 -1
- package/dist/animation/reflow.js +8 -8
- package/dist/animation/reflow.js.map +1 -1
- package/dist/animation/stagger.js +64 -56
- package/dist/animation/stagger.js.map +1 -1
- package/dist/animation/timeline/booking.js +62 -54
- package/dist/animation/timeline/booking.js.map +1 -1
- package/dist/animation/timeline/createTimeline.js +85 -76
- package/dist/animation/timeline/createTimeline.js.map +1 -1
- package/dist/animation/timeline/sampleTrack.js +13 -5
- package/dist/animation/timeline/sampleTrack.js.map +1 -1
- package/dist/animation/useAnimator.js +45 -35
- package/dist/animation/useAnimator.js.map +1 -1
- package/dist/animation/wrappers/animateLifecycle.js +31 -24
- package/dist/animation/wrappers/animateLifecycle.js.map +1 -1
- package/dist/animation/wrappers/animateOnSetPose.js +28 -26
- package/dist/animation/wrappers/animateOnSetPose.js.map +1 -1
- package/dist/animation/wrappers/instantPose.js +13 -0
- package/dist/animation/wrappers/instantPose.js.map +1 -0
- package/dist/{poseDescriptor-D-OH-tu5.d.ts → autoPoseDescriptor-Ct7yqivU.d.ts} +28 -3
- package/dist/barrel/chrome.js +16 -0
- package/dist/barrel/input.js +19 -0
- package/dist/barrel/interactions.js +42 -0
- package/dist/barrel/paint.js +18 -0
- package/dist/barrel/paths.js +19 -0
- package/dist/barrel/renderer.js +20 -0
- package/dist/barrel/routing.js +51 -0
- package/dist/barrel/text.js +18 -0
- package/dist/barrel/viewport.js +52 -0
- package/dist/builtins-DPcdghtB.d.ts +1223 -0
- package/dist/canvas/Canvas.js +363 -448
- package/dist/canvas/Canvas.js.map +1 -1
- package/dist/canvas/CanvasView.js +164 -165
- package/dist/canvas/CanvasView.js.map +1 -1
- package/dist/canvas/CursorCoordsHud.js +37 -32
- package/dist/canvas/CursorCoordsHud.js.map +1 -1
- package/dist/canvas/DrawCanvas.js +49 -43
- package/dist/canvas/DrawCanvas.js.map +1 -1
- package/dist/canvas/MinimapCanvas.js +26 -25
- package/dist/canvas/MinimapCanvas.js.map +1 -1
- package/dist/canvas/NodeShape.js +59 -377
- package/dist/canvas/NodeShape.js.map +1 -1
- package/dist/canvas/PickHud.js +50 -47
- package/dist/canvas/PickHud.js.map +1 -1
- package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js +167 -0
- package/dist/canvas/SceneCanvas/GestureDispatcherMounter.js.map +1 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +13 -13
- package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js +67 -0
- package/dist/canvas/SceneCanvas/StandardActionsRegistrar.js.map +1 -0
- package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js +16 -0
- package/dist/canvas/SceneCanvas/ToolKeybindingsMounter.js.map +1 -0
- package/dist/canvas/SceneCanvas/coordTrace.js +10 -0
- package/dist/canvas/SceneCanvas/coordTrace.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +146 -92
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js +9 -8
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -1
- package/dist/canvas/SceneCanvas/features.js +1 -0
- package/dist/canvas/SceneCanvas/features.js.map +1 -1
- package/dist/canvas/SceneCanvas/isDev.js +12 -0
- package/dist/canvas/SceneCanvas/isDev.js.map +1 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js +29 -28
- package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -1
- package/dist/canvas/SceneCanvas/poseRegistrars.js +13 -0
- package/dist/canvas/SceneCanvas/poseRegistrars.js.map +1 -0
- package/dist/canvas/SceneCanvas/props.js +38 -0
- package/dist/canvas/SceneCanvas/props.js.map +1 -0
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +21 -62
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -1
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +46 -48
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -1
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +33 -33
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -1
- package/dist/canvas/SceneCanvas.js +534 -788
- package/dist/canvas/SceneCanvas.js.map +1 -1
- package/dist/canvas/SceneViewCanvas.js +45 -43
- package/dist/canvas/SceneViewCanvas.js.map +1 -1
- package/dist/canvas/buildSceneLayer.js +91 -0
- package/dist/canvas/buildSceneLayer.js.map +1 -0
- package/dist/canvas/buildSceneTree.js +16 -19
- package/dist/canvas/buildSceneTree.js.map +1 -1
- package/dist/canvas/canvasRenderer.js +68 -52
- package/dist/canvas/canvasRenderer.js.map +1 -1
- package/dist/canvas/deps/changes.js +13 -0
- package/dist/canvas/deps/changes.js.map +1 -0
- package/dist/canvas/deps/editAnchors.js +28 -28
- package/dist/canvas/deps/insert.js +119 -91
- package/dist/canvas/deps/insert.js.map +1 -1
- package/dist/canvas/deps/slice.js +46 -45
- package/dist/canvas/deps/slice.js.map +1 -1
- package/dist/canvas/deps/textEdit.js +10 -9
- package/dist/canvas/deps/textEdit.js.map +1 -1
- package/dist/canvas/derivedPath.js +46 -23
- package/dist/canvas/derivedPath.js.map +1 -1
- package/dist/canvas/getNodeAtPoint.js +7 -7
- package/dist/canvas/getNodeAtPoint.js.map +1 -1
- package/dist/canvas/hud.module.js +1 -1
- package/dist/canvas/hud.module.js.map +1 -1
- package/dist/canvas/kitRequirements.js +2 -2
- package/dist/canvas/kitRequirements.js.map +1 -1
- package/dist/canvas/layerOrder.js +13 -6
- package/dist/canvas/layerOrder.js.map +1 -1
- package/dist/canvas/minimapMath.js +12 -10
- package/dist/canvas/minimapMath.js.map +1 -1
- package/dist/canvas/nodeShapes/derivedPainter.js +34 -0
- package/dist/canvas/nodeShapes/derivedPainter.js.map +1 -0
- package/dist/canvas/nodeShapes/imagePainter.js +87 -0
- package/dist/canvas/nodeShapes/imagePainter.js.map +1 -0
- package/dist/canvas/nodeShapes/memo.js +9 -0
- package/dist/canvas/nodeShapes/memo.js.map +1 -0
- package/dist/canvas/nodeShapes/nodePaint.js +57 -0
- package/dist/canvas/nodeShapes/nodePaint.js.map +1 -0
- package/dist/canvas/nodeShapes/pathPainter.js +38 -0
- package/dist/canvas/nodeShapes/pathPainter.js.map +1 -0
- package/dist/canvas/nodeShapes/poseBox.js +20 -0
- package/dist/canvas/nodeShapes/poseBox.js.map +1 -0
- package/dist/canvas/nodeShapes/rectFallbackPainter.js +38 -0
- package/dist/canvas/nodeShapes/rectFallbackPainter.js.map +1 -0
- package/dist/canvas/nodeShapes/shapePainter.js +72 -0
- package/dist/canvas/nodeShapes/shapePainter.js.map +1 -0
- package/dist/canvas/nodeShapes/textPainter.js +55 -0
- package/dist/canvas/nodeShapes/textPainter.js.map +1 -0
- package/dist/canvas/overlayRoleStrokes.js.map +1 -1
- package/dist/canvas/paintCull.js +10 -11
- package/dist/canvas/paintCull.js.map +1 -1
- package/dist/canvas/pickWalk.js +52 -63
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/poseRotation.js +11 -23
- package/dist/canvas/poseRotation.js.map +1 -1
- package/dist/canvas/renderDebugSnapshot.js +5 -5
- package/dist/canvas/renderSceneToPixels.js +3 -1
- package/dist/canvas/renderSceneToPixels.js.map +1 -1
- package/dist/canvas/sceneAdapter.js +66 -148
- package/dist/canvas/sceneAdapter.js.map +1 -1
- package/dist/canvas/sceneClipboard.js +112 -0
- package/dist/canvas/sceneClipboard.js.map +1 -0
- package/dist/canvas/sceneSlotWiring.js +4 -4
- package/dist/canvas/sceneSlotWiring.js.map +1 -1
- package/dist/canvas/sceneViewRender.js +39 -40
- package/dist/canvas/sceneViewRender.js.map +1 -1
- package/dist/canvas/useCanvasRenderer.js +14 -6
- package/dist/canvas/useCanvasRenderer.js.map +1 -1
- package/dist/canvas/useCanvasView.js +58 -0
- package/dist/canvas/useCanvasView.js.map +1 -0
- package/dist/canvas/useFrameLoop.js +35 -26
- package/dist/canvas/useFrameLoop.js.map +1 -1
- package/dist/canvas/useSceneLayerList.js +21 -0
- package/dist/canvas/useSceneLayerList.js.map +1 -0
- package/dist/clipboard.d.ts +10 -6
- package/dist/clone.d.ts +4 -3
- package/dist/core/adapters/arrayAdapter.js +48 -39
- package/dist/core/adapters/arrayAdapter.js.map +1 -1
- package/dist/core/device/index.js +5 -4
- package/dist/core/device/useDeviceProfile.js +38 -44
- package/dist/core/device/useDeviceProfile.js.map +1 -1
- package/dist/core/device/watchDevicePixelRatio.js +17 -0
- package/dist/core/device/watchDevicePixelRatio.js.map +1 -0
- package/dist/core/fillInPoseFrame.js.map +1 -1
- package/dist/core/geometry/poseDescriptor.js +21 -19
- package/dist/core/geometry/poseDescriptor.js.map +1 -1
- package/dist/core/geometry/poseFrame.js +44 -0
- package/dist/core/geometry/poseFrame.js.map +1 -0
- package/dist/core/geometry/poseRotation.js.map +1 -1
- package/dist/core/geometry/regionHit.js +9 -10
- package/dist/core/geometry/regionHit.js.map +1 -1
- package/dist/core/geometry/unionBounds.js +31 -29
- package/dist/core/geometry/unionBounds.js.map +1 -1
- package/dist/core/isPlainObject.js +2 -11
- package/dist/core/ops/arrange.js +1 -0
- package/dist/core/ops/arrange.js.map +1 -1
- package/dist/core/ops/create.js +10 -5
- package/dist/core/ops/create.js.map +1 -1
- package/dist/core/ops/delete.js +12 -24
- package/dist/core/ops/delete.js.map +1 -1
- package/dist/core/ops/reorder/index.js +43 -40
- package/dist/core/ops/reorder/index.js.map +1 -1
- package/dist/core/ops/reorder/setChildOrder.js +34 -0
- package/dist/core/ops/reorder/setChildOrder.js.map +1 -0
- package/dist/core/paintKinds.js +5 -5
- package/dist/core/paintKinds.js.map +1 -1
- package/dist/core/scene/NodeProperties.js.map +1 -1
- package/dist/core/scene/appliedLog.js +37 -0
- package/dist/core/scene/appliedLog.js.map +1 -0
- package/dist/core/scene/arrivalWindow.js +101 -0
- package/dist/core/scene/arrivalWindow.js.map +1 -0
- package/dist/core/scene/derivedPath.js.map +1 -1
- package/dist/core/scene/historyFacade.js +84 -0
- package/dist/core/scene/historyFacade.js.map +1 -0
- package/dist/core/scene/kitOps.js +173 -0
- package/dist/core/scene/kitOps.js.map +1 -0
- package/dist/core/scene/layerStack.js +38 -0
- package/dist/core/scene/layerStack.js.map +1 -0
- package/dist/core/scene/lockGuard.js +37 -0
- package/dist/core/scene/lockGuard.js.map +1 -0
- package/dist/core/scene/nodeFnFields.js +5 -6
- package/dist/core/scene/nodeFnFields.js.map +1 -1
- package/dist/core/scene/nodeMemo.js +45 -19
- package/dist/core/scene/nodeMemo.js.map +1 -1
- package/dist/core/scene/nodeStore.js +126 -0
- package/dist/core/scene/nodeStore.js.map +1 -0
- package/dist/core/scene/pickability.js +6 -0
- package/dist/core/scene/pickability.js.map +1 -0
- package/dist/core/scene/poseFeed.js +38 -38
- package/dist/core/scene/poseFeed.js.map +1 -1
- package/dist/core/scene/poseOverrides.js +34 -38
- package/dist/core/scene/poseOverrides.js.map +1 -1
- package/dist/core/scene/renderOrder.js +84 -0
- package/dist/core/scene/renderOrder.js.map +1 -0
- package/dist/core/scene/scene.js +289 -866
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/serialization.js +68 -0
- package/dist/core/scene/serialization.js.map +1 -0
- package/dist/core/scene/treeOrder.js +13 -0
- package/dist/core/scene/treeOrder.js.map +1 -0
- package/dist/core/scene/types.js.map +1 -1
- package/dist/core/viewport/meanScale.js +1 -1
- package/dist/core/viewport/meanScale.js.map +1 -1
- package/dist/core/viewport/view.js +12 -12
- package/dist/core/viewport/view.js.map +1 -1
- package/dist/core/viewport/zoomBounds.js +10 -8
- package/dist/core/viewport/zoomBounds.js.map +1 -1
- package/dist/{cornerHandles-BCrDp_mH.d.ts → cornerHandles-CtCb8a3G.d.ts} +1 -1
- package/dist/debug/createDebugOverlayLayer.js +14 -14
- package/dist/debug/createDebugOverlayLayer.js.map +1 -1
- package/dist/debug/flag.js +2 -41
- package/dist/features/chrome-caps/useHoverTracking.js +22 -17
- package/dist/features/chrome-caps/useHoverTracking.js.map +1 -1
- package/dist/features/focus/gateLayer.js +3 -4
- package/dist/features/focus/gateLayer.js.map +1 -1
- package/dist/features/images/imageCache.js +19 -9
- package/dist/features/images/imageCache.js.map +1 -1
- package/dist/features/ingestion/contentHandlers.js +14 -11
- package/dist/features/ingestion/contentHandlers.js.map +1 -1
- package/dist/features/ingestion/index.js +1 -1
- package/dist/features/ingestion/registerKitHandlers.js +7 -7
- package/dist/features/ingestion/weaselJsonHandler.js +17 -14
- package/dist/features/ingestion/weaselJsonHandler.js.map +1 -1
- package/dist/features/meshPaint/lazyKind.js +201 -35
- package/dist/features/meshPaint/lazyKind.js.map +1 -1
- package/dist/features/meshPaint/meshPaint.js +82 -79
- package/dist/features/meshPaint/meshPaint.js.map +1 -1
- package/dist/features/minimap/createMinimapContribution.js +42 -42
- package/dist/features/minimap/layers.js +44 -62
- package/dist/features/minimap/layers.js.map +1 -1
- package/dist/features/parallax/createParallaxPlane.js +10 -14
- package/dist/features/parallax/createParallaxPlane.js.map +1 -1
- package/dist/features/paths/anchorEdits.js +19 -8
- package/dist/features/paths/anchorEdits.js.map +1 -1
- package/dist/features/paths/anchors.js +31 -26
- package/dist/features/paths/anchors.js.map +1 -1
- package/dist/features/paths/booleans.js +2 -2
- package/dist/features/paths/index.js +13 -11
- package/dist/features/paths/markerCommands.js +37 -36
- package/dist/features/paths/markerCommands.js.map +1 -1
- package/dist/features/paths/pathInWorld.js +19 -19
- package/dist/features/paths/pathInWorld.js.map +1 -1
- package/dist/features/paths/pathLayer.js.map +1 -1
- package/dist/features/paths/strokeToPath.js +40 -0
- package/dist/features/paths/strokeToPath.js.map +1 -0
- package/dist/features/paths/tessellate/stroke.js.map +1 -1
- package/dist/features/patterns/commandPaint.js +18 -0
- package/dist/features/patterns/commandPaint.js.map +1 -0
- package/dist/features/patterns/index.js +5 -17
- package/dist/features/patterns/index.js.map +1 -1
- package/dist/features/patterns/rasterizeTile.js +17 -0
- package/dist/features/patterns/rasterizeTile.js.map +1 -0
- package/dist/features/patterns/resolveSpec.js +52 -44
- package/dist/features/patterns/resolveSpec.js.map +1 -1
- package/dist/features/poseRun/usePoseRun.js +8 -3
- package/dist/features/poseRun/usePoseRun.js.map +1 -1
- package/dist/features/selection/SelectionContext.js +5 -0
- package/dist/features/selection/SelectionContext.js.map +1 -1
- package/dist/features/selection/overlay.js +18 -18
- package/dist/features/selection/overlay.js.map +1 -1
- package/dist/features/text/domOffsets.js +82 -0
- package/dist/features/text/domOffsets.js.map +1 -0
- package/dist/features/text/domRuns.js +103 -131
- package/dist/features/text/domRuns.js.map +1 -1
- package/dist/features/text/hitTest.js +5 -2
- package/dist/features/text/hitTest.js.map +1 -1
- package/dist/features/text/isTextData.js +8 -0
- package/dist/features/text/isTextData.js.map +1 -0
- package/dist/features/text/overlayDirection.js +15 -0
- package/dist/features/text/overlayDirection.js.map +1 -0
- package/dist/features/text/runs/rangeStyle.js +32 -34
- package/dist/features/text/runs/rangeStyle.js.map +1 -1
- package/dist/features/text/textCommand.js +34 -33
- package/dist/features/text/textCommand.js.map +1 -1
- package/dist/features/text/textToPath.js +40 -40
- package/dist/features/text/textToPath.js.map +1 -1
- package/dist/features/text/useSceneTextEdit.js +76 -82
- package/dist/features/text/useSceneTextEdit.js.map +1 -1
- package/dist/features/text/useTextEdit.js +184 -160
- package/dist/features/text/useTextEdit.js.map +1 -1
- package/dist/features/tiling/createTiledLayer.js +24 -22
- package/dist/features/tiling/createTiledLayer.js.map +1 -1
- package/dist/index.d.ts +11010 -7700
- package/dist/index.js +316 -309
- package/dist/input/keyState.js +42 -43
- package/dist/input/keyState.js.map +1 -1
- package/dist/input/useKeyModifiers.js +11 -0
- package/dist/input/useKeyModifiers.js.map +1 -0
- package/dist/interactions/actions/align/align.js +8 -8
- package/dist/interactions/actions/clipboard/clipboardOps.js +34 -32
- package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -1
- package/dist/interactions/actions/clipboard/materializePaste.js +10 -7
- package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -1
- package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -1
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +1 -1
- package/dist/interactions/actions/defaultCommitAdapter.js +20 -18
- package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -1
- package/dist/interactions/actions/defaults/align.js +9 -10
- package/dist/interactions/actions/defaults/align.js.map +1 -1
- package/dist/interactions/actions/defaults/anchorEditing.js +59 -81
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
- package/dist/interactions/actions/defaults/areaSelect.js +35 -38
- package/dist/interactions/actions/defaults/areaSelect.js.map +1 -1
- package/dist/interactions/actions/defaults/clipboard.js +26 -10
- package/dist/interactions/actions/defaults/clipboard.js.map +1 -1
- package/dist/interactions/actions/defaults/clone.js +44 -60
- package/dist/interactions/actions/defaults/clone.js.map +1 -1
- package/dist/interactions/actions/defaults/copySubtree.js +40 -0
- package/dist/interactions/actions/defaults/copySubtree.js.map +1 -0
- package/dist/interactions/actions/defaults/distribute.js +14 -13
- package/dist/interactions/actions/defaults/distribute.js.map +1 -1
- package/dist/interactions/actions/defaults/duplicate.js +17 -57
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -1
- package/dist/interactions/actions/defaults/editAnchors.js +18 -18
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -1
- package/dist/interactions/actions/defaults/flip.js +52 -46
- package/dist/interactions/actions/defaults/flip.js.map +1 -1
- package/dist/interactions/actions/defaults/group.js +43 -48
- package/dist/interactions/actions/defaults/group.js.map +1 -1
- package/dist/interactions/actions/defaults/ingest.js +35 -33
- package/dist/interactions/actions/defaults/ingest.js.map +1 -1
- package/dist/interactions/actions/defaults/insert.js +50 -51
- package/dist/interactions/actions/defaults/insert.js.map +1 -1
- package/dist/interactions/actions/defaults/insertPathAnchor.js +7 -7
- package/dist/interactions/actions/defaults/lassoSelect.js +67 -70
- package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -1
- package/dist/interactions/actions/defaults/move.js +267 -249
- package/dist/interactions/actions/defaults/move.js.map +1 -1
- package/dist/interactions/actions/defaults/nudge.js +40 -68
- package/dist/interactions/actions/defaults/nudge.js.map +1 -1
- package/dist/interactions/actions/defaults/nudgeSteps.js +37 -0
- package/dist/interactions/actions/defaults/nudgeSteps.js.map +1 -0
- package/dist/interactions/actions/defaults/reorder.js +2 -0
- package/dist/interactions/actions/defaults/reorder.js.map +1 -1
- package/dist/interactions/actions/defaults/resize.js +104 -98
- package/dist/interactions/actions/defaults/resize.js.map +1 -1
- package/dist/interactions/actions/defaults/rotate.js +111 -110
- package/dist/interactions/actions/defaults/rotate.js.map +1 -1
- package/dist/interactions/actions/defaults/setFill.js +7 -7
- package/dist/interactions/actions/defaults/setFillOpacity.js +4 -4
- package/dist/interactions/actions/defaults/setStroke.js +12 -12
- package/dist/interactions/actions/defaults/setStrokeOpacity.js +6 -6
- package/dist/interactions/actions/defaults/sliceOps.js +19 -19
- package/dist/interactions/actions/defaults/viewportDragPan.js +37 -26
- package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -1
- package/dist/interactions/actions/edit-anchors/geometry.js +28 -23
- package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -1
- package/dist/interactions/actions/flip/helpers.js +30 -17
- package/dist/interactions/actions/flip/helpers.js.map +1 -1
- package/dist/interactions/actions/hitSelection.js +8 -0
- package/dist/interactions/actions/hitSelection.js.map +1 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +14 -18
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +5 -5
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -1
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +32 -21
- package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -1
- package/dist/interactions/actions/move/gestureAdapter.js +32 -15
- package/dist/interactions/actions/move/gestureAdapter.js.map +1 -1
- package/dist/interactions/actions/move/landedDescendants.js +33 -0
- package/dist/interactions/actions/move/landedDescendants.js.map +1 -0
- package/dist/interactions/actions/outlines/createOutlines.js +18 -18
- package/dist/interactions/actions/poseDescriptorDep.js +16 -4
- package/dist/interactions/actions/poseDescriptorDep.js.map +1 -1
- package/dist/interactions/actions/poseFrame.js +11 -6
- package/dist/interactions/actions/poseFrame.js.map +1 -1
- package/dist/interactions/actions/previewOverrides.js +5 -5
- package/dist/interactions/actions/previewOverrides.js.map +1 -1
- package/dist/interactions/actions/selectionSubtree.js +69 -0
- package/dist/interactions/actions/selectionSubtree.js.map +1 -0
- package/dist/interactions/actions/useStandardActions.js +66 -62
- package/dist/interactions/actions/useStandardActions.js.map +1 -1
- package/dist/interactions/gestures/dragGesture/dragGesture.js +4 -7
- package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -1
- package/dist/interactions/gestures/dragGesture/dragPointOf.js +23 -0
- package/dist/interactions/gestures/dragGesture/dragPointOf.js.map +1 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js +21 -26
- package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -1
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js +8 -6
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -1
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +8 -4
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -1
- package/dist/{math-Drrw4ewZ.d.ts → math-J-ACHyEg.d.ts} +1 -2
- package/dist/math.d.ts +2 -3
- package/dist/move.d.ts +12 -11
- package/dist/{originProjection-DEklpDc_.d.ts → originProjection-gHnOup4e.d.ts} +1 -1
- package/dist/{registerProgram-BMZRDgrh.d.ts → registerProgram-T9S_PfAX.d.ts} +18 -7
- package/dist/renderer/DrawCommand.js.map +1 -1
- package/dist/renderer/WeaselRenderer.js +75 -73
- package/dist/renderer/WeaselRenderer.js.map +1 -1
- package/dist/renderer/cache/GLImageCache.js +15 -5
- package/dist/renderer/cache/GLImageCache.js.map +1 -1
- package/dist/renderer/cache/GLMeshCache.js +23 -23
- package/dist/renderer/cache/GLMeshCache.js.map +1 -1
- package/dist/renderer/cache/GLTextureCache.js +18 -1
- package/dist/renderer/cache/GLTextureCache.js.map +1 -1
- package/dist/renderer/cache/cache.js.map +1 -1
- package/dist/renderer/cache/markerCommandCache.js.map +1 -1
- package/dist/renderer/cache/strokeMeshCache.js.map +1 -1
- package/dist/renderer/cullDrawCommands.js +11 -11
- package/dist/renderer/draw/batch.js +133 -0
- package/dist/renderer/draw/batch.js.map +1 -0
- package/dist/renderer/draw/clip.js +89 -0
- package/dist/renderer/draw/clip.js.map +1 -0
- package/dist/renderer/draw/customShader.js +230 -0
- package/dist/renderer/draw/customShader.js.map +1 -0
- package/dist/renderer/draw/drawTriangles.js +8 -0
- package/dist/renderer/draw/drawTriangles.js.map +1 -0
- package/dist/renderer/draw/effects.js +28 -0
- package/dist/renderer/draw/effects.js.map +1 -0
- package/dist/renderer/draw/flushBatch.js +35 -0
- package/dist/renderer/draw/flushBatch.js.map +1 -0
- package/dist/renderer/draw/gradient.js +90 -0
- package/dist/renderer/draw/gradient.js.map +1 -0
- package/dist/renderer/draw/image.js +38 -0
- package/dist/renderer/draw/image.js.map +1 -0
- package/dist/renderer/draw/mesh.js +16 -0
- package/dist/renderer/draw/mesh.js.map +1 -0
- package/dist/renderer/draw/paintBind.js +70 -0
- package/dist/renderer/draw/paintBind.js.map +1 -0
- package/dist/renderer/draw/pathPaint.js +142 -0
- package/dist/renderer/draw/pathPaint.js.map +1 -0
- package/dist/renderer/draw/scratchPass.js +83 -0
- package/dist/renderer/draw/scratchPass.js.map +1 -0
- package/dist/renderer/draw/stencil.js +28 -0
- package/dist/renderer/draw/stencil.js.map +1 -0
- package/dist/renderer/draw/text.js +167 -0
- package/dist/renderer/draw/text.js.map +1 -0
- package/dist/renderer/draw/uniforms.js +77 -0
- package/dist/renderer/draw/uniforms.js.map +1 -0
- package/dist/renderer/draw.js +60 -1116
- package/dist/renderer/draw.js.map +1 -1
- package/dist/renderer/effects/EffectTargets.js +3 -0
- package/dist/renderer/effects/EffectTargets.js.map +1 -1
- package/dist/renderer/effects/composite.js +7 -5
- package/dist/renderer/effects/composite.js.map +1 -1
- package/dist/renderer/index.js +18 -17
- package/dist/renderer/math/color.js +63 -83
- package/dist/renderer/math/color.js.map +1 -1
- package/dist/renderer/math/mat3.js +15 -11
- package/dist/renderer/math/mat3.js.map +1 -1
- package/dist/renderer/math/viewToMat3.js +1 -1
- package/dist/renderer/math/viewToMat3.js.map +1 -1
- package/dist/renderer/shaders/ShaderProgram.js +13 -13
- package/dist/renderer/shaders/ShaderProgram.js.map +1 -1
- package/dist/renderer/shaders/glyphPaint.js +3 -3
- package/dist/renderer/shaders/glyphPaint.js.map +1 -1
- package/dist/renderer/shaders/gradFill.js +2 -1
- package/dist/renderer/shaders/gradFill.js.map +1 -1
- package/dist/renderer/shaders/pathFill.js +2 -1
- package/dist/renderer/shaders/pathFill.js.map +1 -1
- package/dist/renderer/shaders/patternFill.js +2 -1
- package/dist/renderer/shaders/patternFill.js.map +1 -1
- package/dist/renderer/shaders/registerProgram.js.map +1 -1
- package/dist/renderer/strokeLengths.js.map +1 -1
- package/dist/renderer/textures/registerTexture.js +25 -5
- package/dist/renderer/textures/registerTexture.js.map +1 -1
- package/dist/renderer.d.ts +16 -15
- package/dist/renderer.js +17 -16
- package/dist/resize.d.ts +5 -6
- package/dist/resize.js +5 -5
- package/dist/style.css +1 -1
- package/dist/test-hook/install.js +12 -6
- package/dist/test-hook/install.js.map +1 -1
- package/dist/{test-seams-CuIxe0xY.d.ts → test-seams-DM2B87-g.d.ts} +4 -4
- package/dist/test-seams.d.ts +2 -2
- package/dist/tools/builtin/ellipse/useEllipseTool.js +1 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -1
- package/dist/tools/builtin/hand/useHandTool.js +1 -0
- package/dist/tools/builtin/hand/useHandTool.js.map +1 -1
- package/dist/tools/builtin/lasso/useLassoTool.js +11 -11
- package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -1
- package/dist/tools/builtin/line/useLineTool.js +1 -0
- package/dist/tools/builtin/line/useLineTool.js.map +1 -1
- package/dist/tools/builtin/pen/usePenTool.js +153 -103
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -1
- package/dist/tools/builtin/pencil/usePencilTool.js +1 -0
- package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -1
- package/dist/tools/builtin/polygon/usePolygonTool.js +13 -8
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -1
- package/dist/tools/builtin/rect/useRectTool.js +1 -0
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -1
- package/dist/tools/builtin/select/selectionContributions.js +24 -23
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -1
- package/dist/tools/builtin/select/useSelectTool.js +51 -48
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -1
- package/dist/tools/builtin/shared/pointerFollower.js +17 -0
- package/dist/tools/builtin/shared/pointerFollower.js.map +1 -0
- package/dist/tools/builtin/slice/useSliceTool.js +49 -54
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -1
- package/dist/tools/builtin/star/useStarTool.js +22 -16
- package/dist/tools/builtin/star/useStarTool.js.map +1 -1
- package/dist/tools/builtin/text/useTextTool.js +13 -2
- package/dist/tools/builtin/text/useTextTool.js.map +1 -1
- package/dist/tools/useKeybindings.js +14 -30
- package/dist/tools/useKeybindings.js.map +1 -1
- package/dist/{types-B_9g6hMM.d.ts → types-B4iJRHC3.d.ts} +5 -1
- package/dist/{types-A37hYkeR.d.ts → types-k-5Oqh-U.d.ts} +31 -7
- package/dist/util/color.js +3 -3
- package/dist/util/color.js.map +1 -1
- package/dist/util/paint.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +20 -18
- package/dist/autoPoseDescriptor-vCdt55xm.d.ts +0 -27
- package/dist/builtins-C-VgUlWI.d.ts +0 -4514
- package/dist/core/isPlainObject.js.map +0 -1
- package/dist/debug/flag.js.map +0 -1
- package/dist/interactions/actions/defaults/freshNodeId.js +0 -10
- package/dist/interactions/actions/defaults/freshNodeId.js.map +0 -1
- package/dist/renderer/shaders/imageFill.js +0 -14
- package/dist/renderer/shaders/imageFill.js.map +0 -1
- package/dist/tools/prefs.js +0 -47
- package/dist/tools/prefs.js.map +0 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { drawTriangles as e } from "./drawTriangles.js";
|
|
2
|
+
import { setProjAndModel as t } from "./uniforms.js";
|
|
3
|
+
import { returnToRenderTarget as n } from "./effects.js";
|
|
4
|
+
import { BATCH_MODEL as r } from "./flushBatch.js";
|
|
5
|
+
import { getPaintKind as i } from "../../core/paintKinds.js";
|
|
6
|
+
import { paintBindContext as a } from "./paintBind.js";
|
|
7
|
+
//#region src/renderer/draw/scratchPass.ts
|
|
8
|
+
var o = {
|
|
9
|
+
vertices: new Float32Array([
|
|
10
|
+
0,
|
|
11
|
+
0,
|
|
12
|
+
1,
|
|
13
|
+
0,
|
|
14
|
+
1,
|
|
15
|
+
1,
|
|
16
|
+
0,
|
|
17
|
+
1
|
|
18
|
+
]),
|
|
19
|
+
indices: new Uint32Array([
|
|
20
|
+
0,
|
|
21
|
+
1,
|
|
22
|
+
2,
|
|
23
|
+
0,
|
|
24
|
+
2,
|
|
25
|
+
3
|
|
26
|
+
])
|
|
27
|
+
};
|
|
28
|
+
function s(r, s, c) {
|
|
29
|
+
let l = r.paintScratch, u = i(s.fill)?.bind;
|
|
30
|
+
if (!l || !u) return null;
|
|
31
|
+
let d = r.deviceWidth && r.widthCss > 0 ? r.deviceWidth / r.widthCss : 1, f = r.deviceWidth ?? Math.round(r.widthCss), p = r.deviceHeight ?? Math.round(r.heightCss), m = Math.max(0, Math.floor(c.x0 * d)), h = Math.max(0, Math.floor(c.y0 * d)), g = r.imageCache.maxTextureSide, _ = Math.min(g, Math.min(f, Math.ceil(c.x1 * d)) - m), v = Math.min(g, Math.min(p, Math.ceil(c.y1 * d)) - h);
|
|
32
|
+
if (!(_ > 0 && v > 0)) return null;
|
|
33
|
+
let y = m / d, b = h / d, x = _ / d, S = v / d, C = new Float32Array([
|
|
34
|
+
x,
|
|
35
|
+
0,
|
|
36
|
+
0,
|
|
37
|
+
0,
|
|
38
|
+
S,
|
|
39
|
+
0,
|
|
40
|
+
y,
|
|
41
|
+
b,
|
|
42
|
+
1
|
|
43
|
+
]), w = new Float32Array([
|
|
44
|
+
2 / x,
|
|
45
|
+
0,
|
|
46
|
+
0,
|
|
47
|
+
0,
|
|
48
|
+
2 / S,
|
|
49
|
+
0,
|
|
50
|
+
-1 - 2 * y / x,
|
|
51
|
+
-1 - 2 * b / S,
|
|
52
|
+
1
|
|
53
|
+
]), T = a(r), E = {
|
|
54
|
+
...T,
|
|
55
|
+
alpha: r.state.alpha,
|
|
56
|
+
maxTextureSize: T.maxTextureSize,
|
|
57
|
+
setProjAndModel: (e) => t(r, e, C, w)
|
|
58
|
+
}, D = r.gl, O = l.acquire(_, v), k = D.isEnabled(D.SCISSOR_TEST);
|
|
59
|
+
D.activeTexture(D.TEXTURE0), D.bindTexture(D.TEXTURE_2D, null), D.bindFramebuffer(D.FRAMEBUFFER, O.fbo), D.viewport(0, 0, _, v), D.disable(D.SCISSOR_TEST), D.disable(D.STENCIL_TEST), D.clear(D.COLOR_BUFFER_BIT), D.disable(D.BLEND);
|
|
60
|
+
let A = u(E, s);
|
|
61
|
+
return A && (D.bindVertexArray(r.meshCache.uploadRecurring(o).vao), e(r, o.indices.length, D.UNSIGNED_INT), D.bindVertexArray(null)), D.enable(D.BLEND), n(r, f, p, k), A ? {
|
|
62
|
+
texture: O.texture,
|
|
63
|
+
uvFromScreen: new Float32Array([
|
|
64
|
+
d / O.width,
|
|
65
|
+
0,
|
|
66
|
+
0,
|
|
67
|
+
0,
|
|
68
|
+
d / O.height,
|
|
69
|
+
0,
|
|
70
|
+
-m / O.width,
|
|
71
|
+
-h / O.height,
|
|
72
|
+
1
|
|
73
|
+
])
|
|
74
|
+
} : null;
|
|
75
|
+
}
|
|
76
|
+
function c(e, n, i) {
|
|
77
|
+
let a = e.gl;
|
|
78
|
+
return a.useProgram(n.handle), t(e, n, r), a.uniformMatrix3fv(n.uniform("u_worldInv"), !1, i.uvFromScreen), a.activeTexture(a.TEXTURE0), a.bindTexture(a.TEXTURE_2D, i.texture), a.uniform1i(n.uniform("u_sampler"), 0), n;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
export { c as bindScratchPaint, s as renderPaintToScratch };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=scratchPass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scratchPass.js","names":["UNIT_QUAD","renderPaintToScratch","scratch","ctx","bind","getPaintKind","fill","ratio","deviceW","deviceH","px0","rect","py0","maxSide","pw","ph","x0","y0","w","h","model","proj","base","paintBindContext","bindCtx","setProjAndModel","prog","gl","target","scissorWasOn","drawTriangles","returnToRenderTarget","bindScratchPaint","BATCH_MODEL","painted"],"sources":["../../../src/renderer/draw/scratchPass.ts"],"sourcesContent":["import type { FillStyle } from '@weasel-js/paint';\nimport { getPaintKind, type PaintBindContext } from 'core/paintKinds';\nimport type { ShaderProgram } from '../shaders/ShaderProgram';\nimport type { GlMat3 } from '../math/mat3';\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 = getPaintKind(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"],"mappings":";;;;;;;AAeA,IAAMA,IAAkB;CACtB,UAAU,IAAI,aAAa;EAAC;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;CAAC,CAAC;CACnD,SAAS,IAAI,YAAY;EAAC;EAAG;EAAG;EAAG;EAAG;EAAG;CAAC,CAAC;AAC7C;AAwBA,SAAgBC,EAAqB,GAAkB,GAAiB,GAAuC;CAC7G,IAAMC,IAAUC,EAAI,cACdC,IAAOC,EAAaC,EAAK,IAAI,CAAC,EAAE;CACtC,IAAI,CAACJ,KAAW,CAACE,GAAM,OAAO;CAC9B,IAAMG,IAAQJ,EAAI,eAAeA,EAAI,WAAW,IAAIA,EAAI,cAAcA,EAAI,WAAW,GAC/EK,IAAUL,EAAI,eAAe,KAAK,MAAMA,EAAI,QAAQ,GACpDM,IAAUN,EAAI,gBAAgB,KAAK,MAAMA,EAAI,SAAS,GACtDO,IAAM,KAAK,IAAI,GAAG,KAAK,MAAMC,EAAK,KAAKJ,CAAK,CAAC,GAC7CK,IAAM,KAAK,IAAI,GAAG,KAAK,MAAMD,EAAK,KAAKJ,CAAK,CAAC,GAC7CM,IAAUV,EAAI,WAAW,gBACzBW,IAAK,KAAK,IAAID,GAAS,KAAK,IAAIL,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,UAAU,gBAAgBH,CAAS,CAAC,CAAC,GAAG,GAC/D8B,EAAc3B,GAAKH,EAAU,QAAQ,QAAQ2B,EAAG,YAAY,GAC5DA,EAAG,gBAAgB,IAAI,IAGzBA,EAAG,OAAOA,EAAG,KAAK,GAClBI,EAAqB5B,GAAKK,GAASC,GAASoB,CAAY,GACnDH,IACE;EACL,SAASE,EAAO;EAChB,cAAc,IAAI,aAAa;GAC7BrB,IAAQqB,EAAO;GAAO;GAAG;GACzB;GAAGrB,IAAQqB,EAAO;GAAQ;GAC1B,CAAClB,IAAMkB,EAAO;GAAO,CAAChB,IAAMgB,EAAO;GAAQ;EAC7C,CAAC;CACH,IARkB;AASpB;AAGA,SAAgBI,EAAiB,GAAkB,GAAqB,GAAsC;CAC5G,IAAML,IAAKxB,EAAI;CAOf,OANAwB,EAAG,WAAWD,EAAK,MAAM,GACzBD,EAAgBtB,GAAKuB,GAAMO,CAAW,GACtCN,EAAG,iBAAiBD,EAAK,QAAQ,YAAY,GAAI,IAAOQ,EAAQ,YAAY,GAC5EP,EAAG,cAAcA,EAAG,QAAQ,GAC5BA,EAAG,YAAYA,EAAG,YAAYO,EAAQ,OAAO,GAC7CP,EAAG,UAAUD,EAAK,QAAQ,WAAW,GAAI,CAAC,GACnCA;AACT"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { drawTriangles as e } from "./drawTriangles.js";
|
|
2
|
+
//#region src/renderer/draw/stencil.ts
|
|
3
|
+
function t(e, t = e.clipDepth) {
|
|
4
|
+
let r = e.gl;
|
|
5
|
+
if (t === 0) {
|
|
6
|
+
r.disable(r.STENCIL_TEST);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
let i = n(t);
|
|
10
|
+
r.enable(r.STENCIL_TEST), r.stencilFunc(r.EQUAL, i, i), r.stencilOp(r.KEEP, r.KEEP, r.KEEP);
|
|
11
|
+
}
|
|
12
|
+
function n(e) {
|
|
13
|
+
return e === 0 ? 0 : (1 << e + 1) - 1 & 254;
|
|
14
|
+
}
|
|
15
|
+
function r(t, r) {
|
|
16
|
+
let i = t.gl;
|
|
17
|
+
i.enable(i.STENCIL_TEST), i.colorMask(!1, !1, !1, !1), i.stencilMask(1), i.stencilFunc(i.ALWAYS, 0, 1), i.stencilOp(i.KEEP, i.KEEP, i.INVERT), e(t, r, t.gl.UNSIGNED_INT);
|
|
18
|
+
let a = n(t.clipDepth);
|
|
19
|
+
i.colorMask(!0, !0, !0, !0), i.stencilFunc(i.EQUAL, a | 1, a | 1), i.stencilOp(i.KEEP, i.KEEP, i.KEEP);
|
|
20
|
+
}
|
|
21
|
+
function i(e) {
|
|
22
|
+
let t = e.gl;
|
|
23
|
+
t.stencilMask(1), t.clear(t.STENCIL_BUFFER_BIT), t.disable(t.STENCIL_TEST);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { n as ancestorMask, t as applyClipTest, r as beginParityMask, i as endParityMask };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=stencil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stencil.js","names":["applyClipTest","ctx","gl","depth","mask","ancestorMask","beginParityMask","drawTriangles","indexCount","clipMask","endParityMask"],"sources":["../../../src/renderer/draw/stencil.ts"],"sourcesContent":["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"],"mappings":";;AAeA,SAAgBA,EAAc,GAAkB,IAAgBC,EAAI,WAAiB;CACnF,IAAMC,IAAKD,EAAI;CACf,IAAIE,MAAU,GAAG;EACf,EAAG,QAAQD,EAAG,YAAY;EAC1B;CACF;CACA,IAAME,IAAOC,EAAaF,CAAK;CAG/B,AAFAD,EAAG,OAAOA,EAAG,YAAY,GACzBA,EAAG,YAAYA,EAAG,OAAOE,GAAMA,CAAI,GACnCF,EAAG,UAAUA,EAAG,MAAMA,EAAG,MAAMA,EAAG,IAAI;AACxC;AASA,SAAgBG,EAAa,GAAuB;CAClD,OAAOF,MAAU,IAAI,KAAM,KAAMA,IAAQ,KAAM,IAAK;AACtD;AAOA,SAAgBG,EAAgB,GAAkB,GAA0B;CAC1E,IAAMJ,IAAKD,EAAI;CAMf,AALAC,EAAG,OAAOA,EAAG,YAAY,GACzBA,EAAG,UAAU,IAAO,IAAO,IAAO,EAAK,GACvCA,EAAG,YAAY,CAAI,GACnBA,EAAG,YAAYA,EAAG,QAAQ,GAAG,CAAI,GACjCA,EAAG,UAAUA,EAAG,MAAMA,EAAG,MAAMA,EAAG,MAAM,GACxCK,EAAcN,GAAKO,GAAYP,EAAI,GAAG,YAAY;CAElD,IAAMQ,IAAWJ,EAAaJ,EAAI,SAAS;CAG3C,AAFAC,EAAG,UAAU,IAAM,IAAM,IAAM,EAAI,GACnCA,EAAG,YAAYA,EAAG,OAAOO,IAAW,GAAMA,IAAW,CAAI,GACzDP,EAAG,UAAUA,EAAG,MAAMA,EAAG,MAAMA,EAAG,IAAI;AACxC;AAEA,SAAgBQ,EAAc,GAAwB;CACpD,IAAMR,IAAKD,EAAI;CAKf,AAFAC,EAAG,YAAY,CAAI,GACnBA,EAAG,MAAMA,EAAG,kBAAkB,GAC9BA,EAAG,QAAQA,EAAG,YAAY;AAC5B"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { resolveColor as e } from "../math/color.js";
|
|
2
|
+
import { drawTriangles as t } from "./drawTriangles.js";
|
|
3
|
+
import { applyClipTest as n } from "./stencil.js";
|
|
4
|
+
import { BATCH_MODEL as r, flushBatch as i } from "./flushBatch.js";
|
|
5
|
+
import { enterUncut as a, flushForOwnDraw as o, leaveUncut as s } from "./clip.js";
|
|
6
|
+
import { batchPaint as c } from "./gradient.js";
|
|
7
|
+
import { stageGlyphs as l, stageSolid as u, tryStageFill as d } from "./batch.js";
|
|
8
|
+
import { bindGradient as f, bindPattern as p } from "./paintBind.js";
|
|
9
|
+
import { drawPathFillByKind as m } from "./pathPaint.js";
|
|
10
|
+
import { SYNTHETIC_ITALIC_RADIANS as h } from "../syntheticItalic.js";
|
|
11
|
+
import { outlineGroupMesh as g, outlineGroupStrokeMesh as _ } from "../glyphOutlineMesh.js";
|
|
12
|
+
import { bindScratchPaint as v, renderPaintToScratch as y } from "./scratchPass.js";
|
|
13
|
+
import { GLYPH_MODE_MSDF as b, GLYPH_MODE_R8 as x, dynamicPageTextureId as S, ensureFontTexture as C, glyphFieldScale as w, syncDynamicPageTexture as T, textureCacheKey as E } from "@weasel-js/font";
|
|
14
|
+
import { cachedLayoutRuns as D, resolveTextStyle as O, verticalAlignOffset as k } from "@weasel-js/text";
|
|
15
|
+
//#region src/renderer/draw/text.ts
|
|
16
|
+
var A = 48;
|
|
17
|
+
function j(e) {
|
|
18
|
+
let t = Math.hypot(e[0], e[1]), n = Math.hypot(e[3], e[4]);
|
|
19
|
+
return Math.sqrt(t * n) || 1;
|
|
20
|
+
}
|
|
21
|
+
function M(e, t) {
|
|
22
|
+
let n = O(t.style), r = n.lineHeight, i = t.align ?? n.align, a = t.direction ?? n.direction, o = t.maxWidth ?? Infinity, s = e.textOutlineMinScreenSize ?? A, c = Number.isFinite(s) ? s / j(e.state.transform) : void 0, l = D(t.runs, {
|
|
23
|
+
maxWidth: o,
|
|
24
|
+
alignWidth: t.width,
|
|
25
|
+
lineHeight: r,
|
|
26
|
+
align: i,
|
|
27
|
+
direction: a,
|
|
28
|
+
tabSize: n.tabSize,
|
|
29
|
+
justify: t.justify,
|
|
30
|
+
outlineMinSize: c
|
|
31
|
+
});
|
|
32
|
+
if (l.groups.length === 0 && l.decorations.length === 0) return;
|
|
33
|
+
let u = t.x, d = t.y + k(t.verticalAlign, t.height, l.bounds.height);
|
|
34
|
+
for (let t of l.groups) t.source === "outline" ? N(e, t, u, d) : R(e, t, u, d);
|
|
35
|
+
F(e, l.decorations, u, d);
|
|
36
|
+
}
|
|
37
|
+
function N(e, t, n, r) {
|
|
38
|
+
let i = t.fill;
|
|
39
|
+
if (i !== null) {
|
|
40
|
+
let a = g(t, n, r);
|
|
41
|
+
a && P(e, i, a);
|
|
42
|
+
}
|
|
43
|
+
let a = t.stroke?.paint;
|
|
44
|
+
if (!a) return;
|
|
45
|
+
let o = _(t, n, r, e.state.transform);
|
|
46
|
+
o && P(e, a, o);
|
|
47
|
+
}
|
|
48
|
+
function P(e, t, n) {
|
|
49
|
+
let r = c(e, t, !1);
|
|
50
|
+
r !== null && (d(e, n, r) || m(e, t, e.meshCache.uploadTransient(n)));
|
|
51
|
+
}
|
|
52
|
+
function F(t, n, r, i) {
|
|
53
|
+
for (let o of n) {
|
|
54
|
+
if (z(o.fill) !== null) {
|
|
55
|
+
P(t, o.fill, I(o.x0 + r, o.y0 + i, o.x1 + r, o.y1 + i));
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
let [n, c, l, d] = "color" in o.fill ? e(o.fill.color) : [
|
|
59
|
+
0,
|
|
60
|
+
0,
|
|
61
|
+
0,
|
|
62
|
+
1
|
|
63
|
+
], f;
|
|
64
|
+
for (;;) {
|
|
65
|
+
let e = u(t, 4);
|
|
66
|
+
if (t.drawBatch.pushRect(o.x0 + r, o.y0 + i, o.x1 - o.x0, o.y1 - o.y0, t.state.transform, n, c, l, d * (e.foldsAlpha ? t.state.alpha : 1))) break;
|
|
67
|
+
f = a(t);
|
|
68
|
+
}
|
|
69
|
+
f !== void 0 && s(t, f);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function I(e, t, n, r) {
|
|
73
|
+
return {
|
|
74
|
+
vertices: new Float32Array([
|
|
75
|
+
e,
|
|
76
|
+
t,
|
|
77
|
+
n,
|
|
78
|
+
t,
|
|
79
|
+
n,
|
|
80
|
+
r,
|
|
81
|
+
e,
|
|
82
|
+
r
|
|
83
|
+
]),
|
|
84
|
+
indices: new Uint32Array([
|
|
85
|
+
0,
|
|
86
|
+
1,
|
|
87
|
+
2,
|
|
88
|
+
0,
|
|
89
|
+
2,
|
|
90
|
+
3
|
|
91
|
+
])
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
var L = .08;
|
|
95
|
+
function R(t, n, r, o) {
|
|
96
|
+
if (n.source === "canvas") {
|
|
97
|
+
if (!T(t.textureCache, n.page)) return;
|
|
98
|
+
} else if (!C(n.family, n.weight, n.style, t.textureCache)) return;
|
|
99
|
+
if (n.quads.length === 0) return;
|
|
100
|
+
let c = n.source === "canvas" ? S(n.page) : E(n.family, n.weight, n.style), u = n.source === "canvas" ? x : b, d = w(n.source === "canvas" ? "canvas" : "atlas", n.family, n.weight, n.style);
|
|
101
|
+
if (!d) return;
|
|
102
|
+
let f = n.synthetic.bold ? L : 0, p = n.synthetic.italic ? Math.tan(h) : 0, m = z(n.fill);
|
|
103
|
+
if (m !== null) {
|
|
104
|
+
V(t, n, r, o, m, c, u, f, p, d);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
let g = n.fill !== null && "color" in n.fill ? e(n.fill.color) : [
|
|
108
|
+
0,
|
|
109
|
+
0,
|
|
110
|
+
0,
|
|
111
|
+
1
|
|
112
|
+
], _ = t.drawBatch, v = t.state.transform, { staged: y, slot: D } = l(t, c, d, f), O = g[3] * (y.foldsAlpha ? t.state.alpha : 1);
|
|
113
|
+
for (let e of n.quads) {
|
|
114
|
+
_.wouldOverflow(4) && (i(t), {staged: y, slot: D} = l(t, c, d, f), O = g[3] * (y.foldsAlpha ? t.state.alpha : 1));
|
|
115
|
+
let n;
|
|
116
|
+
for (; !_.pushGlyph(e.x0 + r, e.y0 + o, e.x1 + r, e.y1 + o, e.baselineY + o, p, v, e.u0, e.v0, e.u1, e.v1, g[0], g[1], g[2], O, D, u);) n = a(t), {staged: y, slot: D} = l(t, c, d, f), O = g[3] * (y.foldsAlpha ? t.state.alpha : 1);
|
|
117
|
+
n !== void 0 && (s(t, n), {staged: y, slot: D} = l(t, c, d, f), O = g[3] * (y.foldsAlpha ? t.state.alpha : 1));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function z(e) {
|
|
121
|
+
let t = e?.fill ?? "solid";
|
|
122
|
+
return t === "pattern" ? "pattern" : t === "linear-gradient" || t === "radial-gradient" || t === "conic-gradient" ? "gradient" : t === "solid" ? null : "texture";
|
|
123
|
+
}
|
|
124
|
+
var B = 1;
|
|
125
|
+
function V(e, t, i, a, s, c, l, u, d, m) {
|
|
126
|
+
let h = e.glyphPaintProgram?.(s);
|
|
127
|
+
if (!h) return;
|
|
128
|
+
o(e);
|
|
129
|
+
let g = t.fill, _ = e.state.transform, b;
|
|
130
|
+
if (s === "pattern") b = p(e, h, g, r);
|
|
131
|
+
else if (s === "gradient") b = f(e, h, g, r);
|
|
132
|
+
else {
|
|
133
|
+
let n = y(e, g, U(t, i, a, d, _));
|
|
134
|
+
b = n && v(e, h, n);
|
|
135
|
+
}
|
|
136
|
+
if (!b) return;
|
|
137
|
+
let x = e.gl;
|
|
138
|
+
e.textureCache.bind(c, B), x.uniform1i(h.uniform("u_atlas"), B), x.uniform1f(h.uniform("u_synthBold"), u), x.uniform2f(h.uniform("u_fieldScale"), m[0], m[1]), n(e);
|
|
139
|
+
let S = e.drawBatch, C = S.clip;
|
|
140
|
+
S.clip = null;
|
|
141
|
+
for (let n of t.quads) S.wouldOverflow(4) && H(e), S.pushGlyph(n.x0 + i, n.y0 + a, n.x1 + i, n.y1 + a, n.baselineY + a, d, _, n.u0, n.v0, n.u1, n.v1, 1, 1, 1, 1, B, l);
|
|
142
|
+
H(e), S.clip = C, x.activeTexture(x.TEXTURE0), x.bindVertexArray(null);
|
|
143
|
+
}
|
|
144
|
+
function H(e) {
|
|
145
|
+
let n = e.drawBatch;
|
|
146
|
+
n.length !== 0 && (t(e, n.uploadAndBind(), e.gl.UNSIGNED_INT), n.reset());
|
|
147
|
+
}
|
|
148
|
+
function U(e, t, n, r, i) {
|
|
149
|
+
let a = {
|
|
150
|
+
x0: Infinity,
|
|
151
|
+
y0: Infinity,
|
|
152
|
+
x1: -Infinity,
|
|
153
|
+
y1: -Infinity
|
|
154
|
+
}, o = (e, t) => {
|
|
155
|
+
let n = i[0] * e + i[3] * t + i[6], r = i[1] * e + i[4] * t + i[7];
|
|
156
|
+
n < a.x0 && (a.x0 = n), n > a.x1 && (a.x1 = n), r < a.y0 && (a.y0 = r), r > a.y1 && (a.y1 = r);
|
|
157
|
+
};
|
|
158
|
+
for (let i of e.quads) {
|
|
159
|
+
let e = i.x0 + t, a = i.x1 + t, s = i.y0 + n, c = i.y1 + n, l = i.baselineY + n, u = (l - s) * r, d = (l - c) * r;
|
|
160
|
+
o(e + u, s), o(a + u, s), o(a + d, c), o(e + d, c);
|
|
161
|
+
}
|
|
162
|
+
return a;
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
export { A as OUTLINE_MIN_SCREEN_PX, M as drawText };
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","names":["OUTLINE_MIN_SCREEN_PX","modelScale","sx","m","sy","drawText","style","resolveTextStyle","cmd","lineHeight","align","direction","maxWidth","minScreen","ctx","outlineMinSize","laid","cachedLayoutRuns","dx","dy","verticalAlignOffset","group","drawTextOutlineGroup","drawTextGroup","fill","mesh","outlineGroupMesh","drawOutlineMesh","strokePaint","ribbon","outlineGroupStrokeMesh","paint","batchPaint","tryStageFill","drawPathFillByKind","drawTextDecorations","d","decorations","glyphPaintKindOf","ruleMesh","r","g","b","a","resolveColor","cut","staged","stageSolid","enterUncut","leaveUncut","x0","y0","x1","y1","SYNTH_BOLD_AMOUNT","syncDynamicPageTexture","ensureFontTexture","atlasId","dynamicPageTextureId","textureCacheKey","mode","GLYPH_MODE_R8","GLYPH_MODE_MSDF","fieldScale","glyphFieldScale","bold","tanItalic","SYNTHETIC_ITALIC_RADIANS","paintKind","color","batch","stageGlyphs","alpha","q","flushBatch","slot","kind","GLYPH_PAINT_ATLAS_UNIT","drawPaintedGlyphs","prog","bound","bindPattern","BATCH_MODEL","bindGradient","painted","renderPaintToScratch","glyphScreenBounds","bindScratchPaint","gl","applyClipTest","drawStagedGlyphs","drawTriangles","add","x","y","base","top","bottom"],"sources":["../../../src/renderer/draw/text.ts"],"sourcesContent":["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 '../math/mat3';\nimport type { Mesh } from '@weasel-js/geom/tessellate';\nimport { resolveColor } from '../math/color';\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 '../syntheticItalic';\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"],"mappings":";;;;;;;;;;;;;;;AAiDA,IAAaA,IAAwB;AAarC,SAASC,EAAW,GAAmB;CACrC,IAAMC,IAAK,KAAK,MAAMC,EAAE,IAAIA,EAAE,EAAE,GAC1BC,IAAK,KAAK,MAAMD,EAAE,IAAIA,EAAE,EAAE;CAChC,OAAO,KAAK,KAAKD,IAAKE,CAAE,KAAK;AAC/B;AAEA,SAAgBC,EAAS,GAAkB,GAA4B;CACrE,IAAMC,IAAQC,EAAiBC,EAAI,KAAK,GAClCC,IAAaH,EAAM,YACnBI,IAAQF,EAAI,SAASF,EAAM,OAC3BK,IAAYH,EAAI,aAAaF,EAAM,WACnCM,IAAWJ,EAAI,YAAY,UAK3BK,IAAYC,EAAI,4BAA4Bd,GAC5Ce,IAAiB,OAAO,SAASF,CAAS,IAC5CA,IAAYZ,EAAWa,EAAI,MAAM,SAAS,IAC1C,KAAA,GAEEE,IAAOC,EAAiBT,EAAI,MAAM;EACtC;EAAU,YAAYA,EAAI;EAAO;EAAY;EAAO;EAAW,SAASF,EAAM;EAAS,SAASE,EAAI;EAAS;CAC/G,CAAC;CAID,IAAIQ,EAAK,OAAO,WAAW,KAAKA,EAAK,YAAY,WAAW,GAAG;CAQ/D,IAAME,IAAKV,EAAI,GACTW,IAAKX,EAAI,IAAIY,EAAoBZ,EAAI,eAAeA,EAAI,QAAQQ,E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GAAIkC,IAAKoB,EAAE,KAAKtD,GAC5D4E,IAAOtB,EAAE,YAAYtD,GACrB6E,KAAOD,IAAO5C,KAAMe,GACpB+B,KAAUF,IAAO1C,KAAMa;EAI7B,AAHA0B,EAAI1C,IAAK8C,GAAK7C,CAAE,GAChByC,EAAIxC,IAAK4C,GAAK7C,CAAE,GAChByC,EAAIxC,IAAK6C,GAAQ5C,CAAE,GACnBuC,EAAI1C,IAAK+C,GAAQ5C,CAAE;CACrB;CACA,OAAOX;AACT"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { resolveColor as e } from "../math/color.js";
|
|
2
|
+
import { mat3 as t } from "../math/mat3.js";
|
|
3
|
+
//#region src/renderer/draw/uniforms.ts
|
|
4
|
+
var n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function i(e, t) {
|
|
6
|
+
let r = n.get(e);
|
|
7
|
+
r || (r = /* @__PURE__ */ new WeakMap(), n.set(e, r));
|
|
8
|
+
let i = r.get(t);
|
|
9
|
+
return i || (i = {}, r.set(t, i)), i;
|
|
10
|
+
}
|
|
11
|
+
function a(e, t) {
|
|
12
|
+
if (e === void 0 || e.length !== t.length) return !1;
|
|
13
|
+
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
14
|
+
return !0;
|
|
15
|
+
}
|
|
16
|
+
function o(e, t, n, r, a, o) {
|
|
17
|
+
let s = t.uniform("u_color");
|
|
18
|
+
if (s === void 0) return;
|
|
19
|
+
let c = i(e, t), l = c.color;
|
|
20
|
+
(l === void 0 || l[0] !== n || l[1] !== r || l[2] !== a || l[3] !== o) && (e.gl.uniform4f(s, n, r, a, o), c.color = [
|
|
21
|
+
n,
|
|
22
|
+
r,
|
|
23
|
+
a,
|
|
24
|
+
o
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
function s(e, t, n) {
|
|
28
|
+
let r = t.uniform("u_alpha");
|
|
29
|
+
if (r === void 0) return;
|
|
30
|
+
let a = i(e, t);
|
|
31
|
+
a.alpha !== n && (e.gl.uniform1f(r, n), a.alpha = n);
|
|
32
|
+
}
|
|
33
|
+
function c(e) {
|
|
34
|
+
let n = r.get(e);
|
|
35
|
+
return n || (n = t.toUniform(t.screenToClip(e.widthCss, e.heightCss)), r.set(e, n)), n;
|
|
36
|
+
}
|
|
37
|
+
var l = /* @__PURE__ */ new Float32Array(16);
|
|
38
|
+
function u(e, t, n = e.state.colorMatrix) {
|
|
39
|
+
let r = e.gl, o = i(e, t), s = t.uniform("u_colorMatrix");
|
|
40
|
+
if (s !== void 0) {
|
|
41
|
+
for (let e = 0; e < 4; e++) for (let t = 0; t < 4; t++) l[t * 4 + e] = n[e * 5 + t];
|
|
42
|
+
a(o.colorMatrix, l) || (r.uniformMatrix4fv(s, !1, l), o.colorMatrix = Float32Array.from(l));
|
|
43
|
+
}
|
|
44
|
+
let c = t.uniform("u_colorBias");
|
|
45
|
+
if (c !== void 0) {
|
|
46
|
+
let e = [
|
|
47
|
+
n[4],
|
|
48
|
+
n[9],
|
|
49
|
+
n[14],
|
|
50
|
+
n[19]
|
|
51
|
+
];
|
|
52
|
+
a(o.colorBias, e) || (r.uniform4f(c, e[0], e[1], e[2], e[3]), o.colorBias = Float32Array.from(e));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
var d = 65536, f = /* @__PURE__ */ new Float32Array(9), p = /* @__PURE__ */ new Float32Array(9);
|
|
56
|
+
function m(e, t, n = e.state.transform, r = c(e)) {
|
|
57
|
+
let o = e.gl, s = i(e, t);
|
|
58
|
+
p.set(r), a(s.proj, p) || (o.uniformMatrix3fv(t.uniform("u_proj"), !1, p), s.proj = Float32Array.from(p)), f.set(n);
|
|
59
|
+
let l = t.uniform("u_origin");
|
|
60
|
+
if (l !== void 0) {
|
|
61
|
+
let e = 0, t = 0, r = n[6], i = n[7];
|
|
62
|
+
if (Math.abs(r) >= d || Math.abs(i) >= d) {
|
|
63
|
+
let a = n[0], o = n[1], s = n[3], c = n[4], l = a * c - o * s, u = Math.fround((s * i - c * r) / l), d = Math.fround((o * r - a * i) / l);
|
|
64
|
+
Number.isFinite(u) && Number.isFinite(d) && (e = u, t = d, f[6] = a * e + s * t + r, f[7] = o * e + c * t + i);
|
|
65
|
+
}
|
|
66
|
+
(s.originX !== e || s.originY !== t) && (o.uniform2f(l, e, t), s.originX = e, s.originY = t);
|
|
67
|
+
}
|
|
68
|
+
a(s.model, f) || (o.uniformMatrix3fv(t.uniform("u_model"), !1, f), s.model = Float32Array.from(f));
|
|
69
|
+
}
|
|
70
|
+
function h(t, n, r, i) {
|
|
71
|
+
let [a, c, l, u] = e(r);
|
|
72
|
+
o(t, n, a, c, l, u * (i ?? 1)), s(t, n, t.state.alpha);
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { d as REBASE_TRANSLATION_PX, a as sameValues, s as setAlphaUniform, u as setColorMatrixUniforms, o as setColorUniform, m as setProjAndModel, h as setSolidPaintUniforms };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=uniforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniforms.js","names":["FRAME_UPLOADS","FRAME_PROJ","uploadedFor","byProgram","ctx","uploaded","prog","sameValues","prev","next","i","setColorUniform","loc","r","g","b","a","setAlphaUniform","alpha","projFor","proj","mat3","COLOR_MATRIX_SCRATCH","setColorMatrixUniforms","gl","mLoc","row","col","cm","bLoc","bias","REBASE_TRANSLATION_PX","MODEL_SCRATCH","PROJ_SCRATCH","setProjAndModel","model","originLoc","ox","oy","tx","ty","c","d","det","lx","ly","setSolidPaintUniforms","resolveColor","color","opacity"],"sources":["../../../src/renderer/draw/uniforms.ts"],"sourcesContent":["import type { ShaderProgram } from '../shaders/ShaderProgram';\nimport { mat3, type GlMat3 } from '../math/mat3';\nimport { resolveColor } from '../math/color';\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"],"mappings":";;;AAsCA,IAAMA,oBAAgB,IAAI,QAA+D,GAEnFC,oBAAa,IAAI,QAA6B;AAEpD,SAASC,EAAY,GAAkB,GAAuC;CAC5E,IAAIC,IAAYH,EAAc,IAAII,CAAG;CACrC,AAAKD,MACH,oBAAY,IAAI,QAAQ,GACxBH,EAAc,IAAII,GAAKD,CAAS;CAElC,IAAIE,IAAWF,EAAU,IAAIG,CAAI;CAKjC,OAJKD,MACH,IAAW,CAAC,GACZF,EAAU,IAAIG,GAAMD,CAAQ,IAEvBA;AACT;AAKA,SAAgBE,EAAW,GAAgC,GAAkC;CAC3F,IAAIC,MAAS,KAAA,KAAaA,EAAK,WAAWC,EAAK,QAAQ,OAAO;CAC9D,KAAK,IAAIC,IAAI,GAAGA,IAAIF,EAAK,QAAQ,KAAK,IAAIA,EAAKE,OAAOD,EAAKC,IAAI,OAAO;CACtE,OAAO;AACT;AAUA,SAAgBC,EACd,GAAkB,GAClB,GAAW,GAAW,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