@visactor/vrender-core 0.19.0-alpha.1 → 0.19.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.
- package/cjs/common/text.d.ts +3 -2
- package/cjs/common/text.js +20 -4
- package/cjs/common/text.js.map +1 -1
- package/cjs/core/contributions/env/base-contribution.d.ts +1 -0
- package/cjs/core/contributions/env/base-contribution.js +3 -0
- package/cjs/core/contributions/env/base-contribution.js.map +1 -1
- package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +1 -1
- package/cjs/core/contributions/textMeasure/AtextMeasure.js +8 -4
- package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/cjs/core/global.d.ts +1 -0
- package/cjs/core/global.js +3 -0
- package/cjs/core/global.js.map +1 -1
- package/cjs/core/stage.d.ts +4 -0
- package/cjs/core/stage.js +6 -1
- package/cjs/core/stage.js.map +1 -1
- package/cjs/event/event-manager.js +9 -3
- package/cjs/event/event-manager.js.map +1 -1
- package/cjs/event/event-target.js +0 -2
- package/cjs/event/event-target.js.map +1 -1
- package/cjs/graphic/config.js +4 -0
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/graphic-service/graphic-service.d.ts +1 -0
- package/cjs/graphic/graphic-service/graphic-service.js +23 -5
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +1 -0
- package/cjs/graphic/graphic.js +9 -6
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/rect3d.js +1 -1
- package/cjs/graphic/rect3d.js.map +1 -1
- package/cjs/graphic/richtext/frame.js +9 -9
- package/cjs/graphic/richtext/frame.js.map +1 -1
- package/cjs/graphic/richtext/line.d.ts +2 -2
- package/cjs/graphic/richtext/line.js +9 -6
- package/cjs/graphic/richtext/line.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.d.ts +2 -0
- package/cjs/graphic/richtext/paragraph.js +5 -5
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/graphic/richtext/utils.js +4 -2
- package/cjs/graphic/richtext/utils.js.map +1 -1
- package/cjs/graphic/richtext.d.ts +6 -0
- package/cjs/graphic/richtext.js +16 -4
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/graphic/text.js +1 -1
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/theme.js +0 -2
- package/cjs/graphic/theme.js.map +1 -1
- package/cjs/interface/animate.d.ts +1 -0
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/contribution.d.ts +1 -0
- package/cjs/interface/contribution.js.map +1 -1
- package/cjs/interface/event.d.ts +0 -3
- package/cjs/interface/event.js.map +1 -1
- package/cjs/interface/global.d.ts +2 -0
- package/cjs/interface/global.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +6 -2
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/interface/graphic/theme.d.ts +0 -3
- package/cjs/interface/graphic/theme.js.map +1 -1
- package/cjs/interface/graphic.d.ts +25 -19
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/stage.d.ts +8 -0
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +5 -3
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.d.ts +21 -4
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +116 -54
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/react-attribute-plugin.d.ts +8 -1
- package/cjs/plugins/builtin-plugin/react-attribute-plugin.js +32 -43
- package/cjs/plugins/builtin-plugin/react-attribute-plugin.js.map +1 -1
- package/cjs/render/contributions/render/base-render.js +8 -0
- package/cjs/render/contributions/render/base-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js +4 -2
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/text-contribution-render.js +9 -3
- package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/draw-contribution.js +2 -2
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/draw-interceptor.js +7 -0
- package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
- package/cjs/render/contributions/render/rect3d-render.js +1 -1
- package/cjs/render/contributions/render/rect3d-render.js.map +1 -1
- package/cjs/render/contributions/render/text-render.js +2 -2
- package/cjs/render/contributions/render/text-render.js.map +1 -1
- package/cjs/render/contributions/render/utils.js +1 -1
- package/cjs/render/contributions/render/utils.js.map +1 -1
- package/cjs/render/render-modules.js +1 -1
- package/cjs/render/render-modules.js.map +1 -1
- package/cjs/render/render-service.js +1 -1
- package/cjs/render/render-service.js.map +1 -1
- package/es/common/text.d.ts +3 -2
- package/es/common/text.js +13 -0
- package/es/common/text.js.map +1 -1
- package/es/core/contributions/env/base-contribution.d.ts +1 -0
- package/es/core/contributions/env/base-contribution.js +3 -0
- package/es/core/contributions/env/base-contribution.js.map +1 -1
- package/es/core/contributions/textMeasure/AtextMeasure.d.ts +1 -1
- package/es/core/contributions/textMeasure/AtextMeasure.js +8 -4
- package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/es/core/global.d.ts +1 -0
- package/es/core/global.js +3 -0
- package/es/core/global.js.map +1 -1
- package/es/core/stage.d.ts +4 -0
- package/es/core/stage.js +6 -1
- package/es/core/stage.js.map +1 -1
- package/es/event/event-manager.js +9 -3
- package/es/event/event-manager.js.map +1 -1
- package/es/event/event-target.js +0 -2
- package/es/event/event-target.js.map +1 -1
- package/es/graphic/config.js +4 -0
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/graphic-service/graphic-service.d.ts +1 -0
- package/es/graphic/graphic-service/graphic-service.js +23 -8
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/graphic/graphic.d.ts +1 -0
- package/es/graphic/graphic.js +9 -6
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/rect3d.js +1 -1
- package/es/graphic/rect3d.js.map +1 -1
- package/es/graphic/richtext/frame.js +9 -9
- package/es/graphic/richtext/frame.js.map +1 -1
- package/es/graphic/richtext/line.d.ts +2 -2
- package/es/graphic/richtext/line.js +9 -6
- package/es/graphic/richtext/line.js.map +1 -1
- package/es/graphic/richtext/paragraph.d.ts +2 -0
- package/es/graphic/richtext/paragraph.js +5 -5
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/graphic/richtext/utils.js +4 -2
- package/es/graphic/richtext/utils.js.map +1 -1
- package/es/graphic/richtext.d.ts +6 -0
- package/es/graphic/richtext.js +16 -4
- package/es/graphic/richtext.js.map +1 -1
- package/es/graphic/text.js +1 -1
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/theme.js +1 -3
- package/es/graphic/theme.js.map +1 -1
- package/es/interface/animate.d.ts +1 -0
- package/es/interface/animate.js.map +1 -1
- package/es/interface/contribution.d.ts +1 -0
- package/es/interface/contribution.js.map +1 -1
- package/es/interface/event.d.ts +0 -3
- package/es/interface/event.js.map +1 -1
- package/es/interface/global.d.ts +2 -0
- package/es/interface/global.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +6 -2
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/interface/graphic/theme.d.ts +0 -3
- package/es/interface/graphic/theme.js.map +1 -1
- package/es/interface/graphic.d.ts +25 -19
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/stage.d.ts +8 -0
- package/es/interface/stage.js.map +1 -1
- package/es/plugins/builtin-plugin/flex-layout-plugin.js +5 -3
- package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/html-attribute-plugin.d.ts +21 -4
- package/es/plugins/builtin-plugin/html-attribute-plugin.js +117 -54
- package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/react-attribute-plugin.d.ts +8 -1
- package/es/plugins/builtin-plugin/react-attribute-plugin.js +32 -42
- package/es/plugins/builtin-plugin/react-attribute-plugin.js.map +1 -1
- package/es/render/contributions/render/base-render.js +8 -0
- package/es/render/contributions/render/base-render.js.map +1 -1
- package/es/render/contributions/render/contributions/rect-contribution-render.js +4 -2
- package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/text-contribution-render.js +9 -3
- package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.js +2 -2
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/draw-interceptor.js +7 -0
- package/es/render/contributions/render/draw-interceptor.js.map +1 -1
- package/es/render/contributions/render/rect3d-render.js +1 -1
- package/es/render/contributions/render/rect3d-render.js.map +1 -1
- package/es/render/contributions/render/text-render.js +2 -2
- package/es/render/contributions/render/text-render.js.map +1 -1
- package/es/render/contributions/render/utils.js +1 -1
- package/es/render/contributions/render/utils.js.map +1 -1
- package/es/render/render-modules.js +1 -1
- package/es/render/render-modules.js.map +1 -1
- package/es/render/render-service.js +1 -1
- package/es/render/render-service.js.map +1 -1
- package/package.json +4 -4
|
@@ -4,60 +4,50 @@ import { application } from "../../application";
|
|
|
4
4
|
|
|
5
5
|
import { HtmlAttributePlugin } from "./html-attribute-plugin";
|
|
6
6
|
|
|
7
|
+
import { isNil } from "@visactor/vutils";
|
|
8
|
+
|
|
7
9
|
export class ReactAttributePlugin extends HtmlAttributePlugin {
|
|
8
10
|
constructor() {
|
|
9
11
|
super(...arguments), this.name = "ReactAttributePlugin", this.activeEvent = "onRegister",
|
|
10
|
-
this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid;
|
|
12
|
+
this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid, this.htmlMap = {};
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
removeElement(id) {
|
|
15
|
+
if (!this.htmlMap || !this.htmlMap[id]) return;
|
|
16
|
+
const {root: root, wrapContainer: wrapContainer} = this.htmlMap[id];
|
|
17
|
+
if (root) {
|
|
18
|
+
application.global.getRequestAnimationFrame()((() => {
|
|
19
|
+
root.unmount();
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
wrapContainer && application.global.removeDom(wrapContainer), this.htmlMap[id] = null;
|
|
16
23
|
}
|
|
17
24
|
renderGraphicHTML(graphic) {
|
|
25
|
+
var _a;
|
|
18
26
|
const {react: react} = graphic.attribute;
|
|
19
|
-
if (!react) return
|
|
20
|
-
item.root && item.root.unmount();
|
|
21
|
-
})), graphic.bindDom.clear()));
|
|
27
|
+
if (!react) return;
|
|
22
28
|
const stage = graphic.stage;
|
|
23
29
|
if (!stage) return;
|
|
24
|
-
const ReactDOM = stage.params.ReactDOM, {element: element, container: container
|
|
30
|
+
const ReactDOM = stage.params.ReactDOM, {element: element, container: container} = react;
|
|
25
31
|
if (!(element && ReactDOM && ReactDOM.createRoot)) return;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
tagName: "div",
|
|
37
|
-
width: width,
|
|
38
|
-
height: height,
|
|
39
|
-
style: style,
|
|
40
|
-
parent: nativeContainer
|
|
41
|
-
}), wrapGroup) {
|
|
42
|
-
const root = ReactDOM.createRoot(wrapGroup);
|
|
43
|
-
root.render(element), graphic.bindDom.set(element, {
|
|
44
|
-
dom: element,
|
|
32
|
+
const id = isNil(react.id) ? `${null !== (_a = graphic.id) && void 0 !== _a ? _a : graphic._uid}_react` : react.id;
|
|
33
|
+
if (this.htmlMap && this.htmlMap[id] && container && container !== this.htmlMap[id].container && this.removeElement(id),
|
|
34
|
+
this.htmlMap && this.htmlMap[id]) this.htmlMap[id].root.render(element); else {
|
|
35
|
+
const {wrapContainer: wrapContainer, nativeContainer: nativeContainer} = this.getWrapContainer(stage, container);
|
|
36
|
+
if (wrapContainer) {
|
|
37
|
+
const root = ReactDOM.createRoot(wrapContainer);
|
|
38
|
+
root.render(element), this.htmlMap || (this.htmlMap = {}), this.htmlMap[id] = {
|
|
39
|
+
root: root,
|
|
40
|
+
wrapContainer: wrapContainer,
|
|
41
|
+
nativeContainer: nativeContainer,
|
|
45
42
|
container: container,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
43
|
+
renderId: this.renderId
|
|
44
|
+
};
|
|
49
45
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
nativeContainer
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if ("position" === anchorType || b.empty()) {
|
|
56
|
-
const matrix = graphic.globalTransMatrix;
|
|
57
|
-
left = matrix.e, top = matrix.f;
|
|
58
|
-
} else left = b.x1, top = b.y1;
|
|
59
|
-
const containerTL = application.global.getElementTopLeft(nativeContainer, !1), windowTL = stage.window.getTopLeft(!1), offsetX = left + windowTL.left - containerTL.left, offsetTop = top + windowTL.top - containerTL.top;
|
|
60
|
-
wrapGroup.style.left = `${offsetX}px`, wrapGroup.style.top = `${offsetTop}px`;
|
|
46
|
+
}
|
|
47
|
+
if (!this.htmlMap || !this.htmlMap[id]) return;
|
|
48
|
+
const {wrapContainer: wrapContainer, nativeContainer: nativeContainer} = this.htmlMap[id];
|
|
49
|
+
this.updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, react),
|
|
50
|
+
this.htmlMap[id].renderId = this.renderId;
|
|
61
51
|
}
|
|
62
52
|
}
|
|
63
53
|
//# sourceMappingURL=react-attribute-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/builtin-plugin/react-attribute-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3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S,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;aACjG;SACF;aAAM;YAEL,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SACvC;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;YACtC,OAAO;SACR;QAED,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAE5D,IAAI,CAAC,0BAA0B,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC;QACvF,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC5C,CAAC;CACF","file":"react-attribute-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport type { IGraphic, IPlugin, IPluginService } from '../../interface';\nimport { application } from '../../application';\nimport { HtmlAttributePlugin } from './html-attribute-plugin';\nimport { isNil } from '@visactor/vutils';\n\nexport class ReactAttributePlugin extends HtmlAttributePlugin implements IPlugin {\n name: 'ReactAttributePlugin' = 'ReactAttributePlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n htmlMap: Record<\n string,\n {\n root: any;\n wrapContainer: HTMLElement;\n nativeContainer: HTMLElement;\n container: string | HTMLElement | null;\n renderId: number;\n }\n > = {};\n\n removeElement(id: string) {\n if (!this.htmlMap || !this.htmlMap[id]) {\n return;\n }\n\n const { root, wrapContainer } = this.htmlMap[id];\n\n if (root) {\n const raf = application.global.getRequestAnimationFrame();\n raf(() => {\n root.unmount();\n });\n }\n\n wrapContainer && application.global.removeDom(wrapContainer);\n\n this.htmlMap[id] = null;\n }\n\n renderGraphicHTML(graphic: IGraphic) {\n const { react } = graphic.attribute;\n if (!react) {\n return;\n }\n const stage = graphic.stage;\n if (!stage) {\n return;\n }\n const ReactDOM = stage.params.ReactDOM;\n const { element, container } = react;\n if (!(element && ReactDOM && ReactDOM.createRoot)) {\n return;\n }\n const id = isNil(react.id) ? `${graphic.id ?? graphic._uid}_react` : react.id;\n\n if (this.htmlMap && this.htmlMap[id] && container && container !== this.htmlMap[id].container) {\n this.removeElement(id);\n }\n\n if (!this.htmlMap || !this.htmlMap[id]) {\n // createa a wrapper contianer to be the root of react element\n const { wrapContainer, nativeContainer } = this.getWrapContainer(stage, container);\n\n if (wrapContainer) {\n const root = ReactDOM.createRoot(wrapContainer);\n root.render(element);\n\n if (!this.htmlMap) {\n this.htmlMap = {};\n }\n\n this.htmlMap[id] = { root, wrapContainer, nativeContainer, container, renderId: this.renderId };\n }\n } else {\n // update react element\n this.htmlMap[id].root.render(element);\n }\n\n if (!this.htmlMap || !this.htmlMap[id]) {\n return;\n }\n\n const { wrapContainer, nativeContainer } = this.htmlMap[id];\n\n this.updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, react);\n this.htmlMap[id].renderId = this.renderId;\n }\n}\n"]}
|
|
@@ -23,11 +23,17 @@ export class BaseRender {
|
|
|
23
23
|
}
|
|
24
24
|
beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
25
25
|
this._beforeRenderContribitions && this._beforeRenderContribitions.forEach((c => {
|
|
26
|
+
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
27
|
+
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [ c.supportedAppName ]).includes(graphic.stage.params.context.appName)) return;
|
|
28
|
+
}
|
|
26
29
|
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
27
30
|
}));
|
|
28
31
|
}
|
|
29
32
|
afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
30
33
|
this._afterRenderContribitions && this._afterRenderContribitions.forEach((c => {
|
|
34
|
+
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
35
|
+
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [ c.supportedAppName ]).includes(graphic.stage.params.context.appName)) return;
|
|
36
|
+
}
|
|
31
37
|
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
32
38
|
}));
|
|
33
39
|
}
|
|
@@ -89,6 +95,8 @@ export class BaseRender {
|
|
|
89
95
|
_draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
|
|
90
96
|
const {context: context} = drawContext;
|
|
91
97
|
if (!context) return;
|
|
98
|
+
const {renderable: renderable} = graphic.attribute;
|
|
99
|
+
if (!1 === renderable) return;
|
|
92
100
|
context.highPerformanceSave();
|
|
93
101
|
const data = this.transform(graphic, defaultAttr, context, computed3dMatrix), {x: x, y: y, z: z, lastModelMatrix: lastModelMatrix} = data;
|
|
94
102
|
this.z = z, drawPathProxy(graphic, context, x, y, drawContext, params) || (this.drawShape(graphic, context, x, y, drawContext, params),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/base-render.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,MAAM,GAAsD,E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,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CAsHF","file":"base-render.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { injectable } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n ICamera,\n IContext2d,\n IGraphic,\n mat4,\n IRenderService,\n IDrawContext,\n IGraphicRenderDrawParams,\n IMarkAttribute,\n IThemeAttribute,\n IContributionProvider,\n ICircleRenderContribution,\n IBaseRenderContribution\n} from '../../../interface';\nimport { getModelMatrix, multiplyMat4Mat4, shouldUseMat4 } from '../../../graphic';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { BaseRenderContributionTime } from '../../../common/enums';\n\nconst result: IPointLike & { z: number; lastModelMatrix: mat4 } = { x: 0, y: 0, z: 0, lastModelMatrix: null };\n\nexport abstract class BaseRender<T extends IGraphic> {\n camera: ICamera;\n declare z: number;\n\n builtinContributions: IBaseRenderContribution<T, T['attribute']>[];\n\n // declare renderContribitions: IContributionProvider<IBaseRenderContribution<T, T['attribute']>> | null;\n\n protected _beforeRenderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n protected _afterRenderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n protected _renderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n\n init(contributions?: IContributionProvider<IBaseRenderContribution<T, T['attribute']>>) {\n if (contributions) {\n // this.renderContribitions = contributions;\n this._renderContribitions = contributions.getContributions();\n }\n if (!this._renderContribitions) {\n this._renderContribitions = [];\n }\n this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item));\n if (this._renderContribitions.length) {\n this._renderContribitions.sort((a, b) => b.order - a.order);\n this._beforeRenderContribitions = this._renderContribitions.filter(\n c => c.time === BaseRenderContributionTime.beforeFillStroke\n );\n this._afterRenderContribitions = this._renderContribitions.filter(\n c => c.time === BaseRenderContributionTime.afterFillStroke\n );\n }\n }\n\n beforeRenderStep(\n graphic: T,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<T['attribute']>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n params?: any\n ) {\n this._beforeRenderContribitions &&\n this._beforeRenderContribitions.forEach(c => {\n c.drawShape(\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 params\n );\n });\n }\n\n afterRenderStep(\n graphic: T,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<T['attribute']>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n params?: any\n ) {\n this._afterRenderContribitions &&\n this._afterRenderContribitions.forEach(c => {\n c.drawShape(\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 params\n );\n });\n }\n\n valid(graphic: IGraphic, defaultAttribute: IGraphicAttribute, fillCb?: any, strokeCb?: any) {\n const {\n fill = defaultAttribute.fill,\n background,\n stroke = defaultAttribute.stroke,\n opacity = defaultAttribute.opacity,\n fillOpacity = defaultAttribute.fillOpacity,\n lineWidth = defaultAttribute.lineWidth,\n strokeOpacity = defaultAttribute.strokeOpacity,\n visible = defaultAttribute.visible\n } = graphic.attribute;\n const fVisible = fillVisible(opacity, fillOpacity, fill);\n const sVisible = strokeVisible(opacity, strokeOpacity);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(graphic.valid && visible)) {\n return false;\n }\n\n if (!(doFill || doStroke)) {\n return false;\n }\n\n // 如果存在fillCb和strokeCb,以及background那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return false;\n }\n return {\n fVisible,\n sVisible,\n doFill,\n doStroke\n };\n }\n\n /**\n * 进行2d或3d变换\n * @param graphic\n * @param graphicAttribute\n * @param context\n * @param use3dMatrixIn3dMode 是否在3d模式使用3d矩阵\n * @returns\n */\n transform(\n graphic: IGraphic,\n graphicAttribute: IGraphicAttribute,\n context: IContext2d,\n use3dMatrixIn3dMode: boolean = false\n ): IPointLike & { z: number; lastModelMatrix: mat4 } {\n // const transMatrix = graphic.transMatrix;\n const {\n x = graphicAttribute.x,\n y = graphicAttribute.y,\n z = graphicAttribute.z,\n scaleX = graphicAttribute.scaleX,\n scaleY = graphicAttribute.scaleY,\n angle = graphicAttribute.angle,\n postMatrix\n } = graphic.attribute;\n // const onlyTranslate = transMatrix.onlyTranslate() && !postMatrix;\n\n // 存在3d变换的时候,需要计算3d矩阵\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n // const result: IPointLike & { z: number; lastModelMatrix: mat4 } = { x, y, z, lastModelMatrix };\n result.x = x;\n result.y = y;\n result.z = z;\n result.lastModelMatrix = lastModelMatrix;\n\n // 是否应该进行3d变换\n const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic));\n\n // 是否仅有translate\n const onlyTranslate = shouldTransform3d\n ? graphic.transMatrix.onlyTranslate() && !postMatrix\n : scaleX === 1 && scaleY === 1 && angle === 0 && !postMatrix;\n\n if (shouldTransform3d) {\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, graphic, graphicAttribute);\n // 合并模型矩阵\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n result.x = 0;\n result.y = 0;\n result.z = 0;\n context.modelMatrix = nextModelMatrix;\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n mat4Allocate.free(modelMatrix);\n // 有旋转的情况下需要手动计算模型矩阵\n // TODO: 这里暂时都使用模型矩阵,因为视角旋转的时候如果当不固定角度那也需要用到模型矩阵\n }\n\n // 如果只有位移,且没计算3d变换矩阵,那么不设置context的2d矩阵\n if (onlyTranslate && !lastModelMatrix) {\n const point = graphic.getOffsetXY(graphicAttribute);\n result.x += point.x;\n result.y += point.y;\n result.z = z;\n // 当前context有rotate/scale,重置matrix\n context.setTransformForCurrent();\n } else if (shouldTransform3d) {\n // 如果计算了3d矩阵,那么就不需要2d矩阵计算了\n result.x = 0;\n result.y = 0;\n result.z = 0;\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n if (camera && context.project) {\n const point = graphic.getOffsetXY(graphicAttribute);\n result.x += point.x;\n result.y += point.y;\n // result.x = 0;\n // result.y = 0;\n // 位置直接通过project设置,而2d变换通过变换矩阵完成\n this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);\n } else {\n // 如果是纯2d的情况,那么直接设置context的2d矩阵\n // 性能较差\n context.transformFromMatrix(graphic.transMatrix, true);\n result.x = 0;\n result.y = 0;\n result.z = 0;\n }\n }\n\n return result;\n }\n\n /**\n * 将3d的transform转成context2d的transform\n * @param graphic\n * @param graphicAttribute\n * @param z\n * @param context\n */\n transformUseContext2d(graphic: IGraphic, graphicAttribute: IGraphicAttribute, z: number, context: IContext2d) {\n const camera = context.camera;\n this.camera = camera;\n if (camera) {\n const bounds = graphic.AABBBounds;\n const width = bounds.x2 - bounds.x1;\n const height = bounds.y2 - bounds.y1;\n const p1 = context.project(0, 0, z);\n const p2 = context.project(width, 0, z);\n const p3 = context.project(width, height, z);\n const _p1 = { x: 0, y: 0 };\n const _p2 = { x: width, y: 0 };\n const _p3 = { x: width, y: height };\n\n context.camera = null;\n\n // 生成3维矩阵\n /* Adapted from phoria.js by ecomfe\n * https://github.com/kevinroast/phoria.js\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/kevinroast/phoria.js/blob/736c6b854a679df180f8a6e689aeb218efa6dc01/scripts/phoria-renderer.js\n * License: https://github.com/kevinroast/phoria.js/blob/master/LICENSE\n * @license\n */\n const denom = 1.0 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y);\n // calculate context transformation matrix\n const m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom;\n const m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom;\n const m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom;\n const m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom;\n const dx =\n (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) +\n _p1.y * (_p2.x * p3.x - _p3.x * p2.x) +\n (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) *\n denom;\n const dy =\n (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) +\n _p1.y * (_p2.x * p3.y - _p3.x * p2.y) +\n (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) *\n denom;\n\n context.setTransform(m11, m12, m21, m22, dx, dy, true);\n }\n }\n\n /**\n * transformUseContext2d的后处理\n * @param graphic\n * @param graphicAttribute\n * @param z\n * @param context\n */\n restoreTransformUseContext2d(graphic: IGraphic, graphicAttribute: IGraphicAttribute, z: number, context: IContext2d) {\n if (this.camera) {\n context.camera = this.camera;\n }\n }\n\n protected transformWithoutTranslate(\n context: IContext2d,\n x: number,\n y: number,\n z: number,\n scaleX: number,\n scaleY: number,\n angle: number\n ) {\n const p = context.project(x, y, z);\n context.translate(p.x, p.y, false);\n context.scale(scaleX, scaleY, false);\n context.rotate(angle, false);\n context.translate(-p.x, -p.y, false);\n context.setTransformForCurrent();\n }\n\n _draw(\n graphic: T,\n defaultAttr: IGraphicAttribute,\n computed3dMatrix: boolean,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n context.highPerformanceSave();\n\n const data = this.transform(graphic, defaultAttr, context, computed3dMatrix);\n const { x, y, z, lastModelMatrix } = data;\n\n this.z = z;\n if (drawPathProxy(graphic, context, x, y, drawContext, params)) {\n context.highPerformanceRestore();\n return;\n }\n\n this.drawShape(graphic, context, x, y, drawContext, params);\n this.z = 0;\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.highPerformanceRestore();\n }\n\n drawShape?(\n path: T,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ): void;\n\n // abstract drawShape(\n // graphic: T,\n // context: IContext2d,\n // x: number,\n // y: number,\n // drawContext: IDrawContext,\n // params?: IGraphicRenderDrawParams,\n // fillCb?: (\n // ctx: IContext2d,\n // markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n // themeAttribute: IThemeAttribute\n // ) => boolean,\n // strokeCb?: (\n // ctx: IContext2d,\n // markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n // themeAttribute: IThemeAttribute\n // ) => boolean\n // ): void;\n\n // drawPathProxy(\n // graphic: T,\n // context: IContext2d,\n // x: number,\n // y: number,\n // drawContext: IDrawContext,\n // params?: IGraphicRenderDrawParams,\n // fillCb?: (\n // ctx: IContext2d,\n // markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n // themeAttribute: IThemeAttribute\n // ) => boolean,\n // strokeCb?: (\n // ctx: IContext2d,\n // markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n // themeAttribute: IThemeAttribute\n // ) => boolean\n // ) {\n // if (!graphic.pathProxy) {\n // return false;\n // }\n\n // const themeAttributes = getTheme(graphic)[graphic.type];\n\n // const {\n // fill = themeAttributes.fill == null ? !!graphic.attribute.fillColor : themeAttributes.fill,\n // stroke = themeAttributes.stroke == null ? !!graphic.attribute.strokeColor : themeAttributes.stroke,\n // opacity = themeAttributes.opacity,\n // fillOpacity = themeAttributes.fillOpacity,\n // lineWidth = themeAttributes.lineWidth,\n // strokeOpacity = themeAttributes.strokeOpacity,\n // visible = themeAttributes.visible\n // } = graphic.attribute;\n // // 不绘制或者透明\n // const fVisible = fillVisible(opacity, fillOpacity);\n // const sVisible = strokeVisible(opacity, strokeOpacity);\n // const doFill = runFill(fill);\n // const doStroke = runStroke(stroke, lineWidth);\n\n // if (!visible) {\n // return true;\n // }\n\n // if (!(doFill || doStroke)) {\n // return true;\n // }\n\n // // 如果存在fillCb和strokeCb,那就不直接跳过\n // if (!(fVisible || sVisible || fillCb || strokeCb)) {\n // return true;\n // }\n\n // context.beginPath();\n\n // const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;\n // renderCommandList(path.commandList, context, x, y);\n\n // // shadow\n // context.setShadowBlendStyle && context.setShadowBlendStyle(graphic, graphic.attribute, themeAttributes);\n\n // if (doStroke) {\n // if (strokeCb) {\n // strokeCb(context, graphic.attribute, themeAttributes);\n // } else if (sVisible) {\n // context.setStrokeStyle(graphic, graphic.attribute, 0, 0, themeAttributes);\n // context.stroke();\n // }\n // }\n // if (doFill) {\n // if (fillCb) {\n // fillCb(context, graphic.attribute, themeAttributes);\n // } else if (fVisible) {\n // context.setCommonStyle(graphic, graphic.attribute, 0, 0, themeAttributes);\n // context.fill();\n // }\n // }\n // return true;\n // }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/base-render.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,MAAM,GAAsD,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AAE9G,MAAM,OAAgB,UAAU;IAY9B,IAAI,CAAC,aAAiF;QACpF,IAAI,aAAa,EAAE;YAEjB,IAAI,CAAC,oBAAoB,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;SAC9D;QACD,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC9B,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;SAChC;QACD,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7G,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM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AS,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAC7E,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;QAE1C,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE;YAC9D,OAAO,CAAC,sBAAsB,EAAE,CAAC;YACjC,OAAO;SACR;QAED,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAEX,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CAsHF","file":"base-render.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { injectable } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n ICamera,\n IContext2d,\n IGraphic,\n mat4,\n IRenderService,\n IDrawContext,\n IGraphicRenderDrawParams,\n IMarkAttribute,\n IThemeAttribute,\n IContributionProvider,\n ICircleRenderContribution,\n IBaseRenderContribution\n} from '../../../interface';\nimport { getModelMatrix, multiplyMat4Mat4, shouldUseMat4 } from '../../../graphic';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { BaseRenderContributionTime } from '../../../common/enums';\n\nconst result: IPointLike & { z: number; lastModelMatrix: mat4 } = { x: 0, y: 0, z: 0, lastModelMatrix: null };\n\nexport abstract class BaseRender<T extends IGraphic> {\n camera: ICamera;\n declare z: number;\n\n builtinContributions: IBaseRenderContribution<T, T['attribute']>[];\n\n // declare renderContribitions: IContributionProvider<IBaseRenderContribution<T, T['attribute']>> | null;\n\n protected _beforeRenderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n protected _afterRenderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n protected _renderContribitions: IBaseRenderContribution<T, T['attribute']>[];\n\n init(contributions?: IContributionProvider<IBaseRenderContribution<T, T['attribute']>>) {\n if (contributions) {\n // this.renderContribitions = contributions;\n this._renderContribitions = contributions.getContributions();\n }\n if (!this._renderContribitions) {\n this._renderContribitions = [];\n }\n this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item));\n if (this._renderContribitions.length) {\n this._renderContribitions.sort((a, b) => b.order - a.order);\n this._beforeRenderContribitions = this._renderContribitions.filter(\n c => c.time === BaseRenderContributionTime.beforeFillStroke\n );\n this._afterRenderContribitions = this._renderContribitions.filter(\n c => c.time === BaseRenderContributionTime.afterFillStroke\n );\n }\n }\n\n beforeRenderStep(\n graphic: T,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<T['attribute']>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n params?: any\n ) {\n this._beforeRenderContribitions &&\n this._beforeRenderContribitions.forEach(c => {\n if (\n c.supportedAppName &&\n graphic.stage &&\n graphic.stage.params &&\n graphic.stage.params.context &&\n graphic.stage.params.context.appName\n ) {\n const names = Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName];\n if (!names.includes(graphic.stage.params.context.appName)) {\n return;\n }\n }\n c.drawShape(\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 params\n );\n });\n }\n\n afterRenderStep(\n graphic: T,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<T['attribute']>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n params?: any\n ) {\n this._afterRenderContribitions &&\n this._afterRenderContribitions.forEach(c => {\n if (\n c.supportedAppName &&\n graphic.stage &&\n graphic.stage.params &&\n graphic.stage.params.context &&\n graphic.stage.params.context.appName\n ) {\n const names = Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName];\n if (!names.includes(graphic.stage.params.context.appName)) {\n return;\n }\n }\n c.drawShape(\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 params\n );\n });\n }\n\n valid(graphic: IGraphic, defaultAttribute: IGraphicAttribute, fillCb?: any, strokeCb?: any) {\n const {\n fill = defaultAttribute.fill,\n background,\n stroke = defaultAttribute.stroke,\n opacity = defaultAttribute.opacity,\n fillOpacity = defaultAttribute.fillOpacity,\n lineWidth = defaultAttribute.lineWidth,\n strokeOpacity = defaultAttribute.strokeOpacity,\n visible = defaultAttribute.visible\n } = graphic.attribute;\n const fVisible = fillVisible(opacity, fillOpacity, fill);\n const sVisible = strokeVisible(opacity, strokeOpacity);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(graphic.valid && visible)) {\n return false;\n }\n\n if (!(doFill || doStroke)) {\n return false;\n }\n\n // 如果存在fillCb和strokeCb,以及background那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return false;\n }\n return {\n fVisible,\n sVisible,\n doFill,\n doStroke\n };\n }\n\n /**\n * 进行2d或3d变换\n * @param graphic\n * @param graphicAttribute\n * @param context\n * @param use3dMatrixIn3dMode 是否在3d模式使用3d矩阵\n * @returns\n */\n transform(\n graphic: IGraphic,\n graphicAttribute: IGraphicAttribute,\n context: IContext2d,\n use3dMatrixIn3dMode: boolean = false\n ): IPointLike & { z: number; lastModelMatrix: mat4 } {\n // const transMatrix = graphic.transMatrix;\n const {\n x = graphicAttribute.x,\n y = graphicAttribute.y,\n z = graphicAttribute.z,\n scaleX = graphicAttribute.scaleX,\n scaleY = graphicAttribute.scaleY,\n angle = graphicAttribute.angle,\n postMatrix\n } = graphic.attribute;\n // const onlyTranslate = transMatrix.onlyTranslate() && !postMatrix;\n\n // 存在3d变换的时候,需要计算3d矩阵\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n // const result: IPointLike & { z: number; lastModelMatrix: mat4 } = { x, y, z, lastModelMatrix };\n result.x = x;\n result.y = y;\n result.z = z;\n result.lastModelMatrix = lastModelMatrix;\n\n // 是否应该进行3d变换\n const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic));\n\n // 是否仅有translate\n const onlyTranslate = shouldTransform3d\n ? graphic.transMatrix.onlyTranslate() && !postMatrix\n : scaleX === 1 && scaleY === 1 && angle === 0 && !postMatrix;\n\n if (shouldTransform3d) {\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, graphic, graphicAttribute);\n // 合并模型矩阵\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n result.x = 0;\n result.y = 0;\n result.z = 0;\n context.modelMatrix = nextModelMatrix;\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n mat4Allocate.free(modelMatrix);\n // 有旋转的情况下需要手动计算模型矩阵\n // TODO: 这里暂时都使用模型矩阵,因为视角旋转的时候如果当不固定角度那也需要用到模型矩阵\n }\n\n // 如果只有位移,且没计算3d变换矩阵,那么不设置context的2d矩阵\n if (onlyTranslate && !lastModelMatrix) {\n const point = graphic.getOffsetXY(graphicAttribute);\n result.x += point.x;\n result.y += point.y;\n result.z = z;\n // 当前context有rotate/scale,重置matrix\n context.setTransformForCurrent();\n } else if (shouldTransform3d) {\n // 如果计算了3d矩阵,那么就不需要2d矩阵计算了\n result.x = 0;\n result.y = 0;\n result.z = 0;\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n if (camera && context.project) {\n const point = graphic.getOffsetXY(graphicAttribute);\n result.x += point.x;\n result.y += point.y;\n // result.x = 0;\n // result.y = 0;\n // 位置直接通过project设置,而2d变换通过变换矩阵完成\n this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);\n } else {\n // 如果是纯2d的情况,那么直接设置context的2d矩阵\n // 性能较差\n context.transformFromMatrix(graphic.transMatrix, true);\n result.x = 0;\n result.y = 0;\n result.z = 0;\n }\n }\n\n return result;\n }\n\n /**\n * 将3d的transform转成context2d的transform\n * @param graphic\n * @param graphicAttribute\n * @param z\n * @param context\n */\n transformUseContext2d(graphic: IGraphic, graphicAttribute: IGraphicAttribute, z: number, context: IContext2d) {\n const camera = context.camera;\n this.camera = camera;\n if (camera) {\n const bounds = graphic.AABBBounds;\n const width = bounds.x2 - bounds.x1;\n const height = bounds.y2 - bounds.y1;\n const p1 = context.project(0, 0, z);\n const p2 = context.project(width, 0, z);\n const p3 = context.project(width, height, z);\n const _p1 = { x: 0, y: 0 };\n const _p2 = { x: width, y: 0 };\n const _p3 = { x: width, y: height };\n\n context.camera = null;\n\n // 生成3维矩阵\n /* Adapted from phoria.js by ecomfe\n * https://github.com/kevinroast/phoria.js\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/kevinroast/phoria.js/blob/736c6b854a679df180f8a6e689aeb218efa6dc01/scripts/phoria-renderer.js\n * License: https://github.com/kevinroast/phoria.js/blob/master/LICENSE\n * @license\n */\n const denom = 1.0 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y);\n // calculate context transformation matrix\n const m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom;\n const m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom;\n const m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom;\n const m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom;\n const dx =\n (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) +\n _p1.y * (_p2.x * p3.x - _p3.x * p2.x) +\n (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) *\n denom;\n const dy =\n (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) +\n _p1.y * (_p2.x * p3.y - _p3.x * p2.y) +\n (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) *\n denom;\n\n context.setTransform(m11, m12, m21, m22, dx, dy, true);\n }\n }\n\n /**\n * transformUseContext2d的后处理\n * @param graphic\n * @param graphicAttribute\n * @param z\n * @param context\n */\n restoreTransformUseContext2d(graphic: IGraphic, graphicAttribute: IGraphicAttribute, z: number, context: IContext2d) {\n if (this.camera) {\n context.camera = this.camera;\n }\n }\n\n protected transformWithoutTranslate(\n context: IContext2d,\n x: number,\n y: number,\n z: number,\n scaleX: number,\n scaleY: number,\n angle: number\n ) {\n const p = context.project(x, y, z);\n context.translate(p.x, p.y, false);\n context.scale(scaleX, scaleY, false);\n context.rotate(angle, false);\n context.translate(-p.x, -p.y, false);\n context.setTransformForCurrent();\n }\n\n _draw(\n graphic: T,\n defaultAttr: IGraphicAttribute,\n computed3dMatrix: boolean,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n // 如果hide,直接跳过后续绘制\n const { renderable } = graphic.attribute;\n if (renderable === false) {\n return;\n }\n\n context.highPerformanceSave();\n\n const data = this.transform(graphic, defaultAttr, context, computed3dMatrix);\n const { x, y, z, lastModelMatrix } = data;\n\n this.z = z;\n if (drawPathProxy(graphic, context, x, y, drawContext, params)) {\n context.highPerformanceRestore();\n return;\n }\n\n this.drawShape(graphic, context, x, y, drawContext, params);\n this.z = 0;\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.highPerformanceRestore();\n }\n\n drawShape?(\n path: T,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ): void;\n\n // abstract drawShape(\n // graphic: T,\n // context: IContext2d,\n // x: number,\n // y: number,\n // drawContext: IDrawContext,\n // params?: IGraphicRenderDrawParams,\n // fillCb?: (\n // ctx: IContext2d,\n // markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n // themeAttribute: IThemeAttribute\n // ) => boolean,\n // strokeCb?: (\n // ctx: IContext2d,\n // markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n // themeAttribute: IThemeAttribute\n // ) => boolean\n // ): void;\n\n // drawPathProxy(\n // graphic: T,\n // context: IContext2d,\n // x: number,\n // y: number,\n // drawContext: IDrawContext,\n // params?: IGraphicRenderDrawParams,\n // fillCb?: (\n // ctx: IContext2d,\n // markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n // themeAttribute: IThemeAttribute\n // ) => boolean,\n // strokeCb?: (\n // ctx: IContext2d,\n // markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n // themeAttribute: IThemeAttribute\n // ) => boolean\n // ) {\n // if (!graphic.pathProxy) {\n // return false;\n // }\n\n // const themeAttributes = getTheme(graphic)[graphic.type];\n\n // const {\n // fill = themeAttributes.fill == null ? !!graphic.attribute.fillColor : themeAttributes.fill,\n // stroke = themeAttributes.stroke == null ? !!graphic.attribute.strokeColor : themeAttributes.stroke,\n // opacity = themeAttributes.opacity,\n // fillOpacity = themeAttributes.fillOpacity,\n // lineWidth = themeAttributes.lineWidth,\n // strokeOpacity = themeAttributes.strokeOpacity,\n // visible = themeAttributes.visible\n // } = graphic.attribute;\n // // 不绘制或者透明\n // const fVisible = fillVisible(opacity, fillOpacity);\n // const sVisible = strokeVisible(opacity, strokeOpacity);\n // const doFill = runFill(fill);\n // const doStroke = runStroke(stroke, lineWidth);\n\n // if (!visible) {\n // return true;\n // }\n\n // if (!(doFill || doStroke)) {\n // return true;\n // }\n\n // // 如果存在fillCb和strokeCb,那就不直接跳过\n // if (!(fVisible || sVisible || fillCb || strokeCb)) {\n // return true;\n // }\n\n // context.beginPath();\n\n // const path = typeof graphic.pathProxy === 'function' ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;\n // renderCommandList(path.commandList, context, x, y);\n\n // // shadow\n // context.setShadowBlendStyle && context.setShadowBlendStyle(graphic, graphic.attribute, themeAttributes);\n\n // if (doStroke) {\n // if (strokeCb) {\n // strokeCb(context, graphic.attribute, themeAttributes);\n // } else if (sVisible) {\n // context.setStrokeStyle(graphic, graphic.attribute, 0, 0, themeAttributes);\n // context.stroke();\n // }\n // }\n // if (doFill) {\n // if (fillCb) {\n // fillCb(context, graphic.attribute, themeAttributes);\n // } else if (fVisible) {\n // context.setCommonStyle(graphic, graphic.attribute, 0, 0, themeAttributes);\n // context.fill();\n // }\n // }\n // return true;\n // }\n}\n"]}
|
|
@@ -73,8 +73,10 @@ let SplitRectAfterRenderContribution = class {
|
|
|
73
73
|
this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
|
|
74
74
|
}
|
|
75
75
|
drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb) {
|
|
76
|
-
const {
|
|
77
|
-
|
|
76
|
+
const {x1: x1, y1: y1, x: originX = groupAttribute.x, y: originY = groupAttribute.y, stroke: stroke = groupAttribute.stroke} = rect.attribute;
|
|
77
|
+
let {width: width, height: height} = rect.attribute;
|
|
78
|
+
if (width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0,
|
|
79
|
+
Array.isArray(stroke) && stroke.some((s => !1 === s))) {
|
|
78
80
|
if (context.setStrokeStyle(rect, rect.attribute, x, y, groupAttribute), context.beginPath(),
|
|
79
81
|
context.moveTo(x, y), stroke[0] ? context.lineTo(x + width, y) : context.moveTo(x + width, y),
|
|
80
82
|
stroke[1] ? context.lineTo(x + width, y + height) : context.moveTo(x + width, y + height),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/contributions/rect-contribution-render.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAW/D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CA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C,CAAC,CAAC,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SACvC;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SACvC;QAED,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SAC/B;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SAC/B;QAED,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YAEb,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1D,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SAC5B;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACtB;QAED,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;CACF,CAAA;AAtEY,gCAAgC;IAD5C,UAAU,EAAE;GACA,gCAAgC,CAsE5C;SAtEY,gCAAgC;AAwE7C,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,6BAA6B,EAAE,CAAC;AAGjF,MAAM,CAAC,MAAM,oCAAoC,GAAG,oCAAoC,CAAC;AACzF,MAAM,CAAC,MAAM,uCAAuC,GAAG,uCAAuC,CAAC","file":"rect-contribution-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { injectable } from '../../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IRect,\n IRectGraphicAttribute,\n IThemeAttribute,\n IRectRenderContribution,\n IDrawContext\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultRectRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const { outerBorder, innerBorder } = rect.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n const {\n cornerRadius = rectAttribute.cornerRadius,\n opacity = rectAttribute.opacity,\n x: originX = rectAttribute.x,\n y: originY = rectAttribute.y,\n scaleX = rectAttribute.scaleX,\n scaleY = rectAttribute.scaleY,\n x1,\n y1\n } = rect.attribute;\n\n let { width, height } = rect.attribute;\n\n width = (width ?? x1 - x) || 0;\n height = (height ?? y1 - y) || 0;\n\n const doStrokeOuter = !!(outerBorder && outerBorder.stroke);\n const doStrokeInner = !!(innerBorder && innerBorder.stroke);\n\n if (doOuterBorder) {\n const { distance = rectAttribute.outerBorder.distance } = outerBorder;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const nextX = x - d;\n const nextY = y - d;\n const dw = d * 2;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(nextX, nextY, width + dw, height + dw);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, nextX, nextY, width + dw, height + dw, cornerRadius);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n if (strokeCb) {\n strokeCb(context, outerBorder, rectAttribute.outerBorder);\n } else if (doStrokeOuter) {\n // 存在stroke\n const lastOpacity = (rectAttribute.outerBorder as any).opacity;\n (rectAttribute.outerBorder as any).opacity = opacity;\n context.setStrokeStyle(\n rect,\n outerBorder,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n rectAttribute.outerBorder as any\n );\n (rectAttribute.outerBorder as any).opacity = lastOpacity;\n context.stroke();\n }\n }\n\n if (doInnerBorder) {\n const { distance = rectAttribute.innerBorder.distance } = innerBorder;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const nextX = x + d;\n const nextY = y + d;\n const dw = d * 2;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(nextX, nextY, width - dw, height - dw);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, nextX, nextY, width - dw, height - dw, cornerRadius);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n if (strokeCb) {\n strokeCb(context, innerBorder, rectAttribute.innerBorder);\n } else if (doStrokeInner) {\n // 存在stroke\n const lastOpacity = (rectAttribute.innerBorder as any).opacity;\n (rectAttribute.innerBorder as any).opacity = opacity;\n context.setStrokeStyle(\n rect,\n innerBorder,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n rectAttribute.innerBorder as any\n );\n (rectAttribute.innerBorder as any).opacity = lastOpacity;\n context.stroke();\n }\n }\n }\n}\n\n@injectable()\nexport class SplitRectBeforeRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n group: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n doFillOrStroke?: { doFill: boolean; doStroke: boolean }\n ) {\n const { stroke = groupAttribute.stroke } = group.attribute as any;\n\n // 数组且存在为false的项目,那就不绘制\n if (Array.isArray(stroke) && stroke.some(s => s === false)) {\n doFillOrStroke.doStroke = false;\n }\n }\n}\n\n@injectable()\nexport class SplitRectAfterRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const {\n width = groupAttribute.width,\n height = groupAttribute.height,\n stroke = groupAttribute.stroke\n } = rect.attribute as any;\n\n // 不是数组\n if (!(Array.isArray(stroke) && stroke.some(s => s === false))) {\n return;\n }\n\n context.setStrokeStyle(rect, rect.attribute, x, y, groupAttribute);\n // 单独处理每条边界,目前不考虑圆角\n context.beginPath();\n context.moveTo(x, y);\n // top\n if (stroke[0]) {\n context.lineTo(x + width, y);\n } else {\n context.moveTo(x + width, y);\n }\n // right\n if (stroke[1]) {\n context.lineTo(x + width, y + height);\n } else {\n context.moveTo(x + width, y + height);\n }\n // bottom\n if (stroke[2]) {\n context.lineTo(x, y + height);\n } else {\n context.moveTo(x, y + height);\n }\n // left\n if (stroke[3]) {\n // 没有close path是,起点和终点不连续,需要调整y保证不出现缺口\n const adjustY = stroke[0] ? y - context.lineWidth / 2 : y;\n context.lineTo(x, adjustY);\n } else {\n context.moveTo(x, y);\n }\n\n context.stroke();\n }\n}\n\nexport const defaultRectRenderContribution = new DefaultRectRenderContribution();\n// export const splitRectBeforeRenderContribution = new SplitRectBeforeRenderContribution();\n// export const splitRectAfterRenderContribution = new SplitRectAfterRenderContribution();\nexport const defaultRectTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultRectBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/contributions/rect-contribution-render.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAW/D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,MAAM,OAAO,6BAA6B;IAA1C;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E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AAM,uCAAuC,GAAG,uCAAuC,CAAC","file":"rect-contribution-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { injectable } from '../../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IRect,\n IRectGraphicAttribute,\n IThemeAttribute,\n IRectRenderContribution,\n IDrawContext\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultRectRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const { outerBorder, innerBorder } = rect.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n const {\n cornerRadius = rectAttribute.cornerRadius,\n opacity = rectAttribute.opacity,\n x: originX = rectAttribute.x,\n y: originY = rectAttribute.y,\n scaleX = rectAttribute.scaleX,\n scaleY = rectAttribute.scaleY,\n x1,\n y1\n } = rect.attribute;\n\n let { width, height } = rect.attribute;\n\n width = (width ?? x1 - x) || 0;\n height = (height ?? y1 - y) || 0;\n\n const doStrokeOuter = !!(outerBorder && outerBorder.stroke);\n const doStrokeInner = !!(innerBorder && innerBorder.stroke);\n\n if (doOuterBorder) {\n const { distance = rectAttribute.outerBorder.distance } = outerBorder;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const nextX = x - d;\n const nextY = y - d;\n const dw = d * 2;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(nextX, nextY, width + dw, height + dw);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, nextX, nextY, width + dw, height + dw, cornerRadius);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n if (strokeCb) {\n strokeCb(context, outerBorder, rectAttribute.outerBorder);\n } else if (doStrokeOuter) {\n // 存在stroke\n const lastOpacity = (rectAttribute.outerBorder as any).opacity;\n (rectAttribute.outerBorder as any).opacity = opacity;\n context.setStrokeStyle(\n rect,\n outerBorder,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n rectAttribute.outerBorder as any\n );\n (rectAttribute.outerBorder as any).opacity = lastOpacity;\n context.stroke();\n }\n }\n\n if (doInnerBorder) {\n const { distance = rectAttribute.innerBorder.distance } = innerBorder;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const nextX = x + d;\n const nextY = y + d;\n const dw = d * 2;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(nextX, nextY, width - dw, height - dw);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, nextX, nextY, width - dw, height - dw, cornerRadius);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n if (strokeCb) {\n strokeCb(context, innerBorder, rectAttribute.innerBorder);\n } else if (doStrokeInner) {\n // 存在stroke\n const lastOpacity = (rectAttribute.innerBorder as any).opacity;\n (rectAttribute.innerBorder as any).opacity = opacity;\n context.setStrokeStyle(\n rect,\n innerBorder,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n rectAttribute.innerBorder as any\n );\n (rectAttribute.innerBorder as any).opacity = lastOpacity;\n context.stroke();\n }\n }\n }\n}\n\n@injectable()\nexport class SplitRectBeforeRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n group: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n doFillOrStroke?: { doFill: boolean; doStroke: boolean }\n ) {\n const { stroke = groupAttribute.stroke } = group.attribute as any;\n\n // 数组且存在为false的项目,那就不绘制\n if (Array.isArray(stroke) && stroke.some(s => s === false)) {\n doFillOrStroke.doStroke = false;\n }\n }\n}\n\n@injectable()\nexport class SplitRectAfterRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n const {\n x1,\n y1,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y,\n stroke = groupAttribute.stroke\n } = rect.attribute as any;\n\n let { width, height } = rect.attribute;\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n // 不是数组\n if (!(Array.isArray(stroke) && stroke.some(s => s === false))) {\n return;\n }\n\n context.setStrokeStyle(rect, rect.attribute, x, y, groupAttribute);\n // 单独处理每条边界,目前不考虑圆角\n context.beginPath();\n context.moveTo(x, y);\n // top\n if (stroke[0]) {\n context.lineTo(x + width, y);\n } else {\n context.moveTo(x + width, y);\n }\n // right\n if (stroke[1]) {\n context.lineTo(x + width, y + height);\n } else {\n context.moveTo(x + width, y + height);\n }\n // bottom\n if (stroke[2]) {\n context.lineTo(x, y + height);\n } else {\n context.moveTo(x, y + height);\n }\n // left\n if (stroke[3]) {\n // 没有close path是,起点和终点不连续,需要调整y保证不出现缺口\n const adjustY = stroke[0] ? y - context.lineWidth / 2 : y;\n context.lineTo(x, adjustY);\n } else {\n context.moveTo(x, y);\n }\n\n context.stroke();\n }\n}\n\nexport const defaultRectRenderContribution = new DefaultRectRenderContribution();\n// export const splitRectBeforeRenderContribution = new SplitRectBeforeRenderContribution();\n// export const splitRectAfterRenderContribution = new SplitRectAfterRenderContribution();\nexport const defaultRectTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultRectBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
|
|
@@ -17,8 +17,14 @@ 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
|
|
20
|
+
let matrix, {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());
|
|
22
28
|
const shouldReCalBounds = isObject(background) && background.background, onlyTranslate = graphic.transMatrix.onlyTranslate();
|
|
23
29
|
if (shouldReCalBounds) {
|
|
24
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();
|
|
@@ -38,7 +44,7 @@ export class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgrou
|
|
|
38
44
|
})).clone());
|
|
39
45
|
if (graphic.backgroundImg && graphic.resources) {
|
|
40
46
|
const res = graphic.resources.get(background);
|
|
41
|
-
if ("success" !== res.state || !res.data) return;
|
|
47
|
+
if ("success" !== res.state || !res.data) return void restore();
|
|
42
48
|
context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0),
|
|
43
49
|
context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit),
|
|
44
50
|
context.highPerformanceRestore(), context.setTransformForCurrent();
|
|
@@ -48,7 +54,7 @@ export class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgrou
|
|
|
48
54
|
context.fillStyle = background, backgroundCornerRadius ? (createRectPath(context, b.x1, b.y1, b.width(), b.height(), backgroundCornerRadius),
|
|
49
55
|
context.fill()) : context.fillRect(b.x1, b.y1, b.width(), b.height()), context.highPerformanceRestore();
|
|
50
56
|
}
|
|
51
|
-
shouldReCalBounds && boundsAllocate.free(b);
|
|
57
|
+
shouldReCalBounds && boundsAllocate.free(b), restore();
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
|
|
@@ -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,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,OAAO,uCACX,SAAQ,uCAAuC;IADjD;;QAIE,SAAI,GAA+B,0BAA0B,CAAC,gBAAgB,CAAC;
|
|
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,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,OAAO,uCACX,SAAQ,u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3E,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"]}
|
|
@@ -78,8 +78,8 @@ let DefaultDrawContribution = class {
|
|
|
78
78
|
return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
|
|
79
79
|
})).forEach((group => {
|
|
80
80
|
group.isContainer ? this.renderGroup(group, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0)) : this.renderItem(group, drawContext);
|
|
81
|
-
})), context.restore(), context.
|
|
82
|
-
context.
|
|
81
|
+
})), context.restore(), context.setClearMatrix(1, 0, 0, 1, 0, 0), context.inuse = !1,
|
|
82
|
+
context.draw();
|
|
83
83
|
}
|
|
84
84
|
doRegister() {
|
|
85
85
|
throw new Error("暂不支持");
|