Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix VectorLayer render Performance issues #2450

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/renderer/layer/vectorlayer/VectorLayerCanvasRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as vec3 from '../../../core/util/vec3';
import Canvas from '../../../core/Canvas';
import type { Painter, CollectionPainter } from '../../geometry';
import { Point } from '../../../geo';
import { Geometries } from '../../../geometry';
import { Geometries, Marker } from '../../../geometry';
import type { WithUndef } from '../../../types/typings';

const TEMP_EXTENT = new PointExtent();
Expand Down Expand Up @@ -70,19 +70,9 @@ class VectorLayerRenderer extends OverlayLayerCanvasRenderer {
setToRedraw(): this {
super.setToRedraw();
this._resetProgressiveRender();
this._resetGeosCollisionState();
return this;
}

_resetGeosCollisionState() {
const geos = this.layer._geoList || [];
for (let i = 0, len = geos.length; i < len; i++) {
const geo = geos[i];
if (geo.isPoint) {
geo._collided = false;
}
}
}

//@internal
_geoIsCollision(geo: GeoType, collisionIndex: any) {
Expand Down Expand Up @@ -378,20 +368,32 @@ class VectorLayerRenderer extends OverlayLayerCanvasRenderer {

//@internal
_collidesGeos() {
const geos = this._geosToDraw;
const collision = this.layer.options['collision'];
if (!collision) {
//reset points _collided
for (let i = 0, len = geos.length; i < len; i++) {
const geo = geos[i];
if (geo.isPoint) {
(geo as Marker)._collided = false;
}
}
return this;
}
const collisionScope = this.layer.options['collisionScope'];
const collisionIndex = this.layer.getCollisionIndex();
if (collisionScope === 'layer') {
collisionIndex.clear();
}
const geos = this._geosToDraw;
this._geosToDraw = [];
for (let i = 0, len = geos.length; i < len; i++) {
if (this._geoIsCollision(geos[i], collisionIndex)) {
continue;
const geo = geos[i];
if (geo.isPoint) {
(geo as Marker)._collided = false;
if (this._geoIsCollision(geo, collisionIndex)) {
(geo as Marker)._collided = true;
continue;
}
}
this._geosToDraw.push(geos[i]);
}
Expand Down