@visactor/vrender-core 0.17.0-alpha.1 → 0.17.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/cjs/allocator/canvas-allocate.d.ts +2 -0
  2. package/cjs/allocator/canvas-allocate.js +12 -6
  3. package/cjs/allocator/canvas-allocate.js.map +1 -1
  4. package/cjs/common/inversify/annotation/inject.d.ts +1 -0
  5. package/cjs/common/inversify/annotation/inject.js +10 -0
  6. package/cjs/common/inversify/annotation/inject.js.map +1 -0
  7. package/cjs/common/inversify/annotation/inject_base.d.ts +14 -0
  8. package/cjs/common/inversify/annotation/inject_base.js +39 -0
  9. package/cjs/common/inversify/annotation/inject_base.js.map +1 -0
  10. package/cjs/common/inversify/annotation/injectable.d.ts +1 -0
  11. package/cjs/common/{inversify-lite/annotation/post_construct.js → inversify/annotation/injectable.js} +15 -5
  12. package/cjs/common/inversify/annotation/injectable.js.map +1 -0
  13. package/cjs/common/inversify/annotation/multi_inject.d.ts +1 -0
  14. package/cjs/common/inversify/annotation/multi_inject.js +10 -0
  15. package/cjs/common/inversify/annotation/multi_inject.js.map +1 -0
  16. package/cjs/common/inversify/annotation/named.d.ts +1 -0
  17. package/cjs/common/inversify/annotation/named.js +14 -0
  18. package/cjs/common/inversify/annotation/named.js.map +1 -0
  19. package/cjs/common/inversify/binding.d.ts +18 -0
  20. package/cjs/common/inversify/binding.js +26 -0
  21. package/cjs/common/inversify/binding.js.map +1 -0
  22. package/cjs/common/inversify/container.d.ts +28 -0
  23. package/cjs/common/inversify/container.js +155 -0
  24. package/cjs/common/inversify/container.js.map +1 -0
  25. package/cjs/common/inversify/cotainer-module.d.ts +6 -0
  26. package/cjs/common/inversify/cotainer-module.js +16 -0
  27. package/cjs/common/inversify/cotainer-module.js.map +1 -0
  28. package/cjs/common/inversify/index.d.ts +7 -0
  29. package/cjs/common/inversify/index.js +75 -0
  30. package/cjs/common/inversify/index.js.map +1 -0
  31. package/cjs/common/inversify/interfaces.d.ts +218 -0
  32. package/cjs/common/inversify/interfaces.js +6 -0
  33. package/cjs/common/inversify/interfaces.js.map +1 -0
  34. package/cjs/common/inversify/literal_types.d.ts +5 -0
  35. package/cjs/common/inversify/literal_types.js +34 -0
  36. package/cjs/common/inversify/literal_types.js.map +1 -0
  37. package/cjs/common/inversify/meta-data.d.ts +6 -0
  38. package/cjs/common/inversify/meta-data.js +19 -0
  39. package/cjs/common/inversify/meta-data.js.map +1 -0
  40. package/cjs/common/inversify/metadata_keys.d.ts +12 -0
  41. package/cjs/common/inversify/metadata_keys.js +15 -0
  42. package/cjs/common/inversify/metadata_keys.js.map +1 -0
  43. package/cjs/common/inversify/metadata_reader.d.ts +6 -0
  44. package/cjs/common/inversify/metadata_reader.js +28 -0
  45. package/cjs/common/inversify/metadata_reader.js.map +1 -0
  46. package/cjs/common/inversify/syntax/binding_in_syntax.d.ts +10 -0
  47. package/cjs/common/inversify/syntax/binding_in_syntax.js +29 -0
  48. package/cjs/common/inversify/syntax/binding_in_syntax.js.map +1 -0
  49. package/cjs/common/inversify/syntax/binding_to_syntax.d.ts +12 -0
  50. package/cjs/common/inversify/syntax/binding_to_syntax.js +40 -0
  51. package/cjs/common/inversify/syntax/binding_to_syntax.js.map +1 -0
  52. package/cjs/common/inversify/syntax/constraint_helpers.d.ts +2 -0
  53. package/cjs/common/inversify/syntax/constraint_helpers.js +18 -0
  54. package/cjs/common/inversify/syntax/constraint_helpers.js.map +1 -0
  55. package/cjs/common/inversify-lite/index.d.ts +1 -8
  56. package/cjs/common/inversify-lite/index.js +1 -64
  57. package/cjs/common/inversify-lite/index.js.map +1 -1
  58. package/cjs/common/utils.d.ts +1 -0
  59. package/cjs/common/utils.js +10 -1
  60. package/cjs/common/utils.js.map +1 -1
  61. package/cjs/core/global.d.ts +2 -0
  62. package/cjs/core/global.js +4 -3
  63. package/cjs/core/global.js.map +1 -1
  64. package/cjs/core/graphic-utils.d.ts +5 -2
  65. package/cjs/core/graphic-utils.js +14 -4
  66. package/cjs/core/graphic-utils.js.map +1 -1
  67. package/cjs/core/stage.d.ts +4 -1
  68. package/cjs/core/stage.js +26 -22
  69. package/cjs/core/stage.js.map +1 -1
  70. package/cjs/core/window.js +2 -2
  71. package/cjs/core/window.js.map +1 -1
  72. package/cjs/graphic/builtin-symbol/index.d.ts +1 -0
  73. package/cjs/graphic/builtin-symbol/index.js +8 -2
  74. package/cjs/graphic/builtin-symbol/index.js.map +1 -1
  75. package/cjs/graphic/config.js +4 -1
  76. package/cjs/graphic/config.js.map +1 -1
  77. package/cjs/graphic/richtext/paragraph.js +12 -11
  78. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  79. package/cjs/graphic/symbol.js +3 -2
  80. package/cjs/graphic/symbol.js.map +1 -1
  81. package/cjs/graphic/text.d.ts +1 -0
  82. package/cjs/graphic/text.js +93 -7
  83. package/cjs/graphic/text.js.map +1 -1
  84. package/cjs/graphic/wrap-text.js +6 -5
  85. package/cjs/graphic/wrap-text.js.map +1 -1
  86. package/cjs/interface/global.d.ts +1 -0
  87. package/cjs/interface/global.js.map +1 -1
  88. package/cjs/interface/graphic/richText.d.ts +1 -1
  89. package/cjs/interface/graphic/richText.js.map +1 -1
  90. package/cjs/interface/graphic/text.d.ts +4 -1
  91. package/cjs/interface/graphic/text.js.map +1 -1
  92. package/cjs/render/contributions/render/draw-contribution.d.ts +2 -0
  93. package/cjs/render/contributions/render/draw-contribution.js +18 -9
  94. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  95. package/cjs/render/contributions/render/line-render.d.ts +1 -0
  96. package/cjs/render/contributions/render/line-render.js +21 -6
  97. package/cjs/render/contributions/render/line-render.js.map +1 -1
  98. package/cjs/render/contributions/render/text-render.js +12 -10
  99. package/cjs/render/contributions/render/text-render.js.map +1 -1
  100. package/dist/index.js +611 -1515
  101. package/dist/index.min.js +1 -1
  102. package/es/allocator/canvas-allocate.d.ts +2 -0
  103. package/es/allocator/canvas-allocate.js +12 -6
  104. package/es/allocator/canvas-allocate.js.map +1 -1
  105. package/es/common/inversify/annotation/inject.d.ts +1 -0
  106. package/es/common/inversify/annotation/inject.js +6 -0
  107. package/es/common/inversify/annotation/inject.js.map +1 -0
  108. package/es/common/inversify/annotation/inject_base.d.ts +14 -0
  109. package/es/common/inversify/annotation/inject_base.js +29 -0
  110. package/es/common/inversify/annotation/inject_base.js.map +1 -0
  111. package/es/common/inversify/annotation/injectable.d.ts +1 -0
  112. package/es/common/inversify/annotation/injectable.js +10 -0
  113. package/es/common/inversify/annotation/injectable.js.map +1 -0
  114. package/es/common/inversify/annotation/multi_inject.d.ts +1 -0
  115. package/es/common/inversify/annotation/multi_inject.js +6 -0
  116. package/es/common/inversify/annotation/multi_inject.js.map +1 -0
  117. package/es/common/inversify/annotation/named.d.ts +1 -0
  118. package/es/common/inversify/annotation/named.js +10 -0
  119. package/es/common/inversify/annotation/named.js.map +1 -0
  120. package/es/common/inversify/binding.d.ts +18 -0
  121. package/es/common/inversify/binding.js +22 -0
  122. package/es/common/inversify/binding.js.map +1 -0
  123. package/es/common/inversify/container.d.ts +28 -0
  124. package/es/common/inversify/container.js +155 -0
  125. package/es/common/inversify/container.js.map +1 -0
  126. package/es/common/inversify/cotainer-module.d.ts +6 -0
  127. package/es/common/inversify/cotainer-module.js +8 -0
  128. package/es/common/inversify/cotainer-module.js.map +1 -0
  129. package/es/common/inversify/index.d.ts +7 -0
  130. package/es/common/inversify/index.js +14 -0
  131. package/es/common/inversify/index.js.map +1 -0
  132. package/es/common/inversify/interfaces.d.ts +218 -0
  133. package/es/common/inversify/interfaces.js +2 -0
  134. package/es/common/inversify/interfaces.js.map +1 -0
  135. package/es/common/inversify/literal_types.d.ts +5 -0
  136. package/es/common/inversify/literal_types.js +20 -0
  137. package/es/common/inversify/literal_types.js.map +1 -0
  138. package/es/common/inversify/meta-data.d.ts +6 -0
  139. package/es/common/inversify/meta-data.js +11 -0
  140. package/es/common/inversify/meta-data.js.map +1 -0
  141. package/es/common/inversify/metadata_keys.d.ts +12 -0
  142. package/es/common/inversify/metadata_keys.js +28 -0
  143. package/es/common/inversify/metadata_keys.js.map +1 -0
  144. package/es/common/inversify/metadata_reader.d.ts +6 -0
  145. package/es/common/inversify/metadata_reader.js +18 -0
  146. package/es/common/inversify/metadata_reader.js.map +1 -0
  147. package/es/common/inversify/syntax/binding_in_syntax.d.ts +10 -0
  148. package/es/common/inversify/syntax/binding_in_syntax.js +24 -0
  149. package/es/common/inversify/syntax/binding_in_syntax.js.map +1 -0
  150. package/es/common/inversify/syntax/binding_to_syntax.d.ts +12 -0
  151. package/es/common/inversify/syntax/binding_to_syntax.js +36 -0
  152. package/es/common/inversify/syntax/binding_to_syntax.js.map +1 -0
  153. package/es/common/inversify/syntax/constraint_helpers.d.ts +2 -0
  154. package/es/common/inversify/syntax/constraint_helpers.js +16 -0
  155. package/es/common/inversify/syntax/constraint_helpers.js.map +1 -0
  156. package/es/common/inversify-lite/index.d.ts +1 -8
  157. package/es/common/inversify-lite/index.js +1 -15
  158. package/es/common/inversify-lite/index.js.map +1 -1
  159. package/es/common/utils.d.ts +1 -0
  160. package/es/common/utils.js +8 -1
  161. package/es/common/utils.js.map +1 -1
  162. package/es/core/global.d.ts +2 -0
  163. package/es/core/global.js +4 -2
  164. package/es/core/global.js.map +1 -1
  165. package/es/core/graphic-utils.d.ts +5 -2
  166. package/es/core/graphic-utils.js +14 -4
  167. package/es/core/graphic-utils.js.map +1 -1
  168. package/es/core/stage.d.ts +4 -1
  169. package/es/core/stage.js +27 -23
  170. package/es/core/stage.js.map +1 -1
  171. package/es/core/window.js +3 -3
  172. package/es/core/window.js.map +1 -1
  173. package/es/graphic/builtin-symbol/index.d.ts +1 -0
  174. package/es/graphic/builtin-symbol/index.js +8 -0
  175. package/es/graphic/builtin-symbol/index.js.map +1 -1
  176. package/es/graphic/config.js +4 -1
  177. package/es/graphic/config.js.map +1 -1
  178. package/es/graphic/richtext/paragraph.js +5 -2
  179. package/es/graphic/richtext/paragraph.js.map +1 -1
  180. package/es/graphic/symbol.js +4 -3
  181. package/es/graphic/symbol.js.map +1 -1
  182. package/es/graphic/text.d.ts +1 -0
  183. package/es/graphic/text.js +90 -9
  184. package/es/graphic/text.js.map +1 -1
  185. package/es/graphic/wrap-text.js +6 -4
  186. package/es/graphic/wrap-text.js.map +1 -1
  187. package/es/interface/global.d.ts +1 -0
  188. package/es/interface/global.js.map +1 -1
  189. package/es/interface/graphic/richText.d.ts +1 -1
  190. package/es/interface/graphic/richText.js.map +1 -1
  191. package/es/interface/graphic/text.d.ts +4 -1
  192. package/es/interface/graphic/text.js.map +1 -1
  193. package/es/render/contributions/render/draw-contribution.d.ts +2 -0
  194. package/es/render/contributions/render/draw-contribution.js +18 -9
  195. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  196. package/es/render/contributions/render/line-render.d.ts +1 -0
  197. package/es/render/contributions/render/line-render.js +21 -6
  198. package/es/render/contributions/render/line-render.js.map +1 -1
  199. package/es/render/contributions/render/text-render.js +13 -9
  200. package/es/render/contributions/render/text-render.js.map +1 -1
  201. package/package.json +6 -4
  202. package/cjs/common/inversify-lite/annotation/post_construct.d.ts +0 -4
  203. package/cjs/common/inversify-lite/annotation/post_construct.js.map +0 -1
  204. package/es/common/inversify-lite/annotation/post_construct.d.ts +0 -4
  205. package/es/common/inversify-lite/annotation/post_construct.js +0 -10
  206. package/es/common/inversify-lite/annotation/post_construct.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/richText.ts"],"names":[],"mappings":"","file":"richText.js","sourcesContent":["import type { IColor } from '../color';\nimport type { IContext2d } from '../context';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { IImage, IImageGraphicAttribute } from './image';\n\nexport type IRichTextAttribute = {\n width: number;\n height: number;\n ellipsis: boolean | string;\n wordBreak: RichTextWordBreak;\n verticalDirection: RichTextVerticalDirection;\n maxHeight: number;\n maxWidth: number;\n textAlign: RichTextGlobalAlignType;\n textBaseline: RichTextGlobalBaselineType;\n layoutDirection: RichTextLayoutDirectionType;\n textConfig: IRichTextCharacter[];\n singleLine: boolean;\n};\n\nexport type IRichTextGraphicAttribute = Partial<IGraphicAttribute> & Partial<IRichTextAttribute>;\n\nexport type RichTextWordBreak = 'break-word' | 'break-all';\nexport type RichTextVerticalDirection = 'top' | 'middle' | 'bottom';\nexport type RichTextGlobalAlignType = 'left' | 'right' | 'center';\nexport type RichTextGlobalBaselineType = 'top' | 'middle' | 'bottom';\nexport type RichTextLayoutDirectionType = 'horizontal' | 'vertical';\nexport type RichTextFontStyle = 'normal' | 'italic' | 'oblique';\nexport type RichTextTextDecoration = 'none' | 'underline' | 'line-through';\n// export type RichTextTextAlign = 'left' | 'right' | 'center';\nexport type RichTextScript = 'normal' | 'sub' | 'super';\n\nexport type IRichTextBasicCharacter = {\n lineHeight?: number;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextParagraphCharacter = IRichTextBasicCharacter & {\n text: string;\n fontSize?: number;\n fontFamily?: string;\n fill?: IColor | boolean;\n stroke?: IColor | boolean;\n fontWeight?: string;\n // lineHeight?: number;\n fontStyle?: RichTextFontStyle; // normal, italic, oblique\n textDecoration?: RichTextTextDecoration; // none, underline, line-through\n // textAlign?: RichTextTextAlign; // left, right, center\n script?: RichTextScript; // normal, sub, super\n underline?: boolean;\n lineThrough?: boolean;\n // direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextImageCharacter = IRichTextBasicCharacter & {\n // 图片基础属性\n image: string | HTMLImageElement | HTMLCanvasElement;\n width: number;\n height: number;\n\n // hover相关属性\n // backgroundShow?: boolean; // 是否显示background\n backgroundShowMode?: 'always' | 'hover';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n // background size 同时控制了该icon的响应范围\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // 唯一标识符\n id?: string;\n\n // lineHeight?: number;\n // textAlign?: RichTextTextAlign; // left, right, center\n // direction?: RichTextLayoutDirectionType;\n margin?: number | number[];\n\n funcType?: string;\n hoverImage?: string | HTMLImageElement | HTMLCanvasElement;\n};\n\nexport type IRichTextCharacter = IRichTextParagraphCharacter | IRichTextImageCharacter;\n\nexport type IRichTextIconGraphicAttribute = IImageGraphicAttribute & {\n id?: string;\n backgroundShowMode?: 'always' | 'hover' | 'never';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // lineHeight?: number;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n\n margin?: number | number[];\n\n // backgroundShow?: boolean;\n};\n\nexport interface IRichTextParagraph {\n text: string;\n ascent: number;\n descent: number;\n width: number;\n height: number;\n lineHeight: number;\n fontSize: number;\n length: number;\n newLine: boolean;\n character: IRichTextParagraphCharacter;\n left: number;\n top: number;\n direction?: 'horizontal' | 'vertical';\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n updateWidth: () => void;\n draw: (ctx: IContext2d, baseline: number, deltaLeft: number, isLineFirst: boolean, textAlign: string) => void;\n getWidthWithEllips: (direction: string) => number;\n}\n\nexport interface IRichTextLine {\n left: number;\n top: number;\n width: number;\n height: number;\n baseline: number;\n ascent: number;\n descent: number;\n paragraphs: (IRichTextParagraph | IRichTextIcon)[];\n actualWidth: number;\n blankWidth: number;\n textAlign: string;\n direction: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n x: string;\n y: string;\n };\n draw: (\n ctx: IContext2d,\n lastLine: boolean,\n x: number,\n y: number,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => void;\n getWidthWithEllips: () => number;\n}\n\nexport interface IRichTextFrame {\n left: number;\n top: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n actualHeight: number;\n ellipsis: boolean | string;\n wordBreak: 'break-word' | 'break-all';\n verticalDirection: 'top' | 'middle' | 'bottom';\n lines: IRichTextLine[];\n globalAlign: 'left' | 'center' | 'right';\n globalBaseline: 'top' | 'middle' | 'bottom';\n layoutDirection: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n top: string;\n bottom: string;\n };\n isWidthMax: boolean;\n isHeightMax: boolean;\n singleLine: boolean;\n icons: Map<string, IRichTextIcon>;\n draw: (\n ctx: IContext2d,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => boolean;\n getActualSize: () => {\n width: number;\n height: number;\n };\n getRawActualSize: () => {\n width: number;\n height: number;\n };\n getActualSizeWidthEllipsis: () => {\n width: number;\n height: number;\n };\n}\n\nexport interface IRichText extends IGraphic<IRichTextGraphicAttribute> {\n getFrameCache: () => IRichTextFrame;\n}\n\nexport interface IRichTextIcon extends IImage {\n attribute: IRichTextIconGraphicAttribute;\n richtextId?: string;\n globalX?: number;\n globalY?: number;\n\n _x: number;\n _y: number;\n _hovered: boolean;\n _marginArray: [number, number, number, number];\n\n setHoverState: (hovered: boolean) => void;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/richText.ts"],"names":[],"mappings":"","file":"richText.js","sourcesContent":["import type { IColor } from '../color';\nimport type { IContext2d } from '../context';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { IImage, IImageGraphicAttribute } from './image';\n\nexport type IRichTextAttribute = {\n width: number;\n height: number;\n ellipsis: boolean | string;\n wordBreak: RichTextWordBreak;\n verticalDirection: RichTextVerticalDirection;\n maxHeight: number;\n maxWidth: number;\n textAlign: RichTextGlobalAlignType;\n textBaseline: RichTextGlobalBaselineType;\n layoutDirection: RichTextLayoutDirectionType;\n textConfig: IRichTextCharacter[];\n singleLine: boolean;\n};\n\nexport type IRichTextGraphicAttribute = Partial<IGraphicAttribute> & Partial<IRichTextAttribute>;\n\nexport type RichTextWordBreak = 'break-word' | 'break-all';\nexport type RichTextVerticalDirection = 'top' | 'middle' | 'bottom';\nexport type RichTextGlobalAlignType = 'left' | 'right' | 'center';\nexport type RichTextGlobalBaselineType = 'top' | 'middle' | 'bottom';\nexport type RichTextLayoutDirectionType = 'horizontal' | 'vertical';\nexport type RichTextFontStyle = 'normal' | 'italic' | 'oblique';\nexport type RichTextTextDecoration = 'none' | 'underline' | 'line-through';\n// export type RichTextTextAlign = 'left' | 'right' | 'center';\nexport type RichTextScript = 'normal' | 'sub' | 'super';\n\nexport type IRichTextBasicCharacter = {\n lineHeight?: number | string;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextParagraphCharacter = IRichTextBasicCharacter & {\n text: string;\n fontSize?: number;\n fontFamily?: string;\n fill?: IColor | boolean;\n stroke?: IColor | boolean;\n fontWeight?: string;\n // lineHeight?: number;\n fontStyle?: RichTextFontStyle; // normal, italic, oblique\n textDecoration?: RichTextTextDecoration; // none, underline, line-through\n // textAlign?: RichTextTextAlign; // left, right, center\n script?: RichTextScript; // normal, sub, super\n underline?: boolean;\n lineThrough?: boolean;\n // direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextImageCharacter = IRichTextBasicCharacter & {\n // 图片基础属性\n image: string | HTMLImageElement | HTMLCanvasElement;\n width: number;\n height: number;\n\n // hover相关属性\n // backgroundShow?: boolean; // 是否显示background\n backgroundShowMode?: 'always' | 'hover';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n // background size 同时控制了该icon的响应范围\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // 唯一标识符\n id?: string;\n\n // lineHeight?: number;\n // textAlign?: RichTextTextAlign; // left, right, center\n // direction?: RichTextLayoutDirectionType;\n margin?: number | number[];\n\n funcType?: string;\n hoverImage?: string | HTMLImageElement | HTMLCanvasElement;\n};\n\nexport type IRichTextCharacter = IRichTextParagraphCharacter | IRichTextImageCharacter;\n\nexport type IRichTextIconGraphicAttribute = IImageGraphicAttribute & {\n id?: string;\n backgroundShowMode?: 'always' | 'hover' | 'never';\n backgroundFill?: boolean | IColor; // 背景矩形填充颜色\n backgroundFillOpacity?: number; // 背景矩形填充透明度\n backgroundStroke?: boolean | IColor; // 背景矩形边框颜色\n backgroundStrokeOpacity?: number; // 背景矩形边框透明度\n backgroundRadius?: number; // 背景矩形圆角\n backgroundWidth?: number;\n backgroundHeight?: number;\n\n // lineHeight?: number;\n textAlign?: CanvasTextAlign; // left, right, center\n textBaseline?: CanvasTextBaseline;\n direction?: RichTextLayoutDirectionType;\n\n margin?: number | number[];\n\n // backgroundShow?: boolean;\n};\n\nexport interface IRichTextParagraph {\n text: string;\n ascent: number;\n descent: number;\n width: number;\n height: number;\n lineHeight: number;\n fontSize: number;\n length: number;\n newLine: boolean;\n character: IRichTextParagraphCharacter;\n left: number;\n top: number;\n direction?: 'horizontal' | 'vertical';\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n updateWidth: () => void;\n draw: (ctx: IContext2d, baseline: number, deltaLeft: number, isLineFirst: boolean, textAlign: string) => void;\n getWidthWithEllips: (direction: string) => number;\n}\n\nexport interface IRichTextLine {\n left: number;\n top: number;\n width: number;\n height: number;\n baseline: number;\n ascent: number;\n descent: number;\n paragraphs: (IRichTextParagraph | IRichTextIcon)[];\n actualWidth: number;\n blankWidth: number;\n textAlign: string;\n direction: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n x: string;\n y: string;\n };\n draw: (\n ctx: IContext2d,\n lastLine: boolean,\n x: number,\n y: number,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => void;\n getWidthWithEllips: () => number;\n}\n\nexport interface IRichTextFrame {\n left: number;\n top: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n actualHeight: number;\n ellipsis: boolean | string;\n wordBreak: 'break-word' | 'break-all';\n verticalDirection: 'top' | 'middle' | 'bottom';\n lines: IRichTextLine[];\n globalAlign: 'left' | 'center' | 'right';\n globalBaseline: 'top' | 'middle' | 'bottom';\n layoutDirection: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n top: string;\n bottom: string;\n };\n isWidthMax: boolean;\n isHeightMax: boolean;\n singleLine: boolean;\n icons: Map<string, IRichTextIcon>;\n draw: (\n ctx: IContext2d,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => boolean;\n getActualSize: () => {\n width: number;\n height: number;\n };\n getRawActualSize: () => {\n width: number;\n height: number;\n };\n getActualSizeWidthEllipsis: () => {\n width: number;\n height: number;\n };\n}\n\nexport interface IRichText extends IGraphic<IRichTextGraphicAttribute> {\n getFrameCache: () => IRichTextFrame;\n}\n\nexport interface IRichTextIcon extends IImage {\n attribute: IRichTextIconGraphicAttribute;\n richtextId?: string;\n globalX?: number;\n globalY?: number;\n\n _x: number;\n _y: number;\n _hovered: boolean;\n _marginArray: [number, number, number, number];\n\n setHoverState: (hovered: boolean) => void;\n}\n"]}
