Skip to content

Commit

Permalink
Release (#1822)
Browse files Browse the repository at this point in the history
* refactor: support optimize massive attrs clone (#1820)

* refactor: support optimize massive attrs clone

* chore: commit changeset

* chore(release): bump version (#1821)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 7, 2024
1 parent d09378b commit 57fd6ac
Show file tree
Hide file tree
Showing 117 changed files with 773 additions and 106 deletions.
1 change: 1 addition & 0 deletions __tests__/demos/perf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { circles } from './circles';
export { rects } from './rect';
export { image } from './image';
export { attrUpdate } from './attr-update';
export { massiveAttrs } from './massive-attrs';
59 changes: 59 additions & 0 deletions __tests__/demos/perf/massive-attrs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Rect, runtime } from '@antv/g';

export async function massiveAttrs(context) {
const { canvas, gui } = context;

runtime.enableMassiveParsedStyleAssignOptimization = true;

await canvas.ready;

console.time('massiveAttrs');

for (let i = 0; i < 10000; i++) {
const rect = new Rect({
style: {
x: Math.random() * 640,
y: Math.random() * 640,
width: 10 + Math.random() * 40,
height: 10 + Math.random() * 40,
fill: '#1890FF',
stroke: '#F04864',
lineWidth: 4,

// extra attrs
'attr-a': 1,
'attr-b': 2,
'attr-c': 3,
'attr-d': 4,
'attr-e': 5,
'attr-f': 6,
'attr-g': 7,
'attr-h': 8,
'attr-i': 9,
'attr-j': 10,
'attr-k': 11,
'attr-l': 12,
'attr-m': 13,
'attr-n': 14,
'attr-o': 15,
'attr-p': 16,
'attr-q': 17,
'attr-r': 18,
'attr-s': 19,
'attr-t': 20,
'attr-u': 21,
'attr-v': 22,
'attr-w': 23,
'attr-x': 24,
'attr-y': 25,
'attr-z': 26,
},
});

canvas.appendChild(rect);
}

canvas.addEventListener('rerender', () => {
console.timeEnd('massiveAttrs');
});
}
7 changes: 7 additions & 0 deletions packages/g-camera-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-camera-api

## 2.0.21

### Patch Changes

- Updated dependencies [0b639b81]
- @antv/g-lite@2.2.2

## 2.0.20

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-camera-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-camera-api",
"version": "2.0.20",
"version": "2.0.21",
"description": "A simple implementation of Camera API.",
"keywords": [
"antv",
Expand Down
13 changes: 13 additions & 0 deletions packages/g-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @antv/g-canvas

## 2.0.23

### Patch Changes

- Updated dependencies [0b639b81]
- @antv/g-lite@2.2.2
- @antv/g-plugin-canvas-path-generator@2.1.2
- @antv/g-plugin-canvas-picker@2.1.2
- @antv/g-plugin-canvas-renderer@2.2.2
- @antv/g-plugin-dom-interaction@2.1.7
- @antv/g-plugin-html-renderer@2.1.7
- @antv/g-plugin-image-loader@2.1.2

## 2.0.22

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvas",
"version": "2.0.22",
"version": "2.0.23",
"description": "A renderer implemented by Canvas 2D API",
"keywords": [
"antv",
Expand Down
13 changes: 13 additions & 0 deletions packages/g-canvaskit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @antv/g-canvaskit

## 1.0.22

### Patch Changes

- Updated dependencies [0b639b81]
- @antv/g-lite@2.2.2
- @antv/g-plugin-canvas-path-generator@2.1.2
- @antv/g-plugin-canvas-picker@2.1.2
- @antv/g-plugin-canvaskit-renderer@2.1.2
- @antv/g-plugin-dom-interaction@2.1.7
- @antv/g-plugin-html-renderer@2.1.7
- @antv/g-plugin-image-loader@2.1.2

## 1.0.21

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-canvaskit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvaskit",
"version": "1.0.21",
"version": "1.0.22",
"description": "A renderer implemented by CanvasKit",
"keywords": [
"antv",
Expand Down
8 changes: 8 additions & 0 deletions packages/g-components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-components

## 2.0.18

### Patch Changes

- 0b639b81: optimize massive attrs clone
- Updated dependencies [0b639b81]
- @antv/g-lite@2.2.2

## 2.0.17

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-components",
"version": "2.0.17",
"version": "2.0.18",
"description": "Components for g",
"keywords": [
"antv",
Expand Down
13 changes: 13 additions & 0 deletions packages/g-components/src/Arrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ export interface ArrowStyleProps extends BaseStyleProps {
export class Arrow extends CustomElement<ArrowStyleProps> {
static tag = 'arrow';

static PARSED_STYLE_LIST = new Set([
...CustomElement.PARSED_STYLE_LIST,
'body',
'startHead',
'endHead',
'startHeadOffset',
'endHeadOffset',
'stroke',
'lineWidth',
'opacity',
'strokeOpacity',
]);

private body: Line | Path | Polyline;
private startHead?: DisplayObject;
private endHead?: DisplayObject;
Expand Down
11 changes: 11 additions & 0 deletions packages/g-components/src/Sector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ export interface SectorStyleProps extends BaseStyleProps {
}

export class Sector extends CustomElement<SectorStyleProps> {
static PARSED_STYLE_LIST = new Set([
...CustomElement.PARSED_STYLE_LIST,
'startAngle',
'endAngle',
'sr',
'sr0',
'sradius',
'sx',
'sy',
]);

static tag = 'sector';

private path: Path;
Expand Down
11 changes: 11 additions & 0 deletions packages/g-components/src/Sector2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ function computeArcSweep(startAngle: number, endAngle: number) {
}

export class Sector extends Path {
static PARSED_STYLE_LIST = new Set([
...Path.PARSED_STYLE_LIST,
'x',
'y',
'sr',
'sr0',
'radius',
'startAngle',
'endAngle',
]);

// parsedStyle: any;
constructor(config) {
super(config);
Expand Down
7 changes: 7 additions & 0 deletions packages/g-dom-mutation-observer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-dom-mutation-observer-api

## 2.0.18

### Patch Changes

- Updated dependencies [0b639b81]
- @antv/g-lite@2.2.2

## 2.0.17

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-dom-mutation-observer-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-dom-mutation-observer-api",
"version": "2.0.17",
"version": "2.0.18",
"description": "A simple implementation of DOM MutationObserver API.",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-gesture/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-gesture

## 3.0.18

### Patch Changes

- Updated dependencies [0b639b81]
- @antv/g-lite@2.2.2

## 3.0.17

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-gesture/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-gesture",
"version": "3.0.17",
"version": "3.0.18",
"description": "G Gesture",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-image-exporter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-image-exporter

## 1.0.18

### Patch Changes

- Updated dependencies [0b639b81]
- @antv/g-lite@2.2.2

## 1.0.17

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-image-exporter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-image-exporter",
"version": "1.0.17",
"version": "1.0.18",
"description": "A image exporter for G using DOM API",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-lite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-lite

## 2.2.2

### Patch Changes

- 0b639b81: optimize massive attrs clone

## 2.2.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-lite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-lite",
"version": "2.2.1",
"version": "2.2.2",
"description": "A core module for rendering engine implements DOM API.",
"keywords": [
"antv",
Expand Down
21 changes: 19 additions & 2 deletions packages/g-lite/src/css/StyleValueRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { isNil, isUndefined } from '@antv/util';
import { vec3 } from 'gl-matrix';
import type { DisplayObject } from '../display-objects';
import { EMPTY_PARSED_PATH } from '../display-objects/constants';
import type { GlobalRuntime } from '../global-runtime';
import { runtime, type GlobalRuntime } from '../global-runtime';
import { GeometryAABBUpdater } from '../services';
import { AABB } from '../shapes';
import type { BaseStyleProps, Tuple3Number } from '../types';
Expand Down Expand Up @@ -660,7 +660,7 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
const oldClipPath = object.parsedStyle.clipPath;
const oldOffsetPath = object.parsedStyle.offsetPath;

Object.assign(object.parsedStyle, attributes);
assignParsedStyle(object, attributes);

let needUpdateGeometry = !!options.forceUpdateGeometry;
if (!needUpdateGeometry) {
Expand Down Expand Up @@ -1000,3 +1000,20 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
}
}
}

function assignParsedStyle(
object: DisplayObject,
attributes: Record<string, any>,
) {
if (!runtime.enableMassiveParsedStyleAssignOptimization) {
Object.assign(object.parsedStyle, attributes);
return;
}

const list = (object.constructor as typeof DisplayObject).PARSED_STYLE_LIST;
for (const key in attributes) {
if (list.has(key)) {
object.parsedStyle[key] = attributes[key];
}
}
}
10 changes: 10 additions & 0 deletions packages/g-lite/src/display-objects/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ export class Circle extends DisplayObject<
CircleStyleProps,
ParsedCircleStyleProps
> {
static PARSED_STYLE_LIST: Set<string> = new Set([
...DisplayObject.PARSED_STYLE_LIST,
'cx',
'cy',
'cz',
'r',
'isBillboard',
'isSizeAttenuation',
]);

constructor(options: DisplayObjectConfig<CircleStyleProps> = {}) {
super({
type: Shape.CIRCLE,
Expand Down
Loading

0 comments on commit 57fd6ac

Please sign in to comment.