Merge pull request #9260 from fredj/rm_geom_param

Remove unused 'geometry' param from ol/render/canvas/Builder
This commit is contained in:
Frédéric Junod
2019-02-25 08:25:06 +01:00
committed by GitHub
5 changed files with 33 additions and 38 deletions
+8 -12
View File
@@ -206,7 +206,7 @@ class CanvasBuilder extends VectorContext {
* @inheritDoc. * @inheritDoc.
*/ */
drawCustom(geometry, feature, renderer) { drawCustom(geometry, feature, renderer) {
this.beginGeometry(geometry, feature); this.beginGeometry(feature);
const type = geometry.getType(); const type = geometry.getType();
const stride = geometry.getStride(); const stride = geometry.getStride();
const builderBegin = this.coordinates.length; const builderBegin = this.coordinates.length;
@@ -248,15 +248,14 @@ class CanvasBuilder extends VectorContext {
this.instructions.push([CanvasInstruction.CUSTOM, this.instructions.push([CanvasInstruction.CUSTOM,
builderBegin, builderEnd, geometry, renderer]); builderBegin, builderEnd, geometry, renderer]);
} }
this.endGeometry(geometry, feature); this.endGeometry(feature);
} }
/** /**
* @protected * @protected
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
* @param {import("../../Feature.js").FeatureLike} feature Feature. * @param {import("../../Feature.js").FeatureLike} feature Feature.
*/ */
beginGeometry(geometry, feature) { beginGeometry(feature) {
this.beginGeometryInstruction1_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0]; this.beginGeometryInstruction1_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0];
this.instructions.push(this.beginGeometryInstruction1_); this.instructions.push(this.beginGeometryInstruction1_);
this.beginGeometryInstruction2_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0]; this.beginGeometryInstruction2_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0];
@@ -353,10 +352,9 @@ class CanvasBuilder extends VectorContext {
/** /**
* @param {import("../canvas.js").FillStrokeState} state State. * @param {import("../canvas.js").FillStrokeState} state State.
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
* @return {Array<*>} Fill instruction. * @return {Array<*>} Fill instruction.
*/ */
createFill(state, geometry) { createFill(state) {
const fillStyle = state.fillStyle; const fillStyle = state.fillStyle;
/** @type {Array<*>} */ /** @type {Array<*>} */
const fillInstruction = [CanvasInstruction.SET_FILL_STYLE, fillStyle]; const fillInstruction = [CanvasInstruction.SET_FILL_STYLE, fillStyle];
@@ -389,14 +387,13 @@ class CanvasBuilder extends VectorContext {
/** /**
* @param {import("../canvas.js").FillStrokeState} state State. * @param {import("../canvas.js").FillStrokeState} state State.
* @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState, (import("../../geom/Geometry.js").default|import("../Feature.js").default)):Array<*>} createFill Create fill. * @param {function(this:CanvasBuilder, import("../canvas.js").FillStrokeState):Array<*>} createFill Create fill.
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
*/ */
updateFillStyle(state, createFill, geometry) { updateFillStyle(state, createFill) {
const fillStyle = state.fillStyle; const fillStyle = state.fillStyle;
if (typeof fillStyle !== 'string' || state.currentFillStyle != fillStyle) { if (typeof fillStyle !== 'string' || state.currentFillStyle != fillStyle) {
if (fillStyle !== undefined) { if (fillStyle !== undefined) {
this.instructions.push(createFill.call(this, state, geometry)); this.instructions.push(createFill.call(this, state));
} }
state.currentFillStyle = fillStyle; state.currentFillStyle = fillStyle;
} }
@@ -435,10 +432,9 @@ class CanvasBuilder extends VectorContext {
} }
/** /**
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
* @param {import("../../Feature.js").FeatureLike} feature Feature. * @param {import("../../Feature.js").FeatureLike} feature Feature.
*/ */
endGeometry(geometry, feature) { endGeometry(feature) {
this.beginGeometryInstruction1_[2] = this.instructions.length; this.beginGeometryInstruction1_[2] = this.instructions.length;
this.beginGeometryInstruction1_ = null; this.beginGeometryInstruction1_ = null;
this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length; this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
+4 -4
View File
@@ -113,7 +113,7 @@ class CanvasImageBuilder extends CanvasBuilder {
if (!this.image_) { if (!this.image_) {
return; return;
} }
this.beginGeometry(pointGeometry, feature); this.beginGeometry(feature);
const flatCoordinates = pointGeometry.getFlatCoordinates(); const flatCoordinates = pointGeometry.getFlatCoordinates();
const stride = pointGeometry.getStride(); const stride = pointGeometry.getStride();
const myBegin = this.coordinates.length; const myBegin = this.coordinates.length;
@@ -132,7 +132,7 @@ class CanvasImageBuilder extends CanvasBuilder {
this.originX_, this.originY_, this.rotateWithView_, this.rotation_, this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
this.scale_, this.width_ this.scale_, this.width_
]); ]);
this.endGeometry(pointGeometry, feature); this.endGeometry(feature);
} }
/** /**
@@ -142,7 +142,7 @@ class CanvasImageBuilder extends CanvasBuilder {
if (!this.image_) { if (!this.image_) {
return; return;
} }
this.beginGeometry(multiPointGeometry, feature); this.beginGeometry(feature);
const flatCoordinates = multiPointGeometry.getFlatCoordinates(); const flatCoordinates = multiPointGeometry.getFlatCoordinates();
const stride = multiPointGeometry.getStride(); const stride = multiPointGeometry.getStride();
const myBegin = this.coordinates.length; const myBegin = this.coordinates.length;
@@ -162,7 +162,7 @@ class CanvasImageBuilder extends CanvasBuilder {
this.originX_, this.originY_, this.rotateWithView_, this.rotation_, this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
this.scale_, this.width_ this.scale_, this.width_
]); ]);
this.endGeometry(multiPointGeometry, feature); this.endGeometry(feature);
} }
/** /**
+4 -4
View File
@@ -44,7 +44,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
return; return;
} }
this.updateStrokeStyle(state, this.applyStroke); this.updateStrokeStyle(state, this.applyStroke);
this.beginGeometry(lineStringGeometry, feature); this.beginGeometry(feature);
this.hitDetectionInstructions.push([ this.hitDetectionInstructions.push([
CanvasInstruction.SET_STROKE_STYLE, CanvasInstruction.SET_STROKE_STYLE,
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
@@ -54,7 +54,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
const stride = lineStringGeometry.getStride(); const stride = lineStringGeometry.getStride();
this.drawFlatCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride); this.drawFlatCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride);
this.hitDetectionInstructions.push(strokeInstruction); this.hitDetectionInstructions.push(strokeInstruction);
this.endGeometry(lineStringGeometry, feature); this.endGeometry(feature);
} }
/** /**
@@ -68,7 +68,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
return; return;
} }
this.updateStrokeStyle(state, this.applyStroke); this.updateStrokeStyle(state, this.applyStroke);
this.beginGeometry(multiLineStringGeometry, feature); this.beginGeometry(feature);
this.hitDetectionInstructions.push([ this.hitDetectionInstructions.push([
CanvasInstruction.SET_STROKE_STYLE, CanvasInstruction.SET_STROKE_STYLE,
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
@@ -82,7 +82,7 @@ class CanvasLineStringBuilder extends CanvasBuilder {
offset = this.drawFlatCoordinates_(flatCoordinates, offset, ends[i], stride); offset = this.drawFlatCoordinates_(flatCoordinates, offset, ends[i], stride);
} }
this.hitDetectionInstructions.push(strokeInstruction); this.hitDetectionInstructions.push(strokeInstruction);
this.endGeometry(multiLineStringGeometry, feature); this.endGeometry(feature);
} }
/** /**
+11 -12
View File
@@ -72,8 +72,8 @@ class CanvasPolygonBuilder extends CanvasBuilder {
if (fillStyle === undefined && strokeStyle === undefined) { if (fillStyle === undefined && strokeStyle === undefined) {
return; return;
} }
this.setFillStrokeStyles_(circleGeometry); this.setFillStrokeStyles_();
this.beginGeometry(circleGeometry, feature); this.beginGeometry(feature);
if (state.fillStyle !== undefined) { if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([ this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE, CanvasInstruction.SET_FILL_STYLE,
@@ -103,7 +103,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
this.instructions.push(strokeInstruction); this.instructions.push(strokeInstruction);
this.hitDetectionInstructions.push(strokeInstruction); this.hitDetectionInstructions.push(strokeInstruction);
} }
this.endGeometry(circleGeometry, feature); this.endGeometry(feature);
} }
/** /**
@@ -116,8 +116,8 @@ class CanvasPolygonBuilder extends CanvasBuilder {
if (fillStyle === undefined && strokeStyle === undefined) { if (fillStyle === undefined && strokeStyle === undefined) {
return; return;
} }
this.setFillStrokeStyles_(polygonGeometry); this.setFillStrokeStyles_();
this.beginGeometry(polygonGeometry, feature); this.beginGeometry(feature);
if (state.fillStyle !== undefined) { if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([ this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE, CanvasInstruction.SET_FILL_STYLE,
@@ -135,7 +135,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
const flatCoordinates = polygonGeometry.getOrientedFlatCoordinates(); const flatCoordinates = polygonGeometry.getOrientedFlatCoordinates();
const stride = polygonGeometry.getStride(); const stride = polygonGeometry.getStride();
this.drawFlatCoordinatess_(flatCoordinates, 0, ends, stride); this.drawFlatCoordinatess_(flatCoordinates, 0, ends, stride);
this.endGeometry(polygonGeometry, feature); this.endGeometry(feature);
} }
/** /**
@@ -148,8 +148,8 @@ class CanvasPolygonBuilder extends CanvasBuilder {
if (fillStyle === undefined && strokeStyle === undefined) { if (fillStyle === undefined && strokeStyle === undefined) {
return; return;
} }
this.setFillStrokeStyles_(multiPolygonGeometry); this.setFillStrokeStyles_();
this.beginGeometry(multiPolygonGeometry, feature); this.beginGeometry(feature);
if (state.fillStyle !== undefined) { if (state.fillStyle !== undefined) {
this.hitDetectionInstructions.push([ this.hitDetectionInstructions.push([
CanvasInstruction.SET_FILL_STYLE, CanvasInstruction.SET_FILL_STYLE,
@@ -170,7 +170,7 @@ class CanvasPolygonBuilder extends CanvasBuilder {
for (let i = 0, ii = endss.length; i < ii; ++i) { for (let i = 0, ii = endss.length; i < ii; ++i) {
offset = this.drawFlatCoordinatess_(flatCoordinates, offset, endss[i], stride); offset = this.drawFlatCoordinatess_(flatCoordinates, offset, endss[i], stride);
} }
this.endGeometry(multiPolygonGeometry, feature); this.endGeometry(feature);
} }
/** /**
@@ -195,13 +195,12 @@ class CanvasPolygonBuilder extends CanvasBuilder {
/** /**
* @private * @private
* @param {import("../../geom/Geometry.js").default|import("../Feature.js").default} geometry Geometry.
*/ */
setFillStrokeStyles_(geometry) { setFillStrokeStyles_() {
const state = this.state; const state = this.state;
const fillStyle = state.fillStyle; const fillStyle = state.fillStyle;
if (fillStyle !== undefined) { if (fillStyle !== undefined) {
this.updateFillStyle(state, this.createFill, geometry); this.updateFillStyle(state, this.createFill);
} }
if (state.strokeStyle !== undefined) { if (state.strokeStyle !== undefined) {
this.updateStrokeStyle(state, this.applyStroke); this.updateStrokeStyle(state, this.applyStroke);
+6 -6
View File
@@ -184,7 +184,7 @@ class CanvasTextBuilder extends CanvasBuilder {
ends.push(endss[i][0]); ends.push(endss[i][0]);
} }
} }
this.beginGeometry(geometry, feature); this.beginGeometry(feature);
const textAlign = textState.textAlign; const textAlign = textState.textAlign;
let flatOffset = 0; let flatOffset = 0;
let flatEnd; let flatEnd;
@@ -204,7 +204,7 @@ class CanvasTextBuilder extends CanvasBuilder {
this.drawChars_(begin, end, this.declutterGroup_); this.drawChars_(begin, end, this.declutterGroup_);
begin = end; begin = end;
} }
this.endGeometry(geometry, feature); this.endGeometry(feature);
} else { } else {
@@ -258,8 +258,8 @@ class CanvasTextBuilder extends CanvasBuilder {
if (textState.backgroundFill || textState.backgroundStroke) { if (textState.backgroundFill || textState.backgroundStroke) {
this.setFillStrokeStyle(textState.backgroundFill, textState.backgroundStroke); this.setFillStrokeStyle(textState.backgroundFill, textState.backgroundStroke);
if (textState.backgroundFill) { if (textState.backgroundFill) {
this.updateFillStyle(this.state, this.createFill, geometry); this.updateFillStyle(this.state, this.createFill);
this.hitDetectionInstructions.push(this.createFill(this.state, geometry)); this.hitDetectionInstructions.push(this.createFill(this.state));
} }
if (textState.backgroundStroke) { if (textState.backgroundStroke) {
this.updateStrokeStyle(this.state, this.applyStroke); this.updateStrokeStyle(this.state, this.applyStroke);
@@ -267,7 +267,7 @@ class CanvasTextBuilder extends CanvasBuilder {
} }
} }
this.beginGeometry(geometry, feature); this.beginGeometry(feature);
// The image is unknown at this stage so we pass null; it will be computed at render time. // The image is unknown at this stage so we pass null; it will be computed at render time.
// For clarity, we pass NaN for offsetX, offsetY, width and height, which will be computed at // For clarity, we pass NaN for offsetX, offsetY, width and height, which will be computed at
@@ -293,7 +293,7 @@ class CanvasTextBuilder extends CanvasBuilder {
this.textOffsetX_, this.textOffsetY_, geometryWidths this.textOffsetX_, this.textOffsetY_, geometryWidths
]); ]);
this.endGeometry(geometry, feature); this.endGeometry(feature);
} }
} }