@yft-design/engine 0.0.17 → 0.0.19
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 +23 -11
- package/dist/EngineCanvas.d.ts +0 -255
- package/dist/core/color.d.ts +0 -11
- package/dist/core/distanceField.d.ts +0 -13
- package/dist/core/events.d.ts +0 -25
- package/dist/core/gradient.d.ts +0 -47
- package/dist/core/homography.d.ts +0 -20
- package/dist/core/imageFilters.d.ts +0 -31
- package/dist/core/mat2d.d.ts +0 -62
- package/dist/core/pathData.d.ts +0 -36
- package/dist/core/pattern.d.ts +0 -14
- package/dist/core/point.d.ts +0 -14
- package/dist/core/psdEffects.d.ts +0 -48
- package/dist/core/roundedRect.d.ts +0 -48
- package/dist/core/shadow.d.ts +0 -23
- package/dist/core/snap.d.ts +0 -103
- package/dist/core/stroke.d.ts +0 -13
- package/dist/core/triangulate.d.ts +0 -31
- package/dist/core/warpMesh.d.ts +0 -38
- package/dist/debug/canvasInspection.d.ts +0 -20
- package/dist/debug/pixelDiff.d.ts +0 -7
- package/dist/debug/pixelDiff.js +1 -64
- package/dist/debug/seed.d.ts +0 -426
- package/dist/debug/seed.js +28 -3806
- package/dist/decoders/webp2sprite.d.ts +0 -16
- package/dist/engineFlag.d.ts +0 -76
- package/dist/export/SceneExporter.d.ts +0 -58
- package/dist/export/glExport.d.ts +0 -41
- package/dist/export/svgExport.d.ts +0 -181
- package/dist/index.d.ts +1 -14
- package/dist/index.js +1060 -64
- package/dist/interact/animationPlayback.d.ts +0 -62
- package/dist/interact/canvasInteractions.d.ts +1 -38
- package/dist/interact/cropSession.d.ts +0 -68
- package/dist/interact/dblClick.d.ts +0 -32
- package/dist/interact/expandSession.d.ts +0 -46
- package/dist/interact/hotkeyActions.d.ts +0 -12
- package/dist/interact/pageTransfer.d.ts +0 -2
- package/dist/interact/pathSession.d.ts +0 -42
- package/dist/interact/pointer.d.ts +0 -87
- package/dist/interact/pointerTablePuzzle.d.ts +0 -60
- package/dist/interact/pointerTransform.d.ts +0 -48
- package/dist/interact/pointerTypes.d.ts +6 -148
- package/dist/interact/snapGuide.d.ts +0 -68
- package/dist/interact/tableCellEditing.d.ts +0 -34
- package/dist/interact/tableInteraction.d.ts +0 -31
- package/dist/interact/textEditing.d.ts +0 -44
- package/dist/interact/warpFacade.d.ts +0 -5
- package/dist/interact/warpSession.d.ts +0 -55
- package/dist/interact/wheelScroll.d.ts +0 -42
- package/dist/model/alphaHit.d.ts +0 -51
- package/dist/model/animation.d.ts +0 -99
- package/dist/model/arcLayout.d.ts +0 -33
- package/dist/model/arcTextTransform.d.ts +0 -4
- package/dist/model/compatEvents.d.ts +0 -72
- package/dist/model/compatObject.d.ts +0 -360
- package/dist/model/cropEdit.d.ts +0 -60
- package/dist/model/document.d.ts +0 -167
- package/dist/model/elementTypes.d.ts +0 -47
- package/dist/model/expandEdit.d.ts +0 -36
- package/dist/model/fabricPrimitives.d.ts +0 -24
- package/dist/model/filler.d.ts +0 -12
- package/dist/model/groupAssemble.d.ts +0 -5
- package/dist/model/groupChildMove.d.ts +0 -37
- package/dist/model/groupResize.d.ts +0 -42
- package/dist/model/handles.d.ts +0 -24
- package/dist/model/imageMaskBake.d.ts +0 -50
- package/dist/model/lineConstruct.d.ts +0 -8
- package/dist/model/maskCropEdit.d.ts +0 -34
- package/dist/model/pathBackground.d.ts +0 -33
- package/dist/model/pathConstruct.d.ts +0 -24
- package/dist/model/pathEdit.d.ts +0 -55
- package/dist/model/puzzleEdit.d.ts +0 -66
- package/dist/model/puzzleLayout.d.ts +0 -31
- package/dist/model/scene.d.ts +0 -603
- package/dist/model/schema.d.ts +0 -48
- package/dist/model/shapePath.d.ts +0 -5
- package/dist/model/smartObjectBake.d.ts +0 -6
- package/dist/model/tableEdit.d.ts +0 -90
- package/dist/model/tableFacade.d.ts +0 -5
- package/dist/model/tableLayout.d.ts +0 -40
- package/dist/model/textAlign.d.ts +0 -22
- package/dist/model/textLayout.d.ts +0 -213
- package/dist/render/GLBlend.d.ts +0 -24
- package/dist/render/GLContext.d.ts +0 -11
- package/dist/render/GLIsolate.d.ts +0 -25
- package/dist/render/GLTextureCache.d.ts +0 -72
- package/dist/render/GlyphAtlas.d.ts +0 -98
- package/dist/render/MeshBatch.d.ts +0 -71
- package/dist/render/QuadBatch.d.ts +0 -87
- package/dist/render/SceneRenderer.d.ts +0 -137
- package/dist/render/SourceManager.d.ts +0 -82
- package/dist/render/TextRenderer.d.ts +0 -120
- package/dist/render/arcText.d.ts +0 -28
- package/dist/render/bakeGate.d.ts +0 -35
- package/dist/render/batchOrder.d.ts +0 -60
- package/dist/render/blendMode.d.ts +0 -27
- package/dist/render/clipMaskPainter.d.ts +0 -42
- package/dist/render/fontInvalidation.d.ts +0 -18
- package/dist/render/fontInvalidationController.d.ts +0 -52
- package/dist/render/frameOverlay.d.ts +0 -32
- package/dist/render/framePipeline.d.ts +0 -27
- package/dist/render/gpuFilterPasses.d.ts +0 -15
- package/dist/render/gpuFx.d.ts +0 -82
- package/dist/render/gpuImageFilters.d.ts +0 -41
- package/dist/render/gpuShadow.d.ts +0 -38
- package/dist/render/gradientRamp.d.ts +0 -14
- package/dist/render/imageEffects.d.ts +0 -99
- package/dist/render/lineDecorationSdf.d.ts +0 -32
- package/dist/render/maskRender.d.ts +0 -60
- package/dist/render/multiPage.d.ts +0 -91
- package/dist/render/progressiveLoad.d.ts +0 -27
- package/dist/render/psdEffectPainter.d.ts +0 -25
- package/dist/render/psdWarpText.d.ts +0 -19
- package/dist/render/puzzleClamp.d.ts +0 -15
- package/dist/render/renderEpoch.d.ts +0 -21
- package/dist/render/retainedFrame.d.ts +0 -36
- package/dist/render/ruler.d.ts +0 -36
- package/dist/render/screenClip.d.ts +0 -31
- package/dist/render/scrollText.d.ts +0 -46
- package/dist/render/segmentTable.d.ts +0 -30
- package/dist/render/selectionOverlay.d.ts +0 -203
- package/dist/render/settleScheduler.d.ts +0 -24
- package/dist/render/shaders.d.ts +4 -24
- package/dist/render/shadowBake.d.ts +0 -28
- package/dist/render/shadowPainter.d.ts +0 -8
- package/dist/render/sharedGpuPainters.d.ts +0 -13
- package/dist/render/sourceHydration.d.ts +0 -8
- package/dist/render/strokeBake.d.ts +0 -59
- package/dist/render/strokeMiterOutline.d.ts +0 -29
- package/dist/render/strokePainter.d.ts +0 -31
- package/dist/render/strokeSdf.d.ts +0 -52
- package/dist/render/svgRaster.d.ts +0 -34
- package/dist/render/tableOverlay.d.ts +0 -35
- package/dist/render/textHighlight.d.ts +0 -67
- package/dist/render/textureUpload.d.ts +0 -13
- package/dist/render/verticalText.d.ts +0 -21
- package/dist/render/warpText.d.ts +0 -48
- package/dist/render/workspaceBackdrop.d.ts +0 -22
- package/dist/render/workspaceChecker.d.ts +0 -34
- package/dist/render/workspaceGlow.d.ts +0 -38
- package/package.json +4 -3
- package/dist/EngineCanvas.js +0 -1202
- package/dist/core/canvasPerf.js +0 -170
- package/dist/core/color.js +0 -107
- package/dist/core/distanceField.js +0 -92
- package/dist/core/events.js +0 -80
- package/dist/core/gradient.js +0 -175
- package/dist/core/homography.js +0 -123
- package/dist/core/imageFilters.js +0 -330
- package/dist/core/mat2d.js +0 -241
- package/dist/core/pathData.js +0 -926
- package/dist/core/pattern.js +0 -40
- package/dist/core/point.js +0 -119
- package/dist/core/psdEffects.js +0 -158
- package/dist/core/roundedRect.js +0 -164
- package/dist/core/shadow.js +0 -47
- package/dist/core/snap.js +0 -793
- package/dist/core/stroke.js +0 -45
- package/dist/core/triangulate.js +0 -194
- package/dist/core/warpMesh.js +0 -469
- package/dist/debug/canvasInspection.js +0 -113
- package/dist/decoders/gif2sprite.js +0 -84
- package/dist/decoders/webp2sprite.js +0 -133
- package/dist/engineFlag.js +0 -104
- package/dist/export/SceneExporter.js +0 -286
- package/dist/export/glExport.js +0 -79
- package/dist/export/svgExport.js +0 -1803
- package/dist/interact/animationPlayback.js +0 -358
- package/dist/interact/canvasInteractions.js +0 -174
- package/dist/interact/cropSession.js +0 -527
- package/dist/interact/dblClick.js +0 -120
- package/dist/interact/expandSession.js +0 -282
- package/dist/interact/hotkeyActions.js +0 -42
- package/dist/interact/pageTransfer.js +0 -56
- package/dist/interact/pathSession.js +0 -480
- package/dist/interact/pointer.js +0 -1692
- package/dist/interact/pointerTablePuzzle.js +0 -358
- package/dist/interact/pointerTransform.js +0 -441
- package/dist/interact/pointerTypes.js +0 -96
- package/dist/interact/snapGuide.js +0 -377
- package/dist/interact/tableCellEditing.js +0 -207
- package/dist/interact/tableInteraction.js +0 -219
- package/dist/interact/textEditing.js +0 -423
- package/dist/interact/warpFacade.js +0 -51
- package/dist/interact/warpSession.js +0 -583
- package/dist/interact/wheelScroll.js +0 -100
- package/dist/model/alphaHit.js +0 -267
- package/dist/model/animation.js +0 -510
- package/dist/model/arcLayout.js +0 -308
- package/dist/model/arcTextTransform.js +0 -87
- package/dist/model/compatEvents.js +0 -96
- package/dist/model/compatObject.js +0 -1583
- package/dist/model/cropEdit.js +0 -497
- package/dist/model/document.js +0 -590
- package/dist/model/elementTypes.js +0 -119
- package/dist/model/expandEdit.js +0 -161
- package/dist/model/fabricPrimitives.js +0 -9
- package/dist/model/filler.js +0 -1
- package/dist/model/groupAssemble.js +0 -98
- package/dist/model/groupChildMove.js +0 -145
- package/dist/model/groupResize.js +0 -109
- package/dist/model/handles.js +0 -29
- package/dist/model/imageMaskBake.js +0 -136
- package/dist/model/lineConstruct.js +0 -79
- package/dist/model/maskCropEdit.js +0 -90
- package/dist/model/pathBackground.js +0 -196
- package/dist/model/pathConstruct.js +0 -55
- package/dist/model/pathEdit.js +0 -378
- package/dist/model/puzzleEdit.js +0 -742
- package/dist/model/puzzleLayout.js +0 -143
- package/dist/model/scene.js +0 -2930
- package/dist/model/schema.js +0 -13
- package/dist/model/shapePath.js +0 -137
- package/dist/model/smartObjectBake.js +0 -295
- package/dist/model/tableEdit.js +0 -751
- package/dist/model/tableFacade.js +0 -808
- package/dist/model/tableLayout.js +0 -194
- package/dist/model/textAlign.js +0 -36
- package/dist/model/textLayout.js +0 -842
- package/dist/render/GLBlend.js +0 -270
- package/dist/render/GLContext.js +0 -48
- package/dist/render/GLIsolate.js +0 -188
- package/dist/render/GLTextureCache.js +0 -224
- package/dist/render/GlyphAtlas.js +0 -412
- package/dist/render/MeshBatch.js +0 -416
- package/dist/render/QuadBatch.js +0 -561
- package/dist/render/SceneRenderer.js +0 -753
- package/dist/render/SourceManager.js +0 -523
- package/dist/render/TextRenderer.js +0 -854
- package/dist/render/arcText.js +0 -187
- package/dist/render/bakeGate.js +0 -32
- package/dist/render/batchOrder.js +0 -168
- package/dist/render/blendMode.js +0 -142
- package/dist/render/clipMaskPainter.js +0 -244
- package/dist/render/fontInvalidation.js +0 -77
- package/dist/render/fontInvalidationController.js +0 -119
- package/dist/render/frameOverlay.js +0 -124
- package/dist/render/framePipeline.js +0 -96
- package/dist/render/gpuFilterPasses.js +0 -883
- package/dist/render/gpuFx.js +0 -673
- package/dist/render/gpuImageFilters.js +0 -295
- package/dist/render/gpuShadow.js +0 -327
- package/dist/render/gradientRamp.js +0 -74
- package/dist/render/imageEffects.js +0 -415
- package/dist/render/lineDecorationSdf.js +0 -189
- package/dist/render/maskRender.js +0 -217
- package/dist/render/multiPage.js +0 -420
- package/dist/render/progressiveLoad.js +0 -86
- package/dist/render/psdEffectPainter.js +0 -333
- package/dist/render/psdWarpText.js +0 -212
- package/dist/render/puzzleClamp.js +0 -30
- package/dist/render/renderEpoch.js +0 -35
- package/dist/render/renderViewport.js +0 -18
- package/dist/render/retainedFrame.js +0 -192
- package/dist/render/ruler.js +0 -287
- package/dist/render/screenClip.js +0 -67
- package/dist/render/scrollText.js +0 -266
- package/dist/render/segmentTable.js +0 -117
- package/dist/render/selectionOverlay.js +0 -1008
- package/dist/render/settleScheduler.js +0 -51
- package/dist/render/shaders.js +0 -450
- package/dist/render/shadowBake.js +0 -203
- package/dist/render/shadowPainter.js +0 -93
- package/dist/render/sharedGpuPainters.js +0 -42
- package/dist/render/sourceHydration.js +0 -48
- package/dist/render/strokeBake.js +0 -516
- package/dist/render/strokeMiterOutline.js +0 -224
- package/dist/render/strokePainter.js +0 -207
- package/dist/render/strokeSdf.js +0 -262
- package/dist/render/svgRaster.js +0 -71
- package/dist/render/tableOverlay.js +0 -233
- package/dist/render/textHighlight.js +0 -380
- package/dist/render/textureUpload.js +0 -26
- package/dist/render/verticalText.js +0 -63
- package/dist/render/warpText.js +0 -384
- package/dist/render/workspaceBackdrop.js +0 -60
- package/dist/render/workspaceChecker.js +0 -170
- package/dist/render/workspaceGlow.js +0 -198
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 渲染产物统一失效纪元(方向一第一刀,
|
|
3
|
-
* docs/2026-10-13_webgl2-render-jank-causes-and-watchlist.md §6.2)。
|
|
4
|
-
*
|
|
5
|
-
* 批次 223/225 的教训:纹理级失效(GlyphAtlas.reset 删全部页纹理、
|
|
6
|
-
* GLTextureCache 淘汰删句柄)不产生任何节点染脏——保留式快照持有死引用
|
|
7
|
-
* 重放即整层消失,自愈链对这类失效天然失明,只能靠失效源各自把计数
|
|
8
|
-
* 「接进门链」。此前是两个独立信号各自为政(atlas generation /
|
|
9
|
-
* evictionCount),批次 374 起收敛为单一单调纪元:
|
|
10
|
-
* - 失效源(reset/淘汰/未来的烘焙删除口)统一 `bump(reason)`;
|
|
11
|
-
* - 保留式帧门链快照只记一个 `artifactEpoch`,不等即回退全量帧——
|
|
12
|
-
* 新增失效源接一个 bump 就自动入门链,不可能再静默绕过(结构性收口);
|
|
13
|
-
* - `lastReason` 仅诊断(门链回退打点/快照收录日志)。
|
|
14
|
-
*
|
|
15
|
-
* 纪元只承载「产物级销毁」信号;节点级内容失效仍走 renderDirty 染脏
|
|
16
|
-
* (脏集重推语义不变)。EngineCanvas 持唯一实例注入 GlyphAtlas/
|
|
17
|
-
* GLTextureCache(缺省自建=独立纪元,直构单测等价旧口径)。
|
|
18
|
-
*/
|
|
19
|
-
export class RenderEpoch {
|
|
20
|
-
_value = 0;
|
|
21
|
-
_lastReason = '';
|
|
22
|
-
/** 单调纪元值(快照收录时记录比对) */
|
|
23
|
-
get value() {
|
|
24
|
-
return this._value;
|
|
25
|
-
}
|
|
26
|
-
/** 最近一次失效原因(仅诊断打点) */
|
|
27
|
-
get lastReason() {
|
|
28
|
-
return this._lastReason;
|
|
29
|
-
}
|
|
30
|
-
/** 失效通知:任何「删了已被快照命令表引用的产物」的路径必须调用 */
|
|
31
|
-
bump(reason) {
|
|
32
|
-
this._value++;
|
|
33
|
-
this._lastReason = reason;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** Drawing a visible page must not change the editor's active-page coordinate system. */
|
|
2
|
-
const renderingViewports = new WeakMap();
|
|
3
|
-
export function renderViewportOf(host) {
|
|
4
|
-
return renderingViewports.get(host) ?? host.viewportTransform;
|
|
5
|
-
}
|
|
6
|
-
export function withRenderViewport(host, viewport, render) {
|
|
7
|
-
const previous = renderingViewports.get(host);
|
|
8
|
-
renderingViewports.set(host, viewport);
|
|
9
|
-
try {
|
|
10
|
-
render();
|
|
11
|
-
}
|
|
12
|
-
finally {
|
|
13
|
-
if (previous)
|
|
14
|
-
renderingViewports.set(host, previous);
|
|
15
|
-
else
|
|
16
|
-
renderingViewports.delete(host);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 保留式场景帧控制器(批次 223 重落)。
|
|
3
|
-
*
|
|
4
|
-
* 全量扁平帧后把「命令表 + 两批槽位表/总量」快照留驻;后续帧门链全过时只对
|
|
5
|
-
* 脏集节点做槽位原位重推(rewind → 重推 → 计数契约校验),然后重放缓照命令
|
|
6
|
-
* 表——万级场景节点相位从每帧 O(n) 收敛为 O(dirty),干净节点的 GPU 内容跨帧
|
|
7
|
-
* 留驻。门链宁可慢不可错:结构版本/vpt/dpr/画布尺寸/纹理逐出/图集世代/
|
|
8
|
-
* 会话态/渐进装载/编辑态/动画/烘焙续帧任一在即全量帧。
|
|
9
|
-
*
|
|
10
|
-
* 图集世代门是重落的核心修复:GlyphAtlas.reset()(页上限触顶/字体迟到)删除
|
|
11
|
-
* 全部页纹理但不染脏任何节点——快照命令表持有页纹理活引用,重放死句柄 = 文本
|
|
12
|
-
* 整层不绘制(模板 273 文本消失回归的根因,理论自愈链「脏文本节点无槽位→回退
|
|
13
|
-
* 全量」对纹理级失效天然失明)。纹理级失效天然是全量帧信号,经世代/逐出计数
|
|
14
|
-
* 入门链而非逐节点染脏。
|
|
15
|
-
*
|
|
16
|
-
* 逃逸门:?retained=0 / localStorage('engine.retained'='0')(engineFlag)。
|
|
17
|
-
* 诊断日志:?retainedDebug=1——快照收录/门链回退理由/图集 reset 调用栈。
|
|
18
|
-
*/
|
|
19
|
-
import { isRetainedDebugEnabled, isRetainedFrameEnabled } from '../engineFlag';
|
|
20
|
-
export class RetainedFrameController {
|
|
21
|
-
host;
|
|
22
|
-
retained = null;
|
|
23
|
-
/** 上帧动画活动/烘焙续帧(门):动画节点逐帧自变(tick 在覆写层有脏标记,
|
|
24
|
-
* 但 mask 动态 clip 在渲染期 tick——干净节点被跳过即冻结);烘焙续帧完成
|
|
25
|
-
* 前推入的是暂态内容——两者在即全量帧 */
|
|
26
|
-
lastFrameAnimated = false;
|
|
27
|
-
lastFrameBakeMore = false;
|
|
28
|
-
/** 诊断:门链回退理由只在状态翻转时打点(防 rAF 级刷屏) */
|
|
29
|
-
lastGateReason = null;
|
|
30
|
-
constructor(host) {
|
|
31
|
-
this.host = host;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 保留式帧尝试(render 节点相位入口):门链全过时按脏集原位重推 + 重放
|
|
35
|
-
* 快照命令表。返回 false = 任一门失败或重推异常(调用方回退全量遍历,
|
|
36
|
-
* 本帧缓冲被全量重写覆盖,无残留语义)。flatFrame 每相位复位(重落修正:
|
|
37
|
-
* 223 原版只在保留路径复位,隔离帧后快照会被永久禁用——保守方向的性能缺陷)。
|
|
38
|
-
*/
|
|
39
|
-
tryRetainedFrame() {
|
|
40
|
-
const { host } = this;
|
|
41
|
-
host.renderer.flatFrame = true;
|
|
42
|
-
if (!isRetainedFrameEnabled())
|
|
43
|
-
return this.gateFail('flag-off');
|
|
44
|
-
const rf = this.retained;
|
|
45
|
-
if (!rf)
|
|
46
|
-
return this.gateFail('no-snapshot');
|
|
47
|
-
if (this.lastFrameAnimated)
|
|
48
|
-
return this.gateFail('animating');
|
|
49
|
-
if (this.lastFrameBakeMore)
|
|
50
|
-
return this.gateFail('bake-continue');
|
|
51
|
-
if (host.cropSessionController.active || host.expandSessionController.active || host.pathSessionController.active || host.warpSessionController.active)
|
|
52
|
-
return this.gateFail('session');
|
|
53
|
-
if (host.progressiveLoad.limit >= 0 && host.progressiveLoad.limit < host.doc.nodes.length)
|
|
54
|
-
return this.gateFail('progressive');
|
|
55
|
-
if (host.doc.editingNode)
|
|
56
|
-
return this.gateFail('editing');
|
|
57
|
-
if (rf.structureVersion !== host.doc.structureVersion)
|
|
58
|
-
return this.gateFail('structure');
|
|
59
|
-
if (rf.vptKey !== host.vpt.join(','))
|
|
60
|
-
return this.gateFail('vpt');
|
|
61
|
-
if (rf.dpr !== host.dpr || rf.sizeKey !== `${host.canvasEl.width}x${host.canvasEl.height}`)
|
|
62
|
-
return this.gateFail('surface');
|
|
63
|
-
// 产物失效纪元门(批次 374 折叠图集世代+纹理淘汰两信号):纹理级失效
|
|
64
|
-
// (reset 删页纹理/淘汰删句柄)零节点染脏,快照命令表持有活引用——重放
|
|
65
|
-
// 死句柄 = 文本整层消失(模板 273 回归根因)。新增失效源经 renderEpoch
|
|
66
|
-
// .bump 汇入即自动入门链(方向一:结构性收口,不可能静默绕过)
|
|
67
|
-
if (rf.artifactEpoch !== host.renderEpoch.value)
|
|
68
|
-
return this.gateFail(`artifact-epoch(${host.renderEpoch.lastReason})`);
|
|
69
|
-
const snap = rf.snap;
|
|
70
|
-
const dirty = host.doc.renderDirty;
|
|
71
|
-
for (const node of dirty) {
|
|
72
|
-
// 参考线无场景槽位(frameOverlay 通道)——纯跳过
|
|
73
|
-
if (node.isReferenceLine)
|
|
74
|
-
continue;
|
|
75
|
-
const qs = snap.quadSlots.get(node);
|
|
76
|
-
const ms = snap.meshSlots.get(node);
|
|
77
|
-
// 无槽位:新可见/上帧隐藏/TextRenderer 等无 owner 推送——结构序变化,
|
|
78
|
-
// 回退全量(理论自愈链的入口:脏而无槽位必全量)
|
|
79
|
-
if (!qs && !ms)
|
|
80
|
-
return this.gateFail('no-slot');
|
|
81
|
-
const qBefore = host.batch.instanceTotal;
|
|
82
|
-
const mBefore = host.meshBatch.vertexTotal;
|
|
83
|
-
if (qs)
|
|
84
|
-
host.batch.rewindToSlot(qs.start);
|
|
85
|
-
if (ms)
|
|
86
|
-
host.meshBatch.rewindToSlot(ms.start);
|
|
87
|
-
host.renderer.renderSceneNode(node);
|
|
88
|
-
// 计数契约:有槽位 → 恰好落在槽位区间;无槽位 → 该批不前进(防止新增
|
|
89
|
-
// 网格/quad 内容静默从 0 位覆写他人区域)
|
|
90
|
-
if (host.batch.instanceTotal !== (qs ? qs.start + qs.count : qBefore))
|
|
91
|
-
return this.gateFail('contract-quad');
|
|
92
|
-
if (host.meshBatch.vertexTotal !== (ms ? ms.start + ms.count : mBefore))
|
|
93
|
-
return this.gateFail('contract-mesh');
|
|
94
|
-
// 重推命中隔离/混合路径 → 全量
|
|
95
|
-
if (!host.renderer.flatFrame)
|
|
96
|
-
return this.gateFail('isolated');
|
|
97
|
-
// 批次 300 守卫(批次 301 收窄口径):重推期命令出现快照没有的纹理/
|
|
98
|
-
// 渐变引用 = 换纹理类新写入(滤镜换 GPU 链输出纹理等),「脏帧重写不
|
|
99
|
-
// 产生新绘制」前提被破坏——继续走 discardRecorded + replaySnapshot 会把
|
|
100
|
-
// 画面钉在上一个观感(用户报障「点滤镜先停在之前状态之后才生效」根因)。
|
|
101
|
-
// 懒出清的等价命令(纹理/渐变同快照,带描边形状重推的常态)不触发——
|
|
102
|
-
// 批次 300 原口径 hasRecordedCommands 连等价命令也打成 gateFail,拖拽
|
|
103
|
-
// 热路径整族退化全量帧。宁可慢不可错:新颖引用立即回退全量帧
|
|
104
|
-
if (host.batchOrder.hasNovelPaintReferences(snap))
|
|
105
|
-
return this.gateFail('repush-commands');
|
|
106
|
-
}
|
|
107
|
-
// 批次 321 复检(批次 374 纪元化):重推期(renderSceneNode)新纹理插入
|
|
108
|
-
// 可触发预算淘汰(get miss → evictIfNeeded),被逐句柄若在快照命令表里
|
|
109
|
-
// (干净节点的纹理),重放即整帧消失。入口门读数在重推前——纪元已变即
|
|
110
|
-
// 整体回退全量帧(调用方全量重写覆盖本帧缓冲,无残留语义)
|
|
111
|
-
if (rf.artifactEpoch !== host.renderEpoch.value)
|
|
112
|
-
return this.gateFail(`artifact-epoch-late(${host.renderEpoch.lastReason})`);
|
|
113
|
-
host.batch.restoreTotals(snap.quadTotal);
|
|
114
|
-
host.meshBatch.restoreTotals(snap.meshTotal);
|
|
115
|
-
host.batchOrder.discardRecorded();
|
|
116
|
-
host.batchOrder.replaySnapshot(snap);
|
|
117
|
-
this.gateOk();
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
/** 全量扁平帧的快照收录(render 节点相位 flushAll 后调用) */
|
|
121
|
-
captureSnapshot() {
|
|
122
|
-
const { host } = this;
|
|
123
|
-
if (!isRetainedFrameEnabled()) {
|
|
124
|
-
this.retained = null;
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const flat = host.renderer.flatFrame;
|
|
128
|
-
const sessions = host.cropSessionController.active || host.expandSessionController.active || host.pathSessionController.active || host.warpSessionController.active;
|
|
129
|
-
const progressive = host.progressiveLoad.limit >= 0 && host.progressiveLoad.limit < host.doc.nodes.length;
|
|
130
|
-
// 门校验(会话态/渐进中/编辑态/非扁平不建——隔离帧命令缺 FBO 边界语义)
|
|
131
|
-
if (!flat || sessions || progressive || host.doc.editingNode) {
|
|
132
|
-
this.retained = null;
|
|
133
|
-
this.logDebug(`snapshot 跳过(flat=${flat} sessions=${sessions} progressive=${progressive} editing=${host.doc.editingNode !== null})`);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const snap = host.batchOrder.retained;
|
|
137
|
-
this.retained = snap
|
|
138
|
-
? {
|
|
139
|
-
snap,
|
|
140
|
-
structureVersion: host.doc.structureVersion,
|
|
141
|
-
vptKey: host.vpt.join(','),
|
|
142
|
-
dpr: host.dpr,
|
|
143
|
-
sizeKey: `${host.canvasEl.width}x${host.canvasEl.height}`,
|
|
144
|
-
artifactEpoch: host.renderEpoch.value
|
|
145
|
-
}
|
|
146
|
-
: null;
|
|
147
|
-
if (snap && isRetainedDebugEnabled()) {
|
|
148
|
-
const atlas = host.glyphAtlas.stats();
|
|
149
|
-
console.info('[retained] 快照收录', {
|
|
150
|
-
commands: snap.commands.length,
|
|
151
|
-
quadSlots: snap.quadSlots.size,
|
|
152
|
-
meshSlots: snap.meshSlots.size,
|
|
153
|
-
structureVersion: host.doc.structureVersion,
|
|
154
|
-
atlasPages: atlas.pages,
|
|
155
|
-
artifactEpoch: host.renderEpoch.value,
|
|
156
|
-
epochLastReason: host.renderEpoch.lastReason
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/** 帧尾记录(render 尾部调用):上帧动画/烘焙续帧态供下一帧门链 */
|
|
161
|
-
noteFrameRendered() {
|
|
162
|
-
this.lastFrameAnimated = this.host.renderer.frame.animationActive;
|
|
163
|
-
this.lastFrameBakeMore = this.host.renderer.frame.bakeMore;
|
|
164
|
-
}
|
|
165
|
-
/** 快照作废(越界使用):FBO 导出(SceneExporter 复用 host 主批缓冲覆写内容)
|
|
166
|
-
* 与 context 恢复(rebuild 后纹理句柄全死)前置调用 */
|
|
167
|
-
invalidate() {
|
|
168
|
-
this.retained = null;
|
|
169
|
-
}
|
|
170
|
-
dispose() {
|
|
171
|
-
this.retained = null;
|
|
172
|
-
}
|
|
173
|
-
gateFail(reason) {
|
|
174
|
-
if (this.lastGateReason !== reason) {
|
|
175
|
-
this.lastGateReason = reason;
|
|
176
|
-
if (isRetainedDebugEnabled())
|
|
177
|
-
console.info('[retained] 门链回退:', reason);
|
|
178
|
-
}
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
gateOk() {
|
|
182
|
-
if (this.lastGateReason !== null) {
|
|
183
|
-
this.lastGateReason = null;
|
|
184
|
-
if (isRetainedDebugEnabled())
|
|
185
|
-
console.info('[retained] 保留式帧恢复生效');
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
logDebug(message) {
|
|
189
|
-
if (isRetainedDebugEnabled())
|
|
190
|
-
console.info('[retained]', message);
|
|
191
|
-
}
|
|
192
|
-
}
|
package/dist/render/ruler.js
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 画布标尺(P5-3 子片)——应用 FabricRuler(src/app/fabricRuler.ts)的引擎侧复刻。
|
|
3
|
-
*
|
|
4
|
-
* 视觉口径逐项同源:20px 边带(上=水平/左=垂直)、zoom→gap 分档表、主刻度带数值
|
|
5
|
-
* /副刻度 gap/10、工作区场景矩形裁剪(只画画板区段)、选区包围盒投影到边带的
|
|
6
|
-
* 蓝色高亮(同轴合并)、左上角单位方块('px')、垂直标尺数字 -90° 旋转。
|
|
7
|
-
* 线条浓度口径(批次 90 像素对拍勘正):fabric 刻度=darwLine 0.6px canvas2d AA
|
|
8
|
-
* 淡线、边带无外框线/角块描边 0.05px 不可见——引擎以 1px quad×alpha0.6 等价
|
|
9
|
-
* 刻度墨量、不画任何边框线(GL 亚像素 quad 有整条丢弃风险,宽度不缩、降浓度)。
|
|
10
|
-
*
|
|
11
|
-
* 渲染形态:OverlayQuad(场景空间矩阵 + px/zoom 恒定屏幕尺寸——selectionOverlay
|
|
12
|
-
* 同约定),由 EngineCanvas.render 覆盖层段消费。**数字不走逐帧 fillText**:
|
|
13
|
-
* 每个数值用 2D canvas 栅格化一次进模块级位图缓存(3× 超采样),quad 以缓存
|
|
14
|
-
* 画布为贴图经 GLTextureCache 上传(纹理可被 LRU 逐出,源画布常驻重传即回)。
|
|
15
|
-
*
|
|
16
|
-
* 刻度规划(rulerGap/planRulerTicks)为纯函数——jsdom 单测锁死分档/范围/裁剪。
|
|
17
|
-
*/
|
|
18
|
-
import { parseColor } from '../core/color';
|
|
19
|
-
/** 标尺带宽(CSS px)——渲染与 pointer 带命中/参考线拖出的单一来源 */
|
|
20
|
-
export const RULER_SIZE = 20;
|
|
21
|
-
const DEFAULT_STYLE = {
|
|
22
|
-
ruleSize: RULER_SIZE,
|
|
23
|
-
backgroundColor: parseColor('#ffffff'),
|
|
24
|
-
tickColor: parseColor('#A1A7AF'),
|
|
25
|
-
textColor: '#444444',
|
|
26
|
-
highlightColor: parseColor('#165dff3b'),
|
|
27
|
-
fontSize: 8,
|
|
28
|
-
unitName: 'px'
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* 刻度线浓度(批次 90):fabric darwLine 硬编码 lineWidth=0.6 CSS px,canvas2d AA
|
|
32
|
-
* 下单行有效墨量 ≈0.6 列;GL 1px quad 不能靠缩宽度还原(亚像素 quad 盖不到像素
|
|
33
|
-
* 中心整条被丢弃——参考线批次 72 教训),以 alpha 0.6 等价(1px×0.6 ≈ 0.6px AA
|
|
34
|
-
* 线墨量;像素对拍 fabric 实测 ~0.62 列 vs 修复前引擎 ~1.15 列)。
|
|
35
|
-
*/
|
|
36
|
-
const TICK_ALPHA = 0.6;
|
|
37
|
-
/** 数字位图超采样倍数(8px 字号按 24px 栅格化,quad 缩回——低分屏仍锐利) */
|
|
38
|
-
const DIGIT_SUPERSAMPLE = 3;
|
|
39
|
-
const DIGIT_FONT = `'Arial Narrow', 'Segoe UI', sans-serif`;
|
|
40
|
-
/** zoom→主刻度间距分档(应用 FabricRuler.getGap 同表) */
|
|
41
|
-
const GAP_ZOOMS = [0.02, 0.03, 0.05, 0.1, 0.2, 0.5, 1, 2, 5];
|
|
42
|
-
const GAP_STEPS = [5000, 2500, 1000, 500, 200, 100, 50, 20, 10];
|
|
43
|
-
export const rulerGap = (zoom) => {
|
|
44
|
-
let i = 0;
|
|
45
|
-
while (i < GAP_ZOOMS.length && GAP_ZOOMS[i] < zoom)
|
|
46
|
-
i++;
|
|
47
|
-
return GAP_STEPS[i - 1] ?? 10000;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* 刻度规划:startScene = 视口 0 位对应的场景坐标,visibleScene = 视口全长(场景单位),
|
|
51
|
-
* clip = 工作区场景区间(null = 全幅)。主刻度从 ≤startScene 的第一个 gap 整数倍起。
|
|
52
|
-
*/
|
|
53
|
-
export const planRulerTicks = (startScene, visibleScene, clip, zoom) => {
|
|
54
|
-
const gap = rulerGap(zoom);
|
|
55
|
-
const first = Math.floor(startScene / gap) * gap;
|
|
56
|
-
const last = startScene + visibleScene;
|
|
57
|
-
const majors = [];
|
|
58
|
-
const minors = [];
|
|
59
|
-
const inRange = (v) => v >= startScene - 1e-6 && v <= last + 1e-6 && (!clip || (v >= clip[0] - 1e-6 && v <= clip[1] + 1e-6));
|
|
60
|
-
for (let v = first; v <= last + gap; v += gap) {
|
|
61
|
-
if (inRange(v))
|
|
62
|
-
majors.push(v);
|
|
63
|
-
for (let i = 1; i < 10; i++) {
|
|
64
|
-
const m = v + (gap * i) / 10;
|
|
65
|
-
if (m > last + gap)
|
|
66
|
-
break;
|
|
67
|
-
if (inRange(m))
|
|
68
|
-
minors.push(m);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return { majors, minors };
|
|
72
|
-
};
|
|
73
|
-
/** 同轴合并(应用 mergeLines 同算法):把选区包围盒按带宽轴合并成不连续段 */
|
|
74
|
-
export const mergeHighlightSpans = (rects, horizontal) => {
|
|
75
|
-
if (!rects.length)
|
|
76
|
-
return [];
|
|
77
|
-
const axis = horizontal ? 'left' : 'top';
|
|
78
|
-
const len = horizontal ? 'width' : 'height';
|
|
79
|
-
const sorted = [...rects].sort((a, b) => a[axis] - b[axis]);
|
|
80
|
-
const spans = [];
|
|
81
|
-
let cur = { start: sorted[0][axis], length: sorted[0][len] };
|
|
82
|
-
for (let i = 1; i < sorted.length; i++) {
|
|
83
|
-
const r = sorted[i];
|
|
84
|
-
if (cur.start + cur.length >= r[axis]) {
|
|
85
|
-
cur.length = Math.max(cur.start + cur.length, r[axis] + r[len]) - cur.start;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
spans.push(cur);
|
|
89
|
-
cur = { start: r[axis], length: r[len] };
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
spans.push(cur);
|
|
93
|
-
return spans;
|
|
94
|
-
};
|
|
95
|
-
/** 数字位图缓存:每文本栅格化一次(模块级——标尺数值集合有限,长会话有界) */
|
|
96
|
-
const digitBitmapCache = new Map();
|
|
97
|
-
export const rulerDigitCanvas = (text, style = DEFAULT_STYLE) => {
|
|
98
|
-
const cached = digitBitmapCache.get(text);
|
|
99
|
-
if (cached)
|
|
100
|
-
return cached;
|
|
101
|
-
const canvas = document.createElement('canvas');
|
|
102
|
-
const ctx = canvas.getContext('2d');
|
|
103
|
-
if (!ctx) {
|
|
104
|
-
// jsdom 等无 2d 环境:占位画布(尺寸按字符宽估算,消费方仅取 width/height)
|
|
105
|
-
canvas.width = Math.max(1, Math.round(text.length * style.fontSize * 0.6 * DIGIT_SUPERSAMPLE));
|
|
106
|
-
canvas.height = Math.max(1, Math.round(style.fontSize * 1.4 * DIGIT_SUPERSAMPLE));
|
|
107
|
-
digitBitmapCache.set(text, canvas);
|
|
108
|
-
return canvas;
|
|
109
|
-
}
|
|
110
|
-
const font = `${style.fontSize * DIGIT_SUPERSAMPLE}px ${DIGIT_FONT}`;
|
|
111
|
-
ctx.font = font;
|
|
112
|
-
const metrics = ctx.measureText(text);
|
|
113
|
-
canvas.width = Math.max(1, Math.ceil(metrics.width) + 2);
|
|
114
|
-
canvas.height = Math.ceil(style.fontSize * DIGIT_SUPERSAMPLE * 1.25);
|
|
115
|
-
// 尺寸重置后 font 复位,重设再画
|
|
116
|
-
ctx.font = font;
|
|
117
|
-
ctx.textBaseline = 'top';
|
|
118
|
-
ctx.fillStyle = style.textColor;
|
|
119
|
-
ctx.fillText(text, 1, Math.round(style.fontSize * DIGIT_SUPERSAMPLE * 0.15));
|
|
120
|
-
digitBitmapCache.set(text, canvas);
|
|
121
|
-
return canvas;
|
|
122
|
-
};
|
|
123
|
-
/** 参考线数值气泡位图(批次 72;app FabricRuler.drawReferenceLineValue 同构):
|
|
124
|
-
* 蓝底圆角 + 白字 10px,pad 4、r 3,3× 超采样,按文本串缓存 */
|
|
125
|
-
const badgeCache = new Map();
|
|
126
|
-
const BADGE_FONT_SIZE = 10;
|
|
127
|
-
const BADGE_PADDING = 4;
|
|
128
|
-
export const referenceBadgeCanvas = (text) => {
|
|
129
|
-
const cached = badgeCache.get(text);
|
|
130
|
-
if (cached)
|
|
131
|
-
return cached;
|
|
132
|
-
const fontSize = BADGE_FONT_SIZE * DIGIT_SUPERSAMPLE;
|
|
133
|
-
const pad = BADGE_PADDING * DIGIT_SUPERSAMPLE;
|
|
134
|
-
const canvas = document.createElement('canvas');
|
|
135
|
-
const ctx = canvas.getContext('2d');
|
|
136
|
-
if (!ctx) {
|
|
137
|
-
// jsdom 无 2d:占位尺寸(消费方仅取 width/height)
|
|
138
|
-
canvas.width = Math.max(1, Math.round((text.length * BADGE_FONT_SIZE * 0.6 + BADGE_PADDING * 2) * DIGIT_SUPERSAMPLE));
|
|
139
|
-
canvas.height = Math.max(1, Math.round((BADGE_FONT_SIZE + BADGE_PADDING * 2) * DIGIT_SUPERSAMPLE));
|
|
140
|
-
badgeCache.set(text, canvas);
|
|
141
|
-
return canvas;
|
|
142
|
-
}
|
|
143
|
-
const font = `${fontSize}px ${DIGIT_FONT}`;
|
|
144
|
-
ctx.font = font;
|
|
145
|
-
const textW = ctx.measureText(text).width;
|
|
146
|
-
const radius = 3 * DIGIT_SUPERSAMPLE;
|
|
147
|
-
canvas.width = Math.max(1, Math.ceil(textW) + pad * 2);
|
|
148
|
-
canvas.height = Math.ceil((BADGE_FONT_SIZE + BADGE_PADDING * 2) * DIGIT_SUPERSAMPLE);
|
|
149
|
-
// 尺寸重置后 font 复位,重设再画
|
|
150
|
-
ctx.font = font;
|
|
151
|
-
// 圆角矩形(app 手绘 quad 曲线同形)
|
|
152
|
-
ctx.beginPath();
|
|
153
|
-
ctx.moveTo(radius, 0);
|
|
154
|
-
ctx.lineTo(canvas.width - radius, 0);
|
|
155
|
-
ctx.quadraticCurveTo(canvas.width, 0, canvas.width, radius);
|
|
156
|
-
ctx.lineTo(canvas.width, canvas.height - radius);
|
|
157
|
-
ctx.quadraticCurveTo(canvas.width, canvas.height, canvas.width - radius, canvas.height);
|
|
158
|
-
ctx.lineTo(radius, canvas.height);
|
|
159
|
-
ctx.quadraticCurveTo(0, canvas.height, 0, canvas.height - radius);
|
|
160
|
-
ctx.lineTo(0, radius);
|
|
161
|
-
ctx.quadraticCurveTo(0, 0, radius, 0);
|
|
162
|
-
ctx.closePath();
|
|
163
|
-
ctx.fillStyle = 'rgba(22, 93, 255, 0.9)';
|
|
164
|
-
ctx.fill();
|
|
165
|
-
ctx.strokeStyle = '#fff';
|
|
166
|
-
ctx.lineWidth = 0.5 * DIGIT_SUPERSAMPLE;
|
|
167
|
-
ctx.stroke();
|
|
168
|
-
ctx.fillStyle = '#fff';
|
|
169
|
-
ctx.textBaseline = 'top';
|
|
170
|
-
ctx.fillText(text, pad, pad);
|
|
171
|
-
badgeCache.set(text, canvas);
|
|
172
|
-
return canvas;
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* 标尺覆盖层:上边带(水平)+ 左边带(垂直)+ 角块。
|
|
176
|
-
* quads 为场景空间矩阵(batch 已带场景视图)——屏幕 px 位置经 vpt 逆变换落场景,
|
|
177
|
-
* 尺寸按 px/zoom 保持屏幕恒定(selectionOverlay 同约定)。
|
|
178
|
-
*/
|
|
179
|
-
export const buildRulerOverlay = (input) => {
|
|
180
|
-
const style = { ...DEFAULT_STYLE, ...input.style };
|
|
181
|
-
const { vpt, cssWidth, cssHeight } = input;
|
|
182
|
-
const zoom = vpt[0];
|
|
183
|
-
const digit = input.digitCanvas ?? ((text) => rulerDigitCanvas(text, style));
|
|
184
|
-
const quads = [];
|
|
185
|
-
// 屏幕 css px → 场景(vpt 逆)
|
|
186
|
-
const sx = (cssX) => (cssX - vpt[4]) / zoom;
|
|
187
|
-
const sy = (cssY) => (cssY - vpt[5]) / zoom;
|
|
188
|
-
const s = 1 / zoom;
|
|
189
|
-
// 批次 70:OverlayQuad 平移=quad 中心(selectionOverlay lineQuad/squareQuad 同约定,
|
|
190
|
-
// 着色器 (corner-0.5)*dim 中心系顶点)——rect 按「左上角+半宽高」落中心、digitQuad
|
|
191
|
-
// 按字形锚换算。修复前 rect 直把左上角塞进平移:顶带白底左移半幅(右半露出
|
|
192
|
-
// 工作区灰遮罩)、左带白底上移半幅(下半段灰底),低缩放下大面积暴露。
|
|
193
|
-
const rect = (left, top, w, h, color) => ({
|
|
194
|
-
matrix: [s, 0, 0, s, sx(left + w / 2), sy(top + h / 2)],
|
|
195
|
-
dims: { x: w, y: h },
|
|
196
|
-
color
|
|
197
|
-
});
|
|
198
|
-
const digitQuad = (text, anchorX, anchorY, rotate90 = false) => {
|
|
199
|
-
const canvas = digit(text);
|
|
200
|
-
const w = canvas.width / DIGIT_SUPERSAMPLE;
|
|
201
|
-
const h = canvas.height / DIGIT_SUPERSAMPLE;
|
|
202
|
-
// 锚=字形盒左上角(应用 darwText align left/baseline top 同位),两分支都换算到
|
|
203
|
-
// 盒中心(着色器中心系顶点)。水平带中心=锚+半宽高;垂直带 -90°:fabric rotate(-90)
|
|
204
|
-
// 的字形下行朝屏幕右、advance 朝上——盒占 x∈[anchorX, anchorX+h]、y∈[anchorY-w, anchorY],
|
|
205
|
-
// 中心=(anchorX+h/2, anchorY-w/2)。批次 91 勘正:旋转分支曾把锚直接当中心(漏换算),
|
|
206
|
-
// 盒左移 h/2≈5px 贴带左缘(用户报「垂直标尺的文本太靠近左边了」)
|
|
207
|
-
const matrix = rotate90 ? [0, s, -s, 0, sx(anchorX + h / 2), sy(anchorY - w / 2)] : [s, 0, 0, s, sx(anchorX + w / 2), sy(anchorY + h / 2)];
|
|
208
|
-
return { matrix, dims: { x: w, y: h }, color: [1, 1, 1, 1], texture: canvas };
|
|
209
|
-
};
|
|
210
|
-
const size = style.ruleSize;
|
|
211
|
-
const drawBand = (horizontal) => {
|
|
212
|
-
const rulerLength = horizontal ? cssWidth : cssHeight;
|
|
213
|
-
// 背景(不透明白:盖住边带下的画布内容,应用同语义)
|
|
214
|
-
quads.push(horizontal ? rect(0, 0, cssWidth, size, style.backgroundColor) : rect(0, 0, size, cssHeight, style.backgroundColor));
|
|
215
|
-
// 工作区裁剪区间
|
|
216
|
-
const ws = input.workspaceRect;
|
|
217
|
-
const clip = ws ? (horizontal ? [ws.left, ws.left + ws.width] : [ws.top, ws.top + ws.height]) : null;
|
|
218
|
-
const startScene = horizontal ? -vpt[4] / zoom : -vpt[5] / zoom;
|
|
219
|
-
const plan = planRulerTicks(startScene, rulerLength / zoom, clip, zoom);
|
|
220
|
-
// 刻度:主刻度从带外缘起全长,副刻度从内缘 8px;宽 1px、浓度 TICK_ALPHA
|
|
221
|
-
// (fabric darwLine 0.6px AA 视觉等价——宽度收窄有 GL 亚像素丢弃风险,见常量注)
|
|
222
|
-
const tickRGBA = [style.tickColor[0], style.tickColor[1], style.tickColor[2], style.tickColor[3] * TICK_ALPHA];
|
|
223
|
-
const toScreen = (sceneV) => (horizontal ? (sceneV - startScene) * zoom : (sceneV - startScene) * zoom);
|
|
224
|
-
for (const v of plan.majors) {
|
|
225
|
-
const p = Math.round(toScreen(v));
|
|
226
|
-
quads.push(horizontal ? rect(p, 0, 1, size, tickRGBA) : rect(0, p, size, 1, tickRGBA));
|
|
227
|
-
}
|
|
228
|
-
for (const v of plan.minors) {
|
|
229
|
-
const p = Math.round(toScreen(v));
|
|
230
|
-
quads.push(horizontal ? rect(p, size - 8, 1, 8, tickRGBA) : rect(size - 8, p, 8, 1, tickRGBA));
|
|
231
|
-
}
|
|
232
|
-
// 数值:主刻度处;水平带 (p+6, 2.5),垂直带旋转 -90° 锚 (2.5, p-6)(应用同位)
|
|
233
|
-
for (const v of plan.majors) {
|
|
234
|
-
const p = toScreen(v);
|
|
235
|
-
const text = String(Math.round(v));
|
|
236
|
-
if (horizontal)
|
|
237
|
-
quads.push(digitQuad(text, p + 6, 2.5));
|
|
238
|
-
else
|
|
239
|
-
quads.push(digitQuad(text, 2.5, p - 6, true));
|
|
240
|
-
}
|
|
241
|
-
// 高亮:同轴合并段 → 边带投影
|
|
242
|
-
for (const span of mergeHighlightSpans(input.selectionRects, horizontal)) {
|
|
243
|
-
const p = (span.start - startScene) * zoom;
|
|
244
|
-
const len = span.length * zoom;
|
|
245
|
-
quads.push(horizontal ? rect(p, 0, len, size, style.highlightColor) : rect(0, p, size, len, style.highlightColor));
|
|
246
|
-
}
|
|
247
|
-
// 无外缘描边线(批次 90 对拍勘正):fabric 边带背景 darwRect stroke:''——边带
|
|
248
|
-
// 边界=白底与工作区灰遮罩的自然对比;引擎 1px 实色 borderColor 线是复刻加笔,
|
|
249
|
-
// 实测比 fabric 多一条全长灰线(用户观感「标尺线太粗」来源之一)
|
|
250
|
-
};
|
|
251
|
-
drawBand(true);
|
|
252
|
-
drawBand(false);
|
|
253
|
-
// 角块(单位标签居中近似;无描边——fabric darwRect stroke lineWidth=0.05 视觉不可见)
|
|
254
|
-
quads.push(rect(0, 0, size, size, style.backgroundColor));
|
|
255
|
-
const unitCanvas = digit(style.unitName);
|
|
256
|
-
quads.push(digitQuad(style.unitName, size / 2 - unitCanvas.width / DIGIT_SUPERSAMPLE / 2, size / 2 - unitCanvas.height / DIGIT_SUPERSAMPLE / 2));
|
|
257
|
-
// 参考线拖拽数值气泡(批次 72;app FabricRuler.drawReferenceLineValue 同构):
|
|
258
|
-
// 横线 → 气泡贴左带外侧(x=ruleSize+5),竖线 → 贴上带外侧(y=ruleSize+5);
|
|
259
|
-
// 沿带向位置 = 线位×zoom+vpt 平移,出画布钳边(app 同钳位式)
|
|
260
|
-
if (input.referenceLine) {
|
|
261
|
-
const badge = referenceBadgeCanvas(String(Math.round(input.referenceLine.position)));
|
|
262
|
-
const w = badge.width / DIGIT_SUPERSAMPLE;
|
|
263
|
-
const h = badge.height / DIGIT_SUPERSAMPLE;
|
|
264
|
-
let left;
|
|
265
|
-
let top;
|
|
266
|
-
if (input.referenceLine.axis === 'horizontal') {
|
|
267
|
-
const viewportPosition = input.referenceLine.position * zoom + vpt[5];
|
|
268
|
-
left = size + 5;
|
|
269
|
-
top = viewportPosition + h / 2;
|
|
270
|
-
if (top < 0)
|
|
271
|
-
top = 2;
|
|
272
|
-
if (top + h > cssHeight)
|
|
273
|
-
top = cssHeight - h - 2;
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
const viewportPosition = input.referenceLine.position * zoom + vpt[4];
|
|
277
|
-
left = viewportPosition + w / 2;
|
|
278
|
-
top = size + 5;
|
|
279
|
-
if (left < 0)
|
|
280
|
-
left = 2;
|
|
281
|
-
if (left + w > cssWidth)
|
|
282
|
-
left = cssWidth - w - 2;
|
|
283
|
-
}
|
|
284
|
-
quads.push({ matrix: [s, 0, 0, s, sx(left + w / 2), sy(top + h / 2)], dims: { x: w, y: h }, color: [1, 1, 1, 1], texture: badge });
|
|
285
|
-
}
|
|
286
|
-
return quads;
|
|
287
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 屏幕域页剪裁(方案 D 多页「内容不出页」,批次 414)。
|
|
3
|
-
*
|
|
4
|
-
* 多页分段帧逐页换装视口但不裁几何——节点越出本页工作区矩形的部分会画进
|
|
5
|
-
* 页间 gap 与邻页矩形;gap 段随后被不透明多洞灰遮罩盖住(不可见),而邻页
|
|
6
|
-
* 矩形是遮罩的洞,越界内容就此漏显在他人画板里(「元素跨两页显示」病灶——
|
|
7
|
-
* 跨页拖入置顶已定归属语义,渲染面须执行同一语义:元素只在归属页可见)。
|
|
8
|
-
* 单页态既有语义本就是「工作区外内容被遮罩盖住、只留覆盖层选框」——本模块
|
|
9
|
-
* 把它推广到多页:页段渲染期开 GL scissor,把本页全部绘制(含越界几何与
|
|
10
|
-
* 隔离/混合全屏合成)钳在本页矩形的帧缓冲像素内;遮罩/覆盖层相位关回。
|
|
11
|
-
*
|
|
12
|
-
* 坐标口径:编辑器 vpt 无旋转,页矩形(绝对场景系)经 vpt 映射为轴对齐
|
|
13
|
-
* CSS 矩形,再 ×dpr、y 翻转(GL 原点左下)得帧缓冲 scissor 盒;外向取整
|
|
14
|
-
* (floor/ceil)保边沿内容像素,与视口求交,空交集 = 零尺寸盒(全弃置,
|
|
15
|
-
* 预筛 margin 余量下的视口外沿页)。
|
|
16
|
-
*
|
|
17
|
-
* 烘焙豁免(suspendScissor):scissor 是上下文级状态,作用于一切帧缓冲的
|
|
18
|
-
* draw/clear/blit/像素拷贝。GPU 烘焙族(GpuShadowBaker/GpuFxPainter 三入口/
|
|
19
|
-
* GpuImageFilterChain)在自身内容坐标系的内容尺寸 FBO 里跑 pass——页矩形投
|
|
20
|
-
* 到那边是随机区域,不豁免即剪坏烘焙纹理。屏幕尺寸 FBO(GLIsolate 组隔离/
|
|
21
|
-
* GLBlend 混合)与页同屏同系:不豁免恰是把组内容一并钳在页内(组越页同裁)
|
|
22
|
-
* ——故不在豁免之列。CPU 烘焙(2D canvas → texImage 上传)不受 scissor 影响
|
|
23
|
-
* 天然豁免(maskRender/strokePainter/shadowPainter CPU 支/psdEffectPainter/
|
|
24
|
-
* GlyphAtlas 全族)。
|
|
25
|
-
*/
|
|
26
|
-
import { transformPoint } from '../core/mat2d';
|
|
27
|
-
/** 场景矩形 → 帧缓冲 scissor 盒(vpt 无旋转假设下两角即轴对齐;空交集零尺寸) */
|
|
28
|
-
export function pageClipRect(sceneRect, vpt, cssWidth, cssHeight, dpr) {
|
|
29
|
-
const p1 = transformPoint(vpt, sceneRect.left, sceneRect.top);
|
|
30
|
-
const p2 = transformPoint(vpt, sceneRect.left + sceneRect.width, sceneRect.top + sceneRect.height);
|
|
31
|
-
const x0 = Math.floor(Math.min(p1.x, p2.x) * dpr);
|
|
32
|
-
const x1 = Math.ceil(Math.max(p1.x, p2.x) * dpr);
|
|
33
|
-
const yTop = Math.min(p1.y, p2.y);
|
|
34
|
-
const yBottom = Math.max(p1.y, p2.y);
|
|
35
|
-
// y 翻转:CSS 顶左原点 → GL 底左原点(帧缓冲底边 = cssHeight − 矩形下沿)
|
|
36
|
-
const y0 = Math.floor((cssHeight - yBottom) * dpr);
|
|
37
|
-
const y1 = Math.ceil((cssHeight - yTop) * dpr);
|
|
38
|
-
const cx0 = Math.max(0, x0);
|
|
39
|
-
const cy0 = Math.max(0, y0);
|
|
40
|
-
const cx1 = Math.min(Math.ceil(cssWidth * dpr), x1);
|
|
41
|
-
const cy1 = Math.min(Math.ceil(cssHeight * dpr), y1);
|
|
42
|
-
return { x: cx0, y: cy0, w: Math.max(0, cx1 - cx0), h: Math.max(0, cy1 - cy0) };
|
|
43
|
-
}
|
|
44
|
-
/** 开启并设置页剪裁(零尺寸盒合法——本页绘制全弃置) */
|
|
45
|
-
export function applyScissor(gl, rect) {
|
|
46
|
-
gl.enable(gl.SCISSOR_TEST);
|
|
47
|
-
gl.scissor(rect.x, rect.y, rect.w, rect.h);
|
|
48
|
-
}
|
|
49
|
-
/** 关闭页剪裁(帧尾 finally/遮罩与覆盖层相位前) */
|
|
50
|
-
export function clearScissor(gl) {
|
|
51
|
-
gl.disable(gl.SCISSOR_TEST);
|
|
52
|
-
}
|
|
53
|
-
/** 烘焙豁免:记录并关闭 scissor,返回恢复函数(幂等;出口/finally 调用)。
|
|
54
|
-
* 未开启时零成本直通(单页态/导出链恒不开启)。 */
|
|
55
|
-
export function suspendScissor(gl) {
|
|
56
|
-
const wasEnabled = gl.isEnabled(gl.SCISSOR_TEST);
|
|
57
|
-
if (wasEnabled)
|
|
58
|
-
gl.disable(gl.SCISSOR_TEST);
|
|
59
|
-
let resumed = false;
|
|
60
|
-
return () => {
|
|
61
|
-
if (resumed)
|
|
62
|
-
return;
|
|
63
|
-
resumed = true;
|
|
64
|
-
if (wasEnabled)
|
|
65
|
-
gl.enable(gl.SCISSOR_TEST);
|
|
66
|
-
};
|
|
67
|
-
}
|