@visactor/vrender-core 0.22.7-alpha.3 → 0.23.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/cjs/canvas/constants.js +1 -2
  2. package/cjs/canvas/empty-context.d.ts +1 -0
  3. package/cjs/canvas/empty-context.js +4 -0
  4. package/cjs/canvas/empty-context.js.map +1 -1
  5. package/cjs/color-string/interpolate.d.ts +1 -0
  6. package/cjs/color-string/interpolate.js +7 -2
  7. package/cjs/color-string/interpolate.js.map +1 -1
  8. package/cjs/color-string/store.js +2 -1
  9. package/cjs/common/enums.js +1 -2
  10. package/cjs/common/performance-raf.d.ts +8 -0
  11. package/cjs/common/performance-raf.js +31 -0
  12. package/cjs/common/performance-raf.js.map +1 -0
  13. package/cjs/common/render-area.js +1 -0
  14. package/cjs/common/store.js +1 -2
  15. package/cjs/common/text.js +1 -1
  16. package/cjs/common/utils.js +1 -1
  17. package/cjs/core/application.js +1 -1
  18. package/cjs/core/camera.js +1 -1
  19. package/cjs/core/constants.js +1 -1
  20. package/cjs/core/core-modules.js +1 -1
  21. package/cjs/core/global-module.js +0 -2
  22. package/cjs/core/global.d.ts +3 -0
  23. package/cjs/core/global.js +13 -3
  24. package/cjs/core/global.js.map +1 -1
  25. package/cjs/core/stage.d.ts +3 -1
  26. package/cjs/core/stage.js +24 -19
  27. package/cjs/core/stage.js.map +1 -1
  28. package/cjs/event/event-system.js +7 -6
  29. package/cjs/event/event-system.js.map +1 -1
  30. package/cjs/graphic/graphic.d.ts +4 -3
  31. package/cjs/graphic/graphic.js +16 -22
  32. package/cjs/graphic/graphic.js.map +1 -1
  33. package/cjs/index.d.ts +1 -3
  34. package/cjs/index.js +16 -17
  35. package/cjs/index.js.map +1 -1
  36. package/cjs/interface/animate.d.ts +5 -0
  37. package/cjs/interface/animate.js.map +1 -1
  38. package/cjs/interface/context.d.ts +1 -0
  39. package/cjs/interface/context.js.map +1 -1
  40. package/cjs/interface/global.d.ts +2 -0
  41. package/cjs/interface/global.js.map +1 -1
  42. package/cjs/interface/graphic.d.ts +3 -1
  43. package/cjs/interface/graphic.js.map +1 -1
  44. package/cjs/interface/index.d.ts +1 -1
  45. package/cjs/interface/index.js +9 -9
  46. package/cjs/interface/index.js.map +1 -1
  47. package/cjs/interface/render.d.ts +6 -0
  48. package/cjs/interface/render.js.map +1 -1
  49. package/cjs/interface/stage.d.ts +1 -0
  50. package/cjs/interface/stage.js.map +1 -1
  51. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -2
  52. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +6 -5
  53. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  54. package/cjs/render/contributions/render/arc-render.d.ts +4 -2
  55. package/cjs/render/contributions/render/arc-render.js +19 -17
  56. package/cjs/render/contributions/render/arc-render.js.map +1 -1
  57. package/cjs/render/contributions/render/base-render.d.ts +2 -2
  58. package/cjs/render/contributions/render/base-render.js +2 -2
  59. package/cjs/render/contributions/render/base-render.js.map +1 -1
  60. package/cjs/render/contributions/render/draw-contribution.d.ts +1 -0
  61. package/cjs/render/contributions/render/draw-contribution.js +23 -19
  62. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  63. package/cjs/render/contributions/render/draw-interceptor.js +1 -0
  64. package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
  65. package/cjs/render/contributions/render/group-render.d.ts +2 -2
  66. package/cjs/render/contributions/render/group-render.js +14 -10
  67. package/cjs/render/contributions/render/group-render.js.map +1 -1
  68. package/cjs/render/contributions/render/rect-render.d.ts +3 -1
  69. package/cjs/render/contributions/render/rect-render.js +17 -15
  70. package/cjs/render/contributions/render/rect-render.js.map +1 -1
  71. package/cjs/render/contributions/render/symbol-render.d.ts +4 -2
  72. package/cjs/render/contributions/render/symbol-render.js +16 -11
  73. package/cjs/render/contributions/render/symbol-render.js.map +1 -1
  74. package/dist/index.es.js +2507 -5202
  75. package/es/canvas/constants.js +1 -2
  76. package/es/canvas/empty-context.d.ts +1 -0
  77. package/es/canvas/empty-context.js +4 -0
  78. package/es/canvas/empty-context.js.map +1 -1
  79. package/es/color-string/interpolate.d.ts +1 -0
  80. package/es/color-string/interpolate.js +4 -0
  81. package/es/color-string/interpolate.js.map +1 -1
  82. package/es/color-string/store.js +2 -1
  83. package/es/common/enums.js +1 -2
  84. package/es/common/performance-raf.d.ts +8 -0
  85. package/es/common/performance-raf.js +23 -0
  86. package/es/common/performance-raf.js.map +1 -0
  87. package/es/common/render-area.js +2 -1
  88. package/es/common/store.js +1 -2
  89. package/es/common/text.js +1 -1
  90. package/es/common/utils.js +1 -1
  91. package/es/core/application.js +1 -1
  92. package/es/core/camera.js +1 -1
  93. package/es/core/constants.js +1 -1
  94. package/es/core/core-modules.js +1 -1
  95. package/es/core/global-module.js +0 -2
  96. package/es/core/global.d.ts +3 -0
  97. package/es/core/global.js +14 -2
  98. package/es/core/global.js.map +1 -1
  99. package/es/core/stage.d.ts +3 -1
  100. package/es/core/stage.js +23 -21
  101. package/es/core/stage.js.map +1 -1
  102. package/es/event/event-system.js +7 -6
  103. package/es/event/event-system.js.map +1 -1
  104. package/es/graphic/graphic.d.ts +4 -3
  105. package/es/graphic/graphic.js +17 -23
  106. package/es/graphic/graphic.js.map +1 -1
  107. package/es/index.d.ts +1 -3
  108. package/es/index.js +2 -6
  109. package/es/index.js.map +1 -1
  110. package/es/interface/animate.d.ts +5 -0
  111. package/es/interface/animate.js.map +1 -1
  112. package/es/interface/context.d.ts +1 -0
  113. package/es/interface/context.js.map +1 -1
  114. package/es/interface/global.d.ts +2 -0
  115. package/es/interface/global.js.map +1 -1
  116. package/es/interface/graphic.d.ts +3 -1
  117. package/es/interface/graphic.js.map +1 -1
  118. package/es/interface/index.d.ts +1 -1
  119. package/es/interface/index.js +2 -2
  120. package/es/interface/index.js.map +1 -1
  121. package/es/interface/render.d.ts +6 -0
  122. package/es/interface/render.js.map +1 -1
  123. package/es/interface/stage.d.ts +1 -0
  124. package/es/interface/stage.js.map +1 -1
  125. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +2 -2
  126. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +4 -5
  127. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  128. package/es/render/contributions/render/arc-render.d.ts +4 -2
  129. package/es/render/contributions/render/arc-render.js +19 -17
  130. package/es/render/contributions/render/arc-render.js.map +1 -1
  131. package/es/render/contributions/render/base-render.d.ts +2 -2
  132. package/es/render/contributions/render/base-render.js +2 -2
  133. package/es/render/contributions/render/base-render.js.map +1 -1
  134. package/es/render/contributions/render/draw-contribution.d.ts +1 -0
  135. package/es/render/contributions/render/draw-contribution.js +23 -19
  136. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  137. package/es/render/contributions/render/draw-interceptor.js +1 -0
  138. package/es/render/contributions/render/draw-interceptor.js.map +1 -1
  139. package/es/render/contributions/render/group-render.d.ts +2 -2
  140. package/es/render/contributions/render/group-render.js +14 -10
  141. package/es/render/contributions/render/group-render.js.map +1 -1
  142. package/es/render/contributions/render/rect-render.d.ts +3 -1
  143. package/es/render/contributions/render/rect-render.js +17 -14
  144. package/es/render/contributions/render/rect-render.js.map +1 -1
  145. package/es/render/contributions/render/symbol-render.d.ts +4 -2
  146. package/es/render/contributions/render/symbol-render.js +16 -11
  147. package/es/render/contributions/render/symbol-render.js.map +1 -1
  148. package/package.json +3 -3
  149. package/cjs/animate/Ticker/default-ticker.d.ts +0 -40
  150. package/cjs/animate/Ticker/default-ticker.js +0 -140
  151. package/cjs/animate/Ticker/default-ticker.js.map +0 -1
  152. package/cjs/animate/Ticker/index.d.ts +0 -5
  153. package/cjs/animate/Ticker/index.js +0 -23
  154. package/cjs/animate/Ticker/index.js.map +0 -1
  155. package/cjs/animate/Ticker/manual-ticker-handler.d.ts +0 -15
  156. package/cjs/animate/Ticker/manual-ticker-handler.js +0 -36
  157. package/cjs/animate/Ticker/manual-ticker-handler.js.map +0 -1
  158. package/cjs/animate/Ticker/manual-ticker.d.ts +0 -19
  159. package/cjs/animate/Ticker/manual-ticker.js +0 -37
  160. package/cjs/animate/Ticker/manual-ticker.js.map +0 -1
  161. package/cjs/animate/Ticker/raf-tick-handler.d.ts +0 -9
  162. package/cjs/animate/Ticker/raf-tick-handler.js +0 -30
  163. package/cjs/animate/Ticker/raf-tick-handler.js.map +0 -1
  164. package/cjs/animate/Ticker/timeout-tick-handler.d.ts +0 -9
  165. package/cjs/animate/Ticker/timeout-tick-handler.js +0 -28
  166. package/cjs/animate/Ticker/timeout-tick-handler.js.map +0 -1
  167. package/cjs/animate/Ticker/type.d.ts +0 -6
  168. package/cjs/animate/Ticker/type.js +0 -11
  169. package/cjs/animate/Ticker/type.js.map +0 -1
  170. package/cjs/animate/animate.d.ts +0 -147
  171. package/cjs/animate/animate.js +0 -403
  172. package/cjs/animate/animate.js.map +0 -1
  173. package/cjs/animate/custom-animate.d.ts +0 -236
  174. package/cjs/animate/custom-animate.js +0 -722
  175. package/cjs/animate/custom-animate.js.map +0 -1
  176. package/cjs/animate/default-ticker.d.ts +0 -2
  177. package/cjs/animate/default-ticker.js +0 -14
  178. package/cjs/animate/default-ticker.js.map +0 -1
  179. package/cjs/animate/easing-func.d.ts +0 -1
  180. package/cjs/animate/easing-func.js +0 -16
  181. package/cjs/animate/easing-func.js.map +0 -1
  182. package/cjs/animate/easing.d.ts +0 -49
  183. package/cjs/animate/easing.js +0 -141
  184. package/cjs/animate/easing.js.map +0 -1
  185. package/cjs/animate/group-fade.d.ts +0 -16
  186. package/cjs/animate/group-fade.js +0 -66
  187. package/cjs/animate/group-fade.js.map +0 -1
  188. package/cjs/animate/index.d.ts +0 -8
  189. package/cjs/animate/index.js +0 -24
  190. package/cjs/animate/index.js.map +0 -1
  191. package/cjs/animate/morphing.d.ts +0 -52
  192. package/cjs/animate/morphing.js +0 -292
  193. package/cjs/animate/morphing.js.map +0 -1
  194. package/cjs/animate/timeline.d.ts +0 -17
  195. package/cjs/animate/timeline.js +0 -46
  196. package/cjs/animate/timeline.js.map +0 -1
  197. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
  198. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
  199. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +0 -1
  200. package/es/animate/Ticker/default-ticker.d.ts +0 -40
  201. package/es/animate/Ticker/default-ticker.js +0 -138
  202. package/es/animate/Ticker/default-ticker.js.map +0 -1
  203. package/es/animate/Ticker/index.d.ts +0 -5
  204. package/es/animate/Ticker/index.js +0 -10
  205. package/es/animate/Ticker/index.js.map +0 -1
  206. package/es/animate/Ticker/manual-ticker-handler.d.ts +0 -15
  207. package/es/animate/Ticker/manual-ticker-handler.js +0 -28
  208. package/es/animate/Ticker/manual-ticker-handler.js.map +0 -1
  209. package/es/animate/Ticker/manual-ticker.d.ts +0 -19
  210. package/es/animate/Ticker/manual-ticker.js +0 -31
  211. package/es/animate/Ticker/manual-ticker.js.map +0 -1
  212. package/es/animate/Ticker/raf-tick-handler.d.ts +0 -9
  213. package/es/animate/Ticker/raf-tick-handler.js +0 -22
  214. package/es/animate/Ticker/raf-tick-handler.js.map +0 -1
  215. package/es/animate/Ticker/timeout-tick-handler.d.ts +0 -9
  216. package/es/animate/Ticker/timeout-tick-handler.js +0 -20
  217. package/es/animate/Ticker/timeout-tick-handler.js.map +0 -1
  218. package/es/animate/Ticker/type.d.ts +0 -6
  219. package/es/animate/Ticker/type.js +0 -7
  220. package/es/animate/Ticker/type.js.map +0 -1
  221. package/es/animate/animate.d.ts +0 -147
  222. package/es/animate/animate.js +0 -398
  223. package/es/animate/animate.js.map +0 -1
  224. package/es/animate/custom-animate.d.ts +0 -236
  225. package/es/animate/custom-animate.js +0 -699
  226. package/es/animate/custom-animate.js.map +0 -1
  227. package/es/animate/default-ticker.d.ts +0 -2
  228. package/es/animate/default-ticker.js +0 -12
  229. package/es/animate/default-ticker.js.map +0 -1
  230. package/es/animate/easing-func.d.ts +0 -1
  231. package/es/animate/easing-func.js +0 -10
  232. package/es/animate/easing-func.js.map +0 -1
  233. package/es/animate/easing.d.ts +0 -49
  234. package/es/animate/easing.js +0 -134
  235. package/es/animate/easing.js.map +0 -1
  236. package/es/animate/group-fade.d.ts +0 -16
  237. package/es/animate/group-fade.js +0 -56
  238. package/es/animate/group-fade.js.map +0 -1
  239. package/es/animate/index.d.ts +0 -8
  240. package/es/animate/index.js +0 -16
  241. package/es/animate/index.js.map +0 -1
  242. package/es/animate/morphing.d.ts +0 -52
  243. package/es/animate/morphing.js +0 -295
  244. package/es/animate/morphing.js.map +0 -1
  245. package/es/animate/timeline.d.ts +0 -17
  246. package/es/animate/timeline.js +0 -42
  247. package/es/animate/timeline.js.map +0 -1
  248. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
  249. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
  250. 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,mEAA4D;AAC5D,6CAA8C;AAC9C,mDAAsE;AACtE,sEAAkE;AAYlE,wEAAkF;AAClF,oEAA4D;AAG/C,QAAA,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AASrE,MAAM,eAAe,GAAG,IAAI,mBAAU,EAAE,CAAC;AACzC,MAAM,qBAAqB,GAAG,IAAI,mBAAU,EAAE,CAAC;AAK/C,MAAa,yCAAyC;IAAtD;QACE,UAAK,GAAW,CAAC,CAAC;IAoFpB,CAAC;IAnFC,aAAa,CACX,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,gBAAmC,EACnC,MAAiC;QAGjC,IACE,OAAO,CAAC,SAAS,CAAC,aAAa,IAAI,IAAI;YACvC,OAAO,CAAC,UAAU;YAClB,OAAO,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G,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,IAAA,4BAAU,EACR,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,8BAAY,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;AA9ED,kEA8EC","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds } from '@visactor/vutils';\nimport { mat3Tomat4, multiplyMat4Mat4 } from '../../../common/matrix';\nimport { graphicCreator } from '../../../graphic/graphic-creator';\nimport type {\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate, matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { draw3dItem } from '../../../common/3d-interceptor';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx < 0\n ) {\n return false;\n }\n if (\n graphic.attribute.shadowRootIdx > 0 ||\n !graphic.attribute.shadowRootIdx ||\n (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0)\n ) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx > 0\n ) {\n return false;\n }\n if (graphic.attribute.shadowRootIdx < 0 || (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0)) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n // 一直往上找\n let intree = !!baseGraphic.stage;\n let _g = baseGraphic.parent;\n while (intree && _g) {\n if ((_g as any).stage === _g) {\n break;\n }\n intree = !!_g.stage;\n _g = _g.parent;\n }\n if (!intree) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n draw3dItem(\n context,\n graphic,\n (isPie: boolean, is3d: boolean) => {\n return drawContribution.renderGroup(\n graphic as IGroup,\n drawContext,\n graphic.parent.globalTransMatrix,\n !isPie && is3d\n );\n },\n drawContext\n );\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAA4D;AAC5D,6CAA8C;AAC9C,mDAAsE;AACtE,sEAAkE;AAYlE,w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,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,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,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;AA9ED,kEA8EC","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds } from '@visactor/vutils';\nimport { mat3Tomat4, multiplyMat4Mat4 } from '../../../common/matrix';\nimport { graphicCreator } from '../../../graphic/graphic-creator';\nimport type {\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate, matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { draw3dItem } from '../../../common/3d-interceptor';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx < 0\n ) {\n return false;\n }\n if (\n graphic.attribute.shadowRootIdx > 0 ||\n !graphic.attribute.shadowRootIdx ||\n (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0)\n ) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx > 0\n ) {\n return false;\n }\n if (graphic.attribute.shadowRootIdx < 0 || (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0)) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n // 一直往上找\n let intree = !!baseGraphic.stage;\n let _g = baseGraphic.parent;\n while (intree && _g) {\n if ((_g as any).stage === _g) {\n break;\n }\n intree = !!_g.stage;\n _g = _g.parent;\n }\n if (!intree) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n draw3dItem(\n context,\n graphic,\n (isPie: boolean, is3d: boolean) => {\n return drawContribution.renderGroup(\n graphic as IGroup,\n drawContext,\n graphic.parent.globalTransMatrix,\n !isPie && is3d\n );\n },\n drawContext\n );\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
