@visactor/vrender-core 0.21.2-vstory.2 → 0.21.2
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/animate/Ticker/default-ticker.d.ts +0 -2
- package/cjs/animate/Ticker/default-ticker.js +1 -7
- package/cjs/animate/Ticker/default-ticker.js.map +1 -1
- package/cjs/animate/animate.js +1 -1
- package/cjs/animate/animate.js.map +1 -1
- package/cjs/animate/custom-animate.js +25 -14
- package/cjs/animate/custom-animate.js.map +1 -1
- package/cjs/animate/easing.d.ts +0 -4
- package/cjs/animate/easing.js +1 -24
- package/cjs/animate/easing.js.map +1 -1
- package/cjs/animate/index.d.ts +0 -1
- package/cjs/animate/index.js +1 -1
- package/cjs/animate/index.js.map +1 -1
- package/cjs/color-string/store.js +2 -1
- package/cjs/common/3d-interceptor.js +1 -2
- package/cjs/common/bezier-utils.d.ts +0 -3
- package/cjs/common/bezier-utils.js +2 -17
- package/cjs/common/bezier-utils.js.map +1 -1
- package/cjs/common/custom-path2d.d.ts +0 -4
- package/cjs/common/custom-path2d.js +11 -43
- package/cjs/common/custom-path2d.js.map +1 -1
- package/cjs/common/render-area.js +1 -0
- package/cjs/common/render-command-list.js +1 -2
- package/cjs/common/segment/curve/arc.d.ts +1 -4
- package/cjs/common/segment/curve/arc.js +1 -10
- package/cjs/common/segment/curve/arc.js.map +1 -1
- package/cjs/common/segment/curve/base.d.ts +1 -4
- package/cjs/common/segment/curve/base.js.map +1 -1
- package/cjs/common/segment/curve/cubic-bezier.d.ts +1 -5
- package/cjs/common/segment/curve/cubic-bezier.js +3 -24
- package/cjs/common/segment/curve/cubic-bezier.js.map +1 -1
- package/cjs/common/segment/curve/curve-context.js +4 -5
- package/cjs/common/segment/curve/curve-context.js.map +1 -1
- package/cjs/common/segment/curve/ellipse.d.ts +1 -4
- package/cjs/common/segment/curve/ellipse.js +0 -9
- package/cjs/common/segment/curve/ellipse.js.map +1 -1
- package/cjs/common/segment/curve/line.d.ts +1 -4
- package/cjs/common/segment/curve/line.js +0 -18
- package/cjs/common/segment/curve/line.js.map +1 -1
- package/cjs/common/segment/curve/move.d.ts +1 -4
- package/cjs/common/segment/curve/move.js +0 -9
- package/cjs/common/segment/curve/move.js.map +1 -1
- package/cjs/common/segment/curve/path.d.ts +1 -2
- package/cjs/common/segment/curve/path.js +2 -5
- package/cjs/common/segment/curve/path.js.map +1 -1
- package/cjs/common/segment/curve/quadratic-bezier.d.ts +2 -6
- package/cjs/common/segment/curve/quadratic-bezier.js +5 -23
- package/cjs/common/segment/curve/quadratic-bezier.js.map +1 -1
- package/cjs/common/shape/rect.d.ts +1 -1
- package/cjs/common/shape/rect.js +23 -28
- package/cjs/common/shape/rect.js.map +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/graphic/builtin-symbol/rect.d.ts +1 -2
- package/cjs/graphic/builtin-symbol/rect.js +0 -28
- package/cjs/graphic/builtin-symbol/rect.js.map +1 -1
- package/cjs/graphic/builtin-symbol/utils.d.ts +1 -2
- package/cjs/graphic/builtin-symbol/utils.js +0 -5
- package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
- package/cjs/graphic/config.js +5 -14
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/graphic.js +1 -15
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/richtext/wrapper.d.ts +0 -1
- package/cjs/graphic/richtext/wrapper.js +1 -1
- package/cjs/graphic/richtext/wrapper.js.map +1 -1
- package/cjs/graphic/richtext.js +1 -2
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/index.d.ts +0 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interface/animate.d.ts +39 -5
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/graphic/group.d.ts +0 -1
- package/cjs/interface/graphic/group.js.map +1 -1
- package/cjs/interface/graphic/image.d.ts +0 -1
- package/cjs/interface/graphic/image.js.map +1 -1
- package/cjs/interface/graphic/path.d.ts +0 -1
- package/cjs/interface/graphic/path.js.map +1 -1
- package/cjs/interface/graphic/rect.d.ts +0 -1
- package/cjs/interface/graphic/rect.js.map +1 -1
- package/cjs/interface/graphic/symbol.d.ts +0 -2
- package/cjs/interface/graphic/symbol.js.map +1 -1
- package/cjs/interface/graphic.d.ts +2 -6
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/path.d.ts +0 -5
- package/cjs/interface/path.js.map +1 -1
- package/cjs/interface/picker.d.ts +0 -13
- package/cjs/interface/picker.js.map +1 -1
- package/cjs/picker/constants.d.ts +0 -2
- package/cjs/picker/constants.js +2 -3
- package/cjs/picker/constants.js.map +1 -1
- package/cjs/picker/pick-interceptor.d.ts +2 -7
- package/cjs/picker/pick-interceptor.js +2 -19
- package/cjs/picker/pick-interceptor.js.map +1 -1
- package/cjs/picker/pick-modules.js +4 -7
- package/cjs/picker/pick-modules.js.map +1 -1
- package/cjs/picker/picker-service.d.ts +2 -4
- package/cjs/picker/picker-service.js +12 -13
- package/cjs/picker/picker-service.js.map +1 -1
- package/cjs/plugins/builtin-plugin/edit-module.d.ts +5 -6
- package/cjs/plugins/builtin-plugin/edit-module.js +28 -84
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +30 -49
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +217 -280
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/cjs/render/contributions/render/arc3d-render.js.map +1 -1
- package/cjs/render/contributions/render/base-render.d.ts +0 -1
- package/cjs/render/contributions/render/base-render.js +2 -20
- package/cjs/render/contributions/render/base-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +2 -29
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.js +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js +4 -4
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -8
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +2 -30
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/text-contribution-render.js +1 -1
- package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/draw-interceptor.js +2 -3
- package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
- package/cjs/render/contributions/render/group-render.js +2 -2
- package/cjs/render/contributions/render/group-render.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js +3 -3
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/cjs/render/contributions/render/path-render.js.map +1 -1
- package/cjs/render/contributions/render/polygon-render.js.map +1 -1
- package/cjs/render/contributions/render/rect-render.js +2 -2
- package/cjs/render/contributions/render/rect-render.js.map +1 -1
- package/cjs/render/contributions/render/richtext-render.js +1 -1
- package/cjs/render/contributions/render/richtext-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.js +12 -15
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/cjs/render/contributions/render/utils.d.ts +2 -1
- package/cjs/render/contributions/render/utils.js +20 -4
- package/cjs/render/contributions/render/utils.js.map +1 -1
- package/dist/index.es.js +7663 -8316
- package/es/animate/Ticker/default-ticker.d.ts +0 -2
- package/es/animate/Ticker/default-ticker.js +1 -7
- package/es/animate/Ticker/default-ticker.js.map +1 -1
- package/es/animate/animate.js +1 -1
- package/es/animate/animate.js.map +1 -1
- package/es/animate/custom-animate.js +25 -14
- package/es/animate/custom-animate.js.map +1 -1
- package/es/animate/easing.d.ts +0 -4
- package/es/animate/easing.js +1 -24
- package/es/animate/easing.js.map +1 -1
- package/es/animate/index.d.ts +0 -1
- package/es/animate/index.js +0 -2
- package/es/animate/index.js.map +1 -1
- package/es/color-string/store.js +2 -1
- package/es/common/3d-interceptor.js +1 -2
- package/es/common/bezier-utils.d.ts +0 -3
- package/es/common/bezier-utils.js +0 -14
- package/es/common/bezier-utils.js.map +1 -1
- package/es/common/custom-path2d.d.ts +0 -4
- package/es/common/custom-path2d.js +12 -44
- package/es/common/custom-path2d.js.map +1 -1
- package/es/common/render-area.js +2 -1
- package/es/common/render-command-list.js +1 -2
- package/es/common/segment/curve/arc.d.ts +1 -4
- package/es/common/segment/curve/arc.js +1 -10
- package/es/common/segment/curve/arc.js.map +1 -1
- package/es/common/segment/curve/base.d.ts +1 -4
- package/es/common/segment/curve/base.js.map +1 -1
- package/es/common/segment/curve/cubic-bezier.d.ts +1 -5
- package/es/common/segment/curve/cubic-bezier.js +1 -22
- package/es/common/segment/curve/cubic-bezier.js.map +1 -1
- package/es/common/segment/curve/curve-context.js +3 -6
- package/es/common/segment/curve/curve-context.js.map +1 -1
- package/es/common/segment/curve/ellipse.d.ts +1 -4
- package/es/common/segment/curve/ellipse.js +0 -9
- package/es/common/segment/curve/ellipse.js.map +1 -1
- package/es/common/segment/curve/line.d.ts +1 -4
- package/es/common/segment/curve/line.js +0 -18
- package/es/common/segment/curve/line.js.map +1 -1
- package/es/common/segment/curve/move.d.ts +1 -4
- package/es/common/segment/curve/move.js +0 -9
- package/es/common/segment/curve/move.js.map +1 -1
- package/es/common/segment/curve/path.d.ts +1 -2
- package/es/common/segment/curve/path.js +2 -5
- package/es/common/segment/curve/path.js.map +1 -1
- package/es/common/segment/curve/quadratic-bezier.d.ts +2 -6
- package/es/common/segment/curve/quadratic-bezier.js +5 -28
- package/es/common/segment/curve/quadratic-bezier.js.map +1 -1
- package/es/common/shape/rect.d.ts +1 -1
- package/es/common/shape/rect.js +23 -28
- package/es/common/shape/rect.js.map +1 -1
- package/es/common/store.js +1 -1
- package/es/graphic/builtin-symbol/rect.d.ts +1 -2
- package/es/graphic/builtin-symbol/rect.js +0 -28
- package/es/graphic/builtin-symbol/rect.js.map +1 -1
- package/es/graphic/builtin-symbol/utils.d.ts +1 -2
- package/es/graphic/builtin-symbol/utils.js +0 -5
- package/es/graphic/builtin-symbol/utils.js.map +1 -1
- package/es/graphic/config.js +5 -14
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/graphic.js +1 -15
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/richtext/wrapper.d.ts +0 -1
- package/es/graphic/richtext/wrapper.js +1 -1
- package/es/graphic/richtext/wrapper.js.map +1 -1
- package/es/graphic/richtext.js +1 -2
- package/es/graphic/richtext.js.map +1 -1
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -2
- package/es/index.js.map +1 -1
- package/es/interface/animate.d.ts +39 -5
- package/es/interface/animate.js.map +1 -1
- package/es/interface/graphic/group.d.ts +0 -1
- package/es/interface/graphic/group.js.map +1 -1
- package/es/interface/graphic/image.d.ts +0 -1
- package/es/interface/graphic/image.js.map +1 -1
- package/es/interface/graphic/path.d.ts +0 -1
- package/es/interface/graphic/path.js.map +1 -1
- package/es/interface/graphic/rect.d.ts +0 -1
- package/es/interface/graphic/rect.js.map +1 -1
- package/es/interface/graphic/symbol.d.ts +0 -2
- package/es/interface/graphic/symbol.js.map +1 -1
- package/es/interface/graphic.d.ts +2 -6
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/path.d.ts +0 -5
- package/es/interface/path.js.map +1 -1
- package/es/interface/picker.d.ts +0 -13
- package/es/interface/picker.js.map +1 -1
- package/es/picker/constants.d.ts +0 -2
- package/es/picker/constants.js +0 -4
- package/es/picker/constants.js.map +1 -1
- package/es/picker/pick-interceptor.d.ts +2 -7
- package/es/picker/pick-interceptor.js +1 -19
- package/es/picker/pick-interceptor.js.map +1 -1
- package/es/picker/pick-modules.js +3 -5
- package/es/picker/pick-modules.js.map +1 -1
- package/es/picker/picker-service.d.ts +2 -4
- package/es/picker/picker-service.js +13 -13
- package/es/picker/picker-service.js.map +1 -1
- package/es/plugins/builtin-plugin/edit-module.d.ts +5 -6
- package/es/plugins/builtin-plugin/edit-module.js +25 -79
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +30 -49
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +214 -283
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/es/render/contributions/render/arc3d-render.js.map +1 -1
- package/es/render/contributions/render/base-render.d.ts +0 -1
- package/es/render/contributions/render/base-render.js +2 -21
- package/es/render/contributions/render/base-render.js.map +1 -1
- package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js +2 -29
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.js +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/rect-contribution-render.js +4 -4
- package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -8
- package/es/render/contributions/render/contributions/symbol-contribution-render.js +0 -26
- package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/text-contribution-render.js +1 -1
- package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/es/render/contributions/render/draw-interceptor.js +2 -3
- package/es/render/contributions/render/draw-interceptor.js.map +1 -1
- package/es/render/contributions/render/group-render.js +2 -2
- package/es/render/contributions/render/group-render.js.map +1 -1
- package/es/render/contributions/render/image-render.js +3 -3
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/path-render.js.map +1 -1
- package/es/render/contributions/render/polygon-render.js.map +1 -1
- package/es/render/contributions/render/rect-render.js +2 -2
- package/es/render/contributions/render/rect-render.js.map +1 -1
- package/es/render/contributions/render/richtext-render.js +1 -1
- package/es/render/contributions/render/richtext-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.js +13 -16
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/es/render/contributions/render/utils.d.ts +2 -1
- package/es/render/contributions/render/utils.js +18 -0
- package/es/render/contributions/render/utils.js.map +1 -1
- package/package.json +1 -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/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/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/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/richtext-edit-plugin-old.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
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,GAAG,IAAI,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AC,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 const t1 = graphic.parent.globalTransMatrix;\n const t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);\n graphic.parent && context.setTransformFromMatrix(t2, 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,GAAG,IAAI,UAAU,EAAE,CAAC;AAK/C,MAAM,OAAO,yCAAyC;IAAtD;QACE,UAAK,GAAW,CAAC,CAAC;IAoFpB,CAAC;IAnFC,aAAa,CACX,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,gBAAmC,E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CAAC;aACpE;SACF;aAAM;YACL,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC;SAC9B;QACD,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAG7C,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,UAAU,CACR,OAAO,EACP,OAAO,EACP,CAAC,KAAc,EAAE,IAAa,EAAE,EAAE;gBAChC,OAAO,gBAAgB,CAAC,WAAW,CACjC,OAAiB,EACjB,WAAW,EACX,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAChC,CAAC,KAAK,IAAI,IAAI,CACf,CAAC;YACJ,CAAC,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"]}
|
|
@@ -41,7 +41,7 @@ let DefaultCanvasGroupRender = class {
|
|
|
41
41
|
this.groupRenderContribitions = groupRenderContribitions, this.numberType = GROUP_NUMBER_TYPE;
|
|
42
42
|
}
|
|
43
43
|
drawShape(group, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
44
|
-
const groupAttribute = getTheme(group, null == params ? void 0 : params.theme).group, {fill: fill = groupAttribute.fill, background: background, stroke: stroke = groupAttribute.stroke, opacity: opacity = groupAttribute.opacity, width: width = groupAttribute.width, height: height = groupAttribute.height, clip: clip = groupAttribute.clip, 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,
|
|
44
|
+
const groupAttribute = getTheme(group, null == params ? void 0 : params.theme).group, {fill: fill = groupAttribute.fill, background: background, stroke: stroke = groupAttribute.stroke, opacity: opacity = groupAttribute.opacity, width: width = groupAttribute.width, height: height = groupAttribute.height, clip: clip = groupAttribute.clip, 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, 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);
|
|
45
45
|
if (!group.valid || !visible) return;
|
|
46
46
|
if (!clip) {
|
|
47
47
|
if (!doFill && !doStroke) return;
|
|
@@ -54,7 +54,7 @@ let DefaultCanvasGroupRender = class {
|
|
|
54
54
|
drawContext.drawContribution.getRenderContribution(g).draw(g, drawContext.renderService, drawContext, params);
|
|
55
55
|
})), context.disableFill = disableFill, context.disableStroke = disableStroke, context.disableBeginPath = disableBeginPath;
|
|
56
56
|
} else 0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every((num => 0 === num)) ? (context.beginPath(),
|
|
57
|
-
context.rect(x, y, width, height)) : (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius
|
|
57
|
+
context.rect(x, y, width, height)) : (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius));
|
|
58
58
|
this._groupRenderContribitions || (this._groupRenderContribitions = this.groupRenderContribitions.getContributions() || [],
|
|
59
59
|
this._groupRenderContribitions.push(defaultGroupBackgroundRenderContribution));
|
|
60
60
|
const doFillOrStroke = {
|
|
@@ -1 +1 @@
|
|
|
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;AAc3E,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;AAGnD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ClC;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;AArSY,wBAAwB;IADpC,UAAU,EAAE;IAQR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,uBAAuB,CAAC,CAAA;;GARtB,wBAAwB,CAqSpC;SArSY,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';\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 === 'round');\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 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 // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);\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 // debugger;\n const { clip, baseOpacity = 1 } = group.attribute;\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 (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;AAc3E,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;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BAClC;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;AArSY,wBAAwB;IADpC,UAAU,EAAE;IAQR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,uBAAuB,CAAC,CAAA;;GARtB,wBAAwB,CAqSpC;SArSY,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';\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\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);\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 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 // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);\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 // debugger;\n const { clip, baseOpacity = 1 } = group.attribute;\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 (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"]}
|
|
@@ -39,7 +39,7 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
39
39
|
this.init(imageRenderContribitions);
|
|
40
40
|
}
|
|
41
41
|
drawShape(image, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
42
|
-
const imageAttribute = getTheme(image).image, {width: width = imageAttribute.width, height: height = imageAttribute.height, repeatX: repeatX = imageAttribute.repeatX, repeatY: repeatY = imageAttribute.repeatY, x: originX = imageAttribute.x, y: originY = imageAttribute.y, cornerRadius: cornerRadius = imageAttribute.cornerRadius, fillStrokeOrder: fillStrokeOrder = imageAttribute.fillStrokeOrder,
|
|
42
|
+
const imageAttribute = getTheme(image).image, {width: width = imageAttribute.width, height: height = imageAttribute.height, repeatX: repeatX = imageAttribute.repeatX, repeatY: repeatY = imageAttribute.repeatY, x: originX = imageAttribute.x, y: originY = imageAttribute.y, cornerRadius: cornerRadius = imageAttribute.cornerRadius, fillStrokeOrder: fillStrokeOrder = imageAttribute.fillStrokeOrder, image: url} = image.attribute, data = this.valid(image, imageAttribute, fillCb);
|
|
43
43
|
if (!data) return;
|
|
44
44
|
const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data;
|
|
45
45
|
context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute),
|
|
@@ -51,8 +51,8 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
51
51
|
if ("success" !== res.state) return;
|
|
52
52
|
let needRestore = !1;
|
|
53
53
|
0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every((num => 0 === num)) || (context.beginPath(),
|
|
54
|
-
createRectPath(context, x, y, width, height, cornerRadius,
|
|
55
|
-
|
|
54
|
+
createRectPath(context, x, y, width, height, cornerRadius), context.save(), context.clip(),
|
|
55
|
+
needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
|
|
56
56
|
let repeat = 0;
|
|
57
57
|
if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2),
|
|
58
58
|
repeat) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/image-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,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wCAAwC,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,SAAS,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAGlD,IAAM,wBAA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inversify-lite';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IImage,\n IThemeAttribute,\n IGraphicRender,\n IImageRenderContribution,\n IContributionProvider,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { ImageRenderContribution } from './contributions/constants';\nimport { fillVisible, runFill } from './utils';\nimport { IMAGE_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { isArray, isString } from '@visactor/vutils';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { BaseRender } from './base-render';\nimport { defaultImageBackgroundRenderContribution, defaultImageRenderContribution } from './contributions';\nimport { ResourceLoader } from '../../../resource-loader/loader';\n\nconst repeatStr = ['', 'repeat-x', 'repeat-y', 'repeat'];\n\n@injectable()\nexport class DefaultCanvasImageRender extends BaseRender<IImage> implements IGraphicRender {\n type: 'image';\n numberType: number = IMAGE_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(ImageRenderContribution)\n protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution];\n this.init(imageRenderContribitions);\n }\n\n drawShape(\n image: IImage,\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 imageAttribute = graphicService.themeService.getCurrentTheme().imageAttribute;\n const imageAttribute = getTheme(image).image;\n const {\n width = imageAttribute.width,\n height = imageAttribute.height,\n repeatX = imageAttribute.repeatX,\n repeatY = imageAttribute.repeatY,\n x: originX = imageAttribute.x,\n y: originY = imageAttribute.y,\n cornerRadius = imageAttribute.cornerRadius,\n fillStrokeOrder = imageAttribute.fillStrokeOrder,\n cornerType = imageAttribute.cornerType,\n image: url\n } = image.attribute;\n\n const data = this.valid(image, imageAttribute, fillCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute);\n\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n\n // context.beginPath();\n // context.image(x, y, width, height);\n\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, image.attribute, imageAttribute);\n } else if (fVisible) {\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n if (res.state !== 'success') {\n return;\n }\n\n // deal with cornerRadius\n let needRestore = false;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n } else {\n context.beginPath();\n createRectPath(context, x, y, width, height, cornerRadius, cornerType === 'round');\n context.save();\n context.clip();\n needRestore = true;\n }\n\n context.setCommonStyle(image, image.attribute, x, y, imageAttribute);\n let repeat = 0;\n if (repeatX === 'repeat') {\n repeat |= 0b0001;\n }\n if (repeatY === 'repeat') {\n repeat |= 0b0010;\n }\n if (repeat) {\n const pattern = context.createPattern(res.data, repeatStr[repeat]);\n context.fillStyle = pattern;\n context.translate(x, y, true);\n context.fillRect(0, 0, width, height);\n context.translate(-x, -y, true);\n } else {\n context.drawImage(res.data, x, y, width, height);\n }\n\n if (needRestore) {\n context.restore();\n }\n }\n }\n };\n\n const _runStroke = () => {\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, image.attribute, imageAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute);\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(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n }\n\n draw(image: IImage, renderService: IRenderService, drawContext: IDrawContext) {\n const { image: url } = image.attribute;\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n // if (res.state !== 'success') {\n // return;\n // }\n if (res.state === 'loading' && isString(url)) {\n ResourceLoader.improveImageLoading(url);\n return;\n } else if (res.state !== 'success') {\n return;\n }\n\n const { context } = renderService.drawParams;\n if (!context) {\n return;\n }\n const imageAttribute = getTheme(image).image;\n this._draw(image, imageAttribute, false, drawContext);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/image-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,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wCAAwC,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,SAAS,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAGlD,IAAM,wBAAwB,GAA9B,MAAM,wBAA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I,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAClH,CAAC;IAED,IAAI,CAAC,KAAa,EAAE,aAA6B,EAAE,WAAyB;QAC1E,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC;QACvC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;YAC5B,OAAO;SACR;QACD,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAIrC,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC5C,cAAc,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;YACxC,OAAO;SACR;aAAM,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE;YAClC,OAAO;SACR;QAED,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,UAAU,CAAC;QAC7C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QACD,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AA3JY,wBAAwB;IADpC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,uBAAuB,CAAC,CAAA;;GANtB,wBAAwB,CA2JpC;SA3JY,wBAAwB","file":"image-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IImage,\n IThemeAttribute,\n IGraphicRender,\n IImageRenderContribution,\n IContributionProvider,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { ImageRenderContribution } from './contributions/constants';\nimport { fillVisible, runFill } from './utils';\nimport { IMAGE_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { isArray, isString } from '@visactor/vutils';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { BaseRender } from './base-render';\nimport { defaultImageBackgroundRenderContribution, defaultImageRenderContribution } from './contributions';\nimport { ResourceLoader } from '../../../resource-loader/loader';\n\nconst repeatStr = ['', 'repeat-x', 'repeat-y', 'repeat'];\n\n@injectable()\nexport class DefaultCanvasImageRender extends BaseRender<IImage> implements IGraphicRender {\n type: 'image';\n numberType: number = IMAGE_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(ImageRenderContribution)\n protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution];\n this.init(imageRenderContribitions);\n }\n\n drawShape(\n image: IImage,\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 imageAttribute = graphicService.themeService.getCurrentTheme().imageAttribute;\n const imageAttribute = getTheme(image).image;\n const {\n width = imageAttribute.width,\n height = imageAttribute.height,\n repeatX = imageAttribute.repeatX,\n repeatY = imageAttribute.repeatY,\n x: originX = imageAttribute.x,\n y: originY = imageAttribute.y,\n cornerRadius = imageAttribute.cornerRadius,\n fillStrokeOrder = imageAttribute.fillStrokeOrder,\n image: url\n } = image.attribute;\n\n const data = this.valid(image, imageAttribute, fillCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute);\n\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n\n // context.beginPath();\n // context.image(x, y, width, height);\n\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, image.attribute, imageAttribute);\n } else if (fVisible) {\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n if (res.state !== 'success') {\n return;\n }\n\n // deal with cornerRadius\n let needRestore = false;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n } else {\n context.beginPath();\n createRectPath(context, x, y, width, height, cornerRadius);\n context.save();\n context.clip();\n needRestore = true;\n }\n\n context.setCommonStyle(image, image.attribute, x, y, imageAttribute);\n let repeat = 0;\n if (repeatX === 'repeat') {\n repeat |= 0b0001;\n }\n if (repeatY === 'repeat') {\n repeat |= 0b0010;\n }\n if (repeat) {\n const pattern = context.createPattern(res.data, repeatStr[repeat]);\n context.fillStyle = pattern;\n context.translate(x, y, true);\n context.fillRect(0, 0, width, height);\n context.translate(-x, -y, true);\n } else {\n context.drawImage(res.data, x, y, width, height);\n }\n\n if (needRestore) {\n context.restore();\n }\n }\n }\n };\n\n const _runStroke = () => {\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, image.attribute, imageAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute);\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(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n }\n\n draw(image: IImage, renderService: IRenderService, drawContext: IDrawContext) {\n const { image: url } = image.attribute;\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n // if (res.state !== 'success') {\n // return;\n // }\n if (res.state === 'loading' && isString(url)) {\n ResourceLoader.improveImageLoading(url);\n return;\n } else if (res.state !== 'success') {\n return;\n }\n\n const { context } = renderService.drawParams;\n if (!context) {\n return;\n }\n const imageAttribute = getTheme(image).image;\n this._draw(image, imageAttribute, false, drawContext);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/path-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,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAgBxE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/path-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,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAgBxE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EACL,uCAAuC,EACvC,o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AC,SAAS,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;oBACtF,OAAO,CAAC,IAAI,EAAE,CAAC;iBAChB;aACF;QACH,CAAC,CAAC;QAEF,IAAI,CAAC,eAAe,EAAE;YACpB,QAAQ,EAAE,CAAC;YACX,UAAU,EAAE,CAAC;SACd;aAAM;YACL,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,CAAC;SACZ;QAED,IAAI,CAAC,eAAe,CAClB,IAAI,EACJ,OAAO,EACP,CAAC,EACD,CAAC,EACD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,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;AA9HY,uBAAuB;IADnC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,sBAAsB,CAAC,CAAA;;GAPrB,uBAAuB,CA8HnC;SA9HY,uBAAuB","file":"path-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { renderCommandList } from '../../../common/render-command-list';\nimport type {\n IPath,\n ICustomPath2D,\n IContext2d,\n IThemeAttribute,\n IGraphicAttribute,\n IMarkAttribute,\n IPathRenderContribution,\n IGraphicRender,\n IContributionProvider,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService,\n IPathGraphicAttribute\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { PATH_NUMBER_TYPE } from '../../../graphic/constants';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { PathRenderContribution } from './contributions/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { BaseRender } from './base-render';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport {\n defaultPathBackgroundRenderContribution,\n defaultPathTextureRenderContribution\n} from './contributions/path-contribution-render';\n\n@injectable()\nexport class DefaultCanvasPathRender extends BaseRender<IPath> implements IGraphicRender {\n type: 'path';\n numberType: number = PATH_NUMBER_TYPE;\n tempTheme: Required<IPathGraphicAttribute>;\n\n constructor(\n @inject(ContributionProvider)\n @named(PathRenderContribution)\n protected readonly pathRenderContribitions: IContributionProvider<IPathRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultPathBackgroundRenderContribution, defaultPathTextureRenderContribution];\n this.init(pathRenderContribitions);\n }\n\n drawShape(\n path: IPath,\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 pathAttribute = graphicService.themeService.getCurrentTheme().pathAttribute;\n const pathAttribute = this.tempTheme ?? getTheme(path, params?.theme).path;\n const {\n x: originX = pathAttribute.x,\n y: originY = pathAttribute.y,\n fillStrokeOrder = pathAttribute.fillStrokeOrder\n } = path.attribute;\n\n const z = this.z ?? 0;\n\n const data = this.valid(path, pathAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n context.beginPath();\n if (path.pathShape) {\n renderCommandList((path.pathShape as ICustomPath2D).commandList, context, x, y, 1, 1, z);\n } else {\n const path2D = path.attribute.path ?? pathAttribute.path;\n renderCommandList((path2D as ICustomPath2D).commandList, context, x, y, 1, 1, z);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute);\n\n this.beforeRenderStep(\n path,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n pathAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n const _runStroke = () => {\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, path.attribute, pathAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute);\n context.stroke();\n }\n }\n };\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, path.attribute, pathAttribute);\n } else if (fVisible) {\n context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute);\n context.fill();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this.afterRenderStep(\n path,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n pathAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(path: IPath, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const pathAttribute = getTheme(path, params?.theme).path;\n this.tempTheme = pathAttribute;\n this._draw(path, pathAttribute, false, drawContext, params);\n this.tempTheme = null;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/polygon-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAA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AAC;SACZ;QAED,IAAI,CAAC,eAAe,CAClB,OAAO,EACP,OAAO,EACP,CAAC,EACD,CAAC,EACD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,OAAiB,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QACjH,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,OAAO,CAAC;QAClE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC;CACF,CAAA;AAjIY,0BAA0B;IADtC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,yBAAyB,CAAC,CAAA;;GANxB,0BAA0B,CAiItC;SAjIY,0BAA0B","file":"polygon-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { POLYGON_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IPolygon,\n IThemeAttribute,\n IGraphicRender,\n IPolygonRenderContribution,\n IContributionProvider,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { drawPolygon, drawRoundedPolygon } from '../../../common/polygon';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { PolygonRenderContribution } from './contributions/constants';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { BaseRender } from './base-render';\nimport {\n defaultPolygonBackgroundRenderContribution,\n defaultPolygonTextureRenderContribution\n} from './contributions/polygon-contribution-render';\n\n@injectable()\nexport class DefaultCanvasPolygonRender extends BaseRender<IPolygon> implements IGraphicRender {\n type: 'polygon';\n numberType: number = POLYGON_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(PolygonRenderContribution)\n protected readonly polygonRenderContribitions: IContributionProvider<IPolygonRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultPolygonBackgroundRenderContribution, defaultPolygonTextureRenderContribution];\n this.init(polygonRenderContribitions);\n }\n\n drawShape(\n polygon: IPolygon,\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 polygonAttribute = graphicService.themeService.getCurrentTheme().polygonAttribute;\n const polygonAttribute = getTheme(polygon, params?.theme).polygon;\n const {\n points = polygonAttribute.points,\n cornerRadius = polygonAttribute.cornerRadius,\n x: originX = polygonAttribute.x,\n y: originY = polygonAttribute.y,\n closePath = polygonAttribute.closePath,\n fillStrokeOrder = polygonAttribute.fillStrokeOrder\n } = polygon.attribute;\n\n const data = this.valid(polygon, polygonAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n context.beginPath();\n\n if ((cornerRadius as number) <= 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n drawPolygon(context.camera ? context : context.nativeContext, points, x, y);\n } else {\n // FIXME: type\n drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath);\n }\n // polygon 默认闭合\n closePath && context.closePath();\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute);\n\n this.beforeRenderStep(\n polygon,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n polygonAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, polygon.attribute, polygonAttribute);\n } else if (fVisible) {\n // 存在fill\n context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute);\n context.fill();\n }\n }\n };\n const _runStroke = () => {\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, polygon.attribute, polygonAttribute);\n } else if (sVisible) {\n // 存在stroke\n context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute);\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 polygon,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n polygonAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(polygon: IPolygon, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const polygonAttribute = getTheme(polygon, params?.theme).polygon;\n this._draw(polygon, polygonAttribute, false, drawContext, params);\n }\n}\n"]}
|
|
@@ -38,7 +38,7 @@ let DefaultCanvasRectRender = class extends BaseRender {
|
|
|
38
38
|
}
|
|
39
39
|
drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
40
40
|
var _a;
|
|
41
|
-
const rectAttribute = null !== (_a = this.tempTheme) && void 0 !== _a ? _a : getTheme(rect, null == params ? void 0 : params.theme).rect, {fill: fill = rectAttribute.fill, background: background, stroke: stroke = rectAttribute.stroke, cornerRadius: cornerRadius = rectAttribute.cornerRadius,
|
|
41
|
+
const rectAttribute = null !== (_a = this.tempTheme) && void 0 !== _a ? _a : getTheme(rect, null == params ? void 0 : params.theme).rect, {fill: fill = rectAttribute.fill, background: background, stroke: stroke = rectAttribute.stroke, cornerRadius: cornerRadius = rectAttribute.cornerRadius, 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);
|
|
@@ -46,7 +46,7 @@ let DefaultCanvasRectRender = class extends BaseRender {
|
|
|
46
46
|
if (!doFill && !doStroke) return;
|
|
47
47
|
if (!(fVisible || sVisible || fillCb || strokeCb || background)) return;
|
|
48
48
|
0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every((num => 0 === num)) ? (context.beginPath(),
|
|
49
|
-
context.rect(x, y, width, height)) : (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius
|
|
49
|
+
context.rect(x, y, width, height)) : (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius));
|
|
50
50
|
const doFillOrStroke = {
|
|
51
51
|
doFill: doFill,
|
|
52
52
|
doStroke: doStroke
|
|
@@ -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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B,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 === 'round');\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":["../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;AAC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AC,eAAe,EAAE;YACpB,QAAQ,EAAE,CAAC;YACX,UAAU,EAAE,CAAC;SACd;aAAM;YACL,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,CAAC;SACZ;QAED,IAAI,CAAC,eAAe,CAClB,IAAI,EACJ,OAAO,EACP,CAAC,EACD,CAAC,EACD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,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;AArKY,uBAAuB;IADnC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,sBAAsB,CAAC,CAAA;;GAPrB,uBAAuB,CAqKnC;SArKY,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 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);\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"]}
|
|
@@ -39,7 +39,7 @@ let DefaultCanvasRichTextRender = class extends BaseRender {
|
|
|
39
39
|
if (margin && (x += icon._marginArray[3], y += icon._marginArray[0]), icon._hovered) {
|
|
40
40
|
const expandX = (backgroundWidth - width) / 2, expandY = (backgroundHeight - height) / 2;
|
|
41
41
|
0 === backgroundRadius ? (context.beginPath(), context.rect(x - expandX, y - expandY, backgroundWidth, backgroundHeight)) : (context.beginPath(),
|
|
42
|
-
createRectPath(context, x - expandX, y - expandY, backgroundWidth, backgroundHeight, backgroundRadius
|
|
42
|
+
createRectPath(context, x - expandX, y - expandY, backgroundWidth, backgroundHeight, backgroundRadius)),
|
|
43
43
|
backgroundFill && (context.globalAlpha = backgroundFillOpacity, context.fillStyle = backgroundFill,
|
|
44
44
|
context.fill()), backgroundStroke && (context.globalAlpha = backgroundStrokeOpacity,
|
|
45
45
|
context.strokeStyle = backgroundStroke, context.stroke());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/richtext-render.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AASlE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,uCAAuC,EAAE,MAAM,0CAA0C,CAAC;AAG5F,IAAM,2BAA2B,GAAjC,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AA0B,CAAC;gBACjD,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;SACF;QAGD,MAAM,GAAG,GAAG,GAAG,KAAI,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,0CAAE,GAAG,CAAC,GAAG,CAAC,CAAA,CAAC;QAC7C,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE;YACnC,OAAO;SACR;QAED,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC;QAC9B,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,CAAC,QAAmB,EAAE,aAA6B,EAAE,WAAyB;QAChF,MAAM,iBAAiB,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC;QACtD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC;CACF,CAAA;AA/HY,2BAA2B;IADvC,UAAU,EAAE;;GACA,2BAA2B,CA+HvC;SA/HY,2BAA2B","file":"richtext-render.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { getTheme } from '../../../graphic/theme';\nimport { RICHTEXT_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IContext2d,\n IRichText,\n IRichTextIcon,\n IDrawContext,\n IRenderService,\n IGraphicRender\n} from '../../../interface';\nimport { fillVisible } from './utils';\nimport { BaseRender } from './base-render';\nimport { defaultTextBackgroundRenderContribution } from './contributions/text-contribution-render';\n\n@injectable()\nexport class DefaultCanvasRichTextRender extends BaseRender<IRichText> implements IGraphicRender {\n type: 'richtext';\n numberType: number = RICHTEXT_NUMBER_TYPE;\n\n constructor() {\n super();\n this.builtinContributions = [defaultTextBackgroundRenderContribution as any];\n this.init();\n }\n\n drawShape(richtext: IRichText, context: IContext2d, x: number, y: number, drawContext: IDrawContext) {\n const richtextAttribute = getTheme(richtext).richtext;\n const {\n strokeOpacity = richtextAttribute.strokeOpacity,\n opacity = richtextAttribute.opacity,\n fillOpacity = richtextAttribute.fillOpacity,\n visible = richtextAttribute.visible\n } = richtext.attribute;\n\n if (!(richtext.valid && visible)) {\n return;\n }\n\n const fVisible = fillVisible(opacity, fillOpacity, true);\n const sVisible = fillVisible(opacity, strokeOpacity, true);\n if (!fVisible) {\n return;\n }\n\n context.translate(x, y);\n this.beforeRenderStep(\n richtext,\n context,\n x,\n y,\n fVisible,\n sVisible,\n fVisible,\n sVisible,\n richtextAttribute,\n drawContext\n );\n const frame = richtext.getFrameCache();\n frame.draw(context, this.drawIcon);\n\n this.afterRenderStep(\n richtext,\n context,\n x,\n y,\n fVisible,\n sVisible,\n fVisible,\n sVisible,\n richtextAttribute,\n drawContext\n );\n }\n\n drawIcon(icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) {\n const richtextIconAttribute = getTheme(icon).richtextIcon;\n\n const {\n width = richtextIconAttribute.width,\n height = richtextIconAttribute.height,\n opacity = richtextIconAttribute.opacity,\n image: url,\n backgroundFill = richtextIconAttribute.backgroundFill,\n // backgroundFillColor = richtextIconAttribute.backgroundFillColor,\n backgroundFillOpacity = richtextIconAttribute.backgroundFillOpacity,\n backgroundStroke = richtextIconAttribute.backgroundStroke,\n // backgroundStrokeColor = richtextIconAttribute.backgroundStrokeColor,\n backgroundStrokeOpacity = richtextIconAttribute.backgroundStrokeOpacity,\n backgroundRadius = richtextIconAttribute.backgroundRadius,\n margin\n } = icon.attribute;\n\n const { backgroundWidth = width, backgroundHeight = height } = icon.attribute;\n\n if (margin) {\n x += icon._marginArray[3];\n y += icon._marginArray[0];\n }\n\n // y -= height / 2 - baseline;\n\n // 绘制background\n if (icon._hovered) {\n const expandX = (backgroundWidth - width) / 2;\n const expandY = (backgroundHeight - height) / 2;\n\n if (backgroundRadius === 0) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x - expandX, y - expandY, backgroundWidth, backgroundHeight);\n } else {\n context.beginPath();\n createRectPath(context, x - expandX, y - expandY, backgroundWidth, backgroundHeight, backgroundRadius);\n }\n if (backgroundFill) {\n // context.setCommonStyle(rect, rect.attribute, x, y, rectAttribute);\n context.globalAlpha = backgroundFillOpacity;\n context.fillStyle = backgroundFill as string;\n context.fill();\n }\n if (backgroundStroke) {\n // context.setStrokeStyle(rect, rect.attribute, x, y, rectAttribute);\n context.globalAlpha = backgroundStrokeOpacity;\n context.strokeStyle = backgroundStroke as string;\n context.stroke();\n }\n }\n\n // 绘制图标\n const res = url && icon?.resources?.get(url);\n if (!res || res.state !== 'success') {\n return;\n }\n // context.setCommonStyle(icon, icon.attribute, x, y, iconAttribute);\n context.globalAlpha = opacity;\n context.drawImage(res.data, x, y, width, height);\n }\n\n draw(richtext: IRichText, renderService: IRenderService, drawContext: IDrawContext) {\n const richtextAttribute = getTheme(richtext).richtext;\n this._draw(richtext, richtextAttribute, false, drawContext);\n }\n}\n"]}
|