@visactor/vrender-core 0.18.14-alpha.0 → 0.19.0-alpha.1

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 (53) hide show
  1. package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +1 -1
  2. package/cjs/core/contributions/textMeasure/AtextMeasure.js +4 -8
  3. package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  4. package/cjs/core/stage.js +1 -2
  5. package/cjs/core/stage.js.map +1 -1
  6. package/cjs/event/event-manager.js +3 -9
  7. package/cjs/event/event-manager.js.map +1 -1
  8. package/cjs/event/event-target.js +2 -0
  9. package/cjs/event/event-target.js.map +1 -1
  10. package/cjs/graphic/graphic-service/graphic-service.js +2 -5
  11. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  12. package/cjs/graphic/graphic.d.ts +0 -1
  13. package/cjs/graphic/graphic.js +6 -9
  14. package/cjs/graphic/graphic.js.map +1 -1
  15. package/cjs/graphic/text.js +1 -1
  16. package/cjs/graphic/text.js.map +1 -1
  17. package/cjs/interface/animate.d.ts +0 -1
  18. package/cjs/interface/animate.js.map +1 -1
  19. package/cjs/interface/event.d.ts +3 -0
  20. package/cjs/interface/event.js.map +1 -1
  21. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +2 -4
  22. package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  23. package/cjs/render/contributions/render/contributions/text-contribution-render.js +3 -9
  24. package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  25. package/cjs/render/render-service.js +1 -1
  26. package/cjs/render/render-service.js.map +1 -1
  27. package/es/core/contributions/textMeasure/AtextMeasure.d.ts +1 -1
  28. package/es/core/contributions/textMeasure/AtextMeasure.js +4 -8
  29. package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  30. package/es/core/stage.js +1 -2
  31. package/es/core/stage.js.map +1 -1
  32. package/es/event/event-manager.js +3 -9
  33. package/es/event/event-manager.js.map +1 -1
  34. package/es/event/event-target.js +2 -0
  35. package/es/event/event-target.js.map +1 -1
  36. package/es/graphic/graphic-service/graphic-service.js +2 -5
  37. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  38. package/es/graphic/graphic.d.ts +0 -1
  39. package/es/graphic/graphic.js +6 -9
  40. package/es/graphic/graphic.js.map +1 -1
  41. package/es/graphic/text.js +1 -1
  42. package/es/graphic/text.js.map +1 -1
  43. package/es/interface/animate.d.ts +0 -1
  44. package/es/interface/animate.js.map +1 -1
  45. package/es/interface/event.d.ts +3 -0
  46. package/es/interface/event.js.map +1 -1
  47. package/es/plugins/builtin-plugin/flex-layout-plugin.js +2 -4
  48. package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
  49. package/es/render/contributions/render/contributions/text-contribution-render.js +3 -9
  50. package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  51. package/es/render/render-service.js +1 -1
  52. package/es/render/render-service.js.map +1 -1
  53. package/package.json +3 -3
@@ -17,14 +17,8 @@ export class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgrou
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
19
  const {backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit} = graphic.attribute;
20
- let matrix, {background: background} = graphic.attribute;
20
+ let b, {background: background} = graphic.attribute;
21
21
  if (!background) return;
22
- const restore = () => {
23
- "richtext" === graphic.type && (context.restore(), context.save(), matrix && context.setTransformFromMatrix(matrix, !0, 1));
24
- };
25
- let b;
26
- "richtext" === graphic.type && (matrix = context.currentMatrix.clone(), context.restore(),
27
- context.save(), context.setTransformForCurrent());
28
22
  const shouldReCalBounds = isObject(background) && background.background, onlyTranslate = graphic.transMatrix.onlyTranslate();
29
23
  if (shouldReCalBounds) {
30
24
  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();
@@ -44,7 +38,7 @@ export class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgrou
44
38
  })).clone());
45
39
  if (graphic.backgroundImg && graphic.resources) {
46
40
  const res = graphic.resources.get(background);
47
- if ("success" !== res.state || !res.data) return void restore();
41
+ if ("success" !== res.state || !res.data) return;
48
42
  context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0),
49
43
  context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit),
50
44
  context.highPerformanceRestore(), context.setTransformForCurrent();
@@ -54,7 +48,7 @@ export class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgrou
54
48
  context.fillStyle = background, backgroundCornerRadius ? (createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius),
55
49
  context.fill()) : context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
56
50
  }
57
- shouldReCalBounds && boundsAllocate.free(b), restore();
51
+ shouldReCalBounds && boundsAllocate.free(b);
58
52
  }
59
53
  }
60
54
 
