@visactor/vrender-core 1.0.44 → 1.0.45

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 (120) hide show
  1. package/cjs/canvas/constants.js +2 -1
  2. package/cjs/color-string/index.js +1 -2
  3. package/cjs/common/diff.js +2 -1
  4. package/cjs/common/event-transformer.js +1 -2
  5. package/cjs/common/render-area.js +1 -1
  6. package/cjs/common/render-command-list.js +1 -1
  7. package/cjs/common/render-curve.js +1 -1
  8. package/cjs/common/render-utils.js +1 -1
  9. package/cjs/common/seg-context.js +1 -1
  10. package/cjs/common/simplify.js +2 -1
  11. package/cjs/common/sort.js +1 -1
  12. package/cjs/common/split-path.js +1 -1
  13. package/cjs/common/store.js +1 -1
  14. package/cjs/common/text.js +1 -1
  15. package/cjs/common/utils.js +1 -1
  16. package/cjs/core/constants.js +1 -1
  17. package/cjs/core/core-modules.js +1 -1
  18. package/cjs/core/global-module.js +0 -2
  19. package/cjs/core/global.js +1 -1
  20. package/cjs/core/graphic-utils.js +1 -1
  21. package/cjs/core/index.js +1 -1
  22. package/cjs/core/layer-service.js +1 -2
  23. package/cjs/core/layer.d.ts +1 -1
  24. package/cjs/core/layer.js +1 -1
  25. package/cjs/core/layer.js.map +1 -1
  26. package/cjs/core/light.js +1 -1
  27. package/cjs/core/stage.d.ts +5 -3
  28. package/cjs/core/stage.js +17 -5
  29. package/cjs/core/stage.js.map +1 -1
  30. package/cjs/core/window.js +1 -1
  31. package/cjs/graphic/config.js +7 -1
  32. package/cjs/graphic/config.js.map +1 -1
  33. package/cjs/graphic/graphic.js +5 -2
  34. package/cjs/graphic/graphic.js.map +1 -1
  35. package/cjs/graphic/image.d.ts +1 -0
  36. package/cjs/graphic/image.js +2 -1
  37. package/cjs/graphic/image.js.map +1 -1
  38. package/cjs/interface/graphic/image.d.ts +7 -1
  39. package/cjs/interface/graphic/image.js.map +1 -1
  40. package/cjs/interface/graphic.d.ts +14 -2
  41. package/cjs/interface/graphic.js.map +1 -1
  42. package/cjs/interface/layer.d.ts +3 -2
  43. package/cjs/interface/layer.js.map +1 -1
  44. package/cjs/interface/render.d.ts +1 -1
  45. package/cjs/interface/render.js.map +1 -1
  46. package/cjs/interface/stage.d.ts +3 -2
  47. package/cjs/interface/stage.js.map +1 -1
  48. package/cjs/render/contributions/render/contributions/base-contribution-render.d.ts +27 -9
  49. package/cjs/render/contributions/render/contributions/base-contribution-render.js +147 -34
  50. package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  51. package/cjs/render/contributions/render/contributions/group-contribution-render.js +8 -6
  52. package/cjs/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  53. package/cjs/render/contributions/render/contributions/text-contribution-render.js +20 -17
  54. package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  55. package/cjs/render/contributions/render/draw-contribution.js +16 -5
  56. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  57. package/cjs/render/contributions/render/image-render.d.ts +14 -1
  58. package/cjs/render/contributions/render/image-render.js +99 -20
  59. package/cjs/render/contributions/render/image-render.js.map +1 -1
  60. package/dist/index.es.js +414 -114
  61. package/es/canvas/constants.js +2 -1
  62. package/es/color-string/index.js +1 -2
  63. package/es/common/diff.js +2 -1
  64. package/es/common/event-transformer.js +1 -2
  65. package/es/common/render-area.js +1 -1
  66. package/es/common/render-command-list.js +1 -1
  67. package/es/common/render-curve.js +1 -1
  68. package/es/common/render-utils.js +1 -1
  69. package/es/common/seg-context.js +1 -1
  70. package/es/common/simplify.js +2 -1
  71. package/es/common/sort.js +1 -1
  72. package/es/common/split-path.js +1 -1
  73. package/es/common/store.js +1 -1
  74. package/es/common/text.js +1 -1
  75. package/es/common/utils.js +1 -1
  76. package/es/core/constants.js +1 -1
  77. package/es/core/core-modules.js +1 -1
  78. package/es/core/global-module.js +0 -2
  79. package/es/core/global.js +1 -1
  80. package/es/core/graphic-utils.js +1 -1
  81. package/es/core/index.js +1 -1
  82. package/es/core/layer-service.js +1 -2
  83. package/es/core/layer.d.ts +1 -1
  84. package/es/core/layer.js +1 -1
  85. package/es/core/layer.js.map +1 -1
  86. package/es/core/light.js +1 -1
  87. package/es/core/stage.d.ts +5 -3
  88. package/es/core/stage.js +17 -6
  89. package/es/core/stage.js.map +1 -1
  90. package/es/core/window.js +1 -1
  91. package/es/graphic/config.js +7 -1
  92. package/es/graphic/config.js.map +1 -1
  93. package/es/graphic/graphic.js +4 -2
  94. package/es/graphic/graphic.js.map +1 -1
  95. package/es/graphic/image.d.ts +1 -0
  96. package/es/graphic/image.js +2 -1
  97. package/es/graphic/image.js.map +1 -1
  98. package/es/interface/graphic/image.d.ts +7 -1
  99. package/es/interface/graphic/image.js.map +1 -1
  100. package/es/interface/graphic.d.ts +14 -2
  101. package/es/interface/graphic.js.map +1 -1
  102. package/es/interface/layer.d.ts +3 -2
  103. package/es/interface/layer.js.map +1 -1
  104. package/es/interface/render.d.ts +1 -1
  105. package/es/interface/render.js.map +1 -1
  106. package/es/interface/stage.d.ts +3 -2
  107. package/es/interface/stage.js.map +1 -1
  108. package/es/render/contributions/render/contributions/base-contribution-render.d.ts +27 -9
  109. package/es/render/contributions/render/contributions/base-contribution-render.js +140 -33
  110. package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  111. package/es/render/contributions/render/contributions/group-contribution-render.js +9 -7
  112. package/es/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  113. package/es/render/contributions/render/contributions/text-contribution-render.js +20 -16
  114. package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  115. package/es/render/contributions/render/draw-contribution.js +17 -4
  116. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  117. package/es/render/contributions/render/image-render.d.ts +14 -1
  118. package/es/render/contributions/render/image-render.js +93 -18
  119. package/es/render/contributions/render/image-render.js.map +1 -1
  120. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/base-contribution-render.ts"],"names":[],"mappings":";;;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AA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IA4BpB,CAAC;IA3BC,SAAS,CACP,OAAiB,EACjB,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH,EACnH,OAAa;QAEb,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QACD,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO;SACR;QACD,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,EAAE;YACzB,OAAO,CAAC,OAAO,EAAE,CAAC;SACnB;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,sCAAsC,GAAG,IAAI,sCAAsC,EAAE,CAAC","file":"base-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IGraphic,\n IThemeAttribute,\n IBaseRenderContribution,\n IContributionProvider,\n IDrawContext,\n ISymbol,\n IPath,\n ISymbolGraphicAttribute\n} from '../../../../interface';\nimport type { IBounds } from '@visactor/vutils';\nimport { inject, injectable, named } from '../../../../common/inversify-lite';\nimport { getTheme } from '../../../../graphic/theme';\nimport { canvasAllocate } from '../../../../allocator/canvas-allocate';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { ContributionProvider } from '../../../../common/contribution-provider';\nimport { InteractiveSubRenderContribution } from './constants';\n\nexport class DefaultBaseBackgroundRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n const {\n background,\n backgroundOpacity = graphic.attribute.fillOpacity ?? graphicAttribute.backgroundOpacity,\n opacity = graphicAttribute.opacity,\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit,\n backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,\n backgroundScale = graphicAttribute.backgroundScale,\n backgroundOffsetX = graphicAttribute.backgroundOffsetX,\n backgroundOffsetY = graphicAttribute.backgroundOffsetY,\n backgroundClip = graphicAttribute.backgroundClip\n } = graphic.attribute;\n if (!background) {\n return;\n }\n\n if (graphic.backgroundImg && graphic.resources) {\n const res = graphic.resources.get(background as any);\n if (res.state !== 'success' || !res.data) {\n return;\n }\n\n context.save();\n\n if (graphic.parent && !graphic.transMatrix.onlyTranslate()) {\n const groupAttribute = getTheme(graphic.parent).group;\n const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = graphic.parent.attribute;\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n context.translate(scrollX, scrollY);\n }\n backgroundClip && context.clip();\n const b = graphic.AABBBounds;\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.globalAlpha = backgroundOpacity * opacity;\n this.doDrawImage(context, res.data, b, {\n backgroundMode,\n backgroundFit,\n backgroundKeepAspectRatio,\n backgroundScale,\n backgroundOffsetX,\n backgroundOffsetY\n });\n context.restore();\n if (!graphic.transMatrix.onlyTranslate()) {\n context.setTransformForCurrent();\n }\n } else {\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.globalAlpha = backgroundOpacity * opacity;\n context.fillStyle = background as string;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n\n protected doDrawImage(\n context: IContext2d,\n data: any,\n b: IBounds,\n params: {\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';\n backgroundFit: boolean;\n backgroundKeepAspectRatio: boolean;\n backgroundScale?: number;\n backgroundOffsetX?: number;\n backgroundOffsetY?: number;\n }\n ): void {\n const {\n backgroundMode,\n backgroundFit,\n backgroundKeepAspectRatio,\n backgroundScale = 1,\n backgroundOffsetX = 0,\n backgroundOffsetY = 0\n } = params;\n const targetW = b.width();\n const targetH = b.height();\n let w = targetW;\n let h = targetH;\n if (backgroundMode === 'no-repeat') {\n if (backgroundFit) {\n if (!backgroundKeepAspectRatio) {\n context.drawImage(data, b.x1, b.y1, b.width(), b.height());\n } else {\n const maxScale = Math.max(targetW / data.width, targetH / data.height);\n context.drawImage(\n data,\n b.x1 + backgroundOffsetX,\n b.y1 + backgroundOffsetY,\n data.width * maxScale * backgroundScale,\n data.height * maxScale * backgroundScale\n );\n }\n } else {\n const resW = data.width * backgroundScale;\n const resH = data.height * backgroundScale;\n context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);\n }\n } else {\n // debugger;\n // TODO 考虑缓存\n if (backgroundFit && backgroundMode !== 'repeat' && (data.width || data.height)) {\n const resW = data.width;\n const resH = data.height;\n\n if (backgroundMode === 'repeat-x') {\n // 高度适应\n const ratio = targetH / resH;\n w = resW * ratio;\n h = targetH;\n } else if (backgroundMode === 'repeat-y') {\n // 宽度适应\n const ratio = targetW / resW;\n h = resH * ratio;\n w = targetW;\n }\n\n const dpr = context.dpr;\n const canvas = canvasAllocate.allocate({ width: w, height: h, dpr });\n const ctx = canvas.getContext('2d');\n if (ctx) {\n ctx.inuse = true;\n ctx.clearMatrix();\n ctx.setTransformForCurrent(true);\n ctx.clearRect(0, 0, w, h);\n ctx.drawImage(data, 0, 0, w, h);\n data = canvas.nativeCanvas;\n }\n canvasAllocate.free(canvas);\n }\n const dpr = context.dpr;\n const pattern = context.createPattern(data, backgroundMode);\n pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0]));\n context.fillStyle = pattern;\n context.translate(b.x1, b.y1);\n context.fillRect(0, 0, targetW, targetH);\n context.translate(-b.x1, -b.y1);\n }\n }\n}\n\nexport const defaultBaseBackgroundRenderContribution = new DefaultBaseBackgroundRenderContribution();\n\nexport interface IInteractiveSubRenderContribution {\n render: (\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) => void;\n}\n\n@injectable()\nexport class DefaultBaseInteractiveRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n\n _subRenderContribitions?: IInteractiveSubRenderContribution[];\n constructor(\n @inject(ContributionProvider)\n @named(InteractiveSubRenderContribution)\n protected readonly subRenderContribitions: IContributionProvider<IInteractiveSubRenderContribution>\n ) {}\n\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n if (!this._subRenderContribitions) {\n this._subRenderContribitions = this.subRenderContribitions.getContributions();\n }\n this._subRenderContribitions.forEach(c => {\n c.render(\n graphic,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n graphicAttribute,\n drawContext,\n fillCb,\n strokeCb,\n options\n );\n });\n }\n}\n\nexport class DefaultBaseClipRenderBeforeContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IGraphicAttribute>,\n themeAttribute: IThemeAttribute,\n final?: boolean\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IGraphicAttribute>,\n themeAttribute: IThemeAttribute,\n final?: boolean\n ) => boolean,\n options?: any\n ) {\n const { clipConfig } = graphic.attribute;\n if (!clipConfig) {\n return;\n }\n const clipPath = graphic.getClipPath();\n if (!clipPath) {\n return;\n }\n const draw = !(fillCb || strokeCb);\n const b = graphic.AABBBounds;\n const width = (graphic.attribute as any).width ?? b.width();\n const height = (graphic.attribute as any).height ?? b.height();\n if (draw) {\n context.save();\n }\n context.beginPath();\n if (clipPath.draw(context, [width, height], x + width / 2, y + height / 2, 0) === false) {\n context.closePath();\n }\n if (fillCb) {\n fillCb(context, graphic.attribute, graphicAttribute, true);\n }\n\n if (draw) {\n context.clip();\n }\n }\n}\n\nexport const defaultBaseClipRenderBeforeContribution = new DefaultBaseClipRenderBeforeContribution();\nexport class DefaultBaseClipRenderAfterContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n const { clipConfig } = graphic.attribute;\n if (!clipConfig) {\n return;\n }\n const clipPath = graphic.getClipPath();\n if (!clipPath) {\n return;\n }\n if (!(fillCb || strokeCb)) {\n context.restore();\n }\n }\n}\n\nexport const defaultBaseClipRenderAfterContribution = new DefaultBaseClipRenderAfterContribution();\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/base-contribution-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAcA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,gCAAgC,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,OAAO,uCAAuC;IAApD;QACE,SAAI,GAA+B,0BAA0B,CAAC,gBAAgB,CAAC;QAC/E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IA6EpB,CAAC;IA5EC,SAAS,CACP,OAAiB,EACjB,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,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E;YACR,OAAO,CAAC,IAAI,EAAE,CAAC;SAChB;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uCAAuC,GAAG,IAAI,uCAAuC,EAAE,CAAC;AACrG,MAAM,OAAO,sCAAsC;IAAnD;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IA4BpB,CAAC;IA3BC,SAAS,CACP,OAAiB,EACjB,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH,EACnH,OAAa;QAEb,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QACD,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO;SACR;QACD,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,EAAE;YACzB,OAAO,CAAC,OAAO,EAAE,CAAC;SACnB;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,sCAAsC,GAAG,IAAI,sCAAsC,EAAE,CAAC","file":"base-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n BackgroundSizing,\n IContext2d,\n IGraphic,\n IThemeAttribute,\n IBaseRenderContribution,\n IContributionProvider,\n IDrawContext,\n ISymbol,\n IPath,\n ISymbolGraphicAttribute\n} from '../../../../interface';\nimport type { IBounds } from '@visactor/vutils';\nimport { inject, injectable, named } from '../../../../common/inversify-lite';\nimport { getTheme } from '../../../../graphic/theme';\nimport { canvasAllocate } from '../../../../allocator/canvas-allocate';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { ContributionProvider } from '../../../../common/contribution-provider';\nimport { InteractiveSubRenderContribution } from './constants';\n\nexport class DefaultBaseBackgroundRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n const {\n background,\n backgroundOpacity = graphic.attribute.fillOpacity ?? graphicAttribute.backgroundOpacity,\n opacity = graphicAttribute.opacity,\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit,\n backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,\n backgroundScale = graphicAttribute.backgroundScale,\n backgroundOffsetX = graphicAttribute.backgroundOffsetX,\n backgroundOffsetY = graphicAttribute.backgroundOffsetY,\n backgroundClip = graphicAttribute.backgroundClip,\n backgroundPosition = graphicAttribute.backgroundPosition\n } = graphic.attribute;\n if (!background) {\n return;\n }\n\n if (graphic.backgroundImg && graphic.resources) {\n const res = graphic.resources.get(getBackgroundImage(background) as any);\n if (!res || res.state !== 'success' || !res.data) {\n return;\n }\n\n context.save();\n\n if (graphic.parent && !graphic.transMatrix.onlyTranslate()) {\n const groupAttribute = getTheme(graphic.parent).group;\n const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = graphic.parent.attribute;\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n context.translate(scrollX, scrollY);\n }\n backgroundClip && context.clip();\n const b = graphic.AABBBounds;\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.globalAlpha = backgroundOpacity * opacity;\n this.doDrawImage(context, res.data, b, {\n backgroundMode,\n backgroundFit,\n backgroundKeepAspectRatio,\n backgroundScale,\n backgroundOffsetX,\n backgroundOffsetY,\n backgroundPosition\n });\n context.restore();\n if (!graphic.transMatrix.onlyTranslate()) {\n context.setTransformForCurrent();\n }\n } else {\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.globalAlpha = backgroundOpacity * opacity;\n context.fillStyle = background as string;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n\n protected doDrawImage(context: IContext2d, data: any, b: IBounds, params: IBackgroundImageDrawParams): void {\n drawBackgroundImage(context, data, b, params);\n }\n}\n\nexport const defaultBaseBackgroundRenderContribution = new DefaultBaseBackgroundRenderContribution();\n\nexport type IBackgroundImageDrawParams = {\n backgroundMode: IGraphicAttribute['backgroundMode'];\n backgroundFit: boolean;\n backgroundKeepAspectRatio: boolean;\n backgroundScale?: number;\n backgroundOffsetX?: number;\n backgroundOffsetY?: number;\n backgroundPosition?: IGraphicAttribute['backgroundPosition'];\n};\n\ntype BackgroundPositionValue = number | string;\n\nconst verticalPositionKeywords = new Set(['top', 'center', 'bottom']);\n\nexport function getBackgroundImage(background: any) {\n return background?.background ?? background;\n}\n\nexport function resolveBackgroundSizing({\n backgroundFit,\n backgroundKeepAspectRatio\n}: Pick<IBackgroundImageDrawParams, 'backgroundFit' | 'backgroundKeepAspectRatio'>): NonNullable<BackgroundSizing> {\n if (backgroundFit) {\n return backgroundKeepAspectRatio ? 'cover' : 'fill';\n }\n return 'auto';\n}\n\nexport function isNoRepeatSizingMode(\n mode: IGraphicAttribute['backgroundMode']\n): mode is Extract<IGraphicAttribute['backgroundMode'], `no-repeat-${string}`> {\n return typeof mode === 'string' && mode.startsWith('no-repeat-');\n}\n\nconst NO_REPEAT_SIZING_MAP: Record<string, BackgroundSizing> = {\n 'no-repeat-cover': 'cover',\n 'no-repeat-contain': 'contain',\n 'no-repeat-fill': 'fill',\n 'no-repeat-auto': 'auto'\n};\n\nexport function resolveBackgroundDrawMode({\n backgroundMode,\n backgroundFit,\n backgroundKeepAspectRatio\n}: Pick<IBackgroundImageDrawParams, 'backgroundMode' | 'backgroundFit' | 'backgroundKeepAspectRatio'>): {\n backgroundRepeatMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';\n backgroundSizing: BackgroundSizing;\n} {\n const sizing = NO_REPEAT_SIZING_MAP[backgroundMode];\n if (sizing) {\n return {\n backgroundRepeatMode: 'no-repeat',\n backgroundSizing: sizing\n };\n }\n\n return {\n backgroundRepeatMode: backgroundMode as 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat',\n backgroundSizing: resolveBackgroundSizing({\n backgroundFit,\n backgroundKeepAspectRatio\n })\n };\n}\n\nfunction isPercentageValue(value: string): boolean {\n return /^-?\\d+(\\.\\d+)?%$/.test(value);\n}\n\nfunction parsePositionToken(\n value: BackgroundPositionValue,\n remainSpace: number,\n startKeyword: 'left' | 'top',\n centerKeyword: 'center',\n endKeyword: 'right' | 'bottom'\n): number {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n\n const normalizedValue = `${value ?? ''}`.trim().toLowerCase();\n\n if (!normalizedValue || normalizedValue === startKeyword) {\n return 0;\n }\n if (normalizedValue === centerKeyword) {\n return remainSpace / 2;\n }\n if (normalizedValue === endKeyword) {\n return remainSpace;\n }\n if (isPercentageValue(normalizedValue)) {\n return (remainSpace * parseFloat(normalizedValue)) / 100;\n }\n\n const parsedValue = Number(normalizedValue);\n if (Number.isFinite(parsedValue)) {\n return parsedValue;\n }\n\n return 0;\n}\n\nfunction normalizeBackgroundPosition(\n position?: IGraphicAttribute['backgroundPosition']\n): [BackgroundPositionValue, BackgroundPositionValue] {\n if (Array.isArray(position)) {\n return [position[0] ?? 'left', position[1] ?? 'top'];\n }\n\n const normalizedPosition = `${position ?? 'top-left'}`.trim().toLowerCase().replace(/-/g, ' ');\n const tokens = normalizedPosition.split(/\\s+/).filter(Boolean);\n\n if (tokens.length === 0) {\n return ['left', 'top'];\n }\n\n if (tokens.length === 1) {\n const token = tokens[0];\n if (token === 'center') {\n return ['center', 'center'];\n }\n if (verticalPositionKeywords.has(token)) {\n return ['center', token];\n }\n return [token, 'center'];\n }\n\n let horizontal: BackgroundPositionValue | undefined;\n let vertical: BackgroundPositionValue | undefined;\n const genericTokens: BackgroundPositionValue[] = [];\n\n for (let i = 0; i < 2; i++) {\n const token = tokens[i];\n if (token === 'left' || token === 'right') {\n horizontal = token;\n continue;\n }\n if (token === 'top' || token === 'bottom') {\n vertical = token;\n continue;\n }\n genericTokens.push(token);\n }\n\n if (horizontal == null && genericTokens.length) {\n horizontal = genericTokens.shift();\n }\n if (vertical == null && genericTokens.length) {\n vertical = genericTokens.shift();\n }\n\n return [horizontal ?? 'left', vertical ?? 'top'];\n}\n\nexport function resolveBackgroundPosition(\n position: IGraphicAttribute['backgroundPosition'],\n remainWidth: number,\n remainHeight: number\n) {\n const [horizontalPosition, verticalPosition] = normalizeBackgroundPosition(position);\n return {\n x: parsePositionToken(horizontalPosition, remainWidth, 'left', 'center', 'right'),\n y: parsePositionToken(verticalPosition, remainHeight, 'top', 'center', 'bottom')\n };\n}\n\nfunction pickRenderableDimension(...values: any[]): number | null {\n for (const value of values) {\n if (typeof value === 'number' && Number.isFinite(value) && value > 0) {\n return value;\n }\n }\n return null;\n}\n\nexport function resolveRenderableImageSize(data: any): { width: number; height: number } | null {\n if (!data) {\n return null;\n }\n\n // DOM image-like resources may expose intrinsic size on naturalWidth/videoWidth\n // while width/height stays 0, so prefer intrinsic dimensions when available.\n const width = pickRenderableDimension(data.naturalWidth, data.videoWidth, data.width);\n const height = pickRenderableDimension(data.naturalHeight, data.videoHeight, data.height);\n\n if (width == null || height == null) {\n return null;\n }\n\n return { width, height };\n}\n\nexport function drawBackgroundImage(\n context: IContext2d,\n data: any,\n b: IBounds,\n params: IBackgroundImageDrawParams\n): void {\n const {\n backgroundMode,\n backgroundFit,\n backgroundKeepAspectRatio,\n backgroundScale = 1,\n backgroundOffsetX = 0,\n backgroundOffsetY = 0,\n backgroundPosition = 'top-left'\n } = params;\n const targetW = b.width();\n const targetH = b.height();\n const sourceSize = resolveRenderableImageSize(data);\n const { backgroundRepeatMode, backgroundSizing: resolvedBackgroundSizing } = resolveBackgroundDrawMode({\n backgroundMode,\n backgroundFit,\n backgroundKeepAspectRatio\n });\n let w = targetW;\n let h = targetH;\n\n if (targetW <= 0 || targetH <= 0) {\n return;\n }\n\n if (backgroundRepeatMode === 'no-repeat') {\n let drawWidth = sourceSize?.width ?? targetW;\n let drawHeight = sourceSize?.height ?? targetH;\n\n if ((resolvedBackgroundSizing === 'cover' || resolvedBackgroundSizing === 'contain') && sourceSize) {\n const scale =\n resolvedBackgroundSizing === 'cover'\n ? Math.max(targetW / sourceSize.width, targetH / sourceSize.height)\n : Math.min(targetW / sourceSize.width, targetH / sourceSize.height);\n drawWidth = sourceSize.width * scale;\n drawHeight = sourceSize.height * scale;\n } else if (resolvedBackgroundSizing === 'fill') {\n drawWidth = targetW;\n drawHeight = targetH;\n }\n\n drawWidth *= backgroundScale;\n drawHeight *= backgroundScale;\n\n const { x, y } = resolveBackgroundPosition(backgroundPosition, targetW - drawWidth, targetH - drawHeight);\n context.drawImage(data, b.x1 + x + backgroundOffsetX, b.y1 + y + backgroundOffsetY, drawWidth, drawHeight);\n return;\n }\n\n // TODO 考虑缓存\n if (backgroundFit && backgroundRepeatMode !== 'repeat' && sourceSize) {\n const resW = sourceSize.width;\n const resH = sourceSize.height;\n\n if (backgroundRepeatMode === 'repeat-x') {\n // 高度适应\n const ratio = targetH / resH;\n w = resW * ratio;\n h = targetH;\n } else if (backgroundRepeatMode === 'repeat-y') {\n // 宽度适应\n const ratio = targetW / resW;\n h = resH * ratio;\n w = targetW;\n }\n\n const dpr = context.dpr;\n const canvas = canvasAllocate.allocate({ width: w, height: h, dpr });\n const ctx = canvas.getContext('2d');\n if (ctx) {\n ctx.inuse = true;\n ctx.clearMatrix();\n ctx.setTransformForCurrent(true);\n ctx.clearRect(0, 0, w, h);\n ctx.drawImage(data, 0, 0, w, h);\n data = canvas.nativeCanvas;\n }\n canvasAllocate.free(canvas);\n }\n const dpr = context.dpr;\n const pattern = context.createPattern(data, backgroundRepeatMode);\n pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0]));\n context.fillStyle = pattern;\n context.translate(b.x1, b.y1);\n context.fillRect(0, 0, targetW, targetH);\n context.translate(-b.x1, -b.y1);\n}\n\nexport interface IInteractiveSubRenderContribution {\n render: (\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) => void;\n}\n\n@injectable()\nexport class DefaultBaseInteractiveRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n\n _subRenderContribitions?: IInteractiveSubRenderContribution[];\n constructor(\n @inject(ContributionProvider)\n @named(InteractiveSubRenderContribution)\n protected readonly subRenderContribitions: IContributionProvider<IInteractiveSubRenderContribution>\n ) {}\n\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n if (!this._subRenderContribitions) {\n this._subRenderContribitions = this.subRenderContribitions.getContributions();\n }\n this._subRenderContribitions.forEach(c => {\n c.render(\n graphic,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n graphicAttribute,\n drawContext,\n fillCb,\n strokeCb,\n options\n );\n });\n }\n}\n\nexport class DefaultBaseClipRenderBeforeContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IGraphicAttribute>,\n themeAttribute: IThemeAttribute,\n final?: boolean\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IGraphicAttribute>,\n themeAttribute: IThemeAttribute,\n final?: boolean\n ) => boolean,\n options?: any\n ) {\n const { clipConfig } = graphic.attribute;\n if (!clipConfig) {\n return;\n }\n const clipPath = graphic.getClipPath();\n if (!clipPath) {\n return;\n }\n const draw = !(fillCb || strokeCb);\n const b = graphic.AABBBounds;\n const width = (graphic.attribute as any).width ?? b.width();\n const height = (graphic.attribute as any).height ?? b.height();\n if (draw) {\n context.save();\n }\n context.beginPath();\n if (clipPath.draw(context, [width, height], x + width / 2, y + height / 2, 0) === false) {\n context.closePath();\n }\n if (fillCb) {\n fillCb(context, graphic.attribute, graphicAttribute, true);\n }\n\n if (draw) {\n context.clip();\n }\n }\n}\n\nexport const defaultBaseClipRenderBeforeContribution = new DefaultBaseClipRenderBeforeContribution();\nexport class DefaultBaseClipRenderAfterContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n const { clipConfig } = graphic.attribute;\n if (!clipConfig) {\n return;\n }\n const clipPath = graphic.getClipPath();\n if (!clipPath) {\n return;\n }\n if (!(fillCb || strokeCb)) {\n context.restore();\n }\n }\n}\n\nexport const defaultBaseClipRenderAfterContribution = new DefaultBaseClipRenderAfterContribution();\n"]}
@@ -1,4 +1,4 @@
1
- import { DefaultBaseBackgroundRenderContribution } from "./base-contribution-render";
1
+ import { DefaultBaseBackgroundRenderContribution, getBackgroundImage } from "./base-contribution-render";
2
2
 
3
3
  import { BaseRenderContributionTime } from "../../../../common/enums";
4
4
 
@@ -7,22 +7,24 @@ export class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgro
7
7
  super(...arguments), this.time = BaseRenderContributionTime.beforeFillStroke;
8
8
  }
9
9
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
10
- const {background: background, backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit, backgroundKeepAspectRatio: backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio, backgroundScale: backgroundScale = graphicAttribute.backgroundScale, backgroundOffsetX: backgroundOffsetX = graphicAttribute.backgroundOffsetX, backgroundOffsetY: backgroundOffsetY = graphicAttribute.backgroundOffsetY} = graphic.attribute;
10
+ const {background: background, backgroundOpacity: backgroundOpacity = graphicAttribute.backgroundOpacity, opacity: opacity = graphicAttribute.opacity, backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit, backgroundKeepAspectRatio: backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio, backgroundScale: backgroundScale = graphicAttribute.backgroundScale, backgroundOffsetX: backgroundOffsetX = graphicAttribute.backgroundOffsetX, backgroundOffsetY: backgroundOffsetY = graphicAttribute.backgroundOffsetY, backgroundClip: backgroundClip = graphicAttribute.backgroundClip, backgroundPosition: backgroundPosition = graphicAttribute.backgroundPosition} = graphic.attribute;
11
11
  if (background) if (graphic.backgroundImg && graphic.resources) {
12
- const res = graphic.resources.get(background);
13
- if ("success" !== res.state || !res.data) return;
12
+ const res = graphic.resources.get(getBackgroundImage(background));
13
+ if (!res || "success" !== res.state || !res.data) return;
14
14
  context.highPerformanceSave(), context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0);
15
15
  const b = graphic.AABBBounds;
16
+ context.globalAlpha = backgroundOpacity * opacity, backgroundClip && context.clip(),
16
17
  this.doDrawImage(context, res.data, b, {
17
18
  backgroundMode: backgroundMode,
18
19
  backgroundFit: backgroundFit,
19
20
  backgroundKeepAspectRatio: backgroundKeepAspectRatio,
20
21
  backgroundScale: backgroundScale,
21
22
  backgroundOffsetX: backgroundOffsetX,
22
- backgroundOffsetY: backgroundOffsetY
23
+ backgroundOffsetY: backgroundOffsetY,
24
+ backgroundPosition: backgroundPosition
23
25
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
24
- } else context.highPerformanceSave(), context.fillStyle = background, context.fill(),
25
- context.highPerformanceRestore();
26
+ } else context.highPerformanceSave(), context.globalAlpha = backgroundOpacity * opacity,
27
+ context.fillStyle = background, context.fill(), context.highPerformanceRestore();
26
28
  }
27
29
  }
28
30
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/group-contribution-render.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,uCAAuC,EAA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;gBACzB,eAAe;gBACf,iBAAiB;gBACjB,iBAAiB;aAClB,CAAC,CAAC;YACH,OAAO,CAAC,sBAAsB,EAAE,CAAC;YACjC,OAAO,CAAC,sBAAsB,EAAE,CAAC;SAClC;aAAM;YACL,OAAO,CAAC,mBAAmB,EAAE,CAAC;YAC9B,OAAO,CAAC,SAAS,GAAG,UAAoB,CAAC;YACzC,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,sBAAsB,EAAE,CAAC;SAClC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,wCAAwC,GAAG,IAAI,wCAAwC,EAAE,CAAC","file":"group-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext\n} from '../../../../interface';\nimport { DefaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\n\nexport class DefaultGroupBackgroundRenderContribution\n extends DefaultBaseBackgroundRenderContribution\n implements IGroupRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n drawShape(\n graphic: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n ) {\n const {\n background,\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit,\n backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,\n backgroundScale = graphicAttribute.backgroundScale,\n backgroundOffsetX = graphicAttribute.backgroundOffsetX,\n backgroundOffsetY = graphicAttribute.backgroundOffsetY\n } = graphic.attribute;\n if (!background) {\n return;\n }\n\n if (graphic.backgroundImg && graphic.resources) {\n const res = graphic.resources.get(background as any);\n if (res.state !== 'success' || !res.data) {\n return;\n }\n\n context.highPerformanceSave();\n\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n const b = graphic.AABBBounds;\n this.doDrawImage(context, res.data, b, {\n backgroundMode,\n backgroundFit,\n backgroundKeepAspectRatio,\n backgroundScale,\n backgroundOffsetX,\n backgroundOffsetY\n });\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n } else {\n context.highPerformanceSave();\n context.fillStyle = background as string;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n}\n\nexport const defaultGroupBackgroundRenderContribution = new DefaultGroupBackgroundRenderContribution();\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/group-contribution-render.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,uCAAuC,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,OAAO,wCACX,SAAQ,uCAAuC;IADjD;;QAIE,SAAI,GAA+B,0BAA0B,CAAC,gBAAgB,CAAC;IAgEjF,CAAC;IA9DC,SAAS,CACP,OAAe,EACf,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH;QAEnH,MAAM,EACJ,UAAU,EACV,iBAAiB,GAAG,gBAAgB,CAAC,iBAAiB,EACtD,OAAO,GAAG,gBAAgB,CAAC,OAAO,EAClC,cAAc,GAAG,gBAAgB,CAAC,cAAc,EAChD,aAAa,GAAG,gBAAgB,CAAC,aAAa,EAC9C,yBAAyB,GAAG,gBAAgB,CAAC,yBAAyB,EACtE,eAAe,GAAG,gBAAgB,CAAC,eAAe,EAClD,iBAAiB,GAAG,gBAAgB,CAAC,iBAAiB,EACtD,iB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AsB,EAAE,CAAC;SAClC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,wCAAwC,GAAG,IAAI,wCAAwC,EAAE,CAAC","file":"group-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext\n} from '../../../../interface';\nimport { DefaultBaseBackgroundRenderContribution, getBackgroundImage } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\n\nexport class DefaultGroupBackgroundRenderContribution\n extends DefaultBaseBackgroundRenderContribution\n implements IGroupRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n drawShape(\n graphic: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n ) {\n const {\n background,\n backgroundOpacity = graphicAttribute.backgroundOpacity,\n opacity = graphicAttribute.opacity,\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit,\n backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,\n backgroundScale = graphicAttribute.backgroundScale,\n backgroundOffsetX = graphicAttribute.backgroundOffsetX,\n backgroundOffsetY = graphicAttribute.backgroundOffsetY,\n backgroundClip = graphicAttribute.backgroundClip,\n backgroundPosition = graphicAttribute.backgroundPosition\n } = graphic.attribute;\n if (!background) {\n return;\n }\n\n if (graphic.backgroundImg && graphic.resources) {\n const res = graphic.resources.get(getBackgroundImage(background) as any);\n if (!res || res.state !== 'success' || !res.data) {\n return;\n }\n\n context.highPerformanceSave();\n\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n const b = graphic.AABBBounds;\n context.globalAlpha = backgroundOpacity * opacity;\n backgroundClip && context.clip();\n this.doDrawImage(context, res.data, b, {\n backgroundMode,\n backgroundFit,\n backgroundKeepAspectRatio,\n backgroundScale,\n backgroundOffsetX,\n backgroundOffsetY,\n backgroundPosition\n });\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n } else {\n context.highPerformanceSave();\n context.globalAlpha = backgroundOpacity * opacity;\n context.fillStyle = background as string;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n}\n\nexport const defaultGroupBackgroundRenderContribution = new DefaultGroupBackgroundRenderContribution();\n"]}
@@ -16,7 +16,7 @@ export class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgrou
16
16
  }
17
17
  drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
18
18
  var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19
- const {backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit, backgroundKeepAspectRatio: backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio} = graphic.attribute;
19
+ const {backgroundOpacity: backgroundOpacity = graphicAttribute.backgroundOpacity, opacity: opacity = graphicAttribute.opacity, backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit, backgroundKeepAspectRatio: backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio, backgroundScale: backgroundScale = graphicAttribute.backgroundScale, backgroundOffsetX: backgroundOffsetX = graphicAttribute.backgroundOffsetX, backgroundOffsetY: backgroundOffsetY = graphicAttribute.backgroundOffsetY, backgroundPosition: backgroundPosition = graphicAttribute.backgroundPosition, backgroundClip: backgroundClip = graphicAttribute.backgroundClip, backgroundCornerRadius: backgroundCornerRadius = graphicAttribute.backgroundCornerRadius} = graphic.attribute;
20
20
  let matrix, {background: background} = graphic.attribute;
21
21
  if (!background) return;
22
22
  const restore = () => {
@@ -25,13 +25,13 @@ export class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgrou
25
25
  let b;
26
26
  "richtext" === graphic.type && (matrix = context.currentMatrix.clone(), context.restore(),
27
27
  context.save(), context.setTransformForCurrent());
28
- const shouldReCalBounds = isObject(background) && background.background, onlyTranslate = graphic.transMatrix.onlyTranslate();
29
- if (shouldReCalBounds) {
30
- const _b = graphic.AABBBounds, x = (null !== (_a = background.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = background.dx) && void 0 !== _c ? _c : 0), y = (null !== (_d = background.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = background.dy) && void 0 !== _e ? _e : 0), w = null !== (_f = background.width) && void 0 !== _f ? _f : _b.width(), h = null !== (_g = background.height) && void 0 !== _g ? _g : _b.height();
31
- if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = background.background,
28
+ const backgroundConfig = isObject(background) && background.background ? background : null, onlyTranslate = graphic.transMatrix.onlyTranslate();
29
+ if (backgroundConfig) {
30
+ const _b = graphic.AABBBounds, x = (null !== (_a = backgroundConfig.x) && void 0 !== _a ? _a : _b.x1) + (null !== (_c = backgroundConfig.dx) && void 0 !== _c ? _c : 0), y = (null !== (_d = backgroundConfig.y) && void 0 !== _d ? _d : _b.y1) + (null !== (_e = backgroundConfig.dy) && void 0 !== _e ? _e : 0), w = null !== (_f = backgroundConfig.width) && void 0 !== _f ? _f : _b.width(), h = null !== (_g = backgroundConfig.height) && void 0 !== _g ? _g : _b.height();
31
+ if (b = boundsAllocate.allocate(x, y, x + w, y + h), background = backgroundConfig.background,
32
32
  !onlyTranslate) {
33
33
  const w = b.width(), h = b.height();
34
- b.set((null !== (_h = background.x) && void 0 !== _h ? _h : 0) + (null !== (_j = background.dx) && void 0 !== _j ? _j : 0), (null !== (_k = background.y) && void 0 !== _k ? _k : 0) + (null !== (_l = background.dy) && void 0 !== _l ? _l : 0), w, h);
34
+ b.set((null !== (_h = backgroundConfig.x) && void 0 !== _h ? _h : 0) + (null !== (_j = backgroundConfig.dx) && void 0 !== _j ? _j : 0), (null !== (_k = backgroundConfig.y) && void 0 !== _k ? _k : 0) + (null !== (_l = backgroundConfig.dy) && void 0 !== _l ? _l : 0), w, h);
35
35
  }
36
36
  } else b = graphic.AABBBounds, onlyTranslate || (b = getTextBounds(Object.assign(Object.assign({}, graphic.attribute), {
37
37
  angle: 0,
@@ -44,20 +44,24 @@ export class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgrou
44
44
  })).clone());
45
45
  if (graphic.backgroundImg && graphic.resources) {
46
46
  const res = graphic.resources.get(background);
47
- if ("success" !== res.state || !res.data) return void restore();
47
+ if (!res || "success" !== res.state || !res.data) return void restore();
48
48
  context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0),
49
- context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, {
49
+ context.globalAlpha = backgroundOpacity * opacity, backgroundClip && (context.beginPath(),
50
+ backgroundCornerRadius ? createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0) : context.rect(b.x1, b.y1, b.width(), b.height()),
51
+ context.clip()), this.doDrawImage(context, res.data, b, {
50
52
  backgroundMode: backgroundMode,
51
53
  backgroundFit: backgroundFit,
52
- backgroundKeepAspectRatio: backgroundKeepAspectRatio
54
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
55
+ backgroundScale: backgroundScale,
56
+ backgroundOffsetX: backgroundOffsetX,
57
+ backgroundOffsetY: backgroundOffsetY,
58
+ backgroundPosition: backgroundPosition
53
59
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
54
- } else {
55
- const {backgroundCornerRadius: backgroundCornerRadius, backgroundOpacity: backgroundOpacity = 1} = graphic.attribute;
56
- context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute),
57
- context.globalAlpha = backgroundOpacity, context.fillStyle = background, backgroundCornerRadius ? (createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0),
58
- context.fill()) : context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
59
- }
60
- shouldReCalBounds && boundsAllocate.free(b), restore();
60
+ } else context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute),
61
+ context.globalAlpha = backgroundOpacity * opacity, context.fillStyle = background,
62
+ backgroundCornerRadius ? (createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, !0),
63
+ context.fill()) : context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
64
+ backgroundConfig && boundsAllocate.free(b), restore();
61
65
  }
