@visactor/vrender 0.14.2 → 0.15.0-alpha.0

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.
Files changed (170) hide show
  1. package/cjs/animate/default-ticker.js +1 -1
  2. package/cjs/animate/default-ticker.js.map +1 -1
  3. package/cjs/core/contributions/env/base-contribution.d.ts +5 -1
  4. package/cjs/core/contributions/env/base-contribution.js +10 -1
  5. package/cjs/core/contributions/env/base-contribution.js.map +1 -1
  6. package/cjs/core/contributions/env/browser-contribution.d.ts +5 -2
  7. package/cjs/core/contributions/env/browser-contribution.js +47 -0
  8. package/cjs/core/contributions/env/browser-contribution.js.map +1 -1
  9. package/cjs/core/global.d.ts +5 -1
  10. package/cjs/core/global.js +9 -0
  11. package/cjs/core/global.js.map +1 -1
  12. package/cjs/core/stage.d.ts +4 -0
  13. package/cjs/core/stage.js +11 -2
  14. package/cjs/core/stage.js.map +1 -1
  15. package/cjs/graphic/builtin-symbol/arrow2-down.d.ts +12 -0
  16. package/cjs/graphic/builtin-symbol/arrow2-down.js +30 -0
  17. package/cjs/graphic/builtin-symbol/arrow2-down.js.map +1 -0
  18. package/cjs/graphic/builtin-symbol/arrow2-left.js +1 -1
  19. package/cjs/graphic/builtin-symbol/arrow2-left.js.map +1 -1
  20. package/cjs/graphic/builtin-symbol/arrow2-right.js +1 -1
  21. package/cjs/graphic/builtin-symbol/arrow2-right.js.map +1 -1
  22. package/cjs/graphic/builtin-symbol/arrow2-up.d.ts +12 -0
  23. package/cjs/graphic/builtin-symbol/arrow2-up.js +30 -0
  24. package/cjs/graphic/builtin-symbol/arrow2-up.js.map +1 -0
  25. package/cjs/graphic/builtin-symbol/close.d.ts +13 -0
  26. package/cjs/graphic/builtin-symbol/close.js +33 -0
  27. package/cjs/graphic/builtin-symbol/close.js.map +1 -0
  28. package/cjs/graphic/builtin-symbol/index.d.ts +1 -1
  29. package/cjs/graphic/builtin-symbol/index.js +2 -2
  30. package/cjs/graphic/builtin-symbol/index.js.map +1 -1
  31. package/cjs/graphic/builtin-symbol/line-h.d.ts +13 -0
  32. package/cjs/graphic/builtin-symbol/line-h.js +32 -0
  33. package/cjs/graphic/builtin-symbol/line-h.js.map +1 -0
  34. package/cjs/graphic/builtin-symbol/line-v.d.ts +13 -0
  35. package/cjs/graphic/builtin-symbol/line-v.js +32 -0
  36. package/cjs/graphic/builtin-symbol/line-v.js.map +1 -0
  37. package/cjs/graphic/builtin-symbol/utils.d.ts +13 -5
  38. package/cjs/graphic/builtin-symbol/utils.js +23 -9
  39. package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
  40. package/cjs/graphic/config.js +2 -1
  41. package/cjs/graphic/config.js.map +1 -1
  42. package/cjs/graphic/constants.d.ts +22 -0
  43. package/cjs/graphic/constants.js +20 -2
  44. package/cjs/graphic/constants.js.map +1 -1
  45. package/cjs/graphic/symbol.d.ts +2 -1
  46. package/cjs/graphic/symbol.js +27 -4
  47. package/cjs/graphic/symbol.js.map +1 -1
  48. package/cjs/index.d.ts +2 -1
  49. package/cjs/index.js +2 -2
  50. package/cjs/index.js.map +1 -1
  51. package/cjs/interface/global.d.ts +13 -1
  52. package/cjs/interface/global.js.map +1 -1
  53. package/cjs/interface/graphic/symbol.d.ts +3 -2
  54. package/cjs/interface/graphic/symbol.js.map +1 -1
  55. package/cjs/interface/graphic.d.ts +14 -0
  56. package/cjs/interface/graphic.js.map +1 -1
  57. package/cjs/interface/render.d.ts +1 -0
  58. package/cjs/interface/render.js.map +1 -1
  59. package/cjs/interface/stage.d.ts +2 -0
  60. package/cjs/interface/stage.js.map +1 -1
  61. package/cjs/jsx/graphicType.d.ts +72 -0
  62. package/cjs/jsx/graphicType.js +120 -0
  63. package/cjs/jsx/graphicType.js.map +1 -0
  64. package/cjs/jsx/index.d.ts +2 -0
  65. package/cjs/jsx/index.js +21 -0
  66. package/cjs/jsx/index.js.map +1 -0
  67. package/cjs/jsx/jsx-classic.d.ts +5 -0
  68. package/cjs/jsx/jsx-classic.js +46 -0
  69. package/cjs/jsx/jsx-classic.js.map +1 -0
  70. package/cjs/picker/contributions/canvas-picker/symbol-picker.js +4 -2
  71. package/cjs/picker/contributions/canvas-picker/symbol-picker.js.map +1 -1
  72. package/cjs/picker/pick-interceptor.js +2 -3
  73. package/cjs/picker/pick-interceptor.js.map +1 -1
  74. package/cjs/plugins/builtin-plugin/html-attribute-plugin.d.ts +13 -0
  75. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +75 -0
  76. package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -0
  77. package/cjs/render/contributions/render/draw-contribution.d.ts +3 -1
  78. package/cjs/render/contributions/render/draw-contribution.js +3 -1
  79. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  80. package/cjs/render/contributions/render/symbol-render.js +12 -5
  81. package/cjs/render/contributions/render/symbol-render.js.map +1 -1
  82. package/cjs/render/render-service.js +3 -1
  83. package/cjs/render/render-service.js.map +1 -1
  84. package/dist/index.js +3186 -354
  85. package/dist/index.min.js +1 -1
  86. package/es/animate/default-ticker.js +1 -1
  87. package/es/animate/default-ticker.js.map +1 -1
  88. package/es/core/contributions/env/base-contribution.d.ts +5 -1
  89. package/es/core/contributions/env/base-contribution.js +11 -0
  90. package/es/core/contributions/env/base-contribution.js.map +1 -1
  91. package/es/core/contributions/env/browser-contribution.d.ts +5 -2
  92. package/es/core/contributions/env/browser-contribution.js +48 -1
  93. package/es/core/contributions/env/browser-contribution.js.map +1 -1
  94. package/es/core/global.d.ts +5 -1
  95. package/es/core/global.js +9 -0
  96. package/es/core/global.js.map +1 -1
  97. package/es/core/stage.d.ts +4 -0
  98. package/es/core/stage.js +12 -1
  99. package/es/core/stage.js.map +1 -1
  100. package/es/graphic/builtin-symbol/arrow2-down.d.ts +12 -0
  101. package/es/graphic/builtin-symbol/arrow2-down.js +24 -0
  102. package/es/graphic/builtin-symbol/arrow2-down.js.map +1 -0
  103. package/es/graphic/builtin-symbol/arrow2-left.js +1 -1
  104. package/es/graphic/builtin-symbol/arrow2-left.js.map +1 -1
  105. package/es/graphic/builtin-symbol/arrow2-right.js +1 -1
  106. package/es/graphic/builtin-symbol/arrow2-right.js.map +1 -1
  107. package/es/graphic/builtin-symbol/arrow2-up.d.ts +12 -0
  108. package/es/graphic/builtin-symbol/arrow2-up.js +24 -0
  109. package/es/graphic/builtin-symbol/arrow2-up.js.map +1 -0
  110. package/es/graphic/builtin-symbol/close.d.ts +13 -0
  111. package/es/graphic/builtin-symbol/close.js +27 -0
  112. package/es/graphic/builtin-symbol/close.js.map +1 -0
  113. package/es/graphic/builtin-symbol/index.d.ts +1 -1
  114. package/es/graphic/builtin-symbol/index.js +11 -1
  115. package/es/graphic/builtin-symbol/index.js.map +1 -1
  116. package/es/graphic/builtin-symbol/line-h.d.ts +13 -0
  117. package/es/graphic/builtin-symbol/line-h.js +26 -0
  118. package/es/graphic/builtin-symbol/line-h.js.map +1 -0
  119. package/es/graphic/builtin-symbol/line-v.d.ts +13 -0
  120. package/es/graphic/builtin-symbol/line-v.js +26 -0
  121. package/es/graphic/builtin-symbol/line-v.js.map +1 -0
  122. package/es/graphic/builtin-symbol/utils.d.ts +13 -5
  123. package/es/graphic/builtin-symbol/utils.js +25 -7
  124. package/es/graphic/builtin-symbol/utils.js.map +1 -1
  125. package/es/graphic/config.js +2 -1
  126. package/es/graphic/config.js.map +1 -1
  127. package/es/graphic/constants.d.ts +22 -0
  128. package/es/graphic/constants.js +26 -0
  129. package/es/graphic/constants.js.map +1 -1
  130. package/es/graphic/symbol.d.ts +2 -1
  131. package/es/graphic/symbol.js +28 -1
  132. package/es/graphic/symbol.js.map +1 -1
  133. package/es/index.d.ts +2 -1
  134. package/es/index.js +3 -1
  135. package/es/index.js.map +1 -1
  136. package/es/interface/global.d.ts +13 -1
  137. package/es/interface/global.js.map +1 -1
  138. package/es/interface/graphic/symbol.d.ts +3 -2
  139. package/es/interface/graphic/symbol.js.map +1 -1
  140. package/es/interface/graphic.d.ts +14 -0
  141. package/es/interface/graphic.js.map +1 -1
  142. package/es/interface/render.d.ts +1 -0
  143. package/es/interface/render.js.map +1 -1
  144. package/es/interface/stage.d.ts +2 -0
  145. package/es/interface/stage.js.map +1 -1
  146. package/es/jsx/graphicType.d.ts +72 -0
  147. package/es/jsx/graphicType.js +112 -0
  148. package/es/jsx/graphicType.js.map +1 -0
  149. package/es/jsx/index.d.ts +2 -0
  150. package/es/jsx/index.js +4 -0
  151. package/es/jsx/index.js.map +1 -0
  152. package/es/jsx/jsx-classic.d.ts +5 -0
  153. package/es/jsx/jsx-classic.js +40 -0
  154. package/es/jsx/jsx-classic.js.map +1 -0
  155. package/es/picker/contributions/canvas-picker/symbol-picker.js +6 -1
  156. package/es/picker/contributions/canvas-picker/symbol-picker.js.map +1 -1
  157. package/es/picker/pick-interceptor.js +2 -3
  158. package/es/picker/pick-interceptor.js.map +1 -1
  159. package/es/plugins/builtin-plugin/html-attribute-plugin.d.ts +13 -0
  160. package/es/plugins/builtin-plugin/html-attribute-plugin.js +71 -0
  161. package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -0
  162. package/es/render/contributions/render/draw-contribution.d.ts +3 -1
  163. package/es/render/contributions/render/draw-contribution.js +4 -0
  164. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  165. package/es/render/contributions/render/symbol-render.js +12 -5
  166. package/es/render/contributions/render/symbol-render.js.map +1 -1
  167. package/es/render/render-service.js +3 -1
  168. package/es/render/render-service.js.map +1 -1
  169. package/es/tsconfig.tsbuildinfo +1 -1
  170. package/package.json +6 -5
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.HtmlAttributePlugin = void 0;
6
+
7
+ const generator_1 = require("../../common/generator"), application_1 = require("../../application"), graphic_1 = require("../../graphic");
8
+
9
+ class HtmlAttributePlugin {
10
+ constructor() {
11
+ this.name = "HtmlAttributePlugin", this.activeEvent = "onRegister", this._uid = generator_1.Generator.GenAutoIncrementId(),
12
+ this.key = this.name + this._uid;
13
+ }
14
+ activate(context) {
15
+ this.pluginService = context, context.stage.hooks.afterRender.tap(this.key, (stage => {
16
+ stage && stage === this.pluginService.stage && this.drawHTML(context.stage.renderService);
17
+ }));
18
+ }
19
+ deactivate(context) {
20
+ context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter((item => item.name !== this.key));
21
+ }
22
+ drawHTML(renderService) {
23
+ "browser" === application_1.application.global.env && renderService.renderTreeRoots.sort(((a, b) => {
24
+ var _a, _b;
25
+ return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : graphic_1.DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : graphic_1.DefaultAttribute.zIndex);
26
+ })).forEach((group => {
27
+ this.renderGroupHTML(group);
28
+ }));
29
+ }
30
+ renderGroupHTML(group) {
31
+ this.renderGraphicHTML(group), group.forEachChildren((g => {
32
+ this.renderGraphicHTML(g);
33
+ }));
34
+ }
35
+ renderGraphicHTML(graphic) {
36
+ const {html: html} = graphic.attribute;
37
+ if (!html) return;
38
+ const stage = graphic.stage;
39
+ if (!stage) return;
40
+ const {dom: dom, container: container, width: width, height: height, style: style, anchorType: anchorType = "boundsLeftTop"} = html;
41
+ graphic.bindDom || (graphic.bindDom = new Map);
42
+ const lastDom = graphic.bindDom.get(dom);
43
+ if (lastDom && (!container || container === lastDom.container)) return;
44
+ let nativeDom, nativeContainer;
45
+ graphic.bindDom.forEach((({wrapGroup: wrapGroup}) => {
46
+ application_1.application.global.removeDom(wrapGroup);
47
+ })), nativeDom = "string" == typeof dom ? (new DOMParser).parseFromString(dom, "text/xml").firstChild : dom;
48
+ const _container = container || (!0 === stage.params.enableHtmlAttribute ? null : stage.params.enableHtmlAttribute);
49
+ nativeContainer = _container ? "string" == typeof _container ? application_1.application.global.getElementById(_container) : _container : graphic.stage.window.getContainer();
50
+ const wrapGroup = application_1.application.global.createDom({
51
+ tagName: "div",
52
+ width: width,
53
+ height: height,
54
+ style: style,
55
+ parent: nativeContainer
56
+ });
57
+ wrapGroup && (wrapGroup.appendChild(nativeDom), graphic.bindDom.set(dom, {
58
+ dom: nativeDom,
59
+ container: container,
60
+ wrapGroup: wrapGroup
61
+ })), wrapGroup.style.pointerEvents = "none", wrapGroup.style.position || (wrapGroup.style.position = "absolute");
62
+ let left = 0, top = 0;
63
+ if ("position" === anchorType) {
64
+ const matrix = graphic.transMatrix;
65
+ left = matrix.e, top = matrix.f;
66
+ } else {
67
+ const b = graphic.AABBBounds;
68
+ left = b.x1, top = b.y1;
69
+ }
70
+ wrapGroup.style.left = `${left}px`, wrapGroup.style.top = `${top}px`;
71
+ }
72
+ }
73
+
74
+ exports.HtmlAttributePlugin = HtmlAttributePlugin;
75
+ //# sourceMappingURL=html-attribute-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins/builtin-plugin/html-attribute-plugin.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD,mDAAgD;AAChD,2CAAiD;AAEjD,MAAa,mBAAmB;IAAhC;QACE,SAAI,GAA0B,qBAAqB,CAAC;QACpD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,qBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IA0GtC,CAAC;IAxGC,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE;YACpD,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;gBAClD,OAAO;aACR;YAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC7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,MAAM,CAAC,YAAY,EAAE,CAAC;SACvD;QAED,MAAM,SAAS,GAAG,yBAAW,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;QAClH,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YACjC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAgB,EAAE,CAAC,CAAC;SACtF;QAED,SAAS,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;QAEvC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC7B,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;SACvC;QACD,IAAI,IAAI,GAAW,CAAC,CAAC;QACrB,IAAI,GAAG,GAAW,CAAC,CAAC;QACpB,IAAI,UAAU,KAAK,UAAU,EAAE;YAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;YACnC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;YAChB,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC;SAChB;aAAM;YACL,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;YAC7B,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC;YACZ,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC;SACZ;QACD,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC;QACnC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;IACnC,CAAC;CACF;AA/GD,kDA+GC","file":"html-attribute-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport type { IGraphic, IPlugin, IPluginService, IRenderService, IDrawContext, IGroup } from '../../interface';\nimport { application } from '../../application';\nimport { DefaultAttribute } from '../../graphic';\n\nexport class HtmlAttributePlugin implements IPlugin {\n name: 'HtmlAttributePlugin' = 'HtmlAttributePlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n context.stage.hooks.afterRender.tap(this.key, stage => {\n if (!(stage && stage === this.pluginService.stage)) {\n return;\n }\n\n this.drawHTML(context.stage.renderService);\n });\n }\n deactivate(context: IPluginService): void {\n context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n\n protected drawHTML(renderService: IRenderService) {\n if (application.global.env === 'browser') {\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroupHTML(group as IGroup);\n });\n }\n }\n\n renderGroupHTML(group: IGroup) {\n this.renderGraphicHTML(group);\n group.forEachChildren((g: IGraphic) => {\n this.renderGraphicHTML(g);\n });\n }\n\n renderGraphicHTML(graphic: IGraphic) {\n const { html } = graphic.attribute;\n if (!html) {\n return;\n }\n const stage = graphic.stage;\n if (!stage) {\n return;\n }\n const { dom, container, width, height, style, anchorType = 'boundsLeftTop' } = html;\n if (!graphic.bindDom) {\n graphic.bindDom = new Map();\n }\n const lastDom = graphic.bindDom.get(dom);\n // 如果存在了(dom存在,且container没有变化),就跳过\n if (lastDom && !(container && container !== lastDom.container)) {\n return;\n }\n // 清除上一次的dom\n graphic.bindDom.forEach(({ wrapGroup }) => {\n application.global.removeDom(wrapGroup);\n });\n // 转化这个dom为nativeDOM\n let nativeDom: HTMLElement;\n if (typeof dom === 'string') {\n nativeDom = new DOMParser().parseFromString(dom, 'text/xml').firstChild as any;\n } else {\n nativeDom = dom;\n }\n // 获取container的dom,默认为window的container\n let nativeContainer;\n const _container =\n container || (stage.params.enableHtmlAttribute === true ? null : stage.params.enableHtmlAttribute);\n if (_container) {\n if (typeof _container === 'string') {\n nativeContainer = application.global.getElementById(_container);\n } else {\n nativeContainer = _container;\n }\n } else {\n // nativeContainer = application.global.getRootElement();\n nativeContainer = graphic.stage.window.getContainer();\n }\n // 创建wrapGroup\n const wrapGroup = application.global.createDom({ tagName: 'div', width, height, style, parent: nativeContainer });\n if (wrapGroup) {\n wrapGroup.appendChild(nativeDom);\n graphic.bindDom.set(dom, { dom: nativeDom, container, wrapGroup: wrapGroup as any });\n }\n // 事件穿透\n wrapGroup.style.pointerEvents = 'none';\n // 定位wrapGroup\n if (!wrapGroup.style.position) {\n wrapGroup.style.position = 'absolute';\n }\n let left: number = 0;\n let top: number = 0;\n if (anchorType === 'position') {\n const matrix = graphic.transMatrix;\n left = matrix.e;\n top = matrix.f;\n } else {\n const b = graphic.AABBBounds;\n left = b.x1;\n top = b.y1;\n }\n wrapGroup.style.left = `${left}px`;\n wrapGroup.style.top = `${top}px`;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { IContext2d, MaybePromise, IGraphic, IGroup, IDrawContext, IRenderService, IGraphicRender, IGraphicRenderDrawParams, IContributionProvider, IDrawItemInterceptorContribution, IDrawContribution, IRenderSelector } from '../../../interface';
1
+ import type { IContext2d, MaybePromise, IGraphic, IGroup, IDrawContext, IRenderService, IGraphicRender, IGraphicRenderDrawParams, IContributionProvider, IDrawItemInterceptorContribution, IDrawContribution, IRenderSelector, IGlobal } from '../../../interface';
2
2
  import type { IBounds } from '@visactor/vutils';
