Simplify custom circle rendering

This commit is contained in:
Andreas Hocevar
2020-12-18 23:27:11 +01:00
committed by changqing
parent 3393de3c54
commit c4f5709349
3 changed files with 9 additions and 28 deletions

View File

@@ -303,7 +303,10 @@ class CanvasBuilder extends VectorContext {
renderer,
inflateCoordinatesArray,
]);
} else if (type == GeometryType.LINE_STRING) {
} else if (
type == GeometryType.LINE_STRING ||
type == GeometryType.CIRCLE
) {
flatCoordinates = geometry.getFlatCoordinates();
builderEnd = this.appendFlatLineCoordinates(
flatCoordinates,
@@ -345,26 +348,6 @@ class CanvasBuilder extends VectorContext {
geometry,
renderer,
]);
} else if (type == GeometryType.CIRCLE) {
const flatCoordinates = geometry.getFlatCoordinates();
this.appendFlatLineCoordinates(
flatCoordinates,
0,
flatCoordinates.length,
stride,
false,
false
);
builderEnd = this.coordinates.length;
this.instructions.push([
CanvasInstruction.CUSTOM,
builderBegin,
builderEnd,
geometry,
renderer,
undefined,
4,
]);
}
this.endGeometry(feature);
}

View File

@@ -731,7 +731,6 @@ class Executor {
const geometry = /** @type {import("../../geom/SimpleGeometry.js").default} */ (instruction[3]);
const renderer = instruction[4];
const fn = instruction.length == 6 ? instruction[5] : undefined;
const coordsLength = instruction.length >= 7 ? instruction[6] : 2;
state.geometry = geometry;
state.feature = feature;
if (!(i in coordinateCache)) {
@@ -741,10 +740,9 @@ class Executor {
if (fn) {
fn(pixelCoordinates, d, dd, 2, coords);
} else {
for (let index = 0; index < coordsLength; index++) {
coords[index] = pixelCoordinates[d + index];
}
coords.length = coordsLength;
coords[0] = pixelCoordinates[d];
coords[1] = pixelCoordinates[d + 1];
coords.length = 2;
}
renderer(coords, state);
++i;