Remove ol.ENABLE_WEBGL condition from webgl files
This commit is contained in:
@@ -3,84 +3,82 @@ goog.provide('ol.render.webgl');
|
|||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultFont = '10px sans-serif';
|
ol.render.webgl.defaultFont = '10px sans-serif';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.Color}
|
* @type {ol.Color}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultFillStyle = [0.0, 0.0, 0.0, 1.0];
|
ol.render.webgl.defaultFillStyle = [0.0, 0.0, 0.0, 1.0];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultLineCap = 'round';
|
ol.render.webgl.defaultLineCap = 'round';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {Array.<number>}
|
* @type {Array.<number>}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultLineDash = [];
|
ol.render.webgl.defaultLineDash = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultLineDashOffset = 0;
|
ol.render.webgl.defaultLineDashOffset = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultLineJoin = 'round';
|
ol.render.webgl.defaultLineJoin = 'round';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultMiterLimit = 10;
|
ol.render.webgl.defaultMiterLimit = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {ol.Color}
|
* @type {ol.Color}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultStrokeStyle = [0.0, 0.0, 0.0, 1.0];
|
ol.render.webgl.defaultStrokeStyle = [0.0, 0.0, 0.0, 1.0];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultTextAlign = 0.5;
|
ol.render.webgl.defaultTextAlign = 0.5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultTextBaseline = 0.5;
|
ol.render.webgl.defaultTextBaseline = 0.5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.defaultLineWidth = 1;
|
ol.render.webgl.defaultLineWidth = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the orientation of a triangle based on the determinant method.
|
* Calculates the orientation of a triangle based on the determinant method.
|
||||||
* @param {number} x1 First X coordinate.
|
* @param {number} x1 First X coordinate.
|
||||||
* @param {number} y1 First Y coordinate.
|
* @param {number} y1 First Y coordinate.
|
||||||
@@ -90,16 +88,14 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @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) {
|
ol.render.webgl.triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) {
|
||||||
var area = (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1);
|
var area = (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1);
|
||||||
return (area <= ol.render.webgl.EPSILON && area >= -ol.render.webgl.EPSILON) ?
|
return (area <= ol.render.webgl.EPSILON && area >= -ol.render.webgl.EPSILON) ?
|
||||||
undefined : area > 0;
|
undefined : area > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.EPSILON = Number.EPSILON || 2.220446049250313e-16;
|
ol.render.webgl.EPSILON = Number.EPSILON || 2.220446049250313e-16;
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,16 +13,14 @@ goog.require('ol.webgl');
|
|||||||
goog.require('ol.webgl.Buffer');
|
goog.require('ol.webgl.Buffer');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.webgl.Replay}
|
* @extends {ol.render.webgl.Replay}
|
||||||
* @param {number} tolerance Tolerance.
|
* @param {number} tolerance Tolerance.
|
||||||
* @param {ol.Extent} maxExtent Max extent.
|
* @param {ol.Extent} maxExtent Max extent.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay = function(tolerance, maxExtent) {
|
ol.render.webgl.CircleReplay = function(tolerance, maxExtent) {
|
||||||
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,18 +65,18 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
changed: false
|
changed: false
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.CircleReplay, ol.render.webgl.Replay);
|
ol.inherits(ol.render.webgl.CircleReplay, ol.render.webgl.Replay);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
* @param {number} offset Offset.
|
* @param {number} offset Offset.
|
||||||
* @param {number} end End.
|
* @param {number} end End.
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.drawCoordinates_ = function(
|
ol.render.webgl.CircleReplay.prototype.drawCoordinates_ = function(
|
||||||
flatCoordinates, offset, end, stride) {
|
flatCoordinates, offset, end, stride) {
|
||||||
var numVertices = this.vertices.length;
|
var numVertices = this.vertices.length;
|
||||||
var numIndices = this.indices.length;
|
var numIndices = this.indices.length;
|
||||||
@@ -115,13 +113,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
|
|
||||||
n += 4;
|
n += 4;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
ol.render.webgl.CircleReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
||||||
var radius = circleGeometry.getRadius();
|
var radius = circleGeometry.getRadius();
|
||||||
var stride = circleGeometry.getStride();
|
var stride = circleGeometry.getStride();
|
||||||
if (radius) {
|
if (radius) {
|
||||||
@@ -149,13 +147,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
**/
|
**/
|
||||||
ol.render.webgl.CircleReplay.prototype.finish = function(context) {
|
ol.render.webgl.CircleReplay.prototype.finish = function(context) {
|
||||||
// create, bind, and populate the vertices buffer
|
// create, bind, and populate the vertices buffer
|
||||||
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
||||||
|
|
||||||
@@ -171,13 +169,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
|
|
||||||
this.vertices = null;
|
this.vertices = null;
|
||||||
this.indices = null;
|
this.indices = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.getDeleteResourcesFunction = function(context) {
|
ol.render.webgl.CircleReplay.prototype.getDeleteResourcesFunction = function(context) {
|
||||||
// We only delete our stuff here. The shaders and the program may
|
// We only delete our stuff here. The shaders and the program may
|
||||||
// be used by other CircleReplay instances (for other layers). And
|
// be used by other CircleReplay instances (for other layers). And
|
||||||
// they will be deleted when disposing of the ol.webgl.Context
|
// they will be deleted when disposing of the ol.webgl.Context
|
||||||
@@ -188,13 +186,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
context.deleteBuffer(verticesBuffer);
|
context.deleteBuffer(verticesBuffer);
|
||||||
context.deleteBuffer(indicesBuffer);
|
context.deleteBuffer(indicesBuffer);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
ol.render.webgl.CircleReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||||
// get the program
|
// get the program
|
||||||
var fragmentShader, vertexShader;
|
var fragmentShader, vertexShader;
|
||||||
fragmentShader = ol.render.webgl.circlereplay.defaultshader.fragment;
|
fragmentShader = ol.render.webgl.circlereplay.defaultshader.fragment;
|
||||||
@@ -231,23 +229,23 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
gl.uniform1f(locations.u_pixelRatio, pixelRatio);
|
gl.uniform1f(locations.u_pixelRatio, pixelRatio);
|
||||||
|
|
||||||
return locations;
|
return locations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.shutDownProgram = function(gl, locations) {
|
ol.render.webgl.CircleReplay.prototype.shutDownProgram = function(gl, locations) {
|
||||||
gl.disableVertexAttribArray(locations.a_position);
|
gl.disableVertexAttribArray(locations.a_position);
|
||||||
gl.disableVertexAttribArray(locations.a_instruction);
|
gl.disableVertexAttribArray(locations.a_instruction);
|
||||||
gl.disableVertexAttribArray(locations.a_radius);
|
gl.disableVertexAttribArray(locations.a_radius);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
ol.render.webgl.CircleReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||||
if (!ol.obj.isEmpty(skippedFeaturesHash)) {
|
if (!ol.obj.isEmpty(skippedFeaturesHash)) {
|
||||||
this.drawReplaySkipping_(gl, context, skippedFeaturesHash);
|
this.drawReplaySkipping_(gl, context, skippedFeaturesHash);
|
||||||
} else {
|
} else {
|
||||||
@@ -264,13 +262,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
end = start;
|
end = start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
ol.render.webgl.CircleReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||||
featureCallback, opt_hitExtent) {
|
featureCallback, opt_hitExtent) {
|
||||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
||||||
featureIndex = this.startIndices.length - 2;
|
featureIndex = this.startIndices.length - 2;
|
||||||
@@ -308,16 +306,16 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
ol.render.webgl.CircleReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
||||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
||||||
featureIndex = this.startIndices.length - 2;
|
featureIndex = this.startIndices.length - 2;
|
||||||
end = start = this.startIndices[featureIndex + 1];
|
end = start = this.startIndices[featureIndex + 1];
|
||||||
@@ -348,35 +346,35 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
start = end = groupStart;
|
start = end = groupStart;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {Array.<number>} color Color.
|
* @param {Array.<number>} color Color.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.setFillStyle_ = function(gl, color) {
|
ol.render.webgl.CircleReplay.prototype.setFillStyle_ = function(gl, color) {
|
||||||
gl.uniform4fv(this.defaultLocations_.u_fillColor, color);
|
gl.uniform4fv(this.defaultLocations_.u_fillColor, color);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {Array.<number>} color Color.
|
* @param {Array.<number>} color Color.
|
||||||
* @param {number} lineWidth Line width.
|
* @param {number} lineWidth Line width.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth) {
|
ol.render.webgl.CircleReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth) {
|
||||||
gl.uniform4fv(this.defaultLocations_.u_strokeColor, color);
|
gl.uniform4fv(this.defaultLocations_.u_strokeColor, color);
|
||||||
gl.uniform1f(this.defaultLocations_.u_lineWidth, lineWidth);
|
gl.uniform1f(this.defaultLocations_.u_lineWidth, lineWidth);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.CircleReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
ol.render.webgl.CircleReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||||
var strokeStyleColor, strokeStyleWidth;
|
var strokeStyleColor, strokeStyleWidth;
|
||||||
if (strokeStyle) {
|
if (strokeStyle) {
|
||||||
var strokeStyleLineDash = strokeStyle.getLineDash();
|
var strokeStyleLineDash = strokeStyle.getLineDash();
|
||||||
@@ -419,6 +417,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.state_.lineWidth = strokeStyleWidth;
|
this.state_.lineWidth = strokeStyleWidth;
|
||||||
this.styles_.push([fillStyleColor, strokeStyleColor, strokeStyleWidth]);
|
this.styles_.push([fillStyleColor, strokeStyleColor, strokeStyleWidth]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,89 +6,87 @@ goog.require('ol');
|
|||||||
goog.require('ol.webgl.Fragment');
|
goog.require('ol.webgl.Fragment');
|
||||||
goog.require('ol.webgl.Vertex');
|
goog.require('ol.webgl.Vertex');
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Fragment}
|
* @extends {ol.webgl.Fragment}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.circlereplay.defaultshader.Fragment = function() {
|
ol.render.webgl.circlereplay.defaultshader.Fragment = function() {
|
||||||
ol.webgl.Fragment.call(this, ol.render.webgl.circlereplay.defaultshader.Fragment.SOURCE);
|
ol.webgl.Fragment.call(this, ol.render.webgl.circlereplay.defaultshader.Fragment.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.circlereplay.defaultshader.Fragment, ol.webgl.Fragment);
|
ol.inherits(ol.render.webgl.circlereplay.defaultshader.Fragment, ol.webgl.Fragment);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.circlereplay.defaultshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\n\nuniform float u_opacity;\nuniform vec4 u_fillColor;\nuniform vec4 u_strokeColor;\nuniform vec2 u_size;\n\nvoid main(void) {\n vec2 windowCenter = vec2((v_center.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n (v_center.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n vec2 windowOffset = vec2((v_offset.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n (v_offset.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n float radius = length(windowCenter - windowOffset);\n float dist = length(windowCenter - gl_FragCoord.xy);\n if (dist > radius + v_halfWidth) {\n if (u_strokeColor.a == 0.0) {\n gl_FragColor = u_fillColor;\n } else {\n gl_FragColor = u_strokeColor;\n }\n gl_FragColor.a = gl_FragColor.a - (dist - (radius + v_halfWidth));\n } else if (u_fillColor.a == 0.0) {\n // Hooray, no fill, just stroke. We can use real antialiasing.\n gl_FragColor = u_strokeColor;\n if (dist < radius - v_halfWidth) {\n gl_FragColor.a = gl_FragColor.a - (radius - v_halfWidth - dist);\n }\n } else {\n gl_FragColor = u_fillColor;\n float strokeDist = radius - v_halfWidth;\n float antialias = 2.0 * v_pixelRatio;\n if (dist > strokeDist) {\n gl_FragColor = u_strokeColor;\n } else if (dist >= strokeDist - antialias) {\n float step = smoothstep(strokeDist - antialias, strokeDist, dist);\n gl_FragColor = mix(u_fillColor, u_strokeColor, step);\n }\n }\n gl_FragColor.a = gl_FragColor.a * u_opacity;\n if (gl_FragColor.a <= 0.0) {\n discard;\n }\n}\n';
|
ol.render.webgl.circlereplay.defaultshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\n\nuniform float u_opacity;\nuniform vec4 u_fillColor;\nuniform vec4 u_strokeColor;\nuniform vec2 u_size;\n\nvoid main(void) {\n vec2 windowCenter = vec2((v_center.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n (v_center.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n vec2 windowOffset = vec2((v_offset.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n (v_offset.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n float radius = length(windowCenter - windowOffset);\n float dist = length(windowCenter - gl_FragCoord.xy);\n if (dist > radius + v_halfWidth) {\n if (u_strokeColor.a == 0.0) {\n gl_FragColor = u_fillColor;\n } else {\n gl_FragColor = u_strokeColor;\n }\n gl_FragColor.a = gl_FragColor.a - (dist - (radius + v_halfWidth));\n } else if (u_fillColor.a == 0.0) {\n // Hooray, no fill, just stroke. We can use real antialiasing.\n gl_FragColor = u_strokeColor;\n if (dist < radius - v_halfWidth) {\n gl_FragColor.a = gl_FragColor.a - (radius - v_halfWidth - dist);\n }\n } else {\n gl_FragColor = u_fillColor;\n float strokeDist = radius - v_halfWidth;\n float antialias = 2.0 * v_pixelRatio;\n if (dist > strokeDist) {\n gl_FragColor = u_strokeColor;\n } else if (dist >= strokeDist - antialias) {\n float step = smoothstep(strokeDist - antialias, strokeDist, dist);\n gl_FragColor = mix(u_fillColor, u_strokeColor, step);\n }\n }\n gl_FragColor.a = gl_FragColor.a * u_opacity;\n if (gl_FragColor.a <= 0.0) {\n discard;\n }\n}\n';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.circlereplay.defaultshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;varying vec2 b;varying float c;varying float d;uniform float m;uniform vec4 n;uniform vec4 o;uniform vec2 p;void main(void){vec2 windowCenter=vec2((a.x+1.0)/2.0*p.x*d,(a.y+1.0)/2.0*p.y*d);vec2 windowOffset=vec2((b.x+1.0)/2.0*p.x*d,(b.y+1.0)/2.0*p.y*d);float radius=length(windowCenter-windowOffset);float dist=length(windowCenter-gl_FragCoord.xy);if(dist>radius+c){if(o.a==0.0){gl_FragColor=n;}else{gl_FragColor=o;}gl_FragColor.a=gl_FragColor.a-(dist-(radius+c));}else if(n.a==0.0){gl_FragColor=o;if(dist<radius-c){gl_FragColor.a=gl_FragColor.a-(radius-c-dist);}} else{gl_FragColor=n;float strokeDist=radius-c;float antialias=2.0*d;if(dist>strokeDist){gl_FragColor=o;}else if(dist>=strokeDist-antialias){float step=smoothstep(strokeDist-antialias,strokeDist,dist);gl_FragColor=mix(n,o,step);}} gl_FragColor.a=gl_FragColor.a*m;if(gl_FragColor.a<=0.0){discard;}}';
|
ol.render.webgl.circlereplay.defaultshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;varying vec2 b;varying float c;varying float d;uniform float m;uniform vec4 n;uniform vec4 o;uniform vec2 p;void main(void){vec2 windowCenter=vec2((a.x+1.0)/2.0*p.x*d,(a.y+1.0)/2.0*p.y*d);vec2 windowOffset=vec2((b.x+1.0)/2.0*p.x*d,(b.y+1.0)/2.0*p.y*d);float radius=length(windowCenter-windowOffset);float dist=length(windowCenter-gl_FragCoord.xy);if(dist>radius+c){if(o.a==0.0){gl_FragColor=n;}else{gl_FragColor=o;}gl_FragColor.a=gl_FragColor.a-(dist-(radius+c));}else if(n.a==0.0){gl_FragColor=o;if(dist<radius-c){gl_FragColor.a=gl_FragColor.a-(radius-c-dist);}} else{gl_FragColor=n;float strokeDist=radius-c;float antialias=2.0*d;if(dist>strokeDist){gl_FragColor=o;}else if(dist>=strokeDist-antialias){float step=smoothstep(strokeDist-antialias,strokeDist,dist);gl_FragColor=mix(n,o,step);}} gl_FragColor.a=gl_FragColor.a*m;if(gl_FragColor.a<=0.0){discard;}}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.circlereplay.defaultshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
ol.render.webgl.circlereplay.defaultshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
ol.render.webgl.circlereplay.defaultshader.Fragment.DEBUG_SOURCE :
|
ol.render.webgl.circlereplay.defaultshader.Fragment.DEBUG_SOURCE :
|
||||||
ol.render.webgl.circlereplay.defaultshader.Fragment.OPTIMIZED_SOURCE;
|
ol.render.webgl.circlereplay.defaultshader.Fragment.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
ol.render.webgl.circlereplay.defaultshader.fragment = new ol.render.webgl.circlereplay.defaultshader.Fragment();
|
ol.render.webgl.circlereplay.defaultshader.fragment = new ol.render.webgl.circlereplay.defaultshader.Fragment();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Vertex}
|
* @extends {ol.webgl.Vertex}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.circlereplay.defaultshader.Vertex = function() {
|
ol.render.webgl.circlereplay.defaultshader.Vertex = function() {
|
||||||
ol.webgl.Vertex.call(this, ol.render.webgl.circlereplay.defaultshader.Vertex.SOURCE);
|
ol.webgl.Vertex.call(this, ol.render.webgl.circlereplay.defaultshader.Vertex.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.circlereplay.defaultshader.Vertex, ol.webgl.Vertex);
|
ol.inherits(ol.render.webgl.circlereplay.defaultshader.Vertex, ol.webgl.Vertex);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.circlereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\nattribute vec2 a_position;\nattribute float a_instruction;\nattribute float a_radius;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_lineWidth;\nuniform float u_pixelRatio;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n v_center = vec4(u_projectionMatrix * vec4(a_position, 0.0, 1.0)).xy;\n v_pixelRatio = u_pixelRatio;\n float lineWidth = u_lineWidth * u_pixelRatio;\n v_halfWidth = lineWidth / 2.0;\n if (lineWidth == 0.0) {\n lineWidth = 2.0 * u_pixelRatio;\n }\n vec2 offset;\n // Radius with anitaliasing (roughly).\n float radius = a_radius + 3.0 * u_pixelRatio;\n // Until we get gl_VertexID in WebGL, we store an instruction.\n if (a_instruction == 0.0) {\n // Offsetting the edges of the triangle by lineWidth / 2 is necessary, however\n // we should also leave some space for the antialiasing, thus we offset by lineWidth.\n offset = vec2(-1.0, 1.0);\n } else if (a_instruction == 1.0) {\n offset = vec2(-1.0, -1.0);\n } else if (a_instruction == 2.0) {\n offset = vec2(1.0, -1.0);\n } else {\n offset = vec2(1.0, 1.0);\n }\n\n gl_Position = u_projectionMatrix * vec4(a_position + offset * radius, 0.0, 1.0) +\n offsetMatrix * vec4(offset * lineWidth, 0.0, 0.0);\n v_offset = vec4(u_projectionMatrix * vec4(a_position.x + a_radius, a_position.y,\n 0.0, 1.0)).xy;\n\n if (distance(v_center, v_offset) > 20000.0) {\n gl_Position = vec4(v_center, 0.0, 1.0);\n }\n}\n\n\n';
|
ol.render.webgl.circlereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\nattribute vec2 a_position;\nattribute float a_instruction;\nattribute float a_radius;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_lineWidth;\nuniform float u_pixelRatio;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n v_center = vec4(u_projectionMatrix * vec4(a_position, 0.0, 1.0)).xy;\n v_pixelRatio = u_pixelRatio;\n float lineWidth = u_lineWidth * u_pixelRatio;\n v_halfWidth = lineWidth / 2.0;\n if (lineWidth == 0.0) {\n lineWidth = 2.0 * u_pixelRatio;\n }\n vec2 offset;\n // Radius with anitaliasing (roughly).\n float radius = a_radius + 3.0 * u_pixelRatio;\n // Until we get gl_VertexID in WebGL, we store an instruction.\n if (a_instruction == 0.0) {\n // Offsetting the edges of the triangle by lineWidth / 2 is necessary, however\n // we should also leave some space for the antialiasing, thus we offset by lineWidth.\n offset = vec2(-1.0, 1.0);\n } else if (a_instruction == 1.0) {\n offset = vec2(-1.0, -1.0);\n } else if (a_instruction == 2.0) {\n offset = vec2(1.0, -1.0);\n } else {\n offset = vec2(1.0, 1.0);\n }\n\n gl_Position = u_projectionMatrix * vec4(a_position + offset * radius, 0.0, 1.0) +\n offsetMatrix * vec4(offset * lineWidth, 0.0, 0.0);\n v_offset = vec4(u_projectionMatrix * vec4(a_position.x + a_radius, a_position.y,\n 0.0, 1.0)).xy;\n\n if (distance(v_center, v_offset) > 20000.0) {\n gl_Position = vec4(v_center, 0.0, 1.0);\n }\n}\n\n\n';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.circlereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying vec2 b;varying float c;varying float d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;uniform float k;uniform float l;void main(void){mat4 offsetMatrix=i*j;a=vec4(h*vec4(e,0.0,1.0)).xy;d=l;float lineWidth=k*l;c=lineWidth/2.0;if(lineWidth==0.0){lineWidth=2.0*l;}vec2 offset;float radius=g+3.0*l;if(f==0.0){offset=vec2(-1.0,1.0);}else if(f==1.0){offset=vec2(-1.0,-1.0);}else if(f==2.0){offset=vec2(1.0,-1.0);}else{offset=vec2(1.0,1.0);}gl_Position=h*vec4(e+offset*radius,0.0,1.0)+offsetMatrix*vec4(offset*lineWidth,0.0,0.0);b=vec4(h*vec4(e.x+g,e.y,0.0,1.0)).xy;if(distance(a,b)>20000.0){gl_Position=vec4(a,0.0,1.0);}}';
|
ol.render.webgl.circlereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying vec2 b;varying float c;varying float d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;uniform float k;uniform float l;void main(void){mat4 offsetMatrix=i*j;a=vec4(h*vec4(e,0.0,1.0)).xy;d=l;float lineWidth=k*l;c=lineWidth/2.0;if(lineWidth==0.0){lineWidth=2.0*l;}vec2 offset;float radius=g+3.0*l;if(f==0.0){offset=vec2(-1.0,1.0);}else if(f==1.0){offset=vec2(-1.0,-1.0);}else if(f==2.0){offset=vec2(1.0,-1.0);}else{offset=vec2(1.0,1.0);}gl_Position=h*vec4(e+offset*radius,0.0,1.0)+offsetMatrix*vec4(offset*lineWidth,0.0,0.0);b=vec4(h*vec4(e.x+g,e.y,0.0,1.0)).xy;if(distance(a,b)>20000.0){gl_Position=vec4(a,0.0,1.0);}}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.circlereplay.defaultshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
ol.render.webgl.circlereplay.defaultshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
ol.render.webgl.circlereplay.defaultshader.Vertex.DEBUG_SOURCE :
|
ol.render.webgl.circlereplay.defaultshader.Vertex.DEBUG_SOURCE :
|
||||||
ol.render.webgl.circlereplay.defaultshader.Vertex.OPTIMIZED_SOURCE;
|
ol.render.webgl.circlereplay.defaultshader.Vertex.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
ol.render.webgl.circlereplay.defaultshader.vertex = new ol.render.webgl.circlereplay.defaultshader.Vertex();
|
ol.render.webgl.circlereplay.defaultshader.vertex = new ol.render.webgl.circlereplay.defaultshader.Vertex();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {WebGLRenderingContext} gl GL.
|
* @param {WebGLRenderingContext} gl GL.
|
||||||
* @param {WebGLProgram} program Program.
|
* @param {WebGLProgram} program Program.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.circlereplay.defaultshader.Locations = function(gl, program) {
|
ol.render.webgl.circlereplay.defaultshader.Locations = function(gl, program) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {WebGLUniformLocation}
|
* @type {WebGLUniformLocation}
|
||||||
@@ -161,6 +159,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.a_radius = gl.getAttribLocation(
|
this.a_radius = gl.getAttribLocation(
|
||||||
program, ol.DEBUG_WEBGL ? 'a_radius' : 'g');
|
program, ol.DEBUG_WEBGL ? 'a_radius' : 'g');
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,16 +5,14 @@ goog.require('ol.render.webgl.TextureReplay');
|
|||||||
goog.require('ol.webgl.Buffer');
|
goog.require('ol.webgl.Buffer');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.webgl.TextureReplay}
|
* @extends {ol.render.webgl.TextureReplay}
|
||||||
* @param {number} tolerance Tolerance.
|
* @param {number} tolerance Tolerance.
|
||||||
* @param {ol.Extent} maxExtent Max extent.
|
* @param {ol.Extent} maxExtent Max extent.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay = function(tolerance, maxExtent) {
|
ol.render.webgl.ImageReplay = function(tolerance, maxExtent) {
|
||||||
ol.render.webgl.TextureReplay.call(this, tolerance, maxExtent);
|
ol.render.webgl.TextureReplay.call(this, tolerance, maxExtent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,40 +39,40 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.hitDetectionTextures_ = [];
|
this.hitDetectionTextures_ = [];
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.ImageReplay, ol.render.webgl.TextureReplay);
|
ol.inherits(ol.render.webgl.ImageReplay, ol.render.webgl.TextureReplay);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.drawMultiPoint = function(multiPointGeometry, feature) {
|
ol.render.webgl.ImageReplay.prototype.drawMultiPoint = function(multiPointGeometry, feature) {
|
||||||
this.startIndices.push(this.indices.length);
|
this.startIndices.push(this.indices.length);
|
||||||
this.startIndicesFeature.push(feature);
|
this.startIndicesFeature.push(feature);
|
||||||
var flatCoordinates = multiPointGeometry.getFlatCoordinates();
|
var flatCoordinates = multiPointGeometry.getFlatCoordinates();
|
||||||
var stride = multiPointGeometry.getStride();
|
var stride = multiPointGeometry.getStride();
|
||||||
this.drawCoordinates(
|
this.drawCoordinates(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.drawPoint = function(pointGeometry, feature) {
|
ol.render.webgl.ImageReplay.prototype.drawPoint = function(pointGeometry, feature) {
|
||||||
this.startIndices.push(this.indices.length);
|
this.startIndices.push(this.indices.length);
|
||||||
this.startIndicesFeature.push(feature);
|
this.startIndicesFeature.push(feature);
|
||||||
var flatCoordinates = pointGeometry.getFlatCoordinates();
|
var flatCoordinates = pointGeometry.getFlatCoordinates();
|
||||||
var stride = pointGeometry.getStride();
|
var stride = pointGeometry.getStride();
|
||||||
this.drawCoordinates(
|
this.drawCoordinates(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
||||||
var gl = context.getGL();
|
var gl = context.getGL();
|
||||||
|
|
||||||
this.groupIndices.push(this.indices.length);
|
this.groupIndices.push(this.indices.length);
|
||||||
@@ -100,13 +98,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.images_ = null;
|
this.images_ = null;
|
||||||
this.hitDetectionImages_ = null;
|
this.hitDetectionImages_ = null;
|
||||||
ol.render.webgl.TextureReplay.prototype.finish.call(this, context);
|
ol.render.webgl.TextureReplay.prototype.finish.call(this, context);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
||||||
var anchor = imageStyle.getAnchor();
|
var anchor = imageStyle.getAnchor();
|
||||||
var image = imageStyle.getImage(1);
|
var image = imageStyle.getImage(1);
|
||||||
var imageSize = imageStyle.getImageSize();
|
var imageSize = imageStyle.getImageSize();
|
||||||
@@ -152,22 +150,20 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.rotateWithView = rotateWithView;
|
this.rotateWithView = rotateWithView;
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
this.width = size[0];
|
this.width = size[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.getTextures = function(opt_all) {
|
ol.render.webgl.ImageReplay.prototype.getTextures = function(opt_all) {
|
||||||
return opt_all ? this.textures_.concat(this.hitDetectionTextures_) : this.textures_;
|
return opt_all ? this.textures_.concat(this.hitDetectionTextures_) : this.textures_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.getHitDetectionTextures = function() {
|
ol.render.webgl.ImageReplay.prototype.getHitDetectionTextures = function() {
|
||||||
return this.hitDetectionTextures_;
|
return this.hitDetectionTextures_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ goog.require('ol.render.VectorContext');
|
|||||||
goog.require('ol.render.webgl.ReplayGroup');
|
goog.require('ol.render.webgl.ReplayGroup');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.VectorContext}
|
* @extends {ol.render.VectorContext}
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
@@ -22,7 +20,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate = function(context, center, resolution, rotation, size, extent, pixelRatio) {
|
ol.render.webgl.Immediate = function(context, center, resolution, rotation, size, extent, pixelRatio) {
|
||||||
ol.render.VectorContext.call(this);
|
ol.render.VectorContext.call(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,11 +82,11 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.textStyle_ = null;
|
this.textStyle_ = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.Immediate, ol.render.VectorContext);
|
ol.inherits(ol.render.webgl.Immediate, ol.render.VectorContext);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.render.webgl.ReplayGroup} replayGroup Replay group.
|
* @param {ol.render.webgl.ReplayGroup} replayGroup Replay group.
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
* @param {number} offset Offset.
|
* @param {number} offset Offset.
|
||||||
@@ -96,7 +94,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawText_ = function(replayGroup,
|
ol.render.webgl.Immediate.prototype.drawText_ = function(replayGroup,
|
||||||
flatCoordinates, offset, end, stride) {
|
flatCoordinates, offset, end, stride) {
|
||||||
var context = this.context_;
|
var context = this.context_;
|
||||||
var replay = /** @type {ol.render.webgl.TextReplay} */ (
|
var replay = /** @type {ol.render.webgl.TextReplay} */ (
|
||||||
@@ -113,10 +111,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback,
|
this.size_, this.pixelRatio_, opacity, skippedFeatures, featureCallback,
|
||||||
oneByOne);
|
oneByOne);
|
||||||
replay.getDeleteResourcesFunction(context)();
|
replay.getDeleteResourcesFunction(context)();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the rendering style. Note that since this is an immediate rendering API,
|
* Set the rendering style. Note that since this is an immediate rendering API,
|
||||||
* any `zIndex` on the provided style will be ignored.
|
* any `zIndex` on the provided style will be ignored.
|
||||||
*
|
*
|
||||||
@@ -124,14 +122,14 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @override
|
* @override
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.setStyle = function(style) {
|
ol.render.webgl.Immediate.prototype.setStyle = function(style) {
|
||||||
this.setFillStrokeStyle(style.getFill(), style.getStroke());
|
this.setFillStrokeStyle(style.getFill(), style.getStroke());
|
||||||
this.setImageStyle(style.getImage());
|
this.setImageStyle(style.getImage());
|
||||||
this.setTextStyle(style.getText());
|
this.setTextStyle(style.getText());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render a geometry into the canvas. Call
|
* Render a geometry into the canvas. Call
|
||||||
* {@link ol.render.webgl.Immediate#setStyle} first to set the rendering style.
|
* {@link ol.render.webgl.Immediate#setStyle} first to set the rendering style.
|
||||||
*
|
*
|
||||||
@@ -139,7 +137,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @override
|
* @override
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawGeometry = function(geometry) {
|
ol.render.webgl.Immediate.prototype.drawGeometry = function(geometry) {
|
||||||
var type = geometry.getType();
|
var type = geometry.getType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ol.geom.GeometryType.POINT:
|
case ol.geom.GeometryType.POINT:
|
||||||
@@ -169,14 +167,14 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
default:
|
default:
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawFeature = function(feature, style) {
|
ol.render.webgl.Immediate.prototype.drawFeature = function(feature, style) {
|
||||||
var geometry = style.getGeometryFunction()(feature);
|
var geometry = style.getGeometryFunction()(feature);
|
||||||
if (!geometry ||
|
if (!geometry ||
|
||||||
!ol.extent.intersects(this.extent_, geometry.getExtent())) {
|
!ol.extent.intersects(this.extent_, geometry.getExtent())) {
|
||||||
@@ -184,25 +182,25 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
this.setStyle(style);
|
this.setStyle(style);
|
||||||
this.drawGeometry(geometry);
|
this.drawGeometry(geometry);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawGeometryCollection = function(geometry, data) {
|
ol.render.webgl.Immediate.prototype.drawGeometryCollection = function(geometry, data) {
|
||||||
var geometries = geometry.getGeometriesArray();
|
var geometries = geometry.getGeometriesArray();
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||||
this.drawGeometry(geometries[i]);
|
this.drawGeometry(geometries[i]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawPoint = function(geometry, data) {
|
ol.render.webgl.Immediate.prototype.drawPoint = function(geometry, data) {
|
||||||
var context = this.context_;
|
var context = this.context_;
|
||||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||||
var replay = /** @type {ol.render.webgl.ImageReplay} */ (
|
var replay = /** @type {ol.render.webgl.ImageReplay} */ (
|
||||||
@@ -225,13 +223,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var stride = geometry.getStride();
|
var stride = geometry.getStride();
|
||||||
this.drawText_(replayGroup, flatCoordinates, 0, flatCoordinates.length, stride);
|
this.drawText_(replayGroup, flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawMultiPoint = function(geometry, data) {
|
ol.render.webgl.Immediate.prototype.drawMultiPoint = function(geometry, data) {
|
||||||
var context = this.context_;
|
var context = this.context_;
|
||||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||||
var replay = /** @type {ol.render.webgl.ImageReplay} */ (
|
var replay = /** @type {ol.render.webgl.ImageReplay} */ (
|
||||||
@@ -253,13 +251,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var stride = geometry.getStride();
|
var stride = geometry.getStride();
|
||||||
this.drawText_(replayGroup, flatCoordinates, 0, flatCoordinates.length, stride);
|
this.drawText_(replayGroup, flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawLineString = function(geometry, data) {
|
ol.render.webgl.Immediate.prototype.drawLineString = function(geometry, data) {
|
||||||
var context = this.context_;
|
var context = this.context_;
|
||||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||||
var replay = /** @type {ol.render.webgl.LineStringReplay} */ (
|
var replay = /** @type {ol.render.webgl.LineStringReplay} */ (
|
||||||
@@ -280,13 +278,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var flatMidpoint = geometry.getFlatMidpoint();
|
var flatMidpoint = geometry.getFlatMidpoint();
|
||||||
this.drawText_(replayGroup, flatMidpoint, 0, 2, 2);
|
this.drawText_(replayGroup, flatMidpoint, 0, 2, 2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawMultiLineString = function(geometry, data) {
|
ol.render.webgl.Immediate.prototype.drawMultiLineString = function(geometry, data) {
|
||||||
var context = this.context_;
|
var context = this.context_;
|
||||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||||
var replay = /** @type {ol.render.webgl.LineStringReplay} */ (
|
var replay = /** @type {ol.render.webgl.LineStringReplay} */ (
|
||||||
@@ -307,13 +305,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var flatMidpoints = geometry.getFlatMidpoints();
|
var flatMidpoints = geometry.getFlatMidpoints();
|
||||||
this.drawText_(replayGroup, flatMidpoints, 0, flatMidpoints.length, 2);
|
this.drawText_(replayGroup, flatMidpoints, 0, flatMidpoints.length, 2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawPolygon = function(geometry, data) {
|
ol.render.webgl.Immediate.prototype.drawPolygon = function(geometry, data) {
|
||||||
var context = this.context_;
|
var context = this.context_;
|
||||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||||
var replay = /** @type {ol.render.webgl.PolygonReplay} */ (
|
var replay = /** @type {ol.render.webgl.PolygonReplay} */ (
|
||||||
@@ -334,13 +332,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var flatInteriorPoint = geometry.getFlatInteriorPoint();
|
var flatInteriorPoint = geometry.getFlatInteriorPoint();
|
||||||
this.drawText_(replayGroup, flatInteriorPoint, 0, 2, 2);
|
this.drawText_(replayGroup, flatInteriorPoint, 0, 2, 2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawMultiPolygon = function(geometry, data) {
|
ol.render.webgl.Immediate.prototype.drawMultiPolygon = function(geometry, data) {
|
||||||
var context = this.context_;
|
var context = this.context_;
|
||||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||||
var replay = /** @type {ol.render.webgl.PolygonReplay} */ (
|
var replay = /** @type {ol.render.webgl.PolygonReplay} */ (
|
||||||
@@ -361,13 +359,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var flatInteriorPoints = geometry.getFlatInteriorPoints();
|
var flatInteriorPoints = geometry.getFlatInteriorPoints();
|
||||||
this.drawText_(replayGroup, flatInteriorPoints, 0, flatInteriorPoints.length, 2);
|
this.drawText_(replayGroup, flatInteriorPoints, 0, flatInteriorPoints.length, 2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.drawCircle = function(geometry, data) {
|
ol.render.webgl.Immediate.prototype.drawCircle = function(geometry, data) {
|
||||||
var context = this.context_;
|
var context = this.context_;
|
||||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||||
var replay = /** @type {ol.render.webgl.CircleReplay} */ (
|
var replay = /** @type {ol.render.webgl.CircleReplay} */ (
|
||||||
@@ -387,31 +385,29 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
if (this.textStyle_) {
|
if (this.textStyle_) {
|
||||||
this.drawText_(replayGroup, geometry.getCenter(), 0, 2, 2);
|
this.drawText_(replayGroup, geometry.getCenter(), 0, 2, 2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.setImageStyle = function(imageStyle) {
|
ol.render.webgl.Immediate.prototype.setImageStyle = function(imageStyle) {
|
||||||
this.imageStyle_ = imageStyle;
|
this.imageStyle_ = imageStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
ol.render.webgl.Immediate.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||||
this.fillStyle_ = fillStyle;
|
this.fillStyle_ = fillStyle;
|
||||||
this.strokeStyle_ = strokeStyle;
|
this.strokeStyle_ = strokeStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Immediate.prototype.setTextStyle = function(textStyle) {
|
ol.render.webgl.Immediate.prototype.setTextStyle = function(textStyle) {
|
||||||
this.textStyle_ = textStyle;
|
this.textStyle_ = textStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,16 +15,14 @@ goog.require('ol.webgl');
|
|||||||
goog.require('ol.webgl.Buffer');
|
goog.require('ol.webgl.Buffer');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.webgl.Replay}
|
* @extends {ol.render.webgl.Replay}
|
||||||
* @param {number} tolerance Tolerance.
|
* @param {number} tolerance Tolerance.
|
||||||
* @param {ol.Extent} maxExtent Max extent.
|
* @param {ol.Extent} maxExtent Max extent.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay = function(tolerance, maxExtent) {
|
ol.render.webgl.LineStringReplay = function(tolerance, maxExtent) {
|
||||||
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,11 +65,11 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
changed: false
|
changed: false
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.LineStringReplay, ol.render.webgl.Replay);
|
ol.inherits(ol.render.webgl.LineStringReplay, ol.render.webgl.Replay);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw one segment.
|
* Draw one segment.
|
||||||
* @private
|
* @private
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
@@ -79,7 +77,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {number} end End.
|
* @param {number} end End.
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
||||||
|
|
||||||
var i, ii;
|
var i, ii;
|
||||||
var numVertices = this.vertices.length;
|
var numVertices = this.vertices.length;
|
||||||
@@ -252,9 +250,9 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.indices[numIndices++] = n;
|
this.indices[numIndices++] = n;
|
||||||
this.indices[numIndices++] = lastSign * sign > 0 ? lastIndex : lastIndex - 1;
|
this.indices[numIndices++] = lastSign * sign > 0 ? lastIndex : lastIndex - 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array.<number>} p0 Last coordinates.
|
* @param {Array.<number>} p0 Last coordinates.
|
||||||
* @param {Array.<number>} p1 Current coordinates.
|
* @param {Array.<number>} p1 Current coordinates.
|
||||||
* @param {Array.<number>} p2 Next coordinates.
|
* @param {Array.<number>} p2 Next coordinates.
|
||||||
@@ -263,7 +261,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {number} Vertex counter.
|
* @return {number} Vertex counter.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.addVertices_ = function(p0, p1, p2, product, numVertices) {
|
ol.render.webgl.LineStringReplay.prototype.addVertices_ = function(p0, p1, p2, product, numVertices) {
|
||||||
this.vertices[numVertices++] = p0[0];
|
this.vertices[numVertices++] = p0[0];
|
||||||
this.vertices[numVertices++] = p0[1];
|
this.vertices[numVertices++] = p0[1];
|
||||||
this.vertices[numVertices++] = p1[0];
|
this.vertices[numVertices++] = p1[0];
|
||||||
@@ -273,9 +271,9 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.vertices[numVertices++] = product;
|
this.vertices[numVertices++] = product;
|
||||||
|
|
||||||
return numVertices;
|
return numVertices;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the linestring can be drawn (i. e. valid).
|
* Check if the linestring can be drawn (i. e. valid).
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
* @param {number} offset Offset.
|
* @param {number} offset Offset.
|
||||||
@@ -284,7 +282,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {boolean} The linestring can be drawn.
|
* @return {boolean} The linestring can be drawn.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.isValid_ = function(flatCoordinates, offset, end, stride) {
|
ol.render.webgl.LineStringReplay.prototype.isValid_ = function(flatCoordinates, offset, end, stride) {
|
||||||
var range = end - offset;
|
var range = end - offset;
|
||||||
if (range < stride * 2) {
|
if (range < stride * 2) {
|
||||||
return false;
|
return false;
|
||||||
@@ -295,13 +293,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.drawLineString = function(lineStringGeometry, feature) {
|
ol.render.webgl.LineStringReplay.prototype.drawLineString = function(lineStringGeometry, feature) {
|
||||||
var flatCoordinates = lineStringGeometry.getFlatCoordinates();
|
var flatCoordinates = lineStringGeometry.getFlatCoordinates();
|
||||||
var stride = lineStringGeometry.getStride();
|
var stride = lineStringGeometry.getStride();
|
||||||
if (this.isValid_(flatCoordinates, 0, flatCoordinates.length, stride)) {
|
if (this.isValid_(flatCoordinates, 0, flatCoordinates.length, stride)) {
|
||||||
@@ -316,13 +314,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.drawCoordinates_(
|
this.drawCoordinates_(
|
||||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
|
ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
|
||||||
var indexCount = this.indices.length;
|
var indexCount = this.indices.length;
|
||||||
var ends = multiLineStringGeometry.getEnds();
|
var ends = multiLineStringGeometry.getEnds();
|
||||||
ends.unshift(0);
|
ends.unshift(0);
|
||||||
@@ -347,15 +345,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.state_.changed = false;
|
this.state_.changed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
* @param {Array.<Array.<number>>} holeFlatCoordinates Hole flat coordinates.
|
* @param {Array.<Array.<number>>} holeFlatCoordinates Hole flat coordinates.
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.drawPolygonCoordinates = function(
|
ol.render.webgl.LineStringReplay.prototype.drawPolygonCoordinates = function(
|
||||||
flatCoordinates, holeFlatCoordinates, stride) {
|
flatCoordinates, holeFlatCoordinates, stride) {
|
||||||
if (!ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0,
|
if (!ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0,
|
||||||
flatCoordinates.length, stride)) {
|
flatCoordinates.length, stride)) {
|
||||||
@@ -375,14 +373,14 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
holeFlatCoordinates[i].length, stride);
|
holeFlatCoordinates[i].length, stride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||||
* @param {number=} opt_index Index count.
|
* @param {number=} opt_index Index count.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.setPolygonStyle = function(feature, opt_index) {
|
ol.render.webgl.LineStringReplay.prototype.setPolygonStyle = function(feature, opt_index) {
|
||||||
var index = opt_index === undefined ? this.indices.length : opt_index;
|
var index = opt_index === undefined ? this.indices.length : opt_index;
|
||||||
this.startIndices.push(index);
|
this.startIndices.push(index);
|
||||||
this.startIndicesFeature.push(feature);
|
this.startIndicesFeature.push(feature);
|
||||||
@@ -390,21 +388,21 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.styleIndices_.push(index);
|
this.styleIndices_.push(index);
|
||||||
this.state_.changed = false;
|
this.state_.changed = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number} Current index.
|
* @return {number} Current index.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.getCurrentIndex = function() {
|
ol.render.webgl.LineStringReplay.prototype.getCurrentIndex = function() {
|
||||||
return this.indices.length;
|
return this.indices.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
**/
|
**/
|
||||||
ol.render.webgl.LineStringReplay.prototype.finish = function(context) {
|
ol.render.webgl.LineStringReplay.prototype.finish = function(context) {
|
||||||
// create, bind, and populate the vertices buffer
|
// create, bind, and populate the vertices buffer
|
||||||
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
||||||
|
|
||||||
@@ -420,26 +418,26 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
|
|
||||||
this.vertices = null;
|
this.vertices = null;
|
||||||
this.indices = null;
|
this.indices = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.getDeleteResourcesFunction = function(context) {
|
ol.render.webgl.LineStringReplay.prototype.getDeleteResourcesFunction = function(context) {
|
||||||
var verticesBuffer = this.verticesBuffer;
|
var verticesBuffer = this.verticesBuffer;
|
||||||
var indicesBuffer = this.indicesBuffer;
|
var indicesBuffer = this.indicesBuffer;
|
||||||
return function() {
|
return function() {
|
||||||
context.deleteBuffer(verticesBuffer);
|
context.deleteBuffer(verticesBuffer);
|
||||||
context.deleteBuffer(indicesBuffer);
|
context.deleteBuffer(indicesBuffer);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
ol.render.webgl.LineStringReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||||
// get the program
|
// get the program
|
||||||
var fragmentShader, vertexShader;
|
var fragmentShader, vertexShader;
|
||||||
fragmentShader = ol.render.webgl.linestringreplay.defaultshader.fragment;
|
fragmentShader = ol.render.webgl.linestringreplay.defaultshader.fragment;
|
||||||
@@ -480,24 +478,24 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
gl.uniform1f(locations.u_pixelRatio, pixelRatio);
|
gl.uniform1f(locations.u_pixelRatio, pixelRatio);
|
||||||
|
|
||||||
return locations;
|
return locations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.shutDownProgram = function(gl, locations) {
|
ol.render.webgl.LineStringReplay.prototype.shutDownProgram = function(gl, locations) {
|
||||||
gl.disableVertexAttribArray(locations.a_lastPos);
|
gl.disableVertexAttribArray(locations.a_lastPos);
|
||||||
gl.disableVertexAttribArray(locations.a_position);
|
gl.disableVertexAttribArray(locations.a_position);
|
||||||
gl.disableVertexAttribArray(locations.a_nextPos);
|
gl.disableVertexAttribArray(locations.a_nextPos);
|
||||||
gl.disableVertexAttribArray(locations.a_direction);
|
gl.disableVertexAttribArray(locations.a_direction);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
ol.render.webgl.LineStringReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||||
//Save GL parameters.
|
//Save GL parameters.
|
||||||
var tmpDepthFunc = /** @type {number} */ (gl.getParameter(gl.DEPTH_FUNC));
|
var tmpDepthFunc = /** @type {number} */ (gl.getParameter(gl.DEPTH_FUNC));
|
||||||
var tmpDepthMask = /** @type {boolean} */ (gl.getParameter(gl.DEPTH_WRITEMASK));
|
var tmpDepthMask = /** @type {boolean} */ (gl.getParameter(gl.DEPTH_WRITEMASK));
|
||||||
@@ -530,16 +528,16 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
gl.depthMask(tmpDepthMask);
|
gl.depthMask(tmpDepthMask);
|
||||||
gl.depthFunc(tmpDepthFunc);
|
gl.depthFunc(tmpDepthFunc);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
ol.render.webgl.LineStringReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
||||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
||||||
featureIndex = this.startIndices.length - 2;
|
featureIndex = this.startIndices.length - 2;
|
||||||
end = start = this.startIndices[featureIndex + 1];
|
end = start = this.startIndices[featureIndex + 1];
|
||||||
@@ -570,13 +568,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
start = end = groupStart;
|
start = end = groupStart;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
ol.render.webgl.LineStringReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||||
featureCallback, opt_hitExtent) {
|
featureCallback, opt_hitExtent) {
|
||||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
||||||
featureIndex = this.startIndices.length - 2;
|
featureIndex = this.startIndices.length - 2;
|
||||||
@@ -612,27 +610,27 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {Array.<number>} color Color.
|
* @param {Array.<number>} color Color.
|
||||||
* @param {number} lineWidth Line width.
|
* @param {number} lineWidth Line width.
|
||||||
* @param {number} miterLimit Miter limit.
|
* @param {number} miterLimit Miter limit.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth, miterLimit) {
|
ol.render.webgl.LineStringReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth, miterLimit) {
|
||||||
gl.uniform4fv(this.defaultLocations_.u_color, color);
|
gl.uniform4fv(this.defaultLocations_.u_color, color);
|
||||||
gl.uniform1f(this.defaultLocations_.u_lineWidth, lineWidth);
|
gl.uniform1f(this.defaultLocations_.u_lineWidth, lineWidth);
|
||||||
gl.uniform1f(this.defaultLocations_.u_miterLimit, miterLimit);
|
gl.uniform1f(this.defaultLocations_.u_miterLimit, miterLimit);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
ol.render.webgl.LineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||||
var strokeStyleLineCap = strokeStyle.getLineCap();
|
var strokeStyleLineCap = strokeStyle.getLineCap();
|
||||||
this.state_.lineCap = strokeStyleLineCap !== undefined ?
|
this.state_.lineCap = strokeStyleLineCap !== undefined ?
|
||||||
strokeStyleLineCap : ol.render.webgl.defaultLineCap;
|
strokeStyleLineCap : ol.render.webgl.defaultLineCap;
|
||||||
@@ -668,13 +666,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.state_.miterLimit = strokeStyleMiterLimit;
|
this.state_.miterLimit = strokeStyleMiterLimit;
|
||||||
this.styles_.push([strokeStyleColor, strokeStyleWidth, strokeStyleMiterLimit]);
|
this.styles_.push([strokeStyleColor, strokeStyleWidth, strokeStyleMiterLimit]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.LineStringReplay.Instruction_ = {
|
ol.render.webgl.LineStringReplay.Instruction_ = {
|
||||||
ROUND: 2,
|
ROUND: 2,
|
||||||
BEGIN_LINE: 3,
|
BEGIN_LINE: 3,
|
||||||
END_LINE: 5,
|
END_LINE: 5,
|
||||||
@@ -684,6 +682,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
BEVEL_SECOND: 17,
|
BEVEL_SECOND: 17,
|
||||||
MITER_BOTTOM: 19,
|
MITER_BOTTOM: 19,
|
||||||
MITER_TOP: 23
|
MITER_TOP: 23
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -19,16 +19,14 @@ goog.require('ol.webgl');
|
|||||||
goog.require('ol.webgl.Buffer');
|
goog.require('ol.webgl.Buffer');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.webgl.Replay}
|
* @extends {ol.render.webgl.Replay}
|
||||||
* @param {number} tolerance Tolerance.
|
* @param {number} tolerance Tolerance.
|
||||||
* @param {ol.Extent} maxExtent Max extent.
|
* @param {ol.Extent} maxExtent Max extent.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay = function(tolerance, maxExtent) {
|
ol.render.webgl.PolygonReplay = function(tolerance, maxExtent) {
|
||||||
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
||||||
|
|
||||||
this.lineStringReplay = new ol.render.webgl.LineStringReplay(
|
this.lineStringReplay = new ol.render.webgl.LineStringReplay(
|
||||||
@@ -62,18 +60,18 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
changed: false
|
changed: false
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.PolygonReplay, ol.render.webgl.Replay);
|
ol.inherits(ol.render.webgl.PolygonReplay, ol.render.webgl.Replay);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw one polygon.
|
* Draw one polygon.
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
* @param {Array.<Array.<number>>} holeFlatCoordinates Hole flat coordinates.
|
* @param {Array.<Array.<number>>} holeFlatCoordinates Hole flat coordinates.
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.drawCoordinates_ = function(
|
ol.render.webgl.PolygonReplay.prototype.drawCoordinates_ = function(
|
||||||
flatCoordinates, holeFlatCoordinates, stride) {
|
flatCoordinates, holeFlatCoordinates, stride) {
|
||||||
// Triangulate the polygon
|
// Triangulate the polygon
|
||||||
var outerRing = new ol.structs.LinkedList();
|
var outerRing = new ol.structs.LinkedList();
|
||||||
@@ -126,10 +124,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.classifyPoints_(outerRing, rtree, false);
|
this.classifyPoints_(outerRing, rtree, false);
|
||||||
}
|
}
|
||||||
this.triangulate_(outerRing, rtree);
|
this.triangulate_(outerRing, rtree);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts flat coordinates in a linked list and adds them to the vertex buffer.
|
* Inserts flat coordinates in a linked list and adds them to the vertex buffer.
|
||||||
* @private
|
* @private
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
@@ -138,7 +136,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
* @param {boolean} clockwise Coordinate order should be clockwise.
|
* @param {boolean} clockwise Coordinate order should be clockwise.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.processFlatCoordinates_ = function(
|
ol.render.webgl.PolygonReplay.prototype.processFlatCoordinates_ = function(
|
||||||
flatCoordinates, stride, list, rtree, clockwise) {
|
flatCoordinates, stride, list, rtree, clockwise) {
|
||||||
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates,
|
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates,
|
||||||
0, flatCoordinates.length, stride);
|
0, flatCoordinates.length, stride);
|
||||||
@@ -181,16 +179,16 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
Math.max(p0.y, p1.y)]);
|
Math.max(p0.y, p1.y)]);
|
||||||
}
|
}
|
||||||
rtree.load(extents, segments);
|
rtree.load(extents, segments);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the rightmost coordinates of a polygon on the X axis.
|
* Returns the rightmost coordinates of a polygon on the X axis.
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.structs.LinkedList} list Polygons ring.
|
* @param {ol.structs.LinkedList} list Polygons ring.
|
||||||
* @return {Array.<number>} Max X coordinates.
|
* @return {Array.<number>} Max X coordinates.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.getMaxCoords_ = function(list) {
|
ol.render.webgl.PolygonReplay.prototype.getMaxCoords_ = function(list) {
|
||||||
var start = list.firstItem();
|
var start = list.firstItem();
|
||||||
var seg = start;
|
var seg = start;
|
||||||
var maxCoords = [seg.p0.x, seg.p0.y];
|
var maxCoords = [seg.p0.x, seg.p0.y];
|
||||||
@@ -203,10 +201,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
} while (seg !== start);
|
} while (seg !== start);
|
||||||
|
|
||||||
return maxCoords;
|
return maxCoords;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classifies the points of a polygon list as convex, reflex. Removes collinear vertices.
|
* Classifies the points of a polygon list as convex, reflex. Removes collinear vertices.
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.structs.LinkedList} list Polygon ring.
|
* @param {ol.structs.LinkedList} list Polygon ring.
|
||||||
@@ -214,7 +212,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {boolean} ccw The orientation of the polygon is counter-clockwise.
|
* @param {boolean} ccw The orientation of the polygon is counter-clockwise.
|
||||||
* @return {boolean} There were reclassified points.
|
* @return {boolean} There were reclassified points.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.classifyPoints_ = function(list, rtree, ccw) {
|
ol.render.webgl.PolygonReplay.prototype.classifyPoints_ = function(list, rtree, ccw) {
|
||||||
var start = list.firstItem();
|
var start = list.firstItem();
|
||||||
var s0 = start;
|
var s0 = start;
|
||||||
var s1 = list.nextItem();
|
var s1 = list.nextItem();
|
||||||
@@ -240,10 +238,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
s1 = list.nextItem();
|
s1 = list.nextItem();
|
||||||
} while (s0 !== start);
|
} while (s0 !== start);
|
||||||
return pointsReclassified;
|
return pointsReclassified;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.structs.LinkedList} hole Linked list of the hole.
|
* @param {ol.structs.LinkedList} hole Linked list of the hole.
|
||||||
* @param {number} holeMaxX Maximum X value of the hole.
|
* @param {number} holeMaxX Maximum X value of the hole.
|
||||||
@@ -252,7 +250,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
* @return {boolean} Bridging was successful.
|
* @return {boolean} Bridging was successful.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
|
ol.render.webgl.PolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
|
||||||
list, listMaxX, rtree) {
|
list, listMaxX, rtree) {
|
||||||
var seg = hole.firstItem();
|
var seg = hole.firstItem();
|
||||||
while (seg.p1.x !== holeMaxX) {
|
while (seg.p1.x !== holeMaxX) {
|
||||||
@@ -317,15 +315,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
list.concat(hole);
|
list.concat(hole);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.triangulate_ = function(list, rtree) {
|
ol.render.webgl.PolygonReplay.prototype.triangulate_ = function(list, rtree) {
|
||||||
var ccw = false;
|
var ccw = false;
|
||||||
var simple = this.isSimple_(list, rtree);
|
var simple = this.isSimple_(list, rtree);
|
||||||
|
|
||||||
@@ -367,10 +365,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.indices[numIndices++] = list.getCurrItem().p0.i;
|
this.indices[numIndices++] = list.getCurrItem().p0.i;
|
||||||
this.indices[numIndices++] = list.getNextItem().p0.i;
|
this.indices[numIndices++] = list.getNextItem().p0.i;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
@@ -378,7 +376,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {boolean} ccw Orientation of the polygon is counter-clockwise.
|
* @param {boolean} ccw Orientation of the polygon is counter-clockwise.
|
||||||
* @return {boolean} There were processed ears.
|
* @return {boolean} There were processed ears.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.clipEars_ = function(list, rtree, simple, ccw) {
|
ol.render.webgl.PolygonReplay.prototype.clipEars_ = function(list, rtree, simple, ccw) {
|
||||||
var numIndices = this.indices.length;
|
var numIndices = this.indices.length;
|
||||||
var start = list.firstItem();
|
var start = list.firstItem();
|
||||||
var s0 = list.getPrevItem();
|
var s0 = list.getPrevItem();
|
||||||
@@ -426,17 +424,17 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
} while (s1 !== start && list.getLength() > 3);
|
} while (s1 !== start && list.getLength() > 3);
|
||||||
|
|
||||||
return processedEars;
|
return processedEars;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
* @param {boolean=} opt_touch Resolve touching segments.
|
* @param {boolean=} opt_touch Resolve touching segments.
|
||||||
* @return {boolean} There were resolved intersections.
|
* @return {boolean} There were resolved intersections.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.resolveSelfIntersections_ = function(
|
ol.render.webgl.PolygonReplay.prototype.resolveSelfIntersections_ = function(
|
||||||
list, rtree, opt_touch) {
|
list, rtree, opt_touch) {
|
||||||
var start = list.firstItem();
|
var start = list.firstItem();
|
||||||
list.nextItem();
|
list.nextItem();
|
||||||
@@ -495,16 +493,16 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
s1 = list.nextItem();
|
s1 = list.nextItem();
|
||||||
} while (s0 !== start);
|
} while (s0 !== start);
|
||||||
return resolvedIntersections;
|
return resolvedIntersections;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
* @return {boolean} The polygon is simple.
|
* @return {boolean} The polygon is simple.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.isSimple_ = function(list, rtree) {
|
ol.render.webgl.PolygonReplay.prototype.isSimple_ = function(list, rtree) {
|
||||||
var start = list.firstItem();
|
var start = list.firstItem();
|
||||||
var seg = start;
|
var seg = start;
|
||||||
do {
|
do {
|
||||||
@@ -514,15 +512,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
seg = list.nextItem();
|
seg = list.nextItem();
|
||||||
} while (seg !== start);
|
} while (seg !== start);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
||||||
* @return {boolean} Orientation is clockwise.
|
* @return {boolean} Orientation is clockwise.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.isClockwise_ = function(list) {
|
ol.render.webgl.PolygonReplay.prototype.isClockwise_ = function(list) {
|
||||||
var length = list.getLength() * 2;
|
var length = list.getLength() * 2;
|
||||||
var flatCoordinates = new Array(length);
|
var flatCoordinates = new Array(length);
|
||||||
var start = list.firstItem();
|
var start = list.firstItem();
|
||||||
@@ -534,15 +532,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
seg = list.nextItem();
|
seg = list.nextItem();
|
||||||
} while (seg !== start);
|
} while (seg !== start);
|
||||||
return ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates, 0, length, 2);
|
return ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates, 0, length, 2);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.splitPolygon_ = function(list, rtree) {
|
ol.render.webgl.PolygonReplay.prototype.splitPolygon_ = function(list, rtree) {
|
||||||
var start = list.firstItem();
|
var start = list.firstItem();
|
||||||
var s0 = start;
|
var s0 = start;
|
||||||
do {
|
do {
|
||||||
@@ -578,17 +576,17 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
s0 = list.nextItem();
|
s0 = list.nextItem();
|
||||||
} while (s0 !== start);
|
} while (s0 !== start);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {number} x X coordinate.
|
* @param {number} x X coordinate.
|
||||||
* @param {number} y Y coordinate.
|
* @param {number} y Y coordinate.
|
||||||
* @param {number} i Index.
|
* @param {number} i Index.
|
||||||
* @return {ol.WebglPolygonVertex} List item.
|
* @return {ol.WebglPolygonVertex} List item.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.createPoint_ = function(x, y, i) {
|
ol.render.webgl.PolygonReplay.prototype.createPoint_ = function(x, y, i) {
|
||||||
var numVertices = this.vertices.length;
|
var numVertices = this.vertices.length;
|
||||||
this.vertices[numVertices++] = x;
|
this.vertices[numVertices++] = x;
|
||||||
this.vertices[numVertices++] = y;
|
this.vertices[numVertices++] = y;
|
||||||
@@ -600,10 +598,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
reflex: undefined
|
reflex: undefined
|
||||||
};
|
};
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.WebglPolygonVertex} p0 First point of segment.
|
* @param {ol.WebglPolygonVertex} p0 First point of segment.
|
||||||
* @param {ol.WebglPolygonVertex} p1 Second point of segment.
|
* @param {ol.WebglPolygonVertex} p1 Second point of segment.
|
||||||
@@ -611,7 +609,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.structs.RBush=} opt_rtree Insert the segment into the R-Tree.
|
* @param {ol.structs.RBush=} opt_rtree Insert the segment into the R-Tree.
|
||||||
* @return {ol.WebglPolygonSegment} segment.
|
* @return {ol.WebglPolygonSegment} segment.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.insertItem_ = function(p0, p1, list, opt_rtree) {
|
ol.render.webgl.PolygonReplay.prototype.insertItem_ = function(p0, p1, list, opt_rtree) {
|
||||||
var seg = {
|
var seg = {
|
||||||
p0: p0,
|
p0: p0,
|
||||||
p1: p1
|
p1: p1
|
||||||
@@ -622,17 +620,17 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
Math.max(p0.x, p1.x), Math.max(p0.y, p1.y)], seg);
|
Math.max(p0.x, p1.x), Math.max(p0.y, p1.y)], seg);
|
||||||
}
|
}
|
||||||
return seg;
|
return seg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.WebglPolygonSegment} s0 Segment before the remove candidate.
|
* @param {ol.WebglPolygonSegment} s0 Segment before the remove candidate.
|
||||||
* @param {ol.WebglPolygonSegment} s1 Remove candidate segment.
|
* @param {ol.WebglPolygonSegment} s1 Remove candidate segment.
|
||||||
* @param {ol.structs.LinkedList} list Polygon ring.
|
* @param {ol.structs.LinkedList} list Polygon ring.
|
||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.removeItem_ = function(s0, s1, list, rtree) {
|
ol.render.webgl.PolygonReplay.prototype.removeItem_ = function(s0, s1, list, rtree) {
|
||||||
if (list.getCurrItem() === s1) {
|
if (list.getCurrItem() === s1) {
|
||||||
list.removeItem();
|
list.removeItem();
|
||||||
s0.p1 = s1.p1;
|
s0.p1 = s1.p1;
|
||||||
@@ -640,10 +638,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
rtree.update([Math.min(s0.p0.x, s0.p1.x), Math.min(s0.p0.y, s0.p1.y),
|
rtree.update([Math.min(s0.p0.x, s0.p1.x), Math.min(s0.p0.y, s0.p1.y),
|
||||||
Math.max(s0.p0.x, s0.p1.x), Math.max(s0.p0.y, s0.p1.y)], s0);
|
Math.max(s0.p0.x, s0.p1.x), Math.max(s0.p0.y, s0.p1.y)], s0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.WebglPolygonVertex} p0 First point.
|
* @param {ol.WebglPolygonVertex} p0 First point.
|
||||||
* @param {ol.WebglPolygonVertex} p1 Second point.
|
* @param {ol.WebglPolygonVertex} p1 Second point.
|
||||||
@@ -652,7 +650,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {boolean=} opt_reflex Only include reflex points.
|
* @param {boolean=} opt_reflex Only include reflex points.
|
||||||
* @return {Array.<ol.WebglPolygonVertex>} Points in the triangle.
|
* @return {Array.<ol.WebglPolygonVertex>} Points in the triangle.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1,
|
ol.render.webgl.PolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1,
|
||||||
p2, rtree, opt_reflex) {
|
p2, rtree, opt_reflex) {
|
||||||
var i, ii, j, p;
|
var i, ii, j, p;
|
||||||
var result = [];
|
var result = [];
|
||||||
@@ -673,17 +671,17 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.WebglPolygonSegment} segment Segment.
|
* @param {ol.WebglPolygonSegment} segment Segment.
|
||||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||||
* @param {boolean=} opt_touch Touching segments should be considered an intersection.
|
* @param {boolean=} opt_touch Touching segments should be considered an intersection.
|
||||||
* @return {Array.<ol.WebglPolygonSegment>} Intersecting segments.
|
* @return {Array.<ol.WebglPolygonSegment>} Intersecting segments.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.getIntersections_ = function(segment, rtree, opt_touch) {
|
ol.render.webgl.PolygonReplay.prototype.getIntersections_ = function(segment, rtree, opt_touch) {
|
||||||
var p0 = segment.p0;
|
var p0 = segment.p0;
|
||||||
var p1 = segment.p1;
|
var p1 = segment.p1;
|
||||||
var segmentsInExtent = rtree.getInExtent([Math.min(p0.x, p1.x),
|
var segmentsInExtent = rtree.getInExtent([Math.min(p0.x, p1.x),
|
||||||
@@ -698,10 +696,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Line intersection algorithm by Paul Bourke.
|
* Line intersection algorithm by Paul Bourke.
|
||||||
* @see http://paulbourke.net/geometry/pointlineplane/
|
* @see http://paulbourke.net/geometry/pointlineplane/
|
||||||
*
|
*
|
||||||
@@ -713,7 +711,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {boolean=} opt_touch Touching segments should be considered an intersection.
|
* @param {boolean=} opt_touch Touching segments should be considered an intersection.
|
||||||
* @return {Array.<number>|undefined} Intersection coordinates.
|
* @return {Array.<number>|undefined} Intersection coordinates.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.calculateIntersection_ = function(p0,
|
ol.render.webgl.PolygonReplay.prototype.calculateIntersection_ = function(p0,
|
||||||
p1, p2, p3, opt_touch) {
|
p1, p2, p3, opt_touch) {
|
||||||
var denom = (p3.y - p2.y) * (p1.x - p0.x) - (p3.x - p2.x) * (p1.y - p0.y);
|
var denom = (p3.y - p2.y) * (p1.x - p0.x) - (p3.x - p2.x) * (p1.y - p0.y);
|
||||||
if (denom !== 0) {
|
if (denom !== 0) {
|
||||||
@@ -726,10 +724,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.WebglPolygonVertex} p0 Point before the start of the diagonal.
|
* @param {ol.WebglPolygonVertex} p0 Point before the start of the diagonal.
|
||||||
* @param {ol.WebglPolygonVertex} p1 Start point of the diagonal.
|
* @param {ol.WebglPolygonVertex} p1 Start point of the diagonal.
|
||||||
@@ -738,7 +736,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.WebglPolygonVertex} p4 Point after the end of the diagonal.
|
* @param {ol.WebglPolygonVertex} p4 Point after the end of the diagonal.
|
||||||
* @return {boolean} Diagonal is inside the polygon.
|
* @return {boolean} Diagonal is inside the polygon.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.diagonalIsInside_ = function(p0, p1, p2, p3, p4) {
|
ol.render.webgl.PolygonReplay.prototype.diagonalIsInside_ = function(p0, p1, p2, p3, p4) {
|
||||||
if (p1.reflex === undefined || p3.reflex === undefined) {
|
if (p1.reflex === undefined || p3.reflex === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -749,13 +747,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var p1InCone = p3.reflex ? p1IsRightOf || p1IsLeftOf : p1IsRightOf && p1IsLeftOf;
|
var p1InCone = p3.reflex ? p1IsRightOf || p1IsLeftOf : p1IsRightOf && p1IsLeftOf;
|
||||||
var p3InCone = p1.reflex ? p3IsRightOf || p3IsLeftOf : p3IsRightOf && p3IsLeftOf;
|
var p3InCone = p1.reflex ? p3IsRightOf || p3IsLeftOf : p3IsRightOf && p3IsLeftOf;
|
||||||
return p1InCone && p3InCone;
|
return p1InCone && p3InCone;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
|
ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
|
||||||
var endss = multiPolygonGeometry.getEndss();
|
var endss = multiPolygonGeometry.getEndss();
|
||||||
var stride = multiPolygonGeometry.getStride();
|
var stride = multiPolygonGeometry.getStride();
|
||||||
var currIndex = this.indices.length;
|
var currIndex = this.indices.length;
|
||||||
@@ -795,13 +793,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
if (this.lineStringReplay.getCurrentIndex() > currLineIndex) {
|
if (this.lineStringReplay.getCurrentIndex() > currLineIndex) {
|
||||||
this.lineStringReplay.setPolygonStyle(feature, currLineIndex);
|
this.lineStringReplay.setPolygonStyle(feature, currLineIndex);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
ol.render.webgl.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
||||||
var ends = polygonGeometry.getEnds();
|
var ends = polygonGeometry.getEnds();
|
||||||
var stride = polygonGeometry.getStride();
|
var stride = polygonGeometry.getStride();
|
||||||
if (ends.length > 0) {
|
if (ends.length > 0) {
|
||||||
@@ -831,13 +829,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.drawCoordinates_(outerRing, holes, stride);
|
this.drawCoordinates_(outerRing, holes, stride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
**/
|
**/
|
||||||
ol.render.webgl.PolygonReplay.prototype.finish = function(context) {
|
ol.render.webgl.PolygonReplay.prototype.finish = function(context) {
|
||||||
// create, bind, and populate the vertices buffer
|
// create, bind, and populate the vertices buffer
|
||||||
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
||||||
|
|
||||||
@@ -855,13 +853,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
|
|
||||||
this.vertices = null;
|
this.vertices = null;
|
||||||
this.indices = null;
|
this.indices = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.getDeleteResourcesFunction = function(context) {
|
ol.render.webgl.PolygonReplay.prototype.getDeleteResourcesFunction = function(context) {
|
||||||
var verticesBuffer = this.verticesBuffer;
|
var verticesBuffer = this.verticesBuffer;
|
||||||
var indicesBuffer = this.indicesBuffer;
|
var indicesBuffer = this.indicesBuffer;
|
||||||
var lineDeleter = this.lineStringReplay.getDeleteResourcesFunction(context);
|
var lineDeleter = this.lineStringReplay.getDeleteResourcesFunction(context);
|
||||||
@@ -870,13 +868,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
context.deleteBuffer(indicesBuffer);
|
context.deleteBuffer(indicesBuffer);
|
||||||
lineDeleter();
|
lineDeleter();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
ol.render.webgl.PolygonReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||||
// get the program
|
// get the program
|
||||||
var fragmentShader, vertexShader;
|
var fragmentShader, vertexShader;
|
||||||
fragmentShader = ol.render.webgl.polygonreplay.defaultshader.fragment;
|
fragmentShader = ol.render.webgl.polygonreplay.defaultshader.fragment;
|
||||||
@@ -901,21 +899,21 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
false, 8, 0);
|
false, 8, 0);
|
||||||
|
|
||||||
return locations;
|
return locations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.shutDownProgram = function(gl, locations) {
|
ol.render.webgl.PolygonReplay.prototype.shutDownProgram = function(gl, locations) {
|
||||||
gl.disableVertexAttribArray(locations.a_position);
|
gl.disableVertexAttribArray(locations.a_position);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||||
//Save GL parameters.
|
//Save GL parameters.
|
||||||
var tmpDepthFunc = /** @type {number} */ (gl.getParameter(gl.DEPTH_FUNC));
|
var tmpDepthFunc = /** @type {number} */ (gl.getParameter(gl.DEPTH_FUNC));
|
||||||
var tmpDepthMask = /** @type {boolean} */ (gl.getParameter(gl.DEPTH_WRITEMASK));
|
var tmpDepthMask = /** @type {boolean} */ (gl.getParameter(gl.DEPTH_WRITEMASK));
|
||||||
@@ -947,13 +945,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
gl.depthMask(tmpDepthMask);
|
gl.depthMask(tmpDepthMask);
|
||||||
gl.depthFunc(tmpDepthFunc);
|
gl.depthFunc(tmpDepthFunc);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
ol.render.webgl.PolygonReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||||
featureCallback, opt_hitExtent) {
|
featureCallback, opt_hitExtent) {
|
||||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
||||||
featureIndex = this.startIndices.length - 2;
|
featureIndex = this.startIndices.length - 2;
|
||||||
@@ -989,16 +987,16 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
ol.render.webgl.PolygonReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
||||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
||||||
featureIndex = this.startIndices.length - 2;
|
featureIndex = this.startIndices.length - 2;
|
||||||
end = start = this.startIndices[featureIndex + 1];
|
end = start = this.startIndices[featureIndex + 1];
|
||||||
@@ -1029,23 +1027,23 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
start = end = groupStart;
|
start = end = groupStart;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {Array.<number>} color Color.
|
* @param {Array.<number>} color Color.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.setFillStyle_ = function(gl, color) {
|
ol.render.webgl.PolygonReplay.prototype.setFillStyle_ = function(gl, color) {
|
||||||
gl.uniform4fv(this.defaultLocations_.u_color, color);
|
gl.uniform4fv(this.defaultLocations_.u_color, color);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.PolygonReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
ol.render.webgl.PolygonReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||||
var fillStyleColor = fillStyle ? fillStyle.getColor() : [0, 0, 0, 0];
|
var fillStyleColor = fillStyle ? fillStyle.getColor() : [0, 0, 0, 0];
|
||||||
if (!(fillStyleColor instanceof CanvasGradient) &&
|
if (!(fillStyleColor instanceof CanvasGradient) &&
|
||||||
!(fillStyleColor instanceof CanvasPattern)) {
|
!(fillStyleColor instanceof CanvasPattern)) {
|
||||||
@@ -1070,6 +1068,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
});
|
});
|
||||||
this.lineStringReplay.setFillStrokeStyle(null, nullStrokeStyle);
|
this.lineStringReplay.setFillStrokeStyle(null, nullStrokeStyle);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,89 +6,87 @@ goog.require('ol');
|
|||||||
goog.require('ol.webgl.Fragment');
|
goog.require('ol.webgl.Fragment');
|
||||||
goog.require('ol.webgl.Vertex');
|
goog.require('ol.webgl.Vertex');
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Fragment}
|
* @extends {ol.webgl.Fragment}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Fragment = function() {
|
ol.render.webgl.polygonreplay.defaultshader.Fragment = function() {
|
||||||
ol.webgl.Fragment.call(this, ol.render.webgl.polygonreplay.defaultshader.Fragment.SOURCE);
|
ol.webgl.Fragment.call(this, ol.render.webgl.polygonreplay.defaultshader.Fragment.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.polygonreplay.defaultshader.Fragment, ol.webgl.Fragment);
|
ol.inherits(ol.render.webgl.polygonreplay.defaultshader.Fragment, ol.webgl.Fragment);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\n\n\n\nuniform vec4 u_color;\nuniform float u_opacity;\n\nvoid main(void) {\n gl_FragColor = u_color;\n float alpha = u_color.a * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n';
|
ol.render.webgl.polygonreplay.defaultshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\n\n\n\nuniform vec4 u_color;\nuniform float u_opacity;\n\nvoid main(void) {\n gl_FragColor = u_color;\n float alpha = u_color.a * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;uniform vec4 e;uniform float f;void main(void){gl_FragColor=e;float alpha=e.a*f;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}';
|
ol.render.webgl.polygonreplay.defaultshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;uniform vec4 e;uniform float f;void main(void){gl_FragColor=e;float alpha=e.a*f;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
ol.render.webgl.polygonreplay.defaultshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Fragment.DEBUG_SOURCE :
|
ol.render.webgl.polygonreplay.defaultshader.Fragment.DEBUG_SOURCE :
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Fragment.OPTIMIZED_SOURCE;
|
ol.render.webgl.polygonreplay.defaultshader.Fragment.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
ol.render.webgl.polygonreplay.defaultshader.fragment = new ol.render.webgl.polygonreplay.defaultshader.Fragment();
|
ol.render.webgl.polygonreplay.defaultshader.fragment = new ol.render.webgl.polygonreplay.defaultshader.Fragment();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Vertex}
|
* @extends {ol.webgl.Vertex}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Vertex = function() {
|
ol.render.webgl.polygonreplay.defaultshader.Vertex = function() {
|
||||||
ol.webgl.Vertex.call(this, ol.render.webgl.polygonreplay.defaultshader.Vertex.SOURCE);
|
ol.webgl.Vertex.call(this, ol.render.webgl.polygonreplay.defaultshader.Vertex.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.polygonreplay.defaultshader.Vertex, ol.webgl.Vertex);
|
ol.inherits(ol.render.webgl.polygonreplay.defaultshader.Vertex, ol.webgl.Vertex);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Vertex.DEBUG_SOURCE = '\n\nattribute vec2 a_position;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n}\n\n\n';
|
ol.render.webgl.polygonreplay.defaultshader.Vertex.DEBUG_SOURCE = '\n\nattribute vec2 a_position;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n}\n\n\n';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'attribute vec2 a;uniform mat4 b;uniform mat4 c;uniform mat4 d;void main(void){gl_Position=b*vec4(a,0.0,1.0);}';
|
ol.render.webgl.polygonreplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'attribute vec2 a;uniform mat4 b;uniform mat4 c;uniform mat4 d;void main(void){gl_Position=b*vec4(a,0.0,1.0);}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
ol.render.webgl.polygonreplay.defaultshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Vertex.DEBUG_SOURCE :
|
ol.render.webgl.polygonreplay.defaultshader.Vertex.DEBUG_SOURCE :
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Vertex.OPTIMIZED_SOURCE;
|
ol.render.webgl.polygonreplay.defaultshader.Vertex.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
ol.render.webgl.polygonreplay.defaultshader.vertex = new ol.render.webgl.polygonreplay.defaultshader.Vertex();
|
ol.render.webgl.polygonreplay.defaultshader.vertex = new ol.render.webgl.polygonreplay.defaultshader.Vertex();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {WebGLRenderingContext} gl GL.
|
* @param {WebGLRenderingContext} gl GL.
|
||||||
* @param {WebGLProgram} program Program.
|
* @param {WebGLProgram} program Program.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.polygonreplay.defaultshader.Locations = function(gl, program) {
|
ol.render.webgl.polygonreplay.defaultshader.Locations = function(gl, program) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {WebGLUniformLocation}
|
* @type {WebGLUniformLocation}
|
||||||
@@ -125,6 +123,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.a_position = gl.getAttribLocation(
|
this.a_position = gl.getAttribLocation(
|
||||||
program, ol.DEBUG_WEBGL ? 'a_position' : 'a');
|
program, ol.DEBUG_WEBGL ? 'a_position' : 'a');
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ goog.require('ol.vec.Mat4');
|
|||||||
goog.require('ol.webgl');
|
goog.require('ol.webgl');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @abstract
|
* @abstract
|
||||||
* @extends {ol.render.VectorContext}
|
* @extends {ol.render.VectorContext}
|
||||||
@@ -18,7 +16,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.Extent} maxExtent Max extent.
|
* @param {ol.Extent} maxExtent Max extent.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay = function(tolerance, maxExtent) {
|
ol.render.webgl.Replay = function(tolerance, maxExtent) {
|
||||||
ol.render.VectorContext.call(this);
|
ol.render.VectorContext.call(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,26 +111,26 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.lineStringReplay = undefined;
|
this.lineStringReplay = undefined;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.Replay, ol.render.VectorContext);
|
ol.inherits(ol.render.webgl.Replay, ol.render.VectorContext);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @param {ol.webgl.Context} context WebGL context.
|
* @param {ol.webgl.Context} context WebGL context.
|
||||||
* @return {function()} Delete resources function.
|
* @return {function()} Delete resources function.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.getDeleteResourcesFunction = function(context) {};
|
ol.render.webgl.Replay.prototype.getDeleteResourcesFunction = function(context) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.finish = function(context) {};
|
ol.render.webgl.Replay.prototype.finish = function(context) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @protected
|
* @protected
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
@@ -144,10 +142,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
ol.render.webgl.polygonreplay.defaultshader.Locations|
|
ol.render.webgl.polygonreplay.defaultshader.Locations|
|
||||||
ol.render.webgl.texturereplay.defaultshader.Locations} Locations.
|
ol.render.webgl.texturereplay.defaultshader.Locations} Locations.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {};
|
ol.render.webgl.Replay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @protected
|
* @protected
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
@@ -156,10 +154,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
ol.render.webgl.polygonreplay.defaultshader.Locations|
|
ol.render.webgl.polygonreplay.defaultshader.Locations|
|
||||||
ol.render.webgl.texturereplay.defaultshader.Locations} locations Locations.
|
ol.render.webgl.texturereplay.defaultshader.Locations} locations Locations.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.shutDownProgram = function(gl, locations) {};
|
ol.render.webgl.Replay.prototype.shutDownProgram = function(gl, locations) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @protected
|
* @protected
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
@@ -168,10 +166,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* to skip.
|
* to skip.
|
||||||
* @param {boolean} hitDetection Hit detection mode.
|
* @param {boolean} hitDetection Hit detection mode.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {};
|
ol.render.webgl.Replay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @protected
|
* @protected
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
@@ -184,10 +182,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {T|undefined} Callback result.
|
* @return {T|undefined} Callback result.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {};
|
ol.render.webgl.Replay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
@@ -200,7 +198,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {T|undefined} Callback result.
|
* @return {T|undefined} Callback result.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.drawHitDetectionReplay = function(gl, context, skippedFeaturesHash,
|
ol.render.webgl.Replay.prototype.drawHitDetectionReplay = function(gl, context, skippedFeaturesHash,
|
||||||
featureCallback, oneByOne, opt_hitExtent) {
|
featureCallback, oneByOne, opt_hitExtent) {
|
||||||
if (!oneByOne) {
|
if (!oneByOne) {
|
||||||
// draw all hit-detection features in "once" (by texture group)
|
// draw all hit-detection features in "once" (by texture group)
|
||||||
@@ -211,10 +209,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
return this.drawHitDetectionReplayOneByOne(gl, context,
|
return this.drawHitDetectionReplayOneByOne(gl, context,
|
||||||
skippedFeaturesHash, featureCallback, opt_hitExtent);
|
skippedFeaturesHash, featureCallback, opt_hitExtent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
@@ -224,7 +222,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {T|undefined} Callback result.
|
* @return {T|undefined} Callback result.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.drawHitDetectionReplayAll = function(gl, context, skippedFeaturesHash,
|
ol.render.webgl.Replay.prototype.drawHitDetectionReplayAll = function(gl, context, skippedFeaturesHash,
|
||||||
featureCallback) {
|
featureCallback) {
|
||||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||||
this.drawReplay(gl, context, skippedFeaturesHash, true);
|
this.drawReplay(gl, context, skippedFeaturesHash, true);
|
||||||
@@ -235,10 +233,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
* @param {ol.Coordinate} center Center.
|
* @param {ol.Coordinate} center Center.
|
||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
@@ -255,7 +253,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {T|undefined} Callback result.
|
* @return {T|undefined} Callback result.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.replay = function(context,
|
ol.render.webgl.Replay.prototype.replay = function(context,
|
||||||
center, resolution, rotation, size, pixelRatio,
|
center, resolution, rotation, size, pixelRatio,
|
||||||
opacity, skippedFeaturesHash,
|
opacity, skippedFeaturesHash,
|
||||||
featureCallback, oneByOne, opt_hitExtent) {
|
featureCallback, oneByOne, opt_hitExtent) {
|
||||||
@@ -342,16 +340,16 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
* @param {number} start Start index.
|
* @param {number} start Start index.
|
||||||
* @param {number} end End index.
|
* @param {number} end End index.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.Replay.prototype.drawElements = function(
|
ol.render.webgl.Replay.prototype.drawElements = function(
|
||||||
gl, context, start, end) {
|
gl, context, start, end) {
|
||||||
var elementType = context.hasOESElementIndexUint ?
|
var elementType = context.hasOESElementIndexUint ?
|
||||||
ol.webgl.UNSIGNED_INT : ol.webgl.UNSIGNED_SHORT;
|
ol.webgl.UNSIGNED_INT : ol.webgl.UNSIGNED_SHORT;
|
||||||
@@ -360,6 +358,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var numItems = end - start;
|
var numItems = end - start;
|
||||||
var offsetInBytes = start * elementSize;
|
var offsetInBytes = start * elementSize;
|
||||||
gl.drawElements(ol.webgl.TRIANGLES, numItems, elementType, offsetInBytes);
|
gl.drawElements(ol.webgl.TRIANGLES, numItems, elementType, offsetInBytes);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ goog.require('ol.render.webgl.PolygonReplay');
|
|||||||
goog.require('ol.render.webgl.TextReplay');
|
goog.require('ol.render.webgl.TextReplay');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.ReplayGroup}
|
* @extends {ol.render.ReplayGroup}
|
||||||
* @param {number} tolerance Tolerance.
|
* @param {number} tolerance Tolerance.
|
||||||
@@ -23,7 +21,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {number=} opt_renderBuffer Render buffer.
|
* @param {number=} opt_renderBuffer Render buffer.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup = function(tolerance, maxExtent, opt_renderBuffer) {
|
ol.render.webgl.ReplayGroup = function(tolerance, maxExtent, opt_renderBuffer) {
|
||||||
ol.render.ReplayGroup.call(this);
|
ol.render.ReplayGroup.call(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,15 +49,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.replaysByZIndex_ = {};
|
this.replaysByZIndex_ = {};
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.ReplayGroup, ol.render.ReplayGroup);
|
ol.inherits(ol.render.webgl.ReplayGroup, ol.render.ReplayGroup);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.webgl.Context} context WebGL context.
|
* @param {ol.webgl.Context} context WebGL context.
|
||||||
* @return {function()} Delete resources function.
|
* @return {function()} Delete resources function.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.prototype.getDeleteResourcesFunction = function(context) {
|
ol.render.webgl.ReplayGroup.prototype.getDeleteResourcesFunction = function(context) {
|
||||||
var functions = [];
|
var functions = [];
|
||||||
var zKey;
|
var zKey;
|
||||||
for (zKey in this.replaysByZIndex_) {
|
for (zKey in this.replaysByZIndex_) {
|
||||||
@@ -78,13 +76,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.prototype.finish = function(context) {
|
ol.render.webgl.ReplayGroup.prototype.finish = function(context) {
|
||||||
var zKey;
|
var zKey;
|
||||||
for (zKey in this.replaysByZIndex_) {
|
for (zKey in this.replaysByZIndex_) {
|
||||||
var replays = this.replaysByZIndex_[zKey];
|
var replays = this.replaysByZIndex_[zKey];
|
||||||
@@ -93,13 +91,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
replays[replayKey].finish(context);
|
replays[replayKey].finish(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.prototype.getReplay = function(zIndex, replayType) {
|
ol.render.webgl.ReplayGroup.prototype.getReplay = function(zIndex, replayType) {
|
||||||
var zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
|
var zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
|
||||||
var replays = this.replaysByZIndex_[zIndexKey];
|
var replays = this.replaysByZIndex_[zIndexKey];
|
||||||
if (replays === undefined) {
|
if (replays === undefined) {
|
||||||
@@ -116,18 +114,18 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
replays[replayType] = replay;
|
replays[replayType] = replay;
|
||||||
}
|
}
|
||||||
return replay;
|
return replay;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.prototype.isEmpty = function() {
|
ol.render.webgl.ReplayGroup.prototype.isEmpty = function() {
|
||||||
return ol.obj.isEmpty(this.replaysByZIndex_);
|
return ol.obj.isEmpty(this.replaysByZIndex_);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
* @param {ol.Coordinate} center Center.
|
* @param {ol.Coordinate} center Center.
|
||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
@@ -138,7 +136,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
||||||
* to skip.
|
* to skip.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.prototype.replay = function(context,
|
ol.render.webgl.ReplayGroup.prototype.replay = function(context,
|
||||||
center, resolution, rotation, size, pixelRatio,
|
center, resolution, rotation, size, pixelRatio,
|
||||||
opacity, skippedFeaturesHash) {
|
opacity, skippedFeaturesHash) {
|
||||||
/** @type {Array.<number>} */
|
/** @type {Array.<number>} */
|
||||||
@@ -158,10 +156,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
* @param {ol.Coordinate} center Center.
|
* @param {ol.Coordinate} center Center.
|
||||||
@@ -179,7 +177,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {T|undefined} Callback result.
|
* @return {T|undefined} Callback result.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context,
|
ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context,
|
||||||
center, resolution, rotation, size, pixelRatio, opacity,
|
center, resolution, rotation, size, pixelRatio, opacity,
|
||||||
skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent) {
|
skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent) {
|
||||||
/** @type {Array.<number>} */
|
/** @type {Array.<number>} */
|
||||||
@@ -204,10 +202,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate} coordinate Coordinate.
|
* @param {ol.Coordinate} coordinate Coordinate.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
* @param {ol.Coordinate} center Center.
|
* @param {ol.Coordinate} center Center.
|
||||||
@@ -222,7 +220,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {T|undefined} Callback result.
|
* @return {T|undefined} Callback result.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
||||||
coordinate, context, center, resolution, rotation, size, pixelRatio,
|
coordinate, context, center, resolution, rotation, size, pixelRatio,
|
||||||
opacity, skippedFeaturesHash,
|
opacity, skippedFeaturesHash,
|
||||||
callback) {
|
callback) {
|
||||||
@@ -261,10 +259,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, true, hitExtent);
|
}, true, hitExtent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate} coordinate Coordinate.
|
* @param {ol.Coordinate} coordinate Coordinate.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
* @param {ol.Coordinate} center Center.
|
* @param {ol.Coordinate} center Center.
|
||||||
@@ -277,7 +275,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* to skip.
|
* to skip.
|
||||||
* @return {boolean} Is there a feature at the given coordinate?
|
* @return {boolean} Is there a feature at the given coordinate?
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function(
|
ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function(
|
||||||
coordinate, context, center, resolution, rotation, size, pixelRatio,
|
coordinate, context, center, resolution, rotation, size, pixelRatio,
|
||||||
opacity, skippedFeaturesHash) {
|
opacity, skippedFeaturesHash) {
|
||||||
var gl = context.getGL();
|
var gl = context.getGL();
|
||||||
@@ -298,28 +296,26 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
return hasFeature !== undefined;
|
return hasFeature !== undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @private
|
* @private
|
||||||
* @type {Array.<number>}
|
* @type {Array.<number>}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.HIT_DETECTION_SIZE_ = [1, 1];
|
ol.render.webgl.ReplayGroup.HIT_DETECTION_SIZE_ = [1, 1];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @private
|
* @private
|
||||||
* @type {Object.<ol.render.ReplayType,
|
* @type {Object.<ol.render.ReplayType,
|
||||||
* function(new: ol.render.webgl.Replay, number,
|
* function(new: ol.render.webgl.Replay, number,
|
||||||
* ol.Extent)>}
|
* ol.Extent)>}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.BATCH_CONSTRUCTORS_ = {
|
ol.render.webgl.ReplayGroup.BATCH_CONSTRUCTORS_ = {
|
||||||
'Circle': ol.render.webgl.CircleReplay,
|
'Circle': ol.render.webgl.CircleReplay,
|
||||||
'Image': ol.render.webgl.ImageReplay,
|
'Image': ol.render.webgl.ImageReplay,
|
||||||
'LineString': ol.render.webgl.LineStringReplay,
|
'LineString': ol.render.webgl.LineStringReplay,
|
||||||
'Polygon': ol.render.webgl.PolygonReplay,
|
'Polygon': ol.render.webgl.PolygonReplay,
|
||||||
'Text': ol.render.webgl.TextReplay
|
'Text': ol.render.webgl.TextReplay
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,16 +10,14 @@ goog.require('ol.style.AtlasManager');
|
|||||||
goog.require('ol.webgl.Buffer');
|
goog.require('ol.webgl.Buffer');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.webgl.TextureReplay}
|
* @extends {ol.render.webgl.TextureReplay}
|
||||||
* @param {number} tolerance Tolerance.
|
* @param {number} tolerance Tolerance.
|
||||||
* @param {ol.Extent} maxExtent Max extent.
|
* @param {ol.Extent} maxExtent Max extent.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay = function(tolerance, maxExtent) {
|
ol.render.webgl.TextReplay = function(tolerance, maxExtent) {
|
||||||
ol.render.webgl.TextureReplay.call(this, tolerance, maxExtent);
|
ol.render.webgl.TextureReplay.call(this, tolerance, maxExtent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,14 +110,14 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
|
|
||||||
this.opacity = 1;
|
this.opacity = 1;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.TextReplay, ol.render.webgl.TextureReplay);
|
ol.inherits(ol.render.webgl.TextReplay, ol.render.webgl.TextureReplay);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.drawText = function(flatCoordinates, offset,
|
ol.render.webgl.TextReplay.prototype.drawText = function(flatCoordinates, offset,
|
||||||
end, stride, geometry, feature) {
|
end, stride, geometry, feature) {
|
||||||
if (this.text_) {
|
if (this.text_) {
|
||||||
this.startIndices.push(this.indices.length);
|
this.startIndices.push(this.indices.length);
|
||||||
@@ -171,15 +169,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Array.<string>} lines Label to draw split to lines.
|
* @param {Array.<string>} lines Label to draw split to lines.
|
||||||
* @return {Array.<number>} Size of the label in pixels.
|
* @return {Array.<number>} Size of the label in pixels.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.getTextSize_ = function(lines) {
|
ol.render.webgl.TextReplay.prototype.getTextSize_ = function(lines) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var glyphAtlas = this.currAtlas_;
|
var glyphAtlas = this.currAtlas_;
|
||||||
var textHeight = lines.length * glyphAtlas.height;
|
var textHeight = lines.length * glyphAtlas.height;
|
||||||
@@ -200,30 +198,30 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return [textWidth, textHeight];
|
return [textWidth, textHeight];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
* @param {number} offset Offset.
|
* @param {number} offset Offset.
|
||||||
* @param {number} end End.
|
* @param {number} end End.
|
||||||
* @param {number} stride Stride.
|
* @param {number} stride Stride.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.drawText_ = function(flatCoordinates, offset,
|
ol.render.webgl.TextReplay.prototype.drawText_ = function(flatCoordinates, offset,
|
||||||
end, stride) {
|
end, stride) {
|
||||||
var i, ii;
|
var i, ii;
|
||||||
for (i = offset, ii = end; i < ii; i += stride) {
|
for (i = offset, ii = end; i < ii; i += stride) {
|
||||||
this.drawCoordinates(flatCoordinates, offset, end, stride);
|
this.drawCoordinates(flatCoordinates, offset, end, stride);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {string} char Character.
|
* @param {string} char Character.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.addCharToAtlas_ = function(char) {
|
ol.render.webgl.TextReplay.prototype.addCharToAtlas_ = function(char) {
|
||||||
if (char.length === 1) {
|
if (char.length === 1) {
|
||||||
var glyphAtlas = this.currAtlas_;
|
var glyphAtlas = this.currAtlas_;
|
||||||
var state = this.state_;
|
var state = this.state_;
|
||||||
@@ -267,13 +265,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
glyphAtlas.width[char] = width;
|
glyphAtlas.width[char] = width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.finish = function(context) {
|
ol.render.webgl.TextReplay.prototype.finish = function(context) {
|
||||||
var gl = context.getGL();
|
var gl = context.getGL();
|
||||||
|
|
||||||
this.groupIndices.push(this.indices.length);
|
this.groupIndices.push(this.indices.length);
|
||||||
@@ -312,13 +310,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.atlases_ = {};
|
this.atlases_ = {};
|
||||||
this.currAtlas_ = undefined;
|
this.currAtlas_ = undefined;
|
||||||
ol.render.webgl.TextureReplay.prototype.finish.call(this, context);
|
ol.render.webgl.TextureReplay.prototype.finish.call(this, context);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.setTextStyle = function(textStyle) {
|
ol.render.webgl.TextReplay.prototype.setTextStyle = function(textStyle) {
|
||||||
var state = this.state_;
|
var state = this.state_;
|
||||||
var textFillStyle = textStyle.getFill();
|
var textFillStyle = textStyle.getFill();
|
||||||
var textStrokeStyle = textStyle.getStroke();
|
var textStrokeStyle = textStyle.getStroke();
|
||||||
@@ -363,15 +361,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
|
|
||||||
this.currAtlas_ = this.getAtlas_(state);
|
this.currAtlas_ = this.getAtlas_(state);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} state Font attributes.
|
* @param {Object} state Font attributes.
|
||||||
* @return {ol.WebglGlyphAtlas} Glyph atlas.
|
* @return {ol.WebglGlyphAtlas} Glyph atlas.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.getAtlas_ = function(state) {
|
ol.render.webgl.TextReplay.prototype.getAtlas_ = function(state) {
|
||||||
var params = [];
|
var params = [];
|
||||||
var i;
|
var i;
|
||||||
for (i in state) {
|
for (i in state) {
|
||||||
@@ -399,15 +397,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return this.atlases_[hash];
|
return this.atlases_[hash];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Array.<string|number>} params Array of parameters.
|
* @param {Array.<string|number>} params Array of parameters.
|
||||||
* @return {string} Hash string.
|
* @return {string} Hash string.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.calculateHash_ = function(params) {
|
ol.render.webgl.TextReplay.prototype.calculateHash_ = function(params) {
|
||||||
//TODO: Create a more performant, reliable, general hash function.
|
//TODO: Create a more performant, reliable, general hash function.
|
||||||
var i, ii;
|
var i, ii;
|
||||||
var hash = '';
|
var hash = '';
|
||||||
@@ -415,30 +413,30 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
hash += params[i];
|
hash += params[i];
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.getTextures = function(opt_all) {
|
ol.render.webgl.TextReplay.prototype.getTextures = function(opt_all) {
|
||||||
return this.textures_;
|
return this.textures_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.prototype.getHitDetectionTextures = function() {
|
ol.render.webgl.TextReplay.prototype.getHitDetectionTextures = function() {
|
||||||
return this.textures_;
|
return this.textures_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextReplay.Align_ = {
|
ol.render.webgl.TextReplay.Align_ = {
|
||||||
left: 0,
|
left: 0,
|
||||||
end: 0,
|
end: 0,
|
||||||
center: 0.5,
|
center: 0.5,
|
||||||
@@ -450,6 +448,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
alphabetic: 0.8,
|
alphabetic: 0.8,
|
||||||
ideographic: 0.8,
|
ideographic: 0.8,
|
||||||
bottom: 1
|
bottom: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ goog.require('ol.render.webgl.Replay');
|
|||||||
goog.require('ol.webgl');
|
goog.require('ol.webgl');
|
||||||
goog.require('ol.webgl.Context');
|
goog.require('ol.webgl.Context');
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @abstract
|
* @abstract
|
||||||
* @extends {ol.render.webgl.Replay}
|
* @extends {ol.render.webgl.Replay}
|
||||||
@@ -18,7 +16,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.Extent} maxExtent Max extent.
|
* @param {ol.Extent} maxExtent Max extent.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay = function(tolerance, maxExtent) {
|
ol.render.webgl.TextureReplay = function(tolerance, maxExtent) {
|
||||||
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,14 +108,14 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
this.width = undefined;
|
this.width = undefined;
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.TextureReplay, ol.render.webgl.Replay);
|
ol.inherits(ol.render.webgl.TextureReplay, ol.render.webgl.Replay);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.getDeleteResourcesFunction = function(context) {
|
ol.render.webgl.TextureReplay.prototype.getDeleteResourcesFunction = function(context) {
|
||||||
var verticesBuffer = this.verticesBuffer;
|
var verticesBuffer = this.verticesBuffer;
|
||||||
var indicesBuffer = this.indicesBuffer;
|
var indicesBuffer = this.indicesBuffer;
|
||||||
var textures = this.getTextures(true);
|
var textures = this.getTextures(true);
|
||||||
@@ -132,10 +130,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
context.deleteBuffer(verticesBuffer);
|
context.deleteBuffer(verticesBuffer);
|
||||||
context.deleteBuffer(indicesBuffer);
|
context.deleteBuffer(indicesBuffer);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
* @param {Array.<number>} flatCoordinates Flat coordinates.
|
||||||
* @param {number} offset Offset.
|
* @param {number} offset Offset.
|
||||||
* @param {number} end End.
|
* @param {number} end End.
|
||||||
@@ -143,7 +141,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {number} My end.
|
* @return {number} My end.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.drawCoordinates = function(flatCoordinates, offset, end, stride) {
|
ol.render.webgl.TextureReplay.prototype.drawCoordinates = function(flatCoordinates, offset, end, stride) {
|
||||||
var anchorX = /** @type {number} */ (this.anchorX);
|
var anchorX = /** @type {number} */ (this.anchorX);
|
||||||
var anchorY = /** @type {number} */ (this.anchorY);
|
var anchorY = /** @type {number} */ (this.anchorY);
|
||||||
var height = /** @type {number} */ (this.height);
|
var height = /** @type {number} */ (this.height);
|
||||||
@@ -235,10 +233,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return numVertices;
|
return numVertices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
* @param {Array.<WebGLTexture>} textures Textures.
|
* @param {Array.<WebGLTexture>} textures Textures.
|
||||||
* @param {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>} images
|
* @param {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>} images
|
||||||
@@ -246,7 +244,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {Object.<string, WebGLTexture>} texturePerImage Texture cache.
|
* @param {Object.<string, WebGLTexture>} texturePerImage Texture cache.
|
||||||
* @param {WebGLRenderingContext} gl Gl.
|
* @param {WebGLRenderingContext} gl Gl.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.createTextures = function(textures, images, texturePerImage, gl) {
|
ol.render.webgl.TextureReplay.prototype.createTextures = function(textures, images, texturePerImage, gl) {
|
||||||
var texture, image, uid, i;
|
var texture, image, uid, i;
|
||||||
var ii = images.length;
|
var ii = images.length;
|
||||||
for (i = 0; i < ii; ++i) {
|
for (i = 0; i < ii; ++i) {
|
||||||
@@ -262,13 +260,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
textures[i] = texture;
|
textures[i] = texture;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
ol.render.webgl.TextureReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||||
// get the program
|
// get the program
|
||||||
var fragmentShader = ol.render.webgl.texturereplay.defaultshader.fragment;
|
var fragmentShader = ol.render.webgl.texturereplay.defaultshader.fragment;
|
||||||
var vertexShader = ol.render.webgl.texturereplay.defaultshader.vertex;
|
var vertexShader = ol.render.webgl.texturereplay.defaultshader.vertex;
|
||||||
@@ -309,25 +307,25 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
false, 32, 28);
|
false, 32, 28);
|
||||||
|
|
||||||
return locations;
|
return locations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.shutDownProgram = function(gl, locations) {
|
ol.render.webgl.TextureReplay.prototype.shutDownProgram = function(gl, locations) {
|
||||||
gl.disableVertexAttribArray(locations.a_position);
|
gl.disableVertexAttribArray(locations.a_position);
|
||||||
gl.disableVertexAttribArray(locations.a_offsets);
|
gl.disableVertexAttribArray(locations.a_offsets);
|
||||||
gl.disableVertexAttribArray(locations.a_texCoord);
|
gl.disableVertexAttribArray(locations.a_texCoord);
|
||||||
gl.disableVertexAttribArray(locations.a_opacity);
|
gl.disableVertexAttribArray(locations.a_opacity);
|
||||||
gl.disableVertexAttribArray(locations.a_rotateWithView);
|
gl.disableVertexAttribArray(locations.a_rotateWithView);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
ol.render.webgl.TextureReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||||
var textures = hitDetection ? this.getHitDetectionTextures() : this.getTextures();
|
var textures = hitDetection ? this.getHitDetectionTextures() : this.getTextures();
|
||||||
var groupIndices = hitDetection ? this.hitDetectionGroupIndices : this.groupIndices;
|
var groupIndices = hitDetection ? this.hitDetectionGroupIndices : this.groupIndices;
|
||||||
|
|
||||||
@@ -343,10 +341,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
start = end;
|
start = end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the replay while paying attention to skipped features.
|
* Draw the replay while paying attention to skipped features.
|
||||||
*
|
*
|
||||||
* This functions creates groups of features that can be drawn to together,
|
* This functions creates groups of features that can be drawn to together,
|
||||||
@@ -372,7 +370,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {Array.<WebGLTexture>} textures Textures.
|
* @param {Array.<WebGLTexture>} textures Textures.
|
||||||
* @param {Array.<number>} groupIndices Texture group indices.
|
* @param {Array.<number>} groupIndices Texture group indices.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.drawReplaySkipping = function(gl, context, skippedFeaturesHash, textures,
|
ol.render.webgl.TextureReplay.prototype.drawReplaySkipping = function(gl, context, skippedFeaturesHash, textures,
|
||||||
groupIndices) {
|
groupIndices) {
|
||||||
var featureIndex = 0;
|
var featureIndex = 0;
|
||||||
|
|
||||||
@@ -413,13 +411,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.drawElements(gl, context, start, end);
|
this.drawElements(gl, context, start, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
ol.render.webgl.TextureReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||||
featureCallback, opt_hitExtent) {
|
featureCallback, opt_hitExtent) {
|
||||||
var i, groupStart, start, end, feature, featureUid;
|
var i, groupStart, start, end, feature, featureUid;
|
||||||
var featureIndex = this.startIndices.length - 1;
|
var featureIndex = this.startIndices.length - 1;
|
||||||
@@ -455,13 +453,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.finish = function(context) {
|
ol.render.webgl.TextureReplay.prototype.finish = function(context) {
|
||||||
this.anchorX = undefined;
|
this.anchorX = undefined;
|
||||||
this.anchorY = undefined;
|
this.anchorY = undefined;
|
||||||
this.height = undefined;
|
this.height = undefined;
|
||||||
@@ -476,22 +474,21 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.scale = undefined;
|
this.scale = undefined;
|
||||||
this.vertices = null;
|
this.vertices = null;
|
||||||
this.width = undefined;
|
this.width = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @protected
|
* @protected
|
||||||
* @param {boolean=} opt_all Return hit detection textures with regular ones.
|
* @param {boolean=} opt_all Return hit detection textures with regular ones.
|
||||||
* @returns {Array.<WebGLTexture>} Textures.
|
* @returns {Array.<WebGLTexture>} Textures.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.getTextures = function(opt_all) {};
|
ol.render.webgl.TextureReplay.prototype.getTextures = function(opt_all) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @protected
|
* @protected
|
||||||
* @returns {Array.<WebGLTexture>} Textures.
|
* @returns {Array.<WebGLTexture>} Textures.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.TextureReplay.prototype.getHitDetectionTextures = function() {};
|
ol.render.webgl.TextureReplay.prototype.getHitDetectionTextures = function() {};
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,89 +6,87 @@ goog.require('ol');
|
|||||||
goog.require('ol.webgl.Fragment');
|
goog.require('ol.webgl.Fragment');
|
||||||
goog.require('ol.webgl.Vertex');
|
goog.require('ol.webgl.Vertex');
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Fragment}
|
* @extends {ol.webgl.Fragment}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.texturereplay.defaultshader.Fragment = function() {
|
ol.render.webgl.texturereplay.defaultshader.Fragment = function() {
|
||||||
ol.webgl.Fragment.call(this, ol.render.webgl.texturereplay.defaultshader.Fragment.SOURCE);
|
ol.webgl.Fragment.call(this, ol.render.webgl.texturereplay.defaultshader.Fragment.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.texturereplay.defaultshader.Fragment, ol.webgl.Fragment);
|
ol.inherits(ol.render.webgl.texturereplay.defaultshader.Fragment, ol.webgl.Fragment);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.texturereplay.defaultshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_texCoord;\nvarying float v_opacity;\n\nuniform float u_opacity;\nuniform sampler2D u_image;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_image, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n float alpha = texColor.a * v_opacity * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n';
|
ol.render.webgl.texturereplay.defaultshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_texCoord;\nvarying float v_opacity;\n\nuniform float u_opacity;\nuniform sampler2D u_image;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_image, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n float alpha = texColor.a * v_opacity * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.texturereplay.defaultshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;varying float b;uniform float k;uniform sampler2D l;void main(void){vec4 texColor=texture2D(l,a);gl_FragColor.rgb=texColor.rgb;float alpha=texColor.a*b*k;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}';
|
ol.render.webgl.texturereplay.defaultshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;varying float b;uniform float k;uniform sampler2D l;void main(void){vec4 texColor=texture2D(l,a);gl_FragColor.rgb=texColor.rgb;float alpha=texColor.a*b*k;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.texturereplay.defaultshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
ol.render.webgl.texturereplay.defaultshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
ol.render.webgl.texturereplay.defaultshader.Fragment.DEBUG_SOURCE :
|
ol.render.webgl.texturereplay.defaultshader.Fragment.DEBUG_SOURCE :
|
||||||
ol.render.webgl.texturereplay.defaultshader.Fragment.OPTIMIZED_SOURCE;
|
ol.render.webgl.texturereplay.defaultshader.Fragment.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
ol.render.webgl.texturereplay.defaultshader.fragment = new ol.render.webgl.texturereplay.defaultshader.Fragment();
|
ol.render.webgl.texturereplay.defaultshader.fragment = new ol.render.webgl.texturereplay.defaultshader.Fragment();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Vertex}
|
* @extends {ol.webgl.Vertex}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.texturereplay.defaultshader.Vertex = function() {
|
ol.render.webgl.texturereplay.defaultshader.Vertex = function() {
|
||||||
ol.webgl.Vertex.call(this, ol.render.webgl.texturereplay.defaultshader.Vertex.SOURCE);
|
ol.webgl.Vertex.call(this, ol.render.webgl.texturereplay.defaultshader.Vertex.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.render.webgl.texturereplay.defaultshader.Vertex, ol.webgl.Vertex);
|
ol.inherits(ol.render.webgl.texturereplay.defaultshader.Vertex, ol.webgl.Vertex);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.texturereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\nvarying float v_opacity;\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nattribute vec2 a_offsets;\nattribute float a_opacity;\nattribute float a_rotateWithView;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n if (a_rotateWithView == 1.0) {\n offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n }\n vec4 offsets = offsetMatrix * vec4(a_offsets, 0.0, 0.0);\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;\n v_texCoord = a_texCoord;\n v_opacity = a_opacity;\n}\n\n\n';
|
ol.render.webgl.texturereplay.defaultshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\nvarying float v_opacity;\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nattribute vec2 a_offsets;\nattribute float a_opacity;\nattribute float a_rotateWithView;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n if (a_rotateWithView == 1.0) {\n offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n }\n vec4 offsets = offsetMatrix * vec4(a_offsets, 0.0, 0.0);\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;\n v_texCoord = a_texCoord;\n v_opacity = a_opacity;\n}\n\n\n';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.texturereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying float b;attribute vec2 c;attribute vec2 d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;void main(void){mat4 offsetMatrix=i;if(g==1.0){offsetMatrix=i*j;}vec4 offsets=offsetMatrix*vec4(e,0.0,0.0);gl_Position=h*vec4(c,0.0,1.0)+offsets;a=d;b=f;}';
|
ol.render.webgl.texturereplay.defaultshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;varying float b;attribute vec2 c;attribute vec2 d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;void main(void){mat4 offsetMatrix=i;if(g==1.0){offsetMatrix=i*j;}vec4 offsets=offsetMatrix*vec4(e,0.0,0.0);gl_Position=h*vec4(c,0.0,1.0)+offsets;a=d;b=f;}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.texturereplay.defaultshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
ol.render.webgl.texturereplay.defaultshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
ol.render.webgl.texturereplay.defaultshader.Vertex.DEBUG_SOURCE :
|
ol.render.webgl.texturereplay.defaultshader.Vertex.DEBUG_SOURCE :
|
||||||
ol.render.webgl.texturereplay.defaultshader.Vertex.OPTIMIZED_SOURCE;
|
ol.render.webgl.texturereplay.defaultshader.Vertex.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
ol.render.webgl.texturereplay.defaultshader.vertex = new ol.render.webgl.texturereplay.defaultshader.Vertex();
|
ol.render.webgl.texturereplay.defaultshader.vertex = new ol.render.webgl.texturereplay.defaultshader.Vertex();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {WebGLRenderingContext} gl GL.
|
* @param {WebGLRenderingContext} gl GL.
|
||||||
* @param {WebGLProgram} program Program.
|
* @param {WebGLProgram} program Program.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.texturereplay.defaultshader.Locations = function(gl, program) {
|
ol.render.webgl.texturereplay.defaultshader.Locations = function(gl, program) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {WebGLUniformLocation}
|
* @type {WebGLUniformLocation}
|
||||||
@@ -149,6 +147,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.a_texCoord = gl.getAttribLocation(
|
this.a_texCoord = gl.getAttribLocation(
|
||||||
program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'd');
|
program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'd');
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,89 +6,87 @@ goog.require('ol');
|
|||||||
goog.require('ol.webgl.Fragment');
|
goog.require('ol.webgl.Fragment');
|
||||||
goog.require('ol.webgl.Vertex');
|
goog.require('ol.webgl.Vertex');
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Fragment}
|
* @extends {ol.webgl.Fragment}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.defaultmapshader.Fragment = function() {
|
ol.renderer.webgl.defaultmapshader.Fragment = function() {
|
||||||
ol.webgl.Fragment.call(this, ol.renderer.webgl.defaultmapshader.Fragment.SOURCE);
|
ol.webgl.Fragment.call(this, ol.renderer.webgl.defaultmapshader.Fragment.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.renderer.webgl.defaultmapshader.Fragment, ol.webgl.Fragment);
|
ol.inherits(ol.renderer.webgl.defaultmapshader.Fragment, ol.webgl.Fragment);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.defaultmapshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_texCoord;\n\n\nuniform float u_opacity;\nuniform sampler2D u_texture;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_texture, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n gl_FragColor.a = texColor.a * u_opacity;\n}\n';
|
ol.renderer.webgl.defaultmapshader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_texCoord;\n\n\nuniform float u_opacity;\nuniform sampler2D u_texture;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_texture, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n gl_FragColor.a = texColor.a * u_opacity;\n}\n';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.defaultmapshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;uniform float f;uniform sampler2D g;void main(void){vec4 texColor=texture2D(g,a);gl_FragColor.rgb=texColor.rgb;gl_FragColor.a=texColor.a*f;}';
|
ol.renderer.webgl.defaultmapshader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;uniform float f;uniform sampler2D g;void main(void){vec4 texColor=texture2D(g,a);gl_FragColor.rgb=texColor.rgb;gl_FragColor.a=texColor.a*f;}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.defaultmapshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
ol.renderer.webgl.defaultmapshader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
ol.renderer.webgl.defaultmapshader.Fragment.DEBUG_SOURCE :
|
ol.renderer.webgl.defaultmapshader.Fragment.DEBUG_SOURCE :
|
||||||
ol.renderer.webgl.defaultmapshader.Fragment.OPTIMIZED_SOURCE;
|
ol.renderer.webgl.defaultmapshader.Fragment.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
ol.renderer.webgl.defaultmapshader.fragment = new ol.renderer.webgl.defaultmapshader.Fragment();
|
ol.renderer.webgl.defaultmapshader.fragment = new ol.renderer.webgl.defaultmapshader.Fragment();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Vertex}
|
* @extends {ol.webgl.Vertex}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.defaultmapshader.Vertex = function() {
|
ol.renderer.webgl.defaultmapshader.Vertex = function() {
|
||||||
ol.webgl.Vertex.call(this, ol.renderer.webgl.defaultmapshader.Vertex.SOURCE);
|
ol.webgl.Vertex.call(this, ol.renderer.webgl.defaultmapshader.Vertex.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.renderer.webgl.defaultmapshader.Vertex, ol.webgl.Vertex);
|
ol.inherits(ol.renderer.webgl.defaultmapshader.Vertex, ol.webgl.Vertex);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.defaultmapshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\n\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\n\nuniform mat4 u_texCoordMatrix;\nuniform mat4 u_projectionMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.);\n v_texCoord = (u_texCoordMatrix * vec4(a_texCoord, 0., 1.)).st;\n}\n\n\n';
|
ol.renderer.webgl.defaultmapshader.Vertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\n\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\n\nuniform mat4 u_texCoordMatrix;\nuniform mat4 u_projectionMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0., 1.);\n v_texCoord = (u_texCoordMatrix * vec4(a_texCoord, 0., 1.)).st;\n}\n\n\n';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.defaultmapshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;attribute vec2 b;attribute vec2 c;uniform mat4 d;uniform mat4 e;void main(void){gl_Position=e*vec4(b,0.,1.);a=(d*vec4(c,0.,1.)).st;}';
|
ol.renderer.webgl.defaultmapshader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;attribute vec2 b;attribute vec2 c;uniform mat4 d;uniform mat4 e;void main(void){gl_Position=e*vec4(b,0.,1.);a=(d*vec4(c,0.,1.)).st;}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.defaultmapshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
ol.renderer.webgl.defaultmapshader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
ol.renderer.webgl.defaultmapshader.Vertex.DEBUG_SOURCE :
|
ol.renderer.webgl.defaultmapshader.Vertex.DEBUG_SOURCE :
|
||||||
ol.renderer.webgl.defaultmapshader.Vertex.OPTIMIZED_SOURCE;
|
ol.renderer.webgl.defaultmapshader.Vertex.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
ol.renderer.webgl.defaultmapshader.vertex = new ol.renderer.webgl.defaultmapshader.Vertex();
|
ol.renderer.webgl.defaultmapshader.vertex = new ol.renderer.webgl.defaultmapshader.Vertex();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {WebGLRenderingContext} gl GL.
|
* @param {WebGLRenderingContext} gl GL.
|
||||||
* @param {WebGLProgram} program Program.
|
* @param {WebGLProgram} program Program.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.defaultmapshader.Locations = function(gl, program) {
|
ol.renderer.webgl.defaultmapshader.Locations = function(gl, program) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {WebGLUniformLocation}
|
* @type {WebGLUniformLocation}
|
||||||
@@ -125,6 +123,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.a_texCoord = gl.getAttribLocation(
|
this.a_texCoord = gl.getAttribLocation(
|
||||||
program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'c');
|
program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'c');
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,16 +14,14 @@ goog.require('ol.webgl');
|
|||||||
goog.require('ol.webgl.Context');
|
goog.require('ol.webgl.Context');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.renderer.webgl.Layer}
|
* @extends {ol.renderer.webgl.Layer}
|
||||||
* @param {ol.renderer.webgl.Map} mapRenderer Map renderer.
|
* @param {ol.renderer.webgl.Map} mapRenderer Map renderer.
|
||||||
* @param {ol.layer.Image} imageLayer Tile layer.
|
* @param {ol.layer.Image} imageLayer Tile layer.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.ImageLayer = function(mapRenderer, imageLayer) {
|
ol.renderer.webgl.ImageLayer = function(mapRenderer, imageLayer) {
|
||||||
|
|
||||||
ol.renderer.webgl.Layer.call(this, mapRenderer, imageLayer);
|
ol.renderer.webgl.Layer.call(this, mapRenderer, imageLayer);
|
||||||
|
|
||||||
@@ -46,41 +44,41 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.hitTransformationMatrix_ = null;
|
this.hitTransformationMatrix_ = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.renderer.webgl.ImageLayer, ol.renderer.webgl.Layer);
|
ol.inherits(ol.renderer.webgl.ImageLayer, ol.renderer.webgl.Layer);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if this renderer handles the provided layer.
|
* Determine if this renderer handles the provided layer.
|
||||||
* @param {ol.renderer.Type} type The renderer type.
|
* @param {ol.renderer.Type} type The renderer type.
|
||||||
* @param {ol.layer.Layer} layer The candidate layer.
|
* @param {ol.layer.Layer} layer The candidate layer.
|
||||||
* @return {boolean} The renderer can render the layer.
|
* @return {boolean} The renderer can render the layer.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.ImageLayer['handles'] = function(type, layer) {
|
ol.renderer.webgl.ImageLayer['handles'] = function(type, layer) {
|
||||||
return type === ol.renderer.Type.WEBGL && layer.getType() === ol.LayerType.IMAGE;
|
return type === ol.renderer.Type.WEBGL && layer.getType() === ol.LayerType.IMAGE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a layer renderer.
|
* Create a layer renderer.
|
||||||
* @param {ol.renderer.Map} mapRenderer The map renderer.
|
* @param {ol.renderer.Map} mapRenderer The map renderer.
|
||||||
* @param {ol.layer.Layer} layer The layer to be rendererd.
|
* @param {ol.layer.Layer} layer The layer to be rendererd.
|
||||||
* @return {ol.renderer.webgl.ImageLayer} The layer renderer.
|
* @return {ol.renderer.webgl.ImageLayer} The layer renderer.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.ImageLayer['create'] = function(mapRenderer, layer) {
|
ol.renderer.webgl.ImageLayer['create'] = function(mapRenderer, layer) {
|
||||||
return new ol.renderer.webgl.ImageLayer(
|
return new ol.renderer.webgl.ImageLayer(
|
||||||
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
||||||
/** @type {ol.layer.Image} */ (layer)
|
/** @type {ol.layer.Image} */ (layer)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.ImageBase} image Image.
|
* @param {ol.ImageBase} image Image.
|
||||||
* @private
|
* @private
|
||||||
* @return {WebGLTexture} Texture.
|
* @return {WebGLTexture} Texture.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.ImageLayer.prototype.createTexture_ = function(image) {
|
ol.renderer.webgl.ImageLayer.prototype.createTexture_ = function(image) {
|
||||||
|
|
||||||
// We meet the conditions to work with non-power of two textures.
|
// We meet the conditions to work with non-power of two textures.
|
||||||
// http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences#Non-Power_of_Two_Texture_Support
|
// http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences#Non-Power_of_Two_Texture_Support
|
||||||
@@ -91,13 +89,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
|
|
||||||
return ol.webgl.Context.createTexture(
|
return ol.webgl.Context.createTexture(
|
||||||
gl, imageElement, ol.webgl.CLAMP_TO_EDGE, ol.webgl.CLAMP_TO_EDGE);
|
gl, imageElement, ol.webgl.CLAMP_TO_EDGE, ol.webgl.CLAMP_TO_EDGE);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) {
|
ol.renderer.webgl.ImageLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) {
|
||||||
var layer = this.getLayer();
|
var layer = this.getLayer();
|
||||||
var source = layer.getSource();
|
var source = layer.getSource();
|
||||||
var resolution = frameState.viewState.resolution;
|
var resolution = frameState.viewState.resolution;
|
||||||
@@ -113,13 +111,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
function(feature) {
|
function(feature) {
|
||||||
return callback.call(thisArg, feature, layer);
|
return callback.call(thisArg, feature, layer);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.ImageLayer.prototype.prepareFrame = function(frameState, layerState, context) {
|
ol.renderer.webgl.ImageLayer.prototype.prepareFrame = function(frameState, layerState, context) {
|
||||||
|
|
||||||
var gl = this.mapRenderer.getGL();
|
var gl = this.mapRenderer.getGL();
|
||||||
|
|
||||||
@@ -197,10 +195,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return !!image;
|
return !!image;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} canvasWidth Canvas width.
|
* @param {number} canvasWidth Canvas width.
|
||||||
* @param {number} canvasHeight Canvas height.
|
* @param {number} canvasHeight Canvas height.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
@@ -210,7 +208,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.Extent} imageExtent Image extent.
|
* @param {ol.Extent} imageExtent Image extent.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ = function(canvasWidth, canvasHeight, pixelRatio,
|
ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ = function(canvasWidth, canvasHeight, pixelRatio,
|
||||||
viewCenter, viewResolution, viewRotation, imageExtent) {
|
viewCenter, viewResolution, viewRotation, imageExtent) {
|
||||||
|
|
||||||
var canvasExtentWidth = canvasWidth * viewResolution;
|
var canvasExtentWidth = canvasWidth * viewResolution;
|
||||||
@@ -230,23 +228,23 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
(imageExtent[3] - imageExtent[1]) / 2);
|
(imageExtent[3] - imageExtent[1]) / 2);
|
||||||
ol.transform.translate(projectionMatrix, 1, 1);
|
ol.transform.translate(projectionMatrix, 1, 1);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.ImageLayer.prototype.hasFeatureAtCoordinate = function(coordinate, frameState) {
|
ol.renderer.webgl.ImageLayer.prototype.hasFeatureAtCoordinate = function(coordinate, frameState) {
|
||||||
var hasFeature = this.forEachFeatureAtCoordinate(
|
var hasFeature = this.forEachFeatureAtCoordinate(
|
||||||
coordinate, frameState, 0, ol.functions.TRUE, this);
|
coordinate, frameState, 0, ol.functions.TRUE, this);
|
||||||
return hasFeature !== undefined;
|
return hasFeature !== undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {
|
ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {
|
||||||
if (!this.image_ || !this.image_.getImage()) {
|
if (!this.image_ || !this.image_.getImage()) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -297,10 +295,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The transformation matrix to get the pixel on the image for a
|
* The transformation matrix to get the pixel on the image for a
|
||||||
* pixel on the map.
|
* pixel on the map.
|
||||||
* @param {ol.Size} mapSize The map size.
|
* @param {ol.Size} mapSize The map size.
|
||||||
@@ -308,7 +306,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {ol.Transform} The transformation matrix.
|
* @return {ol.Transform} The transformation matrix.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.ImageLayer.prototype.getHitTransformationMatrix_ = function(mapSize, imageSize) {
|
ol.renderer.webgl.ImageLayer.prototype.getHitTransformationMatrix_ = function(mapSize, imageSize) {
|
||||||
// the first matrix takes a map pixel, flips the y-axis and scales to
|
// the first matrix takes a map pixel, flips the y-axis and scales to
|
||||||
// a range between -1 ... 1
|
// a range between -1 ... 1
|
||||||
var mapCoordTransform = ol.transform.create();
|
var mapCoordTransform = ol.transform.create();
|
||||||
@@ -332,6 +330,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
ol.transform.multiply(transform, mapCoordTransform);
|
ol.transform.multiply(transform, mapCoordTransform);
|
||||||
|
|
||||||
return transform;
|
return transform;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,16 +13,14 @@ goog.require('ol.webgl.Buffer');
|
|||||||
goog.require('ol.webgl.Context');
|
goog.require('ol.webgl.Context');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @abstract
|
* @abstract
|
||||||
* @extends {ol.renderer.Layer}
|
* @extends {ol.renderer.Layer}
|
||||||
* @param {ol.renderer.webgl.Map} mapRenderer Map renderer.
|
* @param {ol.renderer.webgl.Map} mapRenderer Map renderer.
|
||||||
* @param {ol.layer.Layer} layer Layer.
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer = function(mapRenderer, layer) {
|
ol.renderer.webgl.Layer = function(mapRenderer, layer) {
|
||||||
|
|
||||||
ol.renderer.Layer.call(this, layer);
|
ol.renderer.Layer.call(this, layer);
|
||||||
|
|
||||||
@@ -85,16 +83,16 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.defaultLocations_ = null;
|
this.defaultLocations_ = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.renderer.webgl.Layer, ol.renderer.Layer);
|
ol.inherits(ol.renderer.webgl.Layer, ol.renderer.Layer);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @param {number} framebufferDimension Framebuffer dimension.
|
* @param {number} framebufferDimension Framebuffer dimension.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.bindFramebuffer = function(frameState, framebufferDimension) {
|
ol.renderer.webgl.Layer.prototype.bindFramebuffer = function(frameState, framebufferDimension) {
|
||||||
|
|
||||||
var gl = this.mapRenderer.getGL();
|
var gl = this.mapRenderer.getGL();
|
||||||
|
|
||||||
@@ -132,15 +130,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
gl.bindFramebuffer(ol.webgl.FRAMEBUFFER, this.framebuffer);
|
gl.bindFramebuffer(ol.webgl.FRAMEBUFFER, this.framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @param {ol.LayerState} layerState Layer state.
|
* @param {ol.LayerState} layerState Layer state.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.composeFrame = function(frameState, layerState, context) {
|
ol.renderer.webgl.Layer.prototype.composeFrame = function(frameState, layerState, context) {
|
||||||
|
|
||||||
this.dispatchComposeEvent_(
|
this.dispatchComposeEvent_(
|
||||||
ol.render.EventType.PRECOMPOSE, context, frameState);
|
ol.render.EventType.PRECOMPOSE, context, frameState);
|
||||||
@@ -184,16 +182,16 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.dispatchComposeEvent_(
|
this.dispatchComposeEvent_(
|
||||||
ol.render.EventType.POSTCOMPOSE, context, frameState);
|
ol.render.EventType.POSTCOMPOSE, context, frameState);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.render.EventType} type Event type.
|
* @param {ol.render.EventType} type Event type.
|
||||||
* @param {ol.webgl.Context} context WebGL context.
|
* @param {ol.webgl.Context} context WebGL context.
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.dispatchComposeEvent_ = function(type, context, frameState) {
|
ol.renderer.webgl.Layer.prototype.dispatchComposeEvent_ = function(type, context, frameState) {
|
||||||
var layer = this.getLayer();
|
var layer = this.getLayer();
|
||||||
if (layer.hasListener(type)) {
|
if (layer.hasListener(type)) {
|
||||||
var viewState = frameState.viewState;
|
var viewState = frameState.viewState;
|
||||||
@@ -210,54 +208,54 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
type, render, frameState, null, context);
|
type, render, frameState, null, context);
|
||||||
layer.dispatchEvent(composeEvent);
|
layer.dispatchEvent(composeEvent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {!ol.Transform} Matrix.
|
* @return {!ol.Transform} Matrix.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.getTexCoordMatrix = function() {
|
ol.renderer.webgl.Layer.prototype.getTexCoordMatrix = function() {
|
||||||
return this.texCoordMatrix;
|
return this.texCoordMatrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {WebGLTexture} Texture.
|
* @return {WebGLTexture} Texture.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.getTexture = function() {
|
ol.renderer.webgl.Layer.prototype.getTexture = function() {
|
||||||
return this.texture;
|
return this.texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {!ol.Transform} Matrix.
|
* @return {!ol.Transform} Matrix.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.getProjectionMatrix = function() {
|
ol.renderer.webgl.Layer.prototype.getProjectionMatrix = function() {
|
||||||
return this.projectionMatrix;
|
return this.projectionMatrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle webglcontextlost.
|
* Handle webglcontextlost.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.handleWebGLContextLost = function() {
|
ol.renderer.webgl.Layer.prototype.handleWebGLContextLost = function() {
|
||||||
this.texture = null;
|
this.texture = null;
|
||||||
this.framebuffer = null;
|
this.framebuffer = null;
|
||||||
this.framebufferDimension = undefined;
|
this.framebufferDimension = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @param {ol.LayerState} layerState Layer state.
|
* @param {ol.LayerState} layerState Layer state.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
* @return {boolean} whether composeFrame should be called.
|
* @return {boolean} whether composeFrame should be called.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.prepareFrame = function(frameState, layerState, context) {};
|
ol.renderer.webgl.Layer.prototype.prepareFrame = function(frameState, layerState, context) {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @param {ol.Pixel} pixel Pixel.
|
* @param {ol.Pixel} pixel Pixel.
|
||||||
* @param {olx.FrameState} frameState FrameState.
|
* @param {olx.FrameState} frameState FrameState.
|
||||||
@@ -267,6 +265,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @return {T|undefined} Callback result.
|
* @return {T|undefined} Callback result.
|
||||||
* @template S,T,U
|
* @template S,T,U
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {};
|
ol.renderer.webgl.Layer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -22,16 +22,14 @@ goog.require('ol.webgl.Context');
|
|||||||
goog.require('ol.webgl.ContextEventType');
|
goog.require('ol.webgl.ContextEventType');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.renderer.Map}
|
* @extends {ol.renderer.Map}
|
||||||
* @param {Element} container Container.
|
* @param {Element} container Container.
|
||||||
* @param {ol.PluggableMap} map Map.
|
* @param {ol.PluggableMap} map Map.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map = function(container, map) {
|
ol.renderer.webgl.Map = function(container, map) {
|
||||||
ol.renderer.Map.call(this, container, map);
|
ol.renderer.Map.call(this, container, map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,39 +158,39 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.textureCacheFrameMarkerCount_ = 0;
|
this.textureCacheFrameMarkerCount_ = 0;
|
||||||
|
|
||||||
this.initializeGL_();
|
this.initializeGL_();
|
||||||
};
|
};
|
||||||
ol.inherits(ol.renderer.webgl.Map, ol.renderer.Map);
|
ol.inherits(ol.renderer.webgl.Map, ol.renderer.Map);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if this renderer handles the provided layer.
|
* Determine if this renderer handles the provided layer.
|
||||||
* @param {ol.renderer.Type} type The renderer type.
|
* @param {ol.renderer.Type} type The renderer type.
|
||||||
* @return {boolean} The renderer can render the layer.
|
* @return {boolean} The renderer can render the layer.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map['handles'] = function(type) {
|
ol.renderer.webgl.Map['handles'] = function(type) {
|
||||||
return ol.has.WEBGL && type === ol.renderer.Type.WEBGL;
|
return ol.has.WEBGL && type === ol.renderer.Type.WEBGL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the map renderer.
|
* Create the map renderer.
|
||||||
* @param {Element} container Container.
|
* @param {Element} container Container.
|
||||||
* @param {ol.PluggableMap} map Map.
|
* @param {ol.PluggableMap} map Map.
|
||||||
* @return {ol.renderer.webgl.Map} The map renderer.
|
* @return {ol.renderer.webgl.Map} The map renderer.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map['create'] = function(container, map) {
|
ol.renderer.webgl.Map['create'] = function(container, map) {
|
||||||
return new ol.renderer.webgl.Map(container, map);
|
return new ol.renderer.webgl.Map(container, map);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Tile} tile Tile.
|
* @param {ol.Tile} tile Tile.
|
||||||
* @param {ol.Size} tileSize Tile size.
|
* @param {ol.Size} tileSize Tile size.
|
||||||
* @param {number} tileGutter Tile gutter.
|
* @param {number} tileGutter Tile gutter.
|
||||||
* @param {number} magFilter Mag filter.
|
* @param {number} magFilter Mag filter.
|
||||||
* @param {number} minFilter Min filter.
|
* @param {number} minFilter Min filter.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.bindTileTexture = function(tile, tileSize, tileGutter, magFilter, minFilter) {
|
ol.renderer.webgl.Map.prototype.bindTileTexture = function(tile, tileSize, tileGutter, magFilter, minFilter) {
|
||||||
var gl = this.getGL();
|
var gl = this.getGL();
|
||||||
var tileKey = tile.getKey();
|
var tileKey = tile.getKey();
|
||||||
if (this.textureCache_.containsKey(tileKey)) {
|
if (this.textureCache_.containsKey(tileKey)) {
|
||||||
@@ -247,15 +245,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
minFilter: minFilter
|
minFilter: minFilter
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.render.EventType} type Event type.
|
* @param {ol.render.EventType} type Event type.
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.dispatchComposeEvent_ = function(type, frameState) {
|
ol.renderer.webgl.Map.prototype.dispatchComposeEvent_ = function(type, frameState) {
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
if (map.hasListener(type)) {
|
if (map.hasListener(type)) {
|
||||||
var context = this.context_;
|
var context = this.context_;
|
||||||
@@ -275,13 +273,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
frameState, null, context);
|
frameState, null, context);
|
||||||
map.dispatchEvent(composeEvent);
|
map.dispatchEvent(composeEvent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.disposeInternal = function() {
|
ol.renderer.webgl.Map.prototype.disposeInternal = function() {
|
||||||
var gl = this.getGL();
|
var gl = this.getGL();
|
||||||
if (!gl.isContextLost()) {
|
if (!gl.isContextLost()) {
|
||||||
this.textureCache_.forEach(
|
this.textureCache_.forEach(
|
||||||
@@ -297,15 +295,15 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
this.context_.dispose();
|
this.context_.dispose();
|
||||||
ol.renderer.Map.prototype.disposeInternal.call(this);
|
ol.renderer.Map.prototype.disposeInternal.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.PluggableMap} map Map.
|
* @param {ol.PluggableMap} map Map.
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.expireCache_ = function(map, frameState) {
|
ol.renderer.webgl.Map.prototype.expireCache_ = function(map, frameState) {
|
||||||
var gl = this.getGL();
|
var gl = this.getGL();
|
||||||
var textureCacheEntry;
|
var textureCacheEntry;
|
||||||
while (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ >
|
while (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ >
|
||||||
@@ -322,46 +320,46 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
this.textureCache_.pop();
|
this.textureCache_.pop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.webgl.Context} The context.
|
* @return {ol.webgl.Context} The context.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.getContext = function() {
|
ol.renderer.webgl.Map.prototype.getContext = function() {
|
||||||
return this.context_;
|
return this.context_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {WebGLRenderingContext} GL.
|
* @return {WebGLRenderingContext} GL.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.getGL = function() {
|
ol.renderer.webgl.Map.prototype.getGL = function() {
|
||||||
return this.gl_;
|
return this.gl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.structs.PriorityQueue.<Array>} Tile texture queue.
|
* @return {ol.structs.PriorityQueue.<Array>} Tile texture queue.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.getTileTextureQueue = function() {
|
ol.renderer.webgl.Map.prototype.getTileTextureQueue = function() {
|
||||||
return this.tileTextureQueue_;
|
return this.tileTextureQueue_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.getType = function() {
|
ol.renderer.webgl.Map.prototype.getType = function() {
|
||||||
return ol.renderer.Type.WEBGL;
|
return ol.renderer.Type.WEBGL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.events.Event} event Event.
|
* @param {ol.events.Event} event Event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.handleWebGLContextLost = function(event) {
|
ol.renderer.webgl.Map.prototype.handleWebGLContextLost = function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.textureCache_.clear();
|
this.textureCache_.clear();
|
||||||
this.textureCacheFrameMarkerCount_ = 0;
|
this.textureCacheFrameMarkerCount_ = 0;
|
||||||
@@ -371,22 +369,22 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
var renderer = /** @type {ol.renderer.webgl.Layer} */ (renderers[id]);
|
var renderer = /** @type {ol.renderer.webgl.Layer} */ (renderers[id]);
|
||||||
renderer.handleWebGLContextLost();
|
renderer.handleWebGLContextLost();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.handleWebGLContextRestored = function() {
|
ol.renderer.webgl.Map.prototype.handleWebGLContextRestored = function() {
|
||||||
this.initializeGL_();
|
this.initializeGL_();
|
||||||
this.getMap().render();
|
this.getMap().render();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.initializeGL_ = function() {
|
ol.renderer.webgl.Map.prototype.initializeGL_ = function() {
|
||||||
var gl = this.gl_;
|
var gl = this.gl_;
|
||||||
gl.activeTexture(ol.webgl.TEXTURE0);
|
gl.activeTexture(ol.webgl.TEXTURE0);
|
||||||
gl.blendFuncSeparate(
|
gl.blendFuncSeparate(
|
||||||
@@ -396,22 +394,22 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
gl.disable(ol.webgl.DEPTH_TEST);
|
gl.disable(ol.webgl.DEPTH_TEST);
|
||||||
gl.disable(ol.webgl.SCISSOR_TEST);
|
gl.disable(ol.webgl.SCISSOR_TEST);
|
||||||
gl.disable(ol.webgl.STENCIL_TEST);
|
gl.disable(ol.webgl.STENCIL_TEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Tile} tile Tile.
|
* @param {ol.Tile} tile Tile.
|
||||||
* @return {boolean} Is tile texture loaded.
|
* @return {boolean} Is tile texture loaded.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.isTileTextureLoaded = function(tile) {
|
ol.renderer.webgl.Map.prototype.isTileTextureLoaded = function(tile) {
|
||||||
return this.textureCache_.containsKey(tile.getKey());
|
return this.textureCache_.containsKey(tile.getKey());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
||||||
|
|
||||||
var context = this.getContext();
|
var context = this.getContext();
|
||||||
var gl = this.getGL();
|
var gl = this.getGL();
|
||||||
@@ -497,13 +495,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.scheduleRemoveUnusedLayerRenderers(frameState);
|
this.scheduleRemoveUnusedLayerRenderers(frameState);
|
||||||
this.scheduleExpireIconCache(frameState);
|
this.scheduleExpireIconCache(frameState);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg,
|
ol.renderer.webgl.Map.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg,
|
||||||
layerFilter, thisArg2) {
|
layerFilter, thisArg2) {
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
@@ -530,13 +528,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, layerFilter, thisArg) {
|
ol.renderer.webgl.Map.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, layerFilter, thisArg) {
|
||||||
var hasFeature = false;
|
var hasFeature = false;
|
||||||
|
|
||||||
if (this.getGL().isContextLost()) {
|
if (this.getGL().isContextLost()) {
|
||||||
@@ -562,13 +560,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hasFeature;
|
return hasFeature;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Map.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg,
|
ol.renderer.webgl.Map.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg,
|
||||||
layerFilter, thisArg2) {
|
layerFilter, thisArg2) {
|
||||||
if (this.getGL().isContextLost()) {
|
if (this.getGL().isContextLost()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -594,6 +592,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,16 +19,14 @@ goog.require('ol.webgl');
|
|||||||
goog.require('ol.webgl.Buffer');
|
goog.require('ol.webgl.Buffer');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.renderer.webgl.Layer}
|
* @extends {ol.renderer.webgl.Layer}
|
||||||
* @param {ol.renderer.webgl.Map} mapRenderer Map renderer.
|
* @param {ol.renderer.webgl.Map} mapRenderer Map renderer.
|
||||||
* @param {ol.layer.Tile} tileLayer Tile layer.
|
* @param {ol.layer.Tile} tileLayer Tile layer.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.TileLayer = function(mapRenderer, tileLayer) {
|
ol.renderer.webgl.TileLayer = function(mapRenderer, tileLayer) {
|
||||||
|
|
||||||
ol.renderer.webgl.Layer.call(this, mapRenderer, tileLayer);
|
ol.renderer.webgl.Layer.call(this, mapRenderer, tileLayer);
|
||||||
|
|
||||||
@@ -85,49 +83,49 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.tmpSize_ = [0, 0];
|
this.tmpSize_ = [0, 0];
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.renderer.webgl.TileLayer, ol.renderer.webgl.Layer);
|
ol.inherits(ol.renderer.webgl.TileLayer, ol.renderer.webgl.Layer);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if this renderer handles the provided layer.
|
* Determine if this renderer handles the provided layer.
|
||||||
* @param {ol.renderer.Type} type The renderer type.
|
* @param {ol.renderer.Type} type The renderer type.
|
||||||
* @param {ol.layer.Layer} layer The candidate layer.
|
* @param {ol.layer.Layer} layer The candidate layer.
|
||||||
* @return {boolean} The renderer can render the layer.
|
* @return {boolean} The renderer can render the layer.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.TileLayer['handles'] = function(type, layer) {
|
ol.renderer.webgl.TileLayer['handles'] = function(type, layer) {
|
||||||
return type === ol.renderer.Type.WEBGL && layer.getType() === ol.LayerType.TILE;
|
return type === ol.renderer.Type.WEBGL && layer.getType() === ol.LayerType.TILE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a layer renderer.
|
* Create a layer renderer.
|
||||||
* @param {ol.renderer.Map} mapRenderer The map renderer.
|
* @param {ol.renderer.Map} mapRenderer The map renderer.
|
||||||
* @param {ol.layer.Layer} layer The layer to be rendererd.
|
* @param {ol.layer.Layer} layer The layer to be rendererd.
|
||||||
* @return {ol.renderer.webgl.TileLayer} The layer renderer.
|
* @return {ol.renderer.webgl.TileLayer} The layer renderer.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.TileLayer['create'] = function(mapRenderer, layer) {
|
ol.renderer.webgl.TileLayer['create'] = function(mapRenderer, layer) {
|
||||||
return new ol.renderer.webgl.TileLayer(
|
return new ol.renderer.webgl.TileLayer(
|
||||||
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
||||||
/** @type {ol.layer.Tile} */ (layer)
|
/** @type {ol.layer.Tile} */ (layer)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.TileLayer.prototype.disposeInternal = function() {
|
ol.renderer.webgl.TileLayer.prototype.disposeInternal = function() {
|
||||||
var context = this.mapRenderer.getContext();
|
var context = this.mapRenderer.getContext();
|
||||||
context.deleteBuffer(this.renderArrayBuffer_);
|
context.deleteBuffer(this.renderArrayBuffer_);
|
||||||
ol.renderer.webgl.Layer.prototype.disposeInternal.call(this);
|
ol.renderer.webgl.Layer.prototype.disposeInternal.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.TileLayer.prototype.createLoadedTileFinder = function(source, projection, tiles) {
|
ol.renderer.webgl.TileLayer.prototype.createLoadedTileFinder = function(source, projection, tiles) {
|
||||||
var mapRenderer = this.mapRenderer;
|
var mapRenderer = this.mapRenderer;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -149,22 +147,22 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
return source.forEachLoadedTile(projection, zoom, tileRange, callback);
|
return source.forEachLoadedTile(projection, zoom, tileRange, callback);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.TileLayer.prototype.handleWebGLContextLost = function() {
|
ol.renderer.webgl.TileLayer.prototype.handleWebGLContextLost = function() {
|
||||||
ol.renderer.webgl.Layer.prototype.handleWebGLContextLost.call(this);
|
ol.renderer.webgl.Layer.prototype.handleWebGLContextLost.call(this);
|
||||||
this.locations_ = null;
|
this.locations_ = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerState, context) {
|
ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerState, context) {
|
||||||
|
|
||||||
var mapRenderer = this.mapRenderer;
|
var mapRenderer = this.mapRenderer;
|
||||||
var gl = context.getGL();
|
var gl = context.getGL();
|
||||||
@@ -376,13 +374,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
ol.transform.translate(texCoordMatrix, -0.5, -0.5);
|
ol.transform.translate(texCoordMatrix, -0.5, -0.5);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.TileLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {
|
ol.renderer.webgl.TileLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {
|
||||||
if (!this.framebuffer) {
|
if (!this.framebuffer) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -408,6 +406,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,89 +6,87 @@ goog.require('ol');
|
|||||||
goog.require('ol.webgl.Fragment');
|
goog.require('ol.webgl.Fragment');
|
||||||
goog.require('ol.webgl.Vertex');
|
goog.require('ol.webgl.Vertex');
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Fragment}
|
* @extends {ol.webgl.Fragment}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.tilelayershader.Fragment = function() {
|
ol.renderer.webgl.tilelayershader.Fragment = function() {
|
||||||
ol.webgl.Fragment.call(this, ol.renderer.webgl.tilelayershader.Fragment.SOURCE);
|
ol.webgl.Fragment.call(this, ol.renderer.webgl.tilelayershader.Fragment.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.renderer.webgl.tilelayershader.Fragment, ol.webgl.Fragment);
|
ol.inherits(ol.renderer.webgl.tilelayershader.Fragment, ol.webgl.Fragment);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.tilelayershader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_texCoord;\n\n\nuniform sampler2D u_texture;\n\nvoid main(void) {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n}\n';
|
ol.renderer.webgl.tilelayershader.Fragment.DEBUG_SOURCE = 'precision mediump float;\nvarying vec2 v_texCoord;\n\n\nuniform sampler2D u_texture;\n\nvoid main(void) {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n}\n';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.tilelayershader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;uniform sampler2D e;void main(void){gl_FragColor=texture2D(e,a);}';
|
ol.renderer.webgl.tilelayershader.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;varying vec2 a;uniform sampler2D e;void main(void){gl_FragColor=texture2D(e,a);}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.tilelayershader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
ol.renderer.webgl.tilelayershader.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
ol.renderer.webgl.tilelayershader.Fragment.DEBUG_SOURCE :
|
ol.renderer.webgl.tilelayershader.Fragment.DEBUG_SOURCE :
|
||||||
ol.renderer.webgl.tilelayershader.Fragment.OPTIMIZED_SOURCE;
|
ol.renderer.webgl.tilelayershader.Fragment.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
ol.renderer.webgl.tilelayershader.fragment = new ol.renderer.webgl.tilelayershader.Fragment();
|
ol.renderer.webgl.tilelayershader.fragment = new ol.renderer.webgl.tilelayershader.Fragment();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Vertex}
|
* @extends {ol.webgl.Vertex}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.tilelayershader.Vertex = function() {
|
ol.renderer.webgl.tilelayershader.Vertex = function() {
|
||||||
ol.webgl.Vertex.call(this, ol.renderer.webgl.tilelayershader.Vertex.SOURCE);
|
ol.webgl.Vertex.call(this, ol.renderer.webgl.tilelayershader.Vertex.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.renderer.webgl.tilelayershader.Vertex, ol.webgl.Vertex);
|
ol.inherits(ol.renderer.webgl.tilelayershader.Vertex, ol.webgl.Vertex);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.tilelayershader.Vertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\n\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nuniform vec4 u_tileOffset;\n\nvoid main(void) {\n gl_Position = vec4(a_position * u_tileOffset.xy + u_tileOffset.zw, 0., 1.);\n v_texCoord = a_texCoord;\n}\n\n\n';
|
ol.renderer.webgl.tilelayershader.Vertex.DEBUG_SOURCE = 'varying vec2 v_texCoord;\n\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nuniform vec4 u_tileOffset;\n\nvoid main(void) {\n gl_Position = vec4(a_position * u_tileOffset.xy + u_tileOffset.zw, 0., 1.);\n v_texCoord = a_texCoord;\n}\n\n\n';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.tilelayershader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;attribute vec2 b;attribute vec2 c;uniform vec4 d;void main(void){gl_Position=vec4(b*d.xy+d.zw,0.,1.);a=c;}';
|
ol.renderer.webgl.tilelayershader.Vertex.OPTIMIZED_SOURCE = 'varying vec2 a;attribute vec2 b;attribute vec2 c;uniform vec4 d;void main(void){gl_Position=vec4(b*d.xy+d.zw,0.,1.);a=c;}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.tilelayershader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
ol.renderer.webgl.tilelayershader.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
ol.renderer.webgl.tilelayershader.Vertex.DEBUG_SOURCE :
|
ol.renderer.webgl.tilelayershader.Vertex.DEBUG_SOURCE :
|
||||||
ol.renderer.webgl.tilelayershader.Vertex.OPTIMIZED_SOURCE;
|
ol.renderer.webgl.tilelayershader.Vertex.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
ol.renderer.webgl.tilelayershader.vertex = new ol.renderer.webgl.tilelayershader.Vertex();
|
ol.renderer.webgl.tilelayershader.vertex = new ol.renderer.webgl.tilelayershader.Vertex();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {WebGLRenderingContext} gl GL.
|
* @param {WebGLRenderingContext} gl GL.
|
||||||
* @param {WebGLProgram} program Program.
|
* @param {WebGLProgram} program Program.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.tilelayershader.Locations = function(gl, program) {
|
ol.renderer.webgl.tilelayershader.Locations = function(gl, program) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {WebGLUniformLocation}
|
* @type {WebGLUniformLocation}
|
||||||
@@ -113,6 +111,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.a_texCoord = gl.getAttribLocation(
|
this.a_texCoord = gl.getAttribLocation(
|
||||||
program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'c');
|
program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'c');
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,16 +11,14 @@ goog.require('ol.renderer.webgl.Layer');
|
|||||||
goog.require('ol.transform');
|
goog.require('ol.transform');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.renderer.webgl.Layer}
|
* @extends {ol.renderer.webgl.Layer}
|
||||||
* @param {ol.renderer.webgl.Map} mapRenderer Map renderer.
|
* @param {ol.renderer.webgl.Map} mapRenderer Map renderer.
|
||||||
* @param {ol.layer.Vector} vectorLayer Vector layer.
|
* @param {ol.layer.Vector} vectorLayer Vector layer.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer = function(mapRenderer, vectorLayer) {
|
ol.renderer.webgl.VectorLayer = function(mapRenderer, vectorLayer) {
|
||||||
|
|
||||||
ol.renderer.webgl.Layer.call(this, mapRenderer, vectorLayer);
|
ol.renderer.webgl.Layer.call(this, mapRenderer, vectorLayer);
|
||||||
|
|
||||||
@@ -67,39 +65,39 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.layerState_ = null;
|
this.layerState_ = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.renderer.webgl.VectorLayer, ol.renderer.webgl.Layer);
|
ol.inherits(ol.renderer.webgl.VectorLayer, ol.renderer.webgl.Layer);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if this renderer handles the provided layer.
|
* Determine if this renderer handles the provided layer.
|
||||||
* @param {ol.renderer.Type} type The renderer type.
|
* @param {ol.renderer.Type} type The renderer type.
|
||||||
* @param {ol.layer.Layer} layer The candidate layer.
|
* @param {ol.layer.Layer} layer The candidate layer.
|
||||||
* @return {boolean} The renderer can render the layer.
|
* @return {boolean} The renderer can render the layer.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer['handles'] = function(type, layer) {
|
ol.renderer.webgl.VectorLayer['handles'] = function(type, layer) {
|
||||||
return type === ol.renderer.Type.WEBGL && layer.getType() === ol.LayerType.VECTOR;
|
return type === ol.renderer.Type.WEBGL && layer.getType() === ol.LayerType.VECTOR;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a layer renderer.
|
* Create a layer renderer.
|
||||||
* @param {ol.renderer.Map} mapRenderer The map renderer.
|
* @param {ol.renderer.Map} mapRenderer The map renderer.
|
||||||
* @param {ol.layer.Layer} layer The layer to be rendererd.
|
* @param {ol.layer.Layer} layer The layer to be rendererd.
|
||||||
* @return {ol.renderer.webgl.VectorLayer} The layer renderer.
|
* @return {ol.renderer.webgl.VectorLayer} The layer renderer.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer['create'] = function(mapRenderer, layer) {
|
ol.renderer.webgl.VectorLayer['create'] = function(mapRenderer, layer) {
|
||||||
return new ol.renderer.webgl.VectorLayer(
|
return new ol.renderer.webgl.VectorLayer(
|
||||||
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
||||||
/** @type {ol.layer.Vector} */ (layer)
|
/** @type {ol.layer.Vector} */ (layer)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer.prototype.composeFrame = function(frameState, layerState, context) {
|
ol.renderer.webgl.VectorLayer.prototype.composeFrame = function(frameState, layerState, context) {
|
||||||
this.layerState_ = layerState;
|
this.layerState_ = layerState;
|
||||||
var viewState = frameState.viewState;
|
var viewState = frameState.viewState;
|
||||||
var replayGroup = this.replayGroup_;
|
var replayGroup = this.replayGroup_;
|
||||||
@@ -116,13 +114,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
gl.disable(gl.SCISSOR_TEST);
|
gl.disable(gl.SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer.prototype.disposeInternal = function() {
|
ol.renderer.webgl.VectorLayer.prototype.disposeInternal = function() {
|
||||||
var replayGroup = this.replayGroup_;
|
var replayGroup = this.replayGroup_;
|
||||||
if (replayGroup) {
|
if (replayGroup) {
|
||||||
var context = this.mapRenderer.getContext();
|
var context = this.mapRenderer.getContext();
|
||||||
@@ -130,13 +128,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.replayGroup_ = null;
|
this.replayGroup_ = null;
|
||||||
}
|
}
|
||||||
ol.renderer.webgl.Layer.prototype.disposeInternal.call(this);
|
ol.renderer.webgl.Layer.prototype.disposeInternal.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) {
|
ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) {
|
||||||
if (!this.replayGroup_ || !this.layerState_) {
|
if (!this.replayGroup_ || !this.layerState_) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
@@ -162,13 +160,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtCoordinate = function(coordinate, frameState) {
|
ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtCoordinate = function(coordinate, frameState) {
|
||||||
if (!this.replayGroup_ || !this.layerState_) {
|
if (!this.replayGroup_ || !this.layerState_) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -180,13 +178,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
frameState.size, frameState.pixelRatio, layerState.opacity,
|
frameState.size, frameState.pixelRatio, layerState.opacity,
|
||||||
frameState.skippedFeatureUids);
|
frameState.skippedFeatureUids);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {
|
ol.renderer.webgl.VectorLayer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {
|
||||||
var coordinate = ol.transform.apply(
|
var coordinate = ol.transform.apply(
|
||||||
frameState.pixelToCoordinateTransform, pixel.slice());
|
frameState.pixelToCoordinateTransform, pixel.slice());
|
||||||
var hasFeature = this.hasFeatureAtCoordinate(coordinate, frameState);
|
var hasFeature = this.hasFeatureAtCoordinate(coordinate, frameState);
|
||||||
@@ -196,23 +194,23 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle changes in image style state.
|
* Handle changes in image style state.
|
||||||
* @param {ol.events.Event} event Image style change event.
|
* @param {ol.events.Event} event Image style change event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer.prototype.handleStyleImageChange_ = function(event) {
|
ol.renderer.webgl.VectorLayer.prototype.handleStyleImageChange_ = function(event) {
|
||||||
this.renderIfReadyAndVisible();
|
this.renderIfReadyAndVisible();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer.prototype.prepareFrame = function(frameState, layerState, context) {
|
ol.renderer.webgl.VectorLayer.prototype.prepareFrame = function(frameState, layerState, context) {
|
||||||
|
|
||||||
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
||||||
var vectorSource = vectorLayer.getSource();
|
var vectorSource = vectorLayer.getSource();
|
||||||
@@ -311,10 +309,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.replayGroup_ = replayGroup;
|
this.replayGroup_ = replayGroup;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Feature} feature Feature.
|
* @param {ol.Feature} feature Feature.
|
||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
* @param {number} pixelRatio Pixel ratio.
|
* @param {number} pixelRatio Pixel ratio.
|
||||||
@@ -323,7 +321,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.render.webgl.ReplayGroup} replayGroup Replay group.
|
* @param {ol.render.webgl.ReplayGroup} replayGroup Replay group.
|
||||||
* @return {boolean} `true` if an image is loading.
|
* @return {boolean} `true` if an image is loading.
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.VectorLayer.prototype.renderFeature = function(feature, resolution, pixelRatio, styles, replayGroup) {
|
ol.renderer.webgl.VectorLayer.prototype.renderFeature = function(feature, resolution, pixelRatio, styles, replayGroup) {
|
||||||
if (!styles) {
|
if (!styles) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -342,6 +340,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.handleStyleImageChange_, this) || loading;
|
this.handleStyleImageChange_, this) || loading;
|
||||||
}
|
}
|
||||||
return loading;
|
return loading;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
160
src/ol/webgl.js
160
src/ol/webgl.js
@@ -3,280 +3,278 @@ goog.provide('ol.webgl');
|
|||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/** Constants taken from goog.webgl
|
||||||
|
|
||||||
/** Constants taken from goog.webgl
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.ONE = 1;
|
ol.webgl.ONE = 1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.SRC_ALPHA = 0x0302;
|
ol.webgl.SRC_ALPHA = 0x0302;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.COLOR_ATTACHMENT0 = 0x8CE0;
|
ol.webgl.COLOR_ATTACHMENT0 = 0x8CE0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.COLOR_BUFFER_BIT = 0x00004000;
|
ol.webgl.COLOR_BUFFER_BIT = 0x00004000;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.TRIANGLES = 0x0004;
|
ol.webgl.TRIANGLES = 0x0004;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.TRIANGLE_STRIP = 0x0005;
|
ol.webgl.TRIANGLE_STRIP = 0x0005;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.ONE_MINUS_SRC_ALPHA = 0x0303;
|
ol.webgl.ONE_MINUS_SRC_ALPHA = 0x0303;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.ARRAY_BUFFER = 0x8892;
|
ol.webgl.ARRAY_BUFFER = 0x8892;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.ELEMENT_ARRAY_BUFFER = 0x8893;
|
ol.webgl.ELEMENT_ARRAY_BUFFER = 0x8893;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.STREAM_DRAW = 0x88E0;
|
ol.webgl.STREAM_DRAW = 0x88E0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.STATIC_DRAW = 0x88E4;
|
ol.webgl.STATIC_DRAW = 0x88E4;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.DYNAMIC_DRAW = 0x88E8;
|
ol.webgl.DYNAMIC_DRAW = 0x88E8;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.CULL_FACE = 0x0B44;
|
ol.webgl.CULL_FACE = 0x0B44;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.BLEND = 0x0BE2;
|
ol.webgl.BLEND = 0x0BE2;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.STENCIL_TEST = 0x0B90;
|
ol.webgl.STENCIL_TEST = 0x0B90;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.DEPTH_TEST = 0x0B71;
|
ol.webgl.DEPTH_TEST = 0x0B71;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.SCISSOR_TEST = 0x0C11;
|
ol.webgl.SCISSOR_TEST = 0x0C11;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.UNSIGNED_BYTE = 0x1401;
|
ol.webgl.UNSIGNED_BYTE = 0x1401;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.UNSIGNED_SHORT = 0x1403;
|
ol.webgl.UNSIGNED_SHORT = 0x1403;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.UNSIGNED_INT = 0x1405;
|
ol.webgl.UNSIGNED_INT = 0x1405;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.FLOAT = 0x1406;
|
ol.webgl.FLOAT = 0x1406;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.RGBA = 0x1908;
|
ol.webgl.RGBA = 0x1908;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.FRAGMENT_SHADER = 0x8B30;
|
ol.webgl.FRAGMENT_SHADER = 0x8B30;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.VERTEX_SHADER = 0x8B31;
|
ol.webgl.VERTEX_SHADER = 0x8B31;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.LINK_STATUS = 0x8B82;
|
ol.webgl.LINK_STATUS = 0x8B82;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.LINEAR = 0x2601;
|
ol.webgl.LINEAR = 0x2601;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.TEXTURE_MAG_FILTER = 0x2800;
|
ol.webgl.TEXTURE_MAG_FILTER = 0x2800;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.TEXTURE_MIN_FILTER = 0x2801;
|
ol.webgl.TEXTURE_MIN_FILTER = 0x2801;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.TEXTURE_WRAP_S = 0x2802;
|
ol.webgl.TEXTURE_WRAP_S = 0x2802;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.TEXTURE_WRAP_T = 0x2803;
|
ol.webgl.TEXTURE_WRAP_T = 0x2803;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.TEXTURE_2D = 0x0DE1;
|
ol.webgl.TEXTURE_2D = 0x0DE1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.TEXTURE0 = 0x84C0;
|
ol.webgl.TEXTURE0 = 0x84C0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.CLAMP_TO_EDGE = 0x812F;
|
ol.webgl.CLAMP_TO_EDGE = 0x812F;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.COMPILE_STATUS = 0x8B81;
|
ol.webgl.COMPILE_STATUS = 0x8B81;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
ol.webgl.FRAMEBUFFER = 0x8D40;
|
ol.webgl.FRAMEBUFFER = 0x8D40;
|
||||||
|
|
||||||
|
|
||||||
/** end of goog.webgl constants
|
/** end of goog.webgl constants
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @private
|
* @private
|
||||||
* @type {Array.<string>}
|
* @type {Array.<string>}
|
||||||
*/
|
*/
|
||||||
ol.webgl.CONTEXT_IDS_ = [
|
ol.webgl.CONTEXT_IDS_ = [
|
||||||
'experimental-webgl',
|
'experimental-webgl',
|
||||||
'webgl',
|
'webgl',
|
||||||
'webkit-3d',
|
'webkit-3d',
|
||||||
'moz-webgl'
|
'moz-webgl'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {HTMLCanvasElement} canvas Canvas.
|
* @param {HTMLCanvasElement} canvas Canvas.
|
||||||
* @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) {
|
ol.webgl.getContext = function(canvas, opt_attributes) {
|
||||||
var context, i, ii = ol.webgl.CONTEXT_IDS_.length;
|
var context, i, ii = ol.webgl.CONTEXT_IDS_.length;
|
||||||
for (i = 0; i < ii; ++i) {
|
for (i = 0; i < ii; ++i) {
|
||||||
try {
|
try {
|
||||||
@@ -289,6 +287,4 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,15 +4,13 @@ goog.require('ol');
|
|||||||
goog.require('ol.webgl');
|
goog.require('ol.webgl');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {Array.<number>=} opt_arr Array.
|
* @param {Array.<number>=} opt_arr Array.
|
||||||
* @param {number=} opt_usage Usage.
|
* @param {number=} opt_usage Usage.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.webgl.Buffer = function(opt_arr, opt_usage) {
|
ol.webgl.Buffer = function(opt_arr, opt_usage) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -27,33 +25,31 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.usage_ = opt_usage !== undefined ?
|
this.usage_ = opt_usage !== undefined ?
|
||||||
opt_usage : ol.webgl.Buffer.Usage_.STATIC_DRAW;
|
opt_usage : ol.webgl.Buffer.Usage_.STATIC_DRAW;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Array.<number>} Array.
|
* @return {Array.<number>} Array.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Buffer.prototype.getArray = function() {
|
ol.webgl.Buffer.prototype.getArray = function() {
|
||||||
return this.arr_;
|
return this.arr_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number} Usage.
|
* @return {number} Usage.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Buffer.prototype.getUsage = function() {
|
ol.webgl.Buffer.prototype.getUsage = function() {
|
||||||
return this.usage_;
|
return this.usage_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum {number}
|
* @enum {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.webgl.Buffer.Usage_ = {
|
ol.webgl.Buffer.Usage_ = {
|
||||||
STATIC_DRAW: ol.webgl.STATIC_DRAW,
|
STATIC_DRAW: ol.webgl.STATIC_DRAW,
|
||||||
STREAM_DRAW: ol.webgl.STREAM_DRAW,
|
STREAM_DRAW: ol.webgl.STREAM_DRAW,
|
||||||
DYNAMIC_DRAW: ol.webgl.DYNAMIC_DRAW
|
DYNAMIC_DRAW: ol.webgl.DYNAMIC_DRAW
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ goog.require('ol.webgl');
|
|||||||
goog.require('ol.webgl.ContextEventType');
|
goog.require('ol.webgl.ContextEventType');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @classdesc
|
* @classdesc
|
||||||
* A WebGL context for accessing low-level WebGL capabilities.
|
* A WebGL context for accessing low-level WebGL capabilities.
|
||||||
*
|
*
|
||||||
@@ -20,7 +18,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {HTMLCanvasElement} canvas Canvas.
|
* @param {HTMLCanvasElement} canvas Canvas.
|
||||||
* @param {WebGLRenderingContext} gl GL.
|
* @param {WebGLRenderingContext} gl GL.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context = function(canvas, gl) {
|
ol.webgl.Context = function(canvas, gl) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -92,18 +90,18 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
ol.events.listen(this.canvas_, ol.webgl.ContextEventType.RESTORED,
|
ol.events.listen(this.canvas_, ol.webgl.ContextEventType.RESTORED,
|
||||||
this.handleWebGLContextRestored, this);
|
this.handleWebGLContextRestored, this);
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.webgl.Context, ol.Disposable);
|
ol.inherits(ol.webgl.Context, ol.Disposable);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just bind the buffer if it's in the cache. Otherwise create
|
* Just bind the buffer if it's in the cache. Otherwise create
|
||||||
* the WebGL buffer, bind it, populate it, and add an entry to
|
* the WebGL buffer, bind it, populate it, and add an entry to
|
||||||
* the cache.
|
* the cache.
|
||||||
* @param {number} target Target.
|
* @param {number} target Target.
|
||||||
* @param {ol.webgl.Buffer} buf Buffer.
|
* @param {ol.webgl.Buffer} buf Buffer.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.bindBuffer = function(target, buf) {
|
ol.webgl.Context.prototype.bindBuffer = function(target, buf) {
|
||||||
var gl = this.getGL();
|
var gl = this.getGL();
|
||||||
var arr = buf.getArray();
|
var arr = buf.getArray();
|
||||||
var bufferKey = String(ol.getUid(buf));
|
var bufferKey = String(ol.getUid(buf));
|
||||||
@@ -126,13 +124,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
buffer: buffer
|
buffer: buffer
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.webgl.Buffer} buf Buffer.
|
* @param {ol.webgl.Buffer} buf Buffer.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.deleteBuffer = function(buf) {
|
ol.webgl.Context.prototype.deleteBuffer = function(buf) {
|
||||||
var gl = this.getGL();
|
var gl = this.getGL();
|
||||||
var bufferKey = String(ol.getUid(buf));
|
var bufferKey = String(ol.getUid(buf));
|
||||||
var bufferCacheEntry = this.bufferCache_[bufferKey];
|
var bufferCacheEntry = this.bufferCache_[bufferKey];
|
||||||
@@ -140,13 +138,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
gl.deleteBuffer(bufferCacheEntry.buffer);
|
gl.deleteBuffer(bufferCacheEntry.buffer);
|
||||||
}
|
}
|
||||||
delete this.bufferCache_[bufferKey];
|
delete this.bufferCache_[bufferKey];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.disposeInternal = function() {
|
ol.webgl.Context.prototype.disposeInternal = function() {
|
||||||
ol.events.unlistenAll(this.canvas_);
|
ol.events.unlistenAll(this.canvas_);
|
||||||
var gl = this.getGL();
|
var gl = this.getGL();
|
||||||
if (!gl.isContextLost()) {
|
if (!gl.isContextLost()) {
|
||||||
@@ -165,46 +163,46 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
gl.deleteRenderbuffer(this.hitDetectionRenderbuffer_);
|
gl.deleteRenderbuffer(this.hitDetectionRenderbuffer_);
|
||||||
gl.deleteTexture(this.hitDetectionTexture_);
|
gl.deleteTexture(this.hitDetectionTexture_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {HTMLCanvasElement} Canvas.
|
* @return {HTMLCanvasElement} Canvas.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.getCanvas = function() {
|
ol.webgl.Context.prototype.getCanvas = function() {
|
||||||
return this.canvas_;
|
return this.canvas_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the WebGL rendering context
|
* Get the WebGL rendering context
|
||||||
* @return {WebGLRenderingContext} The rendering context.
|
* @return {WebGLRenderingContext} The rendering context.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.getGL = function() {
|
ol.webgl.Context.prototype.getGL = function() {
|
||||||
return this.gl_;
|
return this.gl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the frame buffer for hit detection.
|
* Get the frame buffer for hit detection.
|
||||||
* @return {WebGLFramebuffer} The hit detection frame buffer.
|
* @return {WebGLFramebuffer} The hit detection frame buffer.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.getHitDetectionFramebuffer = function() {
|
ol.webgl.Context.prototype.getHitDetectionFramebuffer = function() {
|
||||||
if (!this.hitDetectionFramebuffer_) {
|
if (!this.hitDetectionFramebuffer_) {
|
||||||
this.initHitDetectionFramebuffer_();
|
this.initHitDetectionFramebuffer_();
|
||||||
}
|
}
|
||||||
return this.hitDetectionFramebuffer_;
|
return this.hitDetectionFramebuffer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get shader from the cache if it's in the cache. Otherwise, create
|
* Get shader from the cache if it's in the cache. Otherwise, create
|
||||||
* the WebGL shader, compile it, and add entry to cache.
|
* the WebGL shader, compile it, and add entry to cache.
|
||||||
* @param {ol.webgl.Shader} shaderObject Shader object.
|
* @param {ol.webgl.Shader} shaderObject Shader object.
|
||||||
* @return {WebGLShader} Shader.
|
* @return {WebGLShader} Shader.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.getShader = function(shaderObject) {
|
ol.webgl.Context.prototype.getShader = function(shaderObject) {
|
||||||
var shaderKey = String(ol.getUid(shaderObject));
|
var shaderKey = String(ol.getUid(shaderObject));
|
||||||
if (shaderKey in this.shaderCache_) {
|
if (shaderKey in this.shaderCache_) {
|
||||||
return this.shaderCache_[shaderKey];
|
return this.shaderCache_[shaderKey];
|
||||||
@@ -216,10 +214,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.shaderCache_[shaderKey] = shader;
|
this.shaderCache_[shaderKey] = shader;
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the program from the cache if it's in the cache. Otherwise create
|
* Get the program from the cache if it's in the cache. Otherwise create
|
||||||
* the WebGL program, attach the shaders to it, and add an entry to the
|
* the WebGL program, attach the shaders to it, and add an entry to the
|
||||||
* cache.
|
* cache.
|
||||||
@@ -227,7 +225,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {ol.webgl.Vertex} vertexShaderObject Vertex shader.
|
* @param {ol.webgl.Vertex} vertexShaderObject Vertex shader.
|
||||||
* @return {WebGLProgram} Program.
|
* @return {WebGLProgram} Program.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.getProgram = function(
|
ol.webgl.Context.prototype.getProgram = function(
|
||||||
fragmentShaderObject, vertexShaderObject) {
|
fragmentShaderObject, vertexShaderObject) {
|
||||||
var programKey =
|
var programKey =
|
||||||
ol.getUid(fragmentShaderObject) + '/' + ol.getUid(vertexShaderObject);
|
ol.getUid(fragmentShaderObject) + '/' + ol.getUid(vertexShaderObject);
|
||||||
@@ -242,13 +240,13 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.programCache_[programKey] = program;
|
this.programCache_[programKey] = program;
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME empy description for jsdoc
|
* FIXME empy description for jsdoc
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.handleWebGLContextLost = function() {
|
ol.webgl.Context.prototype.handleWebGLContextLost = function() {
|
||||||
ol.obj.clear(this.bufferCache_);
|
ol.obj.clear(this.bufferCache_);
|
||||||
ol.obj.clear(this.shaderCache_);
|
ol.obj.clear(this.shaderCache_);
|
||||||
ol.obj.clear(this.programCache_);
|
ol.obj.clear(this.programCache_);
|
||||||
@@ -256,21 +254,21 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.hitDetectionFramebuffer_ = null;
|
this.hitDetectionFramebuffer_ = null;
|
||||||
this.hitDetectionTexture_ = null;
|
this.hitDetectionTexture_ = null;
|
||||||
this.hitDetectionRenderbuffer_ = null;
|
this.hitDetectionRenderbuffer_ = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME empy description for jsdoc
|
* FIXME empy description for jsdoc
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.handleWebGLContextRestored = function() {
|
ol.webgl.Context.prototype.handleWebGLContextRestored = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a 1x1 pixel framebuffer for the hit-detection.
|
* Creates a 1x1 pixel framebuffer for the hit-detection.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.initHitDetectionFramebuffer_ = function() {
|
ol.webgl.Context.prototype.initHitDetectionFramebuffer_ = function() {
|
||||||
var gl = this.gl_;
|
var gl = this.gl_;
|
||||||
var framebuffer = gl.createFramebuffer();
|
var framebuffer = gl.createFramebuffer();
|
||||||
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
||||||
@@ -291,16 +289,16 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.hitDetectionFramebuffer_ = framebuffer;
|
this.hitDetectionFramebuffer_ = framebuffer;
|
||||||
this.hitDetectionTexture_ = texture;
|
this.hitDetectionTexture_ = texture;
|
||||||
this.hitDetectionRenderbuffer_ = renderbuffer;
|
this.hitDetectionRenderbuffer_ = renderbuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use a program. If the program is already in use, this will return `false`.
|
* Use a program. If the program is already in use, this will return `false`.
|
||||||
* @param {WebGLProgram} program Program.
|
* @param {WebGLProgram} program Program.
|
||||||
* @return {boolean} Changed.
|
* @return {boolean} Changed.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.prototype.useProgram = function(program) {
|
ol.webgl.Context.prototype.useProgram = function(program) {
|
||||||
if (program == this.currentProgram_) {
|
if (program == this.currentProgram_) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -309,17 +307,17 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
this.currentProgram_ = program;
|
this.currentProgram_ = program;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {WebGLRenderingContext} gl WebGL rendering context.
|
* @param {WebGLRenderingContext} gl WebGL rendering context.
|
||||||
* @param {number=} opt_wrapS wrapS.
|
* @param {number=} opt_wrapS wrapS.
|
||||||
* @param {number=} opt_wrapT wrapT.
|
* @param {number=} opt_wrapT wrapT.
|
||||||
* @return {WebGLTexture} The texture.
|
* @return {WebGLTexture} The texture.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.createTexture_ = function(gl, opt_wrapS, opt_wrapT) {
|
ol.webgl.Context.createTexture_ = function(gl, opt_wrapS, opt_wrapT) {
|
||||||
var texture = gl.createTexture();
|
var texture = gl.createTexture();
|
||||||
gl.bindTexture(gl.TEXTURE_2D, texture);
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
||||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
||||||
@@ -335,10 +333,10 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {WebGLRenderingContext} gl WebGL rendering context.
|
* @param {WebGLRenderingContext} gl WebGL rendering context.
|
||||||
* @param {number} width Width.
|
* @param {number} width Width.
|
||||||
* @param {number} height Height.
|
* @param {number} height Height.
|
||||||
@@ -346,7 +344,7 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
* @param {number=} opt_wrapT wrapT.
|
* @param {number=} opt_wrapT wrapT.
|
||||||
* @return {WebGLTexture} The texture.
|
* @return {WebGLTexture} The texture.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.createEmptyTexture = function(
|
ol.webgl.Context.createEmptyTexture = function(
|
||||||
gl, width, height, opt_wrapS, opt_wrapT) {
|
gl, width, height, opt_wrapS, opt_wrapT) {
|
||||||
var texture = ol.webgl.Context.createTexture_(gl, opt_wrapS, opt_wrapT);
|
var texture = ol.webgl.Context.createTexture_(gl, opt_wrapS, opt_wrapT);
|
||||||
gl.texImage2D(
|
gl.texImage2D(
|
||||||
@@ -354,22 +352,20 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
null);
|
null);
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {WebGLRenderingContext} gl WebGL rendering context.
|
* @param {WebGLRenderingContext} gl WebGL rendering context.
|
||||||
* @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image.
|
* @param {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} image Image.
|
||||||
* @param {number=} opt_wrapS wrapS.
|
* @param {number=} opt_wrapS wrapS.
|
||||||
* @param {number=} opt_wrapT wrapT.
|
* @param {number=} opt_wrapT wrapT.
|
||||||
* @return {WebGLTexture} The texture.
|
* @return {WebGLTexture} The texture.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Context.createTexture = function(gl, image, opt_wrapS, opt_wrapT) {
|
ol.webgl.Context.createTexture = function(gl, image, opt_wrapS, opt_wrapT) {
|
||||||
var texture = ol.webgl.Context.createTexture_(gl, opt_wrapS, opt_wrapT);
|
var texture = ol.webgl.Context.createTexture_(gl, opt_wrapS, opt_wrapT);
|
||||||
gl.texImage2D(
|
gl.texImage2D(
|
||||||
gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,25 +5,21 @@ goog.require('ol.webgl');
|
|||||||
goog.require('ol.webgl.Shader');
|
goog.require('ol.webgl.Shader');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Shader}
|
* @extends {ol.webgl.Shader}
|
||||||
* @param {string} source Source.
|
* @param {string} source Source.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.webgl.Fragment = function(source) {
|
ol.webgl.Fragment = function(source) {
|
||||||
ol.webgl.Shader.call(this, source);
|
ol.webgl.Shader.call(this, source);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.webgl.Fragment, ol.webgl.Shader);
|
ol.inherits(ol.webgl.Fragment, ol.webgl.Shader);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.webgl.Fragment.prototype.getType = function() {
|
ol.webgl.Fragment.prototype.getType = function() {
|
||||||
return ol.webgl.FRAGMENT_SHADER;
|
return ol.webgl.FRAGMENT_SHADER;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,15 +4,13 @@ goog.require('ol');
|
|||||||
goog.require('ol.functions');
|
goog.require('ol.functions');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @abstract
|
* @abstract
|
||||||
* @param {string} source Source.
|
* @param {string} source Source.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.webgl.Shader = function(source) {
|
ol.webgl.Shader = function(source) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -20,27 +18,25 @@ if (ol.ENABLE_WEBGL) {
|
|||||||
*/
|
*/
|
||||||
this.source_ = source;
|
this.source_ = source;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @abstract
|
* @abstract
|
||||||
* @return {number} Type.
|
* @return {number} Type.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Shader.prototype.getType = function() {};
|
ol.webgl.Shader.prototype.getType = function() {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {string} Source.
|
* @return {string} Source.
|
||||||
*/
|
*/
|
||||||
ol.webgl.Shader.prototype.getSource = function() {
|
ol.webgl.Shader.prototype.getSource = function() {
|
||||||
return this.source_;
|
return this.source_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {boolean} Is animated?
|
* @return {boolean} Is animated?
|
||||||
*/
|
*/
|
||||||
ol.webgl.Shader.prototype.isAnimated = ol.functions.FALSE;
|
ol.webgl.Shader.prototype.isAnimated = ol.functions.FALSE;
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,105 +6,101 @@ goog.require('ol');
|
|||||||
goog.require('ol.webgl.Fragment');
|
goog.require('ol.webgl.Fragment');
|
||||||
goog.require('ol.webgl.Vertex');
|
goog.require('ol.webgl.Vertex');
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Fragment}
|
* @extends {ol.webgl.Fragment}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
{{className}}.Fragment = function() {
|
{{className}}.Fragment = function() {
|
||||||
ol.webgl.Fragment.call(this, {{className}}.Fragment.SOURCE);
|
ol.webgl.Fragment.call(this, {{className}}.Fragment.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits({{className}}.Fragment, ol.webgl.Fragment);
|
ol.inherits({{className}}.Fragment, ol.webgl.Fragment);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
{{className}}.Fragment.DEBUG_SOURCE = 'precision mediump float;\n{{{getOriginalFragmentSource}}}';
|
{{className}}.Fragment.DEBUG_SOURCE = 'precision mediump float;\n{{{getOriginalFragmentSource}}}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
{{className}}.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;{{{getFragmentSource}}}';
|
{{className}}.Fragment.OPTIMIZED_SOURCE = 'precision mediump float;{{{getFragmentSource}}}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
{{className}}.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
{{className}}.Fragment.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
{{className}}.Fragment.DEBUG_SOURCE :
|
{{className}}.Fragment.DEBUG_SOURCE :
|
||||||
{{className}}.Fragment.OPTIMIZED_SOURCE;
|
{{className}}.Fragment.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
{{className}}.fragment = new {{className}}.Fragment();
|
{{className}}.fragment = new {{className}}.Fragment();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Vertex}
|
* @extends {ol.webgl.Vertex}
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
{{className}}.Vertex = function() {
|
{{className}}.Vertex = function() {
|
||||||
ol.webgl.Vertex.call(this, {{className}}.Vertex.SOURCE);
|
ol.webgl.Vertex.call(this, {{className}}.Vertex.SOURCE);
|
||||||
};
|
};
|
||||||
ol.inherits({{className}}.Vertex, ol.webgl.Vertex);
|
ol.inherits({{className}}.Vertex, ol.webgl.Vertex);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
{{className}}.Vertex.DEBUG_SOURCE = '{{{getOriginalVertexSource}}}';
|
{{className}}.Vertex.DEBUG_SOURCE = '{{{getOriginalVertexSource}}}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
{{className}}.Vertex.OPTIMIZED_SOURCE = '{{{getVertexSource}}}';
|
{{className}}.Vertex.OPTIMIZED_SOURCE = '{{{getVertexSource}}}';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
{{className}}.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
{{className}}.Vertex.SOURCE = ol.DEBUG_WEBGL ?
|
||||||
{{className}}.Vertex.DEBUG_SOURCE :
|
{{className}}.Vertex.DEBUG_SOURCE :
|
||||||
{{className}}.Vertex.OPTIMIZED_SOURCE;
|
{{className}}.Vertex.OPTIMIZED_SOURCE;
|
||||||
|
|
||||||
|
|
||||||
{{className}}.vertex = new {{className}}.Vertex();
|
{{className}}.vertex = new {{className}}.Vertex();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {WebGLRenderingContext} gl GL.
|
* @param {WebGLRenderingContext} gl GL.
|
||||||
* @param {WebGLProgram} program Program.
|
* @param {WebGLProgram} program Program.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
{{namespace}}.Locations = function(gl, program) {
|
{{namespace}}.Locations = function(gl, program) {
|
||||||
{{#getUniforms}}
|
{{#getUniforms}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {WebGLUniformLocation}
|
* @type {WebGLUniformLocation}
|
||||||
*/
|
*/
|
||||||
this.{{originalName}} = gl.getUniformLocation(
|
this.{{originalName}} = gl.getUniformLocation(
|
||||||
program, ol.DEBUG_WEBGL ? '{{originalName}}' : '{{shortName}}');
|
program, ol.DEBUG_WEBGL ? '{{originalName}}' : '{{shortName}}');
|
||||||
{{/getUniforms}}
|
{{/getUniforms}}
|
||||||
{{#getAttributes}}
|
{{#getAttributes}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.{{originalName}} = gl.getAttribLocation(
|
this.{{originalName}} = gl.getAttribLocation(
|
||||||
program, ol.DEBUG_WEBGL ? '{{originalName}}' : '{{shortName}}');
|
program, ol.DEBUG_WEBGL ? '{{originalName}}' : '{{shortName}}');
|
||||||
{{/getAttributes}}
|
{{/getAttributes}}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,25 +5,21 @@ goog.require('ol.webgl');
|
|||||||
goog.require('ol.webgl.Shader');
|
goog.require('ol.webgl.Shader');
|
||||||
|
|
||||||
|
|
||||||
if (ol.ENABLE_WEBGL) {
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.webgl.Shader}
|
* @extends {ol.webgl.Shader}
|
||||||
* @param {string} source Source.
|
* @param {string} source Source.
|
||||||
* @struct
|
* @struct
|
||||||
*/
|
*/
|
||||||
ol.webgl.Vertex = function(source) {
|
ol.webgl.Vertex = function(source) {
|
||||||
ol.webgl.Shader.call(this, source);
|
ol.webgl.Shader.call(this, source);
|
||||||
};
|
};
|
||||||
ol.inherits(ol.webgl.Vertex, ol.webgl.Shader);
|
ol.inherits(ol.webgl.Vertex, ol.webgl.Shader);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.webgl.Vertex.prototype.getType = function() {
|
ol.webgl.Vertex.prototype.getType = function() {
|
||||||
return ol.webgl.VERTEX_SHADER;
|
return ol.webgl.VERTEX_SHADER;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user