3
3
  import type { ILayerService } from '../../../interface/core';
4
4
  export declare class DefaultDrawContribution implements IDrawContribution {
@@ -13,6 +13,7 @@ export declare class DefaultDrawContribution implements IDrawContribution {
13
13
  backupDirtyBounds: IBounds;
14
14
  currentRenderService: IRenderService;
15
15
  InterceptorContributions: IDrawItemInterceptorContribution[];
16
+ global: IGlobal;
16
17
  constructor(contributions: IGraphicRender[], renderSelector: IRenderSelector, layerService: ILayerService, drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>);
17
18
  init(): void;
18
19
  draw(renderService: IRenderService, drawContext: IDrawContext): MaybePromise<void>;
@@ -25,4 +26,5 @@ export declare class DefaultDrawContribution implements IDrawContribution {
25
26
  protected selectRenderByType(type?: string): IGraphicRender | null;
26
27
  protected selectRenderByNumberType(type?: number): IGraphicRender | null;
27
28
  protected clearScreen(renderService: IRenderService, context: IContext2d, drawContext: IDrawContext): void;
29
+ afterDraw(renderService: IRenderService, drawParams: IDrawContext): void;
28
30
  }
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", {
16
16
  value: !0
17
17
  }), exports.DefaultDrawContribution = void 0;
