@yft-design/engine 0.0.16 → 0.0.18
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 +0 -13
- 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 +12 -55
- package/dist/model/compatObject.d.ts +0 -360
- package/dist/model/cropEdit.d.ts +0 -60
- package/dist/model/document.d.ts +3 -158
- 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 +32 -4
- 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 +5 -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 -526
- package/dist/interact/dblClick.js +0 -120
- package/dist/interact/expandSession.js +0 -281
- package/dist/interact/hotkeyActions.js +0 -41
- package/dist/interact/pageTransfer.js +0 -56
- package/dist/interact/pathSession.js +0 -480
- package/dist/interact/pointer.js +0 -1691
- 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 -206
- 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 -582
- package/dist/interact/wheelScroll.js +0 -100
- package/dist/model/alphaHit.js +0 -263
- 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 -73
- package/dist/model/compatObject.js +0 -1580
- package/dist/model/cropEdit.js +0 -497
- package/dist/model/document.js +0 -572
- 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 -136
- 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 -123
- 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 -188
- package/dist/render/maskRender.js +0 -217
- package/dist/render/multiPage.js +0 -419
- 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 -515
- package/dist/render/strokeMiterOutline.js +0 -224
- package/dist/render/strokePainter.js +0 -207
- package/dist/render/strokeSdf.js +0 -261
- 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 -382
- package/dist/render/workspaceBackdrop.js +0 -60
- package/dist/render/workspaceChecker.js +0 -170
- package/dist/render/workspaceGlow.js +0 -198
package/dist/EngineCanvas.js
DELETED
|
@@ -1,1202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 引擎画布(main-webgl2 Phase 1)——装配层。
|
|
3
|
-
*
|
|
4
|
-
* 装配 GLContext + QuadBatch + MeshBatch + GLTextureCache + EngineDocument +
|
|
5
|
-
* 拆出的子系统(批次 11/12/132:SourceManager 源加载 / TextRenderer 文本管线 /
|
|
6
|
-
* SceneRenderer 节点渲染 / FontInvalidationController 字体迟到失效 /
|
|
7
|
-
* CanvasInteractionsController 交互接线 / WorkspaceBackdrop 工作区画家 /
|
|
8
|
-
* 各编辑会话与动画播放控制器),面向 fabric toObject JSON:同一份序列化
|
|
9
|
-
* 数据双渲染可逐像素对比(parity 验收地基)。
|
|
10
|
-
*
|
|
11
|
-
* 交互分层:左键 = 选择/移动/缩放/旋转/框选(PointerController),
|
|
12
|
-
* 中键 = 平移,滚轮 = 光标锚定缩放——vpt 变化仅更新一个 uniform,
|
|
13
|
-
* 无 fabric 的位图代理/缓存挂起。requestRenderAll 沿用 rAF 合并语义,
|
|
14
|
-
* e2e/调试走 render() 同步渲染保证确定性。
|
|
15
|
-
*/
|
|
16
|
-
import { installCanvasPerfGlobal, timeCanvasPerf } from './core/canvasPerf';
|
|
17
|
-
import { EventBus } from './core/events';
|
|
18
|
-
import { sceneToClipMatrix } from './core/mat2d';
|
|
19
|
-
import { isSnapGuideEnabled } from './engineFlag';
|
|
20
|
-
import { MaskNode, TableNode, WORKSPACE_ID, loadImageElement } from './model/scene';
|
|
21
|
-
import { getActiveGroupChildInfo, getSceneNodeSummary, getSelectionInfo, getSvgRasterInfo, measureCanvasFrames, readCanvasPixels } from './debug/canvasInspection';
|
|
22
|
-
import { deleteSelectionAction, nudgeSelectionAction, selectAllAction } from './interact/hotkeyActions';
|
|
23
|
-
import { CanvasInteractionsController } from './interact/canvasInteractions';
|
|
24
|
-
import { CropSessionController } from './interact/cropSession';
|
|
25
|
-
import { ExpandSessionController } from './interact/expandSession';
|
|
26
|
-
import { PathSessionController } from './interact/pathSession';
|
|
27
|
-
import { WarpSessionController } from './interact/warpSession';
|
|
28
|
-
import { followScrolledPage } from './interact/wheelScroll';
|
|
29
|
-
import { SnapGuideController } from './interact/snapGuide';
|
|
30
|
-
import { AnimationPlaybackController } from './interact/animationPlayback';
|
|
31
|
-
import { TableCellEditingController } from './interact/tableCellEditing';
|
|
32
|
-
import { TextEditingController } from './interact/textEditing';
|
|
33
|
-
import { createGLContext } from './render/GLContext';
|
|
34
|
-
import { FontInvalidationController } from './render/fontInvalidationController';
|
|
35
|
-
import { GlyphAtlas } from './render/GlyphAtlas';
|
|
36
|
-
import { RenderEpoch } from './render/renderEpoch';
|
|
37
|
-
import { GradientRampCache } from './render/gradientRamp';
|
|
38
|
-
import { GLTextureCache } from './render/GLTextureCache';
|
|
39
|
-
import { BatchOrder } from './render/batchOrder';
|
|
40
|
-
import { MeshBatch } from './render/MeshBatch';
|
|
41
|
-
import { QuadBatch } from './render/QuadBatch';
|
|
42
|
-
import { finishFrameOverlay, renderSceneNodes } from './render/framePipeline';
|
|
43
|
-
import { findWorkspaceNode, MultiPageController, renderMultiPageFrame } from './render/multiPage';
|
|
44
|
-
import { ProgressiveLoadController } from './render/progressiveLoad';
|
|
45
|
-
import { RetainedFrameController } from './render/retainedFrame';
|
|
46
|
-
import { SceneRenderer } from './render/SceneRenderer';
|
|
47
|
-
import { SourceManager } from './render/SourceManager';
|
|
48
|
-
import { collectFlatNodes, hydrateNodeSources } from './render/sourceHydration';
|
|
49
|
-
import { transferPageNodes } from './interact/pageTransfer';
|
|
50
|
-
import { withRenderViewport } from './render/renderViewport';
|
|
51
|
-
import { TextRenderer } from './render/TextRenderer';
|
|
52
|
-
import { SceneExporter } from './export/SceneExporter';
|
|
53
|
-
import { WorkspaceBackdrop } from './render/workspaceBackdrop';
|
|
54
|
-
const MIN_ZOOM = 0.02;
|
|
55
|
-
const MAX_ZOOM = 256;
|
|
56
|
-
export class EngineCanvas {
|
|
57
|
-
/** 画布元素(TextEditingHost 定位 textarea 用)。导出期(applyExportViewport)
|
|
58
|
-
* 换成离屏替身:渲染器/烘焙器经 host.canvasEl 读「当前渲染目标尺寸」,直接改
|
|
59
|
-
* 真画布 width/height 会清空后备缓冲(赋值即清屏,同值亦然),补帧前屏幕闪白 */
|
|
60
|
-
domCanvasEl;
|
|
61
|
-
/** 导出替身(applyExportViewport 换入/换出);非导出期恒 null */
|
|
62
|
-
exportStandInEl = null;
|
|
63
|
-
get canvasEl() {
|
|
64
|
-
return this.exportStandInEl ?? this.domCanvasEl;
|
|
65
|
-
}
|
|
66
|
-
/** 导出窗口(SceneRendererHost):烘焙 stale 手势门在导出期失效——视口由
|
|
67
|
-
* applyExportViewport 接管,k 换档立即新鲜烘焙(multiplier 导出锐度保底) */
|
|
68
|
-
isExporting() {
|
|
69
|
-
return this.exportStandInEl !== null;
|
|
70
|
-
}
|
|
71
|
-
handle;
|
|
72
|
-
batch;
|
|
73
|
-
meshBatch;
|
|
74
|
-
/** 跨批次 z 序协调(批次 210 优化②):quad/mesh 懒出清,交错才 flush */
|
|
75
|
-
batchOrder;
|
|
76
|
-
/** 渐进首帧(批次 218;批次 224 拆出 render/progressiveLoad):万级装载首帧
|
|
77
|
-
* 1.7s 同步阻塞的观感/总量优化——z 前缀递增渲染窗口 + 自适应扩窗;渐进链
|
|
78
|
-
* 自持 rAF,渲染管线经 limit 读窗口(-1 = 非渐进态全量) */
|
|
79
|
-
progressiveLoad = new ProgressiveLoadController({
|
|
80
|
-
render: () => this.render(),
|
|
81
|
-
nodeCount: () => this.doc.nodes.length,
|
|
82
|
-
alive: () => !this.disposed && !this.contextLost,
|
|
83
|
-
onProgressiveDone: (total) => this.bus.fire('engine:progressive-done', total)
|
|
84
|
-
});
|
|
85
|
-
textures;
|
|
86
|
-
gradientRamps;
|
|
87
|
-
glyphAtlas;
|
|
88
|
-
/** 渲染产物统一失效纪元(批次 374 方向一):GlyphAtlas.reset/纹理淘汰经
|
|
89
|
-
* bump 汇入,保留式帧门链单点消费(RetainedFrameHost.renderEpoch) */
|
|
90
|
-
renderEpoch = new RenderEpoch();
|
|
91
|
-
/** 烘焙 k 复用下限(批次 377 §5.1):SceneExporter 预览捕获档按
|
|
92
|
-
* ExportRegion.bakeScaleTolerance 置位/还原;屏幕帧恒 0(精确匹配) */
|
|
93
|
-
bakeKReuseFloor = 0;
|
|
94
|
-
/** 源加载与图案/蒙版纹理(loadObjects 编排;渲染侧 SceneRenderer 读) */
|
|
95
|
-
sources;
|
|
96
|
-
/** 文本渲染管线(字形/背景/装饰/虚线/变形文本烘焙) */
|
|
97
|
-
textRenderer;
|
|
98
|
-
/** 节点渲染分派与烘焙缓存(render 循环体;frame 承载帧级状态) */
|
|
99
|
-
renderer;
|
|
100
|
-
/** GL 原生位图导出(P6-1):FBO 离屏渲染 + readback,host 装配在本类 */
|
|
101
|
-
exporter;
|
|
102
|
-
/** 工作区画家接线(批次 132 拆出):棋盘格(批次 89,清屏后首笔)+ 外灰遮罩
|
|
103
|
-
* 贴边发光(批次 45,节点循环后)——节点查找与相位参数组装在 render/workspaceBackdrop */
|
|
104
|
-
workspaceBackdrop;
|
|
105
|
-
bus = new EventBus();
|
|
106
|
-
/** 多页页注册表(批次 407 方案 D):页 0 = 原单文档(单页态全链行为等价);
|
|
107
|
-
* 布局/路由/分段帧编排全在 render/multiPage,本类只留薄委托 */
|
|
108
|
-
multiPage = new MultiPageController();
|
|
109
|
-
dpr;
|
|
110
|
-
/** 移动端控件面(批次 354):public——PointerHost/OverlayTailHost 双面消费
|
|
111
|
-
* (pointer hitMoveControl + frameOverlay 选区覆盖层),构造期定死 */
|
|
112
|
-
mobileControls;
|
|
113
|
-
/** 交互/静态模式位(构造期定死,见 EngineCanvasOptions.interactive):
|
|
114
|
-
* CanvasInteractionsController 按位决定交互监听挂否 */
|
|
115
|
-
interactive;
|
|
116
|
-
vpt = [1, 0, 0, 1, 0, 0];
|
|
117
|
-
cssWidth = 300;
|
|
118
|
-
cssHeight = 150;
|
|
119
|
-
background;
|
|
120
|
-
rafId = null;
|
|
121
|
-
/** rAF 饥饿兜底定时器句柄(requestRenderAll 双通道,批次 44) */
|
|
122
|
-
renderTimerId = null;
|
|
123
|
-
contextLost = false;
|
|
124
|
-
disposed = false;
|
|
125
|
-
/** 字体迟到失效编排(批次 132 拆出):loadingdone 事件路径 + 帧界 settle 路径
|
|
126
|
-
* 的三层缓存作废,详见 render/fontInvalidationController.ts */
|
|
127
|
-
fontInvalidation;
|
|
128
|
-
/** 保留式场景帧(批次 223 重落):门链全过的帧只重推脏集 + 重放缓照命令表,
|
|
129
|
-
* 详见 render/retainedFrame.ts(含模板 273 回归根因与图集世代门) */
|
|
130
|
-
retainedFrame;
|
|
131
|
-
/** 交互接线(批次 132 拆出):Pointer/Table/DoubleClick 三控制器装配 + 中键
|
|
132
|
-
* 平移/滚轮/Esc/字体监听 + 文档事件接线,详见 interact/canvasInteractions.ts */
|
|
133
|
-
interactions;
|
|
134
|
-
/** 外部绘制会话挂起位(compat 绘制桥写位):true 时 PointerController/
|
|
135
|
-
* DoubleClickController 整体让位——画笔/形状绘制期指针由宿主外工具接管 */
|
|
136
|
-
interactionSuspended = false;
|
|
137
|
-
/** 框选矩形(场景系),PointerController 写、render 读 */
|
|
138
|
-
marquee = null;
|
|
139
|
-
/** 中键平移状态(public:PointerHost 面——pointer.ts 悬停光标让位判断;
|
|
140
|
-
* 手势由 CanvasInteractionsController 写) */
|
|
141
|
-
panning = false;
|
|
142
|
-
/** 文本编辑 UI(textarea/闪烁/导航键/编辑 overlay),构造时装配 */
|
|
143
|
-
textEditing;
|
|
144
|
-
/** 表格单元格文本编辑 overlay 会话(P4-4b(2/2)),构造时装配 */
|
|
145
|
-
tableCellEditing;
|
|
146
|
-
/** 拖拽/缩放吸附(P5-2):帧率化结算在 render 入口、辅助线 overlay 画在选区覆盖层之上 */
|
|
147
|
-
snapGuide;
|
|
148
|
-
/** 画布标尺(P5-3):20px 边带刻度 + 位图数字(应用 FabricRuler.enabled 同义开关) */
|
|
149
|
-
rulerVisibleValue = false;
|
|
150
|
-
/** 图片裁剪会话(B2):吞没常规交互,覆盖层取代选区 UI,SceneRenderer 消费幽灵底图 */
|
|
151
|
-
cropSessionController;
|
|
152
|
-
expandSessionController;
|
|
153
|
-
/** 路径族锚点编辑会话(P4-7):吞没常规交互,覆盖层换锚点/手柄/插点预览 */
|
|
154
|
-
pathSessionController;
|
|
155
|
-
/** 图片扭曲编辑会话(批次 66):warpvas 核心库 + 自建交互层;覆盖层 =
|
|
156
|
-
* 预览纹理 quad + 网格 + 锚点;会话期 SceneRenderer 跳过目标常规绘制 */
|
|
157
|
-
warpSessionController;
|
|
158
|
-
/** 扭曲会话历史栈变化回调(compat 门面赋值——应用 warpUndoable/warpRedoable) */
|
|
159
|
-
onWarpHistoryChange;
|
|
160
|
-
/** 对象动画播放编排(P5-6;批次 11 拆出 interact/animationPlayback):顺序时间轴
|
|
161
|
-
* 插值 → 节点派生层覆写;GIF/Video 不归播放器管(AnimatedNode 自走推帧管线) */
|
|
162
|
-
animationPlaybackController;
|
|
163
|
-
/** 单元格选区通知槽的本实例闭包(dispose 按归属卸 TableNode 静态槽) */
|
|
164
|
-
cellSelectionSink;
|
|
165
|
-
constructor(canvasEl, handle, options) {
|
|
166
|
-
// 引擎模式同装 canvas perf 全局(对齐 app fabricCanvas 构造器惯例,幂等):
|
|
167
|
-
// 引擎模式此前无此挂点,?canvasPerf=1 只在 fabric 模式生效——engine.render
|
|
168
|
-
// 等埋点在引擎模式长期采不到。报告打印引擎模式默认关(canvasPerf.ts
|
|
169
|
-
// shouldEnableByDefault 守卫):显式 ?canvasPerf=1 或 .enable() 才开,
|
|
170
|
-
// localStorage('canvasPerf') 持久化已随批次 278 退役(fabric 口径死支)
|
|
171
|
-
installCanvasPerfGlobal();
|
|
172
|
-
this.domCanvasEl = canvasEl;
|
|
173
|
-
// 画布按块盒接管尺寸(resize 写死 css 宽高):canvas 默认 inline,行盒的
|
|
174
|
-
// 基线留白会让宿主容器比画布高几像素——宿主容器一有溢出就变成「可滚动」,
|
|
175
|
-
// 页面里任何聚焦/scrollIntoView(如文本编辑的隐藏 textarea)都能把它滚走
|
|
176
|
-
this.domCanvasEl.style.display = 'block';
|
|
177
|
-
this.handle = handle;
|
|
178
|
-
this.batch = new QuadBatch(handle.gl);
|
|
179
|
-
this.meshBatch = new MeshBatch(handle.gl);
|
|
180
|
-
// 跨批次 z 序协调器(批次 210 P6-4 优化②):装配后 quad/mesh 懒出清——
|
|
181
|
-
// 只在待发内容真正交错时 flush 先压一方,纯 mesh 连压整段合一 draw
|
|
182
|
-
// (万级 shape 场景每帧万+ draw call 的主削减位)
|
|
183
|
-
this.batchOrder = new BatchOrder(this.batch, this.meshBatch);
|
|
184
|
-
this.batch.order = this.batchOrder;
|
|
185
|
-
this.meshBatch.order = this.batchOrder;
|
|
186
|
-
this.textures = new GLTextureCache(handle.gl, { epoch: this.renderEpoch });
|
|
187
|
-
this.gradientRamps = new GradientRampCache(handle.gl);
|
|
188
|
-
// 批次 42:provisional cell 被 loadingdone 丢弃后立即补帧(否则空转等下一次
|
|
189
|
-
// 外部触发才重烘真字形);批次 46:帧界 settle(事件失联自愈路径)上报
|
|
190
|
-
// family 集 → 宿主补齐排版/度量/烘焙失效(见 fontInvalidation 的 pendingSettle)
|
|
191
|
-
this.glyphAtlas = new GlyphAtlas(handle.gl, () => this.requestRenderAll(), (families) => this.fontInvalidation.queueSettle(families), this.renderEpoch);
|
|
192
|
-
this.dpr = options.dpr ?? (typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1);
|
|
193
|
-
this.mobileControls = options.mobileControls ?? false;
|
|
194
|
-
this.interactive = options.interactive ?? true;
|
|
195
|
-
this.background = options.background ?? [0, 0, 0, 0];
|
|
196
|
-
this.sources = new SourceManager(this);
|
|
197
|
-
this.textRenderer = new TextRenderer(handle.gl, this.batch, this.glyphAtlas);
|
|
198
|
-
this.renderer = new SceneRenderer(this, this.sources, this.textRenderer);
|
|
199
|
-
this.fontInvalidation = new FontInvalidationController(this, this.textRenderer, this.glyphAtlas, this.renderer);
|
|
200
|
-
this.retainedFrame = new RetainedFrameController(this);
|
|
201
|
-
this.exporter = new SceneExporter(this);
|
|
202
|
-
this.workspaceBackdrop = new WorkspaceBackdrop();
|
|
203
|
-
this.textEditing = new TextEditingController(this);
|
|
204
|
-
this.tableCellEditing = new TableCellEditingController(this);
|
|
205
|
-
this.snapGuide = new SnapGuideController(this, isSnapGuideEnabled);
|
|
206
|
-
this.cropSessionController = new CropSessionController(this);
|
|
207
|
-
this.expandSessionController = new ExpandSessionController(this);
|
|
208
|
-
this.pathSessionController = new PathSessionController(this);
|
|
209
|
-
this.warpSessionController = new WarpSessionController(this);
|
|
210
|
-
this.animationPlaybackController = new AnimationPlaybackController(this);
|
|
211
|
-
this.interactions = new CanvasInteractionsController(this, this.snapGuide, this.sources, this.interactive);
|
|
212
|
-
// 表格单元格选区变化通知(P4-4b 补):TableNode 静态槽 → 本文档事件总线
|
|
213
|
-
// (引擎单画布常驻,静态槽即当前文档;dispose 按归属卸载防双实例互踩)
|
|
214
|
-
this.cellSelectionSink = (node) => {
|
|
215
|
-
this.doc.events.fire('table:cellselection', node);
|
|
216
|
-
};
|
|
217
|
-
TableNode.cellSelectionSink = this.cellSelectionSink;
|
|
218
|
-
}
|
|
219
|
-
/** 创建引擎实例;WebGL2 不可用返回 null(调用方回退 fabric 路径) */
|
|
220
|
-
static create(canvasEl, options = {}) {
|
|
221
|
-
let instance = null;
|
|
222
|
-
const handle = createGLContext(canvasEl, {
|
|
223
|
-
onLost: () => instance?.onContextLost(),
|
|
224
|
-
onRestored: () => instance?.onContextRestored()
|
|
225
|
-
});
|
|
226
|
-
if (!handle)
|
|
227
|
-
return null;
|
|
228
|
-
instance = new EngineCanvas(canvasEl, handle, options);
|
|
229
|
-
return instance;
|
|
230
|
-
}
|
|
231
|
-
onContextLost() {
|
|
232
|
-
this.contextLost = true;
|
|
233
|
-
this.bus.fire('engine:context-lost');
|
|
234
|
-
}
|
|
235
|
-
onContextRestored() {
|
|
236
|
-
this.contextLost = false;
|
|
237
|
-
this.recoverGlResources();
|
|
238
|
-
this.bus.fire('engine:context-restored');
|
|
239
|
-
// 恢复后立即补一帧:纹理缓存已清空,下一帧渲染触发全量重传(含动画纹理)
|
|
240
|
-
this.requestRenderAll();
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* P6-2 恢复链主体(onContextRestored 调用;亦可诊断/e2e 在健康上下文上直接
|
|
244
|
-
* 驱动作演练——对活上下文是真实的 delete+recreate 全套):
|
|
245
|
-
* 批渲染器重建(program/VAO/缓冲/白纹理——句柄非空但已死)、纹理缓存/
|
|
246
|
-
* 渐变查/字形图集清空重传、源管理器 GL 纹理失效、渲染器四族烘焙缓存 +
|
|
247
|
-
* 组隔离器 + 阴影/PSD GPU 画家失效(下一帧按签名 miss 全量重跑,分帧摊销如常)
|
|
248
|
-
*/
|
|
249
|
-
recoverGlResources() {
|
|
250
|
-
// 批次 223 重落:rebuild 后纹理句柄全死——保留式快照前置作废
|
|
251
|
-
this.retainedFrame.invalidate();
|
|
252
|
-
this.batch.rebuild();
|
|
253
|
-
this.meshBatch.rebuild();
|
|
254
|
-
this.textures.invalidateAll();
|
|
255
|
-
this.gradientRamps.invalidateAll();
|
|
256
|
-
this.glyphAtlas.reset();
|
|
257
|
-
this.sources.invalidateGlTextures();
|
|
258
|
-
this.renderer.invalidateGlResources();
|
|
259
|
-
this.workspaceBackdrop.invalidate();
|
|
260
|
-
}
|
|
261
|
-
/** 节点级文本烘焙作废(批次 39,语义见 render/fontInvalidationController) */
|
|
262
|
-
invalidateNodeTextBakes(node) {
|
|
263
|
-
this.fontInvalidation.invalidateNodeTextBakes(node);
|
|
264
|
-
}
|
|
265
|
-
/** 字体迟到失效(loadingdone 订阅在 CanvasInteractionsController;语义见
|
|
266
|
-
* render/fontInvalidationController) */
|
|
267
|
-
handleFontsLoaded(fontfaces) {
|
|
268
|
-
this.fontInvalidation.handleFontsLoaded(fontfaces);
|
|
269
|
-
}
|
|
270
|
-
/** FontInvalidationHost:私有存活位的只读面(各失效口守护语义与拆分前逐口一致) */
|
|
271
|
-
get engineDisposed() {
|
|
272
|
-
return this.disposed;
|
|
273
|
-
}
|
|
274
|
-
/** FontInvalidationHost:私有存活位的只读面 */
|
|
275
|
-
get engineContextLost() {
|
|
276
|
-
return this.contextLost;
|
|
277
|
-
}
|
|
278
|
-
/** FontInvalidationHost 多页遍历面(批次 410 D-4):字体迟到失效遍历全部页 */
|
|
279
|
-
documentNodes() {
|
|
280
|
-
return this.multiPage.pageCount > 1 ? this.multiPage.allDocs() : [this.doc];
|
|
281
|
-
}
|
|
282
|
-
/** 指针手势进行中的只读面(CanvasInteractionsController.pointer.active):
|
|
283
|
-
* 宿主判据用(compat `_currentTransform` 兼容位 → 快照保存拖动期顺延) */
|
|
284
|
-
get pointerActive() {
|
|
285
|
-
return this.interactions.pointerActive;
|
|
286
|
-
}
|
|
287
|
-
get events() {
|
|
288
|
-
return this.bus;
|
|
289
|
-
}
|
|
290
|
-
/** 活动页 doc(存量 this.doc 读位全量隐式路由——多页态即活动页,兼容
|
|
291
|
-
* compat/面板/hook 族零改动;页路由显式面见 pageCount/insertPage 族) */
|
|
292
|
-
get doc() {
|
|
293
|
-
return this.multiPage.activeDoc;
|
|
294
|
-
}
|
|
295
|
-
get document() {
|
|
296
|
-
return this.doc;
|
|
297
|
-
}
|
|
298
|
-
get capabilities() {
|
|
299
|
-
return { maxTextureSize: this.handle.capabilities.maxTextureSize, renderer: this.handle.capabilities.renderer };
|
|
300
|
-
}
|
|
301
|
-
/** 活动页视图口径(批次 409 D-3):多页态 = vpt ∘ T(活动页偏移)——snapGuide
|
|
302
|
-
* 视口预过滤/标尺刻度/compat 同步面与 toScene/toScreen 同语义;单页态
|
|
303
|
-
* 恒等原值。raw vpt(布局/GL 域)保持私有 */
|
|
304
|
-
get viewportTransform() {
|
|
305
|
-
return this.multiPage.pageCount > 1 ? this.multiPage.pageVpt(this.vpt, this.multiPage.activeIndex) : [...this.vpt];
|
|
306
|
-
}
|
|
307
|
-
/** 文档流滚动边界读位,坐标系与 workspaceSize 的全文档包围盒一致。 */
|
|
308
|
-
get scrollViewportTransform() {
|
|
309
|
-
return [...this.vpt];
|
|
310
|
-
}
|
|
311
|
-
get zoom() {
|
|
312
|
-
return this.vpt[0];
|
|
313
|
-
}
|
|
314
|
-
get gl() {
|
|
315
|
-
return this.handle.gl;
|
|
316
|
-
}
|
|
317
|
-
/** SnapGuideHost:视口 css 尺寸(吸附候选的视口预过滤用) */
|
|
318
|
-
get viewSize() {
|
|
319
|
-
return { width: this.cssWidth, height: this.cssHeight };
|
|
320
|
-
}
|
|
321
|
-
/** WheelScrollHost:工作区场景尺寸(滚轮平移边界钳制用;缺席两维 0 = fabric
|
|
322
|
-
* workSpaceDraw 缺席同款)。多页态(批次 408 D-2)= 全文档包围盒——钳制
|
|
323
|
-
* 域随文档流纵向展开(页 0 归一化在原点,wheelScroll 原点锚定口径直用) */
|
|
324
|
-
workspaceSize() {
|
|
325
|
-
if (this.multiPage.pageCount > 1) {
|
|
326
|
-
const bounds = this.multiPage.documentBounds();
|
|
327
|
-
return bounds && bounds.width > 0 && bounds.height > 0 ? { width: bounds.width, height: bounds.height } : { width: 0, height: 0 };
|
|
328
|
-
}
|
|
329
|
-
const ws = this.doc.nodes.find((n) => String(n.raw.id ?? '') === WORKSPACE_ID)?.bounds;
|
|
330
|
-
return ws && ws.width > 0 && ws.height > 0 ? { width: ws.width, height: ws.height } : { width: 0, height: 0 };
|
|
331
|
-
}
|
|
332
|
-
/** WheelScrollHost:wheel 光标的画布 css 坐标(缩放锚点) */
|
|
333
|
-
cursorPoint(e) {
|
|
334
|
-
const rect = this.canvasEl.getBoundingClientRect();
|
|
335
|
-
return { x: e.clientX - rect.left, y: e.clientY - rect.top };
|
|
336
|
-
}
|
|
337
|
-
followScrolledPage() {
|
|
338
|
-
if (this.multiPage.pageCount < 2)
|
|
339
|
-
return;
|
|
340
|
-
// 一次布局快照;逐页 pageRectAt 会重复 layout,长文档退化为 O(N²)。
|
|
341
|
-
followScrolledPage(this, this.multiPage.layout().map(({ index, rect, entry }) => ({ index, top: rect.top + entry.origin.y, height: rect.height })));
|
|
342
|
-
}
|
|
343
|
-
// PointerHost B2 裁剪会话句柄(非会话态 null——pointer 侧吞没判定)
|
|
344
|
-
get cropSession() {
|
|
345
|
-
return this.cropSessionController.active ? this.cropSessionController : null;
|
|
346
|
-
}
|
|
347
|
-
/** SceneRendererHost:裁剪会话目标(幽灵底图门控) */
|
|
348
|
-
get cropGhostNode() {
|
|
349
|
-
return this.cropSessionController.target;
|
|
350
|
-
}
|
|
351
|
-
/** SceneRendererHost:蒙版裁剪会话目标(B3 余量——合成层 50% 预览 alpha 门控,
|
|
352
|
-
* 应用 FabricMask 裁剪态 renderClipImage 的 globalAlpha 0.5×opacity 同口径) */
|
|
353
|
-
get maskCropNode() {
|
|
354
|
-
const t = this.cropSessionController.target;
|
|
355
|
-
return t instanceof MaskNode ? t : null;
|
|
356
|
-
}
|
|
357
|
-
/** B3 扩图会话(pointer 消费面;裁剪/扩图互斥——后进会先退另一会话) */
|
|
358
|
-
get expandSession() {
|
|
359
|
-
return this.expandSessionController.active ? this.expandSessionController : null;
|
|
360
|
-
}
|
|
361
|
-
/** P4-7 路径族锚点编辑会话(pointer 消费面;与裁剪/扩图互斥——进入时先退) */
|
|
362
|
-
get pathSession() {
|
|
363
|
-
return this.pathSessionController.active ? this.pathSessionController : null;
|
|
364
|
-
}
|
|
365
|
-
/** 批次 66 图片扭曲会话(pointer 消费面;与裁剪/扩图/路径会话互斥) */
|
|
366
|
-
get warpSession() {
|
|
367
|
-
return this.warpSessionController.active ? this.warpSessionController : null;
|
|
368
|
-
}
|
|
369
|
-
/** 扭曲会话调试读位(批次 66 e2e/坐标系核对) */
|
|
370
|
-
get warpDebugSample() {
|
|
371
|
-
return this.warpSessionController.debugBoundsSample;
|
|
372
|
-
}
|
|
373
|
-
/** 扭曲预览画布调试读位(对象恒等/尺寸——render 单例复用核对) */
|
|
374
|
-
get warpDebugPreview() {
|
|
375
|
-
return this.warpSessionController.debugPreviewInfo;
|
|
376
|
-
}
|
|
377
|
-
/** 扭曲锚点清单调试读位(hitAnchor 同路径自诊断) */
|
|
378
|
-
get warpDebugAnchors() {
|
|
379
|
-
return this.warpSessionController.debugAnchors;
|
|
380
|
-
}
|
|
381
|
-
/** SceneRendererHost:扭曲会话目标(会话期跳过常规绘制——预览 quad 在覆盖层) */
|
|
382
|
-
get warpSessionTarget() {
|
|
383
|
-
return this.warpSessionController.target;
|
|
384
|
-
}
|
|
385
|
-
/** SceneRendererHost:变形文本烘焙门控(编辑态走常规管线) */
|
|
386
|
-
get editingNode() {
|
|
387
|
-
return this.doc.editingNode;
|
|
388
|
-
}
|
|
389
|
-
get stats() {
|
|
390
|
-
return { nodeCount: this.doc.nodes.length, skippedTypes: { ...this.doc.skippedTypes } };
|
|
391
|
-
}
|
|
392
|
-
/** 渲染诊断(e2e/开发用):GL 错误码 + 上一帧提交的实例数 */
|
|
393
|
-
get diagnostics() {
|
|
394
|
-
return {
|
|
395
|
-
glError: this.handle.gl.getError(),
|
|
396
|
-
drawnInstances: this.batch.drawnInstances,
|
|
397
|
-
contextLost: this.contextLost
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
/** 纹理内存预算诊断(P6-2,e2e/性能观察面):缓存 LRU 记账 + 图集页/字形数 */
|
|
401
|
-
get textureBudgetInfo() {
|
|
402
|
-
return { textures: this.textures.stats(), atlas: this.glyphAtlas.stats() };
|
|
403
|
-
}
|
|
404
|
-
/** 运行时调整纹理字节预算(诊断/e2e;立即触发超额淘汰,帧界保护仍生效) */
|
|
405
|
-
setTextureBudget(bytes) {
|
|
406
|
-
this.textures.setBudget(bytes);
|
|
407
|
-
}
|
|
408
|
-
// #region 坐标换算(css 像素 ↔ 场景)
|
|
409
|
-
/** 活动页原点(多页态 = 页偏移装饰;单页态恒等原点——公共坐标面语义不变) */
|
|
410
|
-
get activePageOrigin() {
|
|
411
|
-
return this.multiPage.pageCount > 1 ? this.multiPage.originAt(this.multiPage.activeIndex) : { x: 0, y: 0 };
|
|
412
|
-
}
|
|
413
|
-
/** css → 画布绝对场景坐标(布局系,未减页偏移——多页路由/文档流几何用) */
|
|
414
|
-
toSceneAbs(cssX, cssY) {
|
|
415
|
-
return { x: (cssX - this.vpt[4]) / this.vpt[0], y: (cssY - this.vpt[5]) / this.vpt[3] };
|
|
416
|
-
}
|
|
417
|
-
/** css → 活动页页内场景坐标(批次 409 D-3:多页态减活动页偏移;单页态与
|
|
418
|
-
* toSceneAbs 逐位一致——指针/编辑链的既有语义面) */
|
|
419
|
-
toScene(cssX, cssY) {
|
|
420
|
-
const abs = this.toSceneAbs(cssX, cssY);
|
|
421
|
-
const o = this.activePageOrigin;
|
|
422
|
-
return { x: abs.x - o.x, y: abs.y - o.y };
|
|
423
|
-
}
|
|
424
|
-
/** 活动页页内场景坐标 → css(批次 409 D-3:多页态复合页偏移;单页态逐位一致) */
|
|
425
|
-
toScreen(x, y) {
|
|
426
|
-
const o = this.activePageOrigin;
|
|
427
|
-
return { x: this.vpt[0] * (x + o.x) + this.vpt[4], y: this.vpt[3] * (y + o.y) + this.vpt[5] };
|
|
428
|
-
}
|
|
429
|
-
// #endregion
|
|
430
|
-
resize(cssWidth, cssHeight) {
|
|
431
|
-
// 首帧 CSS(如 UnoCSS 异步注入)未生效时 flex 容器可能瞬时塌缩,
|
|
432
|
-
// 退化尺寸直接跳过等 ResizeObserver 的下一次回调,避免 GL 重设为 1px 画布
|
|
433
|
-
if (cssWidth <= 1 || cssHeight <= 1)
|
|
434
|
-
return;
|
|
435
|
-
this.cssWidth = Math.max(1, cssWidth);
|
|
436
|
-
this.cssHeight = Math.max(1, cssHeight);
|
|
437
|
-
this.canvasEl.width = Math.round(this.cssWidth * this.dpr);
|
|
438
|
-
this.canvasEl.height = Math.round(this.cssHeight * this.dpr);
|
|
439
|
-
this.canvasEl.style.width = `${this.cssWidth}px`;
|
|
440
|
-
this.canvasEl.style.height = `${this.cssHeight}px`;
|
|
441
|
-
this.render();
|
|
442
|
-
}
|
|
443
|
-
/** 渐进首帧启动(批次 218):语义与自适应扩窗/终止门槛见 render/progressiveLoad。
|
|
444
|
-
* 由宿主在装载收尾后调用(compat loadFromJSON 尾部——早于此,装载收尾
|
|
445
|
-
* 链的重绘请求会在渐进首帧产出后把窗口合法收满=失效,实测踩坑) */
|
|
446
|
-
progressiveFirstFrame(initialBatch = 1000, graceMs = 800) {
|
|
447
|
-
this.progressiveLoad.start(initialBatch, graceMs);
|
|
448
|
-
}
|
|
449
|
-
/** 载入 fabric 序列化对象数组(模板 objects 或种子场景);同 src 位图共享同一 element/纹理。
|
|
450
|
-
* 首帧不等资源:形状/文本即时渲染,图像族在途节点渲染色块占位,各源就绪后
|
|
451
|
-
* 逐个重绘替换;Promise 仍等全部源就绪才 resolve(parity/e2e 的加载完成契约不变) */
|
|
452
|
-
async loadObjects(objects) {
|
|
453
|
-
// 场景整体重建:先释放上一批动态源(视频断流/纹理归还),防解码器后台占流;
|
|
454
|
-
// 动画播放态随之作废(覆写挂在旧节点上,随场景一起丢弃)。多页态(批次
|
|
455
|
-
// 411 D-5)只断活动页的源——他页在途 GIF/视频不受扰;单页态整画布释放
|
|
456
|
-
// 与既有行为逐位一致
|
|
457
|
-
if (this.multiPage.pageCount > 1)
|
|
458
|
-
this.sources.releaseAnimatedSourcesOfDoc(this.multiPage.activeDoc);
|
|
459
|
-
else
|
|
460
|
-
this.sources.releaseAnimatedSources();
|
|
461
|
-
this.animationPlaybackController.reset();
|
|
462
|
-
this.doc.loadObjects(objects);
|
|
463
|
-
// 页布局重捕获工作区引用(多页态重排;单页态矩形走渲染期活读不受影响);
|
|
464
|
-
// 同步清懒建造挂起位(急装路径绕过 ensurePageBuilt 时防旧 raw 重放)
|
|
465
|
-
this.multiPage.markBuilt(this.multiPage.activeIndex);
|
|
466
|
-
await hydrateNodeSources(collectFlatNodes([...this.doc.nodes]), this.sources, () => this.requestRenderAll());
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* 批次 112:运行时增量补源——document.add 后动态源(GIF/视频/图案/组蒙版/
|
|
470
|
-
* 位图)的挂接口。装载链此前只随 loadObjects 整景跑:运行时新增节点(compat
|
|
471
|
-
* raw 直构批的产物——无 fabric 实例可随迁 _element)经此口补挂,否则
|
|
472
|
-
* AnimatedNode 无 sprite/视频元素、pattern 节点按无填充渲染(主仓批次 110
|
|
473
|
-
* 登记的「运行时补源不对称」缺口的引擎侧收口)。幂等可重入。
|
|
474
|
-
*/
|
|
475
|
-
async ensureNodeSources(nodes) {
|
|
476
|
-
await hydrateNodeSources(collectFlatNodes(nodes), this.sources, () => this.requestRenderAll());
|
|
477
|
-
}
|
|
478
|
-
// #region 多页(批次 407 方案 D):页注册表薄委托——编排与分段帧在 render/multiPage
|
|
479
|
-
get pageCount() {
|
|
480
|
-
return this.multiPage.pageCount;
|
|
481
|
-
}
|
|
482
|
-
get activePageIndex() {
|
|
483
|
-
return this.multiPage.activeIndex;
|
|
484
|
-
}
|
|
485
|
-
/** 激活页切换(批次 409 D-3 收口):手势期拒绝切页(手势坐标钉死在起始页
|
|
486
|
-
* ——外部入口如缩略图点击在手势期不生效);切换即收口在途编辑会话与
|
|
487
|
-
* 手势装饰位(collate 内联——旧页悬停/编辑态清空、四编辑会话退出保用户
|
|
488
|
-
* 工作、marquee/rotateDrag/referenceLineDrag 复位) */
|
|
489
|
-
setActivePage(index) {
|
|
490
|
-
if (this.interactions.pointerActive)
|
|
491
|
-
return;
|
|
492
|
-
if (index < 0 || index >= this.multiPage.pageCount || index === this.multiPage.activeIndex)
|
|
493
|
-
return;
|
|
494
|
-
const prevDoc = this.multiPage.activeDoc;
|
|
495
|
-
// 播放收口(批次 411 D-5):切页前 stop——时间轴覆写清零 + 旧页自播
|
|
496
|
-
// GIF/视频元素全停 + 滚动文本归零(stop 跟随切换前的活动页;空转零成本)
|
|
497
|
-
this.animationPlaybackController.stop();
|
|
498
|
-
this.bus.fire('engine:active-page-changing', index);
|
|
499
|
-
this.multiPage.setActiveIndex(index);
|
|
500
|
-
prevDoc.setHovered(null);
|
|
501
|
-
if (prevDoc.editingNode)
|
|
502
|
-
prevDoc.exitEditing();
|
|
503
|
-
if (this.cropSessionController.active)
|
|
504
|
-
this.cropSessionController.exit();
|
|
505
|
-
if (this.expandSessionController.active)
|
|
506
|
-
this.expandSessionController.exit();
|
|
507
|
-
if (this.pathSessionController.active)
|
|
508
|
-
this.pathSessionController.exit();
|
|
509
|
-
if (this.warpSessionController.active)
|
|
510
|
-
void this.warpSessionController.exit(true).catch(() => { });
|
|
511
|
-
this.marquee = null;
|
|
512
|
-
this.rotateDrag = null;
|
|
513
|
-
this.referenceLineDrag = null;
|
|
514
|
-
// doc bus 重订(批次 410 D-4):四控制器事件束随活动页切事件源(收口先于
|
|
515
|
-
// 重订——旧页退出事件由仍订旧 bus 的控制器消费,textarea 卸载等收尾完整)
|
|
516
|
-
const nextDoc = this.multiPage.activeDoc;
|
|
517
|
-
this.textEditing.retargetDoc(nextDoc);
|
|
518
|
-
this.tableCellEditing.retargetDoc(nextDoc);
|
|
519
|
-
this.interactions.retargetDoc(nextDoc);
|
|
520
|
-
this.bus.fire('engine:active-page-changed', index);
|
|
521
|
-
this.requestRenderAll();
|
|
522
|
-
}
|
|
523
|
-
/** 多页指针路由(批次 409 D-3;PointerHost/DblClickHost 可选面):绝对场景点
|
|
524
|
-
* → 目标页(doc=命中页、local=页内坐标、routed=真命中)。吞没性编辑会话期
|
|
525
|
-
* 自锁活动页(会话模态——点外退出语义保持);页间 gap 返回 null。单页态
|
|
526
|
-
* 直接回退活动页原坐标(routed=false) */
|
|
527
|
-
resolvePointerTarget(sceneAbsX, sceneAbsY) {
|
|
528
|
-
if (this.multiPage.pageCount === 1)
|
|
529
|
-
return { doc: this.doc, local: { x: sceneAbsX, y: sceneAbsY }, routed: false };
|
|
530
|
-
const sessionLocked = this.cropSessionController.active || this.expandSessionController.active || this.pathSessionController.active || this.warpSessionController.active;
|
|
531
|
-
const entry = this.multiPage.route(sceneAbsX, sceneAbsY);
|
|
532
|
-
if (sessionLocked || !entry) {
|
|
533
|
-
const origin = this.multiPage.originAt(this.multiPage.activeIndex);
|
|
534
|
-
return { doc: this.multiPage.activeDoc, local: { x: sceneAbsX - origin.x, y: sceneAbsY - origin.y }, routed: false };
|
|
535
|
-
}
|
|
536
|
-
return { doc: entry.doc, local: entry.local, routed: true };
|
|
537
|
-
}
|
|
538
|
-
/** 路由激活(down/双击命中非活动页时由指针链调用):即 setActivePage 含收口 */
|
|
539
|
-
activateRoutedDocument(doc) {
|
|
540
|
-
const index = this.multiPage.indexOfDoc(doc);
|
|
541
|
-
if (index >= 0)
|
|
542
|
-
this.setActivePage(index);
|
|
543
|
-
}
|
|
544
|
-
transferDraggedNodes(nodes, before, cssX, cssY) {
|
|
545
|
-
const transfer = transferPageNodes(this.multiPage, nodes, before, this.toSceneAbs(cssX, cssY), (index) => {
|
|
546
|
-
void this.ensurePageBuilt(index);
|
|
547
|
-
});
|
|
548
|
-
if (!transfer)
|
|
549
|
-
return false;
|
|
550
|
-
this.setActivePage(transfer.targetIndex);
|
|
551
|
-
transfer.target.setSelection(transfer.nodes);
|
|
552
|
-
this.bus.fire('engine:page-transfer', transfer);
|
|
553
|
-
this.requestRenderAll();
|
|
554
|
-
return true;
|
|
555
|
-
}
|
|
556
|
-
/** 新建页并装载场景(objects 缺省空页);返回实际落位索引 */
|
|
557
|
-
async insertPage(index, objects = []) {
|
|
558
|
-
const at = this.multiPage.insert(index);
|
|
559
|
-
this.retainedFrame.invalidate();
|
|
560
|
-
await this.loadPageObjects(at, objects);
|
|
561
|
-
return at;
|
|
562
|
-
}
|
|
563
|
-
/** 删除页(末页拒绝 false;活动索引随动钳制) */
|
|
564
|
-
removePage(index) {
|
|
565
|
-
const ok = this.multiPage.remove(index);
|
|
566
|
-
if (ok) {
|
|
567
|
-
this.retainedFrame.invalidate();
|
|
568
|
-
this.requestRenderAll();
|
|
569
|
-
}
|
|
570
|
-
return ok;
|
|
571
|
-
}
|
|
572
|
-
/** 页场景重建(loadObjects 语义限定到指定页:活动页走既有整链含动画源释放/
|
|
573
|
-
* 播放态重置;非活动页仅该 doc 重建 + 补源,整画布态不动——旧页动态源的
|
|
574
|
-
* 定向释放随 D-5 的 per-doc 源记账) */
|
|
575
|
-
async loadPageObjects(index, objects) {
|
|
576
|
-
const entry = this.multiPage.pageAt(index);
|
|
577
|
-
if (!entry)
|
|
578
|
-
return;
|
|
579
|
-
if (index === this.multiPage.activeIndex) {
|
|
580
|
-
await this.loadObjects(objects);
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
|
-
entry.doc.loadObjects(objects);
|
|
584
|
-
this.multiPage.markBuilt(index);
|
|
585
|
-
await hydrateNodeSources(collectFlatNodes([...entry.doc.nodes]), this.sources, () => this.requestRenderAll());
|
|
586
|
-
this.requestRenderAll();
|
|
587
|
-
}
|
|
588
|
-
/** 懒解析挂起(批次 408 D-2):存 raw 不建节点——布局走工作区占位直读,
|
|
589
|
-
* 页进入可见窗口由渲染帧触发建造(onPageVisible → ensurePageBuilt)。
|
|
590
|
-
* 长文档首装载全页 setPageRaw + ensurePageBuilt(活动页) 即可,内存随窗口驻留 */
|
|
591
|
-
setPageRaw(index, objects) {
|
|
592
|
-
const ok = this.multiPage.setPageRaw(index, objects);
|
|
593
|
-
if (ok)
|
|
594
|
-
this.requestRenderAll();
|
|
595
|
-
return ok;
|
|
596
|
-
}
|
|
597
|
-
/** 新建页并懒挂起(insert + setPageRaw 一体);返回实际落位索引 */
|
|
598
|
-
insertPageRaw(index, objects) {
|
|
599
|
-
const at = this.multiPage.insert(index);
|
|
600
|
-
this.retainedFrame.invalidate();
|
|
601
|
-
this.setPageRaw(at, objects);
|
|
602
|
-
return at;
|
|
603
|
-
}
|
|
604
|
-
/** 已建判定(懒解析面——宿主/调试口消费) */
|
|
605
|
-
isPageBuilt(index) {
|
|
606
|
-
return this.multiPage.isBuilt(index);
|
|
607
|
-
}
|
|
608
|
-
/** 建造挂起页(pendingRaw → doc 节点 + 补源;幂等——挂起位在首个同步段清零,
|
|
609
|
-
* 渲染帧重复触发无竞态)。刻意不走 loadObjects 整链:懒建造页此前为空页,
|
|
610
|
-
* 无自身动态源可释,且整画布释放会误杀他页在途源(per-doc 释放随 D-5) */
|
|
611
|
-
async ensurePageBuilt(index) {
|
|
612
|
-
const entry = this.multiPage.pageAt(index);
|
|
613
|
-
if (!entry || !entry.pendingRaw)
|
|
614
|
-
return;
|
|
615
|
-
entry.doc.loadObjects(entry.pendingRaw);
|
|
616
|
-
this.multiPage.markBuilt(index);
|
|
617
|
-
this.bus.fire('engine:page-built', index, entry.doc);
|
|
618
|
-
await hydrateNodeSources(collectFlatNodes([...entry.doc.nodes]), this.sources, () => this.requestRenderAll());
|
|
619
|
-
this.requestRenderAll();
|
|
620
|
-
}
|
|
621
|
-
/** 页绝对场景矩形(宿主滚动定位/e2e/debug 几何共源;无效页 null) */
|
|
622
|
-
pageRectAt(index) {
|
|
623
|
-
return this.multiPage.pageRectAt(index);
|
|
624
|
-
}
|
|
625
|
-
/** 以活动 doc 为锚重建页注册表(主仓 syncEnginePages 结构失配修复面——批次 413) */
|
|
626
|
-
rebuildAroundActive(count, activeIndex) {
|
|
627
|
-
this.retainedFrame.invalidate();
|
|
628
|
-
this.multiPage.rebuildAroundActive(count, activeIndex);
|
|
629
|
-
this.requestRenderAll();
|
|
630
|
-
}
|
|
631
|
-
/** 分段帧宿主装配(每帧现建——vpt/cssWidth 是按值快照进字面量的,缓存会陈旧;
|
|
632
|
-
* 私有控制器不落公开 API) */
|
|
633
|
-
multiPageFrameHost() {
|
|
634
|
-
return {
|
|
635
|
-
gl: this.handle.gl,
|
|
636
|
-
vpt: this.vpt,
|
|
637
|
-
cssWidth: this.cssWidth,
|
|
638
|
-
cssHeight: this.cssHeight,
|
|
639
|
-
dpr: this.dpr,
|
|
640
|
-
zoom: this.zoom,
|
|
641
|
-
batch: this.batch,
|
|
642
|
-
meshBatch: this.meshBatch,
|
|
643
|
-
batchOrder: this.batchOrder,
|
|
644
|
-
renderer: this.renderer,
|
|
645
|
-
withPageViewport: (viewport, render) => withRenderViewport(this, viewport, render),
|
|
646
|
-
workspaceBackdrop: this.workspaceBackdrop,
|
|
647
|
-
textures: this.textures,
|
|
648
|
-
expandUnderlay: () => {
|
|
649
|
-
const target = this.expandSessionController.active ? this.expandSessionController.target : null;
|
|
650
|
-
return target ? { target, underlay: () => this.expandSessionController.buildUnderlay() } : null;
|
|
651
|
-
},
|
|
652
|
-
finishOverlay: () => finishFrameOverlay(this),
|
|
653
|
-
onPageVisible: (index) => {
|
|
654
|
-
void this.ensurePageBuilt(index);
|
|
655
|
-
}
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
// #endregion
|
|
659
|
-
setViewportTransform(vpt) {
|
|
660
|
-
const prevZoom = this.vpt[0];
|
|
661
|
-
this.vpt = [...vpt];
|
|
662
|
-
// 单页时也同步:用户可先缩放再开启多页,首次布局即用当前 zoom 折算间距。
|
|
663
|
-
this.multiPage.viewportZoom = this.vpt[0];
|
|
664
|
-
// 视口写点统一通知(2026-10-09 扩语义:平移也触发——描边烘焙的吸附目标
|
|
665
|
-
// 随平移跨半像素界翻转同样须避开手势窗口;缩放另连 hit 带换算)
|
|
666
|
-
this.renderer.noteVptChange();
|
|
667
|
-
if (this.vpt[0] !== prevZoom) {
|
|
668
|
-
// 命中带随 zoom 换算(批次 97):同值守卫内零开销,平移不触发
|
|
669
|
-
this.doc.setViewportZoom(this.vpt[0]);
|
|
670
|
-
}
|
|
671
|
-
this.requestRenderAll();
|
|
672
|
-
}
|
|
673
|
-
/** 单页光标锚定、多页画板中心缩放;屏幕恒定间隙与页偏移由布局控制器承载。 */
|
|
674
|
-
zoomAt(cssX, cssY, factor) {
|
|
675
|
-
const next = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, this.vpt[0] * factor));
|
|
676
|
-
const k = next / this.vpt[0];
|
|
677
|
-
const vpt = [next, 0, 0, next, cssX - k * (cssX - this.vpt[4]), cssY - k * (cssY - this.vpt[5])];
|
|
678
|
-
this.vpt = this.multiPage.pageCount > 1 ? this.multiPage.zoomViewportAt(this.vpt, cssX, cssY, next) : vpt;
|
|
679
|
-
this.multiPage.viewportZoom = next;
|
|
680
|
-
this.renderer.noteVptChange();
|
|
681
|
-
this.doc.setViewportZoom(next);
|
|
682
|
-
this.requestRenderAll();
|
|
683
|
-
}
|
|
684
|
-
pan(dx, dy) {
|
|
685
|
-
this.vpt[4] += dx;
|
|
686
|
-
this.vpt[5] += dy;
|
|
687
|
-
this.renderer.noteVptChange();
|
|
688
|
-
this.requestRenderAll();
|
|
689
|
-
}
|
|
690
|
-
/** 覆盖层拖拽会话交互标记(批次 386,蒙版工具栏把手拖图「不跟手」刀一):
|
|
691
|
-
* DOM 层把手拖拽(蒙版中心/旋转/缩放把手族)每个拖拽事件调用——k 档
|
|
692
|
-
* settle 补帧在此期间保持 stale 让路(SceneRenderer.noteExternalInteraction
|
|
693
|
-
* 头注的实测数据与语义)。不写 vpt、不触 hit 带、不请求渲染(调用方属性
|
|
694
|
-
* 写自带);settle 定时器停手 160ms 后自动补一帧收尾 */
|
|
695
|
-
noteExternalGesture() {
|
|
696
|
-
this.renderer.noteExternalInteraction();
|
|
697
|
-
}
|
|
698
|
-
/** rAF 合并渲染请求(fabric requestRenderAll 同语义)+ rAF 饥饿超时兜底。
|
|
699
|
-
* 批次 44:失焦/被遮挡的内嵌浏览器窗格(IAB webview)实测 visibility 仍报
|
|
700
|
-
* 'visible' 但 rAF 永不回调——字体迟到自愈等「排帧后无人再触发」的补帧会
|
|
701
|
-
* 永久挂起,preserveDrawingBuffer 下银幕停在旧帧(用户所见「刷新后字体
|
|
702
|
-
* 不重载」终态)。双通道先到先渲染:正常时 rAF(~16ms)先到并清掉定时器
|
|
703
|
-
* (零额外渲染);饥饿时后台定时器(被钳到 ≥1s)兜底补帧——preserveDrawingBuffer
|
|
704
|
-
* 保证失焦期画的帧在窗格可见时即为所见。 */
|
|
705
|
-
requestRenderAll() {
|
|
706
|
-
// 渐进中收到外部渲染请求:立即收满窗口(下帧全量)——交互正确性优先于
|
|
707
|
-
// 渐进观感(双门槛/宽限窗语义见 render/progressiveLoad)
|
|
708
|
-
this.progressiveLoad.absorbExternalRenderRequest();
|
|
709
|
-
if (this.rafId !== null || this.renderTimerId !== null || this.disposed || this.contextLost)
|
|
710
|
-
return;
|
|
711
|
-
this.rafId = requestAnimationFrame(() => {
|
|
712
|
-
this.rafId = null;
|
|
713
|
-
if (this.renderTimerId !== null) {
|
|
714
|
-
clearTimeout(this.renderTimerId);
|
|
715
|
-
this.renderTimerId = null;
|
|
716
|
-
}
|
|
717
|
-
this.render();
|
|
718
|
-
});
|
|
719
|
-
this.renderTimerId = setTimeout(() => {
|
|
720
|
-
this.renderTimerId = null;
|
|
721
|
-
if (this.rafId !== null) {
|
|
722
|
-
cancelAnimationFrame(this.rafId);
|
|
723
|
-
this.rafId = null;
|
|
724
|
-
}
|
|
725
|
-
this.render();
|
|
726
|
-
}, 250);
|
|
727
|
-
}
|
|
728
|
-
/** 同步渲染一帧(e2e/调试确定性路径) */
|
|
729
|
-
render() {
|
|
730
|
-
if (this.disposed || this.contextLost || !this.batch.valid)
|
|
731
|
-
return;
|
|
732
|
-
// 批次 46:消费上一帧图集 settle 上报的 family(排版/度量/烘焙失效)——
|
|
733
|
-
// 必须在 markFrame 前:settle 触发点在渲染中途,失效只能延到帧外的安全位
|
|
734
|
-
this.fontInvalidation.consumePendingSettle();
|
|
735
|
-
// 帧界推进(P6-2 纹理内存预算):纹理缓存 LRU 帧界保护与图集页回收的结算边界。
|
|
736
|
-
// gestureActive:指针手势期冻结插入压力淘汰(思阳素材病型——保留式帧让活动
|
|
737
|
-
// 大图不 touch,拖动中烘焙插入会逐出大图引发 490MiB 级重传死循环)
|
|
738
|
-
this.textures.markFrame(this.pointerActive);
|
|
739
|
-
this.glyphAtlas.markFrame();
|
|
740
|
-
// 拖拽吸附帧率化结算(P5-2,main renderAll 入口同构):必须在场景渲染前——
|
|
741
|
-
// 结算按「本帧最后一次 pointermove 的位置」计算并磁吸改位,改位计入本帧
|
|
742
|
-
this.snapGuide.settleMoveSnap();
|
|
743
|
-
const frameStart = performance.now();
|
|
744
|
-
this.renderer.beginFrame(frameStart);
|
|
745
|
-
// 对象动画推进(P5-6):覆写写派生层后本帧渲染即消费;播放中置
|
|
746
|
-
// animationActive → 尾部自续排接管(GIF 同款闭环,全静止即停)
|
|
747
|
-
this.tickAnimation(frameStart);
|
|
748
|
-
timeCanvasPerf('engine.render', () => {
|
|
749
|
-
const gl = this.handle.gl;
|
|
750
|
-
gl.viewport(0, 0, this.canvasEl.width, this.canvasEl.height);
|
|
751
|
-
gl.clearColor(...this.background);
|
|
752
|
-
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
753
|
-
// 多页态(批次 407 方案 D):分段帧(render/multiPage——逐页 vpt 换装 +
|
|
754
|
-
// 可见页预筛 + 多洞遮罩 + 活动页覆盖层);单页态保持既有路径逐位不动
|
|
755
|
-
if (this.multiPage.pageCount > 1) {
|
|
756
|
-
renderMultiPageFrame(this.multiPage, this.multiPageFrameHost());
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
const view = sceneToClipMatrix(this.vpt, this.cssWidth, this.cssHeight, this.dpr);
|
|
760
|
-
// 单页工作区矩形(findWorkspaceNode 与多页布局共源;无效 = 空数组——
|
|
761
|
-
// 棋盘格/遮罩同跳过,批次 132「无工作区不画」同语义)
|
|
762
|
-
const ws = findWorkspaceNode(this.doc)?.bounds;
|
|
763
|
-
const singleRects = ws ? [ws] : [];
|
|
764
|
-
// 画板透明指示棋盘格(批次 89):清屏后首笔、全场景最底层——不透明白底
|
|
765
|
-
// 画板节点自然盖住、半透明填充自然混合(「仅透明时可见」零状态跟踪)。
|
|
766
|
-
// 必须先于节点循环(与遮罩的节点后相位相反);SceneExporter 不经此挂点
|
|
767
|
-
this.workspaceBackdrop.drawChecker(this.handle.gl, view, { vpt: this.vpt, cssWidth: this.cssWidth, cssHeight: this.cssHeight, dpr: this.dpr }, singleRects);
|
|
768
|
-
// penScale(GS 描边 SDF uniform 笔宽)= zoom×dpr,与烘焙分辨率 k 同源
|
|
769
|
-
this.batch.begin(view, this.zoom * this.dpr);
|
|
770
|
-
this.meshBatch.begin(view);
|
|
771
|
-
// 批次 221 延迟执行:场景推入期 flush 只记命令(上传/绘制不触 GL)——交错
|
|
772
|
-
// z 序下逐 flush 的 bufferSubData 夹在途 draw 触发驱动同步停顿是多选拖拽
|
|
773
|
-
// 帧数百 ms 的主项;FBO 边界/帧尾(pushOverlayAndContinue)统一执行
|
|
774
|
-
this.batch.deferDraws = true;
|
|
775
|
-
this.meshBatch.deferDraws = true;
|
|
776
|
-
this.batchOrder.reset();
|
|
777
|
-
// B3 扩图垫底在节点相位内部(目标节点绘制序列前段,语义见 render/framePipeline)
|
|
778
|
-
const expandTarget = this.expandSessionController.active ? this.expandSessionController.target : null;
|
|
779
|
-
// 批次 223 重落保留式场景:门链全过则只重推脏节点槽位 + 重放缓照命令表,
|
|
780
|
-
// 干净节点的 GPU 内容跨帧留驻(万级场景节点相位 O(n)→O(dirty));任何
|
|
781
|
-
// 门失败/重推异常回退全量遍历(本帧缓冲被全量重写覆盖,无残留语义)
|
|
782
|
-
if (!expandTarget && this.retainedFrame.tryRetainedFrame()) {
|
|
783
|
-
// 脏集已消化、快照命令已重放——节点相位完成
|
|
784
|
-
}
|
|
785
|
-
else {
|
|
786
|
-
// 回退路径:脏相位可能已写半截缓冲——重新 begin 清零再全量推
|
|
787
|
-
this.batch.begin(view, this.zoom * this.dpr);
|
|
788
|
-
this.meshBatch.begin(view);
|
|
789
|
-
this.batch.deferDraws = true;
|
|
790
|
-
this.meshBatch.deferDraws = true;
|
|
791
|
-
this.batchOrder.reset();
|
|
792
|
-
// 渐进窗口(批次 218):z 前缀渲染——窗口外的节点本帧不画(渐进链逐帧扩窗)
|
|
793
|
-
const renderCount = this.progressiveLoad.limit >= 0 ? Math.min(this.progressiveLoad.limit, this.doc.nodes.length) : this.doc.nodes.length;
|
|
794
|
-
renderSceneNodes(this.batch, this.renderer, this.doc.nodes, expandTarget ? { target: expandTarget, underlay: () => this.expandSessionController.buildUnderlay() } : null, renderCount);
|
|
795
|
-
// 批次 223 重落:walk 已完成(flatFrame 终值已知),置位快照请求后出清——
|
|
796
|
-
// executeDeferred 把命令表/槽位表/总量移置 retained;中途隔离边界的
|
|
797
|
-
// flushAll 不会误收(彼时标志尚 false)
|
|
798
|
-
this.batchOrder.requestSnapshot = true;
|
|
799
|
-
// 帧尾出清经协调器(批次 210 优化②):按待发内容压入序出清(旧者先画)
|
|
800
|
-
this.batchOrder.flushAll();
|
|
801
|
-
this.retainedFrame.captureSnapshot();
|
|
802
|
-
}
|
|
803
|
-
this.doc.drainRenderDirty();
|
|
804
|
-
// 工作区背景遮罩 + 外发光(批次 45):板外灰底(#f3f3f3,fabric
|
|
805
|
-
// _renderWorkspaceMask 引擎等价——越出画板的内容被盖住)+ 贴边发光
|
|
806
|
-
// (gaoding 口径)。画在节点之后、选区/会话覆盖层之前(fabric
|
|
807
|
-
// _renderAllWithWorkspaceOverlay 同相位)。仅交互渲染路径——SceneExporter
|
|
808
|
-
// 导出链不经此挂点,快照/缩略图/导出无遮罩无发光;不写 raw 零序列化
|
|
809
|
-
this.workspaceBackdrop.drawBackdrop(this.handle.gl, view, { vpt: this.vpt, cssWidth: this.cssWidth, cssHeight: this.cssHeight, dpr: this.dpr }, singleRects);
|
|
810
|
-
// 会话/覆盖层收尾相位(批次 224 拆出 render/framePipeline:四编辑会话
|
|
811
|
-
// 覆盖层取代选区 UI / 常规 frameOverlay 拼装 + 帧尾统一出清)
|
|
812
|
-
finishFrameOverlay(this);
|
|
813
|
-
});
|
|
814
|
-
// 批次 223 重落:帧尾记录动画/烘焙续帧态(下一帧保留式门链消费)
|
|
815
|
-
this.retainedFrame.noteFrameRendered();
|
|
816
|
-
// 分帧摊销续帧:本帧 PSD 烘焙预算耗尽仍有 stale 节点 → 下一帧继续补齐
|
|
817
|
-
if (this.renderer.frame.bakeMore)
|
|
818
|
-
this.requestRenderAll();
|
|
819
|
-
this.bus.fire('engine:render', performance.now() - frameStart);
|
|
820
|
-
}
|
|
821
|
-
/** 读取画布像素(RGBA)。经 2D canvas 中转,语义与 e2e 的 fabric 读回一致 */
|
|
822
|
-
readPixels() {
|
|
823
|
-
return readCanvasPixels(this.canvasEl);
|
|
824
|
-
}
|
|
825
|
-
// #region GL 原生位图导出(P6-1):SceneExporter 委托 + SceneExportHost 装配
|
|
826
|
-
/** FBO 离屏渲染当前场景 → 直 alpha 像素(编排/口径见 export/SceneExporter.ts) */
|
|
827
|
-
exportToPixels(region) {
|
|
828
|
-
// 批次 223 重落:导出复用主批缓冲(SceneExporter host.batch.begin 覆写
|
|
829
|
-
// 内容)——保留式快照的 GPU 基线失效,下一帧强制全量重建
|
|
830
|
-
this.retainedFrame.invalidate();
|
|
831
|
-
return this.exporter.exportToPixels(region);
|
|
832
|
-
}
|
|
833
|
-
/** exportToPixels 的异步回读变体(预览/缩略高频路径):PBO 暂存 + fence 排水,
|
|
834
|
-
* GL 同步回读的 GPU 进程往返停顿不占交互期主线程帧;真导出(用户主动导出)
|
|
835
|
-
* 仍走同步版。编排/口径见 export/SceneExporter.ts */
|
|
836
|
-
async exportToPixelsAsync(region) {
|
|
837
|
-
// 批次 223 同款:导出复用主批缓冲——保留式快照 GPU 基线失效,下一帧强制全量重建
|
|
838
|
-
this.retainedFrame.invalidate();
|
|
839
|
-
return this.exporter.exportToPixelsAsync(region);
|
|
840
|
-
}
|
|
841
|
-
/** exportToPixelsAsync 的原始字节变体(批次 324 一补):跳过行翻转+反预乘的
|
|
842
|
-
* 主线程转换(1080 级输出 6-13ms),返回预乘/左下原点原始字节——调用方在
|
|
843
|
-
* worker 侧完成转换(预览捕获链主线程零转换成本) */
|
|
844
|
-
async exportRawPixelsAsync(region) {
|
|
845
|
-
this.retainedFrame.invalidate();
|
|
846
|
-
return this.exporter.exportRawPixelsAsync(region);
|
|
847
|
-
}
|
|
848
|
-
/** FBO 导出 → 2D canvas(putImageData 直 alpha;供 toDataURL/编码/绘制复用) */
|
|
849
|
-
exportToCanvas(region) {
|
|
850
|
-
this.retainedFrame.invalidate();
|
|
851
|
-
return this.exporter.exportToCanvas(region);
|
|
852
|
-
}
|
|
853
|
-
/** FBO 导出 → dataURL(fabric toDataURL 同形返回;mime 缺省 png) */
|
|
854
|
-
exportToDataURL(region, mime = 'image/png', quality) {
|
|
855
|
-
this.retainedFrame.invalidate();
|
|
856
|
-
return this.exporter.exportToDataURL(region, mime, quality);
|
|
857
|
-
}
|
|
858
|
-
/** SceneExportHost:导出可用(未 dispose/未上下文丢失/批渲染器有效) */
|
|
859
|
-
get exportReady() {
|
|
860
|
-
return !this.disposed && !this.contextLost && this.batch.valid;
|
|
861
|
-
}
|
|
862
|
-
/** SceneExportHost:当前场景顶层节点 */
|
|
863
|
-
get sceneNodes() {
|
|
864
|
-
return this.doc.nodes;
|
|
865
|
-
}
|
|
866
|
-
/** SceneExportHost:导出视口态临时切换(vpt——烘焙分桶/滤镜签名来源;canvasEl
|
|
867
|
-
* 尺寸——组隔离 FBO 尺寸来源)。返回还原函数;还原后由导出器补帧 */
|
|
868
|
-
applyExportViewport(vpt, pixelWidth, pixelHeight) {
|
|
869
|
-
const savedVpt = this.vpt;
|
|
870
|
-
const savedStandIn = this.exportStandInEl;
|
|
871
|
-
this.vpt = [...vpt];
|
|
872
|
-
// 尺寸语义与旧改写路径逐值等价:隔离 FBO / 混合 FBO / 蒙版 UV 链读的都是
|
|
873
|
-
// host.canvasEl 的 width/height(导出像素口径),替身与真画布同尺寸切换零差异;
|
|
874
|
-
// 差别只在真画布后备缓冲不再被清——导出后屏内容原样(requestRenderAll 仍补帧
|
|
875
|
-
// 刷新 vpt 换档后的烘焙缓存)
|
|
876
|
-
const standIn = document.createElement('canvas');
|
|
877
|
-
standIn.width = pixelWidth;
|
|
878
|
-
standIn.height = pixelHeight;
|
|
879
|
-
this.exportStandInEl = standIn;
|
|
880
|
-
return () => {
|
|
881
|
-
this.vpt = savedVpt;
|
|
882
|
-
this.exportStandInEl = savedStandIn;
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
|
-
// #endregion
|
|
886
|
-
/** e2e 性能路径:同步渲染 n 帧取平均耗时(实现体在 debug/canvasInspection) */
|
|
887
|
-
measureFrames(count) {
|
|
888
|
-
return measureCanvasFrames(count, () => this.render());
|
|
889
|
-
}
|
|
890
|
-
/** e2e/debug:场景摘要(变换 + 几何,不含位图引用;实现在 debug/canvasInspection) */
|
|
891
|
-
getSceneSummary() {
|
|
892
|
-
return getSceneNodeSummary(this.doc);
|
|
893
|
-
}
|
|
894
|
-
/** e2e/debug:单元格编辑会话摘要(P4-4b(2/2);null = 无会话) */
|
|
895
|
-
getTableCellEditingInfo() {
|
|
896
|
-
return this.tableCellEditing.info;
|
|
897
|
-
}
|
|
898
|
-
/** e2e/debug:单选表格的单元格选区摘要(行/列条选中断言用;null = 非单选表格) */
|
|
899
|
-
getTableSelectionInfo() {
|
|
900
|
-
const sel = this.doc.selection.length === 1 && this.doc.selection[0] instanceof TableNode ? this.doc.selection[0] : null;
|
|
901
|
-
if (!sel)
|
|
902
|
-
return null;
|
|
903
|
-
return {
|
|
904
|
-
tableId: sel.id,
|
|
905
|
-
cells: sel.selectedCells.map((c) => ({ row: c.row, col: c.col })),
|
|
906
|
-
anchor: sel.cellAnchor ? { ...sel.cellAnchor } : null,
|
|
907
|
-
range: sel.cellRange ? { ...sel.cellRange } : null
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
/** e2e/debug:吸附状态摘要(P5-2;登记/最近偏移/线计数/候选数) */
|
|
911
|
-
getSnapGuideInfo() {
|
|
912
|
-
return this.snapGuide.info;
|
|
913
|
-
}
|
|
914
|
-
/** e2e/debug:裁剪会话摘要(B2;null = 无会话) */
|
|
915
|
-
/** B3 扩图会话:进入(单选静态图片/蒙版);node 缺省取选区首位——compat 右栏
|
|
916
|
-
* 面板链以目标对象显式进入(enterPathEditMode 同先例),不依赖选中态时序 */
|
|
917
|
-
enterExpandMode(node) {
|
|
918
|
-
if (this.cropSessionController.active)
|
|
919
|
-
this.cropSessionController.exit();
|
|
920
|
-
if (this.pathSessionController.active)
|
|
921
|
-
this.pathSessionController.exit();
|
|
922
|
-
const target = node ?? this.doc.selection[0];
|
|
923
|
-
return target ? this.expandSessionController.enter(target) : false;
|
|
924
|
-
}
|
|
925
|
-
exitExpandMode() {
|
|
926
|
-
this.expandSessionController.exit();
|
|
927
|
-
}
|
|
928
|
-
getExpandInfo() {
|
|
929
|
-
return this.expandSessionController.info;
|
|
930
|
-
}
|
|
931
|
-
/**
|
|
932
|
-
* B3 扩图结果应用(AI outpaint 返回图落地,域逻辑在 ExpandSessionController.
|
|
933
|
-
* applyResult——框中心口径/expand 字段保留/object:modified 同口径的语义见彼处)
|
|
934
|
-
*/
|
|
935
|
-
async applyExpandResult(nodeId, src, frame) {
|
|
936
|
-
const node = this.findNodeById(nodeId);
|
|
937
|
-
if (!node || (!node.isImageType && !(node instanceof MaskNode)))
|
|
938
|
-
return false;
|
|
939
|
-
return this.expandSessionController.applyResult(node, src, frame);
|
|
940
|
-
}
|
|
941
|
-
/** ExpandSessionHost:节点直收位图重载(SourceManager 面——reloadNodeImage 的节点实例版) */
|
|
942
|
-
reloadImageElement(node) {
|
|
943
|
-
return this.sources.reloadNodeImage(node);
|
|
944
|
-
}
|
|
945
|
-
/** 节点查找(含组内递归;id 唯一) */
|
|
946
|
-
findNodeById(id) {
|
|
947
|
-
return this.doc.findNodeDeep(id)?.node ?? null;
|
|
948
|
-
}
|
|
949
|
-
/**
|
|
950
|
-
* 运行时按 raw.src 重载位图源(P5-4 片③ 换图/滤镜族回放消费):历史回放
|
|
951
|
-
* 写回 src 后调用——引擎 setProps({src}) 只改 raw 不重载 imageEl(SourceManager
|
|
952
|
-
* 装载链只在 loadObjects/applyExpandResult)。宽高/缩放几何由调用方随快照
|
|
953
|
-
* 写回(回放条目全量序列化已含),本方法只负责元素与纹理重挂。失败 false。
|
|
954
|
-
*/
|
|
955
|
-
async reloadNodeImage(nodeId) {
|
|
956
|
-
const node = this.findNodeById(nodeId);
|
|
957
|
-
if (!node)
|
|
958
|
-
return false;
|
|
959
|
-
const el = await this.sources.reloadNodeImage(node);
|
|
960
|
-
return !!el;
|
|
961
|
-
}
|
|
962
|
-
/**
|
|
963
|
-
* 运行时按 raw.clipImage 重载蒙版填充图(批次 72——compat guide 拖图入
|
|
964
|
-
* 蒙版/拼图格):set({clipImage}) 换 src 后 clipImageEl 不重载则烘焙仍合成
|
|
965
|
-
* 旧图(SourceManager 装载链只在建库期)。几何/缩放由调用方写回;本方法
|
|
966
|
-
* 只负责元素与纹理重挂(reloadNodeImage 同语义的 clipImage 位)。失败 false
|
|
967
|
-
* (非蒙版/无声明/动态源/加载失败)。
|
|
968
|
-
*/
|
|
969
|
-
async reloadMaskClipImage(nodeId) {
|
|
970
|
-
const node = this.findNodeById(nodeId);
|
|
971
|
-
if (!(node instanceof MaskNode))
|
|
972
|
-
return false;
|
|
973
|
-
const el = await this.sources.reloadMaskClipImage(node);
|
|
974
|
-
return !!el;
|
|
975
|
-
}
|
|
976
|
-
getCropInfo() {
|
|
977
|
-
return this.cropSessionController.info;
|
|
978
|
-
}
|
|
979
|
-
/** 进入裁剪会话(dev 页/调试 API):单选静态图片或蒙版(B3 余量——蒙版
|
|
980
|
-
* 走 clipImage 双轨,见 cropSession.enter 的 Mask 分支);node 缺省取选区
|
|
981
|
-
* 首位(compat 右栏 ImageClip 面板链以目标对象显式进入);失败返回 false */
|
|
982
|
-
enterCropMode(node) {
|
|
983
|
-
if (this.pathSessionController.active)
|
|
984
|
-
this.pathSessionController.exit();
|
|
985
|
-
const target = node ?? this.doc.selection[0];
|
|
986
|
-
return target ? this.cropSessionController.enter(target) : false;
|
|
987
|
-
}
|
|
988
|
-
/** 退出裁剪会话(保留裁剪 + 一条 object:modified) */
|
|
989
|
-
exitCropMode() {
|
|
990
|
-
this.cropSessionController.exit();
|
|
991
|
-
}
|
|
992
|
-
/** 设置裁剪比例约束(null = 自由;正值 = height/width,应用 presetImageClip 口径) */
|
|
993
|
-
setCropAspectRatio(ratio) {
|
|
994
|
-
this.cropSessionController.setAspectRatio(ratio);
|
|
995
|
-
}
|
|
996
|
-
/** 进入路径族锚点编辑(P4-7;dev 页/compat changeControls 消费):
|
|
997
|
-
* 缺省取选区首个;与裁剪/扩图会话互斥(进入时先退) */
|
|
998
|
-
enterPathEditMode(node) {
|
|
999
|
-
if (this.cropSessionController.active)
|
|
1000
|
-
this.cropSessionController.exit();
|
|
1001
|
-
if (this.expandSessionController.active)
|
|
1002
|
-
this.expandSessionController.exit();
|
|
1003
|
-
const target = node ?? this.doc.selection[0];
|
|
1004
|
-
return target ? this.pathSessionController.enter(target) : false;
|
|
1005
|
-
}
|
|
1006
|
-
/** 进入图片扭曲会话(批次 66;compat 门面消费):单选静态位图;与裁剪/
|
|
1007
|
-
* 扩图/路径会话互斥(进入时先退)。失败(imageEl 未挂/裁剪图/动画族)false。
|
|
1008
|
-
* 重编辑链异步装载 warpOriginalSrc 原图(六补记) */
|
|
1009
|
-
async enterWarpMode(node, opts) {
|
|
1010
|
-
if (this.cropSessionController.active)
|
|
1011
|
-
this.cropSessionController.exit();
|
|
1012
|
-
if (this.expandSessionController.active)
|
|
1013
|
-
this.expandSessionController.exit();
|
|
1014
|
-
if (this.pathSessionController.active)
|
|
1015
|
-
this.pathSessionController.exit();
|
|
1016
|
-
const target = node ?? this.doc.selection[0];
|
|
1017
|
-
return target ? this.warpSessionController.enter(target, opts) : false;
|
|
1018
|
-
}
|
|
1019
|
-
/** WarpSessionHost.loadImage:重编辑链的原图装载(失败 null 降级全新会话) */
|
|
1020
|
-
async loadImage(src, crossOrigin) {
|
|
1021
|
-
try {
|
|
1022
|
-
return await loadImageElement(src, crossOrigin ?? null);
|
|
1023
|
-
}
|
|
1024
|
-
catch {
|
|
1025
|
-
return null;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
/** 退出扭曲会话:commit=true 烘焙替换(raw.src/几何/warpvasState 落盘 +
|
|
1029
|
-
* 纹理重载),false 取消(会话期 raw 零写入)。退出载荷归门面提交项目历史 */
|
|
1030
|
-
async exitWarpMode(commit) {
|
|
1031
|
-
return this.warpSessionController.exit(commit);
|
|
1032
|
-
}
|
|
1033
|
-
/** 会话内扭曲历史(应用 Ctrl+Z/Y 在 isWarpvas 态的路由终点) */
|
|
1034
|
-
warpUndo() {
|
|
1035
|
-
return this.warpSessionController.undo();
|
|
1036
|
-
}
|
|
1037
|
-
warpRedo() {
|
|
1038
|
-
return this.warpSessionController.redo();
|
|
1039
|
-
}
|
|
1040
|
-
/** 退出路径族锚点编辑(不发 object:modified——差量提交已在各操作点) */
|
|
1041
|
-
exitPathEditMode() {
|
|
1042
|
-
this.pathSessionController.exit();
|
|
1043
|
-
}
|
|
1044
|
-
/** e2e/debug:路径编辑会话摘要(锚点场景位/选中锚点/插点候选;null = 无会话) */
|
|
1045
|
-
getPathEditInfo() {
|
|
1046
|
-
return this.pathSessionController.info;
|
|
1047
|
-
}
|
|
1048
|
-
/** compat 面板 API(P4-7):L↔C 锚点类型切换(会话目标须为该节点) */
|
|
1049
|
-
setPathAnchorType(node, index, type) {
|
|
1050
|
-
return this.pathSessionController.target === node ? this.pathSessionController.setAnchorType(index, type) : false;
|
|
1051
|
-
}
|
|
1052
|
-
/** compat 面板 API(P4-7):选中锚点高亮(fabricCanvas 鼠标链同位) */
|
|
1053
|
-
highlightPathAnchor(node, key) {
|
|
1054
|
-
if (this.pathSessionController.target === node)
|
|
1055
|
-
this.pathSessionController.setActiveAnchor(key);
|
|
1056
|
-
}
|
|
1057
|
-
/** compat 退出链 API(P4-7):清锚点高亮(不发事件) */
|
|
1058
|
-
resetPathAnchorStyles(node) {
|
|
1059
|
-
if (this.pathSessionController.target === node)
|
|
1060
|
-
this.pathSessionController.resetAnchorStyles();
|
|
1061
|
-
}
|
|
1062
|
-
// #region P5-3 标尺开关 + 快捷键编排(useCanvasHotkey 画布操作子集 → 引擎 API;
|
|
1063
|
-
// 编排层组合 document 现有原语 setSelection/remove/setProps——文档层零改动)
|
|
1064
|
-
get rulerEnabled() {
|
|
1065
|
-
return this.rulerVisible;
|
|
1066
|
-
}
|
|
1067
|
-
/** pointer 宿主面(批次 72):标尺带拖出参考线的带命中前置位 */
|
|
1068
|
-
get rulerVisible() {
|
|
1069
|
-
return this.rulerVisibleValue;
|
|
1070
|
-
}
|
|
1071
|
-
/** 参考线拖拽态(批次 72):pointer 手势期写入线位(场景坐标),标尺 overlay
|
|
1072
|
-
* 据此画数值气泡;up/取消由 pointer 置回 null */
|
|
1073
|
-
referenceLineDrag = null;
|
|
1074
|
-
/** 旋转手势覆盖态:pointer 手势起始写入(mtr 锚定规格 + 角度气泡中心),选区
|
|
1075
|
-
* overlay 每帧把规格经当前框姿态变换(fabric __rotateControlPosition 快照 +
|
|
1076
|
-
* renderRotateControl 旋转中气泡同构——柄贴框随转不换边);up 由 pointer
|
|
1077
|
-
* 置回 null。spec=null=四角隐形旋转区起转(批次 88)不锚定 mtr——fabric
|
|
1078
|
-
* __rotateControlPosition 只由 mtr actionHandler 写,气泡照常 */
|
|
1079
|
-
rotateDrag = null;
|
|
1080
|
-
setRulerVisible(visible) {
|
|
1081
|
-
if (this.rulerVisibleValue === visible)
|
|
1082
|
-
return;
|
|
1083
|
-
this.rulerVisibleValue = visible;
|
|
1084
|
-
this.requestRenderAll();
|
|
1085
|
-
}
|
|
1086
|
-
/** Ctrl+A / Delete / 方向键微移——编排实现体在 interact/hotkeyActions
|
|
1087
|
-
* (批次 224 拆出;口径注释随实现体迁移) */
|
|
1088
|
-
selectAll() {
|
|
1089
|
-
return selectAllAction(this.doc, () => this.requestRenderAll());
|
|
1090
|
-
}
|
|
1091
|
-
deleteSelection() {
|
|
1092
|
-
return deleteSelectionAction(this.doc, () => this.requestRenderAll());
|
|
1093
|
-
}
|
|
1094
|
-
nudgeSelection(dx, dy) {
|
|
1095
|
-
return nudgeSelectionAction(this.doc, dx, dy, () => this.requestRenderAll());
|
|
1096
|
-
}
|
|
1097
|
-
// #endregion
|
|
1098
|
-
/** e2e/debug:选区摘要(id + 手柄屏幕坐标)——实现体在 debug/canvasInspection
|
|
1099
|
-
* (批次 224 拆出;蒙版会话手柄序等口径注释随实现体迁移) */
|
|
1100
|
-
getSelectionInfo() {
|
|
1101
|
-
return getSelectionInfo(this.doc, this.marquee, this.zoom, (x, y) => this.toScreen(x, y));
|
|
1102
|
-
}
|
|
1103
|
-
/** P5-1 组交互片 e2e 断言面:组内激活子元素(点选下钻;null = 无)。
|
|
1104
|
-
* selection/变换框仍以顶组为主体(应用 topGroup 语义),本 API 只报激活子 */
|
|
1105
|
-
getActiveGroupChildInfo() {
|
|
1106
|
-
return getActiveGroupChildInfo(this.doc);
|
|
1107
|
-
}
|
|
1108
|
-
/** e2e/debug:SVG 源重光栅化记账(批次 39)——实现体在 debug/canvasInspection */
|
|
1109
|
-
getSvgRasterInfo() {
|
|
1110
|
-
return getSvgRasterInfo(this.doc, (node) => this.sources.svgRasterFactorOf(node));
|
|
1111
|
-
}
|
|
1112
|
-
/** 序列化往返:当前场景(含交互后的变换)→ fabric JSON */
|
|
1113
|
-
toObjects() {
|
|
1114
|
-
return this.doc.toObjects();
|
|
1115
|
-
}
|
|
1116
|
-
// #region 对象动画播放(P5-6——批次 11 编排拆出 interact/animationPlayback,本类留薄委托)
|
|
1117
|
-
playAnimations() {
|
|
1118
|
-
this.animationPlaybackController.play();
|
|
1119
|
-
}
|
|
1120
|
-
pauseAnimations() {
|
|
1121
|
-
this.animationPlaybackController.pause();
|
|
1122
|
-
}
|
|
1123
|
-
stopAnimations() {
|
|
1124
|
-
this.animationPlaybackController.stop();
|
|
1125
|
-
}
|
|
1126
|
-
seekAnimations(time) {
|
|
1127
|
-
this.animationPlaybackController.seek(time);
|
|
1128
|
-
}
|
|
1129
|
-
getAnimationPlaybackInfo() {
|
|
1130
|
-
return this.animationPlaybackController.info;
|
|
1131
|
-
}
|
|
1132
|
-
getScrollTextPlaybackInfo() {
|
|
1133
|
-
return this.animationPlaybackController.scrollTextInfo;
|
|
1134
|
-
}
|
|
1135
|
-
// #region 单动画预览(P5-6 余项:动画面板 canvas.animater.play 的引擎编排——薄委托)
|
|
1136
|
-
playSingleAnimation(node, animate, onComplete) {
|
|
1137
|
-
return this.animationPlaybackController.playSingleAnimation(node, animate, onComplete);
|
|
1138
|
-
}
|
|
1139
|
-
stopSingleAnimation(node) {
|
|
1140
|
-
this.animationPlaybackController.stopSingleAnimation(node);
|
|
1141
|
-
}
|
|
1142
|
-
getSingleAnimationPreviewInfo() {
|
|
1143
|
-
return this.animationPlaybackController.singlePreviewInfo;
|
|
1144
|
-
}
|
|
1145
|
-
/** 渲染头部推进(render() 调用):求值写派生层 + 播放中置自续排标记
|
|
1146
|
-
* (renderer.frame 是画布私有态,控制器以返回值交接) */
|
|
1147
|
-
tickAnimation(now) {
|
|
1148
|
-
if (this.animationPlaybackController.tick(now))
|
|
1149
|
-
this.renderer.frame.animationActive = true;
|
|
1150
|
-
}
|
|
1151
|
-
/** PointerHost:编辑态光标/选区设置,委托 TextEditingController(含 textarea 同步) */
|
|
1152
|
-
setEditingSelection(start, end) {
|
|
1153
|
-
this.textEditing.setSelection(start, end);
|
|
1154
|
-
}
|
|
1155
|
-
// PointerHost P5-2 吸附钩子(up 结算/手势收尾/缩放辅助线,委托 SnapGuideController)
|
|
1156
|
-
settleMoveSnap() {
|
|
1157
|
-
this.snapGuide.settleMoveSnap();
|
|
1158
|
-
}
|
|
1159
|
-
finishSnapGesture() {
|
|
1160
|
-
this.snapGuide.finishGesture();
|
|
1161
|
-
}
|
|
1162
|
-
registerScalingSnap(node, handle) {
|
|
1163
|
-
this.snapGuide.registerScaling(node, handle);
|
|
1164
|
-
}
|
|
1165
|
-
/** TableInteractionHost:Enter/typover 进入单元格编辑(P4-4b(2/2)) */
|
|
1166
|
-
startCellEditing(table, row, col, opts) {
|
|
1167
|
-
return this.tableCellEditing.startEditing(table, row, col, opts);
|
|
1168
|
-
}
|
|
1169
|
-
/** DblClickHost:双击点进入文本编辑(P5-7 拆出,语义在 TextEditingController) */
|
|
1170
|
-
enterTextEditingAtClick(node, x, y) {
|
|
1171
|
-
this.textEditing.enterEditingAtClick(node, x, y);
|
|
1172
|
-
}
|
|
1173
|
-
// #endregion
|
|
1174
|
-
dispose() {
|
|
1175
|
-
if (this.disposed)
|
|
1176
|
-
return;
|
|
1177
|
-
this.disposed = true;
|
|
1178
|
-
if (this.cellSelectionSink && TableNode.cellSelectionSink === this.cellSelectionSink)
|
|
1179
|
-
TableNode.cellSelectionSink = null;
|
|
1180
|
-
if (this.rafId !== null)
|
|
1181
|
-
cancelAnimationFrame(this.rafId);
|
|
1182
|
-
if (this.renderTimerId !== null)
|
|
1183
|
-
clearTimeout(this.renderTimerId);
|
|
1184
|
-
this.retainedFrame.dispose();
|
|
1185
|
-
this.progressiveLoad.dispose();
|
|
1186
|
-
this.interactions.dispose();
|
|
1187
|
-
this.tableCellEditing.dispose();
|
|
1188
|
-
this.cropSessionController.dispose();
|
|
1189
|
-
this.expandSessionController.dispose();
|
|
1190
|
-
this.pathSessionController.dispose();
|
|
1191
|
-
this.textEditing.dispose();
|
|
1192
|
-
this.bus.clear();
|
|
1193
|
-
this.sources.releaseAnimatedSources();
|
|
1194
|
-
this.batch.dispose();
|
|
1195
|
-
this.meshBatch.dispose();
|
|
1196
|
-
this.textures.dispose();
|
|
1197
|
-
this.gradientRamps.dispose();
|
|
1198
|
-
this.sources.dispose();
|
|
1199
|
-
this.glyphAtlas.dispose();
|
|
1200
|
-
this.handle.dispose();
|
|
1201
|
-
}
|
|
1202
|
-
}
|