Rename _ol_render_canvas_Instruction_ to CanvasInstruction
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @module ol/render/canvas/ImageReplay
|
* @module ol/render/canvas/ImageReplay
|
||||||
*/
|
*/
|
||||||
import {inherits} from '../../index.js';
|
import {inherits} from '../../index.js';
|
||||||
import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js';
|
import CanvasInstruction from '../canvas/Instruction.js';
|
||||||
import CanvasReplay from '../canvas/Replay.js';
|
import CanvasReplay from '../canvas/Replay.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,14 +138,14 @@ CanvasImageReplay.prototype.drawPoint = function(pointGeometry, feature) {
|
|||||||
const myEnd = this.drawCoordinates_(
|
const myEnd = this.drawCoordinates_(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
this.instructions.push([
|
this.instructions.push([
|
||||||
_ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
||||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||||
this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
|
this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
|
||||||
]);
|
]);
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
_ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd,
|
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd,
|
||||||
this.hitDetectionImage_,
|
this.hitDetectionImage_,
|
||||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||||
@@ -170,14 +170,14 @@ CanvasImageReplay.prototype.drawMultiPoint = function(multiPointGeometry, featur
|
|||||||
const myEnd = this.drawCoordinates_(
|
const myEnd = this.drawCoordinates_(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
this.instructions.push([
|
this.instructions.push([
|
||||||
_ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
||||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||||
this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
|
this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
|
||||||
]);
|
]);
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
_ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd,
|
CanvasInstruction.DRAW_IMAGE, myBegin, myEnd,
|
||||||
this.hitDetectionImage_,
|
this.hitDetectionImage_,
|
||||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @module ol/render/canvas/LineStringReplay
|
* @module ol/render/canvas/LineStringReplay
|
||||||
*/
|
*/
|
||||||
import {inherits} from '../../index.js';
|
import {inherits} from '../../index.js';
|
||||||
import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js';
|
import CanvasInstruction from '../canvas/Instruction.js';
|
||||||
import CanvasReplay from '../canvas/Replay.js';
|
import CanvasReplay from '../canvas/Replay.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,8 +37,7 @@ CanvasLineStringReplay.prototype.drawFlatCoordinates_ = function(flatCoordinates
|
|||||||
const myBegin = this.coordinates.length;
|
const myBegin = this.coordinates.length;
|
||||||
const myEnd = this.appendFlatCoordinates(
|
const myEnd = this.appendFlatCoordinates(
|
||||||
flatCoordinates, offset, end, stride, false, false);
|
flatCoordinates, offset, end, stride, false, false);
|
||||||
const moveToLineToInstruction =
|
const moveToLineToInstruction = [CanvasInstruction.MOVE_TO_LINE_TO, myBegin, myEnd];
|
||||||
[_ol_render_canvas_Instruction_.MOVE_TO_LINE_TO, myBegin, myEnd];
|
|
||||||
this.instructions.push(moveToLineToInstruction);
|
this.instructions.push(moveToLineToInstruction);
|
||||||
this.hitDetectionInstructions.push(moveToLineToInstruction);
|
this.hitDetectionInstructions.push(moveToLineToInstruction);
|
||||||
return end;
|
return end;
|
||||||
@@ -58,16 +57,16 @@ CanvasLineStringReplay.prototype.drawLineString = function(lineStringGeometry, f
|
|||||||
this.updateStrokeStyle(state, this.applyStroke);
|
this.updateStrokeStyle(state, this.applyStroke);
|
||||||
this.beginGeometry(lineStringGeometry, feature);
|
this.beginGeometry(lineStringGeometry, feature);
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
CanvasInstruction.SET_STROKE_STYLE,
|
||||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||||
], [
|
], [
|
||||||
_ol_render_canvas_Instruction_.BEGIN_PATH
|
CanvasInstruction.BEGIN_PATH
|
||||||
]);
|
]);
|
||||||
const flatCoordinates = lineStringGeometry.getFlatCoordinates();
|
const flatCoordinates = lineStringGeometry.getFlatCoordinates();
|
||||||
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([_ol_render_canvas_Instruction_.STROKE]);
|
this.hitDetectionInstructions.push([CanvasInstruction.STROKE]);
|
||||||
this.endGeometry(lineStringGeometry, feature);
|
this.endGeometry(lineStringGeometry, feature);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -85,11 +84,11 @@ CanvasLineStringReplay.prototype.drawMultiLineString = function(multiLineStringG
|
|||||||
this.updateStrokeStyle(state, this.applyStroke);
|
this.updateStrokeStyle(state, this.applyStroke);
|
||||||
this.beginGeometry(multiLineStringGeometry, feature);
|
this.beginGeometry(multiLineStringGeometry, feature);
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
CanvasInstruction.SET_STROKE_STYLE,
|
||||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||||
], [
|
], [
|
||||||
_ol_render_canvas_Instruction_.BEGIN_PATH
|
CanvasInstruction.BEGIN_PATH
|
||||||
]);
|
]);
|
||||||
const ends = multiLineStringGeometry.getEnds();
|
const ends = multiLineStringGeometry.getEnds();
|
||||||
const flatCoordinates = multiLineStringGeometry.getFlatCoordinates();
|
const flatCoordinates = multiLineStringGeometry.getFlatCoordinates();
|
||||||
@@ -99,7 +98,7 @@ CanvasLineStringReplay.prototype.drawMultiLineString = function(multiLineStringG
|
|||||||
offset = this.drawFlatCoordinates_(
|
offset = this.drawFlatCoordinates_(
|
||||||
flatCoordinates, offset, ends[i], stride);
|
flatCoordinates, offset, ends[i], stride);
|
||||||
}
|
}
|
||||||
this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.STROKE]);
|
this.hitDetectionInstructions.push([CanvasInstruction.STROKE]);
|
||||||
this.endGeometry(multiLineStringGeometry, feature);
|
this.endGeometry(multiLineStringGeometry, feature);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,7 +109,7 @@ CanvasLineStringReplay.prototype.drawMultiLineString = function(multiLineStringG
|
|||||||
CanvasLineStringReplay.prototype.finish = function() {
|
CanvasLineStringReplay.prototype.finish = function() {
|
||||||
const state = this.state;
|
const state = this.state;
|
||||||
if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) {
|
if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) {
|
||||||
this.instructions.push([_ol_render_canvas_Instruction_.STROKE]);
|
this.instructions.push([CanvasInstruction.STROKE]);
|
||||||
}
|
}
|
||||||
this.reverseHitDetectionInstructions();
|
this.reverseHitDetectionInstructions();
|
||||||
this.state = null;
|
this.state = null;
|
||||||
@@ -122,11 +121,11 @@ CanvasLineStringReplay.prototype.finish = function() {
|
|||||||
*/
|
*/
|
||||||
CanvasLineStringReplay.prototype.applyStroke = function(state) {
|
CanvasLineStringReplay.prototype.applyStroke = function(state) {
|
||||||
if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) {
|
if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) {
|
||||||
this.instructions.push([_ol_render_canvas_Instruction_.STROKE]);
|
this.instructions.push([CanvasInstruction.STROKE]);
|
||||||
state.lastStroke = this.coordinates.length;
|
state.lastStroke = this.coordinates.length;
|
||||||
}
|
}
|
||||||
state.lastStroke = 0;
|
state.lastStroke = 0;
|
||||||
CanvasReplay.prototype.applyStroke.call(this, state);
|
CanvasReplay.prototype.applyStroke.call(this, state);
|
||||||
this.instructions.push([_ol_render_canvas_Instruction_.BEGIN_PATH]);
|
this.instructions.push([CanvasInstruction.BEGIN_PATH]);
|
||||||
};
|
};
|
||||||
export default CanvasLineStringReplay;
|
export default CanvasLineStringReplay;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {inherits} from '../../index.js';
|
|||||||
import {asString} from '../../color.js';
|
import {asString} from '../../color.js';
|
||||||
import _ol_geom_flat_simplify_ from '../../geom/flat/simplify.js';
|
import _ol_geom_flat_simplify_ from '../../geom/flat/simplify.js';
|
||||||
import _ol_render_canvas_ from '../canvas.js';
|
import _ol_render_canvas_ from '../canvas.js';
|
||||||
import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js';
|
import CanvasInstruction from '../canvas/Instruction.js';
|
||||||
import CanvasReplay from '../canvas/Replay.js';
|
import CanvasReplay from '../canvas/Replay.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +41,7 @@ CanvasPolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCoordinates,
|
|||||||
const fill = state.fillStyle !== undefined;
|
const fill = state.fillStyle !== undefined;
|
||||||
const stroke = state.strokeStyle != undefined;
|
const stroke = state.strokeStyle != undefined;
|
||||||
const numEnds = ends.length;
|
const numEnds = ends.length;
|
||||||
const beginPathInstruction = [_ol_render_canvas_Instruction_.BEGIN_PATH];
|
const beginPathInstruction = [CanvasInstruction.BEGIN_PATH];
|
||||||
this.instructions.push(beginPathInstruction);
|
this.instructions.push(beginPathInstruction);
|
||||||
this.hitDetectionInstructions.push(beginPathInstruction);
|
this.hitDetectionInstructions.push(beginPathInstruction);
|
||||||
for (let i = 0; i < numEnds; ++i) {
|
for (let i = 0; i < numEnds; ++i) {
|
||||||
@@ -49,26 +49,25 @@ CanvasPolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCoordinates,
|
|||||||
const myBegin = this.coordinates.length;
|
const myBegin = this.coordinates.length;
|
||||||
const myEnd = this.appendFlatCoordinates(
|
const myEnd = this.appendFlatCoordinates(
|
||||||
flatCoordinates, offset, end, stride, true, !stroke);
|
flatCoordinates, offset, end, stride, true, !stroke);
|
||||||
const moveToLineToInstruction =
|
const moveToLineToInstruction = [CanvasInstruction.MOVE_TO_LINE_TO, myBegin, myEnd];
|
||||||
[_ol_render_canvas_Instruction_.MOVE_TO_LINE_TO, myBegin, myEnd];
|
|
||||||
this.instructions.push(moveToLineToInstruction);
|
this.instructions.push(moveToLineToInstruction);
|
||||||
this.hitDetectionInstructions.push(moveToLineToInstruction);
|
this.hitDetectionInstructions.push(moveToLineToInstruction);
|
||||||
if (stroke) {
|
if (stroke) {
|
||||||
// Performance optimization: only call closePath() when we have a stroke.
|
// Performance optimization: only call closePath() when we have a stroke.
|
||||||
// Otherwise the ring is closed already (see appendFlatCoordinates above).
|
// Otherwise the ring is closed already (see appendFlatCoordinates above).
|
||||||
const closePathInstruction = [_ol_render_canvas_Instruction_.CLOSE_PATH];
|
const closePathInstruction = [CanvasInstruction.CLOSE_PATH];
|
||||||
this.instructions.push(closePathInstruction);
|
this.instructions.push(closePathInstruction);
|
||||||
this.hitDetectionInstructions.push(closePathInstruction);
|
this.hitDetectionInstructions.push(closePathInstruction);
|
||||||
}
|
}
|
||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
const fillInstruction = [_ol_render_canvas_Instruction_.FILL];
|
const fillInstruction = [CanvasInstruction.FILL];
|
||||||
this.hitDetectionInstructions.push(fillInstruction);
|
this.hitDetectionInstructions.push(fillInstruction);
|
||||||
if (fill) {
|
if (fill) {
|
||||||
this.instructions.push(fillInstruction);
|
this.instructions.push(fillInstruction);
|
||||||
}
|
}
|
||||||
if (stroke) {
|
if (stroke) {
|
||||||
const strokeInstruction = [_ol_render_canvas_Instruction_.STROKE];
|
const strokeInstruction = [CanvasInstruction.STROKE];
|
||||||
this.instructions.push(strokeInstruction);
|
this.instructions.push(strokeInstruction);
|
||||||
this.hitDetectionInstructions.push(strokeInstruction);
|
this.hitDetectionInstructions.push(strokeInstruction);
|
||||||
}
|
}
|
||||||
@@ -90,12 +89,12 @@ CanvasPolygonReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
|||||||
this.beginGeometry(circleGeometry, feature);
|
this.beginGeometry(circleGeometry, feature);
|
||||||
// always fill the circle for hit detection
|
// always fill the circle for hit detection
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
_ol_render_canvas_Instruction_.SET_FILL_STYLE,
|
CanvasInstruction.SET_FILL_STYLE,
|
||||||
asString(_ol_render_canvas_.defaultFillStyle)
|
asString(_ol_render_canvas_.defaultFillStyle)
|
||||||
]);
|
]);
|
||||||
if (state.strokeStyle !== undefined) {
|
if (state.strokeStyle !== undefined) {
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
CanvasInstruction.SET_STROKE_STYLE,
|
||||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||||
]);
|
]);
|
||||||
@@ -105,17 +104,17 @@ CanvasPolygonReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
|||||||
const myBegin = this.coordinates.length;
|
const myBegin = this.coordinates.length;
|
||||||
this.appendFlatCoordinates(
|
this.appendFlatCoordinates(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
||||||
const beginPathInstruction = [_ol_render_canvas_Instruction_.BEGIN_PATH];
|
const beginPathInstruction = [CanvasInstruction.BEGIN_PATH];
|
||||||
const circleInstruction = [_ol_render_canvas_Instruction_.CIRCLE, myBegin];
|
const circleInstruction = [CanvasInstruction.CIRCLE, myBegin];
|
||||||
this.instructions.push(beginPathInstruction, circleInstruction);
|
this.instructions.push(beginPathInstruction, circleInstruction);
|
||||||
this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction);
|
this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction);
|
||||||
const fillInstruction = [_ol_render_canvas_Instruction_.FILL];
|
const fillInstruction = [CanvasInstruction.FILL];
|
||||||
this.hitDetectionInstructions.push(fillInstruction);
|
this.hitDetectionInstructions.push(fillInstruction);
|
||||||
if (state.fillStyle !== undefined) {
|
if (state.fillStyle !== undefined) {
|
||||||
this.instructions.push(fillInstruction);
|
this.instructions.push(fillInstruction);
|
||||||
}
|
}
|
||||||
if (state.strokeStyle !== undefined) {
|
if (state.strokeStyle !== undefined) {
|
||||||
const strokeInstruction = [_ol_render_canvas_Instruction_.STROKE];
|
const strokeInstruction = [CanvasInstruction.STROKE];
|
||||||
this.instructions.push(strokeInstruction);
|
this.instructions.push(strokeInstruction);
|
||||||
this.hitDetectionInstructions.push(strokeInstruction);
|
this.hitDetectionInstructions.push(strokeInstruction);
|
||||||
}
|
}
|
||||||
@@ -132,12 +131,12 @@ CanvasPolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
|||||||
this.beginGeometry(polygonGeometry, feature);
|
this.beginGeometry(polygonGeometry, feature);
|
||||||
// always fill the polygon for hit detection
|
// always fill the polygon for hit detection
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
_ol_render_canvas_Instruction_.SET_FILL_STYLE,
|
CanvasInstruction.SET_FILL_STYLE,
|
||||||
asString(_ol_render_canvas_.defaultFillStyle)]
|
asString(_ol_render_canvas_.defaultFillStyle)]
|
||||||
);
|
);
|
||||||
if (state.strokeStyle !== undefined) {
|
if (state.strokeStyle !== undefined) {
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
CanvasInstruction.SET_STROKE_STYLE,
|
||||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||||
]);
|
]);
|
||||||
@@ -164,12 +163,12 @@ CanvasPolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry,
|
|||||||
this.beginGeometry(multiPolygonGeometry, feature);
|
this.beginGeometry(multiPolygonGeometry, feature);
|
||||||
// always fill the multi-polygon for hit detection
|
// always fill the multi-polygon for hit detection
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
_ol_render_canvas_Instruction_.SET_FILL_STYLE,
|
CanvasInstruction.SET_FILL_STYLE,
|
||||||
asString(_ol_render_canvas_.defaultFillStyle)
|
asString(_ol_render_canvas_.defaultFillStyle)
|
||||||
]);
|
]);
|
||||||
if (state.strokeStyle !== undefined) {
|
if (state.strokeStyle !== undefined) {
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
CanvasInstruction.SET_STROKE_STYLE,
|
||||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import _ol_has_ from '../../has.js';
|
|||||||
import {isEmpty} from '../../obj.js';
|
import {isEmpty} from '../../obj.js';
|
||||||
import VectorContext from '../VectorContext.js';
|
import VectorContext from '../VectorContext.js';
|
||||||
import _ol_render_canvas_ from '../canvas.js';
|
import _ol_render_canvas_ from '../canvas.js';
|
||||||
import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js';
|
import CanvasInstruction from '../canvas/Instruction.js';
|
||||||
import _ol_render_replay_ from '../replay.js';
|
import _ol_render_replay_ from '../replay.js';
|
||||||
import _ol_transform_ from '../../transform.js';
|
import _ol_transform_ from '../../transform.js';
|
||||||
|
|
||||||
@@ -409,7 +409,7 @@ CanvasReplay.prototype.drawCustom = function(geometry, feature, renderer) {
|
|||||||
offset = this.drawCustomCoordinates_(flatCoordinates, offset, endss[i], stride, myEnds);
|
offset = this.drawCustomCoordinates_(flatCoordinates, offset, endss[i], stride, myEnds);
|
||||||
replayEndss.push(myEnds);
|
replayEndss.push(myEnds);
|
||||||
}
|
}
|
||||||
this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM,
|
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||||
replayBegin, replayEndss, geometry, renderer, _ol_geom_flat_inflate_.coordinatesss]);
|
replayBegin, replayEndss, geometry, renderer, _ol_geom_flat_inflate_.coordinatesss]);
|
||||||
} else if (type == GeometryType.POLYGON || type == GeometryType.MULTI_LINE_STRING) {
|
} else if (type == GeometryType.POLYGON || type == GeometryType.MULTI_LINE_STRING) {
|
||||||
replayEnds = [];
|
replayEnds = [];
|
||||||
@@ -419,19 +419,19 @@ CanvasReplay.prototype.drawCustom = function(geometry, feature, renderer) {
|
|||||||
offset = this.drawCustomCoordinates_(flatCoordinates, 0,
|
offset = this.drawCustomCoordinates_(flatCoordinates, 0,
|
||||||
/** @type {ol.geom.Polygon|ol.geom.MultiLineString} */ (geometry).getEnds(),
|
/** @type {ol.geom.Polygon|ol.geom.MultiLineString} */ (geometry).getEnds(),
|
||||||
stride, replayEnds);
|
stride, replayEnds);
|
||||||
this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM,
|
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||||
replayBegin, replayEnds, geometry, renderer, _ol_geom_flat_inflate_.coordinatess]);
|
replayBegin, replayEnds, geometry, renderer, _ol_geom_flat_inflate_.coordinatess]);
|
||||||
} else if (type == GeometryType.LINE_STRING || type == GeometryType.MULTI_POINT) {
|
} else if (type == GeometryType.LINE_STRING || type == GeometryType.MULTI_POINT) {
|
||||||
flatCoordinates = geometry.getFlatCoordinates();
|
flatCoordinates = geometry.getFlatCoordinates();
|
||||||
replayEnd = this.appendFlatCoordinates(
|
replayEnd = this.appendFlatCoordinates(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
||||||
this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM,
|
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||||
replayBegin, replayEnd, geometry, renderer, _ol_geom_flat_inflate_.coordinates]);
|
replayBegin, replayEnd, geometry, renderer, _ol_geom_flat_inflate_.coordinates]);
|
||||||
} else if (type == GeometryType.POINT) {
|
} else if (type == GeometryType.POINT) {
|
||||||
flatCoordinates = geometry.getFlatCoordinates();
|
flatCoordinates = geometry.getFlatCoordinates();
|
||||||
this.coordinates.push(flatCoordinates[0], flatCoordinates[1]);
|
this.coordinates.push(flatCoordinates[0], flatCoordinates[1]);
|
||||||
replayEnd = this.coordinates.length;
|
replayEnd = this.coordinates.length;
|
||||||
this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM,
|
this.instructions.push([CanvasInstruction.CUSTOM,
|
||||||
replayBegin, replayEnd, geometry, renderer]);
|
replayBegin, replayEnd, geometry, renderer]);
|
||||||
}
|
}
|
||||||
this.endGeometry(geometry, feature);
|
this.endGeometry(geometry, feature);
|
||||||
@@ -444,11 +444,9 @@ CanvasReplay.prototype.drawCustom = function(geometry, feature, renderer) {
|
|||||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||||
*/
|
*/
|
||||||
CanvasReplay.prototype.beginGeometry = function(geometry, feature) {
|
CanvasReplay.prototype.beginGeometry = function(geometry, feature) {
|
||||||
this.beginGeometryInstruction1_ =
|
this.beginGeometryInstruction1_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0];
|
||||||
[_ol_render_canvas_Instruction_.BEGIN_GEOMETRY, feature, 0];
|
|
||||||
this.instructions.push(this.beginGeometryInstruction1_);
|
this.instructions.push(this.beginGeometryInstruction1_);
|
||||||
this.beginGeometryInstruction2_ =
|
this.beginGeometryInstruction2_ = [CanvasInstruction.BEGIN_GEOMETRY, feature, 0];
|
||||||
[_ol_render_canvas_Instruction_.BEGIN_GEOMETRY, feature, 0];
|
|
||||||
this.hitDetectionInstructions.push(this.beginGeometryInstruction2_);
|
this.hitDetectionInstructions.push(this.beginGeometryInstruction2_);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -586,7 +584,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
const instruction = instructions[i];
|
const instruction = instructions[i];
|
||||||
const type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
|
const type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case _ol_render_canvas_Instruction_.BEGIN_GEOMETRY:
|
case CanvasInstruction.BEGIN_GEOMETRY:
|
||||||
feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
|
feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
|
||||||
if ((skipFeatures &&
|
if ((skipFeatures &&
|
||||||
skippedFeaturesHash[getUid(feature).toString()]) ||
|
skippedFeaturesHash[getUid(feature).toString()]) ||
|
||||||
@@ -599,7 +597,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.BEGIN_PATH:
|
case CanvasInstruction.BEGIN_PATH:
|
||||||
if (pendingFill > batchSize) {
|
if (pendingFill > batchSize) {
|
||||||
this.fill_(context);
|
this.fill_(context);
|
||||||
pendingFill = 0;
|
pendingFill = 0;
|
||||||
@@ -614,7 +612,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.CIRCLE:
|
case CanvasInstruction.CIRCLE:
|
||||||
d = /** @type {number} */ (instruction[1]);
|
d = /** @type {number} */ (instruction[1]);
|
||||||
const x1 = pixelCoordinates[d];
|
const x1 = pixelCoordinates[d];
|
||||||
const y1 = pixelCoordinates[d + 1];
|
const y1 = pixelCoordinates[d + 1];
|
||||||
@@ -627,11 +625,11 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
context.arc(x1, y1, r, 0, 2 * Math.PI, true);
|
context.arc(x1, y1, r, 0, 2 * Math.PI, true);
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.CLOSE_PATH:
|
case CanvasInstruction.CLOSE_PATH:
|
||||||
context.closePath();
|
context.closePath();
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.CUSTOM:
|
case CanvasInstruction.CUSTOM:
|
||||||
d = /** @type {number} */ (instruction[1]);
|
d = /** @type {number} */ (instruction[1]);
|
||||||
dd = instruction[2];
|
dd = instruction[2];
|
||||||
const geometry = /** @type {ol.geom.SimpleGeometry} */ (instruction[3]);
|
const geometry = /** @type {ol.geom.SimpleGeometry} */ (instruction[3]);
|
||||||
@@ -653,7 +651,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
renderer(coords, state);
|
renderer(coords, state);
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.DRAW_IMAGE:
|
case CanvasInstruction.DRAW_IMAGE:
|
||||||
d = /** @type {number} */ (instruction[1]);
|
d = /** @type {number} */ (instruction[1]);
|
||||||
dd = /** @type {number} */ (instruction[2]);
|
dd = /** @type {number} */ (instruction[2]);
|
||||||
image = /** @type {HTMLCanvasElement|HTMLVideoElement|Image} */
|
image = /** @type {HTMLCanvasElement|HTMLVideoElement|Image} */
|
||||||
@@ -696,7 +694,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
this.renderDeclutter_(declutterGroup, feature);
|
this.renderDeclutter_(declutterGroup, feature);
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.DRAW_CHARS:
|
case CanvasInstruction.DRAW_CHARS:
|
||||||
const begin = /** @type {number} */ (instruction[1]);
|
const begin = /** @type {number} */ (instruction[1]);
|
||||||
const end = /** @type {number} */ (instruction[2]);
|
const end = /** @type {number} */ (instruction[2]);
|
||||||
const baseline = /** @type {number} */ (instruction[3]);
|
const baseline = /** @type {number} */ (instruction[3]);
|
||||||
@@ -754,7 +752,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
this.renderDeclutter_(declutterGroup, feature);
|
this.renderDeclutter_(declutterGroup, feature);
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.END_GEOMETRY:
|
case CanvasInstruction.END_GEOMETRY:
|
||||||
if (featureCallback !== undefined) {
|
if (featureCallback !== undefined) {
|
||||||
feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
|
feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
|
||||||
const result = featureCallback(feature);
|
const result = featureCallback(feature);
|
||||||
@@ -764,7 +762,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.FILL:
|
case CanvasInstruction.FILL:
|
||||||
if (batchSize) {
|
if (batchSize) {
|
||||||
pendingFill++;
|
pendingFill++;
|
||||||
} else {
|
} else {
|
||||||
@@ -772,7 +770,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.MOVE_TO_LINE_TO:
|
case CanvasInstruction.MOVE_TO_LINE_TO:
|
||||||
d = /** @type {number} */ (instruction[1]);
|
d = /** @type {number} */ (instruction[1]);
|
||||||
dd = /** @type {number} */ (instruction[2]);
|
dd = /** @type {number} */ (instruction[2]);
|
||||||
x = pixelCoordinates[d];
|
x = pixelCoordinates[d];
|
||||||
@@ -797,7 +795,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.SET_FILL_STYLE:
|
case CanvasInstruction.SET_FILL_STYLE:
|
||||||
lastFillInstruction = instruction;
|
lastFillInstruction = instruction;
|
||||||
this.fillOrigin_ = instruction[2];
|
this.fillOrigin_ = instruction[2];
|
||||||
|
|
||||||
@@ -813,7 +811,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
context.fillStyle = /** @type {ol.ColorLike} */ (instruction[1]);
|
context.fillStyle = /** @type {ol.ColorLike} */ (instruction[1]);
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.SET_STROKE_STYLE:
|
case CanvasInstruction.SET_STROKE_STYLE:
|
||||||
lastStrokeInstruction = instruction;
|
lastStrokeInstruction = instruction;
|
||||||
if (pendingStroke) {
|
if (pendingStroke) {
|
||||||
context.stroke();
|
context.stroke();
|
||||||
@@ -822,7 +820,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
this.setStrokeStyle_(context, /** @type {Array.<*>} */ (instruction));
|
this.setStrokeStyle_(context, /** @type {Array.<*>} */ (instruction));
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
case _ol_render_canvas_Instruction_.STROKE:
|
case CanvasInstruction.STROKE:
|
||||||
if (batchSize) {
|
if (batchSize) {
|
||||||
pendingStroke++;
|
pendingStroke++;
|
||||||
} else {
|
} else {
|
||||||
@@ -898,9 +896,9 @@ CanvasReplay.prototype.reverseHitDetectionInstructions = function() {
|
|||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
instruction = hitDetectionInstructions[i];
|
instruction = hitDetectionInstructions[i];
|
||||||
type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
|
type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
|
||||||
if (type == _ol_render_canvas_Instruction_.END_GEOMETRY) {
|
if (type == CanvasInstruction.END_GEOMETRY) {
|
||||||
begin = i;
|
begin = i;
|
||||||
} else if (type == _ol_render_canvas_Instruction_.BEGIN_GEOMETRY) {
|
} else if (type == CanvasInstruction.BEGIN_GEOMETRY) {
|
||||||
instruction[2] = i;
|
instruction[2] = i;
|
||||||
reverseSubArray(this.hitDetectionInstructions, begin, i);
|
reverseSubArray(this.hitDetectionInstructions, begin, i);
|
||||||
begin = -1;
|
begin = -1;
|
||||||
@@ -968,7 +966,7 @@ CanvasReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
|||||||
*/
|
*/
|
||||||
CanvasReplay.prototype.createFill = function(state, geometry) {
|
CanvasReplay.prototype.createFill = function(state, geometry) {
|
||||||
const fillStyle = state.fillStyle;
|
const fillStyle = state.fillStyle;
|
||||||
const fillInstruction = [_ol_render_canvas_Instruction_.SET_FILL_STYLE, fillStyle];
|
const fillInstruction = [CanvasInstruction.SET_FILL_STYLE, fillStyle];
|
||||||
if (typeof fillStyle !== 'string') {
|
if (typeof fillStyle !== 'string') {
|
||||||
const fillExtent = geometry.getExtent();
|
const fillExtent = geometry.getExtent();
|
||||||
fillInstruction.push([fillExtent[0], fillExtent[3]]);
|
fillInstruction.push([fillExtent[0], fillExtent[3]]);
|
||||||
@@ -991,7 +989,7 @@ CanvasReplay.prototype.applyStroke = function(state) {
|
|||||||
*/
|
*/
|
||||||
CanvasReplay.prototype.createStroke = function(state) {
|
CanvasReplay.prototype.createStroke = function(state) {
|
||||||
return [
|
return [
|
||||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
CanvasInstruction.SET_STROKE_STYLE,
|
||||||
state.strokeStyle, state.lineWidth * this.pixelRatio, state.lineCap,
|
state.strokeStyle, state.lineWidth * this.pixelRatio, state.lineCap,
|
||||||
state.lineJoin, state.miterLimit,
|
state.lineJoin, state.miterLimit,
|
||||||
this.applyPixelRatio(state.lineDash), state.lineDashOffset * this.pixelRatio
|
this.applyPixelRatio(state.lineDash), state.lineDashOffset * this.pixelRatio
|
||||||
@@ -1057,8 +1055,7 @@ CanvasReplay.prototype.endGeometry = function(geometry, feature) {
|
|||||||
this.beginGeometryInstruction1_ = null;
|
this.beginGeometryInstruction1_ = null;
|
||||||
this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
|
this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
|
||||||
this.beginGeometryInstruction2_ = null;
|
this.beginGeometryInstruction2_ = null;
|
||||||
const endGeometryInstruction =
|
const endGeometryInstruction = [CanvasInstruction.END_GEOMETRY, feature];
|
||||||
[_ol_render_canvas_Instruction_.END_GEOMETRY, feature];
|
|
||||||
this.instructions.push(endGeometryInstruction);
|
this.instructions.push(endGeometryInstruction);
|
||||||
this.hitDetectionInstructions.push(endGeometryInstruction);
|
this.hitDetectionInstructions.push(endGeometryInstruction);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import _ol_geom_flat_straightchunk_ from '../../geom/flat/straightchunk.js';
|
|||||||
import GeometryType from '../../geom/GeometryType.js';
|
import GeometryType from '../../geom/GeometryType.js';
|
||||||
import _ol_has_ from '../../has.js';
|
import _ol_has_ from '../../has.js';
|
||||||
import _ol_render_canvas_ from '../canvas.js';
|
import _ol_render_canvas_ from '../canvas.js';
|
||||||
import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js';
|
import CanvasInstruction from '../canvas/Instruction.js';
|
||||||
import CanvasReplay from '../canvas/Replay.js';
|
import CanvasReplay from '../canvas/Replay.js';
|
||||||
import _ol_render_replay_ from '../replay.js';
|
import _ol_render_replay_ from '../replay.js';
|
||||||
import TextPlacement from '../../style/TextPlacement.js';
|
import TextPlacement from '../../style/TextPlacement.js';
|
||||||
@@ -362,7 +362,7 @@ CanvasTextReplay.prototype.drawTextImage_ = function(label, begin, end) {
|
|||||||
|
|
||||||
const anchorX = align * label.width / pixelRatio + 2 * (0.5 - align) * strokeWidth;
|
const anchorX = align * label.width / pixelRatio + 2 * (0.5 - align) * strokeWidth;
|
||||||
const anchorY = baseline * label.height / pixelRatio + 2 * (0.5 - baseline) * strokeWidth;
|
const anchorY = baseline * label.height / pixelRatio + 2 * (0.5 - baseline) * strokeWidth;
|
||||||
this.instructions.push([_ol_render_canvas_Instruction_.DRAW_IMAGE, begin, end,
|
this.instructions.push([CanvasInstruction.DRAW_IMAGE, begin, end,
|
||||||
label, (anchorX - this.textOffsetX_) * pixelRatio, (anchorY - this.textOffsetY_) * pixelRatio,
|
label, (anchorX - this.textOffsetX_) * pixelRatio, (anchorY - this.textOffsetY_) * pixelRatio,
|
||||||
this.declutterGroup_, label.height, 1, 0, 0, this.textRotateWithView_, this.textRotation_,
|
this.declutterGroup_, label.height, 1, 0, 0, this.textRotateWithView_, this.textRotation_,
|
||||||
1, true, label.width,
|
1, true, label.width,
|
||||||
@@ -372,7 +372,7 @@ CanvasTextReplay.prototype.drawTextImage_ = function(label, begin, end) {
|
|||||||
}),
|
}),
|
||||||
!!textState.backgroundFill, !!textState.backgroundStroke
|
!!textState.backgroundFill, !!textState.backgroundStroke
|
||||||
]);
|
]);
|
||||||
this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.DRAW_IMAGE, begin, end,
|
this.hitDetectionInstructions.push([CanvasInstruction.DRAW_IMAGE, begin, end,
|
||||||
label, (anchorX - this.textOffsetX_) * pixelRatio, (anchorY - this.textOffsetY_) * pixelRatio,
|
label, (anchorX - this.textOffsetX_) * pixelRatio, (anchorY - this.textOffsetY_) * pixelRatio,
|
||||||
this.declutterGroup_, label.height, 1, 0, 0, this.textRotateWithView_, this.textRotation_,
|
this.declutterGroup_, label.height, 1, 0, 0, this.textRotateWithView_, this.textRotation_,
|
||||||
1 / pixelRatio, true, label.width, textState.padding,
|
1 / pixelRatio, true, label.width, textState.padding,
|
||||||
@@ -435,7 +435,7 @@ CanvasTextReplay.prototype.drawChars_ = function(begin, end, declutterGroup) {
|
|||||||
if (!widths) {
|
if (!widths) {
|
||||||
this.widths_[font] = widths = {};
|
this.widths_[font] = widths = {};
|
||||||
}
|
}
|
||||||
this.instructions.push([_ol_render_canvas_Instruction_.DRAW_CHARS,
|
this.instructions.push([CanvasInstruction.DRAW_CHARS,
|
||||||
begin, end, baseline, declutterGroup,
|
begin, end, baseline, declutterGroup,
|
||||||
textState.overflow, fillKey, textState.maxAngle,
|
textState.overflow, fillKey, textState.maxAngle,
|
||||||
function(text) {
|
function(text) {
|
||||||
@@ -447,7 +447,7 @@ CanvasTextReplay.prototype.drawChars_ = function(begin, end, declutterGroup) {
|
|||||||
},
|
},
|
||||||
offsetY, strokeKey, strokeWidth * pixelRatio, text, textKey, 1
|
offsetY, strokeKey, strokeWidth * pixelRatio, text, textKey, 1
|
||||||
]);
|
]);
|
||||||
this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.DRAW_CHARS,
|
this.hitDetectionInstructions.push([CanvasInstruction.DRAW_CHARS,
|
||||||
begin, end, baseline, declutterGroup,
|
begin, end, baseline, declutterGroup,
|
||||||
textState.overflow, fillKey, textState.maxAngle,
|
textState.overflow, fillKey, textState.maxAngle,
|
||||||
function(text) {
|
function(text) {
|
||||||
|
|||||||
Reference in New Issue
Block a user