@@ -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,O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EAAE,CAAC;YAC9B,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;YAC3E,OAAO,CAAC,SAAS,GAAG,UAAoB,CAAC;YACzC,IAAI,sBAAsB,EAAE;gBAE1B,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,sBAAsB,CAAC,CAAC;gBACnF,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, IMatrixLike } 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';\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 { backgroundMode = graphicAttribute.backgroundMode, backgroundFit = graphicAttribute.backgroundFit } =\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);\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n } else {\n const { backgroundCornerRadius } = graphic.attribute;\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\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);\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,E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AAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACxB;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uCAAuC,GAAG,IAAI,uCAAuC,EAAE,CAAC","file":"text-contribution-render.js","sourcesContent":["import type { IAABBBounds } 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';\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 { backgroundMode = graphicAttribute.backgroundMode, backgroundFit = graphicAttribute.backgroundFit } =\n graphic.attribute;\n let { background } = graphic.attribute;\n if (!background) {\n return;\n }\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 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);\n context.highPerformanceRestore();\n context.setTransformForCurrent();\n } else {\n const { backgroundCornerRadius } = graphic.attribute;\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\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);\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 }\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"]}
@@ -47,7 +47,7 @@ let DefaultRenderService = class {
47
47
  this.renderTreeRoots = groups, this.drawParams = params;
48
48
  const updateBounds = params.updateBounds;
49
49
  this.prepare(updateBounds), this.prepareRenderList(), this.beforeDraw(params), this.draw(params),
50
- this.afterDraw(params), this.drawParams = null;
50
+ this.afterDraw(params);
51
51
  }
52
52
  };