@@ -1,10 +1,10 @@
1
- import type { IGraphicAttribute, IContext2d, IGroup, IMarkAttribute, IThemeAttribute, IGroupRenderContribution, IDrawContext, IRenderService, IGraphicRender, IGraphicRenderDrawParams, IContributionProvider } from '../../../interface';
1
+ import type { IGraphicAttribute, IContext2d, IGroup, IMarkAttribute, IThemeAttribute, IGroupRenderContribution, IDrawContext, IRenderService, IGraphicRender, IGraphicRenderDrawParams, IContributionProvider, IGroupGraphicAttribute } from '../../../interface';
2
2
  export declare class DefaultCanvasGroupRender implements IGraphicRender {
3
3
  protected readonly groupRenderContribitions: IContributionProvider<IGroupRenderContribution>;
4
4
  type: 'group';
5
5
  numberType: number;
6
6
  _groupRenderContribitions: IGroupRenderContribution[];
7
7
  constructor(groupRenderContribitions: IContributionProvider<IGroupRenderContribution>);
8
- drawShape(group: IGroup, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
8
+ drawShape(group: IGroup, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, groupAttribute?: Required<IGroupGraphicAttribute>): void;
9
9
  draw(group: IGroup, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
10
10
  }
@@ -22,8 +22,11 @@ let DefaultCanvasGroupRender = class {
22
22
  constructor(groupRenderContribitions) {
23
23
  this.groupRenderContribitions = groupRenderContribitions, this.numberType = constants_2.GROUP_NUMBER_TYPE;
24
24
  }
25
- drawShape(group, context, x, y, drawContext, params, fillCb, strokeCb) {
26
- const groupAttribute = (0, theme_1.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, cornerType: cornerType = groupAttribute.cornerType, x: originX = groupAttribute.x, y: originY = groupAttribute.y} = group.attribute, fVisible = (0,
25
+ drawShape(group, context, x, y, drawContext, params, fillCb, strokeCb, groupAttribute) {
26
+ const {clip: clip, fill: fill, stroke: stroke, background: background} = group.attribute;
27
+ if (!(clip || fill || stroke || background)) return;
28
+ groupAttribute = null != groupAttribute ? groupAttribute : (0, theme_1.getTheme)(group, null == params ? void 0 : params.theme).group;
29
+ const {opacity: opacity = groupAttribute.opacity, width: width = groupAttribute.width, height: height = groupAttribute.height, fillOpacity: fillOpacity = groupAttribute.fillOpacity, strokeOpacity: strokeOpacity = groupAttribute.strokeOpacity, cornerRadius: cornerRadius = groupAttribute.cornerRadius, path: path = groupAttribute.path, lineWidth: lineWidth = groupAttribute.lineWidth, visible: visible = groupAttribute.visible, fillStrokeOrder: fillStrokeOrder = groupAttribute.fillStrokeOrder, cornerType: cornerType = groupAttribute.cornerType, x: originX = groupAttribute.x, y: originY = groupAttribute.y} = group.attribute, fVisible = (0,
27
30
  utils_1.rectFillVisible)(opacity, fillOpacity, width, height, fill), sVisible = (0,
28
31
  utils_1.rectStrokeVisible)(opacity, strokeOpacity, width, height), doFill = (0,
29
32
  utils_1.runFill)(fill, background), doStroke = (0, utils_1.runStroke)(stroke, lineWidth);
@@ -62,11 +65,12 @@ let DefaultCanvasGroupRender = class {
62
65
  }));
63
66
  }
64
67
  draw(group, renderService, drawContext, params) {
68
+ var _a;
65
69
  const {context: context} = drawContext;
66
70
  if (!context) return;
67
- const {clip: clip, baseOpacity: baseOpacity = 1, drawMode: drawMode, x: x, y: y, width: width, height: height} = group.attribute, lastNativeContext = context.nativeContext, lastNativeCanvas = context.canvas.nativeCanvas;
71
+ const {clip: clip, baseOpacity: baseOpacity = 1, drawMode: drawMode} = group.attribute, lastNativeContext = context.nativeContext, lastNativeCanvas = context.canvas.nativeCanvas;
68
72
  if (drawMode > 0) {
69
- const canvas = context.canvas, newCanvas = modules_1.vglobal.createCanvas({
73
+ const {x: x, y: y, width: width, height: height} = group.attribute, canvas = context.canvas, newCanvas = modules_1.vglobal.createCanvas({
70
74
  width: canvas.width,
71
75
  height: canvas.height,
72
76
  dpr: 1
@@ -80,22 +84,22 @@ let DefaultCanvasGroupRender = class {
80
84
  clip ? context.save() : context.highPerformanceSave();
81
85
  const baseGlobalAlpha = context.baseGlobalAlpha;
82
86
  context.baseGlobalAlpha *= baseOpacity;
83
- const groupAttribute = (0, theme_1.getTheme)(group, null == params ? void 0 : params.theme).group, lastModelMatrix = context.modelMatrix;
87
+ const lastModelMatrix = context.modelMatrix;
84
88
  if (context.camera) {
85
- const nextModelMatrix = matrix_allocate_1.mat4Allocate.allocate(), modelMatrix = matrix_allocate_1.mat4Allocate.allocate();
89
+ const groupAttribute = (0, theme_1.getTheme)(group, null == params ? void 0 : params.theme).group, nextModelMatrix = matrix_allocate_1.mat4Allocate.allocate(), modelMatrix = matrix_allocate_1.mat4Allocate.allocate();
86
90
  (0, graphic_service_1.getModelMatrix)(modelMatrix, group, groupAttribute), lastModelMatrix ? (0,
87
91
  matrix_1.multiplyMat4Mat4)(nextModelMatrix, lastModelMatrix, modelMatrix) : (0,
88
92
  matrix_1.multiplyMat4Mat4)(nextModelMatrix, nextModelMatrix, modelMatrix), context.modelMatrix = nextModelMatrix,
89
93
  matrix_allocate_1.mat4Allocate.free(modelMatrix), context.setTransform(1, 0, 0, 1, 0, 0, !0);
90
94
  } else context.transformFromMatrix(group.transMatrix, !0);
91
- context.beginPath(), params.skipDraw ? this.drawShape(group, context, 0, 0, drawContext, params, (() => !1), (() => !1)) : this.drawShape(group, context, 0, 0, drawContext);
92
- const {scrollX: scrollX = groupAttribute.scrollX, scrollY: scrollY = groupAttribute.scrollY} = group.attribute;
95
+ context.beginPath(), params.skipDraw ? this.drawShape(group, context, 0, 0, drawContext, params, (() => !1), (() => !1)) : this.drawShape(group, context, 0, 0, drawContext, null, null, null);
96
+ const {scrollX: scrollX, scrollY: scrollY} = group.attribute;
93
97
  let p;
94
- if ((scrollX || scrollY) && context.translate(scrollX, scrollY), params && params.drawingCb && (p = params.drawingCb()),
98
+ if ((scrollX || scrollY) && context.translate(scrollX, scrollY), params && params.renderInGroup && (p = params.renderInGroup(params.skipDraw, group, drawContext, null === (_a = params.renderInGroupParams) || void 0 === _a ? void 0 : _a.nextM)),
95
99
  context.modelMatrix !== lastModelMatrix && matrix_allocate_1.mat4Allocate.free(context.modelMatrix),
96
100
  context.modelMatrix = lastModelMatrix, context.baseGlobalAlpha = baseGlobalAlpha,
97
101
  drawMode > 0) {
98
- const newContext = context.nativeContext, newCanvas = context.canvas.nativeCanvas;
102
+ const {x: x, y: y, width: width, height: height} = group.attribute, newContext = context.nativeContext, newCanvas = context.canvas.nativeCanvas;
99
103
  lastNativeContext.save(), lastNativeContext.setTransform(context.dpr, 0, 0, context.dpr, 0, 0, !0),
100
104
  1 === drawMode && newContext.rect(x, y, width, height), lastNativeContext.drawImage(newCanvas, 0, 0, newCanvas.width, newCanvas.height, 0, 0, context.canvas.displayWidth, context.canvas.displayHeight);
101
105
  const transform = newContext.getTransform();
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/group-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAc3E,kDAAkD;AAClD,sFAAkF;AAClF,6CAA2C;AAE3C,iFAA6E;AAC7E,qDAA4D;AAC5D,mCAAiF;AACjF,yDAAoE;AACpE,wEAAkE;AAClE,0DAA+D;AAC/D,iDAAmE;AACnE,mDAA2E;AAC3E,mDAA0D;AAC1D,8CAA2C;AAGpC,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAMnC,YAGqB,wBAAyE;QAAzE,6BAAwB,GAAxB,wBAAwB,CAAiD;QAP9F,eAAU,GAAW,6BAAiB,CAAC;IAQpC,CAAC;IAEJ,SAAS,CACP,KAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAGZ,MAAM,cAAc,GAAG,IAAA,gBAAQ,EAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CA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AC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,mCAAuB,CAAC,CAAA;;GARtB,wBAAwB,CAwWpC;AAxWY,4DAAwB","file":"group-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IMarkAttribute,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { getModelMatrix } from '../../../graphic/graphic-service/graphic-service';\nimport { isArray } from '@visactor/vutils';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { GroupRenderContribution } from './contributions/constants';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { GROUP_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { defaultGroupBackgroundRenderContribution } from './contributions';\nimport { multiplyMat4Mat4 } from '../../../common/matrix';\nimport { vglobal } from '../../../modules';\n\n@injectable()\nexport class DefaultCanvasGroupRender implements IGraphicRender {\n type: 'group';\n numberType: number = GROUP_NUMBER_TYPE;\n\n _groupRenderContribitions: IGroupRenderContribution[];\n\n constructor(\n @inject(ContributionProvider)\n @named(GroupRenderContribution)\n protected readonly groupRenderContribitions: IContributionProvider<IGroupRenderContribution>\n ) {}\n\n drawShape(\n group: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const groupAttribute = graphicService.themeService.getCurrentTheme().groupAttribute;\n const groupAttribute = getTheme(group, params?.theme).group;\n const {\n fill = groupAttribute.fill,\n background,\n stroke = groupAttribute.stroke,\n opacity = groupAttribute.opacity,\n width = groupAttribute.width,\n height = groupAttribute.height,\n clip = groupAttribute.clip,\n fillOpacity = groupAttribute.fillOpacity,\n strokeOpacity = groupAttribute.strokeOpacity,\n cornerRadius = groupAttribute.cornerRadius,\n path = groupAttribute.path,\n lineWidth = groupAttribute.lineWidth,\n visible = groupAttribute.visible,\n fillStrokeOrder = groupAttribute.fillStrokeOrder,\n cornerType = groupAttribute.cornerType,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y\n } = group.attribute;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(group.valid && visible)) {\n return;\n }\n\n if (!clip) {\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n }\n\n if (path && path.length && drawContext.drawContribution) {\n // 禁用fill和stroke\n const disableFill = context.disableFill;\n const disableStroke = context.disableStroke;\n const disableBeginPath = context.disableBeginPath;\n context.disableFill = true;\n context.disableStroke = true;\n context.disableBeginPath = true;\n path.forEach(g => {\n const rc = drawContext.drawContribution.getRenderContribution(g);\n rc.draw(g, drawContext.renderService, drawContext, params);\n });\n context.disableFill = disableFill;\n context.disableStroke = disableStroke;\n context.disableBeginPath = disableBeginPath;\n } else if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');\n }\n\n if (!this._groupRenderContribitions) {\n this._groupRenderContribitions = this.groupRenderContribitions.getContributions() || [];\n this._groupRenderContribitions.push(defaultGroupBackgroundRenderContribution);\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.beforeFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n }\n });\n\n // beforeFillStroke contribition可以操作clip范围\n if (clip) {\n context.clip();\n }\n\n const _runFill = () => {\n if ((doFillOrStroke as any).doFill) {\n if (fillCb) {\n fillCb(context, group.attribute, groupAttribute);\n } else if (fVisible) {\n context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.fill();\n }\n }\n };\n\n const _runStroke = () => {\n if ((doFillOrStroke as any).doStroke) {\n if (strokeCb) {\n strokeCb(context, group.attribute, groupAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.afterFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n }\n\n draw(group: IGroup, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n // debugger;\n const { clip, baseOpacity = 1, drawMode, x, y, width, height } = group.attribute;\n const lastNativeContext = context.nativeContext;\n const lastNativeCanvas = context.canvas.nativeCanvas;\n\n if (drawMode > 0) {\n // 绘制到新的Canvas上,然后再绘制回来\n const canvas = context.canvas;\n const newCanvas = vglobal.createCanvas({ width: canvas.width, height: canvas.height, dpr: 1 });\n const newContext = newCanvas.getContext('2d');\n const transform = context.nativeContext.getTransform();\n // 首先应用transform\n newContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n // 然后将背景绘制到新的canvas上,只绘制group的Bounds区域\n // 如果drawMode === 1,则需要背景\n // 如果drawMode === 2,则不需要背景,只需要group即可\n if (drawMode === 1) {\n newContext.save();\n newContext.clearRect(0, 0, canvas.width, canvas.height);\n newContext.beginPath();\n\n newContext.rect(x, y, width, height);\n newContext.clip();\n newContext.drawImage(\n canvas.nativeCanvas,\n 0,\n 0,\n canvas.width,\n canvas.height,\n 0,\n 0,\n canvas.displayWidth,\n canvas.displayHeight\n );\n newContext.restore();\n }\n // 狸猫换太子,把新的context赋值给context\n context.nativeContext = newContext;\n canvas.nativeCanvas = newCanvas;\n }\n if (clip) {\n context.save();\n } else {\n context.highPerformanceSave();\n }\n const baseGlobalAlpha = context.baseGlobalAlpha;\n context.baseGlobalAlpha *= baseOpacity;\n\n const groupAttribute = getTheme(group, params?.theme).group;\n\n // const lastMatrix = context.modelMatrix;\n // if (context.camera) {\n // const m = group.transMatrix;\n // const matrix = createMat4();\n // mat3Tomat4(matrix, m);\n // const lastModelMatrix = context.modelMatrix;\n // if (lastModelMatrix) {\n // if (matrix) {\n // const m = createMat4();\n // context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n // }\n // } else {\n // context.modelMatrix = matrix;\n // }\n // } else {\n // // group直接transform\n // context.transformFromMatrix(group.transMatrix, true);\n // }\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n if (camera) {\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, group, groupAttribute);\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n context.modelMatrix = nextModelMatrix;\n mat4Allocate.free(modelMatrix);\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n // group直接transform\n context.transformFromMatrix(group.transMatrix, true);\n }\n\n context.beginPath();\n // 如果跳过绘制,那就不绘制\n if (params.skipDraw) {\n this.drawShape(\n group,\n context,\n 0,\n 0,\n drawContext,\n params,\n () => false,\n () => false\n );\n } else {\n this.drawShape(group, context, 0, 0, drawContext);\n }\n\n // 绘制子元素的时候要添加scroll\n const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = group.attribute;\n if (scrollX || scrollY) {\n context.translate(scrollX, scrollY);\n }\n let p: any;\n if (params && params.drawingCb) {\n p = params.drawingCb();\n }\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.baseGlobalAlpha = baseGlobalAlpha;\n\n if (drawMode > 0) {\n // 将原始的context和canvas恢复,另外将newCanvas上的内容绘制到lastCanvas上\n const newContext = context.nativeContext;\n const newCanvas = context.canvas.nativeCanvas;\n lastNativeContext.save();\n lastNativeContext.setTransform(context.dpr, 0, 0, context.dpr, 0, 0, true);\n // 如果drawMode === 1,则需要清一下之前的背景,否则背景就重复绘制了一次\n if (drawMode === 1) {\n newContext.rect(x, y, width, height);\n }\n lastNativeContext.drawImage(\n newCanvas,\n 0,\n 0,\n newCanvas.width,\n newCanvas.height,\n 0,\n 0,\n context.canvas.displayWidth,\n context.canvas.displayHeight\n );\n const transform = newContext.getTransform();\n lastNativeContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n context.nativeContext = lastNativeContext;\n context.canvas.nativeCanvas = lastNativeCanvas;\n lastNativeContext.restore();\n }\n\n if (p && p.then) {\n p.then(() => {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n });\n } else {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/group-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAe3E,kDAAkD;AAClD,sFAAkF;AAClF,6CAA2C;AAE3C,iFAA6E;AAC7E,qDAA4D;AAC5D,mCAAiF;AACjF,yDAAoE;AACpE,wEAAkE;AAClE,0DAA+D;AAC/D,iDAAmE;AACnE,mDAA2E;AAC3E,mDAA0D;AAC1D,8CAA2C;AAGpC,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAMnC,YAGqB,wBAAyE;QAAzE,6BAAwB,GAAxB,wBAAwB,CAAiD;QAP9F,eAAU,GAAW,6BAAiB,CAAC;IAQpC,CAAC;IAEJ,SAAS,CACP,KAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY,EACZ,cAAiD;QAGjD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC;QAE3D,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,UAAU,CAAC,EAAE;YAC3C,OAAO;SACR;QAED,cAAc,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,IAAA,gBAAQ,EAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,KAAK,CAAC;QAExE,MAAM,EACJ,OAAO,GAAG,cAAc,CAAC,OAAO,EAChC,KAAK,GAAG,cAAc,CAAC,KAAK,EA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,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,mCAAuB,CAAC,CAAA;;GARtB,wBAAwB,CA4WpC;AA5WY,4DAAwB","file":"group-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IMarkAttribute,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n IGroupGraphicAttribute\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { getModelMatrix } from '../../../graphic/graphic-service/graphic-service';\nimport { isArray } from '@visactor/vutils';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { GroupRenderContribution } from './contributions/constants';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { GROUP_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { defaultGroupBackgroundRenderContribution } from './contributions';\nimport { multiplyMat4Mat4 } from '../../../common/matrix';\nimport { vglobal } from '../../../modules';\n\n@injectable()\nexport class DefaultCanvasGroupRender implements IGraphicRender {\n type: 'group';\n numberType: number = GROUP_NUMBER_TYPE;\n\n _groupRenderContribitions: IGroupRenderContribution[];\n\n constructor(\n @inject(ContributionProvider)\n @named(GroupRenderContribution)\n protected readonly groupRenderContribitions: IContributionProvider<IGroupRenderContribution>\n ) {}\n\n drawShape(\n group: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n groupAttribute?: Required<IGroupGraphicAttribute>\n ) {\n // 提前判定,否则每次都要获取一堆属性\n const { clip, fill, stroke, background } = group.attribute;\n\n if (!(clip || fill || stroke || background)) {\n return;\n }\n\n groupAttribute = groupAttribute ?? getTheme(group, params?.theme).group;\n\n const {\n opacity = groupAttribute.opacity,\n width = groupAttribute.width,\n height = groupAttribute.height,\n fillOpacity = groupAttribute.fillOpacity,\n strokeOpacity = groupAttribute.strokeOpacity,\n cornerRadius = groupAttribute.cornerRadius,\n path = groupAttribute.path,\n lineWidth = groupAttribute.lineWidth,\n visible = groupAttribute.visible,\n fillStrokeOrder = groupAttribute.fillStrokeOrder,\n cornerType = groupAttribute.cornerType,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y\n } = group.attribute;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(group.valid && visible)) {\n return;\n }\n\n if (!clip) {\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n }\n\n if (path && path.length && drawContext.drawContribution) {\n // 禁用fill和stroke\n const disableFill = context.disableFill;\n const disableStroke = context.disableStroke;\n const disableBeginPath = context.disableBeginPath;\n context.disableFill = true;\n context.disableStroke = true;\n context.disableBeginPath = true;\n path.forEach(g => {\n const rc = drawContext.drawContribution.getRenderContribution(g);\n rc.draw(g, drawContext.renderService, drawContext, params);\n });\n context.disableFill = disableFill;\n context.disableStroke = disableStroke;\n context.disableBeginPath = disableBeginPath;\n } else if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');\n }\n\n if (!this._groupRenderContribitions) {\n this._groupRenderContribitions = this.groupRenderContribitions.getContributions() || [];\n this._groupRenderContribitions.push(defaultGroupBackgroundRenderContribution);\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.beforeFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n }\n });\n\n // beforeFillStroke contribition可以操作clip范围\n if (clip) {\n context.clip();\n }\n\n const _runFill = () => {\n if ((doFillOrStroke as any).doFill) {\n if (fillCb) {\n fillCb(context, group.attribute, groupAttribute);\n } else if (fVisible) {\n context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.fill();\n }\n }\n };\n\n const _runStroke = () => {\n if ((doFillOrStroke as any).doStroke) {\n if (strokeCb) {\n strokeCb(context, group.attribute, groupAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.afterFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n }\n\n draw(group: IGroup, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n const { clip, baseOpacity = 1, drawMode } = group.attribute;\n const lastNativeContext = context.nativeContext;\n const lastNativeCanvas = context.canvas.nativeCanvas;\n\n if (drawMode > 0) {\n const { x, y, width, height } = group.attribute;\n // 绘制到新的Canvas上,然后再绘制回来\n const canvas = context.canvas;\n const newCanvas = vglobal.createCanvas({ width: canvas.width, height: canvas.height, dpr: 1 });\n const newContext = newCanvas.getContext('2d');\n const transform = context.nativeContext.getTransform();\n // 首先应用transform\n newContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n // 然后将背景绘制到新的canvas上,只绘制group的Bounds区域\n // 如果drawMode === 1,则需要背景\n // 如果drawMode === 2,则不需要背景,只需要group即可\n if (drawMode === 1) {\n newContext.save();\n newContext.clearRect(0, 0, canvas.width, canvas.height);\n newContext.beginPath();\n\n newContext.rect(x, y, width, height);\n newContext.clip();\n newContext.drawImage(\n canvas.nativeCanvas,\n 0,\n 0,\n canvas.width,\n canvas.height,\n 0,\n 0,\n canvas.displayWidth,\n canvas.displayHeight\n );\n newContext.restore();\n }\n // 狸猫换太子,把新的context赋值给context\n context.nativeContext = newContext;\n canvas.nativeCanvas = newCanvas;\n }\n if (clip) {\n context.save();\n } else {\n context.highPerformanceSave();\n }\n const baseGlobalAlpha = context.baseGlobalAlpha;\n context.baseGlobalAlpha *= baseOpacity;\n\n // const lastMatrix = context.modelMatrix;\n // if (context.camera) {\n // const m = group.transMatrix;\n // const matrix = createMat4();\n // mat3Tomat4(matrix, m);\n // const lastModelMatrix = context.modelMatrix;\n // if (lastModelMatrix) {\n // if (matrix) {\n // const m = createMat4();\n // context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n // }\n // } else {\n // context.modelMatrix = matrix;\n // }\n // } else {\n // // group直接transform\n // context.transformFromMatrix(group.transMatrix, true);\n // }\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n if (camera) {\n const groupAttribute = getTheme(group, params?.theme).group;\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, group, groupAttribute);\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n context.modelMatrix = nextModelMatrix;\n mat4Allocate.free(modelMatrix);\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n // group直接transform\n context.transformFromMatrix(group.transMatrix, true);\n }\n\n context.beginPath();\n // 如果跳过绘制,那就不绘制\n if (params.skipDraw) {\n this.drawShape(\n group,\n context,\n 0,\n 0,\n drawContext,\n params,\n () => false,\n () => false\n );\n } else {\n this.drawShape(group, context, 0, 0, drawContext, null, null, null);\n }\n\n // 绘制子元素的时候要添加scroll\n const { scrollX, scrollY } = group.attribute;\n if (scrollX || scrollY) {\n context.translate(scrollX, scrollY);\n }\n let p: any;\n if (params && params.renderInGroup) {\n p = params.renderInGroup(params.skipDraw, group, drawContext, params.renderInGroupParams?.nextM);\n }\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.baseGlobalAlpha = baseGlobalAlpha;\n\n if (drawMode > 0) {\n const { x, y, width, height } = group.attribute;\n // 将原始的context和canvas恢复,另外将newCanvas上的内容绘制到lastCanvas上\n const newContext = context.nativeContext;\n const newCanvas = context.canvas.nativeCanvas;\n lastNativeContext.save();\n lastNativeContext.setTransform(context.dpr, 0, 0, context.dpr, 0, 0, true);\n // 如果drawMode === 1,则需要清一下之前的背景,否则背景就重复绘制了一次\n if (drawMode === 1) {\n newContext.rect(x, y, width, height);\n }\n lastNativeContext.drawImage(\n newCanvas,\n 0,\n 0,\n newCanvas.width,\n newCanvas.height,\n 0,\n 0,\n context.canvas.displayWidth,\n context.canvas.displayHeight\n );\n const transform = newContext.getTransform();\n lastNativeContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n context.nativeContext = lastNativeContext;\n context.canvas.nativeCanvas = lastNativeCanvas;\n lastNativeContext.restore();\n }\n\n if (p && p.then) {\n p.then(() => {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n });\n } else {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n }\n }\n}\n"]}
@@ -6,6 +6,8 @@ export declare class DefaultCanvasRectRender extends BaseRender<IRect> implement
6
6
  numberType: number;
7
7
  tempTheme: Required<IRectGraphicAttribute>;
8
8
  constructor(rectRenderContribitions: IContributionProvider<IRectRenderContribution>);
9
- drawShape(rect: IRect, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
9
+ drawShape(rect: IRect, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, rectAttribute?: Required<IRectGraphicAttribute>): void;
10
+ private _runFill;
11
+ private _runStroke;
10
12
  draw(rect: IRect, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
11
13
  }
@@ -24,10 +24,9 @@ let DefaultCanvasRectRender = class extends base_render_1.BaseRender {
24
24
  this.numberType = constants_1.RECT_NUMBER_TYPE, this.builtinContributions = [ contributions_1.defaultRectRenderContribution, contributions_1.defaultRectBackgroundRenderContribution, contributions_1.defaultRectTextureRenderContribution ],
25
25
  this.init(rectRenderContribitions);
26
26
  }
27
- drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb) {
28
- var _a;
29
- const rectAttribute = null !== (_a = this.tempTheme) && void 0 !== _a ? _a : (0,
30
- theme_1.getTheme)(rect, null == params ? void 0 : params.theme).rect, {fill: fill = rectAttribute.fill, background: background, stroke: stroke = rectAttribute.stroke, cornerRadius: cornerRadius = rectAttribute.cornerRadius, cornerType: cornerType = rectAttribute.cornerType, opacity: opacity = rectAttribute.opacity, fillOpacity: fillOpacity = rectAttribute.fillOpacity, lineWidth: lineWidth = rectAttribute.lineWidth, strokeOpacity: strokeOpacity = rectAttribute.strokeOpacity, visible: visible = rectAttribute.visible, x1: x1, y1: y1, x: originX = rectAttribute.x, y: originY = rectAttribute.y, fillStrokeOrder: fillStrokeOrder = rectAttribute.fillStrokeOrder} = rect.attribute;
27
+ drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb, rectAttribute) {
28
+ rectAttribute = null != rectAttribute ? rectAttribute : (0, theme_1.getTheme)(rect, null == params ? void 0 : params.theme).rect;
29
+ const {fill: fill = rectAttribute.fill, background: background, stroke: stroke = rectAttribute.stroke, cornerRadius: cornerRadius = rectAttribute.cornerRadius, cornerType: cornerType = rectAttribute.cornerType, opacity: opacity = rectAttribute.opacity, fillOpacity: fillOpacity = rectAttribute.fillOpacity, lineWidth: lineWidth = rectAttribute.lineWidth, strokeOpacity: strokeOpacity = rectAttribute.strokeOpacity, visible: visible = rectAttribute.visible, x1: x1, y1: y1, x: originX = rectAttribute.x, y: originY = rectAttribute.y, fillStrokeOrder: fillStrokeOrder = rectAttribute.fillStrokeOrder} = rect.attribute;
31
30
  let {width: width, height: height} = rect.attribute;
32
31
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
33
32
  const fVisible = (0, utils_1.rectFillVisible)(opacity, fillOpacity, width, height, fill), sVisible = (0,
@@ -43,20 +42,23 @@ let DefaultCanvasRectRender = class extends base_render_1.BaseRender {
43
42
  doStroke: doStroke
44
43
  };
45
44
  context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute),
46
- this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
47
- const _runFill = () => {
48
- doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute),
49
- context.fill()));
50
- }, _runStroke = () => {
51
- doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute),
52
- context.stroke()));
53
- };
54
- fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
45
+ this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke),
46
+ fillStrokeOrder ? (this._runStroke(rect, context, x, y, rectAttribute, doFillOrStroke, sVisible, originX, originY, strokeCb),
47
+ this._runFill(rect, context, x, y, rectAttribute, doFillOrStroke, fVisible, originX, originY, fillCb)) : (this._runFill(rect, context, x, y, rectAttribute, doFillOrStroke, fVisible, originX, originY, fillCb),
48
+ this._runStroke(rect, context, x, y, rectAttribute, doFillOrStroke, sVisible, originX, originY, strokeCb)),
49
+ this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
50
+ }
51
+ _runFill(rect, context, x, y, rectAttribute, doFillOrStroke, fVisible, originX, originY, fillCb) {
52
+ doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute),
53
+ context.fill()));
54
+ }
55
+ _runStroke(rect, context, x, y, rectAttribute, doFillOrStroke, sVisible, originX, originY, strokeCb) {
56
+ doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute),
57
+ context.stroke()));
55
58
  }
56
59
  draw(rect, renderService, drawContext, params) {
57
60
  const rectAttribute = (0, theme_1.getTheme)(rect, null == params ? void 0 : params.theme).rect;
58
- this.tempTheme = rectAttribute, this._draw(rect, rectAttribute, !1, drawContext, params),
59
- this.tempTheme = null;
61
+ this._draw(rect, rectAttribute, !1, drawContext, params, rectAttribute);
60
62
  }
61
63
  };
62
64
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/rect-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAA2C;AAC3C,mEAA2E;AAC3E,kDAAkD;AAClD,0DAA8D;AAC9D,qDAA4D;AAE5D,iFAA6E;AAe7E,yDAAmE;AACnE,mCAAiF;AACjF,+CAA2C;AAC3C,mDAIyB;AAGlB,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,wBAAiB;IAK5D,YAGqB,uBAAuE;QAE1F,KAAK,EAAE,CAAC;QAFW,4BAAuB,GAAvB,uBAAuB,CAAgD;QAP5F,SAAI,GAAG,MAAM,CAAC;QACd,eAAU,GAAW,4BAAgB,CAAC;QASpC,IAAI,CAAC,oBAAoB,GAAG;YAC1B,6CAA6B;YAC7B,uDAAuC;YACvC,oDAAoC;SACrC,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACrC,CAAC;IAED,SAAS,CACP,IAAW,EACX,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;;QAEZ,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAA,gBAAQ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AAI,CAAC,SAAS,GAAG,aAAa,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF,CAAA;AAtKY,uBAAuB;IADnC,IAAA,2BAAU,GAAE;IAOR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,kCAAsB,CAAC,CAAA;;GAPrB,uBAAuB,CAsKnC;AAtKY,0DAAuB","file":"rect-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { RECT_NUMBER_TYPE } from '../../../graphic/constants';\nimport { createRectPath } from '../../../common/shape/rect';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IRect,\n IThemeAttribute,\n IGraphicRender,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService,\n IRectRenderContribution,\n IContributionProvider,\n IRectGraphicAttribute\n} from '../../../interface';\nimport { RectRenderContribution } from './contributions/constants';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { BaseRender } from './base-render';\nimport {\n defaultRectBackgroundRenderContribution,\n defaultRectRenderContribution,\n defaultRectTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasRectRender extends BaseRender<IRect> implements IGraphicRender {\n type = 'rect';\n numberType: number = RECT_NUMBER_TYPE;\n tempTheme: Required<IRectGraphicAttribute>;\n\n constructor(\n @inject(ContributionProvider)\n @named(RectRenderContribution)\n protected readonly rectRenderContribitions: IContributionProvider<IRectRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultRectRenderContribution,\n defaultRectBackgroundRenderContribution,\n defaultRectTextureRenderContribution\n ];\n this.init(rectRenderContribitions);\n }\n\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const rectAttribute = this.tempTheme ?? getTheme(rect, params?.theme).rect;\n const {\n fill = rectAttribute.fill,\n background,\n stroke = rectAttribute.stroke,\n cornerRadius = rectAttribute.cornerRadius,\n cornerType = rectAttribute.cornerType,\n opacity = rectAttribute.opacity,\n fillOpacity = rectAttribute.fillOpacity,\n lineWidth = rectAttribute.lineWidth,\n strokeOpacity = rectAttribute.strokeOpacity,\n visible = rectAttribute.visible,\n x1,\n y1,\n x: originX = rectAttribute.x,\n y: originY = rectAttribute.y,\n fillStrokeOrder = rectAttribute.fillStrokeOrder\n } = rect.attribute;\n let { width, height } = rect.attribute;\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(rect.valid && visible)) {\n return;\n }\n\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n this.beforeRenderStep(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n\n const _runFill = () => {\n if (doFillOrStroke.doFill) {\n if (fillCb) {\n fillCb(context, rect.attribute, rectAttribute);\n } else if (fVisible) {\n // 存在fill\n context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n context.fill();\n }\n }\n };\n const _runStroke = () => {\n if (doFillOrStroke.doStroke) {\n if (strokeCb) {\n strokeCb(context, rect.attribute, rectAttribute);\n } else if (sVisible) {\n // 存在stroke\n context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this.afterRenderStep(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(rect: IRect, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const rectAttribute = getTheme(rect, params?.theme).rect;\n this.tempTheme = rectAttribute;\n this._draw(rect, rectAttribute, false, drawContext, params);\n this.tempTheme = null;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/rect-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAA2C;AAC3C,mEAA2E;AAC3E,kDAAkD;AAClD,0DAA8D;AAC9D,qDAA4D;AAE5D,iFAA6E;AAe7E,yDAAmE;AACnE,mCAAiF;AACjF,+CAA2C;AAC3C,mDAIyB;AAGlB,IAAM,uBAAuB,GAA7B,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,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IAC7E,CAAC;CACF,CAAA;AA5NY,uBAAuB;IADnC,IAAA,2BAAU,GAAE;IAOR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,kCAAsB,CAAC,CAAA;;GAPrB,uBAAuB,CA4NnC;AA5NY,0DAAuB","file":"rect-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { RECT_NUMBER_TYPE } from '../../../graphic/constants';\nimport { createRectPath } from '../../../common/shape/rect';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IRect,\n IThemeAttribute,\n IGraphicRender,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService,\n IRectRenderContribution,\n IContributionProvider,\n IRectGraphicAttribute\n} from '../../../interface';\nimport { RectRenderContribution } from './contributions/constants';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { BaseRender } from './base-render';\nimport {\n defaultRectBackgroundRenderContribution,\n defaultRectRenderContribution,\n defaultRectTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasRectRender extends BaseRender<IRect> implements IGraphicRender {\n type = 'rect';\n numberType: number = RECT_NUMBER_TYPE;\n tempTheme: Required<IRectGraphicAttribute>;\n\n constructor(\n @inject(ContributionProvider)\n @named(RectRenderContribution)\n protected readonly rectRenderContribitions: IContributionProvider<IRectRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultRectRenderContribution,\n defaultRectBackgroundRenderContribution,\n defaultRectTextureRenderContribution\n ];\n this.init(rectRenderContribitions);\n }\n\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n rectAttribute?: Required<IRectGraphicAttribute>\n ) {\n rectAttribute = rectAttribute ?? getTheme(rect, params?.theme).rect;\n const {\n fill = rectAttribute.fill,\n background,\n stroke = rectAttribute.stroke,\n cornerRadius = rectAttribute.cornerRadius,\n cornerType = rectAttribute.cornerType,\n opacity = rectAttribute.opacity,\n fillOpacity = rectAttribute.fillOpacity,\n lineWidth = rectAttribute.lineWidth,\n strokeOpacity = rectAttribute.strokeOpacity,\n visible = rectAttribute.visible,\n x1,\n y1,\n x: originX = rectAttribute.x,\n y: originY = rectAttribute.y,\n fillStrokeOrder = rectAttribute.fillStrokeOrder\n } = rect.attribute;\n let { width, height } = rect.attribute;\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(rect.valid && visible)) {\n return;\n }\n\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n this.beforeRenderStep(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n\n // 内联的函数性能差\n // const _runFill = () => {\n // if (doFillOrStroke.doFill) {\n // if (fillCb) {\n // fillCb(context, rect.attribute, rectAttribute);\n // } else if (fVisible) {\n // // 存在fill\n // context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n // context.fill();\n // }\n // }\n // };\n // const _runStroke = () => {\n // if (doFillOrStroke.doStroke) {\n // if (strokeCb) {\n // strokeCb(context, rect.attribute, rectAttribute);\n // } else if (sVisible) {\n // // 存在stroke\n // context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n // context.stroke();\n // }\n // }\n // };\n\n if (!fillStrokeOrder) {\n this._runFill(rect, context, x, y, rectAttribute, doFillOrStroke, fVisible, originX, originY, fillCb);\n this._runStroke(rect, context, x, y, rectAttribute, doFillOrStroke, sVisible, originX, originY, strokeCb);\n } else {\n this._runStroke(rect, context, x, y, rectAttribute, doFillOrStroke, sVisible, originX, originY, strokeCb);\n this._runFill(rect, context, x, y, rectAttribute, doFillOrStroke, fVisible, originX, originY, fillCb);\n }\n\n this.afterRenderStep(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n private _runFill(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n rectAttribute: Required<IRectGraphicAttribute>,\n doFillOrStroke: { doFill: boolean; doStroke: boolean },\n fVisible: boolean,\n originX: number,\n originY: number,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (doFillOrStroke.doFill) {\n if (fillCb) {\n fillCb(context, rect.attribute, rectAttribute);\n } else if (fVisible) {\n // 存在fill\n context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n context.fill();\n }\n }\n }\n\n private _runStroke(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n rectAttribute: Required<IRectGraphicAttribute>,\n doFillOrStroke: { doFill: boolean; doStroke: boolean },\n sVisible: boolean,\n originX: number,\n originY: number,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (doFillOrStroke.doStroke) {\n if (strokeCb) {\n strokeCb(context, rect.attribute, rectAttribute);\n } else if (sVisible) {\n // 存在stroke\n context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);\n context.stroke();\n }\n }\n }\n\n draw(rect: IRect, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const rectAttribute = getTheme(rect, params?.theme).rect;\n this._draw(rect, rectAttribute, false, drawContext, params, rectAttribute);\n }\n}\n"]}
@@ -1,10 +1,12 @@
1
- import type { IGraphicAttribute, IContext2d, IMarkAttribute, ISymbol, IThemeAttribute, ISymbolRenderContribution, IDrawContext, IRenderService, IGraphicRender, IGraphicRenderDrawParams, IContributionProvider } from '../../../interface';
1
+ import type { IGraphicAttribute, IContext2d, IMarkAttribute, ISymbol, IThemeAttribute, ISymbolRenderContribution, IDrawContext, IRenderService, IGraphicRender, IGraphicRenderDrawParams, IContributionProvider, ISymbolGraphicAttribute } from '../../../interface';
2
2
  import { BaseRender } from './base-render';
3
3
  export declare class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {
4
4
  protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>;
5
5
  type: 'symbol';
6
6
  numberType: number;
7
7
  constructor(symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>);
8
- drawShape(symbol: ISymbol, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
8
+ drawShape(symbol: ISymbol, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, symbolAttribute?: Required<ISymbolGraphicAttribute>): void;
9
+ private _runFill;
10
+ private _runStroke;
9
11
  draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
10
12
  }
@@ -24,9 +24,10 @@ let DefaultCanvasSymbolRender = class extends base_render_1.BaseRender {
24
24
  this.builtinContributions = [ contributions_1.defaultSymbolRenderContribution, contributions_1.defaultSymbolBackgroundRenderContribution, contributions_1.defaultSymbolTextureRenderContribution, contributions_1.defaultSymbolClipRangeStrokeRenderContribution ],
25
25
  this.init(symbolRenderContribitions);
26
26
  }
27
- drawShape(symbol, context, x, y, drawContext, params, fillCb, strokeCb) {
27
+ drawShape(symbol, context, x, y, drawContext, params, fillCb, strokeCb, symbolAttribute) {
28
28
  var _a;
29
- const symbolAttribute = (0, theme_1.getTheme)(symbol, null == params ? void 0 : params.theme).symbol, {size: size = symbolAttribute.size, x: originX = symbolAttribute.x, y: originY = symbolAttribute.y, scaleX: scaleX = symbolAttribute.scaleX, scaleY: scaleY = symbolAttribute.scaleY, fillStrokeOrder: fillStrokeOrder = symbolAttribute.fillStrokeOrder, clipRange: clipRange = symbolAttribute.clipRange} = symbol.attribute, data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);
29
+ symbolAttribute = null != symbolAttribute ? symbolAttribute : (0, theme_1.getTheme)(symbol, null == params ? void 0 : params.theme).symbol;
30
+ const {size: size = symbolAttribute.size, x: originX = symbolAttribute.x, y: originY = symbolAttribute.y, scaleX: scaleX = symbolAttribute.scaleX, scaleY: scaleY = symbolAttribute.scaleY, fillStrokeOrder: fillStrokeOrder = symbolAttribute.fillStrokeOrder, clipRange: clipRange = symbolAttribute.clipRange} = symbol.attribute, data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);
30
31
  if (!data) return;
31
32
  const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, parsedPath = symbol.getParsedPath();
32
33
  if (!parsedPath) return;
@@ -58,15 +59,19 @@ let DefaultCanvasSymbolRender = class extends base_render_1.BaseRender {
58
59
  };
59
60
  fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
60
61
  })) && context.closePath(), context.camera = camera, context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute),
61
- this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
62
- const _runFill = () => {
63
- doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute),
64
- context.fill()));
65
- }, _runStroke = () => {
66
- doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && clipRange >= 1 && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute),
67
- context.stroke()));
68
- };
69
- fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
62
+ this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb),
63
+ fillStrokeOrder ? (this._runStroke(symbol, context, x, y, symbolAttribute, doStroke, sVisible, originX, originY, parsedPath, clipRange, scaleX, scaleY, strokeCb),
64
+ this._runFill(symbol, context, x, y, symbolAttribute, doFill, fVisible, originX, originY, parsedPath, fillCb)) : (this._runFill(symbol, context, x, y, symbolAttribute, doFill, fVisible, originX, originY, parsedPath, fillCb),
65
+ this._runStroke(symbol, context, x, y, symbolAttribute, doStroke, sVisible, originX, originY, parsedPath, clipRange, scaleX, scaleY, strokeCb)),
66
+ this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
67
+ }
68
+ _runFill(symbol, context, x, y, symbolAttribute, doFill, fVisible, originX, originY, parsedPath, fillCb) {
69
+ doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute),
70
+ context.fill()));
71
+ }
72
+ _runStroke(symbol, context, x, y, symbolAttribute, doStroke, sVisible, originX, originY, parsedPath, clipRange, scaleX, scaleY, strokeCb) {
73
+ doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && clipRange >= 1 && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute),
74
+ context.stroke()));
70
75
  }
