Skip to content

Commit

Permalink
optimize vectormarker event performance when it symbol has function-t…
Browse files Browse the repository at this point in the history
…ype (#2186)
  • Loading branch information
deyihu authored Jan 10, 2024
1 parent e097d5a commit e0ded27
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/renderer/geometry/symbolizers/VectorMarkerSymbolizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getDefaultVAlign, getDefaultHAlign, DEFAULT_MARKER_SYMBOLS } from '../.

const MARKER_SIZE = [];
const TEMP_EXTENT = new PointExtent();
const DEFAULT_ANCHOR = new Point(0, 0);

export default class VectorMarkerSymbolizer extends PointSymbolizer {

Expand Down Expand Up @@ -59,15 +60,26 @@ export default class VectorMarkerSymbolizer extends PointSymbolizer {
_drawMarkers(ctx, cookedPoints, resources) {
for (let i = cookedPoints.length - 1; i >= 0; i--) {
let point = cookedPoints[i];
const size = calVectorMarkerSize(MARKER_SIZE, this.style);
const [width, height] = size;
// const origin = this._rotate(ctx, point, this._getRotationAt(i));
let extent;
const origin = this.getRotation() ? this._rotate(ctx, point, this._getRotationAt(i)) : null;
if (origin) {
const pixel = point.sub(origin);
point = origin;
const rad = this._getRotationAt(i);
extent = getMarkerRotationExtent(TEMP_EXTENT, rad, width, height, point, DEFAULT_ANCHOR);
extent._add(pixel);
}

this._drawVectorMarker(ctx, point, resources);
if (origin) {
ctx.restore();
this._setBBOX(ctx, extent.xmin, extent.ymin, extent.xmax, extent.ymax);
} else {
const { x, y } = point;
this._setBBOX(ctx, x, y, x + width, y + height);
}
}
}
Expand Down

0 comments on commit e0ded27

Please sign in to comment.