@visactor/vrender-core 0.18.3 → 0.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/allocator/allocator-modules.js +2 -0
- package/cjs/animate/config.js +2 -1
- package/cjs/canvas/empty-context.d.ts +4 -1
- package/cjs/canvas/empty-context.js +5 -1
- package/cjs/canvas/empty-context.js.map +1 -1
- package/cjs/core/contributions/layerHandler/offscreen2d-contribution.js +4 -4
- package/cjs/core/contributions/layerHandler/offscreen2d-contribution.js.map +1 -1
- package/cjs/core/contributions/window/base-contribution.d.ts +8 -2
- package/cjs/core/contributions/window/base-contribution.js +15 -2
- package/cjs/core/contributions/window/base-contribution.js.map +1 -1
- package/cjs/core/graphic-utils.js +10 -6
- package/cjs/core/graphic-utils.js.map +1 -1
- package/cjs/core/layer.d.ts +0 -1
- package/cjs/core/layer.js +5 -23
- package/cjs/core/layer.js.map +1 -1
- package/cjs/core/stage.d.ts +5 -11
- package/cjs/core/stage.js +57 -66
- package/cjs/core/stage.js.map +1 -1
- package/cjs/core/window.d.ts +9 -2
- package/cjs/core/window.js +42 -5
- package/cjs/core/window.js.map +1 -1
- package/cjs/event/event-manager.js +5 -3
- package/cjs/event/event-manager.js.map +1 -1
- package/cjs/event/event-system.d.ts +3 -2
- package/cjs/event/event-system.js +12 -8
- package/cjs/event/event-system.js.map +1 -1
- package/cjs/interface/context.d.ts +1 -0
- package/cjs/interface/context.js.map +1 -1
- package/cjs/interface/event.d.ts +3 -9
- package/cjs/interface/event.js.map +1 -1
- package/cjs/interface/layer.d.ts +5 -10
- package/cjs/interface/layer.js.map +1 -1
- package/cjs/interface/picker.d.ts +0 -1
- package/cjs/interface/picker.js.map +1 -1
- package/cjs/interface/render.d.ts +2 -5
- package/cjs/interface/render.js.map +1 -1
- package/cjs/interface/stage.d.ts +2 -1
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/interface/window.d.ts +14 -3
- package/cjs/interface/window.js.map +1 -1
- package/cjs/picker/picker-service.js +6 -14
- package/cjs/picker/picker-service.js.map +1 -1
- package/cjs/plugins/builtin-plugin/incremental-auto-render-plugin.js +2 -4
- package/cjs/plugins/builtin-plugin/incremental-auto-render-plugin.js.map +1 -1
- package/cjs/render/contributions/render/draw-contribution.js +17 -23
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/incremental-draw-contribution.js +11 -19
- package/cjs/render/contributions/render/incremental-draw-contribution.js.map +1 -1
- package/es/allocator/allocator-modules.js +2 -0
- package/es/animate/config.js +2 -1
- package/es/canvas/empty-context.d.ts +4 -1
- package/es/canvas/empty-context.js +4 -1
- package/es/canvas/empty-context.js.map +1 -1
- package/es/core/contributions/layerHandler/offscreen2d-contribution.js +4 -4
- package/es/core/contributions/layerHandler/offscreen2d-contribution.js.map +1 -1
- package/es/core/contributions/window/base-contribution.d.ts +8 -2
- package/es/core/contributions/window/base-contribution.js +15 -1
- package/es/core/contributions/window/base-contribution.js.map +1 -1
- package/es/core/graphic-utils.js +10 -6
- package/es/core/graphic-utils.js.map +1 -1
- package/es/core/layer.d.ts +0 -1
- package/es/core/layer.js +5 -23
- package/es/core/layer.js.map +1 -1
- package/es/core/stage.d.ts +5 -11
- package/es/core/stage.js +58 -67
- package/es/core/stage.js.map +1 -1
- package/es/core/window.d.ts +9 -2
- package/es/core/window.js +42 -5
- package/es/core/window.js.map +1 -1
- package/es/event/event-manager.js +5 -3
- package/es/event/event-manager.js.map +1 -1
- package/es/event/event-system.d.ts +3 -2
- package/es/event/event-system.js +13 -9
- package/es/event/event-system.js.map +1 -1
- package/es/interface/context.d.ts +1 -0
- package/es/interface/context.js.map +1 -1
- package/es/interface/event.d.ts +3 -9
- package/es/interface/event.js.map +1 -1
- package/es/interface/layer.d.ts +5 -10
- package/es/interface/layer.js.map +1 -1
- package/es/interface/picker.d.ts +0 -1
- package/es/interface/picker.js.map +1 -1
- package/es/interface/render.d.ts +2 -5
- package/es/interface/render.js.map +1 -1
- package/es/interface/stage.d.ts +2 -1
- package/es/interface/stage.js.map +1 -1
- package/es/interface/window.d.ts +14 -3
- package/es/interface/window.js.map +1 -1
- package/es/picker/picker-service.js +7 -15
- package/es/picker/picker-service.js.map +1 -1
- package/es/plugins/builtin-plugin/incremental-auto-render-plugin.js +2 -4
- package/es/plugins/builtin-plugin/incremental-auto-render-plugin.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.js +17 -23
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/incremental-draw-contribution.js +11 -19
- package/es/render/contributions/render/incremental-draw-contribution.js.map +1 -1
- package/package.json +1 -1
|
@@ -56,15 +56,9 @@ let DefaultDrawContribution = class {
|
|
|
56
56
|
this.prepareForDraw(renderService, drawContext), drawContext.drawContribution = this,
|
|
57
57
|
this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap,
|
|
58
58
|
this.currentRenderService = renderService;
|
|
59
|
-
const {context: context, stage: stage,
|
|
59
|
+
const {context: context, stage: stage, viewBox: viewBox, transMatrix: transMatrix} = drawContext;
|
|
60
60
|
if (!context) return;
|
|
61
|
-
|
|
62
|
-
if (context.nativeContext && context.nativeContext.getTransform) {
|
|
63
|
-
const t = context.nativeContext.getTransform();
|
|
64
|
-
context.setTransformFromMatrix(t, !0, 1);
|
|
65
|
-
}
|
|
66
|
-
} else context.inuse = !0, context.clearMatrix(), context.setTransformForCurrent(!0);
|
|
67
|
-
const dirtyBounds = this.dirtyBounds.setValue(0, 0, width, height);
|
|
61
|
+
const dirtyBounds = this.dirtyBounds.setValue(0, 0, viewBox.width(), viewBox.height());
|
|
68
62
|
if (stage.dirtyBounds && !stage.dirtyBounds.empty()) {
|
|
69
63
|
const b = getRectIntersect(dirtyBounds, stage.dirtyBounds, !1);
|
|
70
64
|
dirtyBounds.x1 = Math.floor(b.x1), dirtyBounds.y1 = Math.floor(b.y1), dirtyBounds.x2 = Math.ceil(b.x2),
|
|
@@ -73,18 +67,19 @@ let DefaultDrawContribution = class {
|
|
|
73
67
|
const d = context.dpr % 1;
|
|
74
68
|
(d || .5 !== d) && (dirtyBounds.x1 = Math.floor(dirtyBounds.x1 * context.dpr) / context.dpr,
|
|
75
69
|
dirtyBounds.y1 = Math.floor(dirtyBounds.y1 * context.dpr) / context.dpr, dirtyBounds.x2 = Math.ceil(dirtyBounds.x2 * context.dpr) / context.dpr,
|
|
76
|
-
dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr), this.backupDirtyBounds.copy(dirtyBounds)
|
|
77
|
-
|
|
78
|
-
context.
|
|
79
|
-
context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height()),
|
|
80
|
-
context.clip()
|
|
70
|
+
dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr), this.backupDirtyBounds.copy(dirtyBounds),
|
|
71
|
+
context.inuse = !0, context.setClearMatrix(transMatrix.a, transMatrix.b, transMatrix.c, transMatrix.d, transMatrix.e, transMatrix.f),
|
|
72
|
+
context.clearMatrix(), context.setTransformForCurrent(!0), context.translate(viewBox.x1, viewBox.y1, !0),
|
|
73
|
+
context.beginPath(), context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height()),
|
|
74
|
+
context.clip(), stage.camera && (this.dirtyBounds.setValue(-1 / 0, -1 / 0, 1 / 0, 1 / 0),
|
|
81
75
|
this.backupDirtyBounds.setValue(-1 / 0, -1 / 0, 1 / 0, 1 / 0)), this.clearScreen(renderService, context, drawContext),
|
|
82
76
|
context.save(), renderService.renderTreeRoots.sort(((a, b) => {
|
|
83
77
|
var _a, _b;
|
|
84
78
|
return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
|
|
85
79
|
})).forEach((group => {
|
|
86
80
|
group.isContainer ? this.renderGroup(group, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0)) : this.renderItem(group, drawContext);
|
|
87
|
-
})), context.restore(), context.
|
|
81
|
+
})), context.restore(), context.draw(), context.setClearMatrix(1, 0, 0, 1, 0, 0),
|
|
82
|
+
context.inuse = !1;
|
|
88
83
|
}
|
|
89
84
|
doRegister() {
|
|
90
85
|
throw new Error("暂不支持");
|
|
@@ -201,23 +196,22 @@ let DefaultDrawContribution = class {
|
|
|
201
196
|
}
|
|
202
197
|
clearScreen(renderService, context, drawContext) {
|
|
203
198
|
var _a, _b;
|
|
204
|
-
const {clear: clear} = drawContext;
|
|
199
|
+
const {clear: clear, viewBox: viewBox} = drawContext, width = viewBox.width(), height = viewBox.height();
|
|
205
200
|
if (clear) {
|
|
206
|
-
|
|
207
|
-
context.clearRect(x, y, width, height);
|
|
201
|
+
context.clearRect(0, 0, width, height);
|
|
208
202
|
const stage = null === (_a = renderService.drawParams) || void 0 === _a ? void 0 : _a.stage;
|
|
209
203
|
if (stage && (context.globalAlpha = null !== (_b = stage.attribute.opacity) && void 0 !== _b ? _b : 1),
|
|
210
204
|
stage && stage.backgroundImg && stage.resources) {
|
|
211
205
|
const res = stage.resources.get(clear);
|
|
212
|
-
res && "success" === res.state && res.data && context.drawImage(res.data,
|
|
206
|
+
res && "success" === res.state && res.data && context.drawImage(res.data, 0, 0, width, height);
|
|
213
207
|
} else context.fillStyle = createColor(context, clear, {
|
|
214
208
|
AABBBounds: {
|
|
215
|
-
x1:
|
|
216
|
-
y1:
|
|
217
|
-
x2:
|
|
218
|
-
y2:
|
|
209
|
+
x1: 0,
|
|
210
|
+
y1: 0,
|
|
211
|
+
x2: 0 + width,
|
|
212
|
+
y2: 0 + height
|
|
219
213
|
}
|
|
220
|
-
}, 0, 0), context.fillRect(
|
|
214
|
+
}, 0, 0), context.fillRect(0, 0, width, height);
|
|
221
215
|
}
|
|
222
216
|
}
|
|
223
217
|
afterDraw(renderService, drawParams) {}
|
|
@@ -1 +1 @@
|
|
|
1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BAAuB;IADnC,UAAU,EAAE;IAmBR,WAAA,WAAW,CAAC,aAAa,CAAC,CAAA;IAG1B,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GAtBlB,uBAAuB,CAganC;SAhaY,uBAAuB","file":"draw-contribution.js","sourcesContent":["import { injectable, inject, named, multiInject } from '../../../common/inversify-lite';\nimport type {\n IContext2d,\n MaybePromise,\n IGraphic,\n IGroup,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n IDrawItemInterceptorContribution,\n IDrawContribution,\n IRenderSelector,\n IGlobal\n} from '../../../interface';\nimport { findNextGraphic, foreach } from '../../../common/sort';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { DefaultAttribute } from '../../../graphic';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix, IMatrixLike } from '@visactor/vutils';\nimport { Bounds, Logger, getRectIntersect, isRectIntersect, last } from '@visactor/vutils';\nimport { LayerService } from '../../../core/constants';\nimport { container } from '../../../container';\nimport { GraphicRender, IncrementalDrawContribution, RenderSelector } from './symbol';\nimport { DrawItemInterceptor } from './draw-interceptor';\nimport { createColor } from '../../../common/canvas-utils';\nimport type { ILayerService } from '../../../interface/core';\nimport { boundsAllocate } from '../../../allocator/bounds-allocate';\nimport { matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { application } from '../../../application';\n\n/**\n * 默认的渲染contribution,基于树状结构针对图元的渲染\n */\n@injectable()\nexport class DefaultDrawContribution implements IDrawContribution {\n declare currentRenderMap: Map<number, IGraphicRender>;\n declare defaultRenderMap: Map<number, IGraphicRender>;\n declare styleRenderMap: Map<string, Map<number, IGraphicRender>>;\n declare dirtyBounds: IBounds;\n declare backupDirtyBounds: IBounds;\n // 是否使用dirtyBounds\n declare useDirtyBounds: boolean;\n declare currentRenderService: IRenderService;\n declare InterceptorContributions: IDrawItemInterceptorContribution[];\n\n declare global: IGlobal;\n declare layerService: ILayerService;\n\n constructor(\n // @inject(ContributionProvider)\n // @named(GraphicRender)\n // protected readonly contributions: ContributionProvider<IGraphicRender>,\n @multiInject(GraphicRender) protected readonly contributions: IGraphicRender[],\n // @inject(RenderSelector) protected readonly renderSelector: IRenderSelector, // 根据图元类型选择对应的renderItem进行渲染\n // 拦截器\n @inject(ContributionProvider)\n @named(DrawItemInterceptor)\n protected readonly drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>\n ) {\n this.currentRenderMap = new Map();\n this.defaultRenderMap = new Map();\n this.styleRenderMap = new Map();\n this.dirtyBounds = new Bounds();\n this.backupDirtyBounds = new Bounds();\n this.global = application.global;\n this.layerService = application.layerService;\n this.init();\n }\n\n init() {\n this.contributions.forEach(item => {\n if (item.style) {\n const map = this.styleRenderMap.get(item.style) || new Map();\n map.set(item.numberType, item);\n this.styleRenderMap.set(item.style, map);\n } else {\n this.defaultRenderMap.set(item.numberType, item);\n }\n });\n this.InterceptorContributions = this.drawItemInterceptorContributions\n .getContributions()\n .sort((a, b) => a.order - b.order);\n }\n\n prepareForDraw(renderService: IRenderService, drawContext: IDrawContext) {\n // 有dirtyBounds用dirtyBounds\n if (drawContext.updateBounds) {\n this.useDirtyBounds = true;\n } else {\n // 没有的话,看看是否需要跳过outRange的渲染\n this.useDirtyBounds = !drawContext.stage.params.optimize.disableCheckGraphicWidthOutRange;\n }\n }\n\n draw(renderService: IRenderService, drawContext: IDrawContext): MaybePromise<void> {\n this.prepareForDraw(renderService, drawContext);\n drawContext.drawContribution = this;\n this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap;\n // this.startAtId = drawParams.startAtId;\n this.currentRenderService = renderService;\n // this.drawParams = drawParams;\n const { context, stage, x = 0, y = 0, width, height } = drawContext;\n\n if (!context) {\n return;\n }\n // 设置context的transform\n if (drawContext.keepMatrix) {\n if (context.nativeContext && context.nativeContext.getTransform) {\n const t = context.nativeContext.getTransform();\n context.setTransformFromMatrix(t, true, 1);\n }\n } else {\n context.inuse = true;\n // 初始化context\n context.clearMatrix();\n context.setTransformForCurrent(true);\n }\n\n const dirtyBounds: IBounds | undefined = this.dirtyBounds.setValue(0, 0, width, height);\n if (stage.dirtyBounds && !stage.dirtyBounds.empty()) {\n const b = getRectIntersect(dirtyBounds, stage.dirtyBounds, false);\n dirtyBounds.x1 = Math.floor(b.x1);\n dirtyBounds.y1 = Math.floor(b.y1);\n dirtyBounds.x2 = Math.ceil(b.x2);\n dirtyBounds.y2 = Math.ceil(b.y2);\n }\n // 如果dpr不是整数或者.5的小数,需要格式化dirtyBounds\n const d = context.dpr % 1;\n if (d || d !== 0.5) {\n dirtyBounds.x1 = Math.floor(dirtyBounds.x1 * context.dpr) / context.dpr;\n dirtyBounds.y1 = Math.floor(dirtyBounds.y1 * context.dpr) / context.dpr;\n dirtyBounds.x2 = Math.ceil(dirtyBounds.x2 * context.dpr) / context.dpr;\n dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr;\n }\n this.backupDirtyBounds.copy(dirtyBounds);\n\n const drawInArea =\n dirtyBounds.width() * context.dpr < context.canvas.width ||\n dirtyBounds.height() * context.dpr < context.canvas.height;\n context.save();\n\n // 设置translate\n context.translate(x, y, true);\n if (drawInArea) {\n context.beginPath();\n context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height());\n context.clip();\n }\n\n // 如果存在3d视角,那么不使用dirtyBounds\n if (stage.camera) {\n this.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n this.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n }\n\n this.clearScreen(renderService, context, drawContext);\n // // 渲染的时候图元的起始位置就是x,y\n // this.backupDirtyBounds.translate(-x, -y);\n // this.dirtyBounds.translate(-x, -y);\n\n // // 设置translate\n // context.translate(x, y, true);\n\n context.save();\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n group.isContainer\n ? this.renderGroup(group as IGroup, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0))\n : this.renderItem(group as IGraphic, drawContext);\n });\n\n context.restore();\n context.restore();\n context.draw();\n // this.break = false;\n if (!drawContext.keepMatrix) {\n context.inuse = false;\n }\n }\n\n doRegister() {\n throw new Error('暂不支持');\n }\n\n // 找到下一个graphic\n protected _findNextGraphic(group: IGroup): IGraphic | null {\n let parent = group.parent;\n let id = group._uid;\n while (parent) {\n const g = findNextGraphic(parent, id, DefaultAttribute.zIndex);\n if (g) {\n return g;\n }\n id = parent._uid;\n parent = parent.parent;\n }\n return null;\n }\n\n renderGroup(group: IGroup, drawContext: IDrawContext, parentMatrix: IMatrix, skipSort?: boolean) {\n if (drawContext.break || group.attribute.visibleAll === false) {\n return;\n }\n if (group.incremental && (drawContext.startAtId == null || drawContext.startAtId === group._uid)) {\n drawContext.break = true;\n this._increaseRender(group, drawContext);\n return;\n }\n\n if (this.useDirtyBounds && !isRectIntersect(group.AABBBounds, this.dirtyBounds, false)) {\n return;\n }\n\n let nextM: IMatrix = parentMatrix;\n let tempBounds: IBounds;\n\n if (this.useDirtyBounds) {\n tempBounds = boundsAllocate.allocateByObj(this.dirtyBounds);\n // 变换dirtyBounds\n const gm = group.transMatrix;\n nextM = matrixAllocate.allocateByObj(parentMatrix).multiply(gm.a, gm.b, gm.c, gm.d, gm.e, gm.f);\n // const m = group.globalTransMatrix.getInverse();\n this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(nextM.getInverse());\n }\n\n this.renderItem(group, drawContext, {\n drawingCb: () => {\n skipSort\n ? group.forEachChildren((item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext, nextM);\n } else {\n this.renderItem(item, drawContext);\n }\n })\n : foreach(\n group,\n DefaultAttribute.zIndex,\n (item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext, nextM);\n } else {\n this.renderItem(item, drawContext);\n }\n },\n false,\n !!drawContext.context?.camera\n );\n }\n });\n\n if (this.useDirtyBounds) {\n this.dirtyBounds.copy(tempBounds);\n boundsAllocate.free(tempBounds);\n matrixAllocate.free(nextM);\n }\n }\n\n protected _increaseRender(group: IGroup, drawContext: IDrawContext) {\n const { layer, stage } = drawContext;\n const { subLayers } = layer;\n // 获取渐进渲染层\n let incrementalLayer = subLayers.get(group._uid);\n if (!incrementalLayer) {\n incrementalLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size,\n group\n };\n subLayers.set(group._uid, incrementalLayer);\n }\n // 渲染\n const incrementalContext = incrementalLayer.layer.getNativeHandler().getContext();\n const idc = incrementalLayer.drawContribution || container.get(IncrementalDrawContribution);\n idc.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n idc.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n (idc as any).draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: incrementalLayer.layer,\n context: incrementalContext,\n startAtId: group._uid,\n break: false\n });\n incrementalLayer.drawContribution = idc;\n // this.draw(this.currentRenderService, {...this.drawParams, startAtId: group._uid})\n // this.draw(this.currentRenderService, {...this.drawParams, clear: 'transparent', layer: incrementalContext.layer, context: incrementalContext, startAtId: group._uid})\n const nextGraphic = this._findNextGraphic(group);\n if (nextGraphic) {\n // 如果是下一个渐进渲染层,那就再来一次\n if (nextGraphic.isContainer && nextGraphic.incremental) {\n this._increaseRender(nextGraphic as IGroup, drawContext);\n } else {\n // 如果不是渐进渲染层,那就默认图层渲染\n let afterLayer = subLayers.get(nextGraphic._uid);\n if (!afterLayer) {\n afterLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size\n };\n subLayers.set(nextGraphic._uid, afterLayer);\n }\n const afterContext = afterLayer.layer.getNativeHandler().getContext();\n this.draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: afterLayer.layer,\n context: afterContext,\n startAtId: nextGraphic._uid,\n break: false\n });\n }\n }\n }\n\n getRenderContribution(graphic: IGraphic): IGraphicRender | null {\n let renderer;\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType, graphic);\n }\n if (!renderer) {\n renderer = this.selectRenderByType(graphic.type);\n }\n return renderer;\n }\n\n renderItem(graphic: IGraphic, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (\n drawContribution.beforeDrawItem &&\n drawContribution.beforeDrawItem(graphic, this.currentRenderService, drawContext, this, params)\n ) {\n return;\n }\n }\n }\n\n const renderer = this.getRenderContribution(graphic);\n if (!renderer) {\n return;\n }\n\n let retrans: boolean = false;\n let tempBounds: IAABBBounds;\n\n if (graphic.parent) {\n const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n retrans = !!(scrollX || scrollY);\n if (retrans) {\n tempBounds = this.dirtyBounds.clone();\n // 变换dirtyBounds\n const m = graphic.globalTransMatrix.getInverse();\n this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(m);\n this.dirtyBounds.translate(-scrollX, -scrollY);\n }\n }\n\n if (this.useDirtyBounds && !(graphic.isContainer || isRectIntersect(graphic.AABBBounds, this.dirtyBounds, false))) {\n retrans && this.dirtyBounds.copy(tempBounds);\n return;\n }\n\n const skipDraw = drawContext.startAtId != null && graphic._uid !== drawContext.startAtId;\n if (graphic._uid === drawContext.startAtId) {\n drawContext.startAtId = null;\n }\n params && (params.skipDraw = skipDraw);\n if (skipDraw) {\n graphic.isContainer && renderer.draw(graphic, this.currentRenderService, drawContext, params);\n } else {\n renderer.draw(graphic, this.currentRenderService, drawContext, params);\n }\n\n retrans && this.dirtyBounds.copy(tempBounds);\n\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.afterDrawItem) {\n if (drawContribution.afterDrawItem(graphic, this.currentRenderService, drawContext, this)) {\n return;\n }\n }\n }\n }\n }\n // 根据type选择对应的render\n protected selectRenderByType(type?: string): IGraphicRender | null {\n Logger.getInstance().warn('未知错误,不应该走到这里');\n return null;\n }\n // 根据type选择对应的render\n protected selectRenderByNumberType(type: number, graphic: IGraphic): IGraphicRender | null {\n let data;\n if (graphic.attribute.renderStyle) {\n const currentRenderMap = this.styleRenderMap.get(graphic.attribute.renderStyle);\n data = currentRenderMap && currentRenderMap.get(type);\n }\n return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);\n }\n\n protected clearScreen(renderService: IRenderService, context: IContext2d, drawContext: IDrawContext) {\n const { clear } = drawContext;\n if (clear) {\n const canvas = context.getCanvas();\n const { width = canvas.width, height = canvas.height } = drawContext;\n const x = 0;\n const y = 0;\n context.clearRect(x, y, width, height);\n const stage = renderService.drawParams?.stage;\n stage && (context.globalAlpha = (stage as any).attribute.opacity ?? 1);\n if (stage && (stage as any).backgroundImg && (stage as any).resources) {\n const res = (stage as any).resources.get(clear);\n if (res && res.state === 'success' && res.data) {\n context.drawImage(res.data, x, y, width, height);\n }\n } else {\n context.fillStyle = createColor(\n context,\n clear,\n {\n AABBBounds: { x1: x, y1: y, x2: x + width, y2: y + height }\n },\n 0,\n 0\n );\n context.fillRect(x, y, width, height);\n }\n }\n }\n\n afterDraw(renderService: IRenderService, drawParams: IDrawContext) {\n return;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,gCA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,GAAI,KAAa,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAChD,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,EAAE;oBAC9C,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;iBAClD;aACF;iBAAM;gBACL,OAAO,CAAC,SAAS,GAAG,WAAW,CAC7B,OAAO,EACP,KAAK,EACL;oBACE,UAAU,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,MAAM,EAAE;iBAC5D,EACD,CAAC,EACD,CAAC,CACF,CAAC;gBACF,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;aACvC;SACF;IACH,CAAC;IAED,SAAS,CAAC,aAA6B,EAAE,UAAwB;QAC/D,OAAO;IACT,CAAC;CACF,CAAA;AAzZY,uBAAuB;IADnC,UAAU,EAAE;IAmBR,WAAA,WAAW,CAAC,aAAa,CAAC,CAAA;IAG1B,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GAtBlB,uBAAuB,CAyZnC;SAzZY,uBAAuB","file":"draw-contribution.js","sourcesContent":["import { injectable, inject, named, multiInject } from '../../../common/inversify-lite';\nimport type {\n IContext2d,\n MaybePromise,\n IGraphic,\n IGroup,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n IDrawItemInterceptorContribution,\n IDrawContribution,\n IRenderSelector,\n IGlobal\n} from '../../../interface';\nimport { findNextGraphic, foreach } from '../../../common/sort';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { DefaultAttribute } from '../../../graphic';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix, IMatrixLike } from '@visactor/vutils';\nimport { Bounds, Logger, getRectIntersect, isRectIntersect, last } from '@visactor/vutils';\nimport { LayerService } from '../../../core/constants';\nimport { container } from '../../../container';\nimport { GraphicRender, IncrementalDrawContribution, RenderSelector } from './symbol';\nimport { DrawItemInterceptor } from './draw-interceptor';\nimport { createColor } from '../../../common/canvas-utils';\nimport type { ILayerService } from '../../../interface/core';\nimport { boundsAllocate } from '../../../allocator/bounds-allocate';\nimport { matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { application } from '../../../application';\n\n/**\n * 默认的渲染contribution,基于树状结构针对图元的渲染\n */\n@injectable()\nexport class DefaultDrawContribution implements IDrawContribution {\n declare currentRenderMap: Map<number, IGraphicRender>;\n declare defaultRenderMap: Map<number, IGraphicRender>;\n declare styleRenderMap: Map<string, Map<number, IGraphicRender>>;\n declare dirtyBounds: IBounds;\n declare backupDirtyBounds: IBounds;\n // 是否使用dirtyBounds\n declare useDirtyBounds: boolean;\n declare currentRenderService: IRenderService;\n declare InterceptorContributions: IDrawItemInterceptorContribution[];\n\n declare global: IGlobal;\n declare layerService: ILayerService;\n\n constructor(\n // @inject(ContributionProvider)\n // @named(GraphicRender)\n // protected readonly contributions: ContributionProvider<IGraphicRender>,\n @multiInject(GraphicRender) protected readonly contributions: IGraphicRender[],\n // @inject(RenderSelector) protected readonly renderSelector: IRenderSelector, // 根据图元类型选择对应的renderItem进行渲染\n // 拦截器\n @inject(ContributionProvider)\n @named(DrawItemInterceptor)\n protected readonly drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>\n ) {\n this.currentRenderMap = new Map();\n this.defaultRenderMap = new Map();\n this.styleRenderMap = new Map();\n this.dirtyBounds = new Bounds();\n this.backupDirtyBounds = new Bounds();\n this.global = application.global;\n this.layerService = application.layerService;\n this.init();\n }\n\n init() {\n this.contributions.forEach(item => {\n if (item.style) {\n const map = this.styleRenderMap.get(item.style) || new Map();\n map.set(item.numberType, item);\n this.styleRenderMap.set(item.style, map);\n } else {\n this.defaultRenderMap.set(item.numberType, item);\n }\n });\n this.InterceptorContributions = this.drawItemInterceptorContributions\n .getContributions()\n .sort((a, b) => a.order - b.order);\n }\n\n prepareForDraw(renderService: IRenderService, drawContext: IDrawContext) {\n // 有dirtyBounds用dirtyBounds\n if (drawContext.updateBounds) {\n this.useDirtyBounds = true;\n } else {\n // 没有的话,看看是否需要跳过outRange的渲染\n this.useDirtyBounds = !drawContext.stage.params.optimize.disableCheckGraphicWidthOutRange;\n }\n }\n\n draw(renderService: IRenderService, drawContext: IDrawContext): MaybePromise<void> {\n this.prepareForDraw(renderService, drawContext);\n drawContext.drawContribution = this;\n this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap;\n // this.startAtId = drawParams.startAtId;\n this.currentRenderService = renderService;\n // this.drawParams = drawParams;\n const { context, stage, viewBox, transMatrix } = drawContext;\n\n if (!context) {\n return;\n }\n // if (context.drawPromise) {\n // return;\n // }\n const dirtyBounds: IBounds | undefined = this.dirtyBounds.setValue(0, 0, viewBox.width(), viewBox.height());\n if (stage.dirtyBounds && !stage.dirtyBounds.empty()) {\n const b = getRectIntersect(dirtyBounds, stage.dirtyBounds, false);\n dirtyBounds.x1 = Math.floor(b.x1);\n dirtyBounds.y1 = Math.floor(b.y1);\n dirtyBounds.x2 = Math.ceil(b.x2);\n dirtyBounds.y2 = Math.ceil(b.y2);\n }\n // 如果dpr不是整数或者.5的小数,需要格式化dirtyBounds\n const d = context.dpr % 1;\n if (d || d !== 0.5) {\n dirtyBounds.x1 = Math.floor(dirtyBounds.x1 * context.dpr) / context.dpr;\n dirtyBounds.y1 = Math.floor(dirtyBounds.y1 * context.dpr) / context.dpr;\n dirtyBounds.x2 = Math.ceil(dirtyBounds.x2 * context.dpr) / context.dpr;\n dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr;\n }\n this.backupDirtyBounds.copy(dirtyBounds);\n context.inuse = true;\n context.setClearMatrix(transMatrix.a, transMatrix.b, transMatrix.c, transMatrix.d, transMatrix.e, transMatrix.f);\n // 初始化context\n context.clearMatrix();\n context.setTransformForCurrent(true);\n\n // const drawInArea =\n // dirtyBounds.width() * context.dpr < context.canvas.width ||\n // dirtyBounds.height() * context.dpr < context.canvas.height;\n // context.save();\n\n // 设置translate\n context.translate(viewBox.x1, viewBox.y1, true);\n context.beginPath();\n context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height());\n context.clip();\n\n // 如果存在3d视角,那么不使用dirtyBounds\n if (stage.camera) {\n this.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n this.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n }\n\n this.clearScreen(renderService, context, drawContext);\n // // 渲染的时候图元的起始位置就是x,y\n // this.backupDirtyBounds.translate(-x, -y);\n // this.dirtyBounds.translate(-x, -y);\n\n // // 设置translate\n // context.translate(x, y, true);\n\n context.save();\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n group.isContainer\n ? this.renderGroup(group as IGroup, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0))\n : this.renderItem(group as IGraphic, drawContext);\n });\n\n // context.restore();\n context.restore();\n context.draw();\n context.setClearMatrix(1, 0, 0, 1, 0, 0);\n // this.break = false;\n context.inuse = false;\n }\n\n doRegister() {\n throw new Error('暂不支持');\n }\n\n // 找到下一个graphic\n protected _findNextGraphic(group: IGroup): IGraphic | null {\n let parent = group.parent;\n let id = group._uid;\n while (parent) {\n const g = findNextGraphic(parent, id, DefaultAttribute.zIndex);\n if (g) {\n return g;\n }\n id = parent._uid;\n parent = parent.parent;\n }\n return null;\n }\n\n renderGroup(group: IGroup, drawContext: IDrawContext, parentMatrix: IMatrix, skipSort?: boolean) {\n if (drawContext.break || group.attribute.visibleAll === false) {\n return;\n }\n if (group.incremental && (drawContext.startAtId == null || drawContext.startAtId === group._uid)) {\n drawContext.break = true;\n this._increaseRender(group, drawContext);\n return;\n }\n\n if (this.useDirtyBounds && !isRectIntersect(group.AABBBounds, this.dirtyBounds, false)) {\n return;\n }\n\n let nextM: IMatrix = parentMatrix;\n let tempBounds: IBounds;\n\n if (this.useDirtyBounds) {\n tempBounds = boundsAllocate.allocateByObj(this.dirtyBounds);\n // 变换dirtyBounds\n const gm = group.transMatrix;\n nextM = matrixAllocate.allocateByObj(parentMatrix).multiply(gm.a, gm.b, gm.c, gm.d, gm.e, gm.f);\n // const m = group.globalTransMatrix.getInverse();\n this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(nextM.getInverse());\n }\n\n this.renderItem(group, drawContext, {\n drawingCb: () => {\n skipSort\n ? group.forEachChildren((item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext, nextM);\n } else {\n this.renderItem(item, drawContext);\n }\n })\n : foreach(\n group,\n DefaultAttribute.zIndex,\n (item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext, nextM);\n } else {\n this.renderItem(item, drawContext);\n }\n },\n false,\n !!drawContext.context?.camera\n );\n }\n });\n\n if (this.useDirtyBounds) {\n this.dirtyBounds.copy(tempBounds);\n boundsAllocate.free(tempBounds);\n matrixAllocate.free(nextM);\n }\n }\n\n protected _increaseRender(group: IGroup, drawContext: IDrawContext) {\n const { layer, stage } = drawContext;\n const { subLayers } = layer;\n // 获取渐进渲染层\n let incrementalLayer = subLayers.get(group._uid);\n if (!incrementalLayer) {\n incrementalLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size,\n group\n };\n subLayers.set(group._uid, incrementalLayer);\n }\n // 渲染\n const incrementalContext = incrementalLayer.layer.getNativeHandler().getContext();\n const idc = incrementalLayer.drawContribution || container.get(IncrementalDrawContribution);\n idc.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n idc.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n (idc as any).draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: incrementalLayer.layer,\n context: incrementalContext,\n startAtId: group._uid,\n break: false\n });\n incrementalLayer.drawContribution = idc;\n // this.draw(this.currentRenderService, {...this.drawParams, startAtId: group._uid})\n // this.draw(this.currentRenderService, {...this.drawParams, clear: 'transparent', layer: incrementalContext.layer, context: incrementalContext, startAtId: group._uid})\n const nextGraphic = this._findNextGraphic(group);\n if (nextGraphic) {\n // 如果是下一个渐进渲染层,那就再来一次\n if (nextGraphic.isContainer && nextGraphic.incremental) {\n this._increaseRender(nextGraphic as IGroup, drawContext);\n } else {\n // 如果不是渐进渲染层,那就默认图层渲染\n let afterLayer = subLayers.get(nextGraphic._uid);\n if (!afterLayer) {\n afterLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size\n };\n subLayers.set(nextGraphic._uid, afterLayer);\n }\n const afterContext = afterLayer.layer.getNativeHandler().getContext();\n this.draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: afterLayer.layer,\n context: afterContext,\n startAtId: nextGraphic._uid,\n break: false\n });\n }\n }\n }\n\n getRenderContribution(graphic: IGraphic): IGraphicRender | null {\n let renderer;\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType, graphic);\n }\n if (!renderer) {\n renderer = this.selectRenderByType(graphic.type);\n }\n return renderer;\n }\n\n renderItem(graphic: IGraphic, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (\n drawContribution.beforeDrawItem &&\n drawContribution.beforeDrawItem(graphic, this.currentRenderService, drawContext, this, params)\n ) {\n return;\n }\n }\n }\n\n const renderer = this.getRenderContribution(graphic);\n if (!renderer) {\n return;\n }\n\n let retrans: boolean = false;\n let tempBounds: IAABBBounds;\n\n if (graphic.parent) {\n const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n retrans = !!(scrollX || scrollY);\n if (retrans) {\n tempBounds = this.dirtyBounds.clone();\n // 变换dirtyBounds\n const m = graphic.globalTransMatrix.getInverse();\n this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(m);\n this.dirtyBounds.translate(-scrollX, -scrollY);\n }\n }\n\n if (this.useDirtyBounds && !(graphic.isContainer || isRectIntersect(graphic.AABBBounds, this.dirtyBounds, false))) {\n retrans && this.dirtyBounds.copy(tempBounds);\n return;\n }\n\n const skipDraw = drawContext.startAtId != null && graphic._uid !== drawContext.startAtId;\n if (graphic._uid === drawContext.startAtId) {\n drawContext.startAtId = null;\n }\n params && (params.skipDraw = skipDraw);\n if (skipDraw) {\n graphic.isContainer && renderer.draw(graphic, this.currentRenderService, drawContext, params);\n } else {\n renderer.draw(graphic, this.currentRenderService, drawContext, params);\n }\n\n retrans && this.dirtyBounds.copy(tempBounds);\n\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.afterDrawItem) {\n if (drawContribution.afterDrawItem(graphic, this.currentRenderService, drawContext, this)) {\n return;\n }\n }\n }\n }\n }\n // 根据type选择对应的render\n protected selectRenderByType(type?: string): IGraphicRender | null {\n Logger.getInstance().warn('未知错误,不应该走到这里');\n return null;\n }\n // 根据type选择对应的render\n protected selectRenderByNumberType(type: number, graphic: IGraphic): IGraphicRender | null {\n let data;\n if (graphic.attribute.renderStyle) {\n const currentRenderMap = this.styleRenderMap.get(graphic.attribute.renderStyle);\n data = currentRenderMap && currentRenderMap.get(type);\n }\n return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);\n }\n\n protected clearScreen(renderService: IRenderService, context: IContext2d, drawContext: IDrawContext) {\n const { clear, viewBox } = drawContext;\n // 已经translate过了\n const x = 0;\n const y = 0;\n const width = viewBox.width();\n const height = viewBox.height();\n if (clear) {\n context.clearRect(x, y, width, height);\n const stage = renderService.drawParams?.stage;\n stage && (context.globalAlpha = (stage as any).attribute.opacity ?? 1);\n if (stage && (stage as any).backgroundImg && (stage as any).resources) {\n const res = (stage as any).resources.get(clear);\n if (res && res.state === 'success' && res.data) {\n context.drawImage(res.data, x, y, width, height);\n }\n } else {\n context.fillStyle = createColor(\n context,\n clear,\n {\n AABBBounds: { x1: x, y1: y, x2: x + width, y2: y + height }\n },\n 0,\n 0\n );\n context.fillRect(x, y, width, height);\n }\n }\n }\n\n afterDraw(renderService: IRenderService, drawParams: IDrawContext) {\n return;\n }\n}\n"]}
|
|
@@ -74,25 +74,17 @@ let DefaultIncrementalDrawContribution = class extends DefaultDrawContribution {
|
|
|
74
74
|
const skipDraw = yield this.checkingForDrawPromise;
|
|
75
75
|
if (this.checkingForDrawPromise = null, skipDraw) return;
|
|
76
76
|
this.currentRenderService = renderService;
|
|
77
|
-
const {context: context,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
context.
|
|
87
|
-
|
|
88
|
-
return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
|
|
89
|
-
})).forEach((group => {
|
|
90
|
-
this.renderGroup(group, drawContext);
|
|
91
|
-
})), this.hooks.completeDraw.tap("top-draw", (() => {
|
|
92
|
-
context.restore(), context.restore(), context.draw(), drawContext.keepMatrix || (context.inuse = !1),
|
|
93
|
-
this.rendering = !1;
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
77
|
+
const {context: context, viewBox: viewBox} = drawContext;
|
|
78
|
+
context && (context.inuse = !0, context.clearMatrix(), context.setTransformForCurrent(!0),
|
|
79
|
+
context.save(), drawContext.restartIncremental && this.clearScreen(this.currentRenderService, context, drawContext),
|
|
80
|
+
context.translate(viewBox.x1, viewBox.y1, !0), context.save(), renderService.renderTreeRoots.sort(((a, b) => {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
|
|
83
|
+
})).forEach((group => {
|
|
84
|
+
this.renderGroup(group, drawContext);
|
|
85
|
+
})), this.hooks.completeDraw.tap("top-draw", (() => {
|
|
86
|
+
context.restore(), context.restore(), context.draw(), context.inuse = !1, this.rendering = !1;
|
|
87
|
+
})));
|
|
96
88
|
}));
|
|
97
89
|
}
|
|
98
90
|
_increaseRender(group, drawContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/incremental-draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAaxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAkB,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,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AAC,CAAA;IAE1B,WAAA,MAAM,CAAC,kCAAkC,CAAC,CAAA;IAC1C,WAAA,MAAM,CAAC,kCAAkC,CAAC,CAAA;IAE1C,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GAvBlB,kCAAkC,CAwQ9C;SAxQY,kCAAkC","file":"incremental-draw-contribution.js","sourcesContent":["import { injectable, inject, named, multiInject } from '../../../common/inversify-lite';\nimport type {\n IGraphic,\n IGroup,\n IGlobal,\n IRenderService,\n IDrawContext,\n IDrawContribution,\n IGraphicRender,\n IRenderSelector,\n IDrawItemInterceptorContribution,\n IContributionProvider\n} from '../../../interface';\nimport { DefaultAttribute } from '../../../graphic';\nimport { LayerService } from '../../../core/constants';\nimport { DefaultDrawContribution } from './draw-contribution';\nimport { SyncHook } from '../../../tapable';\nimport { GraphicRender, RenderSelector } from './symbol';\nimport { DefaultIncrementalCanvasLineRender } from './incremental-line-render';\nimport { DefaultIncrementalCanvasAreaRender } from './incremental-area-render';\nimport { DrawItemInterceptor } from './draw-interceptor';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { foreachAsync } from '../../../common/sort';\n\nenum STATUS {\n NORMAL = 0,\n STOP = 1\n}\n\n/**\n * 增量渲染的contribution,基于树状结构针对图元的渲染\n * 不是单例模式\n */\n@injectable()\nexport class DefaultIncrementalDrawContribution extends DefaultDrawContribution implements IDrawContribution {\n rendering: boolean = false;\n protected currFrameStartAt: number = 0;\n protected currentIdx: number = 0;\n protected status: STATUS = STATUS.NORMAL;\n protected checkingForDrawPromise: Promise<any> | null = null;\n hooks = {\n completeDraw: new SyncHook<[]>([])\n };\n protected lastRenderService: IRenderService;\n protected lastDrawContext: IDrawContext;\n protected count: number;\n\n constructor(\n // @inject(ContributionProvider)\n // @named(GraphicRender)\n // protected readonly contributions: ContributionProvider<IGraphicRender>,\n @multiInject(GraphicRender) protected readonly contributions: IGraphicRender[],\n // @inject(RenderSelector) protected readonly renderSelector: IRenderSelector, // 根据图元类型选择对应的renderItem进行渲染\n @inject(DefaultIncrementalCanvasLineRender) protected readonly lineRender: IGraphicRender, // 默认的lineRender\n @inject(DefaultIncrementalCanvasAreaRender) protected readonly areaRender: IGraphicRender, // 默认的lineRender\n // 拦截器\n @inject(ContributionProvider)\n @named(DrawItemInterceptor)\n protected readonly drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>\n ) {\n super(contributions, drawItemInterceptorContributions);\n this.defaultRenderMap.set(this.lineRender.numberType, this.lineRender);\n this.defaultRenderMap.set(this.areaRender.numberType, this.areaRender);\n }\n\n /**\n *\n * @param renderService\n * @param drawContext restartIncremental为true表示重新执行增量渲染,为false表示不执行增量渲染\n * @returns\n */\n async draw(renderService: IRenderService, drawContext: IDrawContext): Promise<void> {\n // 入口检查是否需要重新绘制\n if (this.checkingForDrawPromise) {\n return;\n }\n this.lastRenderService = renderService;\n this.lastDrawContext = drawContext;\n\n this.checkingForDrawPromise = this.checkForDraw(drawContext);\n const skipDraw = await this.checkingForDrawPromise;\n this.checkingForDrawPromise = null;\n if (skipDraw) {\n return;\n }\n\n this.currentRenderService = renderService;\n const { context, x = 0, y = 0 } = drawContext;\n\n if (!context) {\n return;\n }\n // 增量渲染不需要dirtyBounds\n // const dirtyBounds: IBounds | undefined = this.dirtyBounds.setValue(x, y, x + width, y + height);\n // if (stage.dirtyBounds) {\n // const b = getRectIntersect(dirtyBounds, stage.dirtyBounds, false);\n // dirtyBounds.x1 = Math.floor(b.x1);\n // dirtyBounds.y1 = Math.floor(b.y1);\n // dirtyBounds.x2 = Math.ceil(b.x2);\n // dirtyBounds.y2 = Math.ceil(b.y2);\n // }\n if (drawContext.keepMatrix) {\n if (context.nativeContext && context.nativeContext.getTransform) {\n const t = context.nativeContext.getTransform();\n context.setTransformFromMatrix(t, true, 1);\n }\n } else {\n context.inuse = true;\n // 初始化context\n context.clearMatrix();\n }\n context.setTransformForCurrent(true);\n\n // const drawInArea =\n // dirtyBounds.width() * context.dpr !== context.canvas.width ||\n // dirtyBounds.height() * context.dpr !== context.canvas.height;\n context.save();\n\n // if (drawInArea) {\n // context.beginPath();\n // context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height());\n // context.clip();\n // }\n\n // this.clearScreen(renderService, context, drawContext);\n\n // 绘制之前需要清空画布\n drawContext.restartIncremental && this.clearScreen(this.currentRenderService, context, drawContext);\n // 设置translate\n context.translate(x, y, true);\n\n context.save();\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroup(group as IGroup, drawContext);\n });\n\n this.hooks.completeDraw.tap('top-draw', () => {\n context.restore();\n context.restore();\n context.draw();\n if (!drawContext.keepMatrix) {\n context.inuse = false;\n }\n this.rendering = false;\n });\n }\n\n protected async _increaseRender(group: IGroup, drawContext: IDrawContext) {\n this.rendering = true;\n await this._renderIncrementalGroup(group, drawContext);\n return;\n }\n\n // 默认group后只有一层节点,也就是group是叶子结点的父节点\n protected async _renderIncrementalGroup(group: IGroup, drawContext: IDrawContext) {\n this.count = group.count;\n await new Promise(resolve => {\n this.renderItem(group, drawContext, {\n drawingCb: async () => {\n // 增量图元只支持一个,线段和面积图\n if (group.count === 2) {\n const graphic = group.getChildAt(0) as IGraphic;\n if (graphic.incremental && (graphic.attribute as any).segments) {\n if (!graphic.incrementalAt) {\n graphic.incrementalAt = 0;\n }\n while (graphic.incrementalAt < (graphic.attribute as any).segments.length) {\n drawContext.multiGraphicOptions = {\n startAtIdx: graphic.incrementalAt,\n length: graphic.incremental\n };\n this.renderItem(graphic, drawContext);\n graphic.incrementalAt += graphic.incremental;\n await this.waitToNextFrame();\n }\n } else {\n this.renderItem(graphic, drawContext);\n }\n resolve(false);\n return;\n }\n await foreachAsync(group, DefaultAttribute.zIndex, (item: IGraphic, i: number) => {\n if (this.status === STATUS.STOP) {\n return true;\n }\n if (item.isContainer) {\n // 增量渲染group下不应该有其他的group节点\n return false;\n }\n // 如果小于currentIdx,说明还没到当前的位置,那就直接跳过\n if (i < this.currentIdx) {\n return false;\n }\n const frameTail = this.currFrameStartAt + group.incremental;\n // 绘制 currentIdx到this.lastFrameIdx + group.incremental的内容\n if (i < frameTail) {\n this.currentIdx = i + 1;\n this.renderItem(item, drawContext);\n }\n // 下一帧\n if (i === frameTail - 1) {\n this.currFrameStartAt = this.currentIdx;\n // this.lastFrameIdx = this.currentIdx;\n return this.waitToNextFrame();\n }\n\n return false;\n });\n resolve(false);\n }\n });\n });\n this.hooks.completeDraw.call();\n }\n\n protected async waitToNextFrame(): Promise<boolean> {\n return new Promise(resolve => {\n this.global.getRequestAnimationFrame()(() => {\n resolve(false);\n });\n });\n }\n\n /**\n * 检查这次绘制是否跳过,以及执行一些准备\n * 增量渲染有自己的绘制逻辑流程,外部每次触发draw,该图层不一定会执行\n * @returns 返回true代表跳过绘制,false代表进行绘制\n */\n protected async checkForDraw(drawContext: IDrawContext): Promise<boolean> {\n let skip = this.rendering;\n if (drawContext.restartIncremental) {\n skip = false;\n await this.forceStop();\n this.resetToInit();\n }\n return skip;\n }\n\n protected async forceStop() {\n if (this.rendering) {\n this.status = STATUS.STOP;\n await new Promise(resolve => {\n this.hooks.completeDraw.tap('stopCb', () => {\n this.status = STATUS.NORMAL;\n this.hooks.completeDraw.taps = this.hooks.completeDraw.taps.filter(item => {\n return item.name !== 'stopCb';\n });\n resolve(false);\n });\n });\n }\n }\n\n protected resetToInit() {\n this.currFrameStartAt = 0;\n this.currentIdx = 0;\n }\n\n async renderGroup(group: IGroup, drawContext: IDrawContext) {\n if (drawContext.break || group.attribute.visibleAll === false) {\n return;\n }\n if (group.incremental && drawContext.startAtId === group._uid) {\n await this._increaseRender(group, drawContext);\n drawContext.break = true;\n return;\n }\n\n await new Promise(resolve => {\n this.renderItem(group, drawContext, {\n drawingCb: async () => {\n await foreachAsync(group, DefaultAttribute.zIndex, async (item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n await this.renderGroup(item as IGroup, drawContext);\n } else {\n // 增量渲染不管非_increaseRender的内容\n return;\n }\n });\n resolve(false);\n }\n });\n });\n }\n\n // /**\n // * 一个每一帧都执行的脚本,用于检查和触发执行draw\n // */\n // protected autoRunner() {\n\n // }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/incremental-draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAaxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAkB,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,IAAK,MAGJ;AAHD,WAAK,MAAM;IACT,uCAAU,CAAA;IACV,mCAAQ,CAAA;AACV,CAAC,EAHI,MAAM,KAAN,MAAM,QAGV;AAOM,IAAM,kCAAkC,GAAxC,MAAM,kCAAmC,SAAQ,uBAAuB;IAa7E,YAIiD,aAA+B,EAEf,UAA0B,EAC1B,UAA0B,EAItE,gCAAyF;QAE5G,KAAK,CAAC,aAAa,EAAE,gCAAgC,CAAC,CAAC;QAT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oBAClC,SAAS,EAAE,GAAS,EAAE;wBACpB,MAAM,YAAY,CAAC,KAAK,EAAE,gBAAgB,CAAC,MAAM,EAAE,CAAO,IAAc,EAAE,EAAE;4BAC1E,IAAI,WAAW,CAAC,KAAK,EAAE;gCACrB,OAAO;6BACR;4BACD,IAAI,IAAI,CAAC,WAAW,EAAE;gCACpB,MAAM,IAAI,CAAC,WAAW,CAAC,IAAc,EAAE,WAAW,CAAC,CAAC;6BACrD;iCAAM;gCAEL,OAAO;6BACR;wBACH,CAAC,CAAA,CAAC,CAAC;wBACH,OAAO,CAAC,KAAK,CAAC,CAAC;oBACjB,CAAC,CAAA;iBACF,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CAQF,CAAA;AA/PY,kCAAkC;IAD9C,UAAU,EAAE;IAkBR,WAAA,WAAW,CAAC,aAAa,CAAC,CAAA;IAE1B,WAAA,MAAM,CAAC,kCAAkC,CAAC,CAAA;IAC1C,WAAA,MAAM,CAAC,kCAAkC,CAAC,CAAA;IAE1C,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GAvBlB,kCAAkC,CA+P9C;SA/PY,kCAAkC","file":"incremental-draw-contribution.js","sourcesContent":["import { injectable, inject, named, multiInject } from '../../../common/inversify-lite';\nimport type {\n IGraphic,\n IGroup,\n IGlobal,\n IRenderService,\n IDrawContext,\n IDrawContribution,\n IGraphicRender,\n IRenderSelector,\n IDrawItemInterceptorContribution,\n IContributionProvider\n} from '../../../interface';\nimport { DefaultAttribute } from '../../../graphic';\nimport { LayerService } from '../../../core/constants';\nimport { DefaultDrawContribution } from './draw-contribution';\nimport { SyncHook } from '../../../tapable';\nimport { GraphicRender, RenderSelector } from './symbol';\nimport { DefaultIncrementalCanvasLineRender } from './incremental-line-render';\nimport { DefaultIncrementalCanvasAreaRender } from './incremental-area-render';\nimport { DrawItemInterceptor } from './draw-interceptor';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { foreachAsync } from '../../../common/sort';\n\nenum STATUS {\n NORMAL = 0,\n STOP = 1\n}\n\n/**\n * 增量渲染的contribution,基于树状结构针对图元的渲染\n * 不是单例模式\n */\n@injectable()\nexport class DefaultIncrementalDrawContribution extends DefaultDrawContribution implements IDrawContribution {\n rendering: boolean = false;\n protected currFrameStartAt: number = 0;\n protected currentIdx: number = 0;\n protected status: STATUS = STATUS.NORMAL;\n protected checkingForDrawPromise: Promise<any> | null = null;\n hooks = {\n completeDraw: new SyncHook<[]>([])\n };\n protected lastRenderService: IRenderService;\n protected lastDrawContext: IDrawContext;\n protected count: number;\n\n constructor(\n // @inject(ContributionProvider)\n // @named(GraphicRender)\n // protected readonly contributions: ContributionProvider<IGraphicRender>,\n @multiInject(GraphicRender) protected readonly contributions: IGraphicRender[],\n // @inject(RenderSelector) protected readonly renderSelector: IRenderSelector, // 根据图元类型选择对应的renderItem进行渲染\n @inject(DefaultIncrementalCanvasLineRender) protected readonly lineRender: IGraphicRender, // 默认的lineRender\n @inject(DefaultIncrementalCanvasAreaRender) protected readonly areaRender: IGraphicRender, // 默认的lineRender\n // 拦截器\n @inject(ContributionProvider)\n @named(DrawItemInterceptor)\n protected readonly drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>\n ) {\n super(contributions, drawItemInterceptorContributions);\n this.defaultRenderMap.set(this.lineRender.numberType, this.lineRender);\n this.defaultRenderMap.set(this.areaRender.numberType, this.areaRender);\n }\n\n /**\n *\n * @param renderService\n * @param drawContext restartIncremental为true表示重新执行增量渲染,为false表示不执行增量渲染\n * @returns\n */\n async draw(renderService: IRenderService, drawContext: IDrawContext): Promise<void> {\n // 入口检查是否需要重新绘制\n if (this.checkingForDrawPromise) {\n return;\n }\n this.lastRenderService = renderService;\n this.lastDrawContext = drawContext;\n\n this.checkingForDrawPromise = this.checkForDraw(drawContext);\n const skipDraw = await this.checkingForDrawPromise;\n this.checkingForDrawPromise = null;\n if (skipDraw) {\n return;\n }\n\n this.currentRenderService = renderService;\n const { context, viewBox } = drawContext;\n\n if (!context) {\n return;\n }\n // 增量渲染不需要dirtyBounds\n // const dirtyBounds: IBounds | undefined = this.dirtyBounds.setValue(x, y, x + width, y + height);\n // if (stage.dirtyBounds) {\n // const b = getRectIntersect(dirtyBounds, stage.dirtyBounds, false);\n // dirtyBounds.x1 = Math.floor(b.x1);\n // dirtyBounds.y1 = Math.floor(b.y1);\n // dirtyBounds.x2 = Math.ceil(b.x2);\n // dirtyBounds.y2 = Math.ceil(b.y2);\n // }\n context.inuse = true;\n // 初始化context\n context.clearMatrix();\n context.setTransformForCurrent(true);\n\n // const drawInArea =\n // dirtyBounds.width() * context.dpr !== context.canvas.width ||\n // dirtyBounds.height() * context.dpr !== context.canvas.height;\n context.save();\n\n // if (drawInArea) {\n // context.beginPath();\n // context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height());\n // context.clip();\n // }\n\n // this.clearScreen(renderService, context, drawContext);\n\n // 绘制之前需要清空画布\n drawContext.restartIncremental && this.clearScreen(this.currentRenderService, context, drawContext);\n // 设置translate\n context.translate(viewBox.x1, viewBox.y1, true);\n\n context.save();\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroup(group as IGroup, drawContext);\n });\n\n this.hooks.completeDraw.tap('top-draw', () => {\n context.restore();\n context.restore();\n context.draw();\n context.inuse = false;\n this.rendering = false;\n });\n }\n\n protected async _increaseRender(group: IGroup, drawContext: IDrawContext) {\n this.rendering = true;\n await this._renderIncrementalGroup(group, drawContext);\n return;\n }\n\n // 默认group后只有一层节点,也就是group是叶子结点的父节点\n protected async _renderIncrementalGroup(group: IGroup, drawContext: IDrawContext) {\n this.count = group.count;\n await new Promise(resolve => {\n this.renderItem(group, drawContext, {\n drawingCb: async () => {\n // 增量图元只支持一个,线段和面积图\n if (group.count === 2) {\n const graphic = group.getChildAt(0) as IGraphic;\n if (graphic.incremental && (graphic.attribute as any).segments) {\n if (!graphic.incrementalAt) {\n graphic.incrementalAt = 0;\n }\n while (graphic.incrementalAt < (graphic.attribute as any).segments.length) {\n drawContext.multiGraphicOptions = {\n startAtIdx: graphic.incrementalAt,\n length: graphic.incremental\n };\n this.renderItem(graphic, drawContext);\n graphic.incrementalAt += graphic.incremental;\n await this.waitToNextFrame();\n }\n } else {\n this.renderItem(graphic, drawContext);\n }\n resolve(false);\n return;\n }\n await foreachAsync(group, DefaultAttribute.zIndex, (item: IGraphic, i: number) => {\n if (this.status === STATUS.STOP) {\n return true;\n }\n if (item.isContainer) {\n // 增量渲染group下不应该有其他的group节点\n return false;\n }\n // 如果小于currentIdx,说明还没到当前的位置,那就直接跳过\n if (i < this.currentIdx) {\n return false;\n }\n const frameTail = this.currFrameStartAt + group.incremental;\n // 绘制 currentIdx到this.lastFrameIdx + group.incremental的内容\n if (i < frameTail) {\n this.currentIdx = i + 1;\n this.renderItem(item, drawContext);\n }\n // 下一帧\n if (i === frameTail - 1) {\n this.currFrameStartAt = this.currentIdx;\n // this.lastFrameIdx = this.currentIdx;\n return this.waitToNextFrame();\n }\n\n return false;\n });\n resolve(false);\n }\n });\n });\n this.hooks.completeDraw.call();\n }\n\n protected async waitToNextFrame(): Promise<boolean> {\n return new Promise(resolve => {\n this.global.getRequestAnimationFrame()(() => {\n resolve(false);\n });\n });\n }\n\n /**\n * 检查这次绘制是否跳过,以及执行一些准备\n * 增量渲染有自己的绘制逻辑流程,外部每次触发draw,该图层不一定会执行\n * @returns 返回true代表跳过绘制,false代表进行绘制\n */\n protected async checkForDraw(drawContext: IDrawContext): Promise<boolean> {\n let skip = this.rendering;\n if (drawContext.restartIncremental) {\n skip = false;\n await this.forceStop();\n this.resetToInit();\n }\n return skip;\n }\n\n protected async forceStop() {\n if (this.rendering) {\n this.status = STATUS.STOP;\n await new Promise(resolve => {\n this.hooks.completeDraw.tap('stopCb', () => {\n this.status = STATUS.NORMAL;\n this.hooks.completeDraw.taps = this.hooks.completeDraw.taps.filter(item => {\n return item.name !== 'stopCb';\n });\n resolve(false);\n });\n });\n }\n }\n\n protected resetToInit() {\n this.currFrameStartAt = 0;\n this.currentIdx = 0;\n }\n\n async renderGroup(group: IGroup, drawContext: IDrawContext) {\n if (drawContext.break || group.attribute.visibleAll === false) {\n return;\n }\n if (group.incremental && drawContext.startAtId === group._uid) {\n await this._increaseRender(group, drawContext);\n drawContext.break = true;\n return;\n }\n\n await new Promise(resolve => {\n this.renderItem(group, drawContext, {\n drawingCb: async () => {\n await foreachAsync(group, DefaultAttribute.zIndex, async (item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n await this.renderGroup(item as IGroup, drawContext);\n } else {\n // 增量渲染不管非_increaseRender的内容\n return;\n }\n });\n resolve(false);\n }\n });\n });\n }\n\n // /**\n // * 一个每一帧都执行的脚本,用于检查和触发执行draw\n // */\n // protected autoRunner() {\n\n // }\n}\n"]}
|