71
76
  draw(symbol, renderService, drawContext, params) {
72
77
  const symbolAttribute = (0, theme_1.getTheme)(symbol, null == params ? void 0 : params.theme).symbol;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/symbol-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAE3E,iFAA6E;AAC7E,kDAAkD;AAClD,0DAAgE;AAgBhE,+CAA2C;AAC3C,yDAAqE;AACrE,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EAAE,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;iBACtD;qBAAM,IAAI,QAAQ,IAAI,SAAS,IAAI,CAAC,EAAE;oBAErC,OAAO,CAAC,cAAc,CACpB,MAAM,EACN,MAAM,CAAC,SAAS,EAChB,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,eAAe,CAChB,CAAC;oBACF,OAAO,CAAC,MAAM,EAAE,CAAC;iBAClB;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,MAAM,EACN,OAAO,EACP,CAAC,EACD,CAAC,EACD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,WAAW,EACX,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAe,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC/G,MAAM,eAAe,GAAG,IAAA,gBAAQ,EAAC,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,MAAM,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AA/MY,yBAAyB;IADrC,IAAA,2BAAU,GAAE;IAMR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,oCAAwB,CAAC,CAAA;;GANvB,yBAAyB,CA+MrC;AA/MY,8DAAyB","file":"symbol-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport { SYMBOL_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n ICustomPath2D\n} from '../../../interface';\nimport type {} from '../../render-service';\nimport { BaseRender } from './base-render';\nimport { SymbolRenderContribution } from './contributions/constants';\nimport { isArray } from '@visactor/vutils';\nimport {\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolClipRangeStrokeRenderContribution,\n defaultSymbolRenderContribution,\n defaultSymbolTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number = SYMBOL_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(SymbolRenderContribution)\n protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultSymbolRenderContribution,\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolTextureRenderContribution,\n defaultSymbolClipRangeStrokeRenderContribution\n ];\n this.init(symbolRenderContribitions);\n }\n\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n\n const {\n size = symbolAttribute.size,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY,\n fillStrokeOrder = symbolAttribute.fillStrokeOrder,\n clipRange = symbolAttribute.clipRange\n } = symbol.attribute;\n\n const data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { keepDirIn3d = symbolAttribute.keepDirIn3d } = symbol.attribute;\n const z = this.z ?? 0;\n context.beginPath();\n\n const callback = (p: ICustomPath2D, a: any) => {\n // 如果是svg的话,合并一下fill和stroke\n if (symbol._parsedPath.svgCache) {\n const obj = Object.assign({}, a);\n obj.fill = a.fill ?? symbol.attribute.fill;\n obj.opacity = a.opacity ?? symbol.attribute.opacity;\n obj.fillOpacity = symbol.attribute.fillOpacity;\n obj.stroke = a.stroke ?? symbol.attribute.stroke;\n obj.lineWidth = a.lineWidth ?? symbol.attribute.lineWidth;\n a = obj;\n }\n const _runFill = () => {\n if (a.fill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n };\n const _runStroke = () => {\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible && clipRange >= 1) {\n context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);\n context.stroke();\n }\n }\n };\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n };\n let _size = size;\n let _x = x;\n let _y = y;\n let _z = z;\n const camera = context.camera;\n if (keepDirIn3d && camera && context.project) {\n const p = context.project(x, y, z);\n context.camera = null;\n _size = isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX;\n _x = p.x;\n _y = p.y;\n _z = undefined;\n }\n if (parsedPath.draw(context, size, _x, _y, _z, callback) === false) {\n context.closePath();\n }\n context.camera = camera;\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n this.beforeRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n // if (fill !== false) {\n // context.setCommonStyle(symbol.attribute, symbolAttribute);\n // context.fill();\n // }\n // if (stroke !== false) {\n // context.setStrokeStyle(symbol.attribute, symbolAttribute);\n // context.stroke();\n // }\n\n // svg就不用fill和stroke了\n const _runFill = () => {\n if (doFill && !parsedPath.isSvg) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else if (fVisible) {\n context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n };\n const _runStroke = () => {\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible && clipRange >= 1) {\n // 如果clipRange < 1,就需要靠afterRender进行绘制了\n context.setStrokeStyle(\n symbol,\n symbol.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute\n );\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this.afterRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n this._draw(symbol, symbolAttribute, false, drawContext, params);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/symbol-render.ts"],"names":[],"mappings":";;;;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Y;QAEZ,IAAI,QAAQ,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;YACjC,IAAI,QAAQ,EAAE;gBACZ,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;aACtD;iBAAM,IAAI,QAAQ,IAAI,SAAS,IAAI,CAAC,EAAE;gBAErC,OAAO,CAAC,cAAc,CACpB,MAAM,EACN,MAAM,CAAC,SAAS,EAChB,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,eAAe,CAChB,CAAC;gBACF,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;SACF;IACH,CAAC;IAED,IAAI,CAAC,MAAe,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC/G,MAAM,eAAe,GAAG,IAAA,gBAAQ,EAAC,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,MAAM,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AA/SY,yBAAyB;IADrC,IAAA,2BAAU,GAAE;IAMR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,oCAAwB,CAAC,CAAA;;GANvB,yBAAyB,CA+SrC;AA/SY,8DAAyB","file":"symbol-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport { SYMBOL_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n ICustomPath2D,\n ISymbolGraphicAttribute\n} from '../../../interface';\nimport type {} from '../../render-service';\nimport { BaseRender } from './base-render';\nimport { SymbolRenderContribution } from './contributions/constants';\nimport { isArray } from '@visactor/vutils';\nimport {\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolClipRangeStrokeRenderContribution,\n defaultSymbolRenderContribution,\n defaultSymbolTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number = SYMBOL_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(SymbolRenderContribution)\n protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultSymbolRenderContribution,\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolTextureRenderContribution,\n defaultSymbolClipRangeStrokeRenderContribution\n ];\n this.init(symbolRenderContribitions);\n }\n\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n symbolAttribute?: Required<ISymbolGraphicAttribute>\n ) {\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n symbolAttribute = symbolAttribute ?? getTheme(symbol, params?.theme).symbol;\n\n const {\n size = symbolAttribute.size,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY,\n fillStrokeOrder = symbolAttribute.fillStrokeOrder,\n clipRange = symbolAttribute.clipRange\n } = symbol.attribute;\n\n const data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { keepDirIn3d = symbolAttribute.keepDirIn3d } = symbol.attribute;\n const z = this.z ?? 0;\n context.beginPath();\n\n const callback = (p: ICustomPath2D, a: any) => {\n // 如果是svg的话,合并一下fill和stroke\n if (symbol._parsedPath.svgCache) {\n const obj = Object.assign({}, a);\n obj.fill = a.fill ?? symbol.attribute.fill;\n obj.opacity = a.opacity ?? symbol.attribute.opacity;\n obj.fillOpacity = symbol.attribute.fillOpacity;\n obj.stroke = a.stroke ?? symbol.attribute.stroke;\n obj.lineWidth = a.lineWidth ?? symbol.attribute.lineWidth;\n a = obj;\n }\n const _runFill = () => {\n if (a.fill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n };\n const _runStroke = () => {\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible && clipRange >= 1) {\n context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);\n context.stroke();\n }\n }\n };\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n };\n let _size = size;\n let _x = x;\n let _y = y;\n let _z = z;\n const camera = context.camera;\n if (keepDirIn3d && camera && context.project) {\n const p = context.project(x, y, z);\n context.camera = null;\n _size = isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX;\n _x = p.x;\n _y = p.y;\n _z = undefined;\n }\n if (parsedPath.draw(context, size, _x, _y, _z, callback) === false) {\n context.closePath();\n }\n context.camera = camera;\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n this.beforeRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n // if (fill !== false) {\n // context.setCommonStyle(symbol.attribute, symbolAttribute);\n // context.fill();\n // }\n // if (stroke !== false) {\n // context.setStrokeStyle(symbol.attribute, symbolAttribute);\n // context.stroke();\n // }\n\n // svg就不用fill和stroke了\n // 内联的函数性能差\n // const _runFill = () => {\n // if (doFill && !parsedPath.isSvg) {\n // if (fillCb) {\n // fillCb(context, symbol.attribute, symbolAttribute);\n // } else if (fVisible) {\n // context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n // context.fill();\n // }\n // }\n // };\n // const _runStroke = () => {\n // if (doStroke && !parsedPath.isSvg) {\n // if (strokeCb) {\n // strokeCb(context, symbol.attribute, symbolAttribute);\n // } else if (sVisible && clipRange >= 1) {\n // // 如果clipRange < 1,就需要靠afterRender进行绘制了\n // context.setStrokeStyle(\n // symbol,\n // symbol.attribute,\n // (originX - x) / scaleX,\n // (originY - y) / scaleY,\n // symbolAttribute\n // );\n // context.stroke();\n // }\n // }\n // };\n\n if (!fillStrokeOrder) {\n this._runFill(symbol, context, x, y, symbolAttribute, doFill, fVisible, originX, originY, parsedPath, fillCb);\n this._runStroke(\n symbol,\n context,\n x,\n y,\n symbolAttribute,\n doStroke,\n sVisible,\n originX,\n originY,\n parsedPath,\n clipRange,\n scaleX,\n scaleY,\n strokeCb\n );\n } else {\n this._runStroke(\n symbol,\n context,\n x,\n y,\n symbolAttribute,\n doStroke,\n sVisible,\n originX,\n originY,\n parsedPath,\n clipRange,\n scaleX,\n scaleY,\n strokeCb\n );\n this._runFill(symbol, context, x, y, symbolAttribute, doFill, fVisible, originX, originY, parsedPath, fillCb);\n }\n\n this.afterRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n private _runFill(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n symbolAttribute: Required<ISymbolGraphicAttribute>,\n doFill: boolean,\n fVisible: boolean,\n originX: number,\n originY: number,\n parsedPath: any,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (doFill && !parsedPath.isSvg) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else if (fVisible) {\n context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n }\n\n private _runStroke(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n symbolAttribute: Required<ISymbolGraphicAttribute>,\n doStroke: boolean,\n sVisible: boolean,\n originX: number,\n originY: number,\n parsedPath: any,\n clipRange: number,\n scaleX: number,\n scaleY: number,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible && clipRange >= 1) {\n // 如果clipRange < 1,就需要靠afterRender进行绘制了\n context.setStrokeStyle(\n symbol,\n symbol.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute\n );\n context.stroke();\n }\n }\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n this._draw(symbol, symbolAttribute, false, drawContext, params);\n }\n}\n"]}