18
18
 
19
- const inversify_1 = require("inversify"), sort_1 = require("../../../common/sort"), contribution_provider_1 = require("../../../common/contribution-provider"), graphic_1 = require("../../../graphic"), vutils_1 = require("@visactor/vutils"), constants_1 = require("../../../core/constants"), container_1 = require("../../../container"), symbol_1 = require("./symbol"), draw_interceptor_1 = require("./draw-interceptor"), canvas_utils_1 = require("../../../common/canvas-utils");
19
+ const inversify_1 = require("inversify"), sort_1 = require("../../../common/sort"), contribution_provider_1 = require("../../../common/contribution-provider"), graphic_1 = require("../../../graphic"), vutils_1 = require("@visactor/vutils"), constants_1 = require("../../../core/constants"), container_1 = require("../../../container"), symbol_1 = require("./symbol"), draw_interceptor_1 = require("./draw-interceptor"), canvas_utils_1 = require("../../../common/canvas-utils"), constants_2 = require("../../../constants");
20
20
 
21
21
  let DefaultDrawContribution = class {
22
22
  constructor(contributions, renderSelector, layerService, drawItemInterceptorContributions) {
@@ -164,8 +164,10 @@ let DefaultDrawContribution = class {
164
164
  }, 0, 0), context.fillRect(x, y, width, height);
165
165
  }
166
166
  }
167
+ afterDraw(renderService, drawParams) {}
167
168
  };
168
169
 
