@visactor/vrender-core 0.22.7-alpha.3 → 0.23.0-alpha.3
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/canvas/constants.js +1 -2
- package/cjs/canvas/empty-context.d.ts +1 -0
- package/cjs/canvas/empty-context.js +4 -0
- package/cjs/canvas/empty-context.js.map +1 -1
- package/cjs/color-string/interpolate.d.ts +1 -0
- package/cjs/color-string/interpolate.js +7 -2
- package/cjs/color-string/interpolate.js.map +1 -1
- package/cjs/color-string/store.js +2 -1
- package/cjs/common/enums.js +1 -2
- package/cjs/common/performance-raf.d.ts +8 -0
- package/cjs/common/performance-raf.js +31 -0
- package/cjs/common/performance-raf.js.map +1 -0
- package/cjs/common/render-area.js +1 -0
- package/cjs/common/store.js +1 -2
- package/cjs/common/text.js +1 -1
- package/cjs/common/utils.js +1 -1
- package/cjs/core/application.js +1 -1
- package/cjs/core/camera.js +1 -1
- package/cjs/core/constants.js +1 -1
- package/cjs/core/core-modules.js +1 -1
- package/cjs/core/global-module.js +0 -2
- package/cjs/core/global.d.ts +3 -0
- package/cjs/core/global.js +13 -3
- package/cjs/core/global.js.map +1 -1
- package/cjs/core/stage.d.ts +3 -1
- package/cjs/core/stage.js +24 -19
- package/cjs/core/stage.js.map +1 -1
- package/cjs/event/event-system.js +7 -6
- package/cjs/event/event-system.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +4 -3
- package/cjs/graphic/graphic.js +16 -22
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/index.d.ts +1 -3
- package/cjs/index.js +16 -17
- package/cjs/index.js.map +1 -1
- package/cjs/interface/animate.d.ts +5 -0
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/context.d.ts +1 -0
- package/cjs/interface/context.js.map +1 -1
- package/cjs/interface/global.d.ts +2 -0
- package/cjs/interface/global.js.map +1 -1
- package/cjs/interface/graphic.d.ts +3 -1
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/index.d.ts +1 -1
- package/cjs/interface/index.js +9 -9
- package/cjs/interface/index.js.map +1 -1
- package/cjs/interface/render.d.ts +6 -0
- package/cjs/interface/render.js.map +1 -1
- package/cjs/interface/stage.d.ts +1 -0
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -2
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +6 -5
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/cjs/render/contributions/render/arc-render.d.ts +4 -2
- package/cjs/render/contributions/render/arc-render.js +19 -17
- package/cjs/render/contributions/render/arc-render.js.map +1 -1
- package/cjs/render/contributions/render/base-render.d.ts +2 -2
- package/cjs/render/contributions/render/base-render.js +2 -2
- package/cjs/render/contributions/render/base-render.js.map +1 -1
- package/cjs/render/contributions/render/draw-contribution.d.ts +1 -0
- package/cjs/render/contributions/render/draw-contribution.js +23 -19
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/draw-interceptor.js +1 -0
- package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
- package/cjs/render/contributions/render/group-render.d.ts +2 -2
- package/cjs/render/contributions/render/group-render.js +14 -10
- package/cjs/render/contributions/render/group-render.js.map +1 -1
- package/cjs/render/contributions/render/rect-render.d.ts +3 -1
- package/cjs/render/contributions/render/rect-render.js +17 -15
- package/cjs/render/contributions/render/rect-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.d.ts +4 -2
- package/cjs/render/contributions/render/symbol-render.js +16 -11
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/dist/index.es.js +2507 -5202
- package/es/canvas/constants.js +1 -2
- package/es/canvas/empty-context.d.ts +1 -0
- package/es/canvas/empty-context.js +4 -0
- package/es/canvas/empty-context.js.map +1 -1
- package/es/color-string/interpolate.d.ts +1 -0
- package/es/color-string/interpolate.js +4 -0
- package/es/color-string/interpolate.js.map +1 -1
- package/es/color-string/store.js +2 -1
- package/es/common/enums.js +1 -2
- package/es/common/performance-raf.d.ts +8 -0
- package/es/common/performance-raf.js +23 -0
- package/es/common/performance-raf.js.map +1 -0
- package/es/common/render-area.js +2 -1
- package/es/common/store.js +1 -2
- package/es/common/text.js +1 -1
- package/es/common/utils.js +1 -1
- package/es/core/application.js +1 -1
- package/es/core/camera.js +1 -1
- package/es/core/constants.js +1 -1
- package/es/core/core-modules.js +1 -1
- package/es/core/global-module.js +0 -2
- package/es/core/global.d.ts +3 -0
- package/es/core/global.js +14 -2
- package/es/core/global.js.map +1 -1
- package/es/core/stage.d.ts +3 -1
- package/es/core/stage.js +23 -21
- package/es/core/stage.js.map +1 -1
- package/es/event/event-system.js +7 -6
- package/es/event/event-system.js.map +1 -1
- package/es/graphic/graphic.d.ts +4 -3
- package/es/graphic/graphic.js +17 -23
- package/es/graphic/graphic.js.map +1 -1
- package/es/index.d.ts +1 -3
- package/es/index.js +2 -6
- package/es/index.js.map +1 -1
- package/es/interface/animate.d.ts +5 -0
- package/es/interface/animate.js.map +1 -1
- package/es/interface/context.d.ts +1 -0
- package/es/interface/context.js.map +1 -1
- package/es/interface/global.d.ts +2 -0
- package/es/interface/global.js.map +1 -1
- package/es/interface/graphic.d.ts +3 -1
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/index.d.ts +1 -1
- package/es/interface/index.js +2 -2
- package/es/interface/index.js.map +1 -1
- package/es/interface/render.d.ts +6 -0
- package/es/interface/render.js.map +1 -1
- package/es/interface/stage.d.ts +1 -0
- package/es/interface/stage.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -2
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +4 -5
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/es/render/contributions/render/arc-render.d.ts +4 -2
- package/es/render/contributions/render/arc-render.js +19 -17
- package/es/render/contributions/render/arc-render.js.map +1 -1
- package/es/render/contributions/render/base-render.d.ts +2 -2
- package/es/render/contributions/render/base-render.js +2 -2
- package/es/render/contributions/render/base-render.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.d.ts +1 -0
- package/es/render/contributions/render/draw-contribution.js +23 -19
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/draw-interceptor.js +1 -0
- package/es/render/contributions/render/draw-interceptor.js.map +1 -1
- package/es/render/contributions/render/group-render.d.ts +2 -2
- package/es/render/contributions/render/group-render.js +14 -10
- package/es/render/contributions/render/group-render.js.map +1 -1
- package/es/render/contributions/render/rect-render.d.ts +3 -1
- package/es/render/contributions/render/rect-render.js +17 -14
- package/es/render/contributions/render/rect-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.d.ts +4 -2
- package/es/render/contributions/render/symbol-render.js +16 -11
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/package.json +3 -3
- package/cjs/animate/Ticker/default-ticker.d.ts +0 -40
- package/cjs/animate/Ticker/default-ticker.js +0 -140
- package/cjs/animate/Ticker/default-ticker.js.map +0 -1
- package/cjs/animate/Ticker/index.d.ts +0 -5
- package/cjs/animate/Ticker/index.js +0 -23
- package/cjs/animate/Ticker/index.js.map +0 -1
- package/cjs/animate/Ticker/manual-ticker-handler.d.ts +0 -15
- package/cjs/animate/Ticker/manual-ticker-handler.js +0 -36
- package/cjs/animate/Ticker/manual-ticker-handler.js.map +0 -1
- package/cjs/animate/Ticker/manual-ticker.d.ts +0 -19
- package/cjs/animate/Ticker/manual-ticker.js +0 -37
- package/cjs/animate/Ticker/manual-ticker.js.map +0 -1
- package/cjs/animate/Ticker/raf-tick-handler.d.ts +0 -9
- package/cjs/animate/Ticker/raf-tick-handler.js +0 -30
- package/cjs/animate/Ticker/raf-tick-handler.js.map +0 -1
- package/cjs/animate/Ticker/timeout-tick-handler.d.ts +0 -9
- package/cjs/animate/Ticker/timeout-tick-handler.js +0 -28
- package/cjs/animate/Ticker/timeout-tick-handler.js.map +0 -1
- package/cjs/animate/Ticker/type.d.ts +0 -6
- package/cjs/animate/Ticker/type.js +0 -11
- package/cjs/animate/Ticker/type.js.map +0 -1
- package/cjs/animate/animate.d.ts +0 -147
- package/cjs/animate/animate.js +0 -403
- package/cjs/animate/animate.js.map +0 -1
- package/cjs/animate/custom-animate.d.ts +0 -236
- package/cjs/animate/custom-animate.js +0 -722
- package/cjs/animate/custom-animate.js.map +0 -1
- package/cjs/animate/default-ticker.d.ts +0 -2
- package/cjs/animate/default-ticker.js +0 -14
- package/cjs/animate/default-ticker.js.map +0 -1
- package/cjs/animate/easing-func.d.ts +0 -1
- package/cjs/animate/easing-func.js +0 -16
- package/cjs/animate/easing-func.js.map +0 -1
- package/cjs/animate/easing.d.ts +0 -49
- package/cjs/animate/easing.js +0 -141
- package/cjs/animate/easing.js.map +0 -1
- package/cjs/animate/group-fade.d.ts +0 -16
- package/cjs/animate/group-fade.js +0 -66
- package/cjs/animate/group-fade.js.map +0 -1
- package/cjs/animate/index.d.ts +0 -8
- package/cjs/animate/index.js +0 -24
- package/cjs/animate/index.js.map +0 -1
- package/cjs/animate/morphing.d.ts +0 -52
- package/cjs/animate/morphing.js +0 -292
- package/cjs/animate/morphing.js.map +0 -1
- package/cjs/animate/timeline.d.ts +0 -17
- package/cjs/animate/timeline.js +0 -46
- package/cjs/animate/timeline.js.map +0 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +0 -1
- package/es/animate/Ticker/default-ticker.d.ts +0 -40
- package/es/animate/Ticker/default-ticker.js +0 -138
- package/es/animate/Ticker/default-ticker.js.map +0 -1
- package/es/animate/Ticker/index.d.ts +0 -5
- package/es/animate/Ticker/index.js +0 -10
- package/es/animate/Ticker/index.js.map +0 -1
- package/es/animate/Ticker/manual-ticker-handler.d.ts +0 -15
- package/es/animate/Ticker/manual-ticker-handler.js +0 -28
- package/es/animate/Ticker/manual-ticker-handler.js.map +0 -1
- package/es/animate/Ticker/manual-ticker.d.ts +0 -19
- package/es/animate/Ticker/manual-ticker.js +0 -31
- package/es/animate/Ticker/manual-ticker.js.map +0 -1
- package/es/animate/Ticker/raf-tick-handler.d.ts +0 -9
- package/es/animate/Ticker/raf-tick-handler.js +0 -22
- package/es/animate/Ticker/raf-tick-handler.js.map +0 -1
- package/es/animate/Ticker/timeout-tick-handler.d.ts +0 -9
- package/es/animate/Ticker/timeout-tick-handler.js +0 -20
- package/es/animate/Ticker/timeout-tick-handler.js.map +0 -1
- package/es/animate/Ticker/type.d.ts +0 -6
- package/es/animate/Ticker/type.js +0 -7
- package/es/animate/Ticker/type.js.map +0 -1
- package/es/animate/animate.d.ts +0 -147
- package/es/animate/animate.js +0 -398
- package/es/animate/animate.js.map +0 -1
- package/es/animate/custom-animate.d.ts +0 -236
- package/es/animate/custom-animate.js +0 -699
- package/es/animate/custom-animate.js.map +0 -1
- package/es/animate/default-ticker.d.ts +0 -2
- package/es/animate/default-ticker.js +0 -12
- package/es/animate/default-ticker.js.map +0 -1
- package/es/animate/easing-func.d.ts +0 -1
- package/es/animate/easing-func.js +0 -10
- package/es/animate/easing-func.js.map +0 -1
- package/es/animate/easing.d.ts +0 -49
- package/es/animate/easing.js +0 -134
- package/es/animate/easing.js.map +0 -1
- package/es/animate/group-fade.d.ts +0 -16
- package/es/animate/group-fade.js +0 -56
- package/es/animate/group-fade.js.map +0 -1
- package/es/animate/index.d.ts +0 -8
- package/es/animate/index.js +0 -16
- package/es/animate/index.js.map +0 -1
- package/es/animate/morphing.d.ts +0 -52
- package/es/animate/morphing.js +0 -295
- package/es/animate/morphing.js.map +0 -1
- package/es/animate/timeline.d.ts +0 -17
- package/es/animate/timeline.js +0 -42
- package/es/animate/timeline.js.map +0 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
- package/es/plugins/builtin-plugin/rich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C,EACD,WAAW,CACZ,CAAC;SACH;aAAM;YACL,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SACnD;QACD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,WAAW,CAAC,eAAe,GAAG,KAAK,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds } from '@visactor/vutils';\nimport { mat3Tomat4, multiplyMat4Mat4 } from '../../../common/matrix';\nimport { graphicCreator } from '../../../graphic/graphic-creator';\nimport type {\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate, matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { draw3dItem } from '../../../common/3d-interceptor';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx < 0\n ) {\n return false;\n }\n if (\n graphic.attribute.shadowRootIdx > 0 ||\n !graphic.attribute.shadowRootIdx ||\n (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0)\n ) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx > 0\n ) {\n return false;\n }\n if (graphic.attribute.shadowRootIdx < 0 || (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0)) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n // 一直往上找\n let intree = !!baseGraphic.stage;\n let _g = baseGraphic.parent;\n while (intree && _g) {\n if ((_g as any).stage === _g) {\n break;\n }\n intree = !!_g.stage;\n _g = _g.parent;\n }\n if (!intree) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n draw3dItem(\n context,\n graphic,\n (isPie: boolean, is3d: boolean) => {\n return drawContribution.renderGroup(\n graphic as IGroup,\n drawContext,\n graphic.parent.globalTransMatrix,\n !isPie && is3d\n );\n },\n drawContext\n );\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAYlE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAG5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AASrE,MAAM,eAAe,GAAG,IAAI,UAAU,EAAE,CAAC;AACzC,MAAM,qBAAqB,GA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AK,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds } from '@visactor/vutils';\nimport { mat3Tomat4, multiplyMat4Mat4 } from '../../../common/matrix';\nimport { graphicCreator } from '../../../graphic/graphic-creator';\nimport type {\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate, matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { draw3dItem } from '../../../common/3d-interceptor';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx < 0\n ) {\n return false;\n }\n if (\n graphic.attribute.shadowRootIdx > 0 ||\n !graphic.attribute.shadowRootIdx ||\n (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0)\n ) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx > 0\n ) {\n return false;\n }\n if (graphic.attribute.shadowRootIdx < 0 || (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0)) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n // 一直往上找\n let intree = !!baseGraphic.stage;\n let _g = baseGraphic.parent;\n while (intree && _g) {\n if ((_g as any).stage === _g) {\n break;\n }\n intree = !!_g.stage;\n _g = _g.parent;\n }\n if (!intree) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n draw3dItem(\n context,\n graphic,\n (isPie: boolean, is3d: boolean) => {\n return drawContribution.renderGroup(\n graphic as IGroup,\n drawContext,\n graphic.parent.globalTransMatrix,\n !isPie && is3d\n );\n },\n drawContext\n );\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { IGraphicAttribute, IContext2d, IGroup, IMarkAttribute, IThemeAttribute, IGroupRenderContribution, IDrawContext, IRenderService, IGraphicRender, IGraphicRenderDrawParams, IContributionProvider } from '../../../interface';
|
|
1
|
+
import type { IGraphicAttribute, IContext2d, IGroup, IMarkAttribute, IThemeAttribute, IGroupRenderContribution, IDrawContext, IRenderService, IGraphicRender, IGraphicRenderDrawParams, IContributionProvider, IGroupGraphicAttribute } from '../../../interface';
|
|
2
2
|
export declare class DefaultCanvasGroupRender implements IGraphicRender {
|
|
3
3
|
protected readonly groupRenderContribitions: IContributionProvider<IGroupRenderContribution>;
|
|
4
4
|
type: 'group';
|
|
5
5
|
numberType: number;
|
|
6
6
|
_groupRenderContribitions: IGroupRenderContribution[];
|
|
7
7
|
constructor(groupRenderContribitions: IContributionProvider<IGroupRenderContribution>);
|
|
8
|
-
drawShape(group: IGroup, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
8
|
+
drawShape(group: IGroup, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, groupAttribute?: Required<IGroupGraphicAttribute>): void;
|
|
9
9
|
draw(group: IGroup, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
|
|
10
10
|
}
|
|
@@ -42,8 +42,11 @@ let DefaultCanvasGroupRender = class {
|
|
|
42
42
|
constructor(groupRenderContribitions) {
|
|
43
43
|
this.groupRenderContribitions = groupRenderContribitions, this.numberType = GROUP_NUMBER_TYPE;
|
|
44
44
|
}
|
|
45
|
-
drawShape(group, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
46
|
-
const
|
|
45
|
+
drawShape(group, context, x, y, drawContext, params, fillCb, strokeCb, groupAttribute) {
|
|
46
|
+
const {clip: clip, fill: fill, stroke: stroke, background: background} = group.attribute;
|
|
47
|
+
if (!(clip || fill || stroke || background)) return;
|
|
48
|
+
groupAttribute = null != groupAttribute ? groupAttribute : getTheme(group, null == params ? void 0 : params.theme).group;
|
|
49
|
+
const {opacity: opacity = groupAttribute.opacity, width: width = groupAttribute.width, height: height = groupAttribute.height, fillOpacity: fillOpacity = groupAttribute.fillOpacity, strokeOpacity: strokeOpacity = groupAttribute.strokeOpacity, cornerRadius: cornerRadius = groupAttribute.cornerRadius, path: path = groupAttribute.path, lineWidth: lineWidth = groupAttribute.lineWidth, visible: visible = groupAttribute.visible, fillStrokeOrder: fillStrokeOrder = groupAttribute.fillStrokeOrder, cornerType: cornerType = groupAttribute.cornerType, x: originX = groupAttribute.x, y: originY = groupAttribute.y} = group.attribute, fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill), sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height), doFill = runFill(fill, background), doStroke = runStroke(stroke, lineWidth);
|
|
47
50
|
if (!group.valid || !visible) return;
|
|
48
51
|
if (!clip) {
|
|
49
52
|
if (!doFill && !doStroke) return;
|
|
@@ -79,11 +82,12 @@ let DefaultCanvasGroupRender = class {
|
|
|
79
82
|
}));
|
|
80
83
|
}
|
|
81
84
|
draw(group, renderService, drawContext, params) {
|
|
85
|
+
var _a;
|
|
82
86
|
const {context: context} = drawContext;
|
|
83
87
|
if (!context) return;
|
|
84
|
-
const {clip: clip, baseOpacity: baseOpacity = 1, drawMode: drawMode
|
|
88
|
+
const {clip: clip, baseOpacity: baseOpacity = 1, drawMode: drawMode} = group.attribute, lastNativeContext = context.nativeContext, lastNativeCanvas = context.canvas.nativeCanvas;
|
|
85
89
|
if (drawMode > 0) {
|
|
86
|
-
const canvas = context.canvas, newCanvas = vglobal.createCanvas({
|
|
90
|
+
const {x: x, y: y, width: width, height: height} = group.attribute, canvas = context.canvas, newCanvas = vglobal.createCanvas({
|
|
87
91
|
width: canvas.width,
|
|
88
92
|
height: canvas.height,
|
|
89
93
|
dpr: 1
|
|
@@ -97,20 +101,20 @@ let DefaultCanvasGroupRender = class {
|
|
|
97
101
|
clip ? context.save() : context.highPerformanceSave();
|
|
98
102
|
const baseGlobalAlpha = context.baseGlobalAlpha;
|
|
99
103
|
context.baseGlobalAlpha *= baseOpacity;
|
|
100
|
-
const
|
|
104
|
+
const lastModelMatrix = context.modelMatrix;
|
|
101
105
|
if (context.camera) {
|
|
102
|
-
const nextModelMatrix = mat4Allocate.allocate(), modelMatrix = mat4Allocate.allocate();
|
|
106
|
+
const groupAttribute = getTheme(group, null == params ? void 0 : params.theme).group, nextModelMatrix = mat4Allocate.allocate(), modelMatrix = mat4Allocate.allocate();
|
|
103
107
|
getModelMatrix(modelMatrix, group, groupAttribute), multiplyMat4Mat4(nextModelMatrix, lastModelMatrix || nextModelMatrix, modelMatrix),
|
|
104
108
|
context.modelMatrix = nextModelMatrix, mat4Allocate.free(modelMatrix), context.setTransform(1, 0, 0, 1, 0, 0, !0);
|
|
105
109
|
} else context.transformFromMatrix(group.transMatrix, !0);
|
|
106
|
-
context.beginPath(), params.skipDraw ? this.drawShape(group, context, 0, 0, drawContext, params, (() => !1), (() => !1)) : this.drawShape(group, context, 0, 0, drawContext);
|
|
107
|
-
const {scrollX: scrollX
|
|
110
|
+
context.beginPath(), params.skipDraw ? this.drawShape(group, context, 0, 0, drawContext, params, (() => !1), (() => !1)) : this.drawShape(group, context, 0, 0, drawContext, null, null, null);
|
|
111
|
+
const {scrollX: scrollX, scrollY: scrollY} = group.attribute;
|
|
108
112
|
let p;
|
|
109
|
-
if ((scrollX || scrollY) && context.translate(scrollX, scrollY), params && params.
|
|
113
|
+
if ((scrollX || scrollY) && context.translate(scrollX, scrollY), params && params.renderInGroup && (p = params.renderInGroup(params.skipDraw, group, drawContext, null === (_a = params.renderInGroupParams) || void 0 === _a ? void 0 : _a.nextM)),
|
|
110
114
|
context.modelMatrix !== lastModelMatrix && mat4Allocate.free(context.modelMatrix),
|
|
111
115
|
context.modelMatrix = lastModelMatrix, context.baseGlobalAlpha = baseGlobalAlpha,
|
|
112
116
|
drawMode > 0) {
|
|
113
|
-
const newContext = context.nativeContext, newCanvas = context.canvas.nativeCanvas;
|
|
117
|
+
const {x: x, y: y, width: width, height: height} = group.attribute, newContext = context.nativeContext, newCanvas = context.canvas.nativeCanvas;
|
|
114
118
|
lastNativeContext.save(), lastNativeContext.setTransform(context.dpr, 0, 0, context.dpr, 0, 0, !0),
|
|
115
119
|
1 === drawMode && newContext.rect(x, y, width, height), lastNativeContext.drawImage(newCanvas, 0, 0, newCanvas.width, newCanvas.height, 0, 0, context.canvas.displayWidth, context.canvas.displayHeight);
|
|
116
120
|
const transform = newContext.getTransform();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/group-render.ts"],"names":[],"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E,MAAM,CAAC,CAAC;aACtC;YACD,iBAAiB,CAAC,SAAS,CACzB,SAAS,EACT,CAAC,EACD,CAAC,EACD,SAAS,CAAC,KAAK,EACf,SAAS,CAAC,MAAM,EAChB,CAAC,EACD,CAAC,EACD,OAAO,CAAC,MAAM,CAAC,YAAY,EAC3B,OAAO,CAAC,MAAM,CAAC,aAAa,CAC7B,CAAC;YACF,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC;YAC5C,iBAAiB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;YAC7G,OAAO,CAAC,aAAa,GAAG,iBAAiB,CAAC;YAC1C,OAAO,CAAC,MAAM,CAAC,YAAY,GAAG,gBAAgB,CAAC;YAC/C,iBAAiB,CAAC,OAAO,EAAE,CAAC;SAC7B;QAED,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE;YACf,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBACV,IAAI,IAAI,EAAE;oBACR,OAAO,CAAC,OAAO,EAAE,CAAC;iBACnB;qBAAM;oBACL,OAAO,CAAC,sBAAsB,EAAE,CAAC;iBAClC;YACH,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,IAAI,EAAE;gBACR,OAAO,CAAC,OAAO,EAAE,CAAC;aACnB;iBAAM;gBACL,OAAO,CAAC,sBAAsB,EAAE,CAAC;aAClC;SACF;IACH,CAAC;CACF,CAAA;AAxWY,wBAAwB;IADpC,UAAU,EAAE;IAQR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,uBAAuB,CAAC,CAAA;;GARtB,wBAAwB,CAwWpC;SAxWY,wBAAwB","file":"group-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IMarkAttribute,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { getModelMatrix } from '../../../graphic/graphic-service/graphic-service';\nimport { isArray } from '@visactor/vutils';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { GroupRenderContribution } from './contributions/constants';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { GROUP_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { defaultGroupBackgroundRenderContribution } from './contributions';\nimport { multiplyMat4Mat4 } from '../../../common/matrix';\nimport { vglobal } from '../../../modules';\n\n@injectable()\nexport class DefaultCanvasGroupRender implements IGraphicRender {\n type: 'group';\n numberType: number = GROUP_NUMBER_TYPE;\n\n _groupRenderContribitions: IGroupRenderContribution[];\n\n constructor(\n @inject(ContributionProvider)\n @named(GroupRenderContribution)\n protected readonly groupRenderContribitions: IContributionProvider<IGroupRenderContribution>\n ) {}\n\n drawShape(\n group: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const groupAttribute = graphicService.themeService.getCurrentTheme().groupAttribute;\n const groupAttribute = getTheme(group, params?.theme).group;\n const {\n fill = groupAttribute.fill,\n background,\n stroke = groupAttribute.stroke,\n opacity = groupAttribute.opacity,\n width = groupAttribute.width,\n height = groupAttribute.height,\n clip = groupAttribute.clip,\n fillOpacity = groupAttribute.fillOpacity,\n strokeOpacity = groupAttribute.strokeOpacity,\n cornerRadius = groupAttribute.cornerRadius,\n path = groupAttribute.path,\n lineWidth = groupAttribute.lineWidth,\n visible = groupAttribute.visible,\n fillStrokeOrder = groupAttribute.fillStrokeOrder,\n cornerType = groupAttribute.cornerType,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y\n } = group.attribute;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(group.valid && visible)) {\n return;\n }\n\n if (!clip) {\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n }\n\n if (path && path.length && drawContext.drawContribution) {\n // 禁用fill和stroke\n const disableFill = context.disableFill;\n const disableStroke = context.disableStroke;\n const disableBeginPath = context.disableBeginPath;\n context.disableFill = true;\n context.disableStroke = true;\n context.disableBeginPath = true;\n path.forEach(g => {\n const rc = drawContext.drawContribution.getRenderContribution(g);\n rc.draw(g, drawContext.renderService, drawContext, params);\n });\n context.disableFill = disableFill;\n context.disableStroke = disableStroke;\n context.disableBeginPath = disableBeginPath;\n } else if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');\n }\n\n if (!this._groupRenderContribitions) {\n this._groupRenderContribitions = this.groupRenderContribitions.getContributions() || [];\n this._groupRenderContribitions.push(defaultGroupBackgroundRenderContribution);\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.beforeFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n }\n });\n\n // beforeFillStroke contribition可以操作clip范围\n if (clip) {\n context.clip();\n }\n\n const _runFill = () => {\n if ((doFillOrStroke as any).doFill) {\n if (fillCb) {\n fillCb(context, group.attribute, groupAttribute);\n } else if (fVisible) {\n context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.fill();\n }\n }\n };\n\n const _runStroke = () => {\n if ((doFillOrStroke as any).doStroke) {\n if (strokeCb) {\n strokeCb(context, group.attribute, groupAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.afterFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n }\n\n draw(group: IGroup, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n // debugger;\n const { clip, baseOpacity = 1, drawMode, x, y, width, height } = group.attribute;\n const lastNativeContext = context.nativeContext;\n const lastNativeCanvas = context.canvas.nativeCanvas;\n\n if (drawMode > 0) {\n // 绘制到新的Canvas上,然后再绘制回来\n const canvas = context.canvas;\n const newCanvas = vglobal.createCanvas({ width: canvas.width, height: canvas.height, dpr: 1 });\n const newContext = newCanvas.getContext('2d');\n const transform = context.nativeContext.getTransform();\n // 首先应用transform\n newContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n // 然后将背景绘制到新的canvas上,只绘制group的Bounds区域\n // 如果drawMode === 1,则需要背景\n // 如果drawMode === 2,则不需要背景,只需要group即可\n if (drawMode === 1) {\n newContext.save();\n newContext.clearRect(0, 0, canvas.width, canvas.height);\n newContext.beginPath();\n\n newContext.rect(x, y, width, height);\n newContext.clip();\n newContext.drawImage(\n canvas.nativeCanvas,\n 0,\n 0,\n canvas.width,\n canvas.height,\n 0,\n 0,\n canvas.displayWidth,\n canvas.displayHeight\n );\n newContext.restore();\n }\n // 狸猫换太子,把新的context赋值给context\n context.nativeContext = newContext;\n canvas.nativeCanvas = newCanvas;\n }\n if (clip) {\n context.save();\n } else {\n context.highPerformanceSave();\n }\n const baseGlobalAlpha = context.baseGlobalAlpha;\n context.baseGlobalAlpha *= baseOpacity;\n\n const groupAttribute = getTheme(group, params?.theme).group;\n\n // const lastMatrix = context.modelMatrix;\n // if (context.camera) {\n // const m = group.transMatrix;\n // const matrix = createMat4();\n // mat3Tomat4(matrix, m);\n // const lastModelMatrix = context.modelMatrix;\n // if (lastModelMatrix) {\n // if (matrix) {\n // const m = createMat4();\n // context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n // }\n // } else {\n // context.modelMatrix = matrix;\n // }\n // } else {\n // // group直接transform\n // context.transformFromMatrix(group.transMatrix, true);\n // }\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n if (camera) {\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, group, groupAttribute);\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n context.modelMatrix = nextModelMatrix;\n mat4Allocate.free(modelMatrix);\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n // group直接transform\n context.transformFromMatrix(group.transMatrix, true);\n }\n\n context.beginPath();\n // 如果跳过绘制,那就不绘制\n if (params.skipDraw) {\n this.drawShape(\n group,\n context,\n 0,\n 0,\n drawContext,\n params,\n () => false,\n () => false\n );\n } else {\n this.drawShape(group, context, 0, 0, drawContext);\n }\n\n // 绘制子元素的时候要添加scroll\n const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = group.attribute;\n if (scrollX || scrollY) {\n context.translate(scrollX, scrollY);\n }\n let p: any;\n if (params && params.drawingCb) {\n p = params.drawingCb();\n }\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.baseGlobalAlpha = baseGlobalAlpha;\n\n if (drawMode > 0) {\n // 将原始的context和canvas恢复,另外将newCanvas上的内容绘制到lastCanvas上\n const newContext = context.nativeContext;\n const newCanvas = context.canvas.nativeCanvas;\n lastNativeContext.save();\n lastNativeContext.setTransform(context.dpr, 0, 0, context.dpr, 0, 0, true);\n // 如果drawMode === 1,则需要清一下之前的背景,否则背景就重复绘制了一次\n if (drawMode === 1) {\n newContext.rect(x, y, width, height);\n }\n lastNativeContext.drawImage(\n newCanvas,\n 0,\n 0,\n newCanvas.width,\n newCanvas.height,\n 0,\n 0,\n context.canvas.displayWidth,\n context.canvas.displayHeight\n );\n const transform = newContext.getTransform();\n lastNativeContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n context.nativeContext = lastNativeContext;\n context.canvas.nativeCanvas = lastNativeCanvas;\n lastNativeContext.restore();\n }\n\n if (p && p.then) {\n p.then(() => {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n });\n } else {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/group-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAe3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,wCAAwC,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGpC,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAMnC,YAGqB,wBAAyE;QAAzE,6BAAwB,GAAxB,wBAAwB,CAAiD;QAP9F,eAAU,GAAW,iBAAiB,CAAC;IAQpC,CAAC;IAEJ,SAAS,CACP,KAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY,EACZ,cAAiD;QAGjD,MAAM,EAAE,IA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E,CAAC;iBACnB;qBAAM;oBACL,OAAO,CAAC,sBAAsB,EAAE,CAAC;iBAClC;YACH,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,IAAI,EAAE;gBACR,OAAO,CAAC,OAAO,EAAE,CAAC;aACnB;iBAAM;gBACL,OAAO,CAAC,sBAAsB,EAAE,CAAC;aAClC;SACF;IACH,CAAC;CACF,CAAA;AA5WY,wBAAwB;IADpC,UAAU,EAAE;IAQR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,uBAAuB,CAAC,CAAA;;GARtB,wBAAwB,CA4WpC;SA5WY,wBAAwB","file":"group-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IMarkAttribute,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n IGroupGraphicAttribute\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { getModelMatrix } from '../../../graphic/graphic-service/graphic-service';\nimport { isArray } from '@visactor/vutils';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { GroupRenderContribution } from './contributions/constants';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { GROUP_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { defaultGroupBackgroundRenderContribution } from './contributions';\nimport { multiplyMat4Mat4 } from '../../../common/matrix';\nimport { vglobal } from '../../../modules';\n\n@injectable()\nexport class DefaultCanvasGroupRender implements IGraphicRender {\n type: 'group';\n numberType: number = GROUP_NUMBER_TYPE;\n\n _groupRenderContribitions: IGroupRenderContribution[];\n\n constructor(\n @inject(ContributionProvider)\n @named(GroupRenderContribution)\n protected readonly groupRenderContribitions: IContributionProvider<IGroupRenderContribution>\n ) {}\n\n drawShape(\n group: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n groupAttribute?: Required<IGroupGraphicAttribute>\n ) {\n // 提前判定,否则每次都要获取一堆属性\n const { clip, fill, stroke, background } = group.attribute;\n\n if (!(clip || fill || stroke || background)) {\n return;\n }\n\n groupAttribute = groupAttribute ?? getTheme(group, params?.theme).group;\n\n const {\n opacity = groupAttribute.opacity,\n width = groupAttribute.width,\n height = groupAttribute.height,\n fillOpacity = groupAttribute.fillOpacity,\n strokeOpacity = groupAttribute.strokeOpacity,\n cornerRadius = groupAttribute.cornerRadius,\n path = groupAttribute.path,\n lineWidth = groupAttribute.lineWidth,\n visible = groupAttribute.visible,\n fillStrokeOrder = groupAttribute.fillStrokeOrder,\n cornerType = groupAttribute.cornerType,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y\n } = group.attribute;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(group.valid && visible)) {\n return;\n }\n\n if (!clip) {\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n }\n\n if (path && path.length && drawContext.drawContribution) {\n // 禁用fill和stroke\n const disableFill = context.disableFill;\n const disableStroke = context.disableStroke;\n const disableBeginPath = context.disableBeginPath;\n context.disableFill = true;\n context.disableStroke = true;\n context.disableBeginPath = true;\n path.forEach(g => {\n const rc = drawContext.drawContribution.getRenderContribution(g);\n rc.draw(g, drawContext.renderService, drawContext, params);\n });\n context.disableFill = disableFill;\n context.disableStroke = disableStroke;\n context.disableBeginPath = disableBeginPath;\n } else if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');\n }\n\n if (!this._groupRenderContribitions) {\n this._groupRenderContribitions = this.groupRenderContribitions.getContributions() || [];\n this._groupRenderContribitions.push(defaultGroupBackgroundRenderContribution);\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.beforeFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n }\n });\n\n // beforeFillStroke contribition可以操作clip范围\n if (clip) {\n context.clip();\n }\n\n const _runFill = () => {\n if ((doFillOrStroke as any).doFill) {\n if (fillCb) {\n fillCb(context, group.attribute, groupAttribute);\n } else if (fVisible) {\n context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.fill();\n }\n }\n };\n\n const _runStroke = () => {\n if ((doFillOrStroke as any).doStroke) {\n if (strokeCb) {\n strokeCb(context, group.attribute, groupAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.afterFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n }\n\n draw(group: IGroup, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n const { clip, baseOpacity = 1, drawMode } = group.attribute;\n const lastNativeContext = context.nativeContext;\n const lastNativeCanvas = context.canvas.nativeCanvas;\n\n if (drawMode > 0) {\n const { x, y, width, height } = group.attribute;\n // 绘制到新的Canvas上,然后再绘制回来\n const canvas = context.canvas;\n const newCanvas = vglobal.createCanvas({ width: canvas.width, height: canvas.height, dpr: 1 });\n const newContext = newCanvas.getContext('2d');\n const transform = context.nativeContext.getTransform();\n // 首先应用transform\n newContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n // 然后将背景绘制到新的canvas上,只绘制group的Bounds区域\n // 如果drawMode === 1,则需要背景\n // 如果drawMode === 2,则不需要背景,只需要group即可\n if (drawMode === 1) {\n newContext.save();\n newContext.clearRect(0, 0, canvas.width, canvas.height);\n newContext.beginPath();\n\n newContext.rect(x, y, width, height);\n newContext.clip();\n newContext.drawImage(\n canvas.nativeCanvas,\n 0,\n 0,\n canvas.width,\n canvas.height,\n 0,\n 0,\n canvas.displayWidth,\n canvas.displayHeight\n );\n newContext.restore();\n }\n // 狸猫换太子,把新的context赋值给context\n context.nativeContext = newContext;\n canvas.nativeCanvas = newCanvas;\n }\n if (clip) {\n context.save();\n } else {\n context.highPerformanceSave();\n }\n const baseGlobalAlpha = context.baseGlobalAlpha;\n context.baseGlobalAlpha *= baseOpacity;\n\n // const lastMatrix = context.modelMatrix;\n // if (context.camera) {\n // const m = group.transMatrix;\n // const matrix = createMat4();\n // mat3Tomat4(matrix, m);\n // const lastModelMatrix = context.modelMatrix;\n // if (lastModelMatrix) {\n // if (matrix) {\n // const m = createMat4();\n // context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n // }\n // } else {\n // context.modelMatrix = matrix;\n // }\n // } else {\n // // group直接transform\n // context.transformFromMatrix(group.transMatrix, true);\n // }\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n if (camera) {\n const groupAttribute = getTheme(group, params?.theme).group;\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, group, groupAttribute);\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n context.modelMatrix = nextModelMatrix;\n mat4Allocate.free(modelMatrix);\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n // group直接transform\n context.transformFromMatrix(group.transMatrix, true);\n }\n\n context.beginPath();\n // 如果跳过绘制,那就不绘制\n if (params.skipDraw) {\n this.drawShape(\n group,\n context,\n 0,\n 0,\n drawContext,\n params,\n () => false,\n () => false\n );\n } else {\n this.drawShape(group, context, 0, 0, drawContext, null, null, null);\n }\n\n // 绘制子元素的时候要添加scroll\n const { scrollX, scrollY } = group.attribute;\n if (scrollX || scrollY) {\n context.translate(scrollX, scrollY);\n }\n let p: any;\n if (params && params.renderInGroup) {\n p = params.renderInGroup(params.skipDraw, group, drawContext, params.renderInGroupParams?.nextM);\n }\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.baseGlobalAlpha = baseGlobalAlpha;\n\n if (drawMode > 0) {\n const { x, y, width, height } = group.attribute;\n // 将原始的context和canvas恢复,另外将newCanvas上的内容绘制到lastCanvas上\n const newContext = context.nativeContext;\n const newCanvas = context.canvas.nativeCanvas;\n lastNativeContext.save();\n lastNativeContext.setTransform(context.dpr, 0, 0, context.dpr, 0, 0, true);\n // 如果drawMode === 1,则需要清一下之前的背景,否则背景就重复绘制了一次\n if (drawMode === 1) {\n newContext.rect(x, y, width, height);\n }\n lastNativeContext.drawImage(\n newCanvas,\n 0,\n 0,\n newCanvas.width,\n newCanvas.height,\n 0,\n 0,\n context.canvas.displayWidth,\n context.canvas.displayHeight\n );\n const transform = newContext.getTransform();\n lastNativeContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n context.nativeContext = lastNativeContext;\n context.canvas.nativeCanvas = lastNativeCanvas;\n lastNativeContext.restore();\n }\n\n if (p && p.then) {\n p.then(() => {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n });\n } else {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n }\n }\n}\n"]}
|
|
@@ -6,6 +6,8 @@ export declare class DefaultCanvasRectRender extends BaseRender<IRect> implement
|
|
|
6
6
|
numberType: number;
|
|
7
7
|
tempTheme: Required<IRectGraphicAttribute>;
|
|
8
8
|
constructor(rectRenderContribitions: IContributionProvider<IRectRenderContribution>);
|
|
9
|
-
drawShape(rect: IRect, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
9
|
+
drawShape(rect: IRect, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, rectAttribute?: Required<IRectGraphicAttribute>): void;
|
|
10
|
+
private _runFill;
|
|
11
|
+
private _runStroke;
|
|
10
12
|
draw(rect: IRect, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
|
|
11
13
|
}
|
|
@@ -36,9 +36,9 @@ let DefaultCanvasRectRender = class extends BaseRender {
|
|
|
36
36
|
this.numberType = RECT_NUMBER_TYPE, this.builtinContributions = [ defaultRectRenderContribution, defaultRectBackgroundRenderContribution, defaultRectTextureRenderContribution ],
|
|
37
37
|
this.init(rectRenderContribitions);
|
|
38
38
|
}
|
|
39
|
-
drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
40
|
-
|
|
41
|
-
const
|
|
39
|
+
drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb, rectAttribute) {
|
|
40
|
+
rectAttribute = null != rectAttribute ? rectAttribute : getTheme(rect, null == params ? void 0 : params.theme).rect;
|
|
41
|
+
const {fill: fill = rectAttribute.fill, background: background, stroke: stroke = rectAttribute.stroke, cornerRadius: cornerRadius = rectAttribute.cornerRadius, cornerType: cornerType = rectAttribute.cornerType, opacity: opacity = rectAttribute.opacity, fillOpacity: fillOpacity = rectAttribute.fillOpacity, lineWidth: lineWidth = rectAttribute.lineWidth, strokeOpacity: strokeOpacity = rectAttribute.strokeOpacity, visible: visible = rectAttribute.visible, x1: x1, y1: y1, x: originX = rectAttribute.x, y: originY = rectAttribute.y, fillStrokeOrder: fillStrokeOrder = rectAttribute.fillStrokeOrder} = rect.attribute;
|
|
42
42
|
let {width: width, height: height} = rect.attribute;
|
|
43
43
|
width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
|
|
44
44
|
const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill), sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height), doFill = runFill(fill, background), doStroke = runStroke(stroke, lineWidth);
|
|
@@ -52,20 +52,23 @@ let DefaultCanvasRectRender = class extends BaseRender {
|
|
|
52
52
|
doStroke: doStroke
|
|
53
53
|
};
|
|
54
54
|
context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute),
|
|
55
|
-
this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke),
|
|
56
|
+
fillStrokeOrder ? (this._runStroke(rect, context, x, y, rectAttribute, doFillOrStroke, sVisible, originX, originY, strokeCb),
|
|
57
|
+
this._runFill(rect, context, x, y, rectAttribute, doFillOrStroke, fVisible, originX, originY, fillCb)) : (this._runFill(rect, context, x, y, rectAttribute, doFillOrStroke, fVisible, originX, originY, fillCb),
|
|
58
|
+
this._runStroke(rect, context, x, y, rectAttribute, doFillOrStroke, sVisible, originX, originY, strokeCb)),
|
|
59
|
+
this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
60
|
+
}
|
|
61
|
+
_runFill(rect, context, x, y, rectAttribute, doFillOrStroke, fVisible, originX, originY, fillCb) {
|
|
62
|
+
doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute),
|
|
63
|
+
context.fill()));
|
|
64
|
+
}
|
|
65
|
+
_runStroke(rect, context, x, y, rectAttribute, doFillOrStroke, sVisible, originX, originY, strokeCb) {
|
|
66
|
+
doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute),
|
|
67
|
+
context.stroke()));
|
|
64
68
|
}
|
|
65
69
|
draw(rect, renderService, drawContext, params) {
|
|
66
70
|
const rectAttribute = getTheme(rect, null == params ? void 0 : params.theme).rect;
|
|
67
|
-
this.
|
|
68
|
-
this.tempTheme = null;
|
|
71
|
+
this._draw(rect, rectAttribute, !1, drawContext, params, rectAttribute);
|
|
69
72
|
}
|
|
70
73
|
};
|
|
71
74
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/rect-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAe7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,uCAAuC,EACvC,6BAA6B,EAC7B,oCAAoC,EACrC,MAAM,iBAAiB,CAAC;AAGlB,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,UAAiB;IAK5D,YAGqB,uBAAuE;QAE1F,KAAK,EAAE,CAAC;QAFW,4BAAuB,GAAvB,uBAAuB,CAAgD;QAP5F,SAAI,GAAG,MAAM,CAAC;QACd,eAAU,GAAW,gBAAgB,CAAC;QASpC,IAAI,CAAC,oB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,aAAa,EACb,WAAW,EACX,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,IAAW,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC3G,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,IAAI,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF,CAAA;AAtKY,uBAAuB;IADnC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,sBAAsB,CAAC,CAAA;;GAPrB,uBAAuB,CAsKnC;SAtKY,uBAAuB","file":"rect-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { RECT_NUMBER_TYPE } from '../../../graphic/constants';\nimport { createRectPath } from '../../../common/shape/rect';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IRect,\n IThemeAttribute,\n IGraphicRender,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService,\n IRectRenderContribution,\n IContributionProvider,\n IRectGraphicAttribute\n} from '../../../interface';\nimport { RectRenderContribution } from './contributions/constants';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { BaseRender } from './base-render';\nimport {\n defaultRectBackgroundRenderContribution,\n defaultRectRenderContribution,\n defaultRectTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasRectRender extends BaseRender<IRect> implements IGraphicRender {\n type = 'rect';\n numberType: number = RECT_NUMBER_TYPE;\n tempTheme: Required<IRectGraphicAttribute>;\n\n constructor(\n @inject(ContributionProvider)\n @named(RectRenderContribution)\n protected readonly rectRenderContribitions: IContributionProvider<IRectRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultRectRenderContribution,\n defaultRectBackgroundRenderContribution,\n defaultRectTextureRenderContribution\n ];\n this.init(rectRenderContribitions);\n }\n\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const rectAttribute = this.tempTheme ?? getTheme(rect, params?.theme).rect;\n const {\n fill = rectAttribute.fill,\n background,\n stroke = rectAttribute.stroke,\n cornerRadius = rectAttribute.cornerRadius,\n cornerType = rectAttribute.cornerType,\n opacity = rectAttribute.opacity,\n fillOpacity = rectAttribute.fillOpacity,\n lineWidth = rectAttribute.lineWidth,\n strokeOpacity = rectAttribute.strokeOpacity,\n visible = rectAttribute.visible,\n x1,\n y1,\n x: originX = rectAttribute.x,\n y: originY = rectAttribute.y,\n fillStrokeOrder = rectAttribute.fillStrokeOrder\n } = rect.attribute;\n let { width, height } = rect.attribute;\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(rect.valid && visible)) {\n return;\n }\n\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n this.beforeRenderStep(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n\n const _runFill = () => {\n if (doFillOrStroke.doFill) {\n if (fillCb) {\n fillCb(context, rect.attribute, rectAttribute);\n } else if (fVisible) {\n // 存在fill\n context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n context.fill();\n }\n }\n };\n const _runStroke = () => {\n if (doFillOrStroke.doStroke) {\n if (strokeCb) {\n strokeCb(context, rect.attribute, rectAttribute);\n } else if (sVisible) {\n // 存在stroke\n context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this.afterRenderStep(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(rect: IRect, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const rectAttribute = getTheme(rect, params?.theme).rect;\n this.tempTheme = rectAttribute;\n this._draw(rect, rectAttribute, false, drawContext, params);\n this.tempTheme = null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources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EACT,CAAS,EACT,aAA8C,EAC9C,cAAsD,EACtD,QAAiB,EACjB,OAAe,EACf,OAAe,EACf,QAIY;QAEZ,IAAI,cAAc,CAAC,QAAQ,EAAE;YAC3B,IAAI,QAAQ,EAAE;gBACZ,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;aAClD;iBAAM,IAAI,QAAQ,EAAE;gBAEnB,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;gBACtF,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;SACF;IACH,CAAC;IAED,IAAI,CAAC,IAAW,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC3G,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,IAAI,CAAC;QACzD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IAC7E,CAAC;CACF,CAAA;AA5NY,uBAAuB;IADnC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,sBAAsB,CAAC,CAAA;;GAPrB,uBAAuB,CA4NnC;SA5NY,uBAAuB","file":"rect-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { RECT_NUMBER_TYPE } from '../../../graphic/constants';\nimport { createRectPath } from '../../../common/shape/rect';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IRect,\n IThemeAttribute,\n IGraphicRender,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService,\n IRectRenderContribution,\n IContributionProvider,\n IRectGraphicAttribute\n} from '../../../interface';\nimport { RectRenderContribution } from './contributions/constants';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { BaseRender } from './base-render';\nimport {\n defaultRectBackgroundRenderContribution,\n defaultRectRenderContribution,\n defaultRectTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasRectRender extends BaseRender<IRect> implements IGraphicRender {\n type = 'rect';\n numberType: number = RECT_NUMBER_TYPE;\n tempTheme: Required<IRectGraphicAttribute>;\n\n constructor(\n @inject(ContributionProvider)\n @named(RectRenderContribution)\n protected readonly rectRenderContribitions: IContributionProvider<IRectRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultRectRenderContribution,\n defaultRectBackgroundRenderContribution,\n defaultRectTextureRenderContribution\n ];\n this.init(rectRenderContribitions);\n }\n\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n rectAttribute?: Required<IRectGraphicAttribute>\n ) {\n rectAttribute = rectAttribute ?? getTheme(rect, params?.theme).rect;\n const {\n fill = rectAttribute.fill,\n background,\n stroke = rectAttribute.stroke,\n cornerRadius = rectAttribute.cornerRadius,\n cornerType = rectAttribute.cornerType,\n opacity = rectAttribute.opacity,\n fillOpacity = rectAttribute.fillOpacity,\n lineWidth = rectAttribute.lineWidth,\n strokeOpacity = rectAttribute.strokeOpacity,\n visible = rectAttribute.visible,\n x1,\n y1,\n x: originX = rectAttribute.x,\n y: originY = rectAttribute.y,\n fillStrokeOrder = rectAttribute.fillStrokeOrder\n } = rect.attribute;\n let { width, height } = rect.attribute;\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(rect.valid && visible)) {\n return;\n }\n\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n this.beforeRenderStep(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n\n // 内联的函数性能差\n // const _runFill = () => {\n // if (doFillOrStroke.doFill) {\n // if (fillCb) {\n // fillCb(context, rect.attribute, rectAttribute);\n // } else if (fVisible) {\n // // 存在fill\n // context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n // context.fill();\n // }\n // }\n // };\n // const _runStroke = () => {\n // if (doFillOrStroke.doStroke) {\n // if (strokeCb) {\n // strokeCb(context, rect.attribute, rectAttribute);\n // } else if (sVisible) {\n // // 存在stroke\n // context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n // context.stroke();\n // }\n // }\n // };\n\n if (!fillStrokeOrder) {\n this._runFill(rect, context, x, y, rectAttribute, doFillOrStroke, fVisible, originX, originY, fillCb);\n this._runStroke(rect, context, x, y, rectAttribute, doFillOrStroke, sVisible, originX, originY, strokeCb);\n } else {\n this._runStroke(rect, context, x, y, rectAttribute, doFillOrStroke, sVisible, originX, originY, strokeCb);\n this._runFill(rect, context, x, y, rectAttribute, doFillOrStroke, fVisible, originX, originY, fillCb);\n }\n\n this.afterRenderStep(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n private _runFill(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n rectAttribute: Required<IRectGraphicAttribute>,\n doFillOrStroke: { doFill: boolean; doStroke: boolean },\n fVisible: boolean,\n originX: number,\n originY: number,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (doFillOrStroke.doFill) {\n if (fillCb) {\n fillCb(context, rect.attribute, rectAttribute);\n } else if (fVisible) {\n // 存在fill\n context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n context.fill();\n }\n }\n }\n\n private _runStroke(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n rectAttribute: Required<IRectGraphicAttribute>,\n doFillOrStroke: { doFill: boolean; doStroke: boolean },\n sVisible: boolean,\n originX: number,\n originY: number,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (doFillOrStroke.doStroke) {\n if (strokeCb) {\n strokeCb(context, rect.attribute, rectAttribute);\n } else if (sVisible) {\n // 存在stroke\n context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n context.stroke();\n }\n }\n }\n\n draw(rect: IRect, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const rectAttribute = getTheme(rect, params?.theme).rect;\n this._draw(rect, rectAttribute, false, drawContext, params, rectAttribute);\n }\n}\n"]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { IGraphicAttribute, IContext2d, IMarkAttribute, ISymbol, IThemeAttribute, ISymbolRenderContribution, IDrawContext, IRenderService, IGraphicRender, IGraphicRenderDrawParams, IContributionProvider } from '../../../interface';
|
|
1
|
+
import type { IGraphicAttribute, IContext2d, IMarkAttribute, ISymbol, IThemeAttribute, ISymbolRenderContribution, IDrawContext, IRenderService, IGraphicRender, IGraphicRenderDrawParams, IContributionProvider, ISymbolGraphicAttribute } from '../../../interface';
|
|
2
2
|
import { BaseRender } from './base-render';
|
|
3
3
|
export declare class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {
|
|
4
4
|
protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>;
|
|
5
5
|
type: 'symbol';
|
|
6
6
|
numberType: number;
|
|
7
7
|
constructor(symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>);
|
|
8
|
-
drawShape(symbol: ISymbol, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
8
|
+
drawShape(symbol: ISymbol, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, symbolAttribute?: Required<ISymbolGraphicAttribute>): void;
|
|
9
|
+
private _runFill;
|
|
10
|
+
private _runStroke;
|
|
9
11
|
draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
|
|
10
12
|
}
|
|
@@ -32,9 +32,10 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
|
|
|
32
32
|
this.builtinContributions = [ defaultSymbolRenderContribution, defaultSymbolBackgroundRenderContribution, defaultSymbolTextureRenderContribution, defaultSymbolClipRangeStrokeRenderContribution ],
|
|
33
33
|
this.init(symbolRenderContribitions);
|
|
34
34
|
}
|
|
35
|
-
drawShape(symbol, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
35
|
+
drawShape(symbol, context, x, y, drawContext, params, fillCb, strokeCb, symbolAttribute) {
|
|
36
36
|
var _a;
|
|
37
|
-
|
|
37
|
+
symbolAttribute = null != symbolAttribute ? symbolAttribute : getTheme(symbol, null == params ? void 0 : params.theme).symbol;
|
|
38
|
+
const {size: size = symbolAttribute.size, x: originX = symbolAttribute.x, y: originY = symbolAttribute.y, scaleX: scaleX = symbolAttribute.scaleX, scaleY: scaleY = symbolAttribute.scaleY, fillStrokeOrder: fillStrokeOrder = symbolAttribute.fillStrokeOrder, clipRange: clipRange = symbolAttribute.clipRange} = symbol.attribute, data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);
|
|
38
39
|
if (!data) return;
|
|
39
40
|
const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, parsedPath = symbol.getParsedPath();
|
|
40
41
|
if (!parsedPath) return;
|
|
@@ -66,15 +67,19 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
|
|
|
66
67
|
};
|
|
67
68
|
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
|
|
68
69
|
})) && context.closePath(), context.camera = camera, context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute),
|
|
69
|
-
this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb),
|
|
71
|
+
fillStrokeOrder ? (this._runStroke(symbol, context, x, y, symbolAttribute, doStroke, sVisible, originX, originY, parsedPath, clipRange, scaleX, scaleY, strokeCb),
|
|
72
|
+
this._runFill(symbol, context, x, y, symbolAttribute, doFill, fVisible, originX, originY, parsedPath, fillCb)) : (this._runFill(symbol, context, x, y, symbolAttribute, doFill, fVisible, originX, originY, parsedPath, fillCb),
|
|
73
|
+
this._runStroke(symbol, context, x, y, symbolAttribute, doStroke, sVisible, originX, originY, parsedPath, clipRange, scaleX, scaleY, strokeCb)),
|
|
74
|
+
this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
|
|
75
|
+
}
|
|
76
|
+
_runFill(symbol, context, x, y, symbolAttribute, doFill, fVisible, originX, originY, parsedPath, fillCb) {
|
|
77
|
+
doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute),
|
|
78
|
+
context.fill()));
|
|
79
|
+
}
|
|
80
|
+
_runStroke(symbol, context, x, y, symbolAttribute, doStroke, sVisible, originX, originY, parsedPath, clipRange, scaleX, scaleY, strokeCb) {
|
|
81
|
+
doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && clipRange >= 1 && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute),
|
|
82
|
+
context.stroke()));
|
|
78
83
|
}
|
|
79
84
|
draw(symbol, renderService, drawContext, params) {
|
|
80
85
|
const symbolAttribute = getTheme(symbol, null == params ? void 0 : params.theme).symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/symbol-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAgBhE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EACL,yCAAyC,EACzC,8CAA8C,EAC9C,+BAA+B,EAC/B,sCAAsC,EACvC,MAAM,iBAAiB,CAAC;AAGlB,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,UAAmB;IAIhE,YAGqB,yBAA2E;QAE9F,KAAK,EAAE,CAAC;QAFW,8BAAyB,GAAzB,yBAAyB,CAAkD;QALhG,eAAU,GAAW,kBAAkB,CAAC;QAQtC,IAAI,CAAC,oBAAoB,GAAG;YAC1B,+BAA+B;YAC/B,yCAAyC;YACzC,sCAAsC;YACtC,8CAA8C;SAC/C,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACvC,CAAC;IAED,SAAS,CACP,MAAe,EACf,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;;QAGZ,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,MAAM,CAAC;QAE/D,MAAM,EACJ,IAAI,GAA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M,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAe,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC/G,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,MAAM,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AA/MY,yBAAyB;IADrC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,wBAAwB,CAAC,CAAA;;GANvB,yBAAyB,CA+MrC;SA/MY,yBAAyB","file":"symbol-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport { SYMBOL_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n ICustomPath2D\n} from '../../../interface';\nimport type {} from '../../render-service';\nimport { BaseRender } from './base-render';\nimport { SymbolRenderContribution } from './contributions/constants';\nimport { isArray } from '@visactor/vutils';\nimport {\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolClipRangeStrokeRenderContribution,\n defaultSymbolRenderContribution,\n defaultSymbolTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number = SYMBOL_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(SymbolRenderContribution)\n protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultSymbolRenderContribution,\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolTextureRenderContribution,\n defaultSymbolClipRangeStrokeRenderContribution\n ];\n this.init(symbolRenderContribitions);\n }\n\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n\n const {\n size = symbolAttribute.size,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY,\n fillStrokeOrder = symbolAttribute.fillStrokeOrder,\n clipRange = symbolAttribute.clipRange\n } = symbol.attribute;\n\n const data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { keepDirIn3d = symbolAttribute.keepDirIn3d } = symbol.attribute;\n const z = this.z ?? 0;\n context.beginPath();\n\n const callback = (p: ICustomPath2D, a: any) => {\n // 如果是svg的话,合并一下fill和stroke\n if (symbol._parsedPath.svgCache) {\n const obj = Object.assign({}, a);\n obj.fill = a.fill ?? symbol.attribute.fill;\n obj.opacity = a.opacity ?? symbol.attribute.opacity;\n obj.fillOpacity = symbol.attribute.fillOpacity;\n obj.stroke = a.stroke ?? symbol.attribute.stroke;\n obj.lineWidth = a.lineWidth ?? symbol.attribute.lineWidth;\n a = obj;\n }\n const _runFill = () => {\n if (a.fill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n };\n const _runStroke = () => {\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible && clipRange >= 1) {\n context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);\n context.stroke();\n }\n }\n };\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n };\n let _size = size;\n let _x = x;\n let _y = y;\n let _z = z;\n const camera = context.camera;\n if (keepDirIn3d && camera && context.project) {\n const p = context.project(x, y, z);\n context.camera = null;\n _size = isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX;\n _x = p.x;\n _y = p.y;\n _z = undefined;\n }\n if (parsedPath.draw(context, size, _x, _y, _z, callback) === false) {\n context.closePath();\n }\n context.camera = camera;\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n this.beforeRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n // if (fill !== false) {\n // context.setCommonStyle(symbol.attribute, symbolAttribute);\n // context.fill();\n // }\n // if (stroke !== false) {\n // context.setStrokeStyle(symbol.attribute, symbolAttribute);\n // context.stroke();\n // }\n\n // svg就不用fill和stroke了\n const _runFill = () => {\n if (doFill && !parsedPath.isSvg) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else if (fVisible) {\n context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n };\n const _runStroke = () => {\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible && clipRange >= 1) {\n // 如果clipRange < 1,就需要靠afterRender进行绘制了\n context.setStrokeStyle(\n symbol,\n symbol.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute\n );\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this.afterRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n this._draw(symbol, symbolAttribute, false, drawContext, params);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/symbol-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAiBhE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EACL,yCAAyC,EACzC,8CAA8C,EAC9C,+BAA+B,EAC/B,sCAAsC,EACvC,MAAM,iBAAiB,CAAC;AAGlB,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,UAAmB;IAIhE,YAGqB,yBAA2E;QAE9F,KAAK,EAAE,CAAC;QAFW,8BAAyB,GAAzB,yBAAyB,CAAkD;QALhG,eAAU,GAAW,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AAG,MAAM,EACtB,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,eAAe,CAChB,CAAC;gBACF,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;SACF;IACH,CAAC;IAED,IAAI,CAAC,MAAe,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC/G,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,MAAM,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AA/SY,yBAAyB;IADrC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,wBAAwB,CAAC,CAAA;;GANvB,yBAAyB,CA+SrC;SA/SY,yBAAyB","file":"symbol-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport { SYMBOL_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n ICustomPath2D,\n ISymbolGraphicAttribute\n} from '../../../interface';\nimport type {} from '../../render-service';\nimport { BaseRender } from './base-render';\nimport { SymbolRenderContribution } from './contributions/constants';\nimport { isArray } from '@visactor/vutils';\nimport {\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolClipRangeStrokeRenderContribution,\n defaultSymbolRenderContribution,\n defaultSymbolTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number = SYMBOL_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(SymbolRenderContribution)\n protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultSymbolRenderContribution,\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolTextureRenderContribution,\n defaultSymbolClipRangeStrokeRenderContribution\n ];\n this.init(symbolRenderContribitions);\n }\n\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n symbolAttribute?: Required<ISymbolGraphicAttribute>\n ) {\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n symbolAttribute = symbolAttribute ?? getTheme(symbol, params?.theme).symbol;\n\n const {\n size = symbolAttribute.size,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY,\n fillStrokeOrder = symbolAttribute.fillStrokeOrder,\n clipRange = symbolAttribute.clipRange\n } = symbol.attribute;\n\n const data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { keepDirIn3d = symbolAttribute.keepDirIn3d } = symbol.attribute;\n const z = this.z ?? 0;\n context.beginPath();\n\n const callback = (p: ICustomPath2D, a: any) => {\n // 如果是svg的话,合并一下fill和stroke\n if (symbol._parsedPath.svgCache) {\n const obj = Object.assign({}, a);\n obj.fill = a.fill ?? symbol.attribute.fill;\n obj.opacity = a.opacity ?? symbol.attribute.opacity;\n obj.fillOpacity = symbol.attribute.fillOpacity;\n obj.stroke = a.stroke ?? symbol.attribute.stroke;\n obj.lineWidth = a.lineWidth ?? symbol.attribute.lineWidth;\n a = obj;\n }\n const _runFill = () => {\n if (a.fill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n };\n const _runStroke = () => {\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible && clipRange >= 1) {\n context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);\n context.stroke();\n }\n }\n };\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n };\n let _size = size;\n let _x = x;\n let _y = y;\n let _z = z;\n const camera = context.camera;\n if (keepDirIn3d && camera && context.project) {\n const p = context.project(x, y, z);\n context.camera = null;\n _size = isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX;\n _x = p.x;\n _y = p.y;\n _z = undefined;\n }\n if (parsedPath.draw(context, size, _x, _y, _z, callback) === false) {\n context.closePath();\n }\n context.camera = camera;\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n this.beforeRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n // if (fill !== false) {\n // context.setCommonStyle(symbol.attribute, symbolAttribute);\n // context.fill();\n // }\n // if (stroke !== false) {\n // context.setStrokeStyle(symbol.attribute, symbolAttribute);\n // context.stroke();\n // }\n\n // svg就不用fill和stroke了\n // 内联的函数性能差\n // const _runFill = () => {\n // if (doFill && !parsedPath.isSvg) {\n // if (fillCb) {\n // fillCb(context, symbol.attribute, symbolAttribute);\n // } else if (fVisible) {\n // context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n // context.fill();\n // }\n // }\n // };\n // const _runStroke = () => {\n // if (doStroke && !parsedPath.isSvg) {\n // if (strokeCb) {\n // strokeCb(context, symbol.attribute, symbolAttribute);\n // } else if (sVisible && clipRange >= 1) {\n // // 如果clipRange < 1,就需要靠afterRender进行绘制了\n // context.setStrokeStyle(\n // symbol,\n // symbol.attribute,\n // (originX - x) / scaleX,\n // (originY - y) / scaleY,\n // symbolAttribute\n // );\n // context.stroke();\n // }\n // }\n // };\n\n if (!fillStrokeOrder) {\n this._runFill(symbol, context, x, y, symbolAttribute, doFill, fVisible, originX, originY, parsedPath, fillCb);\n this._runStroke(\n symbol,\n context,\n x,\n y,\n symbolAttribute,\n doStroke,\n sVisible,\n originX,\n originY,\n parsedPath,\n clipRange,\n scaleX,\n scaleY,\n strokeCb\n );\n } else {\n this._runStroke(\n symbol,\n context,\n x,\n y,\n symbolAttribute,\n doStroke,\n sVisible,\n originX,\n originY,\n parsedPath,\n clipRange,\n scaleX,\n scaleY,\n strokeCb\n );\n this._runFill(symbol, context, x, y, symbolAttribute, doFill, fVisible, originX, originY, parsedPath, fillCb);\n }\n\n this.afterRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n private _runFill(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n symbolAttribute: Required<ISymbolGraphicAttribute>,\n doFill: boolean,\n fVisible: boolean,\n originX: number,\n originY: number,\n parsedPath: any,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (doFill && !parsedPath.isSvg) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else if (fVisible) {\n context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n }\n\n private _runStroke(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n symbolAttribute: Required<ISymbolGraphicAttribute>,\n doStroke: boolean,\n sVisible: boolean,\n originX: number,\n originY: number,\n parsedPath: any,\n clipRange: number,\n scaleX: number,\n scaleY: number,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible && clipRange >= 1) {\n // 如果clipRange < 1,就需要靠afterRender进行绘制了\n context.setStrokeStyle(\n symbol,\n symbol.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute\n );\n context.stroke();\n }\n }\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n this._draw(symbol, symbolAttribute, false, drawContext, params);\n }\n}\n"]}
|