62
66
  }
63
67
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/text-contribution-render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAStE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,OAAO,uCACX,SAAQ,uCAAuC;IADjD;;QAIE,SAAI,GAA+B,0BAA0B,CAAC,gBAAgB,CAAC;IAgHjF,CAAC;IA9GC,SAAS,CACP,OAAc,EACd,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH;;QAEnH,MAAM,EACJ,cAAc,GAAG,gBAAgB,CAAC,cAAc,EAChD,aAAa,GAAG,gBAAgB,CAAC,aAAa,EAC9C,yBAAy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EAAE,sBAAsB,EAAE,IAAI,CAAC,CAAC;gBACzF,OAAO,CAAC,IAAI,EAAE,CAAC;aAChB;iBAAM;gBACL,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;aACrD;YACD,OAAO,CAAC,sBAAsB,EAAE,CAAC;SAClC;QAED,IAAI,iBAAiB,EAAE;YACrB,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACxB;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uCAAuC,GAAG,IAAI,uCAAuC,EAAE,CAAC","file":"text-contribution-render.js","sourcesContent":["import type { IAABBBounds, IMatrix } from '@visactor/vutils';\nimport { isObject } from '@visactor/vutils';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport type {\n IContext2d,\n IDrawContext,\n IGraphicAttribute,\n IText,\n ITextRenderContribution,\n IThemeAttribute\n} from '../../../../interface';\nimport { DefaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { boundsAllocate } from '../../../../allocator/bounds-allocate';\nimport { getTextBounds } from '../../../../graphic/bounds';\nimport { createRectPath } from '../../../../common/shape/rect';\n\nexport class DefaultTextBackgroundRenderContribution\n extends DefaultBaseBackgroundRenderContribution\n implements ITextRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n drawShape(\n graphic: IText,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n ) {\n const {\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit,\n backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio\n } = graphic.attribute;\n let { background } = graphic.attribute;\n if (!background) {\n return;\n }\n let matrix: IMatrix;\n const save = () => {\n if (graphic.type === 'richtext') {\n matrix = context.currentMatrix.clone();\n context.restore();\n context.save();\n context.setTransformForCurrent();\n }\n };\n const restore = () => {\n if (graphic.type === 'richtext') {\n context.restore();\n context.save();\n matrix && context.setTransformFromMatrix(matrix, true, 1);\n }\n };\n save();\n let b: IAABBBounds;\n const shouldReCalBounds = isObject(background) && (background as any).background;\n const onlyTranslate = graphic.transMatrix.onlyTranslate();\n if (shouldReCalBounds) {\n const _b = graphic.AABBBounds;\n const x = ((background as any).x ?? _b.x1) + ((background as any).dx ?? 0);\n const y = ((background as any).y ?? _b.y1) + ((background as any).dy ?? 0);\n const w = (background as any).width ?? _b.width();\n const h = (background as any).height ?? _b.height();\n b = boundsAllocate.allocate(x, y, x + w, y + h);\n background = (background as any).background;\n if (!onlyTranslate) {\n const w = b.width();\n const h = b.height();\n b.set(\n ((background as any).x ?? 0) + ((background as any).dx ?? 0),\n ((background as any).y ?? 0) + ((background as any).dy ?? 0),\n w,\n h\n );\n }\n } else {\n b = graphic.AABBBounds;\n if (!onlyTranslate) {\n b = getTextBounds({ ...graphic.attribute, angle: 0, scaleX: 1, scaleY: 1, x: 0, y: 0, dx: 0, dy: 0 }).clone();\n }\n }\n\n if (graphic.backgroundImg && graphic.resources) {\n const res = graphic.resources.get(background as any);\n if (res.state !== 'success' || !res.data) {\n restore();\n return;\n }\n\n context.highPerformanceSave();\n // 默认应用旋转\n if (!onlyTranslate) {\n // TODO 性能优化\n // const _b = getTextBounds({ ...graphic.attribute, angle: 0, scaleX: 1, scaleY: 1, x: 0, y: 0, dx: 0, dy: 0 });\n // b.copy(_b);\n } else {\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n }\n\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n this.doDrawImage(context, res.data, b, { backgroundMode, backgroundFit, backgroundKeepAspectRatio });\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n } else {\n const { backgroundCornerRadius, backgroundOpacity = 1 } = graphic.attribute;\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.globalAlpha = backgroundOpacity;\n context.fillStyle = background as string;\n if (backgroundCornerRadius) {\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, true);\n context.fill();\n } else {\n context.fillRect(b.x1, b.y1, b.width(), b.height());\n }\n context.highPerformanceRestore();\n }\n\n if (shouldReCalBounds) {\n boundsAllocate.free(b);\n }\n restore();\n }\n}\n\nexport const defaultTextBackgroundRenderContribution = new DefaultTextBackgroundRenderContribution();\n\n// @injectable()\n// export class DefaultTextPopTipRenderContribution\n// extends DefaultBasePopTipRenderContribution\n// implements ITextRenderContribution\n// {\n// time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n// }\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/text-contribution-render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAStE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,OAAO,uCACX,SAAQ,uCAAuC;IADjD;;QAIE,SAAI,GAA+B,0BAA0B,CAAC,gBAAgB,CAAC;IAwIjF,CAAC;IAtIC,SAAS,CACP,OAAc,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AK,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;aACrD;YACD,OAAO,CAAC,sBAAsB,EAAE,CAAC;SAClC;QAED,IAAI,gBAAgB,EAAE;YACpB,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACxB;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uCAAuC,GAAG,IAAI,uCAAuC,EAAE,CAAC","file":"text-contribution-render.js","sourcesContent":["import type { IAABBBounds, IMatrix } from '@visactor/vutils';\nimport { isObject } from '@visactor/vutils';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport type {\n IContext2d,\n IDrawContext,\n IGraphicAttribute,\n IText,\n ITextRenderContribution,\n IThemeAttribute\n} from '../../../../interface';\nimport { DefaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { boundsAllocate } from '../../../../allocator/bounds-allocate';\nimport { getTextBounds } from '../../../../graphic/bounds';\nimport { createRectPath } from '../../../../common/shape/rect';\n\nexport class DefaultTextBackgroundRenderContribution\n extends DefaultBaseBackgroundRenderContribution\n implements ITextRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n drawShape(\n graphic: IText,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n ) {\n const {\n backgroundOpacity = graphicAttribute.backgroundOpacity,\n opacity = graphicAttribute.opacity,\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit,\n backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,\n backgroundScale = graphicAttribute.backgroundScale,\n backgroundOffsetX = graphicAttribute.backgroundOffsetX,\n backgroundOffsetY = graphicAttribute.backgroundOffsetY,\n backgroundPosition = graphicAttribute.backgroundPosition,\n backgroundClip = graphicAttribute.backgroundClip,\n backgroundCornerRadius = graphicAttribute.backgroundCornerRadius\n } = graphic.attribute;\n let { background } = graphic.attribute;\n if (!background) {\n return;\n }\n let matrix: IMatrix;\n const save = () => {\n if (graphic.type === 'richtext') {\n matrix = context.currentMatrix.clone();\n context.restore();\n context.save();\n context.setTransformForCurrent();\n }\n };\n const restore = () => {\n if (graphic.type === 'richtext') {\n context.restore();\n context.save();\n matrix && context.setTransformFromMatrix(matrix, true, 1);\n }\n };\n save();\n let b: IAABBBounds;\n const backgroundConfig = isObject(background) && (background as any).background ? (background as any) : null;\n const onlyTranslate = graphic.transMatrix.onlyTranslate();\n if (backgroundConfig) {\n const _b = graphic.AABBBounds;\n const x = (backgroundConfig.x ?? _b.x1) + (backgroundConfig.dx ?? 0);\n const y = (backgroundConfig.y ?? _b.y1) + (backgroundConfig.dy ?? 0);\n const w = backgroundConfig.width ?? _b.width();\n const h = backgroundConfig.height ?? _b.height();\n b = boundsAllocate.allocate(x, y, x + w, y + h);\n background = backgroundConfig.background;\n if (!onlyTranslate) {\n const w = b.width();\n const h = b.height();\n b.set(\n (backgroundConfig.x ?? 0) + (backgroundConfig.dx ?? 0),\n (backgroundConfig.y ?? 0) + (backgroundConfig.dy ?? 0),\n w,\n h\n );\n }\n } else {\n b = graphic.AABBBounds;\n if (!onlyTranslate) {\n b = getTextBounds({ ...graphic.attribute, angle: 0, scaleX: 1, scaleY: 1, x: 0, y: 0, dx: 0, dy: 0 }).clone();\n }\n }\n\n if (graphic.backgroundImg && graphic.resources) {\n const res = graphic.resources.get(background as any);\n if (!res || res.state !== 'success' || !res.data) {\n restore();\n return;\n }\n\n context.highPerformanceSave();\n // 默认应用旋转\n if (!onlyTranslate) {\n // TODO 性能优化\n // const _b = getTextBounds({ ...graphic.attribute, angle: 0, scaleX: 1, scaleY: 1, x: 0, y: 0, dx: 0, dy: 0 });\n // b.copy(_b);\n } else {\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n }\n\n context.globalAlpha = backgroundOpacity * opacity;\n if (backgroundClip) {\n context.beginPath();\n if (backgroundCornerRadius) {\n createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, true);\n } else {\n context.rect(b.x1, b.y1, b.width(), b.height());\n }\n context.clip();\n }\n this.doDrawImage(context, res.data, b, {\n backgroundMode,\n backgroundFit,\n backgroundKeepAspectRatio,\n backgroundScale,\n backgroundOffsetX,\n backgroundOffsetY,\n backgroundPosition\n });\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n } else {\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.globalAlpha = backgroundOpacity * opacity;\n context.fillStyle = background as string;\n if (backgroundCornerRadius) {\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius, true);\n context.fill();\n } else {\n context.fillRect(b.x1, b.y1, b.width(), b.height());\n }\n context.highPerformanceRestore();\n }\n\n if (backgroundConfig) {\n boundsAllocate.free(b);\n }\n restore();\n }\n}\n\nexport const defaultTextBackgroundRenderContribution = new DefaultTextBackgroundRenderContribution();\n\n// @injectable()\n// export class DefaultTextPopTipRenderContribution\n// extends DefaultBasePopTipRenderContribution\n// implements ITextRenderContribution\n// {\n// time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n// }\n"]}
@@ -34,6 +34,8 @@ import { matrixAllocate } from "../../../allocator/matrix-allocate";
34
34
 
35
35
  import { application } from "../../../application";
36
36
 
37
+ import { drawBackgroundImage, getBackgroundImage } from "./contributions/base-contribution-render";
38
+
37
39
  let DefaultDrawContribution = class {
38
40
  constructor(contributions, drawItemInterceptorContributions) {
39
41
  this.contributions = contributions, this.drawItemInterceptorContributions = drawItemInterceptorContributions,
@@ -215,15 +217,26 @@ let DefaultDrawContribution = class {
215
217
  return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);
216
218
  }
217
219
  clearScreen(renderService, context, drawContext) {
218
- var _a, _b, _c;
220
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
219
221
  const {clear: clear, viewBox: viewBox} = drawContext, width = viewBox.width(), height = viewBox.height();
220
222
  if (clear) {
221
223
  context.clearRect(0, 0, width, height), (null === (_a = renderService.drawParams) || void 0 === _a ? void 0 : _a.stage) && renderService.drawParams.stage.hooks.afterClearRect.call(renderService.drawParams);
222
224
  const stage = null === (_b = renderService.drawParams) || void 0 === _b ? void 0 : _b.stage;
223
- if (stage && (context.globalAlpha = null !== (_c = stage.attribute.opacity) && void 0 !== _c ? _c : 1),
225
+ if (stage && (context.globalAlpha = (null !== (_c = stage.attribute.opacity) && void 0 !== _c ? _c : 1) * (null !== (_d = stage.attribute.backgroundOpacity) && void 0 !== _d ? _d : 1)),
224
226
  stage && stage.backgroundImg && stage.resources) {
225
- const res = stage.resources.get(clear);
226
- res && "success" === res.state && res.data && context.drawImage(res.data, 0, 0, width, height);
227
+ const res = stage.resources.get(getBackgroundImage(clear));
228
+ if (res && "success" === res.state && res.data) {
229
+ const backgroundBounds = boundsAllocate.allocate(0, 0, 0 + width, 0 + height);
230
+ drawBackgroundImage(context, res.data, backgroundBounds, {
231
+ backgroundMode: null !== (_e = stage.attribute.backgroundMode) && void 0 !== _e ? _e : DefaultAttribute.backgroundMode,
232
+ backgroundFit: null !== (_f = stage.attribute.backgroundFit) && void 0 !== _f ? _f : DefaultAttribute.backgroundFit,
233
+ backgroundKeepAspectRatio: null !== (_g = stage.attribute.backgroundKeepAspectRatio) && void 0 !== _g ? _g : DefaultAttribute.backgroundKeepAspectRatio,
234
+ backgroundScale: null !== (_h = stage.attribute.backgroundScale) && void 0 !== _h ? _h : DefaultAttribute.backgroundScale,
235
+ backgroundOffsetX: null !== (_j = stage.attribute.backgroundOffsetX) && void 0 !== _j ? _j : DefaultAttribute.backgroundOffsetX,
236
+ backgroundOffsetY: null !== (_k = stage.attribute.backgroundOffsetY) && void 0 !== _k ? _k : DefaultAttribute.backgroundOffsetY,
237
+ backgroundPosition: null !== (_l = stage.attribute.backgroundPosition) && void 0 !== _l ? _l : DefaultAttribute.backgroundPosition
238
+ }), boundsAllocate.free(backgroundBounds);
239
+ }
227
240
  } else context.fillStyle = createColor(context, clear, {
228
241
  AABBBounds: {
229
242
  x1: 0,
@@ -1 +1 @@
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;AAexF,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AACtE,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,GAA7B,MAAM,uBAAuB;IAgBlC,YAIiD,aAA+B,EAK3D,gCAAyF;QAL7D,k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AAA;AAndY,uBAAuB;IADnC,UAAU,EAAE;IAqBR,WAAA,WAAW,CAAC,aAAa,CAAC,CAAA;IAG1B,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GAxBlB,uBAAuB,CAmdnC;SAndY,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 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/config';\nimport type { IAABBBounds, IBounds, IMatrix } from '@visactor/vutils';\nimport { Bounds, Logger, getRectIntersect, isArray, isRectIntersect } from '@visactor/vutils';\nimport { container } from '../../../container';\nimport { GraphicRender, IncrementalDrawContribution } 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 declare scrollMatrix?: IMatrix;\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 if (!isArray(this.contributions)) {\n this.contributions = [this.contributions];\n }\n this.init();\n }\n\n reInit() {\n this.init();\n this.contributions.forEach(item => {\n item.reInit();\n });\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 // 有dirtyBounds用dirtyBounds\n if (drawContext.updateBounds) {\n this.useDirtyBounds = true;\n } else {\n // 没有的话,看看是否需要跳过outRange的渲染\n this.useDirtyBounds = !drawContext.stage.params.optimize.disableCheckGraphicWidthOutRange;\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, viewBox, transMatrix } = 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, viewBox.width(), viewBox.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 // 如果dpr不是整数或者.5的小数,需要格式化dirtyBounds\n const d = context.dpr % 1;\n if (d || d !== 0.5) {\n dirtyBounds.x1 = Math.floor(dirtyBounds.x1 * context.dpr) / context.dpr;\n dirtyBounds.y1 = Math.floor(dirtyBounds.y1 * context.dpr) / context.dpr;\n dirtyBounds.x2 = Math.ceil(dirtyBounds.x2 * context.dpr) / context.dpr;\n dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr;\n }\n this.backupDirtyBounds.copy(dirtyBounds);\n // TODO:不需要设置context.transform,后续translate会设置\n context.reset(false);\n context.save();\n context.setClearMatrix(transMatrix.a, transMatrix.b, transMatrix.c, transMatrix.d, transMatrix.e, transMatrix.f);\n // 初始化context\n context.clearMatrix(false);\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(viewBox.x1, viewBox.y1, true);\n context.beginPath();\n context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height());\n context.clip();\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 if (renderService.drawParams?.stage) {\n renderService.drawParams.stage.hooks.afterClearScreen.call(renderService.drawParams);\n }\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 group.isContainer\n ? this.renderGroup(group as IGroup, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0))\n : this.renderItem(group as IGraphic, drawContext);\n });\n\n // context.restore();\n // context.restore();\n // context.setClearMatrix(1, 0, 0, 1, 0, 0);\n // this.break = false;\n // context.inuse = false;\n context.restore();\n context.draw();\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: IMatrix, 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 (\n this.useDirtyBounds &&\n !isRectIntersect(group.AABBBounds, this.dirtyBounds, false) &&\n group.attribute.boundsMode !== 'empty'\n ) {\n return;\n }\n\n let nextM: IMatrix = parentMatrix;\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 drawContext.isGroupScroll = !!(group.attribute.scrollX || group.attribute.scrollY);\n\n this.renderItem(group, drawContext, {\n renderInGroupParams: {\n skipSort,\n nextM\n },\n renderInGroup: this._renderInGroup\n });\n\n if (this.useDirtyBounds) {\n this.dirtyBounds.copy(tempBounds);\n boundsAllocate.free(tempBounds);\n matrixAllocate.free(nextM);\n }\n }\n\n _renderInGroup = (skipSort: boolean, group: IGroup, drawContext: IDrawContext, nextM: IMatrix) => {\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 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;\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType, graphic);\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 (\n drawContribution.beforeDrawItem &&\n drawContribution.beforeDrawItem(graphic, this.currentRenderService, drawContext, this, params)\n ) {\n return;\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: IBounds;\n\n if (drawContext.isGroupScroll) {\n const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n retrans = true;\n if (!this.scrollMatrix) {\n this.scrollMatrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n }\n this.scrollMatrix.translate(-scrollX, -scrollY);\n }\n // if (graphic.parent) {\n // const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n // if (!!(scrollX || scrollY)) {\n // retrans = true;\n // if (!this.scrollMatrix) {\n // this.scrollMatrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n // }\n // this.scrollMatrix.translate(-scrollX, -scrollY);\n // }\n // }\n // 需要二次变化,那就重新算一个变换后的Bounds\n if (retrans) {\n tempBounds = this.dirtyBounds.clone().transformWithMatrix(this.scrollMatrix);\n }\n\n if (\n this.useDirtyBounds &&\n !(\n graphic.isContainer ||\n graphic.attribute.boundsMode === 'empty' ||\n isRectIntersect(graphic.AABBBounds, tempBounds ?? this.dirtyBounds, false)\n )\n ) {\n if (retrans && graphic.parent) {\n const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n this.scrollMatrix && this.scrollMatrix.translate(scrollX, scrollY);\n }\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 if (retrans && graphic.parent) {\n const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n this.scrollMatrix && this.scrollMatrix.translate(scrollX, scrollY);\n }\n\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.afterDrawItem) {\n if (drawContribution.afterDrawItem(graphic, this.currentRenderService, drawContext, this)) {\n return;\n }\n }\n }\n }\n }\n // 根据type选择对应的render\n protected selectRenderByType(type?: string): IGraphicRender | null {\n Logger.getInstance().warn('未知错误,不应该走到这里');\n return null;\n }\n // 根据type选择对应的render\n protected selectRenderByNumberType(type: number, graphic: IGraphic): IGraphicRender | null {\n let data;\n if (graphic.attribute.renderStyle) {\n const currentRenderMap = this.styleRenderMap.get(graphic.attribute.renderStyle);\n data = currentRenderMap && currentRenderMap.get(type);\n }\n return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);\n }\n\n protected clearScreen(renderService: IRenderService, context: IContext2d, drawContext: IDrawContext) {\n const { clear, viewBox } = drawContext;\n // 已经translate过了\n const x = 0;\n const y = 0;\n const width = viewBox.width();\n const height = viewBox.height();\n if (clear) {\n context.clearRect(x, y, width, height);\n if (renderService.drawParams?.stage) {\n renderService.drawParams.stage.hooks.afterClearRect.call(renderService.drawParams);\n }\n const stage = renderService.drawParams?.stage;\n stage && (context.globalAlpha = (stage as any).attribute.opacity ?? 1);\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;AAexF,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,M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Q,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;AAjeY,uBAAuB;IADnC,UAAU,EAAE;IAqBR,WAAA,WAAW,CAAC,aAAa,CAAC,CAAA;IAG1B,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,mBAAmB,CAAC,CAAA;;GAxBlB,uBAAuB,CAienC;SAjeY,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 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/config';\nimport type { IAABBBounds, IBounds, IMatrix } from '@visactor/vutils';\nimport { Bounds, Logger, getRectIntersect, isArray, isRectIntersect } from '@visactor/vutils';\nimport { container } from '../../../container';\nimport { GraphicRender, IncrementalDrawContribution } 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';\nimport { drawBackgroundImage, getBackgroundImage } from './contributions/base-contribution-render';\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 declare scrollMatrix?: IMatrix;\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 if (!isArray(this.contributions)) {\n this.contributions = [this.contributions];\n }\n this.init();\n }\n\n reInit() {\n this.init();\n this.contributions.forEach(item => {\n item.reInit();\n });\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 // 有dirtyBounds用dirtyBounds\n if (drawContext.updateBounds) {\n this.useDirtyBounds = true;\n } else {\n // 没有的话,看看是否需要跳过outRange的渲染\n this.useDirtyBounds = !drawContext.stage.params.optimize.disableCheckGraphicWidthOutRange;\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, viewBox, transMatrix } = 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, viewBox.width(), viewBox.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 // 如果dpr不是整数或者.5的小数,需要格式化dirtyBounds\n const d = context.dpr % 1;\n if (d || d !== 0.5) {\n dirtyBounds.x1 = Math.floor(dirtyBounds.x1 * context.dpr) / context.dpr;\n dirtyBounds.y1 = Math.floor(dirtyBounds.y1 * context.dpr) / context.dpr;\n dirtyBounds.x2 = Math.ceil(dirtyBounds.x2 * context.dpr) / context.dpr;\n dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr;\n }\n this.backupDirtyBounds.copy(dirtyBounds);\n // TODO:不需要设置context.transform,后续translate会设置\n context.reset(false);\n context.save();\n context.setClearMatrix(transMatrix.a, transMatrix.b, transMatrix.c, transMatrix.d, transMatrix.e, transMatrix.f);\n // 初始化context\n context.clearMatrix(false);\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(viewBox.x1, viewBox.y1, true);\n context.beginPath();\n context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height());\n context.clip();\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 if (renderService.drawParams?.stage) {\n renderService.drawParams.stage.hooks.afterClearScreen.call(renderService.drawParams);\n }\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 group.isContainer\n ? this.renderGroup(group as IGroup, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0))\n : this.renderItem(group as IGraphic, drawContext);\n });\n\n // context.restore();\n // context.restore();\n // context.setClearMatrix(1, 0, 0, 1, 0, 0);\n // this.break = false;\n // context.inuse = false;\n context.restore();\n context.draw();\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: IMatrix, 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 (\n this.useDirtyBounds &&\n !isRectIntersect(group.AABBBounds, this.dirtyBounds, false) &&\n group.attribute.boundsMode !== 'empty'\n ) {\n return;\n }\n\n let nextM: IMatrix = parentMatrix;\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 drawContext.isGroupScroll = !!(group.attribute.scrollX || group.attribute.scrollY);\n\n this.renderItem(group, drawContext, {\n renderInGroupParams: {\n skipSort,\n nextM\n },\n renderInGroup: this._renderInGroup\n });\n\n if (this.useDirtyBounds) {\n this.dirtyBounds.copy(tempBounds);\n boundsAllocate.free(tempBounds);\n matrixAllocate.free(nextM);\n }\n }\n\n _renderInGroup = (skipSort: boolean, group: IGroup, drawContext: IDrawContext, nextM: IMatrix) => {\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 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;\n if (!renderer) {\n renderer = this.selectRenderByNumberType(graphic.numberType, graphic);\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 (\n drawContribution.beforeDrawItem &&\n drawContribution.beforeDrawItem(graphic, this.currentRenderService, drawContext, this, params)\n ) {\n return;\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: IBounds;\n\n if (drawContext.isGroupScroll) {\n const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n retrans = true;\n if (!this.scrollMatrix) {\n this.scrollMatrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n }\n this.scrollMatrix.translate(-scrollX, -scrollY);\n }\n // if (graphic.parent) {\n // const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n // if (!!(scrollX || scrollY)) {\n // retrans = true;\n // if (!this.scrollMatrix) {\n // this.scrollMatrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);\n // }\n // this.scrollMatrix.translate(-scrollX, -scrollY);\n // }\n // }\n // 需要二次变化,那就重新算一个变换后的Bounds\n if (retrans) {\n tempBounds = this.dirtyBounds.clone().transformWithMatrix(this.scrollMatrix);\n }\n\n if (\n this.useDirtyBounds &&\n !(\n graphic.isContainer ||\n graphic.attribute.boundsMode === 'empty' ||\n isRectIntersect(graphic.AABBBounds, tempBounds ?? this.dirtyBounds, false)\n )\n ) {\n if (retrans && graphic.parent) {\n const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n this.scrollMatrix && this.scrollMatrix.translate(scrollX, scrollY);\n }\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 if (retrans && graphic.parent) {\n const { scrollX = 0, scrollY = 0 } = graphic.parent.attribute;\n this.scrollMatrix && this.scrollMatrix.translate(scrollX, scrollY);\n }\n\n // 添加拦截器\n if (this.InterceptorContributions.length) {\n for (let i = 0; i < this.InterceptorContributions.length; i++) {\n const drawContribution = this.InterceptorContributions[i];\n if (drawContribution.afterDrawItem) {\n if (drawContribution.afterDrawItem(graphic, this.currentRenderService, drawContext, this)) {\n return;\n }\n }\n }\n }\n }\n // 根据type选择对应的render\n protected selectRenderByType(type?: string): IGraphicRender | null {\n Logger.getInstance().warn('未知错误,不应该走到这里');\n return null;\n }\n // 根据type选择对应的render\n protected selectRenderByNumberType(type: number, graphic: IGraphic): IGraphicRender | null {\n let data;\n if (graphic.attribute.renderStyle) {\n const currentRenderMap = this.styleRenderMap.get(graphic.attribute.renderStyle);\n data = currentRenderMap && currentRenderMap.get(type);\n }\n return data || this.currentRenderMap.get(type) || this.defaultRenderMap.get(type);\n }\n\n protected clearScreen(renderService: IRenderService, context: IContext2d, drawContext: IDrawContext) {\n const { clear, viewBox } = drawContext;\n // 已经translate过了\n const x = 0;\n const y = 0;\n const width = viewBox.width();\n const height = viewBox.height();\n if (clear) {\n context.clearRect(x, y, width, height);\n if (renderService.drawParams?.stage) {\n renderService.drawParams.stage.hooks.afterClearRect.call(renderService.drawParams);\n }\n const stage = renderService.drawParams?.stage;\n if (stage) {\n context.globalAlpha =\n ((stage as any).attribute.opacity ?? 1) * ((stage as any).attribute.backgroundOpacity ?? 1);\n }\n if (stage && (stage as any).backgroundImg && (stage as any).resources) {\n const res = (stage as any).resources.get(getBackgroundImage(clear));\n if (res && res.state === 'success' && res.data) {\n const backgroundBounds = boundsAllocate.allocate(x, y, x + width, y + height);\n drawBackgroundImage(context, res.data, backgroundBounds, {\n backgroundMode: (stage as any).attribute.backgroundMode ?? DefaultAttribute.backgroundMode,\n backgroundFit: (stage as any).attribute.backgroundFit ?? DefaultAttribute.backgroundFit,\n backgroundKeepAspectRatio:\n (stage as any).attribute.backgroundKeepAspectRatio ?? DefaultAttribute.backgroundKeepAspectRatio,\n backgroundScale: (stage as any).attribute.backgroundScale ?? DefaultAttribute.backgroundScale,\n backgroundOffsetX: (stage as any).attribute.backgroundOffsetX ?? DefaultAttribute.backgroundOffsetX,\n backgroundOffsetY: (stage as any).attribute.backgroundOffsetY ?? DefaultAttribute.backgroundOffsetY,\n backgroundPosition: (stage as any).attribute.backgroundPosition ?? DefaultAttribute.backgroundPosition\n });\n boundsAllocate.free(backgroundBounds);\n }\n } else {\n context.fillStyle = createColor(\n context,\n clear as any,\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,5 +1,18 @@
1
- import type { IGraphicAttribute, IContext2d, IMarkAttribute, IImage, IThemeAttribute, IGraphicRender, IImageRenderContribution, IContributionProvider, IDrawContext, IGraphicRenderDrawParams, IRenderService } from '../../../interface';
1
+ import type { IGraphicAttribute, IContext2d, IMarkAttribute, BackgroundSizing, BackgroundMode, IImage, IImageGraphicAttribute, IThemeAttribute, IGraphicRender, IImageRenderContribution, IContributionProvider, IDrawContext, IGraphicRenderDrawParams, IRenderService } from '../../../interface';
2
2
  import { BaseRender } from './base-render';
3
+ export type IImageLayoutDrawParams = Pick<IImageGraphicAttribute, 'repeatX' | 'repeatY' | 'imageMode' | 'imageScale' | 'imageOffsetX' | 'imageOffsetY' | 'imagePosition'>;
4
+ export declare function resolveImageMode({ repeatX, repeatY, imageMode }: Pick<IImageLayoutDrawParams, 'repeatX' | 'repeatY' | 'imageMode'>): {
5
+ repeatMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
6
+ sizingMode: BackgroundSizing;
7
+ };
8
+ export declare function resolveBackgroundParamsByImageSizing(sizingMode: BackgroundSizing): {
9
+ backgroundMode: BackgroundMode;
10
+ backgroundFit: boolean;
11
+ backgroundKeepAspectRatio: boolean;
12
+ };
13
+ export declare function resolveImageRepeatMode(repeatX: IImageGraphicAttribute['repeatX'], repeatY: IImageGraphicAttribute['repeatY']): 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
14
+ export declare function shouldClipImageByLayout({ repeatX, repeatY, imageMode, imageScale, imageOffsetX, imageOffsetY, imagePosition }: IImageLayoutDrawParams): boolean;
15
+ export declare function drawImageWithLayout(context: IContext2d, data: any, x: number, y: number, width: number, height: number, { repeatX, repeatY, imageMode, imageScale, imageOffsetX, imageOffsetY, imagePosition }: IImageLayoutDrawParams): void;
3
16
  export declare class DefaultCanvasImageRender extends BaseRender<IImage> implements IGraphicRender {
4
17
  protected readonly graphicRenderContributions: IContributionProvider<IImageRenderContribution>;
5
18
  type: 'image';