@@ -17,7 +17,7 @@ import {isEmpty} from '../../obj.js';
|
|||||||
import VectorContext from '../VectorContext.js';
|
import VectorContext from '../VectorContext.js';
|
||||||
import {drawImage, resetTransform, defaultPadding, defaultFillStyle, defaultStrokeStyle, defaultMiterLimit, defaultLineWidth, defaultLineJoin, defaultLineDashOffset, defaultLineDash, defaultLineCap} from '../canvas.js';
|
import {drawImage, resetTransform, defaultPadding, defaultFillStyle, defaultStrokeStyle, defaultMiterLimit, defaultLineWidth, defaultLineJoin, defaultLineDashOffset, defaultLineDash, defaultLineCap} from '../canvas.js';
|
||||||
import CanvasInstruction from '../canvas/Instruction.js';
|
import CanvasInstruction from '../canvas/Instruction.js';
|
||||||
import _ol_render_replay_ from '../replay.js';
|
import {TEXT_ALIGN} from '../replay.js';
|
||||||
import {
|
import {
|
||||||
create as createTransform,
|
create as createTransform,
|
||||||
compose as composeTransform,
|
compose as composeTransform,
|
||||||
@@ -718,7 +718,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
const textLength = measure(text);
|
const textLength = measure(text);
|
||||||
if (overflow || textLength <= pathLength) {
|
if (overflow || textLength <= pathLength) {
|
||||||
const textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign;
|
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(
|
const parts = drawTextOnPath(
|
||||||
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
|
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
|
||||||
if (parts) {
|
if (parts) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import CanvasImageReplay from '../canvas/ImageReplay.js';
|
|||||||
import CanvasLineStringReplay from '../canvas/LineStringReplay.js';
|
import CanvasLineStringReplay from '../canvas/LineStringReplay.js';
|
||||||
import CanvasPolygonReplay from '../canvas/PolygonReplay.js';
|
import CanvasPolygonReplay from '../canvas/PolygonReplay.js';
|
||||||
import CanvasTextReplay from '../canvas/TextReplay.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';
|
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) {
|
for (i = zs.length - 1; i >= 0; --i) {
|
||||||
const zIndexKey = zs[i].toString();
|
const zIndexKey = zs[i].toString();
|
||||||
replays = this.replaysByZIndex_[zIndexKey];
|
replays = this.replaysByZIndex_[zIndexKey];
|
||||||
for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) {
|
for (j = ORDER.length - 1; j >= 0; --j) {
|
||||||
replayType = _ol_render_replay_.ORDER[j];
|
replayType = ORDER[j];
|
||||||
replay = replays[replayType];
|
replay = replays[replayType];
|
||||||
if (replay !== undefined) {
|
if (replay !== undefined) {
|
||||||
if (declutterReplays &&
|
if (declutterReplays &&
|
||||||
@@ -473,7 +473,7 @@ CanvasReplayGroup.prototype.replay = function(context,
|
|||||||
context.save();
|
context.save();
|
||||||
this.clip(context, transform);
|
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;
|
let i, ii, j, jj, replays, replay;
|
||||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||||
const zIndexKey = zs[i].toString();
|
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 {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 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 {TEXT_ALIGN} from '../replay.js';
|
||||||
import TextPlacement from '../../style/TextPlacement.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 textState = this.textStates[textKey] || this.textState_;
|
||||||
const pixelRatio = this.pixelRatio;
|
const pixelRatio = this.pixelRatio;
|
||||||
const scale = textState.scale * 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 strokeWidth = strokeKey && strokeState.lineWidth ? strokeState.lineWidth : 0;
|
||||||
|
|
||||||
const lines = text.split('\n');
|
const lines = text.split('\n');
|
||||||
@@ -353,8 +353,8 @@ CanvasTextReplay.prototype.drawTextImage_ = function(label, begin, end) {
|
|||||||
const textState = this.textState_;
|
const textState = this.textState_;
|
||||||
const strokeState = this.textStrokeState_;
|
const strokeState = this.textStrokeState_;
|
||||||
const pixelRatio = this.pixelRatio;
|
const pixelRatio = this.pixelRatio;
|
||||||
const align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || defaultTextAlign];
|
const align = TEXT_ALIGN[textState.textAlign || defaultTextAlign];
|
||||||
const baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
|
const baseline = TEXT_ALIGN[textState.textBaseline];
|
||||||
const strokeWidth = strokeState && strokeState.lineWidth ? strokeState.lineWidth : 0;
|
const strokeWidth = strokeState && strokeState.lineWidth ? strokeState.lineWidth : 0;
|
||||||
|
|
||||||
const anchorX = align * label.width / pixelRatio + 2 * (0.5 - align) * strokeWidth;
|
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 pixelRatio = this.pixelRatio;
|
||||||
const baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
|
const baseline = TEXT_ALIGN[textState.textBaseline];
|
||||||
|
|
||||||
const offsetY = this.textOffsetY_ * pixelRatio;
|
const offsetY = this.textOffsetY_ * pixelRatio;
|
||||||
const text = this.text_;
|
const text = this.text_;
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
* @module ol/render/replay
|
* @module ol/render/replay
|
||||||
*/
|
*/
|
||||||
import ReplayType from '../render/ReplayType.js';
|
import ReplayType from '../render/ReplayType.js';
|
||||||
const _ol_render_replay_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {Array.<ol.render.ReplayType>}
|
* @type {Array.<ol.render.ReplayType>}
|
||||||
*/
|
*/
|
||||||
_ol_render_replay_.ORDER = [
|
export const ORDER = [
|
||||||
ReplayType.POLYGON,
|
ReplayType.POLYGON,
|
||||||
ReplayType.CIRCLE,
|
ReplayType.CIRCLE,
|
||||||
ReplayType.LINE_STRING,
|
ReplayType.LINE_STRING,
|
||||||
@@ -22,16 +21,15 @@ _ol_render_replay_.ORDER = [
|
|||||||
* @const
|
* @const
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
_ol_render_replay_.TEXT_ALIGN = {};
|
export const TEXT_ALIGN = {};
|
||||||
_ol_render_replay_.TEXT_ALIGN['left'] = 0;
|
TEXT_ALIGN['left'] = 0;
|
||||||
_ol_render_replay_.TEXT_ALIGN['end'] = 0;
|
TEXT_ALIGN['end'] = 0;
|
||||||
_ol_render_replay_.TEXT_ALIGN['center'] = 0.5;
|
TEXT_ALIGN['center'] = 0.5;
|
||||||
_ol_render_replay_.TEXT_ALIGN['right'] = 1;
|
TEXT_ALIGN['right'] = 1;
|
||||||
_ol_render_replay_.TEXT_ALIGN['start'] = 1;
|
TEXT_ALIGN['start'] = 1;
|
||||||
_ol_render_replay_.TEXT_ALIGN['top'] = 0;
|
TEXT_ALIGN['top'] = 0;
|
||||||
_ol_render_replay_.TEXT_ALIGN['middle'] = 0.5;
|
TEXT_ALIGN['middle'] = 0.5;
|
||||||
_ol_render_replay_.TEXT_ALIGN['hanging'] = 0.2;
|
TEXT_ALIGN['hanging'] = 0.2;
|
||||||
_ol_render_replay_.TEXT_ALIGN['alphabetic'] = 0.8;
|
TEXT_ALIGN['alphabetic'] = 0.8;
|
||||||
_ol_render_replay_.TEXT_ALIGN['ideographic'] = 0.8;
|
TEXT_ALIGN['ideographic'] = 0.8;
|
||||||
_ol_render_replay_.TEXT_ALIGN['bottom'] = 1;
|
TEXT_ALIGN['bottom'] = 1;
|
||||||
export default _ol_render_replay_;
|
|
||||||
|
|||||||
@@ -1,83 +1,88 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/render/webgl
|
* @module ol/render/webgl
|
||||||
*/
|
*/
|
||||||
const _ol_render_webgl_ = {};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
_ol_render_webgl_.defaultFont = '10px sans-serif';
|
export const DEFAULT_FONT = '10px sans-serif';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.Color}
|
* @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
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
_ol_render_webgl_.defaultLineCap = 'round';
|
export const DEFAULT_LINECAP = 'round';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {Array.<number>}
|
* @type {Array.<number>}
|
||||||
*/
|
*/
|
||||||
_ol_render_webgl_.defaultLineDash = [];
|
export const DEFAULT_LINEDASH = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_render_webgl_.defaultLineDashOffset = 0;
|
export const DEFAULT_LINEDASHOFFSET = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
_ol_render_webgl_.defaultLineJoin = 'round';
|
export const DEFAULT_LINEJOIN = 'round';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_render_webgl_.defaultMiterLimit = 10;
|
export const DEFAULT_MITERLIMIT = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.Color}
|
* @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
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_render_webgl_.defaultTextAlign = 0.5;
|
export const DEFAULT_TEXTALIGN = 0.5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_render_webgl_.defaultTextBaseline = 0.5;
|
export const DEFAULT_TEXTBASELINE = 0.5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @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.
|
* 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.
|
* @param {number} y3 Third Y coordinate.
|
||||||
* @return {boolean|undefined} Triangle is clockwise.
|
* @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);
|
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;
|
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 {fragment, vertex} from '../webgl/circlereplay/defaultshader.js';
|
||||||
import Locations from '../webgl/circlereplay/defaultshader/Locations.js';
|
import Locations from '../webgl/circlereplay/defaultshader/Locations.js';
|
||||||
import WebGLReplay from '../webgl/Replay.js';
|
import WebGLReplay from '../webgl/Replay.js';
|
||||||
import _ol_render_webgl_ from '../webgl.js';
|
import {DEFAULT_LINEDASH, DEFAULT_LINEDASHOFFSET, DEFAULT_STROKESTYLE,
|
||||||
import _ol_webgl_ from '../../webgl.js';
|
DEFAULT_FILLSTYLE, DEFAULT_LINEWIDTH} from '../webgl.js';
|
||||||
|
import {FLOAT} from '../../webgl.js';
|
||||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,15 +212,15 @@ WebGLCircleReplay.prototype.setUpProgram = function(gl, context, size, pixelRati
|
|||||||
|
|
||||||
// enable the vertex attrib arrays
|
// enable the vertex attrib arrays
|
||||||
gl.enableVertexAttribArray(locations.a_position);
|
gl.enableVertexAttribArray(locations.a_position);
|
||||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
|
||||||
false, 16, 0);
|
false, 16, 0);
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_instruction);
|
gl.enableVertexAttribArray(locations.a_instruction);
|
||||||
gl.vertexAttribPointer(locations.a_instruction, 1, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_instruction, 1, FLOAT,
|
||||||
false, 16, 8);
|
false, 16, 8);
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_radius);
|
gl.enableVertexAttribArray(locations.a_radius);
|
||||||
gl.vertexAttribPointer(locations.a_radius, 1, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_radius, 1, FLOAT,
|
||||||
false, 16, 12);
|
false, 16, 12);
|
||||||
|
|
||||||
// Enable renderer specific uniforms.
|
// Enable renderer specific uniforms.
|
||||||
@@ -377,22 +378,22 @@ WebGLCircleReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle
|
|||||||
if (strokeStyle) {
|
if (strokeStyle) {
|
||||||
const strokeStyleLineDash = strokeStyle.getLineDash();
|
const strokeStyleLineDash = strokeStyle.getLineDash();
|
||||||
this.state_.lineDash = strokeStyleLineDash ?
|
this.state_.lineDash = strokeStyleLineDash ?
|
||||||
strokeStyleLineDash : _ol_render_webgl_.defaultLineDash;
|
strokeStyleLineDash : DEFAULT_LINEDASH;
|
||||||
const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
|
const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
|
||||||
this.state_.lineDashOffset = strokeStyleLineDashOffset ?
|
this.state_.lineDashOffset = strokeStyleLineDashOffset ?
|
||||||
strokeStyleLineDashOffset : _ol_render_webgl_.defaultLineDashOffset;
|
strokeStyleLineDashOffset : DEFAULT_LINEDASHOFFSET;
|
||||||
strokeStyleColor = strokeStyle.getColor();
|
strokeStyleColor = strokeStyle.getColor();
|
||||||
if (!(strokeStyleColor instanceof CanvasGradient) &&
|
if (!(strokeStyleColor instanceof CanvasGradient) &&
|
||||||
!(strokeStyleColor instanceof CanvasPattern)) {
|
!(strokeStyleColor instanceof CanvasPattern)) {
|
||||||
strokeStyleColor = asArray(strokeStyleColor).map(function(c, i) {
|
strokeStyleColor = asArray(strokeStyleColor).map(function(c, i) {
|
||||||
return i != 3 ? c / 255 : c;
|
return i != 3 ? c / 255 : c;
|
||||||
}) || _ol_render_webgl_.defaultStrokeStyle;
|
}) || DEFAULT_STROKESTYLE;
|
||||||
} else {
|
} else {
|
||||||
strokeStyleColor = _ol_render_webgl_.defaultStrokeStyle;
|
strokeStyleColor = DEFAULT_STROKESTYLE;
|
||||||
}
|
}
|
||||||
strokeStyleWidth = strokeStyle.getWidth();
|
strokeStyleWidth = strokeStyle.getWidth();
|
||||||
strokeStyleWidth = strokeStyleWidth !== undefined ?
|
strokeStyleWidth = strokeStyleWidth !== undefined ?
|
||||||
strokeStyleWidth : _ol_render_webgl_.defaultLineWidth;
|
strokeStyleWidth : DEFAULT_LINEWIDTH;
|
||||||
} else {
|
} else {
|
||||||
strokeStyleColor = [0, 0, 0, 0];
|
strokeStyleColor = [0, 0, 0, 0];
|
||||||
strokeStyleWidth = 0;
|
strokeStyleWidth = 0;
|
||||||
@@ -402,9 +403,9 @@ WebGLCircleReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle
|
|||||||
!(fillStyleColor instanceof CanvasPattern)) {
|
!(fillStyleColor instanceof CanvasPattern)) {
|
||||||
fillStyleColor = asArray(fillStyleColor).map(function(c, i) {
|
fillStyleColor = asArray(fillStyleColor).map(function(c, i) {
|
||||||
return i != 3 ? c / 255 : c;
|
return i != 3 ? c / 255 : c;
|
||||||
}) || _ol_render_webgl_.defaultFillStyle;
|
}) || DEFAULT_FILLSTYLE;
|
||||||
} else {
|
} else {
|
||||||
fillStyleColor = _ol_render_webgl_.defaultFillStyle;
|
fillStyleColor = DEFAULT_FILLSTYLE;
|
||||||
}
|
}
|
||||||
if (!this.state_.strokeColor || !equals(this.state_.strokeColor, strokeStyleColor) ||
|
if (!this.state_.strokeColor || !equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||||
!this.state_.fillColor || !equals(this.state_.fillColor, fillStyleColor) ||
|
!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 {translate} from '../../geom/flat/transform.js';
|
||||||
import {lineStringIsClosed} from '../../geom/flat/topology.js';
|
import {lineStringIsClosed} from '../../geom/flat/topology.js';
|
||||||
import {isEmpty} from '../../obj.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 WebGLReplay from '../webgl/Replay.js';
|
||||||
import {fragment, vertex} from '../webgl/linestringreplay/defaultshader.js';
|
import {fragment, vertex} from '../webgl/linestringreplay/defaultshader.js';
|
||||||
import Locations from '../webgl/linestringreplay/defaultshader/Locations.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';
|
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.
|
// 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;
|
? -1 : 1;
|
||||||
|
|
||||||
numVertices = this.addVertices_(p0, p1, p2,
|
numVertices = this.addVertices_(p0, p1, p2,
|
||||||
@@ -471,19 +473,19 @@ WebGLLineStringReplay.prototype.setUpProgram = function(gl, context, size, pixel
|
|||||||
|
|
||||||
// enable the vertex attrib arrays
|
// enable the vertex attrib arrays
|
||||||
gl.enableVertexAttribArray(locations.a_lastPos);
|
gl.enableVertexAttribArray(locations.a_lastPos);
|
||||||
gl.vertexAttribPointer(locations.a_lastPos, 2, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_lastPos, 2, FLOAT,
|
||||||
false, 28, 0);
|
false, 28, 0);
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_position);
|
gl.enableVertexAttribArray(locations.a_position);
|
||||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
|
||||||
false, 28, 8);
|
false, 28, 8);
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_nextPos);
|
gl.enableVertexAttribArray(locations.a_nextPos);
|
||||||
gl.vertexAttribPointer(locations.a_nextPos, 2, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_nextPos, 2, FLOAT,
|
||||||
false, 28, 16);
|
false, 28, 16);
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_direction);
|
gl.enableVertexAttribArray(locations.a_direction);
|
||||||
gl.vertexAttribPointer(locations.a_direction, 1, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_direction, 1, FLOAT,
|
||||||
false, 28, 24);
|
false, 28, 24);
|
||||||
|
|
||||||
// Enable renderer specific uniforms.
|
// Enable renderer specific uniforms.
|
||||||
@@ -646,31 +648,31 @@ WebGLLineStringReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth,
|
|||||||
WebGLLineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
WebGLLineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||||
const strokeStyleLineCap = strokeStyle.getLineCap();
|
const strokeStyleLineCap = strokeStyle.getLineCap();
|
||||||
this.state_.lineCap = strokeStyleLineCap !== undefined ?
|
this.state_.lineCap = strokeStyleLineCap !== undefined ?
|
||||||
strokeStyleLineCap : _ol_render_webgl_.defaultLineCap;
|
strokeStyleLineCap : DEFAULT_LINECAP;
|
||||||
const strokeStyleLineDash = strokeStyle.getLineDash();
|
const strokeStyleLineDash = strokeStyle.getLineDash();
|
||||||
this.state_.lineDash = strokeStyleLineDash ?
|
this.state_.lineDash = strokeStyleLineDash ?
|
||||||
strokeStyleLineDash : _ol_render_webgl_.defaultLineDash;
|
strokeStyleLineDash : DEFAULT_LINEDASH;
|
||||||
const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
|
const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
|
||||||
this.state_.lineDashOffset = strokeStyleLineDashOffset ?
|
this.state_.lineDashOffset = strokeStyleLineDashOffset ?
|
||||||
strokeStyleLineDashOffset : _ol_render_webgl_.defaultLineDashOffset;
|
strokeStyleLineDashOffset : DEFAULT_LINEDASHOFFSET;
|
||||||
const strokeStyleLineJoin = strokeStyle.getLineJoin();
|
const strokeStyleLineJoin = strokeStyle.getLineJoin();
|
||||||
this.state_.lineJoin = strokeStyleLineJoin !== undefined ?
|
this.state_.lineJoin = strokeStyleLineJoin !== undefined ?
|
||||||
strokeStyleLineJoin : _ol_render_webgl_.defaultLineJoin;
|
strokeStyleLineJoin : DEFAULT_LINEJOIN;
|
||||||
let strokeStyleColor = strokeStyle.getColor();
|
let strokeStyleColor = strokeStyle.getColor();
|
||||||
if (!(strokeStyleColor instanceof CanvasGradient) &&
|
if (!(strokeStyleColor instanceof CanvasGradient) &&
|
||||||
!(strokeStyleColor instanceof CanvasPattern)) {
|
!(strokeStyleColor instanceof CanvasPattern)) {
|
||||||
strokeStyleColor = asArray(strokeStyleColor).map(function(c, i) {
|
strokeStyleColor = asArray(strokeStyleColor).map(function(c, i) {
|
||||||
return i != 3 ? c / 255 : c;
|
return i != 3 ? c / 255 : c;
|
||||||
}) || _ol_render_webgl_.defaultStrokeStyle;
|
}) || DEFAULT_STROKESTYLE;
|
||||||
} else {
|
} else {
|
||||||
strokeStyleColor = _ol_render_webgl_.defaultStrokeStyle;
|
strokeStyleColor = DEFAULT_STROKESTYLE;
|
||||||
}
|
}
|
||||||
let strokeStyleWidth = strokeStyle.getWidth();
|
let strokeStyleWidth = strokeStyle.getWidth();
|
||||||
strokeStyleWidth = strokeStyleWidth !== undefined ?
|
strokeStyleWidth = strokeStyleWidth !== undefined ?
|
||||||
strokeStyleWidth : _ol_render_webgl_.defaultLineWidth;
|
strokeStyleWidth : DEFAULT_LINEWIDTH;
|
||||||
let strokeStyleMiterLimit = strokeStyle.getMiterLimit();
|
let strokeStyleMiterLimit = strokeStyle.getMiterLimit();
|
||||||
strokeStyleMiterLimit = strokeStyleMiterLimit !== undefined ?
|
strokeStyleMiterLimit = strokeStyleMiterLimit !== undefined ?
|
||||||
strokeStyleMiterLimit : _ol_render_webgl_.defaultMiterLimit;
|
strokeStyleMiterLimit : DEFAULT_MITERLIMIT;
|
||||||
if (!this.state_.strokeColor || !equals(this.state_.strokeColor, strokeStyleColor) ||
|
if (!this.state_.strokeColor || !equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||||
this.state_.lineWidth !== strokeStyleWidth || this.state_.miterLimit !== strokeStyleMiterLimit) {
|
this.state_.lineWidth !== strokeStyleWidth || this.state_.miterLimit !== strokeStyleMiterLimit) {
|
||||||
this.state_.changed = true;
|
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 Locations from '../webgl/polygonreplay/defaultshader/Locations.js';
|
||||||
import WebGLLineStringReplay from '../webgl/LineStringReplay.js';
|
import WebGLLineStringReplay from '../webgl/LineStringReplay.js';
|
||||||
import WebGLReplay from '../webgl/Replay.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 Stroke from '../../style/Stroke.js';
|
||||||
import LinkedList from '../../structs/LinkedList.js';
|
import LinkedList from '../../structs/LinkedList.js';
|
||||||
import RBush from '../../structs/RBush.js';
|
import RBush from '../../structs/RBush.js';
|
||||||
import _ol_webgl_ from '../../webgl.js';
|
import {FLOAT} from '../../webgl.js';
|
||||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,9 +220,9 @@ WebGLPolygonReplay.prototype.classifyPoints_ = function(list, rtree, ccw) {
|
|||||||
let s1 = list.nextItem();
|
let s1 = list.nextItem();
|
||||||
let pointsReclassified = false;
|
let pointsReclassified = false;
|
||||||
do {
|
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) :
|
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);
|
s0.p1.y, s1.p1.x, s1.p1.y);
|
||||||
if (reflex === undefined) {
|
if (reflex === undefined) {
|
||||||
this.removeItem_(s0, s1, list, rtree);
|
this.removeItem_(s0, s1, list, rtree);
|
||||||
@@ -273,7 +273,7 @@ WebGLPolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
|
|||||||
const intersection = this.calculateIntersection_(p1, p2, currSeg.p0,
|
const intersection = this.calculateIntersection_(p1, p2, currSeg.p0,
|
||||||
currSeg.p1, true);
|
currSeg.p1, true);
|
||||||
const dist = Math.abs(p1.x - intersection[0]);
|
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) {
|
currSeg.p0.x, currSeg.p0.y, currSeg.p1.x, currSeg.p1.y) !== undefined) {
|
||||||
minDist = dist;
|
minDist = dist;
|
||||||
p5 = {x: intersection[0], y: intersection[1], i: -1};
|
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) {
|
if (denom !== 0) {
|
||||||
const ua = ((p3.x - p2.x) * (p0.y - p2.y) - (p3.y - p2.y) * (p0.x - p2.x)) / denom;
|
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;
|
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 &&
|
if ((!opt_touch && ua > EPSILON && ua < 1 - EPSILON &&
|
||||||
ub > _ol_render_webgl_.EPSILON && ub < 1 - _ol_render_webgl_.EPSILON) || (opt_touch &&
|
ub > EPSILON && ub < 1 - EPSILON) || (opt_touch &&
|
||||||
ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1)) {
|
ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1)) {
|
||||||
return [p0.x + ua * (p1.x - p0.x), p0.y + ua * (p1.y - p0.y)];
|
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
|
// enable the vertex attrib arrays
|
||||||
gl.enableVertexAttribArray(locations.a_position);
|
gl.enableVertexAttribArray(locations.a_position);
|
||||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
|
||||||
false, 8, 0);
|
false, 8, 0);
|
||||||
|
|
||||||
return locations;
|
return locations;
|
||||||
@@ -1042,9 +1042,9 @@ WebGLPolygonReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyl
|
|||||||
!(fillStyleColor instanceof CanvasPattern)) {
|
!(fillStyleColor instanceof CanvasPattern)) {
|
||||||
fillStyleColor = asArray(fillStyleColor).map(function(c, i) {
|
fillStyleColor = asArray(fillStyleColor).map(function(c, i) {
|
||||||
return i != 3 ? c / 255 : c;
|
return i != 3 ? c / 255 : c;
|
||||||
}) || _ol_render_webgl_.defaultFillStyle;
|
}) || DEFAULT_FILLSTYLE;
|
||||||
} else {
|
} else {
|
||||||
fillStyleColor = _ol_render_webgl_.defaultFillStyle;
|
fillStyleColor = DEFAULT_FILLSTYLE;
|
||||||
}
|
}
|
||||||
if (!this.state_.fillColor || !equals(fillStyleColor, this.state_.fillColor)) {
|
if (!this.state_.fillColor || !equals(fillStyleColor, this.state_.fillColor)) {
|
||||||
this.state_.fillColor = fillStyleColor;
|
this.state_.fillColor = fillStyleColor;
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ import {
|
|||||||
translate as translateTransform
|
translate as translateTransform
|
||||||
} from '../../transform.js';
|
} from '../../transform.js';
|
||||||
import {create, fromTransform} from '../../vec/mat4.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
|
* @constructor
|
||||||
@@ -293,9 +294,9 @@ WebGLReplay.prototype.replay = function(context,
|
|||||||
gl.stencilFunc(gl.NOTEQUAL, 1, 255);
|
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);
|
const locations = this.setUpProgram(gl, context, size, pixelRatio);
|
||||||
|
|
||||||
@@ -359,11 +360,11 @@ WebGLReplay.prototype.replay = function(context,
|
|||||||
WebGLReplay.prototype.drawElements = function(
|
WebGLReplay.prototype.drawElements = function(
|
||||||
gl, context, start, end) {
|
gl, context, start, end) {
|
||||||
const elementType = context.hasOESElementIndexUint ?
|
const elementType = context.hasOESElementIndexUint ?
|
||||||
_ol_webgl_.UNSIGNED_INT : _ol_webgl_.UNSIGNED_SHORT;
|
UNSIGNED_INT : UNSIGNED_SHORT;
|
||||||
const elementSize = context.hasOESElementIndexUint ? 4 : 2;
|
const elementSize = context.hasOESElementIndexUint ? 4 : 2;
|
||||||
|
|
||||||
const numItems = end - start;
|
const numItems = end - start;
|
||||||
const offsetInBytes = start * elementSize;
|
const offsetInBytes = start * elementSize;
|
||||||
gl.drawElements(_ol_webgl_.TRIANGLES, numItems, elementType, offsetInBytes);
|
gl.drawElements(TRIANGLES, numItems, elementType, offsetInBytes);
|
||||||
};
|
};
|
||||||
export default WebGLReplay;
|
export default WebGLReplay;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {inherits} from '../../index.js';
|
|||||||
import {numberSafeCompareFunction} from '../../array.js';
|
import {numberSafeCompareFunction} from '../../array.js';
|
||||||
import {buffer, createOrUpdateFromCoordinate} from '../../extent.js';
|
import {buffer, createOrUpdateFromCoordinate} from '../../extent.js';
|
||||||
import {isEmpty} from '../../obj.js';
|
import {isEmpty} from '../../obj.js';
|
||||||
import _ol_render_replay_ from '../replay.js';
|
import {ORDER} from '../replay.js';
|
||||||
import ReplayGroup from '../ReplayGroup.js';
|
import ReplayGroup from '../ReplayGroup.js';
|
||||||
import WebGLCircleReplay from '../webgl/CircleReplay.js';
|
import WebGLCircleReplay from '../webgl/CircleReplay.js';
|
||||||
import WebGLImageReplay from '../webgl/ImageReplay.js';
|
import WebGLImageReplay from '../webgl/ImageReplay.js';
|
||||||
@@ -171,8 +171,8 @@ WebGLReplayGroup.prototype.replay = function(context,
|
|||||||
let i, ii, j, jj, replays, replay;
|
let i, ii, j, jj, replays, replay;
|
||||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||||
replays = this.replaysByZIndex_[zs[i].toString()];
|
replays = this.replaysByZIndex_[zs[i].toString()];
|
||||||
for (j = 0, jj = _ol_render_replay_.ORDER.length; j < jj; ++j) {
|
for (j = 0, jj = ORDER.length; j < jj; ++j) {
|
||||||
replay = replays[_ol_render_replay_.ORDER[j]];
|
replay = replays[ORDER[j]];
|
||||||
if (replay !== undefined) {
|
if (replay !== undefined) {
|
||||||
replay.replay(context,
|
replay.replay(context,
|
||||||
center, resolution, rotation, size, pixelRatio,
|
center, resolution, rotation, size, pixelRatio,
|
||||||
@@ -214,8 +214,8 @@ WebGLReplayGroup.prototype.replayHitDetection_ = function(context,
|
|||||||
let i, ii, j, replays, replay, result;
|
let i, ii, j, replays, replay, result;
|
||||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||||
replays = this.replaysByZIndex_[zs[i].toString()];
|
replays = this.replaysByZIndex_[zs[i].toString()];
|
||||||
for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) {
|
for (j = ORDER.length - 1; j >= 0; --j) {
|
||||||
replay = replays[_ol_render_replay_.ORDER[j]];
|
replay = replays[ORDER[j]];
|
||||||
if (replay !== undefined) {
|
if (replay !== undefined) {
|
||||||
result = replay.replay(context,
|
result = replay.replay(context,
|
||||||
center, resolution, rotation, size, pixelRatio, opacity,
|
center, resolution, rotation, size, pixelRatio, opacity,
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import {asColorLike} from '../../colorlike.js';
|
|||||||
import {createCanvasContext2D} from '../../dom.js';
|
import {createCanvasContext2D} from '../../dom.js';
|
||||||
import GeometryType from '../../geom/GeometryType.js';
|
import GeometryType from '../../geom/GeometryType.js';
|
||||||
import {CANVAS_LINE_DASH} from '../../has.js';
|
import {CANVAS_LINE_DASH} from '../../has.js';
|
||||||
import _ol_render_replay_ from '../replay.js';
|
import {TEXT_ALIGN} from '../replay.js';
|
||||||
import _ol_render_webgl_ from '../webgl.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 WebGLTextureReplay from '../webgl/TextureReplay.js';
|
||||||
import AtlasManager from '../../style/AtlasManager.js';
|
import AtlasManager from '../../style/AtlasManager.js';
|
||||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||||
@@ -356,7 +358,7 @@ WebGLTextReplay.prototype.setTextStyle = function(textStyle) {
|
|||||||
} else {
|
} else {
|
||||||
const textFillStyleColor = textFillStyle.getColor();
|
const textFillStyleColor = textFillStyle.getColor();
|
||||||
state.fillColor = asColorLike(textFillStyleColor ?
|
state.fillColor = asColorLike(textFillStyleColor ?
|
||||||
textFillStyleColor : _ol_render_webgl_.defaultFillStyle);
|
textFillStyleColor : DEFAULT_FILLSTYLE);
|
||||||
}
|
}
|
||||||
if (!textStrokeStyle) {
|
if (!textStrokeStyle) {
|
||||||
state.strokeColor = null;
|
state.strokeColor = null;
|
||||||
@@ -364,24 +366,24 @@ WebGLTextReplay.prototype.setTextStyle = function(textStyle) {
|
|||||||
} else {
|
} else {
|
||||||
const textStrokeStyleColor = textStrokeStyle.getColor();
|
const textStrokeStyleColor = textStrokeStyle.getColor();
|
||||||
state.strokeColor = asColorLike(textStrokeStyleColor ?
|
state.strokeColor = asColorLike(textStrokeStyleColor ?
|
||||||
textStrokeStyleColor : _ol_render_webgl_.defaultStrokeStyle);
|
textStrokeStyleColor : DEFAULT_STROKESTYLE);
|
||||||
state.lineWidth = textStrokeStyle.getWidth() || _ol_render_webgl_.defaultLineWidth;
|
state.lineWidth = textStrokeStyle.getWidth() || DEFAULT_LINEWIDTH;
|
||||||
state.lineCap = textStrokeStyle.getLineCap() || _ol_render_webgl_.defaultLineCap;
|
state.lineCap = textStrokeStyle.getLineCap() || DEFAULT_LINECAP;
|
||||||
state.lineDashOffset = textStrokeStyle.getLineDashOffset() || _ol_render_webgl_.defaultLineDashOffset;
|
state.lineDashOffset = textStrokeStyle.getLineDashOffset() || DEFAULT_LINEDASHOFFSET;
|
||||||
state.lineJoin = textStrokeStyle.getLineJoin() || _ol_render_webgl_.defaultLineJoin;
|
state.lineJoin = textStrokeStyle.getLineJoin() || DEFAULT_LINEJOIN;
|
||||||
state.miterLimit = textStrokeStyle.getMiterLimit() || _ol_render_webgl_.defaultMiterLimit;
|
state.miterLimit = textStrokeStyle.getMiterLimit() || DEFAULT_MITERLIMIT;
|
||||||
const lineDash = textStrokeStyle.getLineDash();
|
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;
|
state.scale = textStyle.getScale() || 1;
|
||||||
this.text_ = /** @type {string} */ (textStyle.getText());
|
this.text_ = /** @type {string} */ (textStyle.getText());
|
||||||
const textAlign = _ol_render_replay_.TEXT_ALIGN[textStyle.getTextAlign()];
|
const textAlign = TEXT_ALIGN[textStyle.getTextAlign()];
|
||||||
const textBaseline = _ol_render_replay_.TEXT_ALIGN[textStyle.getTextBaseline()];
|
const textBaseline = TEXT_ALIGN[textStyle.getTextBaseline()];
|
||||||
this.textAlign_ = textAlign === undefined ?
|
this.textAlign_ = textAlign === undefined ?
|
||||||
_ol_render_webgl_.defaultTextAlign : textAlign;
|
DEFAULT_TEXTALIGN : textAlign;
|
||||||
this.textBaseline_ = textBaseline === undefined ?
|
this.textBaseline_ = textBaseline === undefined ?
|
||||||
_ol_render_webgl_.defaultTextBaseline : textBaseline;
|
DEFAULT_TEXTBASELINE : textBaseline;
|
||||||
this.offsetX_ = textStyle.getOffsetX() || 0;
|
this.offsetX_ = textStyle.getOffsetX() || 0;
|
||||||
this.offsetY_ = textStyle.getOffsetY() || 0;
|
this.offsetY_ = textStyle.getOffsetY() || 0;
|
||||||
this.rotateWithView = !!textStyle.getRotateWithView();
|
this.rotateWithView = !!textStyle.getRotateWithView();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {isEmpty} from '../../obj.js';
|
|||||||
import {fragment, vertex} from '../webgl/texturereplay/defaultshader.js';
|
import {fragment, vertex} from '../webgl/texturereplay/defaultshader.js';
|
||||||
import Locations from '../webgl/texturereplay/defaultshader/Locations.js';
|
import Locations from '../webgl/texturereplay/defaultshader/Locations.js';
|
||||||
import WebGLReplay from '../webgl/Replay.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';
|
import {createTexture} from '../../webgl/Context.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,7 +258,7 @@ WebGLTextureReplay.prototype.createTextures = function(textures, images, texture
|
|||||||
texture = texturePerImage[uid];
|
texture = texturePerImage[uid];
|
||||||
} else {
|
} else {
|
||||||
texture = createTexture(
|
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;
|
texturePerImage[uid] = texture;
|
||||||
}
|
}
|
||||||
textures[i] = texture;
|
textures[i] = texture;
|
||||||
@@ -287,23 +287,23 @@ WebGLTextureReplay.prototype.setUpProgram = function(gl, context, size, pixelRat
|
|||||||
|
|
||||||
// enable the vertex attrib arrays
|
// enable the vertex attrib arrays
|
||||||
gl.enableVertexAttribArray(locations.a_position);
|
gl.enableVertexAttribArray(locations.a_position);
|
||||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
|
||||||
false, 32, 0);
|
false, 32, 0);
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_offsets);
|
gl.enableVertexAttribArray(locations.a_offsets);
|
||||||
gl.vertexAttribPointer(locations.a_offsets, 2, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_offsets, 2, FLOAT,
|
||||||
false, 32, 8);
|
false, 32, 8);
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_texCoord);
|
gl.enableVertexAttribArray(locations.a_texCoord);
|
||||||
gl.vertexAttribPointer(locations.a_texCoord, 2, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_texCoord, 2, FLOAT,
|
||||||
false, 32, 16);
|
false, 32, 16);
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_opacity);
|
gl.enableVertexAttribArray(locations.a_opacity);
|
||||||
gl.vertexAttribPointer(locations.a_opacity, 1, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_opacity, 1, FLOAT,
|
||||||
false, 32, 24);
|
false, 32, 24);
|
||||||
|
|
||||||
gl.enableVertexAttribArray(locations.a_rotateWithView);
|
gl.enableVertexAttribArray(locations.a_rotateWithView);
|
||||||
gl.vertexAttribPointer(locations.a_rotateWithView, 1, _ol_webgl_.FLOAT,
|
gl.vertexAttribPointer(locations.a_rotateWithView, 1, FLOAT,
|
||||||
false, 32, 28);
|
false, 32, 28);
|
||||||
|
|
||||||
return locations;
|
return locations;
|
||||||
@@ -334,7 +334,7 @@ WebGLTextureReplay.prototype.drawReplay = function(gl, context, skippedFeaturesH
|
|||||||
} else {
|
} else {
|
||||||
let i, ii, start;
|
let i, ii, start;
|
||||||
for (i = 0, ii = textures.length, start = 0; i < ii; ++i) {
|
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];
|
const end = groupIndices[i];
|
||||||
this.drawElements(gl, context, start, end);
|
this.drawElements(gl, context, start, end);
|
||||||
start = end;
|
start = end;
|
||||||
@@ -375,7 +375,7 @@ WebGLTextureReplay.prototype.drawReplaySkipping = function(gl, context, skippedF
|
|||||||
|
|
||||||
let i, ii;
|
let i, ii;
|
||||||
for (i = 0, ii = textures.length; i < ii; ++i) {
|
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 groupStart = (i > 0) ? groupIndices[i - 1] : 0;
|
||||||
const groupEnd = groupIndices[i];
|
const groupEnd = groupIndices[i];
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ WebGLTextureReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, conte
|
|||||||
let featureIndex = this.startIndices.length - 1;
|
let featureIndex = this.startIndices.length - 1;
|
||||||
const hitDetectionTextures = this.getHitDetectionTextures();
|
const hitDetectionTextures = this.getHitDetectionTextures();
|
||||||
for (i = hitDetectionTextures.length - 1; i >= 0; --i) {
|
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;
|
groupStart = (i > 0) ? this.hitDetectionGroupIndices[i - 1] : 0;
|
||||||
end = this.hitDetectionGroupIndices[i];
|
end = this.hitDetectionGroupIndices[i];
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import Units from '../../proj/Units.js';
|
|||||||
import ReplayType from '../../render/ReplayType.js';
|
import ReplayType from '../../render/ReplayType.js';
|
||||||
import {labelCache, rotateAtOffset} from '../../render/canvas.js';
|
import {labelCache, rotateAtOffset} from '../../render/canvas.js';
|
||||||
import CanvasReplayGroup from '../../render/canvas/ReplayGroup.js';
|
import CanvasReplayGroup from '../../render/canvas/ReplayGroup.js';
|
||||||
import _ol_render_replay_ from '../../render/replay.js';
|
import {ORDER} from '../../render/replay.js';
|
||||||
import RendererType from '../Type.js';
|
import RendererType from '../Type.js';
|
||||||
import CanvasTileLayerRenderer from '../canvas/TileLayer.js';
|
import CanvasTileLayerRenderer from '../canvas/TileLayer.js';
|
||||||
import {getSquaredTolerance as getSquaredRenderTolerance, renderFeature} from '../vector.js';
|
import {getSquaredTolerance as getSquaredRenderTolerance, renderFeature} from '../vector.js';
|
||||||
@@ -44,7 +44,7 @@ const IMAGE_REPLAYS = {
|
|||||||
const VECTOR_REPLAYS = {
|
const VECTOR_REPLAYS = {
|
||||||
'image': [ReplayType.DEFAULT],
|
'image': [ReplayType.DEFAULT],
|
||||||
'hybrid': [ReplayType.IMAGE, ReplayType.TEXT, ReplayType.DEFAULT],
|
'hybrid': [ReplayType.IMAGE, ReplayType.TEXT, ReplayType.DEFAULT],
|
||||||
'vector': _ol_render_replay_.ORDER
|
'vector': ORDER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
invert as invertTransform,
|
invert as invertTransform,
|
||||||
multiply as multiplyTransform
|
multiply as multiplyTransform
|
||||||
} from '../../transform.js';
|
} from '../../transform.js';
|
||||||
import _ol_webgl_ from '../../webgl.js';
|
import {CLAMP_TO_EDGE} from '../../webgl.js';
|
||||||
import {createTexture} from '../../webgl/Context.js';
|
import {createTexture} from '../../webgl/Context.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +98,7 @@ WebGLImageLayerRenderer.prototype.createTexture_ = function(image) {
|
|||||||
const gl = this.mapRenderer.getGL();
|
const gl = this.mapRenderer.getGL();
|
||||||
|
|
||||||
return createTexture(
|
return createTexture(
|
||||||
gl, imageElement, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE);
|
gl, imageElement, CLAMP_TO_EDGE, CLAMP_TO_EDGE);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import {fragment, vertex} from '../webgl/defaultmapshader.js';
|
|||||||
import Locations from '../webgl/defaultmapshader/Locations.js';
|
import Locations from '../webgl/defaultmapshader/Locations.js';
|
||||||
import {create as createTransform} from '../../transform.js';
|
import {create as createTransform} from '../../transform.js';
|
||||||
import {create, fromTransform} from '../../vec/mat4.js';
|
import {create, fromTransform} from '../../vec/mat4.js';
|
||||||
import _ol_webgl_ from '../../webgl.js';
|
import {ARRAY_BUFFER, FRAMEBUFFER, FLOAT, TEXTURE_2D,
|
||||||
|
TRIANGLE_STRIP, COLOR_ATTACHMENT0} from '../../webgl.js';
|
||||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||||
import {createEmptyTexture} from '../../webgl/Context.js';
|
import {createEmptyTexture} from '../../webgl/Context.js';
|
||||||
|
|
||||||
@@ -120,16 +121,16 @@ WebGLLayerRenderer.prototype.bindFramebuffer = function(frameState, framebufferD
|
|||||||
gl, framebufferDimension, framebufferDimension);
|
gl, framebufferDimension, framebufferDimension);
|
||||||
|
|
||||||
const framebuffer = gl.createFramebuffer();
|
const framebuffer = gl.createFramebuffer();
|
||||||
gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, framebuffer);
|
gl.bindFramebuffer(FRAMEBUFFER, framebuffer);
|
||||||
gl.framebufferTexture2D(_ol_webgl_.FRAMEBUFFER,
|
gl.framebufferTexture2D(FRAMEBUFFER,
|
||||||
_ol_webgl_.COLOR_ATTACHMENT0, _ol_webgl_.TEXTURE_2D, texture, 0);
|
COLOR_ATTACHMENT0, TEXTURE_2D, texture, 0);
|
||||||
|
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
this.framebuffer = framebuffer;
|
this.framebuffer = framebuffer;
|
||||||
this.framebufferDimension = framebufferDimension;
|
this.framebufferDimension = framebufferDimension;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, this.framebuffer);
|
gl.bindFramebuffer(FRAMEBUFFER, this.framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -144,7 +145,7 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
|
|||||||
|
|
||||||
this.dispatchComposeEvent_(RenderEventType.PRECOMPOSE, context, frameState);
|
this.dispatchComposeEvent_(RenderEventType.PRECOMPOSE, context, frameState);
|
||||||
|
|
||||||
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.arrayBuffer_);
|
context.bindBuffer(ARRAY_BUFFER, this.arrayBuffer_);
|
||||||
|
|
||||||
const gl = context.getGL();
|
const gl = context.getGL();
|
||||||
|
|
||||||
@@ -161,10 +162,10 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
|
|||||||
if (context.useProgram(program)) {
|
if (context.useProgram(program)) {
|
||||||
gl.enableVertexAttribArray(locations.a_position);
|
gl.enableVertexAttribArray(locations.a_position);
|
||||||
gl.vertexAttribPointer(
|
gl.vertexAttribPointer(
|
||||||
locations.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0);
|
locations.a_position, 2, FLOAT, false, 16, 0);
|
||||||
gl.enableVertexAttribArray(locations.a_texCoord);
|
gl.enableVertexAttribArray(locations.a_texCoord);
|
||||||
gl.vertexAttribPointer(
|
gl.vertexAttribPointer(
|
||||||
locations.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8);
|
locations.a_texCoord, 2, FLOAT, false, 16, 8);
|
||||||
gl.uniform1i(locations.u_texture, 0);
|
gl.uniform1i(locations.u_texture, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,8 +174,8 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
|
|||||||
gl.uniformMatrix4fv(locations.u_projectionMatrix, false,
|
gl.uniformMatrix4fv(locations.u_projectionMatrix, false,
|
||||||
fromTransform(this.tmpMat4_, this.getProjectionMatrix()));
|
fromTransform(this.tmpMat4_, this.getProjectionMatrix()));
|
||||||
gl.uniform1f(locations.u_opacity, layerState.opacity);
|
gl.uniform1f(locations.u_opacity, layerState.opacity);
|
||||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, this.getTexture());
|
gl.bindTexture(TEXTURE_2D, this.getTexture());
|
||||||
gl.drawArrays(_ol_webgl_.TRIANGLE_STRIP, 0, 4);
|
gl.drawArrays(TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
this.dispatchComposeEvent_(RenderEventType.POSTCOMPOSE, context, frameState);
|
this.dispatchComposeEvent_(RenderEventType.POSTCOMPOSE, context, frameState);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ import RendererType from '../Type.js';
|
|||||||
import SourceState from '../../source/State.js';
|
import SourceState from '../../source/State.js';
|
||||||
import LRUCache from '../../structs/LRUCache.js';
|
import LRUCache from '../../structs/LRUCache.js';
|
||||||
import PriorityQueue from '../../structs/PriorityQueue.js';
|
import PriorityQueue from '../../structs/PriorityQueue.js';
|
||||||
import _ol_webgl_ from '../../webgl.js';
|
import {BLEND, CLAMP_TO_EDGE, COLOR_BUFFER_BIT, CULL_FACE, DEPTH_TEST, FRAMEBUFFER,
|
||||||
|
getContext, LINEAR, ONE, ONE_MINUS_SRC_ALPHA, RGBA, SCISSOR_TEST, SRC_ALPHA,
|
||||||
|
STENCIL_TEST, TEXTURE0, TEXTURE_2D, TEXTURE_MAG_FILTER, TEXTURE_MIN_FILTER,
|
||||||
|
TEXTURE_WRAP_S, TEXTURE_WRAP_T, UNSIGNED_BYTE} from '../../webgl.js';
|
||||||
import WebGLContext from '../../webgl/Context.js';
|
import WebGLContext from '../../webgl/Context.js';
|
||||||
import ContextEventType from '../../webgl/ContextEventType.js';
|
import ContextEventType from '../../webgl/ContextEventType.js';
|
||||||
|
|
||||||
@@ -79,7 +82,7 @@ const WebGLMapRenderer = function(container, map) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {WebGLRenderingContext}
|
* @type {WebGLRenderingContext}
|
||||||
*/
|
*/
|
||||||
this.gl_ = _ol_webgl_.getContext(this.canvas_, {
|
this.gl_ = getContext(this.canvas_, {
|
||||||
antialias: true,
|
antialias: true,
|
||||||
depth: true,
|
depth: true,
|
||||||
failIfMajorPerformanceCaveat: true,
|
failIfMajorPerformanceCaveat: true,
|
||||||
@@ -152,7 +155,7 @@ const WebGLMapRenderer = function(container, map) {
|
|||||||
const tileSize = /** @type {ol.Size} */ (element[3]);
|
const tileSize = /** @type {ol.Size} */ (element[3]);
|
||||||
const tileGutter = /** @type {number} */ (element[4]);
|
const tileGutter = /** @type {number} */ (element[4]);
|
||||||
this.bindTileTexture(
|
this.bindTileTexture(
|
||||||
tile, tileSize, tileGutter, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR);
|
tile, tileSize, tileGutter, LINEAR, LINEAR);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
@@ -203,20 +206,20 @@ WebGLMapRenderer.prototype.bindTileTexture = function(tile, tileSize, tileGutter
|
|||||||
const tileKey = tile.getKey();
|
const tileKey = tile.getKey();
|
||||||
if (this.textureCache_.containsKey(tileKey)) {
|
if (this.textureCache_.containsKey(tileKey)) {
|
||||||
const textureCacheEntry = this.textureCache_.get(tileKey);
|
const textureCacheEntry = this.textureCache_.get(tileKey);
|
||||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, textureCacheEntry.texture);
|
gl.bindTexture(TEXTURE_2D, textureCacheEntry.texture);
|
||||||
if (textureCacheEntry.magFilter != magFilter) {
|
if (textureCacheEntry.magFilter != magFilter) {
|
||||||
gl.texParameteri(
|
gl.texParameteri(
|
||||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter);
|
TEXTURE_2D, TEXTURE_MAG_FILTER, magFilter);
|
||||||
textureCacheEntry.magFilter = magFilter;
|
textureCacheEntry.magFilter = magFilter;
|
||||||
}
|
}
|
||||||
if (textureCacheEntry.minFilter != minFilter) {
|
if (textureCacheEntry.minFilter != minFilter) {
|
||||||
gl.texParameteri(
|
gl.texParameteri(
|
||||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter);
|
TEXTURE_2D, TEXTURE_MIN_FILTER, minFilter);
|
||||||
textureCacheEntry.minFilter = minFilter;
|
textureCacheEntry.minFilter = minFilter;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const texture = gl.createTexture();
|
const texture = gl.createTexture();
|
||||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, texture);
|
gl.bindTexture(TEXTURE_2D, texture);
|
||||||
if (tileGutter > 0) {
|
if (tileGutter > 0) {
|
||||||
const clipTileCanvas = this.clipTileContext_.canvas;
|
const clipTileCanvas = this.clipTileContext_.canvas;
|
||||||
const clipTileContext = this.clipTileContext_;
|
const clipTileContext = this.clipTileContext_;
|
||||||
@@ -231,22 +234,22 @@ WebGLMapRenderer.prototype.bindTileTexture = function(tile, tileSize, tileGutter
|
|||||||
}
|
}
|
||||||
clipTileContext.drawImage(tile.getImage(), tileGutter, tileGutter,
|
clipTileContext.drawImage(tile.getImage(), tileGutter, tileGutter,
|
||||||
tileSize[0], tileSize[1], 0, 0, tileSize[0], tileSize[1]);
|
tileSize[0], tileSize[1], 0, 0, tileSize[0], tileSize[1]);
|
||||||
gl.texImage2D(_ol_webgl_.TEXTURE_2D, 0,
|
gl.texImage2D(TEXTURE_2D, 0,
|
||||||
_ol_webgl_.RGBA, _ol_webgl_.RGBA,
|
RGBA, RGBA,
|
||||||
_ol_webgl_.UNSIGNED_BYTE, clipTileCanvas);
|
UNSIGNED_BYTE, clipTileCanvas);
|
||||||
} else {
|
} else {
|
||||||
gl.texImage2D(_ol_webgl_.TEXTURE_2D, 0,
|
gl.texImage2D(TEXTURE_2D, 0,
|
||||||
_ol_webgl_.RGBA, _ol_webgl_.RGBA,
|
RGBA, RGBA,
|
||||||
_ol_webgl_.UNSIGNED_BYTE, tile.getImage());
|
UNSIGNED_BYTE, tile.getImage());
|
||||||
}
|
}
|
||||||
gl.texParameteri(
|
gl.texParameteri(
|
||||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter);
|
TEXTURE_2D, TEXTURE_MAG_FILTER, magFilter);
|
||||||
gl.texParameteri(
|
gl.texParameteri(
|
||||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter);
|
TEXTURE_2D, TEXTURE_MIN_FILTER, minFilter);
|
||||||
gl.texParameteri(_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_S,
|
gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S,
|
||||||
_ol_webgl_.CLAMP_TO_EDGE);
|
CLAMP_TO_EDGE);
|
||||||
gl.texParameteri(_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_T,
|
gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T,
|
||||||
_ol_webgl_.CLAMP_TO_EDGE);
|
CLAMP_TO_EDGE);
|
||||||
this.textureCache_.set(tileKey, {
|
this.textureCache_.set(tileKey, {
|
||||||
texture: texture,
|
texture: texture,
|
||||||
magFilter: magFilter,
|
magFilter: magFilter,
|
||||||
@@ -394,14 +397,14 @@ WebGLMapRenderer.prototype.handleWebGLContextRestored = function() {
|
|||||||
*/
|
*/
|
||||||
WebGLMapRenderer.prototype.initializeGL_ = function() {
|
WebGLMapRenderer.prototype.initializeGL_ = function() {
|
||||||
const gl = this.gl_;
|
const gl = this.gl_;
|
||||||
gl.activeTexture(_ol_webgl_.TEXTURE0);
|
gl.activeTexture(TEXTURE0);
|
||||||
gl.blendFuncSeparate(
|
gl.blendFuncSeparate(
|
||||||
_ol_webgl_.SRC_ALPHA, _ol_webgl_.ONE_MINUS_SRC_ALPHA,
|
SRC_ALPHA, ONE_MINUS_SRC_ALPHA,
|
||||||
_ol_webgl_.ONE, _ol_webgl_.ONE_MINUS_SRC_ALPHA);
|
ONE, ONE_MINUS_SRC_ALPHA);
|
||||||
gl.disable(_ol_webgl_.CULL_FACE);
|
gl.disable(CULL_FACE);
|
||||||
gl.disable(_ol_webgl_.DEPTH_TEST);
|
gl.disable(DEPTH_TEST);
|
||||||
gl.disable(_ol_webgl_.SCISSOR_TEST);
|
gl.disable(SCISSOR_TEST);
|
||||||
gl.disable(_ol_webgl_.STENCIL_TEST);
|
gl.disable(STENCIL_TEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -466,11 +469,11 @@ WebGLMapRenderer.prototype.renderFrame = function(frameState) {
|
|||||||
this.canvas_.height = height;
|
this.canvas_.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, null);
|
gl.bindFramebuffer(FRAMEBUFFER, null);
|
||||||
|
|
||||||
gl.clearColor(0, 0, 0, 0);
|
gl.clearColor(0, 0, 0, 0);
|
||||||
gl.clear(_ol_webgl_.COLOR_BUFFER_BIT);
|
gl.clear(COLOR_BUFFER_BIT);
|
||||||
gl.enable(_ol_webgl_.BLEND);
|
gl.enable(BLEND);
|
||||||
gl.viewport(0, 0, this.canvas_.width, this.canvas_.height);
|
gl.viewport(0, 0, this.canvas_.width, this.canvas_.height);
|
||||||
|
|
||||||
for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) {
|
for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
translate as translateTransform,
|
translate as translateTransform,
|
||||||
apply as applyTransform
|
apply as applyTransform
|
||||||
} from '../../transform.js';
|
} from '../../transform.js';
|
||||||
import _ol_webgl_ from '../../webgl.js';
|
import {COLOR_BUFFER_BIT, BLEND, ARRAY_BUFFER, FLOAT, LINEAR, TRIANGLE_STRIP} from '../../webgl.js';
|
||||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,8 +223,8 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
|||||||
gl.viewport(0, 0, framebufferDimension, framebufferDimension);
|
gl.viewport(0, 0, framebufferDimension, framebufferDimension);
|
||||||
|
|
||||||
gl.clearColor(0, 0, 0, 0);
|
gl.clearColor(0, 0, 0, 0);
|
||||||
gl.clear(_ol_webgl_.COLOR_BUFFER_BIT);
|
gl.clear(COLOR_BUFFER_BIT);
|
||||||
gl.disable(_ol_webgl_.BLEND);
|
gl.disable(BLEND);
|
||||||
|
|
||||||
const program = context.getProgram(this.fragmentShader_, this.vertexShader_);
|
const program = context.getProgram(this.fragmentShader_, this.vertexShader_);
|
||||||
context.useProgram(program);
|
context.useProgram(program);
|
||||||
@@ -232,13 +232,13 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
|||||||
this.locations_ = new Locations(gl, program);
|
this.locations_ = new Locations(gl, program);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.renderArrayBuffer_);
|
context.bindBuffer(ARRAY_BUFFER, this.renderArrayBuffer_);
|
||||||
gl.enableVertexAttribArray(this.locations_.a_position);
|
gl.enableVertexAttribArray(this.locations_.a_position);
|
||||||
gl.vertexAttribPointer(
|
gl.vertexAttribPointer(
|
||||||
this.locations_.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0);
|
this.locations_.a_position, 2, FLOAT, false, 16, 0);
|
||||||
gl.enableVertexAttribArray(this.locations_.a_texCoord);
|
gl.enableVertexAttribArray(this.locations_.a_texCoord);
|
||||||
gl.vertexAttribPointer(
|
gl.vertexAttribPointer(
|
||||||
this.locations_.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8);
|
this.locations_.a_texCoord, 2, FLOAT, false, 16, 8);
|
||||||
gl.uniform1i(this.locations_.u_texture, 0);
|
gl.uniform1i(this.locations_.u_texture, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -320,8 +320,8 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
|||||||
framebufferExtentDimension - 1;
|
framebufferExtentDimension - 1;
|
||||||
gl.uniform4fv(this.locations_.u_tileOffset, u_tileOffset);
|
gl.uniform4fv(this.locations_.u_tileOffset, u_tileOffset);
|
||||||
mapRenderer.bindTileTexture(tile, tilePixelSize,
|
mapRenderer.bindTileTexture(tile, tilePixelSize,
|
||||||
tileGutter * pixelRatio, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR);
|
tileGutter * pixelRatio, LINEAR, LINEAR);
|
||||||
gl.drawArrays(_ol_webgl_.TRIANGLE_STRIP, 0, 4);
|
gl.drawArrays(TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/webgl
|
* @module ol/webgl
|
||||||
*/
|
*/
|
||||||
const _ol_webgl_ = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants taken from goog.webgl
|
* Constants taken from goog.webgl
|
||||||
@@ -12,245 +11,245 @@ const _ol_webgl_ = {};
|
|||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.ONE = 1;
|
export const ONE = 1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.SRC_ALPHA = 0x0302;
|
export const SRC_ALPHA = 0x0302;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.COLOR_ATTACHMENT0 = 0x8CE0;
|
export const COLOR_ATTACHMENT0 = 0x8CE0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.COLOR_BUFFER_BIT = 0x00004000;
|
export const COLOR_BUFFER_BIT = 0x00004000;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.TRIANGLES = 0x0004;
|
export const TRIANGLES = 0x0004;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.TRIANGLE_STRIP = 0x0005;
|
export const TRIANGLE_STRIP = 0x0005;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.ONE_MINUS_SRC_ALPHA = 0x0303;
|
export const ONE_MINUS_SRC_ALPHA = 0x0303;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.ARRAY_BUFFER = 0x8892;
|
export const ARRAY_BUFFER = 0x8892;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.ELEMENT_ARRAY_BUFFER = 0x8893;
|
export const ELEMENT_ARRAY_BUFFER = 0x8893;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.STREAM_DRAW = 0x88E0;
|
export const STREAM_DRAW = 0x88E0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.STATIC_DRAW = 0x88E4;
|
export const STATIC_DRAW = 0x88E4;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.DYNAMIC_DRAW = 0x88E8;
|
export const DYNAMIC_DRAW = 0x88E8;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.CULL_FACE = 0x0B44;
|
export const CULL_FACE = 0x0B44;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.BLEND = 0x0BE2;
|
export const BLEND = 0x0BE2;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.STENCIL_TEST = 0x0B90;
|
export const STENCIL_TEST = 0x0B90;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.DEPTH_TEST = 0x0B71;
|
export const DEPTH_TEST = 0x0B71;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.SCISSOR_TEST = 0x0C11;
|
export const SCISSOR_TEST = 0x0C11;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.UNSIGNED_BYTE = 0x1401;
|
export const UNSIGNED_BYTE = 0x1401;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.UNSIGNED_SHORT = 0x1403;
|
export const UNSIGNED_SHORT = 0x1403;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.UNSIGNED_INT = 0x1405;
|
export const UNSIGNED_INT = 0x1405;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.FLOAT = 0x1406;
|
export const FLOAT = 0x1406;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.RGBA = 0x1908;
|
export const RGBA = 0x1908;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.FRAGMENT_SHADER = 0x8B30;
|
export const FRAGMENT_SHADER = 0x8B30;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.VERTEX_SHADER = 0x8B31;
|
export const VERTEX_SHADER = 0x8B31;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.LINK_STATUS = 0x8B82;
|
export const LINK_STATUS = 0x8B82;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.LINEAR = 0x2601;
|
export const LINEAR = 0x2601;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.TEXTURE_MAG_FILTER = 0x2800;
|
export const TEXTURE_MAG_FILTER = 0x2800;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.TEXTURE_MIN_FILTER = 0x2801;
|
export const TEXTURE_MIN_FILTER = 0x2801;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.TEXTURE_WRAP_S = 0x2802;
|
export const TEXTURE_WRAP_S = 0x2802;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.TEXTURE_WRAP_T = 0x2803;
|
export const TEXTURE_WRAP_T = 0x2803;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.TEXTURE_2D = 0x0DE1;
|
export const TEXTURE_2D = 0x0DE1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.TEXTURE0 = 0x84C0;
|
export const TEXTURE0 = 0x84C0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.CLAMP_TO_EDGE = 0x812F;
|
export const CLAMP_TO_EDGE = 0x812F;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.COMPILE_STATUS = 0x8B81;
|
export const COMPILE_STATUS = 0x8B81;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.FRAMEBUFFER = 0x8D40;
|
export const FRAMEBUFFER = 0x8D40;
|
||||||
|
|
||||||
|
|
||||||
/** end of goog.webgl constants
|
/** end of goog.webgl constants
|
||||||
@@ -262,7 +261,7 @@ _ol_webgl_.FRAMEBUFFER = 0x8D40;
|
|||||||
* @private
|
* @private
|
||||||
* @type {Array.<string>}
|
* @type {Array.<string>}
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.CONTEXT_IDS_ = [
|
export const CONTEXT_IDS_ = [
|
||||||
'experimental-webgl',
|
'experimental-webgl',
|
||||||
'webgl',
|
'webgl',
|
||||||
'webkit-3d',
|
'webkit-3d',
|
||||||
@@ -275,11 +274,11 @@ _ol_webgl_.CONTEXT_IDS_ = [
|
|||||||
* @param {Object=} opt_attributes Attributes.
|
* @param {Object=} opt_attributes Attributes.
|
||||||
* @return {WebGLRenderingContext} WebGL rendering context.
|
* @return {WebGLRenderingContext} WebGL rendering context.
|
||||||
*/
|
*/
|
||||||
_ol_webgl_.getContext = function(canvas, opt_attributes) {
|
export function getContext(canvas, opt_attributes) {
|
||||||
const ii = _ol_webgl_.CONTEXT_IDS_.length;
|
const ii = CONTEXT_IDS_.length;
|
||||||
for (let i = 0; i < ii; ++i) {
|
for (let i = 0; i < ii; ++i) {
|
||||||
try {
|
try {
|
||||||
const context = canvas.getContext(_ol_webgl_.CONTEXT_IDS_[i], opt_attributes);
|
const context = canvas.getContext(CONTEXT_IDS_[i], opt_attributes);
|
||||||
if (context) {
|
if (context) {
|
||||||
return /** @type {!WebGLRenderingContext} */ (context);
|
return /** @type {!WebGLRenderingContext} */ (context);
|
||||||
}
|
}
|
||||||
@@ -288,5 +287,4 @@ _ol_webgl_.getContext = function(canvas, opt_attributes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
}
|
||||||
export default _ol_webgl_;
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/webgl/Buffer
|
* @module ol/webgl/Buffer
|
||||||
*/
|
*/
|
||||||
import _ol_webgl_ from '../webgl.js';
|
import {STATIC_DRAW, STREAM_DRAW, DYNAMIC_DRAW} from '../webgl.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
*/
|
*/
|
||||||
const BufferUsage = {
|
const BufferUsage = {
|
||||||
STATIC_DRAW: _ol_webgl_.STATIC_DRAW,
|
STATIC_DRAW: STATIC_DRAW,
|
||||||
STREAM_DRAW: _ol_webgl_.STREAM_DRAW,
|
STREAM_DRAW: STREAM_DRAW,
|
||||||
DYNAMIC_DRAW: _ol_webgl_.DYNAMIC_DRAW
|
DYNAMIC_DRAW: DYNAMIC_DRAW
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Disposable from '../Disposable.js';
|
|||||||
import {includes} from '../array.js';
|
import {includes} from '../array.js';
|
||||||
import {listen, unlistenAll} from '../events.js';
|
import {listen, unlistenAll} from '../events.js';
|
||||||
import {clear} from '../obj.js';
|
import {clear} from '../obj.js';
|
||||||
import _ol_webgl_ from '../webgl.js';
|
import {ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, TEXTURE_2D, TEXTURE_WRAP_S, TEXTURE_WRAP_T} from '../webgl.js';
|
||||||
import ContextEventType from '../webgl/ContextEventType.js';
|
import ContextEventType from '../webgl/ContextEventType.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,9 +112,9 @@ WebGLContext.prototype.bindBuffer = function(target, buf) {
|
|||||||
const buffer = gl.createBuffer();
|
const buffer = gl.createBuffer();
|
||||||
gl.bindBuffer(target, buffer);
|
gl.bindBuffer(target, buffer);
|
||||||
let /** @type {ArrayBufferView} */ arrayBuffer;
|
let /** @type {ArrayBufferView} */ arrayBuffer;
|
||||||
if (target == _ol_webgl_.ARRAY_BUFFER) {
|
if (target == ARRAY_BUFFER) {
|
||||||
arrayBuffer = new Float32Array(arr);
|
arrayBuffer = new Float32Array(arr);
|
||||||
} else if (target == _ol_webgl_.ELEMENT_ARRAY_BUFFER) {
|
} else if (target == ELEMENT_ARRAY_BUFFER) {
|
||||||
arrayBuffer = this.hasOESElementIndexUint ?
|
arrayBuffer = this.hasOESElementIndexUint ?
|
||||||
new Uint32Array(arr) : new Uint16Array(arr);
|
new Uint32Array(arr) : new Uint16Array(arr);
|
||||||
}
|
}
|
||||||
@@ -323,11 +323,11 @@ function createTextureInternal(gl, opt_wrapS, opt_wrapT) {
|
|||||||
|
|
||||||
if (opt_wrapS !== undefined) {
|
if (opt_wrapS !== undefined) {
|
||||||
gl.texParameteri(
|
gl.texParameteri(
|
||||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_S, opt_wrapS);
|
TEXTURE_2D, TEXTURE_WRAP_S, opt_wrapS);
|
||||||
}
|
}
|
||||||
if (opt_wrapT !== undefined) {
|
if (opt_wrapT !== undefined) {
|
||||||
gl.texParameteri(
|
gl.texParameteri(
|
||||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_T, opt_wrapT);
|
TEXTURE_2D, TEXTURE_WRAP_T, opt_wrapT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @module ol/webgl/Fragment
|
* @module ol/webgl/Fragment
|
||||||
*/
|
*/
|
||||||
import {inherits} from '../index.js';
|
import {inherits} from '../index.js';
|
||||||
import _ol_webgl_ from '../webgl.js';
|
import {FRAGMENT_SHADER} from '../webgl.js';
|
||||||
import WebGLShader from '../webgl/Shader.js';
|
import WebGLShader from '../webgl/Shader.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +22,6 @@ inherits(WebGLFragment, WebGLShader);
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
WebGLFragment.prototype.getType = function() {
|
WebGLFragment.prototype.getType = function() {
|
||||||
return _ol_webgl_.FRAGMENT_SHADER;
|
return FRAGMENT_SHADER;
|
||||||
};
|
};
|
||||||
export default WebGLFragment;
|
export default WebGLFragment;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @module ol/webgl/Vertex
|
* @module ol/webgl/Vertex
|
||||||
*/
|
*/
|
||||||
import {inherits} from '../index.js';
|
import {inherits} from '../index.js';
|
||||||
import _ol_webgl_ from '../webgl.js';
|
import {VERTEX_SHADER} from '../webgl.js';
|
||||||
import WebGLShader from '../webgl/Shader.js';
|
import WebGLShader from '../webgl/Shader.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +22,6 @@ inherits(WebGLVertex, WebGLShader);
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
WebGLVertex.prototype.getType = function() {
|
WebGLVertex.prototype.getType = function() {
|
||||||
return _ol_webgl_.VERTEX_SHADER;
|
return VERTEX_SHADER;
|
||||||
};
|
};
|
||||||
export default WebGLVertex;
|
export default WebGLVertex;
|
||||||
|
|||||||
Reference in New Issue
Block a user