@visactor/vrender-core 0.17.12 → 0.17.13
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/interface/stage.d.ts +2 -0
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/render/contributions/render/draw-contribution.js +3 -2
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/incremental-draw-contribution.d.ts +0 -1
- package/cjs/render/contributions/render/incremental-draw-contribution.js +1 -5
- package/cjs/render/contributions/render/incremental-draw-contribution.js.map +1 -1
- package/es/interface/stage.d.ts +2 -0
- package/es/interface/stage.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.js +3 -2
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/incremental-draw-contribution.d.ts +0 -1
- package/es/render/contributions/render/incremental-draw-contribution.js +1 -5
- package/es/render/contributions/render/incremental-draw-contribution.js.map +1 -1
- package/package.json +1 -1
package/cjs/interface/stage.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { IPickerService, PickResult } from './picker';
|
|
|
12
12
|
import type { IPluginService } from './plugin';
|
|
13
13
|
import type { IWindow } from './window';
|
|
14
14
|
import type { ILayerService } from './core';
|
|
15
|
+
import type { IFullThemeSpec } from './graphic/theme';
|
|
15
16
|
export type IExportType = 'canvas' | 'imageData';
|
|
16
17
|
export interface IStageParams {
|
|
17
18
|
viewBox: IBoundsLike;
|
|
@@ -143,6 +144,7 @@ export interface IStage extends INode {
|
|
|
143
144
|
release: () => void;
|
|
144
145
|
setStage: (stage?: IStage) => void;
|
|
145
146
|
setCursor: (mode?: string) => void;
|
|
147
|
+
getTheme: () => IFullThemeSpec;
|
|
146
148
|
}
|
|
147
149
|
export declare function combineStage(srages: IStage[], params: {
|
|
148
150
|
canvas: string | HTMLCanvasElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer, LayerMode } from './layer';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer, LayerMode } from './layer';\nimport type { IColor } from './color';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix } from '@visactor/vutils';\nimport type { ICamera } from './camera';\nimport type { vec3 } from './matrix';\nimport type { IDirectionLight } from './light';\nimport type { ISyncHook } from './sync-hook';\nimport type { IDrawContext, IRenderService } from './render';\nimport type { ITicker, ITimeline } from './animate';\nimport type { IPickerService, PickResult } from './picker';\nimport type { IPluginService } from './plugin';\nimport type { IWindow } from './window';\nimport type { ILayerService } from './core';\nimport type { IFullThemeSpec } from './graphic/theme';\n\nexport type IExportType = 'canvas' | 'imageData';\n\nexport interface IStageParams {\n // x: number;\n // y: number;\n // // 视口的宽高\n // viewWidth: number;\n // viewHeight: number;\n\n // 视口的宽高\n viewBox: IBoundsLike;\n // 总的宽高\n width: number;\n height: number;\n dpr: number;\n // stage的背景\n background: string | IColor;\n // 外部的canvas\n canvas: string | HTMLCanvasElement;\n // canvas的container容器,如果不传入canvas,那就会在容器中创建canvas\n container: string | HTMLElement;\n // 是否是受控制的canvas,如果不是的话,不会进行resize等操作,也不会修改canvas的样式\n canvasControled: boolean;\n title: string;\n // 是否开启自动渲染\n autoRender: boolean;\n // 是否开启布局支持\n enableLayout: boolean;\n // 是否关闭脏矩形检测\n disableDirtyBounds: boolean;\n // 是否支持interactiveLayer,默认为true\n interactiveLayer: boolean;\n // 是否支持HTML属性\n enableHtmlAttribute: string | boolean | HTMLElement;\n // 是否支持滚动条\n enableScroll: boolean;\n poptip: boolean;\n // 绘制之前的钩子函数\n beforeRender: (stage: IStage) => void;\n // 绘制之后的钩子函数\n afterRender: (stage: IStage) => void;\n renderStyle?: string;\n ticker?: ITicker;\n pluginList?: string[];\n // 优化配置\n optimize?: IOptimizeType;\n /**\n * 事件系统相关配置\n */\n event?: EventConfig;\n}\n\nexport type EventConfig = {\n /** 是否自动阻止事件 */\n autoPreventDefault?: boolean;\n /**\n * 多次点击之间的最大时间,默认为 200 ms\n * @default 200\n */\n clickInterval?: number;\n [key: string]: any;\n};\n\nexport type IOptimizeType = {\n // 视口不在可视区,跳过渲染,默认为true\n skipRenderWithOutRange?: boolean;\n // 跳过图元在区间外的判断\n // 不存在dirtyBounds的时候,根据该配置判断是否关闭图元的超出边界判定\n // 如果有dirtyBounds那么该配置不生效\n disableCheckGraphicWidthOutRange?: boolean;\n};\n\nexport interface IOption3D {\n enableView3dTransform?: boolean; // 是否开启view3d自动旋转\n alpha?: number; // x轴的转角\n beta?: number; // y轴的转角\n gama?: number; // z轴的转角\n center?: { x?: number; y?: number; z?: number; dx?: number; dy?: number; dz?: number }; // 中心位置\n fieldRatio?: number; // 透视的视域缩放比例\n fieldDepth?: number;\n light?: {\n dir?: vec3;\n color?: string;\n ambient?: number;\n };\n // 配置相机后,alpha、beta、gamma配置会失效\n camera?: any; // 相机配置\n}\n\n// TODO 命名方式\nexport interface IStage extends INode {\n stage?: IStage;\n parent: IStage | null;\n // rootNode: IStage;\n x: number;\n y: number;\n\n params: Partial<IStageParams>;\n\n window: IWindow;\n\n width: number;\n height: number;\n viewWidth: number;\n viewHeight: number;\n defaultLayer: ILayer;\n dirtyBounds: IBounds | null;\n\n autoRender: boolean;\n renderCount: number;\n\n hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n option3d?: IOption3D;\n\n set3dOptions: (options: IOption3D) => void;\n light?: IDirectionLight;\n camera?: ICamera;\n\n dpr: number;\n\n viewBox: IBoundsLike;\n background: string | IColor;\n ticker: ITicker;\n increaseAutoRender: boolean;\n readonly renderService: IRenderService;\n pickerService?: IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer: (canvasId?: string, layerMode?: LayerMode) => ILayer;\n getLayer: (name: string) => ILayer;\n sortLayer: (cb: (layer1: ILayer, layer2: ILayer) => number) => void;\n removeLayer: (layerId: number) => ILayer | false;\n\n getTimeline: () => ITimeline;\n\n render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;\n /**\n * 下一帧渲染\n * @param layers 渲染的图层\n * @param force 是否强行下一帧渲染,不采取优化方案\n * @returns\n */\n renderNextFrame: (layers?: ILayer[], force?: boolean) => void;\n tryInitInteractiveLayer: () => void;\n\n // 画布操作\n resize: (w: number, h: number, rerender?: boolean) => void;\n resizeWindow: (w: number, h: number, rerender?: boolean) => void;\n resizeView: (w: number, h: number, rerender?: boolean) => void;\n setViewBox:\n | ((viewBox: IBoundsLike, rerender: boolean) => void)\n | ((x: number, y: number, w: number, h: number, rerender: boolean) => void)\n | ((x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean) => void);\n setDpr: (dpr: number, rerender?: boolean) => void;\n setOrigin: (x: number, y: number) => void;\n export: (type: IExportType) => HTMLCanvasElement | ImageData;\n pick: (x: number, y: number) => PickResult | false;\n\n // 动画相关\n startAnimate: (t: number) => void;\n setToFrame: (t: number) => void;\n dirty: (b: IBounds, matrix?: IMatrix) => void;\n // 考虑操作回放\n\n renderTo: (window: IWindow, params: { x: number; y: number; width: number; height: number }) => void;\n\n renderToNewWindow: (fullImage?: boolean) => IWindow;\n\n toCanvas: (fullImage?: boolean, viewBox?: IAABBBounds) => HTMLCanvasElement | null;\n\n setBeforeRender: (cb: (stage: IStage) => void) => void;\n\n setAfterRender: (cb: (stage: IStage) => void) => void;\n\n afterNextRender: (cb: (stage: IStage) => void) => void;\n enableAutoRender: () => void;\n disableAutoRender: () => void;\n enableIncrementalAutoRender: () => void;\n disableIncrementalAutoRender: () => void;\n enableDirtyBounds: () => void;\n disableDirtyBounds: () => void;\n enableView3dTransform: () => void;\n disableView3dTranform: () => void;\n clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => void;\n\n setCursor: (mode?: string) => void;\n\n getTheme: () => IFullThemeSpec;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
|
|
@@ -175,13 +175,14 @@ let DefaultDrawContribution = class {
|
|
|
175
175
|
return this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);
|
|
176
176
|
}
|
|
177
177
|
clearScreen(renderService, context, drawContext) {
|
|
178
|
-
var _a;
|
|
178
|
+
var _a, _b;
|
|
179
179
|
const {clear: clear} = drawContext;
|
|
180
180
|
if (clear) {
|
|
181
181
|
const canvas = context.getCanvas(), {width: width = canvas.width, height: height = canvas.height} = drawContext, x = 0, y = 0;
|
|
182
182
|
context.clearRect(x, y, width, height);
|
|
183
183
|
const stage = null === (_a = renderService.drawParams) || void 0 === _a ? void 0 : _a.stage;
|
|
184
|
-
if (stage &&
|
|
184
|
+
if (stage && (context.globalAlpha = null !== (_b = stage.attribute.opacity) && void 0 !== _b ? _b : 1),
|
|
185
|
+
stage && stage.backgroundImg && stage.resources) {
|
|
185
186
|
const res = stage.resources.get(clear);
|
|
186
187
|
res && "success" === res.state && res.data && context.drawImage(res.data, x, y, width, height);
|
|
187
188
|
} else context.fillStyle = (0, canvas_utils_1.createColor)(context, clear, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAAwF;AAgBxF,+CAAgE;AAEhE,iFAA6E;AAC7E,8CAAoD;AAEpD,6CAA2F;AAE3F,kDAA+C;AAC/C,qCAAsF;AACtF,yDAAyD;AACzD,+DAA2D;AAE3D,wEAAoE;AACpE,wEAAoE;AACpE,sDAAmD;AAM5C,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAclC,YAIiD,aAA+B,EAK3D,gCAAyF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E,KAAK,EAAE,MAAM,CAAC,CAAC;YACvC,MAAM,KAAK,GAAG,MAAA,aAAa,CAAC,UAAU,0CAAE,KAAK,CAAC;YAC9C,IAAI,KAAK,IAAK,KAAa,CAAC,aAAa,IAAK,KAAa,CAAC,SAAS,EAAE;gBACrE,MAAM,GAAG,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,IAAA,0BAAW,EAC7B,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;AAnZY,uBAAuB;IADnC,IAAA,2BAAU,GAAE;IAmBR,WAAA,IAAA,4BAAW,EAAC,sBAAa,CAAC,CAAA;IAG1B,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,sCAAmB,CAAC,CAAA;;GAtBlB,uBAAuB,CAmZnC;AAnZY,0DAAuB","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 // if (context.drawPromise) {\n // return;\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 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 // 设置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 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 = this.renderSelector.selector(graphic);\n let renderer;\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType);\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): IGraphicRender | null {\n return 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 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,mEAAwF;AAgBxF,+CAAgE;AAEhE,iFAA6E;AAC7E,8CAAoD;AAEpD,6CAA2F;AAE3F,kDAA+C;AAC/C,qCAAsF;AACtF,yDAAyD;AACzD,+DAA2D;AAE3D,wEAAoE;AACpE,wEAAoE;AACpE,sDAAmD;AAM5C,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAclC,YAIiD,aAA+B,EAK3D,gCAAyF;QAL7D,kBAAa,GAAb,aAAa,CAAkB;QAK3D,qCAAgC,GAAhC,gCAAgC,CAAyD;QAE5G,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,IAAI,eAAM,EAAE,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,eAAM,EAAE,CAAC;QACtC,I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C;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,IAAA,0BAAW,EAC7B,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;AApZY,uBAAuB;IADnC,IAAA,2BAAU,GAAE;IAmBR,WAAA,IAAA,4BAAW,EAAC,sBAAa,CAAC,CAAA;IAG1B,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,sCAAmB,CAAC,CAAA;;GAtBlB,uBAAuB,CAoZnC;AApZY,0DAAuB","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 // if (context.drawPromise) {\n // return;\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 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 // 设置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 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 = this.renderSelector.selector(graphic);\n let renderer;\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType);\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): IGraphicRender | null {\n return 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"]}
|
|
@@ -22,7 +22,6 @@ export declare class DefaultIncrementalDrawContribution extends DefaultDrawContr
|
|
|
22
22
|
protected lastDrawContext: IDrawContext;
|
|
23
23
|
protected count: number;
|
|
24
24
|
constructor(contributions: IGraphicRender[], lineRender: IGraphicRender, areaRender: IGraphicRender, drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>);
|
|
25
|
-
init(): void;
|
|
26
25
|
draw(renderService: IRenderService, drawContext: IDrawContext): Promise<void>;
|
|
27
26
|
protected _increaseRender(group: IGroup, drawContext: IDrawContext): Promise<void>;
|
|
28
27
|
protected _renderIncrementalGroup(group: IGroup, drawContext: IDrawContext): Promise<void>;
|
|
@@ -55,11 +55,7 @@ let DefaultIncrementalDrawContribution = class extends draw_contribution_1.Defau
|
|
|
55
55
|
this.rendering = !1, this.currFrameStartAt = 0, this.currentIdx = 0, this.status = STATUS.NORMAL,
|
|
56
56
|
this.checkingForDrawPromise = null, this.hooks = {
|
|
57
57
|
completeDraw: new tapable_1.SyncHook([])
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
init() {
|
|
61
|
-
super.init(), this.defaultRenderMap.set(this.lineRender.numberType, this.lineRender),
|
|
62
|
-
this.defaultRenderMap.set(this.areaRender.numberType, this.areaRender);
|
|
58
|
+
}, this.defaultRenderMap.set(this.lineRender.numberType, this.lineRender), this.defaultRenderMap.set(this.areaRender.numberType, this.areaRender);
|
|
63
59
|
}
|
|
64
60
|
draw(renderService, drawContext) {
|
|
65
61
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/incremental-draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAwF;AAaxF,8CAAoD;AAEpD,2DAA8D;AAC9D,8CAA4C;AAC5C,qCAAyD;AACzD,uEAA+E;AAC/E,uEAA+E;AAC/E,yDAAyD;AAEzD,iFAA6E;AAC7E,+CAAoD;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,2CAAuB;IAa7E,YAIiD,aAA+B,EAEf,UAA0B,EAC1B,UAA0B,EAItE,gCAAyF;QAE5G,KAAK,CAAC,aAAa,EAAE,gCAAgC,CAAC,CAAC;QATR,kBAAa,GAAb,aAAa,CAAkB;QAEf,eAAU,GAAV,UAAU,CAAgB;QAC1B,eAAU,GAAV,UAAU,CAAgB;QAItE,qCAAgC,GAAhC,gCAAgC,CAAyD;QAvB9G,cAAS,GAAY,KAAK,CAAC;QACjB,qBAAgB,GAAW,CAAC,CAAC;QAC7B,eAAU,GAAW,CAAC,CAAC;QACvB,WAAM,GAAW,MAAM,CAAC,MAAM,CAAC;QAC/B,2BAAsB,GAAwB,IAAI,CAAC;QAC7D,UAAK,GAAG;YACN,YAAY,EAAE,IAAI,kBAAQ,CAAK,EAAE,CAAC;SACnC,CAAC;IAmBF,CAAC;IAED,IAAI;QACF,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACvE,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,UAA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AC,sBAAa,CAAC,CAAA;IAE1B,WAAA,IAAA,uBAAM,EAAC,4DAAkC,CAAC,CAAA;IAC1C,WAAA,IAAA,uBAAM,EAAC,4DAAkC,CAAC,CAAA;IAE1C,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,sCAAmB,CAAC,CAAA;;GAvBlB,kCAAkC,CAmQ9C;AAnQY,gFAAkC","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 }\n\n init(): void {\n super.init();\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 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(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 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"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/incremental-draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAwF;AAaxF,8CAAoD;AAEpD,2DAA8D;AAC9D,8CAA4C;AAC5C,qCAAyD;AACzD,uEAA+E;AAC/E,uEAA+E;AAC/E,yDAAyD;AAEzD,iFAA6E;AAC7E,+CAAoD;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,2CAAuB;IAa7E,YAIiD,aAA+B,EAEf,UAA0B,EAC1B,UAA0B,EAItE,gCAAyF;QAE5G,KAAK,CAAC,aAAa,EAAE,gCAAgC,CAAC,CAAC;QATR,kBAAa,GAAb,aAAa,CAAkB;QAEf,eAAU,GAAV,UAAU,CAAgB;QAC1B,eAAU,GAAV,UAAU,CAAgB;QAItE,qCAAgC,GAAhC,gCAAgC,CAAyD;QAvB9G,cAAS,GAAY,KAAK,CAAC;QACjB,qBAAgB,GAAW,CAAC,CAAC;QAC7B,eAAU,GAAW,CAAC,CAAC;QACvB,WAAM,GAAW,MAAM,CAAC,MAAM,CAAC;QAC/B,2BAAsB,GAAwB,IAAI,CAAC;QAC7D,UAAK,GAAG;YACN,YAAY,EAAE,IAAI,kBAAQ,CAAK,EAAE,CAAC;SACnC,CAAC;QAmBA,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,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;CAQF,CAAA;AA/PY,kCAAkC;IAD9C,IAAA,2BAAU,GAAE;IAkBR,WAAA,IAAA,4BAAW,EAAC,sBAAa,CAAC,CAAA;IAE1B,WAAA,IAAA,uBAAM,EAAC,4DAAkC,CAAC,CAAA;IAC1C,WAAA,IAAA,uBAAM,EAAC,4DAAkC,CAAC,CAAA;IAE1C,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,sCAAmB,CAAC,CAAA;;GAvBlB,kCAAkC,CA+P9C;AA/PY,gFAAkC","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 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(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 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"]}
|
package/es/interface/stage.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { IPickerService, PickResult } from './picker';
|
|
|
12
12
|
import type { IPluginService } from './plugin';
|
|
13
13
|
import type { IWindow } from './window';
|
|
14
14
|
import type { ILayerService } from './core';
|
|
15
|
+
import type { IFullThemeSpec } from './graphic/theme';
|
|
15
16
|
export type IExportType = 'canvas' | 'imageData';
|
|
16
17
|
export interface IStageParams {
|
|
17
18
|
viewBox: IBoundsLike;
|
|
@@ -143,6 +144,7 @@ export interface IStage extends INode {
|
|
|
143
144
|
release: () => void;
|
|
144
145
|
setStage: (stage?: IStage) => void;
|
|
145
146
|
setCursor: (mode?: string) => void;
|
|
147
|
+
getTheme: () => IFullThemeSpec;
|
|
146
148
|
}
|
|
147
149
|
export declare function combineStage(srages: IStage[], params: {
|
|
148
150
|
canvas: string | HTMLCanvasElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer, LayerMode } from './layer';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer, LayerMode } from './layer';\nimport type { IColor } from './color';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix } from '@visactor/vutils';\nimport type { ICamera } from './camera';\nimport type { vec3 } from './matrix';\nimport type { IDirectionLight } from './light';\nimport type { ISyncHook } from './sync-hook';\nimport type { IDrawContext, IRenderService } from './render';\nimport type { ITicker, ITimeline } from './animate';\nimport type { IPickerService, PickResult } from './picker';\nimport type { IPluginService } from './plugin';\nimport type { IWindow } from './window';\nimport type { ILayerService } from './core';\nimport type { IFullThemeSpec } from './graphic/theme';\n\nexport type IExportType = 'canvas' | 'imageData';\n\nexport interface IStageParams {\n // x: number;\n // y: number;\n // // 视口的宽高\n // viewWidth: number;\n // viewHeight: number;\n\n // 视口的宽高\n viewBox: IBoundsLike;\n // 总的宽高\n width: number;\n height: number;\n dpr: number;\n // stage的背景\n background: string | IColor;\n // 外部的canvas\n canvas: string | HTMLCanvasElement;\n // canvas的container容器,如果不传入canvas,那就会在容器中创建canvas\n container: string | HTMLElement;\n // 是否是受控制的canvas,如果不是的话,不会进行resize等操作,也不会修改canvas的样式\n canvasControled: boolean;\n title: string;\n // 是否开启自动渲染\n autoRender: boolean;\n // 是否开启布局支持\n enableLayout: boolean;\n // 是否关闭脏矩形检测\n disableDirtyBounds: boolean;\n // 是否支持interactiveLayer,默认为true\n interactiveLayer: boolean;\n // 是否支持HTML属性\n enableHtmlAttribute: string | boolean | HTMLElement;\n // 是否支持滚动条\n enableScroll: boolean;\n poptip: boolean;\n // 绘制之前的钩子函数\n beforeRender: (stage: IStage) => void;\n // 绘制之后的钩子函数\n afterRender: (stage: IStage) => void;\n renderStyle?: string;\n ticker?: ITicker;\n pluginList?: string[];\n // 优化配置\n optimize?: IOptimizeType;\n /**\n * 事件系统相关配置\n */\n event?: EventConfig;\n}\n\nexport type EventConfig = {\n /** 是否自动阻止事件 */\n autoPreventDefault?: boolean;\n /**\n * 多次点击之间的最大时间,默认为 200 ms\n * @default 200\n */\n clickInterval?: number;\n [key: string]: any;\n};\n\nexport type IOptimizeType = {\n // 视口不在可视区,跳过渲染,默认为true\n skipRenderWithOutRange?: boolean;\n // 跳过图元在区间外的判断\n // 不存在dirtyBounds的时候,根据该配置判断是否关闭图元的超出边界判定\n // 如果有dirtyBounds那么该配置不生效\n disableCheckGraphicWidthOutRange?: boolean;\n};\n\nexport interface IOption3D {\n enableView3dTransform?: boolean; // 是否开启view3d自动旋转\n alpha?: number; // x轴的转角\n beta?: number; // y轴的转角\n gama?: number; // z轴的转角\n center?: { x?: number; y?: number; z?: number; dx?: number; dy?: number; dz?: number }; // 中心位置\n fieldRatio?: number; // 透视的视域缩放比例\n fieldDepth?: number;\n light?: {\n dir?: vec3;\n color?: string;\n ambient?: number;\n };\n // 配置相机后,alpha、beta、gamma配置会失效\n camera?: any; // 相机配置\n}\n\n// TODO 命名方式\nexport interface IStage extends INode {\n stage?: IStage;\n parent: IStage | null;\n // rootNode: IStage;\n x: number;\n y: number;\n\n params: Partial<IStageParams>;\n\n window: IWindow;\n\n width: number;\n height: number;\n viewWidth: number;\n viewHeight: number;\n defaultLayer: ILayer;\n dirtyBounds: IBounds | null;\n\n autoRender: boolean;\n renderCount: number;\n\n hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n option3d?: IOption3D;\n\n set3dOptions: (options: IOption3D) => void;\n light?: IDirectionLight;\n camera?: ICamera;\n\n dpr: number;\n\n viewBox: IBoundsLike;\n background: string | IColor;\n ticker: ITicker;\n increaseAutoRender: boolean;\n readonly renderService: IRenderService;\n pickerService?: IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer: (canvasId?: string, layerMode?: LayerMode) => ILayer;\n getLayer: (name: string) => ILayer;\n sortLayer: (cb: (layer1: ILayer, layer2: ILayer) => number) => void;\n removeLayer: (layerId: number) => ILayer | false;\n\n getTimeline: () => ITimeline;\n\n render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;\n /**\n * 下一帧渲染\n * @param layers 渲染的图层\n * @param force 是否强行下一帧渲染,不采取优化方案\n * @returns\n */\n renderNextFrame: (layers?: ILayer[], force?: boolean) => void;\n tryInitInteractiveLayer: () => void;\n\n // 画布操作\n resize: (w: number, h: number, rerender?: boolean) => void;\n resizeWindow: (w: number, h: number, rerender?: boolean) => void;\n resizeView: (w: number, h: number, rerender?: boolean) => void;\n setViewBox:\n | ((viewBox: IBoundsLike, rerender: boolean) => void)\n | ((x: number, y: number, w: number, h: number, rerender: boolean) => void)\n | ((x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean) => void);\n setDpr: (dpr: number, rerender?: boolean) => void;\n setOrigin: (x: number, y: number) => void;\n export: (type: IExportType) => HTMLCanvasElement | ImageData;\n pick: (x: number, y: number) => PickResult | false;\n\n // 动画相关\n startAnimate: (t: number) => void;\n setToFrame: (t: number) => void;\n dirty: (b: IBounds, matrix?: IMatrix) => void;\n // 考虑操作回放\n\n renderTo: (window: IWindow, params: { x: number; y: number; width: number; height: number }) => void;\n\n renderToNewWindow: (fullImage?: boolean) => IWindow;\n\n toCanvas: (fullImage?: boolean, viewBox?: IAABBBounds) => HTMLCanvasElement | null;\n\n setBeforeRender: (cb: (stage: IStage) => void) => void;\n\n setAfterRender: (cb: (stage: IStage) => void) => void;\n\n afterNextRender: (cb: (stage: IStage) => void) => void;\n enableAutoRender: () => void;\n disableAutoRender: () => void;\n enableIncrementalAutoRender: () => void;\n disableIncrementalAutoRender: () => void;\n enableDirtyBounds: () => void;\n disableDirtyBounds: () => void;\n enableView3dTransform: () => void;\n disableView3dTranform: () => void;\n clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => void;\n\n setCursor: (mode?: string) => void;\n\n getTheme: () => IFullThemeSpec;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
|
|
@@ -190,13 +190,14 @@ let DefaultDrawContribution = class {
|
|
|
190
190
|
return this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);
|
|
191
191
|
}
|
|
192
192
|
clearScreen(renderService, context, drawContext) {
|
|
193
|
-
var _a;
|
|
193
|
+
var _a, _b;
|
|
194
194
|
const {clear: clear} = drawContext;
|
|
195
195
|
if (clear) {
|
|
196
196
|
const canvas = context.getCanvas(), {width: width = canvas.width, height: height = canvas.height} = drawContext, x = 0, y = 0;
|
|
197
197
|
context.clearRect(x, y, width, height);
|
|
198
198
|
const stage = null === (_a = renderService.drawParams) || void 0 === _a ? void 0 : _a.stage;
|
|
199
|
-
if (stage &&
|
|
199
|
+
if (stage && (context.globalAlpha = null !== (_b = stage.attribute.opacity) && void 0 !== _b ? _b : 1),
|
|
200
|
+
stage && stage.backgroundImg && stage.resources) {
|
|
200
201
|
const res = stage.resources.get(clear);
|
|
201
202
|
res && "success" === res.state && res.data && context.drawImage(res.data, x, y, width, height);
|
|
202
203
|
} else context.fillStyle = createColor(context, clear, {
|
|
@@ -1 +1 @@
|
|
|
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,gCAAgC,CAAC;AAgBxF,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAQ,MAAM,kBAAkB,CAAC;AAE3F,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,2BAA2B,EAAkB,MAAM,UAAU,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE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BAAuB","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 // if (context.drawPromise) {\n // return;\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 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 // 设置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 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 = this.renderSelector.selector(graphic);\n let renderer;\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType);\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): IGraphicRender | null {\n return 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 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,gCAAgC,CAAC;AAgBxF,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAQ,MAAM,kBAAkB,CAAC;AAE3F,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,2BAA2B,EAAkB,MAAM,UAAU,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAA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AA;AApZY,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,CAoZnC;SApZY,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 // if (context.drawPromise) {\n // return;\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 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 // 设置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 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 = this.renderSelector.selector(graphic);\n let renderer;\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType);\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): IGraphicRender | null {\n return 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"]}
|
|
@@ -22,7 +22,6 @@ export declare class DefaultIncrementalDrawContribution extends DefaultDrawContr
|
|
|
22
22
|
protected lastDrawContext: IDrawContext;
|
|
23
23
|
protected count: number;
|
|
24
24
|
constructor(contributions: IGraphicRender[], lineRender: IGraphicRender, areaRender: IGraphicRender, drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>);
|
|
25
|
-
init(): void;
|
|
26
25
|
draw(renderService: IRenderService, drawContext: IDrawContext): Promise<void>;
|
|
27
26
|
protected _increaseRender(group: IGroup, drawContext: IDrawContext): Promise<void>;
|
|
28
27
|
protected _renderIncrementalGroup(group: IGroup, drawContext: IDrawContext): Promise<void>;
|
|
@@ -65,11 +65,7 @@ let DefaultIncrementalDrawContribution = class extends DefaultDrawContribution {
|
|
|
65
65
|
this.rendering = !1, this.currFrameStartAt = 0, this.currentIdx = 0, this.status = STATUS.NORMAL,
|
|
66
66
|
this.checkingForDrawPromise = null, this.hooks = {
|
|
67
67
|
completeDraw: new SyncHook([])
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
init() {
|
|
71
|
-
super.init(), this.defaultRenderMap.set(this.lineRender.numberType, this.lineRender),
|
|
72
|
-
this.defaultRenderMap.set(this.areaRender.numberType, this.areaRender);
|
|
68
|
+
}, this.defaultRenderMap.set(this.lineRender.numberType, this.lineRender), this.defaultRenderMap.set(this.areaRender.numberType, this.areaRender);
|
|
73
69
|
}
|
|
74
70
|
draw(renderService, drawContext) {
|
|
75
71
|
return __awaiter(this, void 0, void 0, (function*() {
|
|
@@ -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,CAAC;AAC7E,OAAO,EAAE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AK,IAAI,KAAK,CAAC,SAAS,CAAC,UAAU,KAAK,KAAK,EAAE;gBAC7D,OAAO;aACR;YACD,IAAI,KAAK,CAAC,WAAW,IAAI,WAAW,CAAC,SAAS,KAAK,KAAK,CAAC,IAAI,EAAE;gBAC7D,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;gBAC/C,WAAW,CAAC,KAAK,GAAG,IAAI,CAAC;gBACzB,OAAO;aACR;YAED,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;gBAC1B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE;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;AAnQY,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,CAmQ9C;SAnQY,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 }\n\n init(): void {\n super.init();\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 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(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 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"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/incremental-draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,K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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, 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 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(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 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"]}
|