170
+ __decorate([ (0, inversify_1.inject)(constants_2.VGlobal), __metadata("design:type", Object) ], DefaultDrawContribution.prototype, "global", void 0),
169
171
  __decorate([ (0, inversify_1.postConstruct)(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], DefaultDrawContribution.prototype, "init", null),
170
172
  DefaultDrawContribution = __decorate([ (0, inversify_1.injectable)(), __param(0, (0,
171
173
  inversify_1.multiInject)(symbol_1.GraphicRender)), __param(1, (0, inversify_1.inject)(symbol_1.RenderSelector)), __param(2, (0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/render/contributions/render/draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAkF;AAelF,+CAAgE;AAEhE,iFAA6E;AAC7E,8CAAoD;AAEpD,6CAA6E;AAC7E,uDAAuD;AACvD,kDAA+C;AAC/C,qCAAsF;AACtF,yDAAyD;AACzD,+DAA2D;AAOpD,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IASlC,YAIiD,aAA+B,EACnC,cAA+B,EACjC,YAA2B,EAIjD,gCAAyF;QAN7D,kBAAa,GAAb,aAAa,CAAkB;QACnC,mBAAc,GAAd,cAAc,CAAiB;QACjC,iBAAY,GAAZ,YAAY,CAAe;QAIjD,qCAAgC,GAAhC,gCAAgC,CAAyD;QAE5G,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,IAAI,eAAM,EAAE,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,eAAM,EAAE,CAAC;IACxC,CAAC;IAGD,IAAI;QACF,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAChC,IAAI,IAAI,CAAC,KAAK,EAAE;gBACd,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IA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AC,CAAA;IAC5B,WAAA,IAAA,iBAAK,EAAC,sCAAmB,CAAC,CAAA;;GAlBlB,uBAAuB,CA8UnC;AA9UY,0DAAuB","file":"draw-contribution.js","sourcesContent":["import { injectable, inject, postConstruct, named, multiInject } from 'inversify';\nimport type {\n IContext2d,\n MaybePromise,\n IGraphic,\n IGroup,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n IDrawItemInterceptorContribution,\n IDrawContribution,\n IRenderSelector\n} from '../../../interface';\nimport { findNextGraphic, foreach } from '../../../common/sort';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { DefaultAttribute } from '../../../graphic';\nimport type { IBounds } from '@visactor/vutils';\nimport { Bounds, getRectIntersect, isRectIntersect } from '@visactor/vutils';\nimport { LayerService } from '../../../core/constants';\nimport { container } from '../../../container';\nimport { GraphicRender, IncrementalDrawContribution, RenderSelector } from './symbol';\nimport { DrawItemInterceptor } from './draw-interceptor';\nimport { createColor } from '../../../common/canvas-utils';\nimport type { ILayerService } from '../../../interface/core';\n\n/**\n * 默认的渲染contribution,基于树状结构针对图元的渲染\n */\n@injectable()\nexport class DefaultDrawContribution implements IDrawContribution {\n declare currentRenderMap: Map<number, IGraphicRender>;\n declare defaultRenderMap: Map<number, IGraphicRender>;\n declare styleRenderMap: Map<string, Map<number, IGraphicRender>>;\n declare dirtyBounds: IBounds;\n declare backupDirtyBounds: IBounds;\n declare currentRenderService: IRenderService;\n declare InterceptorContributions: IDrawItemInterceptorContribution[];\n\n constructor(\n // @inject(ContributionProvider)\n // @named(GraphicRender)\n // protected readonly contributions: ContributionProvider<IGraphicRender>,\n @multiInject(GraphicRender) protected readonly contributions: IGraphicRender[],\n @inject(RenderSelector) protected readonly renderSelector: IRenderSelector, // 根据图元类型选择对应的renderItem进行渲染\n @inject(LayerService) protected readonly layerService: ILayerService, // 默认的polygonRender\n // 拦截器\n @inject(ContributionProvider)\n @named(DrawItemInterceptor)\n protected readonly drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>\n ) {\n this.currentRenderMap = new Map();\n this.defaultRenderMap = new Map();\n this.styleRenderMap = new Map();\n this.dirtyBounds = new Bounds();\n this.backupDirtyBounds = new Bounds();\n }\n\n @postConstruct()\n init() {\n this.contributions.forEach(item => {\n if (item.style) {\n const map = this.styleRenderMap.get(item.style) || new Map();\n map.set(item.numberType, item);\n this.styleRenderMap.set(item.style, map);\n } else {\n this.defaultRenderMap.set(item.numberType, item);\n }\n });\n this.InterceptorContributions = this.drawItemInterceptorContributions\n .getContributions()\n .sort((a, b) => a.order - b.order);\n }\n\n draw(renderService: IRenderService, drawContext: IDrawContext): MaybePromise<void> {\n drawContext.drawContribution = this;\n this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap;\n // this.startAtId = drawParams.startAtId;\n this.currentRenderService = renderService;\n // this.drawParams = drawParams;\n const { context, stage, x = 0, y = 0, width, height } = drawContext;\n\n if (!context) {\n return;\n }\n // if (context.drawPromise) {\n // return;\n // }\n const dirtyBounds: IBounds | undefined = this.dirtyBounds.setValue(0, 0, width, height);\n if (stage.dirtyBounds && !stage.dirtyBounds.empty()) {\n const b = getRectIntersect(dirtyBounds, stage.dirtyBounds, false);\n dirtyBounds.x1 = Math.floor(b.x1);\n dirtyBounds.y1 = Math.floor(b.y1);\n dirtyBounds.x2 = Math.ceil(b.x2);\n dirtyBounds.y2 = Math.ceil(b.y2);\n }\n this.backupDirtyBounds.copy(dirtyBounds);\n context.inuse = true;\n // 初始化context\n context.clearMatrix();\n context.setTransformForCurrent(true);\n\n const drawInArea =\n dirtyBounds.width() * context.dpr !== context.canvas.width ||\n dirtyBounds.height() * context.dpr !== context.canvas.height;\n context.save();\n\n // 设置translate\n context.translate(x, y, true);\n if (drawInArea) {\n context.beginPath();\n context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height());\n context.clip();\n }\n\n // 如果存在3d视角,那么不使用dirtyBounds\n if (stage.camera) {\n this.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n this.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n }\n\n this.clearScreen(renderService, context, drawContext);\n // // 渲染的时候图元的起始位置就是x,y\n // this.backupDirtyBounds.translate(-x, -y);\n // this.dirtyBounds.translate(-x, -y);\n\n // // 设置translate\n // context.translate(x, y, true);\n\n context.save();\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroup(group as IGroup, drawContext);\n });\n\n context.restore();\n context.restore();\n context.draw();\n // this.break = false;\n context.inuse = false;\n }\n\n doRegister() {\n throw new Error('暂不支持');\n }\n\n // 找到下一个graphic\n protected _findNextGraphic(group: IGroup): IGraphic | null {\n let parent = group.parent;\n let id = group._uid;\n while (parent) {\n const g = findNextGraphic(parent, id, DefaultAttribute.zIndex);\n if (g) {\n return g;\n }\n id = parent._uid;\n parent = parent.parent;\n }\n return null;\n }\n\n renderGroup(group: IGroup, drawContext: IDrawContext, skipSort?: boolean) {\n if (drawContext.break || group.attribute.visibleAll === false) {\n return;\n }\n if (group.incremental && (drawContext.startAtId == null || drawContext.startAtId === group._uid)) {\n drawContext.break = true;\n this._increaseRender(group, drawContext);\n return;\n }\n\n if (!isRectIntersect(group.AABBBounds, this.dirtyBounds, false)) {\n return;\n }\n\n const tempBounds = this.dirtyBounds.clone();\n\n // 变换dirtyBounds\n const m = group.globalTransMatrix.getInverse();\n this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(m);\n\n this.renderItem(group, drawContext, {\n drawingCb: () => {\n skipSort\n ? group.forEachChildren((item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext);\n } else {\n this.renderItem(item, drawContext);\n }\n })\n : foreach(\n group,\n DefaultAttribute.zIndex,\n (item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext);\n } else {\n this.renderItem(item, drawContext);\n }\n },\n false,\n !!drawContext.context?.camera\n );\n }\n });\n\n this.dirtyBounds.copy(tempBounds);\n }\n\n protected _increaseRender(group: IGroup, drawContext: IDrawContext) {\n const { layer, stage } = drawContext;\n const { subLayers } = layer;\n // 获取渐进渲染层\n let incrementalLayer = subLayers.get(group._uid);\n if (!incrementalLayer) {\n incrementalLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size,\n group\n };\n subLayers.set(group._uid, incrementalLayer);\n }\n // 渲染\n const incrementalContext = incrementalLayer.layer.getNativeHandler().getContext();\n const idc = incrementalLayer.drawContribution || container.get(IncrementalDrawContribution);\n idc.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n idc.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n (idc as any).draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: incrementalLayer.layer,\n context: incrementalContext,\n startAtId: group._uid,\n break: false\n });\n incrementalLayer.drawContribution = idc;\n // this.draw(this.currentRenderService, {...this.drawParams, startAtId: group._uid})\n // this.draw(this.currentRenderService, {...this.drawParams, clear: 'transparent', layer: incrementalContext.layer, context: incrementalContext, startAtId: group._uid})\n const nextGraphic = this._findNextGraphic(group);\n if (nextGraphic) {\n // 如果是下一个渐进渲染层,那就再来一次\n if (nextGraphic.isContainer && nextGraphic.incremental) {\n this._increaseRender(nextGraphic as IGroup, drawContext);\n } else {\n // 如果不是渐进渲染层,那就默认图层渲染\n let afterLayer = subLayers.get(nextGraphic._uid);\n if (!afterLayer) {\n afterLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size\n };\n subLayers.set(nextGraphic._uid, afterLayer);\n }\n const afterContext = afterLayer.layer.getNativeHandler().getContext();\n this.draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: afterLayer.layer,\n context: afterContext,\n startAtId: nextGraphic._uid,\n break: false\n });\n }\n }\n }\n\n getRenderContribution(graphic: IGraphic): IGraphicRender | null {\n let renderer = this.renderSelector.selector(graphic);\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType);\n }\n if (!renderer) {\n renderer = this.selectRenderByType(graphic.type);\n }\n return renderer;\n }\n\n renderItem(graphic: IGraphic, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.beforeDrawItem) {\n if (drawContribution.beforeDrawItem(graphic, this.currentRenderService, drawContext, this, params)) {\n return;\n }\n }\n }\n }\n\n const renderer = this.getRenderContribution(graphic);\n if (!renderer) {\n return;\n }\n\n if (!(graphic.isContainer || isRectIntersect(graphic.AABBBounds, this.dirtyBounds, false))) {\n return;\n }\n\n const skipDraw = drawContext.startAtId != null && graphic._uid !== drawContext.startAtId;\n if (graphic._uid === drawContext.startAtId) {\n drawContext.startAtId = null;\n }\n params && (params.skipDraw = skipDraw);\n if (skipDraw) {\n graphic.isContainer && renderer.draw(graphic, this.currentRenderService, drawContext, params);\n } else {\n renderer.draw(graphic, this.currentRenderService, drawContext, params);\n }\n\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.afterDrawItem) {\n if (drawContribution.afterDrawItem(graphic, this.currentRenderService, drawContext, this)) {\n return;\n }\n }\n }\n }\n }\n // 根据type选择对应的render\n protected selectRenderByType(type?: string): IGraphicRender | null {\n console.warn('未知错误,不应该走到这里');\n return null;\n }\n // 根据type选择对应的render\n protected selectRenderByNumberType(type?: number): IGraphicRender | null {\n return this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);\n }\n\n protected clearScreen(renderService: IRenderService, context: IContext2d, drawContext: IDrawContext) {\n const { clear } = drawContext;\n if (clear) {\n const canvas = context.getCanvas();\n const { width = canvas.width, height = canvas.height } = drawContext;\n const x = 0;\n const y = 0;\n context.clearRect(x, y, width, height);\n context.fillStyle = createColor(\n context,\n clear,\n {\n AABBBounds: { x1: x, y1: y, x2: x + width, y2: y + height }\n },\n 0,\n 0\n );\n context.fillRect(x, y, width, height);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/render/contributions/render/draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAkF;AAgBlF,+CAAgE;AAEhE,iFAA6E;AAC7E,8CAAoD;AAEpD,6CAAmF;AACnF,uDAAuD;AACvD,kDAA+C;AAC/C,qCAAsF;AACtF,yDAAyD;AACzD,+DAA2D;AAE3D,kDAA6C;AAMtC,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAWlC,YAIiD,aAA+B,EACnC,cAA+B,EACjC,YAA2B,EAIjD,gCAAyF;QAN7D,kBAAa,GAAb,aAAa,CAAkB;QACnC,mBAAc,GAAd,cAAc,CAAiB;QACjC,iBAAY,GAAZ,YAAY,CAAe;QAIjD,qCAAgC,GAAhC,gCAAgC,CAAyD;QAE5G,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,IAAI,eAAM,EAAE,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,eAAM,EAAE,CAAC;IACxC,CAAC;IAGD,IAAI;QACF,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAChC,IAAI,IAAI,CAAC,KAAK,EAAE;gBACd,MAAM,GAAG,GAAG,IAAI,CAAC,c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AC,sBAAa,CAAC,CAAA;IAC1B,WAAA,IAAA,kBAAM,EAAC,uBAAc,CAAC,CAAA;IACtB,WAAA,IAAA,kBAAM,EAAC,wBAAY,CAAC,CAAA;IAEpB,WAAA,IAAA,kBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,iBAAK,EAAC,sCAAmB,CAAC,CAAA;;GApBlB,uBAAuB,CAoVnC;AApVY,0DAAuB","file":"draw-contribution.js","sourcesContent":["import { injectable, inject, postConstruct, named, multiInject } from 'inversify';\nimport type {\n IContext2d,\n MaybePromise,\n IGraphic,\n IGroup,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n IDrawItemInterceptorContribution,\n IDrawContribution,\n IRenderSelector,\n IGlobal\n} from '../../../interface';\nimport { findNextGraphic, foreach } from '../../../common/sort';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { DefaultAttribute } from '../../../graphic';\nimport type { IBounds } from '@visactor/vutils';\nimport { Bounds, getRectIntersect, isRectIntersect, last } from '@visactor/vutils';\nimport { LayerService } from '../../../core/constants';\nimport { container } from '../../../container';\nimport { GraphicRender, IncrementalDrawContribution, RenderSelector } from './symbol';\nimport { DrawItemInterceptor } from './draw-interceptor';\nimport { createColor } from '../../../common/canvas-utils';\nimport type { ILayerService } from '../../../interface/core';\nimport { VGlobal } from '../../../constants';\n\n/**\n * 默认的渲染contribution,基于树状结构针对图元的渲染\n */\n@injectable()\nexport class DefaultDrawContribution implements IDrawContribution {\n declare currentRenderMap: Map<number, IGraphicRender>;\n declare defaultRenderMap: Map<number, IGraphicRender>;\n declare styleRenderMap: Map<string, Map<number, IGraphicRender>>;\n declare dirtyBounds: IBounds;\n declare backupDirtyBounds: IBounds;\n declare currentRenderService: IRenderService;\n declare InterceptorContributions: IDrawItemInterceptorContribution[];\n\n @inject(VGlobal) global: IGlobal;\n\n constructor(\n // @inject(ContributionProvider)\n // @named(GraphicRender)\n // protected readonly contributions: ContributionProvider<IGraphicRender>,\n @multiInject(GraphicRender) protected readonly contributions: IGraphicRender[],\n @inject(RenderSelector) protected readonly renderSelector: IRenderSelector, // 根据图元类型选择对应的renderItem进行渲染\n @inject(LayerService) protected readonly layerService: ILayerService, // 默认的polygonRender\n // 拦截器\n @inject(ContributionProvider)\n @named(DrawItemInterceptor)\n protected readonly drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>\n ) {\n this.currentRenderMap = new Map();\n this.defaultRenderMap = new Map();\n this.styleRenderMap = new Map();\n this.dirtyBounds = new Bounds();\n this.backupDirtyBounds = new Bounds();\n }\n\n @postConstruct()\n init() {\n this.contributions.forEach(item => {\n if (item.style) {\n const map = this.styleRenderMap.get(item.style) || new Map();\n map.set(item.numberType, item);\n this.styleRenderMap.set(item.style, map);\n } else {\n this.defaultRenderMap.set(item.numberType, item);\n }\n });\n this.InterceptorContributions = this.drawItemInterceptorContributions\n .getContributions()\n .sort((a, b) => a.order - b.order);\n }\n\n draw(renderService: IRenderService, drawContext: IDrawContext): MaybePromise<void> {\n drawContext.drawContribution = this;\n this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap;\n // this.startAtId = drawParams.startAtId;\n this.currentRenderService = renderService;\n // this.drawParams = drawParams;\n const { context, stage, x = 0, y = 0, width, height } = drawContext;\n\n if (!context) {\n return;\n }\n // if (context.drawPromise) {\n // return;\n // }\n const dirtyBounds: IBounds | undefined = this.dirtyBounds.setValue(0, 0, width, height);\n if (stage.dirtyBounds && !stage.dirtyBounds.empty()) {\n const b = getRectIntersect(dirtyBounds, stage.dirtyBounds, false);\n dirtyBounds.x1 = Math.floor(b.x1);\n dirtyBounds.y1 = Math.floor(b.y1);\n dirtyBounds.x2 = Math.ceil(b.x2);\n dirtyBounds.y2 = Math.ceil(b.y2);\n }\n this.backupDirtyBounds.copy(dirtyBounds);\n context.inuse = true;\n // 初始化context\n context.clearMatrix();\n context.setTransformForCurrent(true);\n\n const drawInArea =\n dirtyBounds.width() * context.dpr !== context.canvas.width ||\n dirtyBounds.height() * context.dpr !== context.canvas.height;\n context.save();\n\n // 设置translate\n context.translate(x, y, true);\n if (drawInArea) {\n context.beginPath();\n context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height());\n context.clip();\n }\n\n // 如果存在3d视角,那么不使用dirtyBounds\n if (stage.camera) {\n this.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n this.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n }\n\n this.clearScreen(renderService, context, drawContext);\n // // 渲染的时候图元的起始位置就是x,y\n // this.backupDirtyBounds.translate(-x, -y);\n // this.dirtyBounds.translate(-x, -y);\n\n // // 设置translate\n // context.translate(x, y, true);\n\n context.save();\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroup(group as IGroup, drawContext);\n });\n\n context.restore();\n context.restore();\n context.draw();\n // this.break = false;\n context.inuse = false;\n }\n\n doRegister() {\n throw new Error('暂不支持');\n }\n\n // 找到下一个graphic\n protected _findNextGraphic(group: IGroup): IGraphic | null {\n let parent = group.parent;\n let id = group._uid;\n while (parent) {\n const g = findNextGraphic(parent, id, DefaultAttribute.zIndex);\n if (g) {\n return g;\n }\n id = parent._uid;\n parent = parent.parent;\n }\n return null;\n }\n\n renderGroup(group: IGroup, drawContext: IDrawContext, skipSort?: boolean) {\n if (drawContext.break || group.attribute.visibleAll === false) {\n return;\n }\n if (group.incremental && (drawContext.startAtId == null || drawContext.startAtId === group._uid)) {\n drawContext.break = true;\n this._increaseRender(group, drawContext);\n return;\n }\n\n if (!isRectIntersect(group.AABBBounds, this.dirtyBounds, false)) {\n return;\n }\n\n const tempBounds = this.dirtyBounds.clone();\n\n // 变换dirtyBounds\n const m = group.globalTransMatrix.getInverse();\n this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(m);\n\n this.renderItem(group, drawContext, {\n drawingCb: () => {\n skipSort\n ? group.forEachChildren((item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext);\n } else {\n this.renderItem(item, drawContext);\n }\n })\n : foreach(\n group,\n DefaultAttribute.zIndex,\n (item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext);\n } else {\n this.renderItem(item, drawContext);\n }\n },\n false,\n !!drawContext.context?.camera\n );\n }\n });\n\n this.dirtyBounds.copy(tempBounds);\n }\n\n protected _increaseRender(group: IGroup, drawContext: IDrawContext) {\n const { layer, stage } = drawContext;\n const { subLayers } = layer;\n // 获取渐进渲染层\n let incrementalLayer = subLayers.get(group._uid);\n if (!incrementalLayer) {\n incrementalLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size,\n group\n };\n subLayers.set(group._uid, incrementalLayer);\n }\n // 渲染\n const incrementalContext = incrementalLayer.layer.getNativeHandler().getContext();\n const idc = incrementalLayer.drawContribution || container.get(IncrementalDrawContribution);\n idc.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n idc.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n (idc as any).draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: incrementalLayer.layer,\n context: incrementalContext,\n startAtId: group._uid,\n break: false\n });\n incrementalLayer.drawContribution = idc;\n // this.draw(this.currentRenderService, {...this.drawParams, startAtId: group._uid})\n // this.draw(this.currentRenderService, {...this.drawParams, clear: 'transparent', layer: incrementalContext.layer, context: incrementalContext, startAtId: group._uid})\n const nextGraphic = this._findNextGraphic(group);\n if (nextGraphic) {\n // 如果是下一个渐进渲染层,那就再来一次\n if (nextGraphic.isContainer && nextGraphic.incremental) {\n this._increaseRender(nextGraphic as IGroup, drawContext);\n } else {\n // 如果不是渐进渲染层,那就默认图层渲染\n let afterLayer = subLayers.get(nextGraphic._uid);\n if (!afterLayer) {\n afterLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size\n };\n subLayers.set(nextGraphic._uid, afterLayer);\n }\n const afterContext = afterLayer.layer.getNativeHandler().getContext();\n this.draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: afterLayer.layer,\n context: afterContext,\n startAtId: nextGraphic._uid,\n break: false\n });\n }\n }\n }\n\n getRenderContribution(graphic: IGraphic): IGraphicRender | null {\n let renderer = this.renderSelector.selector(graphic);\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType);\n }\n if (!renderer) {\n renderer = this.selectRenderByType(graphic.type);\n }\n return renderer;\n }\n\n renderItem(graphic: IGraphic, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.beforeDrawItem) {\n if (drawContribution.beforeDrawItem(graphic, this.currentRenderService, drawContext, this, params)) {\n return;\n }\n }\n }\n }\n\n const renderer = this.getRenderContribution(graphic);\n if (!renderer) {\n return;\n }\n\n if (!(graphic.isContainer || isRectIntersect(graphic.AABBBounds, this.dirtyBounds, false))) {\n return;\n }\n\n const skipDraw = drawContext.startAtId != null && graphic._uid !== drawContext.startAtId;\n if (graphic._uid === drawContext.startAtId) {\n drawContext.startAtId = null;\n }\n params && (params.skipDraw = skipDraw);\n if (skipDraw) {\n graphic.isContainer && renderer.draw(graphic, this.currentRenderService, drawContext, params);\n } else {\n renderer.draw(graphic, this.currentRenderService, drawContext, params);\n }\n\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.afterDrawItem) {\n if (drawContribution.afterDrawItem(graphic, this.currentRenderService, drawContext, this)) {\n return;\n }\n }\n }\n }\n }\n // 根据type选择对应的render\n protected selectRenderByType(type?: string): IGraphicRender | null {\n console.warn('未知错误,不应该走到这里');\n return null;\n }\n // 根据type选择对应的render\n protected selectRenderByNumberType(type?: number): IGraphicRender | null {\n return this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);\n }\n\n protected clearScreen(renderService: IRenderService, context: IContext2d, drawContext: IDrawContext) {\n const { clear } = drawContext;\n if (clear) {\n const canvas = context.getCanvas();\n const { width = canvas.width, height = canvas.height } = drawContext;\n const x = 0;\n const y = 0;\n context.clearRect(x, y, width, height);\n context.fillStyle = createColor(\n context,\n clear,\n {\n AABBBounds: { x1: x, y1: y, x2: x + width, y2: y + height }\n },\n 0,\n 0\n );\n context.fillRect(x, y, width, height);\n }\n }\n\n afterDraw(renderService: IRenderService, drawParams: IDrawContext) {\n return;\n }\n}\n"]}
@@ -35,15 +35,22 @@ let DefaultCanvasSymbolRender = class extends base_render_1.BaseRender {
35
35
  const {keepDirIn3d: keepDirIn3d = symbolAttribute.keepDirIn3d} = symbol.attribute, z = null !== (_a = this.z) && void 0 !== _a ? _a : 0;
36
36
  if (context.beginPath(), keepDirIn3d && context.camera && context.project) {
37
37
  const p = context.project(x, y, z), camera = context.camera;
38
- context.camera = null, !1 === parsedPath.draw(context, size, p.x, p.y) && context.closePath(),
39
- context.camera = camera;
40
- } else !1 === parsedPath.draw(context, size, x, y, z) && context.closePath();
38
+ context.camera = null, !1 === parsedPath.draw(context, size, p.x, p.y, void 0, ((p, a) => {
39
+ a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y),
40
+ context.fill())), a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY),
41
+ context.stroke()));
42
+ })) && context.closePath(), context.camera = camera;
43
+ } else !1 === parsedPath.draw(context, size, x, y, z, ((p, a) => {
44
+ a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y),
45
+ context.fill())), a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY),
46
+ context.stroke()));
47
+ })) && context.closePath();
41
48
  this._symbolRenderContribitions || (this._symbolRenderContribitions = this.symbolRenderContribitions.getContributions() || [],
42
49
  this._symbolRenderContribitions.sort(((a, b) => b.order - a.order))), this._symbolRenderContribitions.forEach((c => {
43
50
  c.time === enums_1.BaseRenderContributionTime.beforeFillStroke && c.drawShape(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
44
51
  })), context.setShadowStyle && context.setShadowStyle(symbol, symbol.attribute, symbolAttribute),
45
- doFill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute),
46
- context.fill())), doStroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute),
52
+ doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute),
53
+ context.fill())), doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute),
47
54
  context.stroke())), this._symbolRenderContribitions.forEach((c => {
48
55
  c.time === enums_1.BaseRenderContributionTime.afterFillStroke && c.drawShape(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
49
56
  }));
@@ -1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I,CAAC;QAE1C,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,IAAA,qBAAa,EAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE;YAC7D,OAAO,CAAC,sBAAsB,EAAE,CAAC;YACjC,OAAO;SACR;QAED,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC3D,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAEX,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,8BAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF,CAAA;AA/OY,yBAAyB;IADrC,IAAA,sBAAU,GAAE;IASR,WAAA,IAAA,kBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,iBAAK,EAAC,oCAAwB,CAAC,CAAA;;GATvB,yBAAyB,CA+OrC;AA/OY,8DAAyB","file":"symbol-render.js","sourcesContent":["import { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { inject, injectable, named } from 'inversify';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport { SYMBOL_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider\n} from '../../../interface';\nimport type {} from '../../render-service';\nimport { BaseRender } from './base-render';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { SymbolRenderContribution } from './contributions/constants';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\n\n@injectable()\nexport class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number = SYMBOL_NUMBER_TYPE;\n declare z: number;\n\n protected _symbolRenderContribitions: ISymbolRenderContribution[];\n\n constructor(\n @inject(ContributionProvider)\n @named(SymbolRenderContribution)\n protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>\n ) {\n super();\n }\n\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n\n const {\n size = symbolAttribute.size,\n fill = symbolAttribute.fill,\n background,\n fillOpacity = symbolAttribute.fillOpacity,\n strokeOpacity = symbolAttribute.strokeOpacity,\n opacity = symbolAttribute.opacity,\n lineWidth = symbolAttribute.lineWidth,\n stroke = symbolAttribute.stroke,\n visible = symbolAttribute.visible,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY\n } = symbol.attribute;\n\n // 不绘制或者透明\n const fVisible = fillVisible(opacity, fillOpacity, fill);\n const sVisible = strokeVisible(opacity, strokeOpacity);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(symbol.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 const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { keepDirIn3d = symbolAttribute.keepDirIn3d } = symbol.attribute;\n const z = this.z ?? 0;\n context.beginPath();\n if (keepDirIn3d && context.camera && context.project) {\n const p = context.project(x, y, z);\n const camera = context.camera;\n context.camera = null;\n if (parsedPath.draw(context, size, p.x, p.y) === false) {\n context.closePath();\n }\n context.camera = camera;\n } else {\n if (parsedPath.draw(context, size, x, y, z) === false) {\n context.closePath();\n }\n }\n\n if (!this._symbolRenderContribitions) {\n this._symbolRenderContribitions = this.symbolRenderContribitions.getContributions() || [];\n this._symbolRenderContribitions.sort((a, b) => b.order - a.order);\n }\n this._symbolRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.beforeFillStroke) {\n // c.useStyle && context.setCommonStyle(symbol, symbol.attribute, x, y, symbolAttribute);\n c.drawShape(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n\n // if (fill !== false) {\n // context.setCommonStyle(symbol.attribute, symbolAttribute);\n // context.fill();\n // }\n // if (stroke !== false) {\n // context.setStrokeStyle(symbol.attribute, symbolAttribute);\n // context.stroke();\n // }\n\n // shadow\n context.setShadowStyle && context.setShadowStyle(symbol, symbol.attribute, symbolAttribute);\n\n if (doFill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else if (fVisible) {\n context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(\n symbol,\n symbol.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute\n );\n context.stroke();\n }\n }\n\n this._symbolRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.afterFillStroke) {\n c.drawShape(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n context.highPerformanceSave();\n\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n // let { x = symbolAttribute.x, y = symbolAttribute.y } = symbol.attribute;\n\n // const transMatrix = symbol.transMatrix;\n // const onlyTranslate = transMatrix.onlyTranslate();\n // // 只有translate,那么不设置矩阵,通过xy进行偏移\n // if (onlyTranslate) {\n // const point = symbol.getOffsetXY(symbolAttribute);\n // x += point.x;\n // y += point.y;\n // // 当前context有rotate/scale,重置matrix\n // context.setTransformForCurrent();\n // } else {\n // // 如果存在translate,那么存在三种情况:不需要设置2d矩阵,需要设置2d矩阵,需要修改2d矩阵然后设置\n // // 1. 如果通过3d变换绘制,那么也不需要设置矩阵\n // // 2. 如果缩放等操作依然通过\n\n // const { keepDirIn3d = symbolAttribute.keepDirIn3d, scaleX, scaleY, z } = symbol.attribute;\n // if (context.camera && context.project) {\n // // 如果保持3d视角,那么需要设置2d矩阵,但是需要进行修改,因为通过投影改变位置,但是需要进行2d缩放和旋转变换\n // if (keepDirIn3d) {\n // const p = context.project(x, y, z);\n // context.translate(p.x, p.y, false);\n // context.scale(scaleX, scaleY, false);\n // context.rotate(scaleX, false)\n // context.translate(-p.x, -p.y, false);\n // context.setTransformForCurrent();\n // } else { // 不保持3d视角,所有变换均通过3d矩阵完成,不需要2d的矩阵\n // context.setTransform(1, 0, 0, 1, 0, 0, true);\n // }\n // } else {\n // // 直接设置矩阵即可\n // // 性能较差\n // x = 0;\n // y = 0;\n // context.transformFromMatrix(symbol.transMatrix, true);\n // }\n // }\n const data = this.transform(symbol, symbolAttribute, context);\n const { x, y, z, lastModelMatrix } = data;\n\n this.z = z;\n if (drawPathProxy(symbol, context, x, y, drawContext, params)) {\n context.highPerformanceRestore();\n return;\n }\n\n this.drawShape(symbol, context, x, y, drawContext, params);\n this.z = 0;\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.highPerformanceRestore();\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/render/contributions/render/symbol-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wEAAkE;AAClE,yCAAsD;AAEtD,iFAA6E;AAC7E,kDAAkD;AAClD,0DAAgE;AAehE,+CAA2C;AAC3C,iDAAmE;AACnE,yDAAqE;AACrE,mCAAwF;AAGjF,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,wBAAmB;IAOhE,YAGqB,yBAA2E;QAE9F,KAAK,EAAE,CAAC;QAFW,8BAAyB,GAAzB,yBAAyB,CAAkD;QARhG,eAAU,GAAW,8BAAkB,CAAC;IAWxC,CAAC;IAED,SAAS,CACP,MAAe,EACf,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;;QAGZ,MAAM,eAAe,GAAG,IAAA,gBAAQ,EAAC,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,MAAM,CAAC;QAE/D,MAAM,EACJ,IAAI,GAAG,eAAe,CAAC,IAAI,EAC3B,IAAI,GAAG,eAAe,CAAC,IAAI,EAC3B,UAAU,EACV,WAAW,GAAG,eAAe,CAAC,WAAW,EACzC,aAAa,GAAG,eAAe,CAAC,aAAa,EAC7C,OAAO,GAAG,eAAe,CAAC,OAAO,EACjC,SAAS,GAAG,eAAe,CAAC,SAAS,EACrC,MAAM,GAAG,eAAe,CAAC,MAAM,EAC/B,OAAO,GAAG,eAAe,CAAC,OAAO,EACjC,CA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,WAAA,IAAA,iBAAK,EAAC,oCAAwB,CAAC,CAAA;;GATvB,yBAAyB,CAsRrC;AAtRY,8DAAyB","file":"symbol-render.js","sourcesContent":["import { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { inject, injectable, named } from 'inversify';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport { SYMBOL_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider\n} from '../../../interface';\nimport type {} from '../../render-service';\nimport { BaseRender } from './base-render';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { SymbolRenderContribution } from './contributions/constants';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\n\n@injectable()\nexport class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number = SYMBOL_NUMBER_TYPE;\n declare z: number;\n\n protected _symbolRenderContribitions: ISymbolRenderContribution[];\n\n constructor(\n @inject(ContributionProvider)\n @named(SymbolRenderContribution)\n protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>\n ) {\n super();\n }\n\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n\n const {\n size = symbolAttribute.size,\n fill = symbolAttribute.fill,\n background,\n fillOpacity = symbolAttribute.fillOpacity,\n strokeOpacity = symbolAttribute.strokeOpacity,\n opacity = symbolAttribute.opacity,\n lineWidth = symbolAttribute.lineWidth,\n stroke = symbolAttribute.stroke,\n visible = symbolAttribute.visible,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY\n } = symbol.attribute;\n\n // 不绘制或者透明\n const fVisible = fillVisible(opacity, fillOpacity, fill);\n const sVisible = strokeVisible(opacity, strokeOpacity);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(symbol.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 const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { keepDirIn3d = symbolAttribute.keepDirIn3d } = symbol.attribute;\n const z = this.z ?? 0;\n context.beginPath();\n if (keepDirIn3d && context.camera && context.project) {\n const p = context.project(x, y, z);\n const camera = context.camera;\n context.camera = null;\n if (\n parsedPath.draw(context, size, p.x, p.y, undefined, (p, a) => {\n if (a.fill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setCommonStyle(symbol, a, originX - x, originY - y);\n context.fill();\n }\n }\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY);\n context.stroke();\n }\n }\n }) === false\n ) {\n context.closePath();\n }\n context.camera = camera;\n } else {\n if (\n parsedPath.draw(context, size, x, y, z, (p, a) => {\n if (a.fill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setCommonStyle(symbol, a, originX - x, originY - y);\n context.fill();\n }\n }\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY);\n context.stroke();\n }\n }\n }) === false\n ) {\n context.closePath();\n }\n }\n\n if (!this._symbolRenderContribitions) {\n this._symbolRenderContribitions = this.symbolRenderContribitions.getContributions() || [];\n this._symbolRenderContribitions.sort((a, b) => b.order - a.order);\n }\n this._symbolRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.beforeFillStroke) {\n // c.useStyle && context.setCommonStyle(symbol, symbol.attribute, x, y, symbolAttribute);\n c.drawShape(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n\n // if (fill !== false) {\n // context.setCommonStyle(symbol.attribute, symbolAttribute);\n // context.fill();\n // }\n // if (stroke !== false) {\n // context.setStrokeStyle(symbol.attribute, symbolAttribute);\n // context.stroke();\n // }\n\n // shadow\n context.setShadowStyle && context.setShadowStyle(symbol, symbol.attribute, symbolAttribute);\n\n // svg就不用fill和stroke了\n if (doFill && !parsedPath.isSvg) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else if (fVisible) {\n context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(\n symbol,\n symbol.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute\n );\n context.stroke();\n }\n }\n\n this._symbolRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.afterFillStroke) {\n c.drawShape(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n context.highPerformanceSave();\n\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n // let { x = symbolAttribute.x, y = symbolAttribute.y } = symbol.attribute;\n\n // const transMatrix = symbol.transMatrix;\n // const onlyTranslate = transMatrix.onlyTranslate();\n // // 只有translate,那么不设置矩阵,通过xy进行偏移\n // if (onlyTranslate) {\n // const point = symbol.getOffsetXY(symbolAttribute);\n // x += point.x;\n // y += point.y;\n // // 当前context有rotate/scale,重置matrix\n // context.setTransformForCurrent();\n // } else {\n // // 如果存在translate,那么存在三种情况:不需要设置2d矩阵,需要设置2d矩阵,需要修改2d矩阵然后设置\n // // 1. 如果通过3d变换绘制,那么也不需要设置矩阵\n // // 2. 如果缩放等操作依然通过\n\n // const { keepDirIn3d = symbolAttribute.keepDirIn3d, scaleX, scaleY, z } = symbol.attribute;\n // if (context.camera && context.project) {\n // // 如果保持3d视角,那么需要设置2d矩阵,但是需要进行修改,因为通过投影改变位置,但是需要进行2d缩放和旋转变换\n // if (keepDirIn3d) {\n // const p = context.project(x, y, z);\n // context.translate(p.x, p.y, false);\n // context.scale(scaleX, scaleY, false);\n // context.rotate(scaleX, false)\n // context.translate(-p.x, -p.y, false);\n // context.setTransformForCurrent();\n // } else { // 不保持3d视角,所有变换均通过3d矩阵完成,不需要2d的矩阵\n // context.setTransform(1, 0, 0, 1, 0, 0, true);\n // }\n // } else {\n // // 直接设置矩阵即可\n // // 性能较差\n // x = 0;\n // y = 0;\n // context.transformFromMatrix(symbol.transMatrix, true);\n // }\n // }\n const data = this.transform(symbol, symbolAttribute, context);\n const { x, y, z, lastModelMatrix } = data;\n\n this.z = z;\n if (drawPathProxy(symbol, context, x, y, drawContext, params)) {\n context.highPerformanceRestore();\n return;\n }\n\n this.drawShape(symbol, context, x, y, drawContext, params);\n this.z = 0;\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.highPerformanceRestore();\n }\n}\n"]}
@@ -42,7 +42,9 @@ let DefaultRenderService = class {
42
42
  draw(params) {
43
43
  this.drawContribution.draw(this, Object.assign({}, this.drawParams));
44
44
  }
45
- afterDraw(params) {}
45
+ afterDraw(params) {
46
+ this.drawContribution.afterDraw && this.drawContribution.afterDraw(this, Object.assign({}, this.drawParams));
47
+ }
46
48
  render(groups, params) {
47
49
  this.renderTreeRoots = groups, this.drawParams = params;
48
50
  const updateBounds = params.updateBounds;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/render/render-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA+C;AAG/C,mDAA0D;AAE7C,QAAA,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAC5C,QAAA,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAO1E,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAO/B,YAEmB,gBAAmC;QAAnC,qBAAgB,GAAhB,gBAAgB,CAAmB;IACnD,CAAC;IAGJ,OAAO,CAAC,YAAqB;QAC3B,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAC/B,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IACS,QAAQ,CAAC,CAAW,EAAE,YAAqB;QACnD,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE;YACpB,IAAI,CAAC,QAAQ,CAAC,CAAa,EAAE,YAAY,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,iBAAiB;QACf,OAAO;IACT,CAAC;IAED,UAAU,CAAC,MAAgC;QACzC,OAAO;IACT,CAAC;IAED,IAAI,CAAC,MAAgC;QACnC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,oBAAO,IAAI,CAAC,UAAU,EAAG,CAAC;IAC3D,CAAC;IAED,SAAS,CAAC,MAAgC;QACxC,OAAO;IACT,CAAC;IAED,MAAM,CAAC,MAAgB,EAAE,MAAgC;QACvD,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;CACF,CAAA;AApDY,oBAAoB;IADhC,IAAA,sBAAU,GAAE;IASR,WAAA,IAAA,kBAAM,EAAC,yBAAgB,CAAC,CAAA;;GARhB,oBAAoB,CAoDhC;AApDY,oDAAoB","file":"render-service.js","sourcesContent":["import { injectable, inject } from 'inversify';\nimport type { IAABBBounds, IBounds } from '@visactor/vutils';\nimport type { IGroup, IGraphic, IRenderService, IRenderServiceDrawParams, IDrawContribution } from '../interface';\nimport { DrawContribution } from './contributions/render';\n\nexport const RenderService = Symbol.for('RenderService');\nexport const BeforeRenderConstribution = Symbol.for('BeforeRenderConstribution');\n\n/**\n * 渲染用的service,通常和stage一一绑定,\n * 并不是单例模式,所以会绑定此次渲染的一些数据\n */\n@injectable()\nexport class DefaultRenderService implements IRenderService {\n // 每次render都会变的数据\n dirtyBounds: IBounds;\n renderTreeRoots: IGraphic[]; // 此次render的数组\n renderLists: IGraphic[];\n drawParams: IRenderServiceDrawParams;\n\n constructor(\n @inject(DrawContribution)\n private readonly drawContribution: IDrawContribution\n ) {}\n\n // 渲染前准备工作,计算bounds等逻辑\n prepare(updateBounds: boolean): void {\n this.renderTreeRoots.forEach(g => {\n this._prepare(g, updateBounds);\n });\n return;\n }\n protected _prepare(g: IGraphic, updateBounds: boolean) {\n g.forEachChildren(g => {\n this._prepare(g as IGraphic, updateBounds);\n });\n g.update({ bounds: updateBounds, trans: true });\n }\n // 获取要渲染的list,可能存在一些不用渲染的内容,以及外描边\n prepareRenderList(): void {\n return;\n }\n // 渲染前流程\n beforeDraw(params: IRenderServiceDrawParams): void {\n return;\n }\n // 具体渲染\n draw(params: IRenderServiceDrawParams): void {\n this.drawContribution.draw(this, { ...this.drawParams });\n }\n // 渲染后流程\n afterDraw(params: IRenderServiceDrawParams): void {\n return;\n }\n // 对外暴露的绘制方法\n render(groups: IGroup[], params: IRenderServiceDrawParams): void {\n this.renderTreeRoots = groups;\n this.drawParams = params;\n const updateBounds = params.updateBounds;\n this.prepare(updateBounds);\n this.prepareRenderList();\n this.beforeDraw(params);\n this.draw(params);\n this.afterDraw(params);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/render/render-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA+C;AAG/C,mDAA0D;AAE7C,QAAA,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAC5C,QAAA,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAO1E,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAO/B,YAEmB,gBAAmC;QAAnC,qBAAgB,GAAhB,gBAAgB,CAAmB;IACnD,CAAC;IAGJ,OAAO,CAAC,YAAqB;QAC3B,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAC/B,IAAI,CAAC,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BAAM,EAAC,yBAAgB,CAAC,CAAA;;GARhB,oBAAoB,CAqDhC;AArDY,oDAAoB","file":"render-service.js","sourcesContent":["import { injectable, inject } from 'inversify';\nimport type { IAABBBounds, IBounds } from '@visactor/vutils';\nimport type { IGroup, IGraphic, IRenderService, IRenderServiceDrawParams, IDrawContribution } from '../interface';\nimport { DrawContribution } from './contributions/render';\n\nexport const RenderService = Symbol.for('RenderService');\nexport const BeforeRenderConstribution = Symbol.for('BeforeRenderConstribution');\n\n/**\n * 渲染用的service,通常和stage一一绑定,\n * 并不是单例模式,所以会绑定此次渲染的一些数据\n */\n@injectable()\nexport class DefaultRenderService implements IRenderService {\n // 每次render都会变的数据\n dirtyBounds: IBounds;\n renderTreeRoots: IGraphic[]; // 此次render的数组\n renderLists: IGraphic[];\n drawParams: IRenderServiceDrawParams;\n\n constructor(\n @inject(DrawContribution)\n private readonly drawContribution: IDrawContribution\n ) {}\n\n // 渲染前准备工作,计算bounds等逻辑\n prepare(updateBounds: boolean): void {\n this.renderTreeRoots.forEach(g => {\n this._prepare(g, updateBounds);\n });\n return;\n }\n protected _prepare(g: IGraphic, updateBounds: boolean) {\n g.forEachChildren(g => {\n this._prepare(g as IGraphic, updateBounds);\n });\n g.update({ bounds: updateBounds, trans: true });\n }\n // 获取要渲染的list,可能存在一些不用渲染的内容,以及外描边\n prepareRenderList(): void {\n return;\n }\n // 渲染前流程\n beforeDraw(params: IRenderServiceDrawParams): void {\n return;\n }\n // 具体渲染\n draw(params: IRenderServiceDrawParams): void {\n this.drawContribution.draw(this, { ...this.drawParams });\n }\n // 渲染后流程\n afterDraw(params: IRenderServiceDrawParams): void {\n this.drawContribution.afterDraw && this.drawContribution.afterDraw(this, { ...this.drawParams });\n return;\n }\n // 对外暴露的绘制方法\n render(groups: IGroup[], params: IRenderServiceDrawParams): void {\n this.renderTreeRoots = groups;\n this.drawParams = params;\n const updateBounds = params.updateBounds;\n this.prepare(updateBounds);\n this.prepareRenderList();\n this.beforeDraw(params);\n this.draw(params);\n this.afterDraw(params);\n }\n}\n"]}