53
53
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/render-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAO1E,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAO/B,YAEmB,gBAAmC;QAAnC,qBAAgB,GAAhB,gBAAgB,CAAmB;IACnD,CAAC;IAGJ,OAAO,CAAC,YAAqB;QAG3B,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;SACR;QACD,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAC/B,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IACS,QAAQ,CAAC,CAAW,EAAE,YAAqB;QACnD,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE;YACpB,IAAI,CAAC,QAAQ,CAAC,CAAa,EAAE,YAAY,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,iBAAiB;QACf,OAAO;IACT,CAAC;IAED,UAAU,CAAC,MAAgC;QACzC,OAAO;IACT,CAAC;IAED,IAAI,CAAC,MAAgC;QACnC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,oBAAO,IAAI,CAAC,UAAU,EAAG,CAAC;IAC3D,CAAC;IAED,SAAS,CAAC,MAAgC;QACxC,IAAI,CAAC,gBAAgB,CAAC,SAAS,IAAI,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,oBAAO,IAAI,CAAC,UAAU,EAAG,CAAC;QACjG,OAAO;IACT,CAAC;IAED,MAAM,CAAC,MAAgB,EAAE,MAAgC;QACvD,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAEzB,CAAC;CACF,CAAA;AA5DY,oBAAoB;IADhC,UAAU,EAAE;IASR,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;;GARhB,oBAAoB,CA4DhC;SA5DY,oBAAoB","file":"render-service.js","sourcesContent":["import { injectable, inject } from '../common/inversify-lite';\nimport type { IAABBBounds, IBounds } from '@visactor/vutils';\nimport type { IGroup, IGraphic, IRenderService, IRenderServiceDrawParams, IDrawContribution } from '../interface';\nimport { DrawContribution } from './contributions/render';\n\nexport const RenderService = Symbol.for('RenderService');\nexport const BeforeRenderConstribution = Symbol.for('BeforeRenderConstribution');\n\n/**\n * 渲染用的service,通常和stage一一绑定,\n * 并不是单例模式,所以会绑定此次渲染的一些数据\n */\n@injectable()\nexport class DefaultRenderService implements IRenderService {\n // 每次render都会变的数据\n dirtyBounds: IBounds;\n renderTreeRoots: IGraphic[]; // 此次render的数组\n renderLists: IGraphic[];\n drawParams: IRenderServiceDrawParams;\n\n constructor(\n @inject(DrawContribution)\n private readonly drawContribution: IDrawContribution\n ) {}\n\n // 渲染前准备工作,计算bounds等逻辑\n prepare(updateBounds: boolean): void {\n // 如果不需要计算Bounds,那么transMatrix也不需要计算\n // TODO 后期可能存在依赖transMatrix的插件,但目前不存在\n if (!updateBounds) {\n return;\n }\n this.renderTreeRoots.forEach(g => {\n this._prepare(g, updateBounds);\n });\n return;\n }\n protected _prepare(g: IGraphic, updateBounds: boolean) {\n g.forEachChildren(g => {\n this._prepare(g as IGraphic, updateBounds);\n });\n g.update({ bounds: updateBounds, trans: true });\n }\n // 获取要渲染的list,可能存在一些不用渲染的内容,以及外描边\n prepareRenderList(): void {\n return;\n }\n // 渲染前流程\n beforeDraw(params: IRenderServiceDrawParams): void {\n return;\n }\n // 具体渲染\n draw(params: IRenderServiceDrawParams): void {\n this.drawContribution.draw(this, { ...this.drawParams });\n }\n // 渲染后流程\n afterDraw(params: IRenderServiceDrawParams): void {\n this.drawContribution.afterDraw && this.drawContribution.afterDraw(this, { ...this.drawParams });\n return;\n }\n // 对外暴露的绘制方法\n render(groups: IGroup[], params: IRenderServiceDrawParams): void {\n this.renderTreeRoots = groups;\n this.drawParams = params;\n const updateBounds = params.updateBounds;\n this.prepare(updateBounds);\n this.prepareRenderList();\n this.beforeDraw(params);\n this.draw(params);\n this.afterDraw(params);\n this.drawParams = null;\n // this.renderTreeRoots = [];\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/render-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EAAE,gB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AgB,EAAE,MAAgC;QACvD,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;CACF,CAAA;AA1DY,oBAAoB;IADhC,UAAU,EAAE;IASR,WAAA,MAAM,CAAC,gBAAgB,CAAC,CAAA;;GARhB,oBAAoB,CA0DhC;SA1DY,oBAAoB","file":"render-service.js","sourcesContent":["import { injectable, inject } from '../common/inversify-lite';\nimport type { IAABBBounds, IBounds } from '@visactor/vutils';\nimport type { IGroup, IGraphic, IRenderService, IRenderServiceDrawParams, IDrawContribution } from '../interface';\nimport { DrawContribution } from './contributions/render';\n\nexport const RenderService = Symbol.for('RenderService');\nexport const BeforeRenderConstribution = Symbol.for('BeforeRenderConstribution');\n\n/**\n * 渲染用的service,通常和stage一一绑定,\n * 并不是单例模式,所以会绑定此次渲染的一些数据\n */\n@injectable()\nexport class DefaultRenderService implements IRenderService {\n // 每次render都会变的数据\n dirtyBounds: IBounds;\n renderTreeRoots: IGraphic[]; // 此次render的数组\n renderLists: IGraphic[];\n drawParams: IRenderServiceDrawParams;\n\n constructor(\n @inject(DrawContribution)\n private readonly drawContribution: IDrawContribution\n ) {}\n\n // 渲染前准备工作,计算bounds等逻辑\n prepare(updateBounds: boolean): void {\n // 如果不需要计算Bounds,那么transMatrix也不需要计算\n // TODO 后期可能存在依赖transMatrix的插件,但目前不存在\n if (!updateBounds) {\n return;\n }\n this.renderTreeRoots.forEach(g => {\n this._prepare(g, updateBounds);\n });\n return;\n }\n protected _prepare(g: IGraphic, updateBounds: boolean) {\n g.forEachChildren(g => {\n this._prepare(g as IGraphic, updateBounds);\n });\n g.update({ bounds: updateBounds, trans: true });\n }\n // 获取要渲染的list,可能存在一些不用渲染的内容,以及外描边\n prepareRenderList(): void {\n return;\n }\n // 渲染前流程\n beforeDraw(params: IRenderServiceDrawParams): void {\n return;\n }\n // 具体渲染\n draw(params: IRenderServiceDrawParams): void {\n this.drawContribution.draw(this, { ...this.drawParams });\n }\n // 渲染后流程\n afterDraw(params: IRenderServiceDrawParams): void {\n this.drawContribution.afterDraw && this.drawContribution.afterDraw(this, { ...this.drawParams });\n return;\n }\n // 对外暴露的绘制方法\n render(groups: IGroup[], params: IRenderServiceDrawParams): void {\n this.renderTreeRoots = groups;\n this.drawParams = params;\n const updateBounds = params.updateBounds;\n this.prepare(updateBounds);\n this.prepareRenderList();\n this.beforeDraw(params);\n this.draw(params);\n this.afterDraw(params);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-core",
3
- "version": "0.18.14-alpha.0",
3
+ "version": "0.19.0-alpha.1",
4
4
  "description": "",
5
5
  "sideEffects": [
6
6
  "./src/modules.ts",
@@ -35,8 +35,8 @@
35
35
  "vite": "3.2.6",
36
36
  "typescript": "4.9.5",
37
37
  "@internal/bundler": "0.0.1",
38
- "@internal/eslint-config": "0.0.1",
39
- "@internal/ts-config": "0.0.1"
38
+ "@internal/ts-config": "0.0.1",
39
+ "@internal/eslint-config": "0.0.1"
40
40
  },
41
41
  "keywords": [
42
42
  "VisActor",