@@ -36,7 +36,7 @@ export type ITextAttribute = {
36
36
  ellipsis: boolean | string;
37
37
  fontVariant: string;
38
38
  fontStyle: string;
39
- lineHeight: number;
39
+ lineHeight: number | string;
40
40
  underline: number;
41
41
  lineThrough: number;
42
42
  scaleIn3d: boolean;
@@ -44,6 +44,9 @@ export type ITextAttribute = {
44
44
  verticalMode: number;
45
45
  wordBreak: 'break-word' | 'break-all';
46
46
  ignoreBuf: boolean;
47
+ whiteSpace: 'normal' | 'no-wrap';
48
+ heightLimit?: number;
49
+ lineClamp?: number;
47
50
  };
48
51
  export type ITextCache = {
49
52
  clipedText?: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n verticalMode: number; // 垂直布局的模式,0代表默认(横向textAlign,纵向textBaseline),1代表特殊(横向textBaseline,纵向textAlign)\n wordBreak: 'break-word' | 'break-all';\n ignoreBuf: boolean;\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n};\nexport type ITextCache = {\n // 单行文本的时候缓存用\n clipedText?: string;\n clipedWidth?: number;\n // 多行文本的布局缓存\n layoutData?: LayoutType;\n verticalList?: { text: string; width?: number; direction: number }[][];\n};\n\nexport type ITextGraphicAttribute = Partial<IGraphicAttribute> & Partial<ITextAttribute>;\n\nexport type IWrapTextGraphicAttribute = ITextGraphicAttribute & {\n heightLimit?: number;\n lineClamp?: number;\n};\n\nexport interface IText extends IGraphic<ITextGraphicAttribute> {\n // 判断是否被ellipisised\n clipedText?: string;\n clipedWidth?: number;\n cliped?: boolean;\n multilineLayout?: LayoutType;\n font?: string;\n cache?: ITextCache;\n\n getBaselineMapAlign: () => Record<string, string>;\n getAlignMapBaseline: () => Record<string, string>;\n\n updateMultilineAABBBounds: (text: (number | string)[]) => IAABBBounds;\n updateSingallineAABBBounds: (text: number | string) => IAABBBounds;\n}\n\nexport type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';\nexport type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number | string;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n verticalMode: number; // 垂直布局的模式,0代表默认(横向textAlign,纵向textBaseline),1代表特殊(横向textBaseline,纵向textAlign)\n wordBreak: 'break-word' | 'break-all';\n ignoreBuf: boolean;\n whiteSpace: 'normal' | 'no-wrap';\n heightLimit?: number;\n lineClamp?: number;\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n};\nexport type ITextCache = {\n // 单行文本的时候缓存用\n clipedText?: string;\n clipedWidth?: number;\n // 多行文本的布局缓存\n layoutData?: LayoutType;\n verticalList?: { text: string; width?: number; direction: number }[][];\n};\n\nexport type ITextGraphicAttribute = Partial<IGraphicAttribute> & Partial<ITextAttribute>;\n\nexport type IWrapTextGraphicAttribute = ITextGraphicAttribute & {\n heightLimit?: number;\n lineClamp?: number;\n};\n\nexport interface IText extends IGraphic<ITextGraphicAttribute> {\n // 判断是否被ellipisised\n clipedText?: string;\n clipedWidth?: number;\n cliped?: boolean;\n multilineLayout?: LayoutType;\n font?: string;\n cache?: ITextCache;\n\n getBaselineMapAlign: () => Record<string, string>;\n getAlignMapBaseline: () => Record<string, string>;\n\n updateMultilineAABBBounds: (text: (number | string)[]) => IAABBBounds;\n updateSingallineAABBBounds: (text: number | string) => IAABBBounds;\n}\n\nexport type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';\nexport type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';\n"]}
@@ -9,12 +9,14 @@ export declare class DefaultDrawContribution implements IDrawContribution {
9
9
  styleRenderMap: Map<string, Map<number, IGraphicRender>>;
10
10
  dirtyBounds: IBounds;
11
11
  backupDirtyBounds: IBounds;
12
+ useDirtyBounds: boolean;
12
13
  currentRenderService: IRenderService;
13
14
  InterceptorContributions: IDrawItemInterceptorContribution[];
14
15
  global: IGlobal;
15
16
  layerService: ILayerService;
16
17
  constructor(contributions: IGraphicRender[], drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>);
17
18
  init(): void;
19
+ prepareForDraw(renderService: IRenderService, drawContext: IDrawContext): void;
18
20
  draw(renderService: IRenderService, drawContext: IDrawContext): MaybePromise<void>;
19
21
  doRegister(): void;
20
22
  protected _findNextGraphic(group: IGroup): IGraphic | null;
@@ -10,7 +10,7 @@ var __decorate = this && this.__decorate || function(decorators, target, key, de
10
10
  };
11
11
  };
12
12
 
13
- import { injectable, inject, postConstruct, named, multiInject } from "../../../common/inversify-lite";
13
+ import { injectable, inject, named, multiInject } from "../../../common/inversify-lite";
14
14
 
15
15
  import { findNextGraphic, foreach } from "../../../common/sort";
16
16
 
@@ -39,7 +39,7 @@ let DefaultDrawContribution = class {
39
39
  this.contributions = contributions, this.drawItemInterceptorContributions = drawItemInterceptorContributions,
40
40
  this.currentRenderMap = new Map, this.defaultRenderMap = new Map, this.styleRenderMap = new Map,
41
41
  this.dirtyBounds = new Bounds, this.backupDirtyBounds = new Bounds, this.global = application.global,
42
- this.layerService = application.layerService;
42
+ this.layerService = application.layerService, this.init();
43
43
  }
44
44
  init() {
45
45
  this.contributions.forEach((item => {
@@ -49,8 +49,12 @@ let DefaultDrawContribution = class {
49
49
  } else this.defaultRenderMap.set(item.numberType, item);
50
50
  })), this.InterceptorContributions = this.drawItemInterceptorContributions.getContributions().sort(((a, b) => a.order - b.order));
51
51
  }
52
+ prepareForDraw(renderService, drawContext) {
53
+ renderService.renderTreeRoots.reduce(((a, b) => a + b.count), 0) < this.global.optmizeSkipCheckBoundariesThreshold ? this.useDirtyBounds = !1 : this.useDirtyBounds = !0;
54
+ }
52
55
  draw(renderService, drawContext) {
53
- drawContext.drawContribution = this, this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap,
56
+ this.prepareForDraw(renderService, drawContext), drawContext.drawContribution = this,
57
+ this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap,
54
58
  this.currentRenderService = renderService;
55
59
  const {context: context, stage: stage, x: x = 0, y: y = 0, width: width, height: height} = drawContext;
56
60
  if (!context) return;
@@ -90,9 +94,14 @@ let DefaultDrawContribution = class {
90
94
  if (drawContext.break || !1 === group.attribute.visibleAll) return;
91
95
  if (group.incremental && (null == drawContext.startAtId || drawContext.startAtId === group._uid)) return drawContext.break = !0,
92
96
  void this._increaseRender(group, drawContext);
93
- if (!isRectIntersect(group.AABBBounds, this.dirtyBounds, !1)) return;
94
- const tempBounds = boundsAllocate.allocateByObj(this.dirtyBounds), gm = group.transMatrix, nextM = matrixAllocate.allocateByObj(parentMatrix).multiply(gm.a, gm.b, gm.c, gm.d, gm.e, gm.f);
95
- this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(nextM.getInverse()),
97
+ if (this.useDirtyBounds && !isRectIntersect(group.AABBBounds, this.dirtyBounds, !1)) return;
98
+ let nextM, tempBounds;
99
+ if (this.useDirtyBounds) {
100
+ tempBounds = boundsAllocate.allocateByObj(this.dirtyBounds);
101
+ const gm = group.transMatrix;
102
+ nextM = matrixAllocate.allocateByObj(parentMatrix).multiply(gm.a, gm.b, gm.c, gm.d, gm.e, gm.f),
103
+ this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(nextM.getInverse());
104
+ }
96
105
  this.renderItem(group, drawContext, {
97
106
  drawingCb: () => {
98
107
  var _a;
@@ -102,7 +111,8 @@ let DefaultDrawContribution = class {
102
111
  drawContext.break || (item.isContainer ? this.renderGroup(item, drawContext, nextM) : this.renderItem(item, drawContext));
103
112
  }), !1, !!(null === (_a = drawContext.context) || void 0 === _a ? void 0 : _a.camera));
104
113
  }
105
- }), this.dirtyBounds.copy(tempBounds), boundsAllocate.free(tempBounds), matrixAllocate.free(nextM);
114
+ }), this.useDirtyBounds && (this.dirtyBounds.copy(tempBounds), boundsAllocate.free(tempBounds),
115
+ matrixAllocate.free(nextM));
106
116
  }
