@@ -17,7 +17,7 @@ import {isEmpty} from '../../obj.js';
|
||||
import VectorContext from '../VectorContext.js';
|
||||
import {drawImage, resetTransform, defaultPadding, defaultFillStyle, defaultStrokeStyle, defaultMiterLimit, defaultLineWidth, defaultLineJoin, defaultLineDashOffset, defaultLineDash, defaultLineCap} from '../canvas.js';
|
||||
import CanvasInstruction from '../canvas/Instruction.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import {TEXT_ALIGN} from '../replay.js';
|
||||
import {
|
||||
create as createTransform,
|
||||
compose as composeTransform,
|
||||
@@ -718,7 +718,7 @@ CanvasReplay.prototype.replay_ = function(
|
||||
const textLength = measure(text);
|
||||
if (overflow || textLength <= pathLength) {
|
||||
const textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign;
|
||||
const startM = (pathLength - textLength) * _ol_render_replay_.TEXT_ALIGN[textAlign];
|
||||
const startM = (pathLength - textLength) * TEXT_ALIGN[textAlign];
|
||||
const parts = drawTextOnPath(
|
||||
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
|
||||
if (parts) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import CanvasImageReplay from '../canvas/ImageReplay.js';
|
||||
import CanvasLineStringReplay from '../canvas/LineStringReplay.js';
|
||||
import CanvasPolygonReplay from '../canvas/PolygonReplay.js';
|
||||
import CanvasTextReplay from '../canvas/TextReplay.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import {ORDER} from '../replay.js';
|
||||
import {create as createTransform, compose as composeTransform} from '../../transform.js';
|
||||
|
||||
|
||||
@@ -370,8 +370,8 @@ CanvasReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
||||
for (i = zs.length - 1; i >= 0; --i) {
|
||||
const zIndexKey = zs[i].toString();
|
||||
replays = this.replaysByZIndex_[zIndexKey];
|
||||
for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) {
|
||||
replayType = _ol_render_replay_.ORDER[j];
|
||||
for (j = ORDER.length - 1; j >= 0; --j) {
|
||||
replayType = ORDER[j];
|
||||
replay = replays[replayType];
|
||||
if (replay !== undefined) {
|
||||
if (declutterReplays &&
|
||||
@@ -473,7 +473,7 @@ CanvasReplayGroup.prototype.replay = function(context,
|
||||
context.save();
|
||||
this.clip(context, transform);
|
||||
|
||||
const replayTypes = opt_replayTypes ? opt_replayTypes : _ol_render_replay_.ORDER;
|
||||
const replayTypes = opt_replayTypes ? opt_replayTypes : ORDER;
|
||||
let i, ii, j, jj, replays, replay;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
const zIndexKey = zs[i].toString();
|
||||
|
||||
@@ -11,7 +11,7 @@ import {CANVAS_LINE_DASH, SAFARI} from '../../has.js';
|
||||
import {labelCache, measureTextWidth, defaultTextAlign, measureTextHeight, defaultPadding, defaultLineCap, defaultLineDashOffset, defaultLineDash, defaultLineJoin, defaultFillStyle, checkFont, defaultFont, defaultLineWidth, defaultMiterLimit, defaultStrokeStyle, defaultTextBaseline} from '../canvas.js';
|
||||
import CanvasInstruction from '../canvas/Instruction.js';
|
||||
import CanvasReplay from '../canvas/Replay.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import {TEXT_ALIGN} from '../replay.js';
|
||||
import TextPlacement from '../../style/TextPlacement.js';
|
||||
|
||||
/**
|
||||
@@ -290,7 +290,7 @@ CanvasTextReplay.prototype.getImage = function(text, textKey, fillKey, strokeKey
|
||||
const textState = this.textStates[textKey] || this.textState_;
|
||||
const pixelRatio = this.pixelRatio;
|
||||
const scale = textState.scale * pixelRatio;
|
||||
const align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || defaultTextAlign];
|
||||
const align = TEXT_ALIGN[textState.textAlign || defaultTextAlign];
|
||||
const strokeWidth = strokeKey && strokeState.lineWidth ? strokeState.lineWidth : 0;
|
||||
|
||||
const lines = text.split('\n');
|
||||
@@ -353,8 +353,8 @@ CanvasTextReplay.prototype.drawTextImage_ = function(label, begin, end) {
|
||||
const textState = this.textState_;
|
||||
const strokeState = this.textStrokeState_;
|
||||
const pixelRatio = this.pixelRatio;
|
||||
const align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || defaultTextAlign];
|
||||
const baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
|
||||
const align = TEXT_ALIGN[textState.textAlign || defaultTextAlign];
|
||||
const baseline = TEXT_ALIGN[textState.textBaseline];
|
||||
const strokeWidth = strokeState && strokeState.lineWidth ? strokeState.lineWidth : 0;
|
||||
|
||||
const anchorX = align * label.width / pixelRatio + 2 * (0.5 - align) * strokeWidth;
|
||||
@@ -421,7 +421,7 @@ CanvasTextReplay.prototype.drawChars_ = function(begin, end, declutterGroup) {
|
||||
}
|
||||
|
||||
const pixelRatio = this.pixelRatio;
|
||||
const baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
|
||||
const baseline = TEXT_ALIGN[textState.textBaseline];
|
||||
|
||||
const offsetY = this.textOffsetY_ * pixelRatio;
|
||||
const text = this.text_;
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
* @module ol/render/replay
|
||||
*/
|
||||
import ReplayType from '../render/ReplayType.js';
|
||||
const _ol_render_replay_ = {};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<ol.render.ReplayType>}
|
||||
*/
|
||||
_ol_render_replay_.ORDER = [
|
||||
export const ORDER = [
|
||||
ReplayType.POLYGON,
|
||||
ReplayType.CIRCLE,
|
||||
ReplayType.LINE_STRING,
|
||||
@@ -22,16 +21,15 @@ _ol_render_replay_.ORDER = [
|
||||
* @const
|
||||
* @enum {number}
|
||||
*/
|
||||
_ol_render_replay_.TEXT_ALIGN = {};
|
||||
_ol_render_replay_.TEXT_ALIGN['left'] = 0;
|
||||
_ol_render_replay_.TEXT_ALIGN['end'] = 0;
|
||||
_ol_render_replay_.TEXT_ALIGN['center'] = 0.5;
|
||||
_ol_render_replay_.TEXT_ALIGN['right'] = 1;
|
||||
_ol_render_replay_.TEXT_ALIGN['start'] = 1;
|
||||
_ol_render_replay_.TEXT_ALIGN['top'] = 0;
|
||||
_ol_render_replay_.TEXT_ALIGN['middle'] = 0.5;
|
||||
_ol_render_replay_.TEXT_ALIGN['hanging'] = 0.2;
|
||||
_ol_render_replay_.TEXT_ALIGN['alphabetic'] = 0.8;
|
||||
_ol_render_replay_.TEXT_ALIGN['ideographic'] = 0.8;
|
||||
_ol_render_replay_.TEXT_ALIGN['bottom'] = 1;
|
||||
export default _ol_render_replay_;
|
||||
export const TEXT_ALIGN = {};
|
||||
TEXT_ALIGN['left'] = 0;
|
||||
TEXT_ALIGN['end'] = 0;
|
||||
TEXT_ALIGN['center'] = 0.5;
|
||||
TEXT_ALIGN['right'] = 1;
|
||||
TEXT_ALIGN['start'] = 1;
|
||||
TEXT_ALIGN['top'] = 0;
|
||||
TEXT_ALIGN['middle'] = 0.5;
|
||||
TEXT_ALIGN['hanging'] = 0.2;
|
||||
TEXT_ALIGN['alphabetic'] = 0.8;
|
||||
TEXT_ALIGN['ideographic'] = 0.8;
|
||||
TEXT_ALIGN['bottom'] = 1;
|
||||
|
||||
@@ -1,83 +1,88 @@
|
||||
/**
|
||||
* @module ol/render/webgl
|
||||
*/
|
||||
const _ol_render_webgl_ = {};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
_ol_render_webgl_.defaultFont = '10px sans-serif';
|
||||
export const DEFAULT_FONT = '10px sans-serif';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {ol.Color}
|
||||
*/
|
||||
_ol_render_webgl_.defaultFillStyle = [0.0, 0.0, 0.0, 1.0];
|
||||
export const DEFAULT_FILLSTYLE = [0.0, 0.0, 0.0, 1.0];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
_ol_render_webgl_.defaultLineCap = 'round';
|
||||
export const DEFAULT_LINECAP = 'round';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
_ol_render_webgl_.defaultLineDash = [];
|
||||
export const DEFAULT_LINEDASH = [];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
_ol_render_webgl_.defaultLineDashOffset = 0;
|
||||
export const DEFAULT_LINEDASHOFFSET = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
_ol_render_webgl_.defaultLineJoin = 'round';
|
||||
export const DEFAULT_LINEJOIN = 'round';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
_ol_render_webgl_.defaultMiterLimit = 10;
|
||||
export const DEFAULT_MITERLIMIT = 10;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {ol.Color}
|
||||
*/
|
||||
_ol_render_webgl_.defaultStrokeStyle = [0.0, 0.0, 0.0, 1.0];
|
||||
export const DEFAULT_STROKESTYLE = [0.0, 0.0, 0.0, 1.0];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
_ol_render_webgl_.defaultTextAlign = 0.5;
|
||||
export const DEFAULT_TEXTALIGN = 0.5;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
_ol_render_webgl_.defaultTextBaseline = 0.5;
|
||||
export const DEFAULT_TEXTBASELINE = 0.5;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
_ol_render_webgl_.defaultLineWidth = 1;
|
||||
export const DEFAULT_LINEWIDTH = 1;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
export const EPSILON = Number.EPSILON || 2.220446049250313e-16;
|
||||
|
||||
/**
|
||||
* Calculates the orientation of a triangle based on the determinant method.
|
||||
@@ -89,15 +94,9 @@ _ol_render_webgl_.defaultLineWidth = 1;
|
||||
* @param {number} y3 Third Y coordinate.
|
||||
* @return {boolean|undefined} Triangle is clockwise.
|
||||
*/
|
||||
_ol_render_webgl_.triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) {
|
||||
export const triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) {
|
||||
const area = (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1);
|
||||
return (area <= _ol_render_webgl_.EPSILON && area >= -_ol_render_webgl_.EPSILON) ?
|
||||
return (area <= EPSILON && area >= -EPSILON) ?
|
||||
undefined : area > 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
_ol_render_webgl_.EPSILON = Number.EPSILON || 2.220446049250313e-16;
|
||||
export default _ol_render_webgl_;
|
||||
|
||||
@@ -10,8 +10,9 @@ import {translate} from '../../geom/flat/transform.js';
|
||||
import {fragment, vertex} from '../webgl/circlereplay/defaultshader.js';
|
||||
import Locations from '../webgl/circlereplay/defaultshader/Locations.js';
|
||||
import WebGLReplay from '../webgl/Replay.js';
|
||||
import _ol_render_webgl_ from '../webgl.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import {DEFAULT_LINEDASH, DEFAULT_LINEDASHOFFSET, DEFAULT_STROKESTYLE,
|
||||
DEFAULT_FILLSTYLE, DEFAULT_LINEWIDTH} from '../webgl.js';
|
||||
import {FLOAT} from '../../webgl.js';
|
||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||
|
||||
/**
|
||||
@@ -211,15 +212,15 @@ WebGLCircleReplay.prototype.setUpProgram = function(gl, context, size, pixelRati
|
||||
|
||||
// enable the vertex attrib arrays
|
||||
gl.enableVertexAttribArray(locations.a_position);
|
||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
|
||||
false, 16, 0);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_instruction);
|
||||
gl.vertexAttribPointer(locations.a_instruction, 1, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_instruction, 1, FLOAT,
|
||||
false, 16, 8);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_radius);
|
||||
gl.vertexAttribPointer(locations.a_radius, 1, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_radius, 1, FLOAT,
|
||||
false, 16, 12);
|
||||
|
||||
// Enable renderer specific uniforms.
|
||||
@@ -377,22 +378,22 @@ WebGLCircleReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle
|
||||
if (strokeStyle) {
|
||||
const strokeStyleLineDash = strokeStyle.getLineDash();
|
||||
this.state_.lineDash = strokeStyleLineDash ?
|
||||
strokeStyleLineDash : _ol_render_webgl_.defaultLineDash;
|
||||
strokeStyleLineDash : DEFAULT_LINEDASH;
|
||||
const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
|
||||
this.state_.lineDashOffset = strokeStyleLineDashOffset ?
|
||||
strokeStyleLineDashOffset : _ol_render_webgl_.defaultLineDashOffset;
|
||||
strokeStyleLineDashOffset : DEFAULT_LINEDASHOFFSET;
|
||||
strokeStyleColor = strokeStyle.getColor();
|
||||
if (!(strokeStyleColor instanceof CanvasGradient) &&
|
||||
!(strokeStyleColor instanceof CanvasPattern)) {
|
||||
strokeStyleColor = asArray(strokeStyleColor).map(function(c, i) {
|
||||
return i != 3 ? c / 255 : c;
|
||||
}) || _ol_render_webgl_.defaultStrokeStyle;
|
||||
}) || DEFAULT_STROKESTYLE;
|
||||
} else {
|
||||
strokeStyleColor = _ol_render_webgl_.defaultStrokeStyle;
|
||||
strokeStyleColor = DEFAULT_STROKESTYLE;
|
||||
}
|
||||
strokeStyleWidth = strokeStyle.getWidth();
|
||||
strokeStyleWidth = strokeStyleWidth !== undefined ?
|
||||
strokeStyleWidth : _ol_render_webgl_.defaultLineWidth;
|
||||
strokeStyleWidth : DEFAULT_LINEWIDTH;
|
||||
} else {
|
||||
strokeStyleColor = [0, 0, 0, 0];
|
||||
strokeStyleWidth = 0;
|
||||
@@ -402,9 +403,9 @@ WebGLCircleReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle
|
||||
!(fillStyleColor instanceof CanvasPattern)) {
|
||||
fillStyleColor = asArray(fillStyleColor).map(function(c, i) {
|
||||
return i != 3 ? c / 255 : c;
|
||||
}) || _ol_render_webgl_.defaultFillStyle;
|
||||
}) || DEFAULT_FILLSTYLE;
|
||||
} else {
|
||||
fillStyleColor = _ol_render_webgl_.defaultFillStyle;
|
||||
fillStyleColor = DEFAULT_FILLSTYLE;
|
||||
}
|
||||
if (!this.state_.strokeColor || !equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||
!this.state_.fillColor || !equals(this.state_.fillColor, fillStyleColor) ||
|
||||
|
||||
@@ -9,11 +9,13 @@ import {linearRingIsClockwise} from '../../geom/flat/orient.js';
|
||||
import {translate} from '../../geom/flat/transform.js';
|
||||
import {lineStringIsClosed} from '../../geom/flat/topology.js';
|
||||
import {isEmpty} from '../../obj.js';
|
||||
import _ol_render_webgl_ from '../webgl.js';
|
||||
import {DEFAULT_LINECAP, DEFAULT_LINEDASH, DEFAULT_LINEDASHOFFSET,
|
||||
DEFAULT_LINEJOIN, DEFAULT_LINEWIDTH, DEFAULT_MITERLIMIT, DEFAULT_STROKESTYLE,
|
||||
triangleIsCounterClockwise} from '../webgl.js';
|
||||
import WebGLReplay from '../webgl/Replay.js';
|
||||
import {fragment, vertex} from '../webgl/linestringreplay/defaultshader.js';
|
||||
import Locations from '../webgl/linestringreplay/defaultshader/Locations.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import {FLOAT} from '../../webgl.js';
|
||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||
|
||||
|
||||
@@ -210,7 +212,7 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
||||
}
|
||||
|
||||
// We group CW and straight lines, thus the not so inituitive CCW checking function.
|
||||
sign = _ol_render_webgl_.triangleIsCounterClockwise(p0[0], p0[1], p1[0], p1[1], p2[0], p2[1])
|
||||
sign = triangleIsCounterClockwise(p0[0], p0[1], p1[0], p1[1], p2[0], p2[1])
|
||||
? -1 : 1;
|
||||
|
||||
numVertices = this.addVertices_(p0, p1, p2,
|
||||
@@ -471,19 +473,19 @@ WebGLLineStringReplay.prototype.setUpProgram = function(gl, context, size, pixel
|
||||
|
||||
// enable the vertex attrib arrays
|
||||
gl.enableVertexAttribArray(locations.a_lastPos);
|
||||
gl.vertexAttribPointer(locations.a_lastPos, 2, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_lastPos, 2, FLOAT,
|
||||
false, 28, 0);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_position);
|
||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
|
||||
false, 28, 8);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_nextPos);
|
||||
gl.vertexAttribPointer(locations.a_nextPos, 2, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_nextPos, 2, FLOAT,
|
||||
false, 28, 16);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_direction);
|
||||
gl.vertexAttribPointer(locations.a_direction, 1, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_direction, 1, FLOAT,
|
||||
false, 28, 24);
|
||||
|
||||
// Enable renderer specific uniforms.
|
||||
@@ -646,31 +648,31 @@ WebGLLineStringReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth,
|
||||
WebGLLineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
const strokeStyleLineCap = strokeStyle.getLineCap();
|
||||
this.state_.lineCap = strokeStyleLineCap !== undefined ?
|
||||
strokeStyleLineCap : _ol_render_webgl_.defaultLineCap;
|
||||
strokeStyleLineCap : DEFAULT_LINECAP;
|
||||
const strokeStyleLineDash = strokeStyle.getLineDash();
|
||||
this.state_.lineDash = strokeStyleLineDash ?
|
||||
strokeStyleLineDash : _ol_render_webgl_.defaultLineDash;
|
||||
strokeStyleLineDash : DEFAULT_LINEDASH;
|
||||
const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
|
||||
this.state_.lineDashOffset = strokeStyleLineDashOffset ?
|
||||
strokeStyleLineDashOffset : _ol_render_webgl_.defaultLineDashOffset;
|
||||
strokeStyleLineDashOffset : DEFAULT_LINEDASHOFFSET;
|
||||
const strokeStyleLineJoin = strokeStyle.getLineJoin();
|
||||
this.state_.lineJoin = strokeStyleLineJoin !== undefined ?
|
||||
strokeStyleLineJoin : _ol_render_webgl_.defaultLineJoin;
|
||||
strokeStyleLineJoin : DEFAULT_LINEJOIN;
|
||||
let strokeStyleColor = strokeStyle.getColor();
|
||||
if (!(strokeStyleColor instanceof CanvasGradient) &&
|
||||
!(strokeStyleColor instanceof CanvasPattern)) {
|
||||
strokeStyleColor = asArray(strokeStyleColor).map(function(c, i) {
|
||||
return i != 3 ? c / 255 : c;
|
||||
}) || _ol_render_webgl_.defaultStrokeStyle;
|
||||
}) || DEFAULT_STROKESTYLE;
|
||||
} else {
|
||||
strokeStyleColor = _ol_render_webgl_.defaultStrokeStyle;
|
||||
strokeStyleColor = DEFAULT_STROKESTYLE;
|
||||
}
|
||||
let strokeStyleWidth = strokeStyle.getWidth();
|
||||
strokeStyleWidth = strokeStyleWidth !== undefined ?
|
||||
strokeStyleWidth : _ol_render_webgl_.defaultLineWidth;
|
||||
strokeStyleWidth : DEFAULT_LINEWIDTH;
|
||||
let strokeStyleMiterLimit = strokeStyle.getMiterLimit();
|
||||
strokeStyleMiterLimit = strokeStyleMiterLimit !== undefined ?
|
||||
strokeStyleMiterLimit : _ol_render_webgl_.defaultMiterLimit;
|
||||
strokeStyleMiterLimit : DEFAULT_MITERLIMIT;
|
||||
if (!this.state_.strokeColor || !equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||
this.state_.lineWidth !== strokeStyleWidth || this.state_.miterLimit !== strokeStyleMiterLimit) {
|
||||
this.state_.changed = true;
|
||||
|
||||
@@ -13,11 +13,11 @@ import {fragment, vertex} from '../webgl/polygonreplay/defaultshader.js';
|
||||
import Locations from '../webgl/polygonreplay/defaultshader/Locations.js';
|
||||
import WebGLLineStringReplay from '../webgl/LineStringReplay.js';
|
||||
import WebGLReplay from '../webgl/Replay.js';
|
||||
import _ol_render_webgl_ from '../webgl.js';
|
||||
import {triangleIsCounterClockwise, EPSILON, DEFAULT_FILLSTYLE} from '../webgl.js';
|
||||
import Stroke from '../../style/Stroke.js';
|
||||
import LinkedList from '../../structs/LinkedList.js';
|
||||
import RBush from '../../structs/RBush.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import {FLOAT} from '../../webgl.js';
|
||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||
|
||||
/**
|
||||
@@ -220,9 +220,9 @@ WebGLPolygonReplay.prototype.classifyPoints_ = function(list, rtree, ccw) {
|
||||
let s1 = list.nextItem();
|
||||
let pointsReclassified = false;
|
||||
do {
|
||||
const reflex = ccw ? _ol_render_webgl_.triangleIsCounterClockwise(s1.p1.x,
|
||||
const reflex = ccw ? triangleIsCounterClockwise(s1.p1.x,
|
||||
s1.p1.y, s0.p1.x, s0.p1.y, s0.p0.x, s0.p0.y) :
|
||||
_ol_render_webgl_.triangleIsCounterClockwise(s0.p0.x, s0.p0.y, s0.p1.x,
|
||||
triangleIsCounterClockwise(s0.p0.x, s0.p0.y, s0.p1.x,
|
||||
s0.p1.y, s1.p1.x, s1.p1.y);
|
||||
if (reflex === undefined) {
|
||||
this.removeItem_(s0, s1, list, rtree);
|
||||
@@ -273,7 +273,7 @@ WebGLPolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
|
||||
const intersection = this.calculateIntersection_(p1, p2, currSeg.p0,
|
||||
currSeg.p1, true);
|
||||
const dist = Math.abs(p1.x - intersection[0]);
|
||||
if (dist < minDist && _ol_render_webgl_.triangleIsCounterClockwise(p1.x, p1.y,
|
||||
if (dist < minDist && triangleIsCounterClockwise(p1.x, p1.y,
|
||||
currSeg.p0.x, currSeg.p0.y, currSeg.p1.x, currSeg.p1.y) !== undefined) {
|
||||
minDist = dist;
|
||||
p5 = {x: intersection[0], y: intersection[1], i: -1};
|
||||
@@ -714,8 +714,8 @@ WebGLPolygonReplay.prototype.calculateIntersection_ = function(p0, p1, p2, p3, o
|
||||
if (denom !== 0) {
|
||||
const ua = ((p3.x - p2.x) * (p0.y - p2.y) - (p3.y - p2.y) * (p0.x - p2.x)) / denom;
|
||||
const ub = ((p1.x - p0.x) * (p0.y - p2.y) - (p1.y - p0.y) * (p0.x - p2.x)) / denom;
|
||||
if ((!opt_touch && ua > _ol_render_webgl_.EPSILON && ua < 1 - _ol_render_webgl_.EPSILON &&
|
||||
ub > _ol_render_webgl_.EPSILON && ub < 1 - _ol_render_webgl_.EPSILON) || (opt_touch &&
|
||||
if ((!opt_touch && ua > EPSILON && ua < 1 - EPSILON &&
|
||||
ub > EPSILON && ub < 1 - EPSILON) || (opt_touch &&
|
||||
ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1)) {
|
||||
return [p0.x + ua * (p1.x - p0.x), p0.y + ua * (p1.y - p0.y)];
|
||||
}
|
||||
@@ -888,7 +888,7 @@ WebGLPolygonReplay.prototype.setUpProgram = function(gl, context, size, pixelRat
|
||||
|
||||
// enable the vertex attrib arrays
|
||||
gl.enableVertexAttribArray(locations.a_position);
|
||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
|
||||
false, 8, 0);
|
||||
|
||||
return locations;
|
||||
@@ -1042,9 +1042,9 @@ WebGLPolygonReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyl
|
||||
!(fillStyleColor instanceof CanvasPattern)) {
|
||||
fillStyleColor = asArray(fillStyleColor).map(function(c, i) {
|
||||
return i != 3 ? c / 255 : c;
|
||||
}) || _ol_render_webgl_.defaultFillStyle;
|
||||
}) || DEFAULT_FILLSTYLE;
|
||||
} else {
|
||||
fillStyleColor = _ol_render_webgl_.defaultFillStyle;
|
||||
fillStyleColor = DEFAULT_FILLSTYLE;
|
||||
}
|
||||
if (!this.state_.fillColor || !equals(fillStyleColor, this.state_.fillColor)) {
|
||||
this.state_.fillColor = fillStyleColor;
|
||||
|
||||
@@ -12,7 +12,8 @@ import {
|
||||
translate as translateTransform
|
||||
} from '../../transform.js';
|
||||
import {create, fromTransform} from '../../vec/mat4.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import {ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, TRIANGLES,
|
||||
UNSIGNED_INT, UNSIGNED_SHORT} from '../../webgl.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -293,9 +294,9 @@ WebGLReplay.prototype.replay = function(context,
|
||||
gl.stencilFunc(gl.NOTEQUAL, 1, 255);
|
||||
}
|
||||
|
||||
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.verticesBuffer);
|
||||
context.bindBuffer(ARRAY_BUFFER, this.verticesBuffer);
|
||||
|
||||
context.bindBuffer(_ol_webgl_.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
|
||||
context.bindBuffer(ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
|
||||
|
||||
const locations = this.setUpProgram(gl, context, size, pixelRatio);
|
||||
|
||||
@@ -359,11 +360,11 @@ WebGLReplay.prototype.replay = function(context,
|
||||
WebGLReplay.prototype.drawElements = function(
|
||||
gl, context, start, end) {
|
||||
const elementType = context.hasOESElementIndexUint ?
|
||||
_ol_webgl_.UNSIGNED_INT : _ol_webgl_.UNSIGNED_SHORT;
|
||||
UNSIGNED_INT : UNSIGNED_SHORT;
|
||||
const elementSize = context.hasOESElementIndexUint ? 4 : 2;
|
||||
|
||||
const numItems = end - start;
|
||||
const offsetInBytes = start * elementSize;
|
||||
gl.drawElements(_ol_webgl_.TRIANGLES, numItems, elementType, offsetInBytes);
|
||||
gl.drawElements(TRIANGLES, numItems, elementType, offsetInBytes);
|
||||
};
|
||||
export default WebGLReplay;
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from '../../index.js';
|
||||
import {numberSafeCompareFunction} from '../../array.js';
|
||||
import {buffer, createOrUpdateFromCoordinate} from '../../extent.js';
|
||||
import {isEmpty} from '../../obj.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import {ORDER} from '../replay.js';
|
||||
import ReplayGroup from '../ReplayGroup.js';
|
||||
import WebGLCircleReplay from '../webgl/CircleReplay.js';
|
||||
import WebGLImageReplay from '../webgl/ImageReplay.js';
|
||||
@@ -171,8 +171,8 @@ WebGLReplayGroup.prototype.replay = function(context,
|
||||
let i, ii, j, jj, replays, replay;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
replays = this.replaysByZIndex_[zs[i].toString()];
|
||||
for (j = 0, jj = _ol_render_replay_.ORDER.length; j < jj; ++j) {
|
||||
replay = replays[_ol_render_replay_.ORDER[j]];
|
||||
for (j = 0, jj = ORDER.length; j < jj; ++j) {
|
||||
replay = replays[ORDER[j]];
|
||||
if (replay !== undefined) {
|
||||
replay.replay(context,
|
||||
center, resolution, rotation, size, pixelRatio,
|
||||
@@ -214,8 +214,8 @@ WebGLReplayGroup.prototype.replayHitDetection_ = function(context,
|
||||
let i, ii, j, replays, replay, result;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
replays = this.replaysByZIndex_[zs[i].toString()];
|
||||
for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) {
|
||||
replay = replays[_ol_render_replay_.ORDER[j]];
|
||||
for (j = ORDER.length - 1; j >= 0; --j) {
|
||||
replay = replays[ORDER[j]];
|
||||
if (replay !== undefined) {
|
||||
result = replay.replay(context,
|
||||
center, resolution, rotation, size, pixelRatio, opacity,
|
||||
|
||||
@@ -6,8 +6,10 @@ import {asColorLike} from '../../colorlike.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import {CANVAS_LINE_DASH} from '../../has.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import _ol_render_webgl_ from '../webgl.js';
|
||||
import {TEXT_ALIGN} from '../replay.js';
|
||||
import {DEFAULT_FILLSTYLE, DEFAULT_FONT, DEFAULT_LINECAP, DEFAULT_LINEDASH,
|
||||
DEFAULT_LINEDASHOFFSET, DEFAULT_LINEJOIN, DEFAULT_LINEWIDTH, DEFAULT_MITERLIMIT,
|
||||
DEFAULT_STROKESTYLE, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE} from '../webgl.js';
|
||||
import WebGLTextureReplay from '../webgl/TextureReplay.js';
|
||||
import AtlasManager from '../../style/AtlasManager.js';
|
||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||
@@ -356,7 +358,7 @@ WebGLTextReplay.prototype.setTextStyle = function(textStyle) {
|
||||
} else {
|
||||
const textFillStyleColor = textFillStyle.getColor();
|
||||
state.fillColor = asColorLike(textFillStyleColor ?
|
||||
textFillStyleColor : _ol_render_webgl_.defaultFillStyle);
|
||||
textFillStyleColor : DEFAULT_FILLSTYLE);
|
||||
}
|
||||
if (!textStrokeStyle) {
|
||||
state.strokeColor = null;
|
||||
@@ -364,24 +366,24 @@ WebGLTextReplay.prototype.setTextStyle = function(textStyle) {
|
||||
} else {
|
||||
const textStrokeStyleColor = textStrokeStyle.getColor();
|
||||
state.strokeColor = asColorLike(textStrokeStyleColor ?
|
||||
textStrokeStyleColor : _ol_render_webgl_.defaultStrokeStyle);
|
||||
state.lineWidth = textStrokeStyle.getWidth() || _ol_render_webgl_.defaultLineWidth;
|
||||
state.lineCap = textStrokeStyle.getLineCap() || _ol_render_webgl_.defaultLineCap;
|
||||
state.lineDashOffset = textStrokeStyle.getLineDashOffset() || _ol_render_webgl_.defaultLineDashOffset;
|
||||
state.lineJoin = textStrokeStyle.getLineJoin() || _ol_render_webgl_.defaultLineJoin;
|
||||
state.miterLimit = textStrokeStyle.getMiterLimit() || _ol_render_webgl_.defaultMiterLimit;
|
||||
textStrokeStyleColor : DEFAULT_STROKESTYLE);
|
||||
state.lineWidth = textStrokeStyle.getWidth() || DEFAULT_LINEWIDTH;
|
||||
state.lineCap = textStrokeStyle.getLineCap() || DEFAULT_LINECAP;
|
||||
state.lineDashOffset = textStrokeStyle.getLineDashOffset() || DEFAULT_LINEDASHOFFSET;
|
||||
state.lineJoin = textStrokeStyle.getLineJoin() || DEFAULT_LINEJOIN;
|
||||
state.miterLimit = textStrokeStyle.getMiterLimit() || DEFAULT_MITERLIMIT;
|
||||
const lineDash = textStrokeStyle.getLineDash();
|
||||
state.lineDash = lineDash ? lineDash.slice() : _ol_render_webgl_.defaultLineDash;
|
||||
state.lineDash = lineDash ? lineDash.slice() : DEFAULT_LINEDASH;
|
||||
}
|
||||
state.font = textStyle.getFont() || _ol_render_webgl_.defaultFont;
|
||||
state.font = textStyle.getFont() || DEFAULT_FONT;
|
||||
state.scale = textStyle.getScale() || 1;
|
||||
this.text_ = /** @type {string} */ (textStyle.getText());
|
||||
const textAlign = _ol_render_replay_.TEXT_ALIGN[textStyle.getTextAlign()];
|
||||
const textBaseline = _ol_render_replay_.TEXT_ALIGN[textStyle.getTextBaseline()];
|
||||
const textAlign = TEXT_ALIGN[textStyle.getTextAlign()];
|
||||
const textBaseline = TEXT_ALIGN[textStyle.getTextBaseline()];
|
||||
this.textAlign_ = textAlign === undefined ?
|
||||
_ol_render_webgl_.defaultTextAlign : textAlign;
|
||||
DEFAULT_TEXTALIGN : textAlign;
|
||||
this.textBaseline_ = textBaseline === undefined ?
|
||||
_ol_render_webgl_.defaultTextBaseline : textBaseline;
|
||||
DEFAULT_TEXTBASELINE : textBaseline;
|
||||
this.offsetX_ = textStyle.getOffsetX() || 0;
|
||||
this.offsetY_ = textStyle.getOffsetY() || 0;
|
||||
this.rotateWithView = !!textStyle.getRotateWithView();
|
||||
|
||||
@@ -7,7 +7,7 @@ import {isEmpty} from '../../obj.js';
|
||||
import {fragment, vertex} from '../webgl/texturereplay/defaultshader.js';
|
||||
import Locations from '../webgl/texturereplay/defaultshader/Locations.js';
|
||||
import WebGLReplay from '../webgl/Replay.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import {CLAMP_TO_EDGE, FLOAT, TEXTURE_2D} from '../../webgl.js';
|
||||
import {createTexture} from '../../webgl/Context.js';
|
||||
|
||||
/**
|
||||
@@ -258,7 +258,7 @@ WebGLTextureReplay.prototype.createTextures = function(textures, images, texture
|
||||
texture = texturePerImage[uid];
|
||||
} else {
|
||||
texture = createTexture(
|
||||
gl, image, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE);
|
||||
gl, image, CLAMP_TO_EDGE, CLAMP_TO_EDGE);
|
||||
texturePerImage[uid] = texture;
|
||||
}
|
||||
textures[i] = texture;
|
||||
@@ -287,23 +287,23 @@ WebGLTextureReplay.prototype.setUpProgram = function(gl, context, size, pixelRat
|
||||
|
||||
// enable the vertex attrib arrays
|
||||
gl.enableVertexAttribArray(locations.a_position);
|
||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
|
||||
false, 32, 0);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_offsets);
|
||||
gl.vertexAttribPointer(locations.a_offsets, 2, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_offsets, 2, FLOAT,
|
||||
false, 32, 8);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_texCoord);
|
||||
gl.vertexAttribPointer(locations.a_texCoord, 2, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_texCoord, 2, FLOAT,
|
||||
false, 32, 16);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_opacity);
|
||||
gl.vertexAttribPointer(locations.a_opacity, 1, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_opacity, 1, FLOAT,
|
||||
false, 32, 24);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_rotateWithView);
|
||||
gl.vertexAttribPointer(locations.a_rotateWithView, 1, _ol_webgl_.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_rotateWithView, 1, FLOAT,
|
||||
false, 32, 28);
|
||||
|
||||
return locations;
|
||||
@@ -334,7 +334,7 @@ WebGLTextureReplay.prototype.drawReplay = function(gl, context, skippedFeaturesH
|
||||
} else {
|
||||
let i, ii, start;
|
||||
for (i = 0, ii = textures.length, start = 0; i < ii; ++i) {
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, textures[i]);
|
||||
gl.bindTexture(TEXTURE_2D, textures[i]);
|
||||
const end = groupIndices[i];
|
||||
this.drawElements(gl, context, start, end);
|
||||
start = end;
|
||||
@@ -375,7 +375,7 @@ WebGLTextureReplay.prototype.drawReplaySkipping = function(gl, context, skippedF
|
||||
|
||||
let i, ii;
|
||||
for (i = 0, ii = textures.length; i < ii; ++i) {
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, textures[i]);
|
||||
gl.bindTexture(TEXTURE_2D, textures[i]);
|
||||
const groupStart = (i > 0) ? groupIndices[i - 1] : 0;
|
||||
const groupEnd = groupIndices[i];
|
||||
|
||||
@@ -422,7 +422,7 @@ WebGLTextureReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, conte
|
||||
let featureIndex = this.startIndices.length - 1;
|
||||
const hitDetectionTextures = this.getHitDetectionTextures();
|
||||
for (i = hitDetectionTextures.length - 1; i >= 0; --i) {
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, hitDetectionTextures[i]);
|
||||
gl.bindTexture(TEXTURE_2D, hitDetectionTextures[i]);
|
||||
groupStart = (i > 0) ? this.hitDetectionGroupIndices[i - 1] : 0;
|
||||
end = this.hitDetectionGroupIndices[i];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user