107
117
  _increaseRender(group, drawContext) {
108
118
  const {layer: layer, stage: stage} = drawContext, {subLayers: subLayers} = layer;
@@ -161,7 +171,7 @@ let DefaultDrawContribution = class {
161
171
  this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(m), this.dirtyBounds.translate(-scrollX, -scrollY);
162
172
  }
163
173
  }
164
- if (!graphic.isContainer && !isRectIntersect(graphic.AABBBounds, this.dirtyBounds, !1)) return void (retrans && this.dirtyBounds.copy(tempBounds));
174
+ if (this.useDirtyBounds && !graphic.isContainer && !isRectIntersect(graphic.AABBBounds, this.dirtyBounds, !1)) return void (retrans && this.dirtyBounds.copy(tempBounds));
165
175
  const skipDraw = null != drawContext.startAtId && graphic._uid !== drawContext.startAtId;
166
176
  if (graphic._uid === drawContext.startAtId && (drawContext.startAtId = null), params && (params.skipDraw = skipDraw),
167
177
  skipDraw ? graphic.isContainer && renderer.draw(graphic, this.currentRenderService, drawContext, params) : renderer.draw(graphic, this.currentRenderService, drawContext, params),
@@ -199,7 +209,6 @@ let DefaultDrawContribution = class {
199
209
  afterDraw(renderService, drawParams) {}
200
210
  };
201
211
 
202
- __decorate([ postConstruct(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0) ], DefaultDrawContribution.prototype, "init", null),
203
212
  DefaultDrawContribution = __decorate([ injectable(), __param(0, multiInject(GraphicRender)), __param(1, inject(ContributionProvider)), __param(1, named(DrawItemInterceptor)), __metadata("design:paramtypes", [ Array, Object ]) ], DefaultDrawContribution);
204
213
 
205
214
  export { DefaultDrawContribution };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,E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,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,MAAM,EAAE;iBAC5D,EACD,CAAC,EACD,CAAC,CACF,CAAC;gBACF,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;aACvC;SACF;IACH,CAAC;IAED,SAAS,CAAC,aAA6B,EAAE,UAAwB;QAC/D,OAAO;IACT,CAAC;CACF,CAAA;AArVC;IAAC,aAAa,EAAE;;;;mDAcf;AA9CU,uBAAuB;IADnC,UAAU,EAAE;IAiBR,WAAA,WAAW,CAAC,aAAa,CAAC,CAAA;IAG1B,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GApBlB,uBAAuB,CAqXnC;SArXY,uBAAuB","file":"draw-contribution.js","sourcesContent":["import { injectable, inject, postConstruct, named, multiInject } from '../../../common/inversify-lite';\nimport type {\n IContext2d,\n MaybePromise,\n IGraphic,\n IGroup,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n IDrawItemInterceptorContribution,\n IDrawContribution,\n IRenderSelector,\n IGlobal\n} from '../../../interface';\nimport { findNextGraphic, foreach } from '../../../common/sort';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { DefaultAttribute } from '../../../graphic';\nimport type { IAABBBounds, IBounds, IMatrixLike } from '@visactor/vutils';\nimport { Bounds, getRectIntersect, isRectIntersect, last } from '@visactor/vutils';\nimport { container } from '../../../container';\nimport { GraphicRender, IncrementalDrawContribution, RenderSelector } from './symbol';\nimport { DrawItemInterceptor } from './draw-interceptor';\nimport { createColor } from '../../../common/canvas-utils';\nimport type { ILayerService } from '../../../interface/core';\nimport { boundsAllocate } from '../../../allocator/bounds-allocate';\nimport { matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { application } from '../../../application';\n\n/**\n * 默认的渲染contribution,基于树状结构针对图元的渲染\n */\n@injectable()\nexport class DefaultDrawContribution implements IDrawContribution {\n declare currentRenderMap: Map<number, IGraphicRender>;\n declare defaultRenderMap: Map<number, IGraphicRender>;\n declare styleRenderMap: Map<string, Map<number, IGraphicRender>>;\n declare dirtyBounds: IBounds;\n declare backupDirtyBounds: IBounds;\n declare currentRenderService: IRenderService;\n declare InterceptorContributions: IDrawItemInterceptorContribution[];\n\n declare global: IGlobal;\n declare layerService: ILayerService;\n\n constructor(\n // @inject(ContributionProvider)\n // @named(GraphicRender)\n // protected readonly contributions: ContributionProvider<IGraphicRender>,\n @multiInject(GraphicRender) protected readonly contributions: IGraphicRender[],\n // @inject(RenderSelector) protected readonly renderSelector: IRenderSelector, // 根据图元类型选择对应的renderItem进行渲染\n // 拦截器\n @inject(ContributionProvider)\n @named(DrawItemInterceptor)\n protected readonly drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>\n ) {\n this.currentRenderMap = new Map();\n this.defaultRenderMap = new Map();\n this.styleRenderMap = new Map();\n this.dirtyBounds = new Bounds();\n this.backupDirtyBounds = new Bounds();\n this.global = application.global;\n this.layerService = application.layerService;\n }\n\n @postConstruct()\n init() {\n this.contributions.forEach(item => {\n if (item.style) {\n const map = this.styleRenderMap.get(item.style) || new Map();\n map.set(item.numberType, item);\n this.styleRenderMap.set(item.style, map);\n } else {\n this.defaultRenderMap.set(item.numberType, item);\n }\n });\n this.InterceptorContributions = this.drawItemInterceptorContributions\n .getContributions()\n .sort((a, b) => a.order - b.order);\n }\n\n draw(renderService: IRenderService, drawContext: IDrawContext): MaybePromise<void> {\n drawContext.drawContribution = this;\n this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap;\n // this.startAtId = drawParams.startAtId;\n this.currentRenderService = renderService;\n // this.drawParams = drawParams;\n const { context, stage, x = 0, y = 0, width, height } = drawContext;\n\n if (!context) {\n return;\n }\n // if (context.drawPromise) {\n // return;\n // }\n const dirtyBounds: IBounds | undefined = this.dirtyBounds.setValue(0, 0, width, height);\n if (stage.dirtyBounds && !stage.dirtyBounds.empty()) {\n const b = getRectIntersect(dirtyBounds, stage.dirtyBounds, false);\n dirtyBounds.x1 = Math.floor(b.x1);\n dirtyBounds.y1 = Math.floor(b.y1);\n dirtyBounds.x2 = Math.ceil(b.x2);\n dirtyBounds.y2 = Math.ceil(b.y2);\n }\n this.backupDirtyBounds.copy(dirtyBounds);\n context.inuse = true;\n // 初始化context\n context.clearMatrix();\n context.setTransformForCurrent(true);\n\n const drawInArea =\n dirtyBounds.width() * context.dpr !== context.canvas.width ||\n dirtyBounds.height() * context.dpr !== context.canvas.height;\n context.save();\n\n // 设置translate\n context.translate(x, y, true);\n if (drawInArea) {\n context.beginPath();\n context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height());\n context.clip();\n }\n\n // 如果存在3d视角,那么不使用dirtyBounds\n if (stage.camera) {\n this.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n this.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n }\n\n this.clearScreen(renderService, context, drawContext);\n // // 渲染的时候图元的起始位置就是x,y\n // this.backupDirtyBounds.translate(-x, -y);\n // this.dirtyBounds.translate(-x, -y);\n\n // // 设置translate\n // context.translate(x, y, true);\n\n context.save();\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroup(group as IGroup, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));\n });\n\n context.restore();\n context.restore();\n context.draw();\n // this.break = false;\n context.inuse = false;\n }\n\n doRegister() {\n throw new Error('暂不支持');\n }\n\n // 找到下一个graphic\n protected _findNextGraphic(group: IGroup): IGraphic | null {\n let parent = group.parent;\n let id = group._uid;\n while (parent) {\n const g = findNextGraphic(parent, id, DefaultAttribute.zIndex);\n if (g) {\n return g;\n }\n id = parent._uid;\n parent = parent.parent;\n }\n return null;\n }\n\n renderGroup(group: IGroup, drawContext: IDrawContext, parentMatrix: IMatrixLike, skipSort?: boolean) {\n if (drawContext.break || group.attribute.visibleAll === false) {\n return;\n }\n if (group.incremental && (drawContext.startAtId == null || drawContext.startAtId === group._uid)) {\n drawContext.break = true;\n this._increaseRender(group, drawContext);\n return;\n }\n\n if (!isRectIntersect(group.AABBBounds, this.dirtyBounds, false)) {\n return;\n }\n\n const tempBounds = boundsAllocate.allocateByObj(this.dirtyBounds);\n\n // 变换dirtyBounds\n const gm = group.transMatrix;\n const nextM = matrixAllocate.allocateByObj(parentMatrix).multiply(gm.a, gm.b, gm.c, gm.d, gm.e, gm.f);\n // const m = group.globalTransMatrix.getInverse();\n this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(nextM.getInverse());\n\n this.renderItem(group, drawContext, {\n drawingCb: () => {\n skipSort\n ? group.forEachChildren((item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext, nextM);\n } else {\n this.renderItem(item, drawContext);\n }\n })\n : foreach(\n group,\n DefaultAttribute.zIndex,\n (item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext, nextM);\n } else {\n this.renderItem(item, drawContext);\n }\n },\n false,\n !!drawContext.context?.camera\n );\n }\n });\n\n this.dirtyBounds.copy(tempBounds);\n boundsAllocate.free(tempBounds);\n matrixAllocate.free(nextM);\n }\n\n protected _increaseRender(group: IGroup, drawContext: IDrawContext) {\n const { layer, stage } = drawContext;\n const { subLayers } = layer;\n // 获取渐进渲染层\n let incrementalLayer = subLayers.get(group._uid);\n if (!incrementalLayer) {\n incrementalLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size,\n group\n };\n subLayers.set(group._uid, incrementalLayer);\n }\n // 渲染\n const incrementalContext = incrementalLayer.layer.getNativeHandler().getContext();\n const idc = incrementalLayer.drawContribution || container.get(IncrementalDrawContribution);\n idc.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n idc.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n (idc as any).draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: incrementalLayer.layer,\n context: incrementalContext,\n startAtId: group._uid,\n break: false\n });\n incrementalLayer.drawContribution = idc;\n // this.draw(this.currentRenderService, {...this.drawParams, startAtId: group._uid})\n // this.draw(this.currentRenderService, {...this.drawParams, clear: 'transparent', layer: incrementalContext.layer, context: incrementalContext, startAtId: group._uid})\n const nextGraphic = this._findNextGraphic(group);\n if (nextGraphic) {\n // 如果是下一个渐进渲染层,那就再来一次\n if (nextGraphic.isContainer && nextGraphic.incremental) {\n this._increaseRender(nextGraphic as IGroup, drawContext);\n } else {\n // 如果不是渐进渲染层,那就默认图层渲染\n let afterLayer = subLayers.get(nextGraphic._uid);\n if (!afterLayer) {\n afterLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size\n };\n subLayers.set(nextGraphic._uid, afterLayer);\n }\n const afterContext = afterLayer.layer.getNativeHandler().getContext();\n this.draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: afterLayer.layer,\n context: afterContext,\n startAtId: nextGraphic._uid,\n break: false\n });\n }\n }\n }\n\n getRenderContribution(graphic: IGraphic): IGraphicRender | null {\n // let renderer = this.renderSelector.selector(graphic);\n let renderer;\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType);\n }\n if (!renderer) {\n renderer = this.selectRenderByType(graphic.type);\n }\n return renderer;\n }\n\n renderItem(graphic: IGraphic, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.beforeDrawItem) {\n if (drawContribution.beforeDrawItem(graphic, this.currentRenderService, drawContext, this, params)) {\n return;\n }\n }\n }\n }\n\n const renderer = this.getRenderContribution(graphic);\n if (!renderer) {\n return;\n }\n\n let retrans: boolean = false;\n let tempBounds: IAABBBounds;\n\n if (graphic.parent) {\n const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n retrans = !!(scrollX || scrollY);\n if (retrans) {\n tempBounds = this.dirtyBounds.clone();\n // 变换dirtyBounds\n const m = graphic.globalTransMatrix.getInverse();\n this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(m);\n this.dirtyBounds.translate(-scrollX, -scrollY);\n }\n }\n\n if (!(graphic.isContainer || isRectIntersect(graphic.AABBBounds, this.dirtyBounds, false))) {\n retrans && this.dirtyBounds.copy(tempBounds);\n return;\n }\n\n const skipDraw = drawContext.startAtId != null && graphic._uid !== drawContext.startAtId;\n if (graphic._uid === drawContext.startAtId) {\n drawContext.startAtId = null;\n }\n params && (params.skipDraw = skipDraw);\n if (skipDraw) {\n graphic.isContainer && renderer.draw(graphic, this.currentRenderService, drawContext, params);\n } else {\n renderer.draw(graphic, this.currentRenderService, drawContext, params);\n }\n\n retrans && this.dirtyBounds.copy(tempBounds);\n\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.afterDrawItem) {\n if (drawContribution.afterDrawItem(graphic, this.currentRenderService, drawContext, this)) {\n return;\n }\n }\n }\n }\n }\n // 根据type选择对应的render\n protected selectRenderByType(type?: string): IGraphicRender | null {\n console.warn('未知错误,不应该走到这里');\n return null;\n }\n // 根据type选择对应的render\n protected selectRenderByNumberType(type?: number): IGraphicRender | null {\n return this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);\n }\n\n protected clearScreen(renderService: IRenderService, context: IContext2d, drawContext: IDrawContext) {\n const { clear } = drawContext;\n if (clear) {\n const canvas = context.getCanvas();\n const { width = canvas.width, height = canvas.height } = drawContext;\n const x = 0;\n const y = 0;\n context.clearRect(x, y, width, height);\n const stage = renderService.drawParams?.stage;\n if (stage && (stage as any).backgroundImg && (stage as any).resources) {\n const res = (stage as any).resources.get(clear);\n if (res && res.state === 'success' && res.data) {\n context.drawImage(res.data, x, y, width, height);\n }\n } else {\n context.fillStyle = createColor(\n context,\n clear,\n {\n AABBBounds: { x1: x, y1: y, x2: x + width, y2: y + height }\n },\n 0,\n 0\n );\n context.fillRect(x, y, width, height);\n }\n }\n }\n\n afterDraw(renderService: IRenderService, drawParams: IDrawContext) {\n return;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/draw-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAgBxF,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAQ,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,2BAA2B,EAAkB,MAAM,UAAU,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAM5C,IAAM,uBAAuB,GA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AAG,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,MAAM,EAAE;iBAC5D,EACD,CAAC,EACD,CAAC,CACF,CAAC;gBACF,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;aACvC;SACF;IACH,CAAC;IAED,SAAS,CAAC,aAA6B,EAAE,UAAwB;QAC/D,OAAO;IACT,CAAC;CACF,CAAA;AAxYY,uBAAuB;IADnC,UAAU,EAAE;IAmBR,WAAA,WAAW,CAAC,aAAa,CAAC,CAAA;IAG1B,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GAtBlB,uBAAuB,CAwYnC;SAxYY,uBAAuB","file":"draw-contribution.js","sourcesContent":["import { injectable, inject, named, multiInject } from '../../../common/inversify-lite';\nimport type {\n IContext2d,\n MaybePromise,\n IGraphic,\n IGroup,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n IDrawItemInterceptorContribution,\n IDrawContribution,\n IRenderSelector,\n IGlobal\n} from '../../../interface';\nimport { findNextGraphic, foreach } from '../../../common/sort';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { DefaultAttribute } from '../../../graphic';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix, IMatrixLike } from '@visactor/vutils';\nimport { Bounds, getRectIntersect, isRectIntersect, last } from '@visactor/vutils';\nimport { container } from '../../../container';\nimport { GraphicRender, IncrementalDrawContribution, RenderSelector } from './symbol';\nimport { DrawItemInterceptor } from './draw-interceptor';\nimport { createColor } from '../../../common/canvas-utils';\nimport type { ILayerService } from '../../../interface/core';\nimport { boundsAllocate } from '../../../allocator/bounds-allocate';\nimport { matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { application } from '../../../application';\n\n/**\n * 默认的渲染contribution,基于树状结构针对图元的渲染\n */\n@injectable()\nexport class DefaultDrawContribution implements IDrawContribution {\n declare currentRenderMap: Map<number, IGraphicRender>;\n declare defaultRenderMap: Map<number, IGraphicRender>;\n declare styleRenderMap: Map<string, Map<number, IGraphicRender>>;\n declare dirtyBounds: IBounds;\n declare backupDirtyBounds: IBounds;\n // 是否使用dirtyBounds\n declare useDirtyBounds: boolean;\n declare currentRenderService: IRenderService;\n declare InterceptorContributions: IDrawItemInterceptorContribution[];\n\n declare global: IGlobal;\n declare layerService: ILayerService;\n\n constructor(\n // @inject(ContributionProvider)\n // @named(GraphicRender)\n // protected readonly contributions: ContributionProvider<IGraphicRender>,\n @multiInject(GraphicRender) protected readonly contributions: IGraphicRender[],\n // @inject(RenderSelector) protected readonly renderSelector: IRenderSelector, // 根据图元类型选择对应的renderItem进行渲染\n // 拦截器\n @inject(ContributionProvider)\n @named(DrawItemInterceptor)\n protected readonly drawItemInterceptorContributions: IContributionProvider<IDrawItemInterceptorContribution>\n ) {\n this.currentRenderMap = new Map();\n this.defaultRenderMap = new Map();\n this.styleRenderMap = new Map();\n this.dirtyBounds = new Bounds();\n this.backupDirtyBounds = new Bounds();\n this.global = application.global;\n this.layerService = application.layerService;\n this.init();\n }\n\n init() {\n this.contributions.forEach(item => {\n if (item.style) {\n const map = this.styleRenderMap.get(item.style) || new Map();\n map.set(item.numberType, item);\n this.styleRenderMap.set(item.style, map);\n } else {\n this.defaultRenderMap.set(item.numberType, item);\n }\n });\n this.InterceptorContributions = this.drawItemInterceptorContributions\n .getContributions()\n .sort((a, b) => a.order - b.order);\n }\n\n prepareForDraw(renderService: IRenderService, drawContext: IDrawContext) {\n const count = renderService.renderTreeRoots.reduce((a, b) => a + b.count, 0);\n // 小于500个元素就不用计算dirtyBounds了\n if (count < this.global.optmizeSkipCheckBoundariesThreshold) {\n this.useDirtyBounds = false;\n } else {\n this.useDirtyBounds = true;\n }\n }\n\n draw(renderService: IRenderService, drawContext: IDrawContext): MaybePromise<void> {\n this.prepareForDraw(renderService, drawContext);\n drawContext.drawContribution = this;\n this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap;\n // this.startAtId = drawParams.startAtId;\n this.currentRenderService = renderService;\n // this.drawParams = drawParams;\n const { context, stage, x = 0, y = 0, width, height } = drawContext;\n\n if (!context) {\n return;\n }\n // if (context.drawPromise) {\n // return;\n // }\n const dirtyBounds: IBounds | undefined = this.dirtyBounds.setValue(0, 0, width, height);\n if (stage.dirtyBounds && !stage.dirtyBounds.empty()) {\n const b = getRectIntersect(dirtyBounds, stage.dirtyBounds, false);\n dirtyBounds.x1 = Math.floor(b.x1);\n dirtyBounds.y1 = Math.floor(b.y1);\n dirtyBounds.x2 = Math.ceil(b.x2);\n dirtyBounds.y2 = Math.ceil(b.y2);\n }\n this.backupDirtyBounds.copy(dirtyBounds);\n context.inuse = true;\n // 初始化context\n context.clearMatrix();\n context.setTransformForCurrent(true);\n\n const drawInArea =\n dirtyBounds.width() * context.dpr !== context.canvas.width ||\n dirtyBounds.height() * context.dpr !== context.canvas.height;\n context.save();\n\n // 设置translate\n context.translate(x, y, true);\n if (drawInArea) {\n context.beginPath();\n context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height());\n context.clip();\n }\n\n // 如果存在3d视角,那么不使用dirtyBounds\n if (stage.camera) {\n this.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n this.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n }\n\n this.clearScreen(renderService, context, drawContext);\n // // 渲染的时候图元的起始位置就是x,y\n // this.backupDirtyBounds.translate(-x, -y);\n // this.dirtyBounds.translate(-x, -y);\n\n // // 设置translate\n // context.translate(x, y, true);\n\n context.save();\n renderService.renderTreeRoots\n .sort((a, b) => {\n return (a.attribute.zIndex ?? DefaultAttribute.zIndex) - (b.attribute.zIndex ?? DefaultAttribute.zIndex);\n })\n .forEach(group => {\n this.renderGroup(group as IGroup, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));\n });\n\n context.restore();\n context.restore();\n context.draw();\n // this.break = false;\n context.inuse = false;\n }\n\n doRegister() {\n throw new Error('暂不支持');\n }\n\n // 找到下一个graphic\n protected _findNextGraphic(group: IGroup): IGraphic | null {\n let parent = group.parent;\n let id = group._uid;\n while (parent) {\n const g = findNextGraphic(parent, id, DefaultAttribute.zIndex);\n if (g) {\n return g;\n }\n id = parent._uid;\n parent = parent.parent;\n }\n return null;\n }\n\n renderGroup(group: IGroup, drawContext: IDrawContext, parentMatrix: IMatrixLike, skipSort?: boolean) {\n if (drawContext.break || group.attribute.visibleAll === false) {\n return;\n }\n if (group.incremental && (drawContext.startAtId == null || drawContext.startAtId === group._uid)) {\n drawContext.break = true;\n this._increaseRender(group, drawContext);\n return;\n }\n\n if (this.useDirtyBounds && !isRectIntersect(group.AABBBounds, this.dirtyBounds, false)) {\n return;\n }\n\n let nextM: IMatrix;\n let tempBounds: IBounds;\n\n if (this.useDirtyBounds) {\n tempBounds = boundsAllocate.allocateByObj(this.dirtyBounds);\n // 变换dirtyBounds\n const gm = group.transMatrix;\n nextM = matrixAllocate.allocateByObj(parentMatrix).multiply(gm.a, gm.b, gm.c, gm.d, gm.e, gm.f);\n // const m = group.globalTransMatrix.getInverse();\n this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(nextM.getInverse());\n }\n\n this.renderItem(group, drawContext, {\n drawingCb: () => {\n skipSort\n ? group.forEachChildren((item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext, nextM);\n } else {\n this.renderItem(item, drawContext);\n }\n })\n : foreach(\n group,\n DefaultAttribute.zIndex,\n (item: IGraphic) => {\n if (drawContext.break) {\n return;\n }\n if (item.isContainer) {\n this.renderGroup(item as IGroup, drawContext, nextM);\n } else {\n this.renderItem(item, drawContext);\n }\n },\n false,\n !!drawContext.context?.camera\n );\n }\n });\n\n if (this.useDirtyBounds) {\n this.dirtyBounds.copy(tempBounds);\n boundsAllocate.free(tempBounds);\n matrixAllocate.free(nextM);\n }\n }\n\n protected _increaseRender(group: IGroup, drawContext: IDrawContext) {\n const { layer, stage } = drawContext;\n const { subLayers } = layer;\n // 获取渐进渲染层\n let incrementalLayer = subLayers.get(group._uid);\n if (!incrementalLayer) {\n incrementalLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size,\n group\n };\n subLayers.set(group._uid, incrementalLayer);\n }\n // 渲染\n const incrementalContext = incrementalLayer.layer.getNativeHandler().getContext();\n const idc = incrementalLayer.drawContribution || container.get(IncrementalDrawContribution);\n idc.dirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n idc.backupDirtyBounds.setValue(-Infinity, -Infinity, Infinity, Infinity);\n (idc as any).draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: incrementalLayer.layer,\n context: incrementalContext,\n startAtId: group._uid,\n break: false\n });\n incrementalLayer.drawContribution = idc;\n // this.draw(this.currentRenderService, {...this.drawParams, startAtId: group._uid})\n // this.draw(this.currentRenderService, {...this.drawParams, clear: 'transparent', layer: incrementalContext.layer, context: incrementalContext, startAtId: group._uid})\n const nextGraphic = this._findNextGraphic(group);\n if (nextGraphic) {\n // 如果是下一个渐进渲染层,那就再来一次\n if (nextGraphic.isContainer && nextGraphic.incremental) {\n this._increaseRender(nextGraphic as IGroup, drawContext);\n } else {\n // 如果不是渐进渲染层,那就默认图层渲染\n let afterLayer = subLayers.get(nextGraphic._uid);\n if (!afterLayer) {\n afterLayer = {\n layer: this.layerService.createLayer(stage),\n zIndex: subLayers.size\n };\n subLayers.set(nextGraphic._uid, afterLayer);\n }\n const afterContext = afterLayer.layer.getNativeHandler().getContext();\n this.draw(this.currentRenderService, {\n ...drawContext,\n drawContribution: idc,\n clear: 'transparent',\n layer: afterLayer.layer,\n context: afterContext,\n startAtId: nextGraphic._uid,\n break: false\n });\n }\n }\n }\n\n getRenderContribution(graphic: IGraphic): IGraphicRender | null {\n // let renderer = this.renderSelector.selector(graphic);\n let renderer;\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType);\n }\n if (!renderer) {\n renderer = this.selectRenderByType(graphic.type);\n }\n return renderer;\n }\n\n renderItem(graphic: IGraphic, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.beforeDrawItem) {\n if (drawContribution.beforeDrawItem(graphic, this.currentRenderService, drawContext, this, params)) {\n return;\n }\n }\n }\n }\n\n const renderer = this.getRenderContribution(graphic);\n if (!renderer) {\n return;\n }\n\n let retrans: boolean = false;\n let tempBounds: IAABBBounds;\n\n if (graphic.parent) {\n const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n retrans = !!(scrollX || scrollY);\n if (retrans) {\n tempBounds = this.dirtyBounds.clone();\n // 变换dirtyBounds\n const m = graphic.globalTransMatrix.getInverse();\n this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(m);\n this.dirtyBounds.translate(-scrollX, -scrollY);\n }\n }\n\n if (this.useDirtyBounds && !(graphic.isContainer || isRectIntersect(graphic.AABBBounds, this.dirtyBounds, false))) {\n retrans && this.dirtyBounds.copy(tempBounds);\n return;\n }\n\n const skipDraw = drawContext.startAtId != null && graphic._uid !== drawContext.startAtId;\n if (graphic._uid === drawContext.startAtId) {\n drawContext.startAtId = null;\n }\n params && (params.skipDraw = skipDraw);\n if (skipDraw) {\n graphic.isContainer && renderer.draw(graphic, this.currentRenderService, drawContext, params);\n } else {\n renderer.draw(graphic, this.currentRenderService, drawContext, params);\n }\n\n retrans && this.dirtyBounds.copy(tempBounds);\n\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.afterDrawItem) {\n if (drawContribution.afterDrawItem(graphic, this.currentRenderService, drawContext, this)) {\n return;\n }\n }\n }\n }\n }\n // 根据type选择对应的render\n protected selectRenderByType(type?: string): IGraphicRender | null {\n console.warn('未知错误,不应该走到这里');\n return null;\n }\n // 根据type选择对应的render\n protected selectRenderByNumberType(type?: number): IGraphicRender | null {\n return this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);\n }\n\n protected clearScreen(renderService: IRenderService, context: IContext2d, drawContext: IDrawContext) {\n const { clear } = drawContext;\n if (clear) {\n const canvas = context.getCanvas();\n const { width = canvas.width, height = canvas.height } = drawContext;\n const x = 0;\n const y = 0;\n context.clearRect(x, y, width, height);\n const stage = renderService.drawParams?.stage;\n if (stage && (stage as any).backgroundImg && (stage as any).resources) {\n const res = (stage as any).resources.get(clear);\n if (res && res.state === 'success' && res.data) {\n context.drawImage(res.data, x, y, width, height);\n }\n } else {\n context.fillStyle = createColor(\n context,\n clear,\n {\n AABBBounds: { x1: x, y1: y, x2: x + width, y2: y + height }\n },\n 0,\n 0\n );\n context.fillRect(x, y, width, height);\n }\n }\n }\n\n afterDraw(renderService: IRenderService, drawParams: IDrawContext) {\n return;\n }\n}\n"]}
@@ -6,5 +6,6 @@ export declare class DefaultCanvasLineRender extends BaseRender<ILine> implement
6
6
  z: number;
7
7
  draw(line: ILine, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
8
8
  protected drawSegmentItem(context: IContext2d, cache: ISegPath2D, fill: boolean, stroke: boolean, fillOpacity: number, strokeOpacity: number, attribute: Partial<ILineGraphicAttribute>, defaultAttribute: Required<ILineGraphicAttribute> | Partial<ILineGraphicAttribute>[], clipRange: number, clipRangeByDimension: IClipRangeByDimensionType, offsetX: number, offsetY: number, line: ILine, fillCb?: (ctx: IContext2d, lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute | IThemeAttribute[]) => boolean, strokeCb?: (ctx: IContext2d, lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute | IThemeAttribute[]) => boolean): boolean;
9
+ drawLinearLineHighPerformance(line: ILine, context: IContext2d, fill: boolean, stroke: boolean, fillOpacity: number, strokeOpacity: number, offsetX: number, offsetY: number, lineAttribute: Required<ILineGraphicAttribute>, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
9
10
  drawShape(line: ILine, context: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
10
11
  }
@@ -67,14 +67,30 @@ let DefaultCanvasLineRender = class extends BaseRender {
67
67
  }
68
68
  return !1;
69
69
  }
70
+ drawLinearLineHighPerformance(line, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, lineAttribute, drawContext, params, fillCb, strokeCb) {
71
+ var _a;
72
+ context.beginPath();
73
+ const z = null !== (_a = this.z) && void 0 !== _a ? _a : 0, {points: points} = line.attribute, startP = points[0];
74
+ context.moveTo(startP.x, startP.y, z);
75
+ for (let i = 1; i < points.length; i++) {
76
+ const p = points[i];
77
+ context.lineTo(p.x, p.y, z);
78
+ }
79
+ context.setShadowBlendStyle && context.setShadowBlendStyle(line, line.attribute, lineAttribute);
80
+ const {x: originX = 0, x: originY = 0} = line.attribute;
81
+ !1 !== fill && (fillCb ? fillCb(context, line.attribute, lineAttribute) : fillOpacity && (context.setCommonStyle(line, line.attribute, originX - offsetX, originY - offsetY, lineAttribute),
82
+ context.fill())), !1 !== stroke && (strokeCb ? strokeCb(context, line.attribute, lineAttribute) : strokeOpacity && (context.setStrokeStyle(line, line.attribute, originX - offsetX, originY - offsetY, lineAttribute),
83
+ context.stroke()));
84
+ }
70
85
  drawShape(line, context, x, y, drawContext, params, fillCb, strokeCb) {
71
- const lineAttribute = getTheme(line, null == params ? void 0 : params.theme).line, {fill: fill = lineAttribute.fill, stroke: stroke = lineAttribute.stroke, fillOpacity: fillOpacity = lineAttribute.fillOpacity, strokeOpacity: strokeOpacity = lineAttribute.strokeOpacity} = line.attribute;
86
+ const lineAttribute = getTheme(line, null == params ? void 0 : params.theme).line, {fill: fill = lineAttribute.fill, stroke: stroke = lineAttribute.stroke, fillOpacity: fillOpacity = lineAttribute.fillOpacity, strokeOpacity: strokeOpacity = lineAttribute.strokeOpacity, segments: segments, points: points, closePath: closePath} = line.attribute;
72
87
  if (!this.valid(line, lineAttribute, fillCb, strokeCb)) return;
88
+ let {curveType: curveType = lineAttribute.curveType} = line.attribute;
89
+ closePath && "linear" === curveType && (curveType = "linearClosed");
90
+ const {clipRange: clipRange = lineAttribute.clipRange, clipRangeByDimension: clipRangeByDimension = lineAttribute.clipRangeByDimension} = line.attribute;
91
+ if (1 === clipRange && !segments && !points.some((p => !1 === p.defined)) && "linear" === curveType) return this.drawLinearLineHighPerformance(line, context, !!fill, !!stroke, fillOpacity, strokeOpacity, x, y, lineAttribute, drawContext, params, fillCb, strokeCb);
73
92
  if (line.shouldUpdateShape()) {
74
- const {points: points, segments: segments, closePath: closePath} = line.attribute;
75
- let {curveType: curveType = lineAttribute.curveType} = line.attribute;
76
- closePath && "linear" === curveType && (curveType = "linearClosed");
77
- const _points = points;
93
+ const {points: points, segments: segments} = line.attribute, _points = points;
78
94
  if (segments && segments.length) {
79
95
  let startPoint, lastSeg;
80
96
  if (line.cache = segments.map(((seg, index) => {
@@ -112,7 +128,6 @@ let DefaultCanvasLineRender = class extends BaseRender {
112
128
  }
113
129
  line.clearUpdateShapeTag();
114
130
  }
115
- const {clipRange: clipRange = lineAttribute.clipRange, clipRangeByDimension: clipRangeByDimension = lineAttribute.clipRangeByDimension} = line.attribute;
116
131
  if (Array.isArray(line.cache)) {
117
132
  const segments = line.attribute.segments.filter((item => item.points.length));
118
133
  if (1 === segments[0].points.length && segments.shift(), 1 === clipRange) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/line-render.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAe5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAOjD,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,UAAiB;IAAvD;;QAEL,eAAU,GAAW,gBAAgB,CAAC;IA4VxC,CAAC;IAzVC,IAAI,CAAC,IAAW,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC3G,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,IAAI,CAAC;QACzD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IAiBS,eAAe,CACvB,OAAmB,EACnB,KAAiB,EACjB,IAAa,EACb,MAAe,EACf,WAAmB,EACnB,aAAqB,EACrB,SAAyC,EACzC,gBAAoF,EACpF,SAAiB,EACjB,oBAA+C,EAC/C,OAAe,EACf,OAAe,EACf,IAAW,EACX,MAIY,EACZ,QAIY;;QAEZ,IA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AAC;CACF,CAAA;AA9VY,uBAAuB;IADnC,UAAU,EAAE;GACA,uBAAuB,CA8VnC;SA9VY,uBAAuB","file":"line-render.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { min, isArray } from '@visactor/vutils';\nimport { injectable } from '../../../common/inversify-lite';\nimport type {\n IContext2d,\n ILine,\n ILineGraphicAttribute,\n IMarkAttribute,\n IGraphicAttribute,\n IThemeAttribute,\n IClipRangeByDimensionType,\n ISegPath2D,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { LINE_NUMBER_TYPE } from '../../../graphic/constants';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { BaseRender } from './base-render';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { drawSegments } from '../../../common/render-curve';\nimport { calcLineCache } from '../../../common/segment';\n\n/**\n * 默认的基于canvas的line渲染器\n * 单例\n */\n@injectable()\nexport class DefaultCanvasLineRender extends BaseRender<ILine> implements IGraphicRender {\n type: 'line';\n numberType: number = LINE_NUMBER_TYPE;\n declare z: number;\n\n draw(line: ILine, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const lineAttribute = getTheme(line, params?.theme).line;\n this._draw(line, lineAttribute, false, drawContext, params);\n }\n\n /**\n * 绘制segment\n * @param context\n * @param cache\n * @param fill\n * @param stroke\n * @param attribute\n * @param defaultAttribute\n * @param clipRange\n * @param offsetX\n * @param offsetY\n * @param fillCb\n * @param strokeCb\n * @returns 返回true代表跳过后续绘制\n */\n protected drawSegmentItem(\n context: IContext2d,\n cache: ISegPath2D,\n fill: boolean,\n stroke: boolean,\n fillOpacity: number,\n strokeOpacity: number,\n attribute: Partial<ILineGraphicAttribute>,\n defaultAttribute: Required<ILineGraphicAttribute> | Partial<ILineGraphicAttribute>[],\n clipRange: number,\n clipRangeByDimension: IClipRangeByDimensionType,\n offsetX: number,\n offsetY: number,\n line: ILine,\n fillCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute | IThemeAttribute[]\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute | IThemeAttribute[]\n ) => boolean\n ): boolean {\n if (!cache) {\n return;\n }\n context.beginPath();\n\n const z = this.z ?? 0;\n\n drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {\n offsetX,\n offsetY,\n offsetZ: z\n });\n\n // 如果是一根线,且是Closed,并且没有defined为false的点,需要close\n if (\n line.cache &&\n !isArray(line.cache) &&\n line.cache.curves.every(c => c.defined) &&\n line.attribute.curveType &&\n line.attribute.curveType.includes('Closed')\n ) {\n context.closePath();\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(line, attribute, defaultAttribute);\n\n const { x: originX = 0, x: originY = 0 } = attribute;\n const ret: boolean = false;\n if (fill !== false) {\n if (fillCb) {\n fillCb(context, attribute, defaultAttribute);\n } else if (fillOpacity) {\n context.setCommonStyle(line, attribute, originX - offsetX, originY - offsetY, defaultAttribute);\n context.fill();\n }\n }\n if (stroke !== false) {\n if (strokeCb) {\n strokeCb(context, attribute, defaultAttribute);\n } else if (strokeOpacity) {\n context.setStrokeStyle(line, attribute, originX - offsetX, originY - offsetY, defaultAttribute);\n context.stroke();\n }\n }\n\n // 绘制connect区域\n let { connectedType, connectedX, connectedY, connectedStyle } = attribute;\n if (isArray(defaultAttribute)) {\n connectedType = connectedType ?? defaultAttribute[0].connectedType ?? defaultAttribute[1].connectedType;\n connectedX = connectedX ?? defaultAttribute[0].connectedX ?? defaultAttribute[1].connectedX;\n connectedY = connectedY ?? defaultAttribute[0].connectedY ?? defaultAttribute[1].connectedY;\n connectedStyle = connectedStyle ?? defaultAttribute[0].connectedStyle ?? defaultAttribute[1].connectedStyle;\n } else {\n connectedType = connectedType ?? defaultAttribute.connectedType;\n connectedX = connectedX ?? defaultAttribute.connectedX;\n connectedY = connectedY ?? defaultAttribute.connectedY;\n connectedStyle = connectedStyle ?? defaultAttribute.connectedStyle;\n }\n // 如果有非法值就是none\n if (connectedType !== 'connect' && connectedType !== 'zero') {\n connectedType = 'none';\n }\n if (connectedType !== 'none') {\n context.beginPath();\n drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {\n offsetX,\n offsetY,\n offsetZ: z,\n drawConnect: true,\n mode: connectedType,\n zeroX: connectedX,\n zeroY: connectedY\n });\n\n const da = [];\n if (isArray(defaultAttribute)) {\n defaultAttribute.forEach(i => da.push(i));\n } else {\n da.push(defaultAttribute);\n }\n da.push(attribute);\n\n if (fill !== false) {\n if (fillCb) {\n fillCb(context, attribute, defaultAttribute);\n } else if (fillOpacity) {\n context.setCommonStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);\n context.fill();\n }\n }\n if (stroke !== false) {\n if (strokeCb) {\n strokeCb(context, attribute, defaultAttribute);\n } else if (strokeOpacity) {\n context.setStrokeStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);\n context.stroke();\n }\n }\n }\n return !!ret;\n }\n\n drawShape(\n line: ILine,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const lineAttribute = graphicService.themeService.getCurrentTheme().lineAttribute;\n const lineAttribute = getTheme(line, params?.theme).line;\n\n const {\n fill = lineAttribute.fill,\n stroke = lineAttribute.stroke,\n fillOpacity = lineAttribute.fillOpacity,\n strokeOpacity = lineAttribute.strokeOpacity\n } = line.attribute;\n\n const data = this.valid(line, lineAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n // const { fVisible, sVisible, doFill, doStroke } = data;\n\n // 更新cache\n if (line.shouldUpdateShape()) {\n const { points, segments, closePath } = line.attribute;\n let { curveType = lineAttribute.curveType } = line.attribute;\n if (closePath && curveType === 'linear') {\n curveType = 'linearClosed';\n }\n const _points = points;\n if (segments && segments.length) {\n let startPoint: IPointLike;\n let lastSeg: { endX: number; endY: number; curves: Array<{ defined: boolean }> };\n line.cache = segments\n .map((seg, index) => {\n if (seg.points.length <= 1) {\n // 第一个点的话,直接设置lastTopSeg\n if (index === 0) {\n seg.points[0] &&\n (lastSeg = {\n endX: seg.points[0].x,\n endY: seg.points[0].y,\n curves: [{ defined: seg.points[0].defined !== false }]\n });\n return null;\n }\n }\n // 添加上一个segment结束的点作为这个segment的起始点\n if (index === 1) {\n startPoint = {\n x: lastSeg.endX,\n y: lastSeg.endY,\n defined: lastSeg.curves[lastSeg.curves.length - 1].defined\n };\n } else if (index > 1) {\n startPoint.x = lastSeg.endX;\n startPoint.y = lastSeg.endY;\n startPoint.defined = lastSeg.curves[lastSeg.curves.length - 1].defined;\n }\n const data = calcLineCache(seg.points, curveType, {\n startPoint\n });\n lastSeg = data;\n return data;\n })\n .filter(item => !!item);\n\n // 如果lineClosed,那就绘制到第一个点\n if (curveType === 'linearClosed') {\n let startP: IPointLike;\n for (let i = 0; i < line.cache.length; i++) {\n const cacheItem = line.cache[i];\n for (let i = 0; i < cacheItem.curves.length; i++) {\n if (cacheItem.curves[i].defined) {\n startP = cacheItem.curves[i].p0;\n break;\n }\n }\n if (startP) {\n break;\n }\n }\n line.cache[line.cache.length - 1] && line.cache[line.cache.length - 1].lineTo(startP.x, startP.y, true);\n }\n } else if (points && points.length) {\n line.cache = calcLineCache(_points, curveType);\n } else {\n line.cache = null;\n line.clearUpdateShapeTag();\n return;\n }\n line.clearUpdateShapeTag();\n }\n\n const { clipRange = lineAttribute.clipRange, clipRangeByDimension = lineAttribute.clipRangeByDimension } =\n line.attribute;\n\n if (Array.isArray(line.cache)) {\n const segments = line.attribute.segments.filter(item => item.points.length);\n // 如果第一个seg只有一个点,那么shift出去\n if (segments[0].points.length === 1) {\n segments.shift();\n }\n if (clipRange === 1) {\n let skip = false;\n // 性能优化,不需要clip的线段不需要计算长度\n line.cache.forEach((cache, index) => {\n if (skip) {\n return;\n }\n skip = this.drawSegmentItem(\n context,\n cache,\n !!fill,\n !!stroke,\n fillOpacity,\n strokeOpacity,\n segments[index],\n [lineAttribute, line.attribute],\n clipRange,\n clipRangeByDimension,\n x,\n y,\n line,\n fillCb,\n strokeCb\n );\n });\n } else {\n // 如果是segments的话,每个clipRange需要重新计算\n // 整个线段的总长度\n const totalLength = line.cache.reduce((l, c) => l + c.getLength(), 0);\n // 总需要绘制的长度\n const totalDrawLength = clipRange * totalLength;\n // 直到上次绘制的长度\n let drawedLengthUntilLast = 0;\n let skip = false;\n line.cache.forEach((cache, index) => {\n if (skip) {\n return;\n }\n const curSegLength = cache.getLength();\n const _cr = (totalDrawLength - drawedLengthUntilLast) / curSegLength;\n drawedLengthUntilLast += curSegLength;\n if (_cr > 0) {\n skip = this.drawSegmentItem(\n context,\n cache,\n !!fill,\n !!stroke,\n fillOpacity,\n strokeOpacity,\n segments[index],\n [lineAttribute, line.attribute],\n min(_cr, 1),\n clipRangeByDimension,\n x,\n y,\n line,\n fillCb,\n strokeCb\n );\n }\n });\n }\n } else {\n this.drawSegmentItem(\n context,\n line.cache as ISegPath2D,\n !!fill,\n !!stroke,\n fillOpacity,\n strokeOpacity,\n line.attribute,\n lineAttribute,\n clipRange,\n clipRangeByDimension,\n x,\n y,\n line,\n fillCb,\n strokeCb\n );\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/line-render.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAA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AW,EACX,aAAa,EACb,QAAQ,CAAC,KAAK,CAAC,EACf,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,EAC/B,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EACX,oBAAoB,EACpB,CAAC,EACD,CAAC,EACD,IAAI,EACJ,MAAM,EACN,QAAQ,CACT,CAAC;qBACH;gBACH,CAAC,CAAC,CAAC;aACJ;SACF;aAAM;YACL,IAAI,CAAC,eAAe,CAClB,OAAO,EACP,IAAI,CAAC,KAAmB,EACxB,CAAC,CAAC,IAAI,EACN,CAAC,CAAC,MAAM,EACR,WAAW,EACX,aAAa,EACb,IAAI,CAAC,SAAS,EACd,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,CAAC,EACD,CAAC,EACD,IAAI,EACJ,MAAM,EACN,QAAQ,CACT,CAAC;SACH;IACH,CAAC;CACF,CAAA;AA/aY,uBAAuB;IADnC,UAAU,EAAE;GACA,uBAAuB,CA+anC;SA/aY,uBAAuB","file":"line-render.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { min, isArray } from '@visactor/vutils';\nimport { injectable } from '../../../common/inversify-lite';\nimport type {\n IContext2d,\n ILine,\n ILineGraphicAttribute,\n IMarkAttribute,\n IGraphicAttribute,\n IThemeAttribute,\n IClipRangeByDimensionType,\n ISegPath2D,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { LINE_NUMBER_TYPE } from '../../../graphic/constants';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { BaseRender } from './base-render';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { drawSegments } from '../../../common/render-curve';\nimport { calcLineCache } from '../../../common/segment';\n\n/**\n * 默认的基于canvas的line渲染器\n * 单例\n */\n@injectable()\nexport class DefaultCanvasLineRender extends BaseRender<ILine> implements IGraphicRender {\n type: 'line';\n numberType: number = LINE_NUMBER_TYPE;\n declare z: number;\n\n draw(line: ILine, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const lineAttribute = getTheme(line, params?.theme).line;\n this._draw(line, lineAttribute, false, drawContext, params);\n }\n\n /**\n * 绘制segment\n * @param context\n * @param cache\n * @param fill\n * @param stroke\n * @param attribute\n * @param defaultAttribute\n * @param clipRange\n * @param offsetX\n * @param offsetY\n * @param fillCb\n * @param strokeCb\n * @returns 返回true代表跳过后续绘制\n */\n protected drawSegmentItem(\n context: IContext2d,\n cache: ISegPath2D,\n fill: boolean,\n stroke: boolean,\n fillOpacity: number,\n strokeOpacity: number,\n attribute: Partial<ILineGraphicAttribute>,\n defaultAttribute: Required<ILineGraphicAttribute> | Partial<ILineGraphicAttribute>[],\n clipRange: number,\n clipRangeByDimension: IClipRangeByDimensionType,\n offsetX: number,\n offsetY: number,\n line: ILine,\n fillCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute | IThemeAttribute[]\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute | IThemeAttribute[]\n ) => boolean\n ): boolean {\n if (!cache) {\n return;\n }\n context.beginPath();\n\n const z = this.z ?? 0;\n\n drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {\n offsetX,\n offsetY,\n offsetZ: z\n });\n\n // 如果是一根线,且是Closed,并且没有defined为false的点,需要close\n if (\n line.cache &&\n !isArray(line.cache) &&\n line.cache.curves.every(c => c.defined) &&\n line.attribute.curveType &&\n line.attribute.curveType.includes('Closed')\n ) {\n context.closePath();\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(line, attribute, defaultAttribute);\n\n const { x: originX = 0, x: originY = 0 } = attribute;\n const ret: boolean = false;\n if (fill !== false) {\n if (fillCb) {\n fillCb(context, attribute, defaultAttribute);\n } else if (fillOpacity) {\n context.setCommonStyle(line, attribute, originX - offsetX, originY - offsetY, defaultAttribute);\n context.fill();\n }\n }\n if (stroke !== false) {\n if (strokeCb) {\n strokeCb(context, attribute, defaultAttribute);\n } else if (strokeOpacity) {\n context.setStrokeStyle(line, attribute, originX - offsetX, originY - offsetY, defaultAttribute);\n context.stroke();\n }\n }\n\n // 绘制connect区域\n let { connectedType, connectedX, connectedY, connectedStyle } = attribute;\n if (isArray(defaultAttribute)) {\n connectedType = connectedType ?? defaultAttribute[0].connectedType ?? defaultAttribute[1].connectedType;\n connectedX = connectedX ?? defaultAttribute[0].connectedX ?? defaultAttribute[1].connectedX;\n connectedY = connectedY ?? defaultAttribute[0].connectedY ?? defaultAttribute[1].connectedY;\n connectedStyle = connectedStyle ?? defaultAttribute[0].connectedStyle ?? defaultAttribute[1].connectedStyle;\n } else {\n connectedType = connectedType ?? defaultAttribute.connectedType;\n connectedX = connectedX ?? defaultAttribute.connectedX;\n connectedY = connectedY ?? defaultAttribute.connectedY;\n connectedStyle = connectedStyle ?? defaultAttribute.connectedStyle;\n }\n // 如果有非法值就是none\n if (connectedType !== 'connect' && connectedType !== 'zero') {\n connectedType = 'none';\n }\n if (connectedType !== 'none') {\n context.beginPath();\n drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {\n offsetX,\n offsetY,\n offsetZ: z,\n drawConnect: true,\n mode: connectedType,\n zeroX: connectedX,\n zeroY: connectedY\n });\n\n const da = [];\n if (isArray(defaultAttribute)) {\n defaultAttribute.forEach(i => da.push(i));\n } else {\n da.push(defaultAttribute);\n }\n da.push(attribute);\n\n if (fill !== false) {\n if (fillCb) {\n fillCb(context, attribute, defaultAttribute);\n } else if (fillOpacity) {\n context.setCommonStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);\n context.fill();\n }\n }\n if (stroke !== false) {\n if (strokeCb) {\n strokeCb(context, attribute, defaultAttribute);\n } else if (strokeOpacity) {\n context.setStrokeStyle(line, connectedStyle, originX - offsetX, originY - offsetY, da);\n context.stroke();\n }\n }\n }\n return !!ret;\n }\n\n // 高性能绘制linear line,不用拆分\n drawLinearLineHighPerformance(\n line: ILine,\n context: IContext2d,\n fill: boolean,\n stroke: boolean,\n fillOpacity: number,\n strokeOpacity: number,\n offsetX: number,\n offsetY: number,\n lineAttribute: Required<ILineGraphicAttribute>,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n context.beginPath();\n\n const z = this.z ?? 0;\n const { points } = line.attribute;\n const startP = points[0];\n\n context.moveTo(startP.x, startP.y, z);\n for (let i = 1; i < points.length; i++) {\n const p = points[i];\n context.lineTo(p.x, p.y, z);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(line, line.attribute, lineAttribute);\n\n const { x: originX = 0, x: originY = 0 } = line.attribute;\n if (fill !== false) {\n if (fillCb) {\n fillCb(context, line.attribute, lineAttribute);\n } else if (fillOpacity) {\n context.setCommonStyle(line, line.attribute, originX - offsetX, originY - offsetY, lineAttribute);\n context.fill();\n }\n }\n if (stroke !== false) {\n if (strokeCb) {\n strokeCb(context, line.attribute, lineAttribute);\n } else if (strokeOpacity) {\n context.setStrokeStyle(line, line.attribute, originX - offsetX, originY - offsetY, lineAttribute);\n context.stroke();\n }\n }\n }\n\n drawShape(\n line: ILine,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const lineAttribute = graphicService.themeService.getCurrentTheme().lineAttribute;\n const lineAttribute = getTheme(line, params?.theme).line;\n\n const {\n fill = lineAttribute.fill,\n stroke = lineAttribute.stroke,\n fillOpacity = lineAttribute.fillOpacity,\n strokeOpacity = lineAttribute.strokeOpacity,\n segments,\n points,\n closePath\n } = line.attribute;\n\n const data = this.valid(line, lineAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n\n let { curveType = lineAttribute.curveType } = line.attribute;\n if (closePath && curveType === 'linear') {\n curveType = 'linearClosed';\n }\n\n const { clipRange = lineAttribute.clipRange, clipRangeByDimension = lineAttribute.clipRangeByDimension } =\n line.attribute;\n\n if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {\n return this.drawLinearLineHighPerformance(\n line,\n context,\n !!fill,\n !!stroke,\n fillOpacity,\n strokeOpacity,\n x,\n y,\n lineAttribute,\n drawContext,\n params,\n fillCb,\n strokeCb\n );\n }\n // const { fVisible, sVisible, doFill, doStroke } = data;\n\n // 更新cache\n if (line.shouldUpdateShape()) {\n const { points, segments } = line.attribute;\n\n const _points = points;\n if (segments && segments.length) {\n let startPoint: IPointLike;\n let lastSeg: { endX: number; endY: number; curves: Array<{ defined: boolean }> };\n line.cache = segments\n .map((seg, index) => {\n if (seg.points.length <= 1) {\n // 第一个点的话,直接设置lastTopSeg\n if (index === 0) {\n seg.points[0] &&\n (lastSeg = {\n endX: seg.points[0].x,\n endY: seg.points[0].y,\n curves: [{ defined: seg.points[0].defined !== false }]\n });\n return null;\n }\n }\n // 添加上一个segment结束的点作为这个segment的起始点\n if (index === 1) {\n startPoint = {\n x: lastSeg.endX,\n y: lastSeg.endY,\n defined: lastSeg.curves[lastSeg.curves.length - 1].defined\n };\n } else if (index > 1) {\n startPoint.x = lastSeg.endX;\n startPoint.y = lastSeg.endY;\n startPoint.defined = lastSeg.curves[lastSeg.curves.length - 1].defined;\n }\n const data = calcLineCache(seg.points, curveType, {\n startPoint\n });\n lastSeg = data;\n return data;\n })\n .filter(item => !!item);\n\n // 如果lineClosed,那就绘制到第一个点\n if (curveType === 'linearClosed') {\n let startP: IPointLike;\n for (let i = 0; i < line.cache.length; i++) {\n const cacheItem = line.cache[i];\n for (let i = 0; i < cacheItem.curves.length; i++) {\n if (cacheItem.curves[i].defined) {\n startP = cacheItem.curves[i].p0;\n break;\n }\n }\n if (startP) {\n break;\n }\n }\n line.cache[line.cache.length - 1] && line.cache[line.cache.length - 1].lineTo(startP.x, startP.y, true);\n }\n } else if (points && points.length) {\n line.cache = calcLineCache(_points, curveType);\n } else {\n line.cache = null;\n line.clearUpdateShapeTag();\n return;\n }\n line.clearUpdateShapeTag();\n }\n\n if (Array.isArray(line.cache)) {\n const segments = line.attribute.segments.filter(item => item.points.length);\n // 如果第一个seg只有一个点,那么shift出去\n if (segments[0].points.length === 1) {\n segments.shift();\n }\n if (clipRange === 1) {\n let skip = false;\n // 性能优化,不需要clip的线段不需要计算长度\n line.cache.forEach((cache, index) => {\n if (skip) {\n return;\n }\n skip = this.drawSegmentItem(\n context,\n cache,\n !!fill,\n !!stroke,\n fillOpacity,\n strokeOpacity,\n segments[index],\n [lineAttribute, line.attribute],\n clipRange,\n clipRangeByDimension,\n x,\n y,\n line,\n fillCb,\n strokeCb\n );\n });\n } else {\n // 如果是segments的话,每个clipRange需要重新计算\n // 整个线段的总长度\n const totalLength = line.cache.reduce((l, c) => l + c.getLength(), 0);\n // 总需要绘制的长度\n const totalDrawLength = clipRange * totalLength;\n // 直到上次绘制的长度\n let drawedLengthUntilLast = 0;\n let skip = false;\n line.cache.forEach((cache, index) => {\n if (skip) {\n return;\n }\n const curSegLength = cache.getLength();\n const _cr = (totalDrawLength - drawedLengthUntilLast) / curSegLength;\n drawedLengthUntilLast += curSegLength;\n if (_cr > 0) {\n skip = this.drawSegmentItem(\n context,\n cache,\n !!fill,\n !!stroke,\n fillOpacity,\n strokeOpacity,\n segments[index],\n [lineAttribute, line.attribute],\n min(_cr, 1),\n clipRangeByDimension,\n x,\n y,\n line,\n fillCb,\n strokeCb\n );\n }\n });\n }\n } else {\n this.drawSegmentItem(\n context,\n line.cache as ISegPath2D,\n !!fill,\n !!stroke,\n fillOpacity,\n strokeOpacity,\n line.attribute,\n lineAttribute,\n clipRange,\n clipRangeByDimension,\n x,\n y,\n line,\n fillCb,\n strokeCb\n );\n }\n }\n}\n"]}
@@ -28,6 +28,8 @@ import { matrixAllocate } from "../../../allocator/matrix-allocate";
28
28
 
29
29
  import { max } from "@visactor/vutils";
30
30
 
31
+ import { calculateLineHeight } from "../../../common/utils";
32
+
31
33
  let DefaultCanvasTextRender = class extends BaseRender {
32
34
  constructor(textRenderContribitions) {
33
35
  super(), this.textRenderContribitions = textRenderContribitions, this.numberType = TEXT_NUMBER_TYPE,
@@ -35,14 +37,14 @@ let DefaultCanvasTextRender = class extends BaseRender {
35
37
  }
36
38
  drawShape(text, context, x, y, drawContext, params, fillCb, strokeCb) {
37
39
  var _a, _b, _c;
38
- const textAttribute = getTheme(text, null == params ? void 0 : params.theme).text, {text: str, fill: fill = textAttribute.fill, stroke: stroke = textAttribute.stroke, fillOpacity: fillOpacity = textAttribute.fillOpacity, strokeOpacity: strokeOpacity = textAttribute.strokeOpacity, opacity: opacity = textAttribute.opacity, lineWidth: lineWidth = textAttribute.lineWidth, visible: visible = textAttribute.visible, underline: underline = textAttribute.underline, lineThrough: lineThrough = textAttribute.lineThrough, keepDirIn3d: keepDirIn3d = textAttribute.keepDirIn3d, direction: direction = textAttribute.direction, fontSize: fontSize = textAttribute.fontSize, verticalMode: verticalMode = textAttribute.verticalMode, x: originX = textAttribute.x, y: originY = textAttribute.y} = text.attribute;
40
+ const textAttribute = getTheme(text, null == params ? void 0 : params.theme).text, {text: str, underline: underline = textAttribute.underline, lineThrough: lineThrough = textAttribute.lineThrough, keepDirIn3d: keepDirIn3d = textAttribute.keepDirIn3d, direction: direction = textAttribute.direction, fontSize: fontSize = textAttribute.fontSize, verticalMode: verticalMode = textAttribute.verticalMode, x: originX = textAttribute.x, y: originY = textAttribute.y} = text.attribute;
39
41
  let {textAlign: textAlign = textAttribute.textAlign, textBaseline: textBaseline = textAttribute.textBaseline} = text.attribute;
40
42
  if (!verticalMode && "vertical" === direction) {
41
43
  const t = textAlign;
42
44
  textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left",
43
45
  textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
44
46
  }
45
- const lineHeight = null !== (_c = text.attribute.lineHeight) && void 0 !== _c ? _c : fontSize, data = this.valid(text, textAttribute, fillCb, strokeCb);
47
+ const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize, data = this.valid(text, textAttribute, fillCb, strokeCb);
46
48
  if (!data) return;
47
49
  const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data, transform3dMatrixToContextMatrix = !keepDirIn3d, z = this.z || 0;
48
50
  context.beginPath(), context.setShadowBlendStyle && context.setShadowBlendStyle(text, text.attribute, textAttribute),
@@ -76,6 +78,7 @@ let DefaultCanvasTextRender = class extends BaseRender {
76
78
  this.drawMultiUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + x, (line.topOffset || 0) + yOffset + y, z, line.width, textAttribute, context);
77
79
  }))));
78
80
  } else {
81
+ text.tryUpdateAABBBounds();
79
82
  const cache = text.cache, {verticalList: verticalList} = cache;
80
83
  context.textAlign = "left", context.textBaseline = "top";
81
84
  const totalHeight = lineHeight * verticalList.length;
@@ -97,15 +100,16 @@ let DefaultCanvasTextRender = class extends BaseRender {
97
100
  currentOffsetY += width;
98
101
  }));
99
102
  }));
103
+ } else if ("horizontal" === direction) {
104
+ context.setTextStyle(text.attribute, textAttribute, z);
105
+ const t = text.clipedText;
106
+ let dy = 0;
107
+ lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)),
108
+ drawText(t, 0, dy, 0);
100
109
  } else {
110
+ text.tryUpdateAABBBounds();
101
111
  const cache = text.cache;
102
- if ("horizontal" === direction) {
103
- context.setTextStyle(text.attribute, textAttribute, z);
104
- const t = text.clipedText;
105
- let dy = 0;
106
- lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)),
107
- drawText(t, 0, dy, 0);
108
- } else if (cache) {
112
+ if (cache) {
109
113
  context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
110
114
  const {verticalList: verticalList} = cache;
111
115
  let offsetY = 0;