Skip to content

Commit

Permalink
Merge pull request openlayers#8023 from fredj/typedefs.js
Browse files Browse the repository at this point in the history
 Module type changes for ol.webgl
  • Loading branch information
fredj authored Mar 23, 2018
2 parents b836e23 + 2fc9cb6 commit 02d2e97
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 112 deletions.
4 changes: 2 additions & 2 deletions src/ol/render/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Event from '../events/Event.js';
* @param {ol.render.VectorContext=} opt_vectorContext Vector context.
* @param {module:ol/PluggableMap~FrameState=} opt_frameState Frame state.
* @param {?CanvasRenderingContext2D=} opt_context Context.
* @param {?ol.webgl.Context=} opt_glContext WebGL Context.
* @param {?module:ol/webgl/Context~WebGLContext=} opt_glContext WebGL Context.
*/
const RenderEvent = function(
type, opt_vectorContext, opt_frameState, opt_context,
Expand Down Expand Up @@ -45,7 +45,7 @@ const RenderEvent = function(
/**
* WebGL context. Only available when a WebGL renderer is used, null
* otherwise.
* @type {ol.webgl.Context|null|undefined}
* @type {module:ol/webgl/Context~WebGLContext|null|undefined}
* @api
*/
this.glContext = opt_glContext;
Expand Down
4 changes: 2 additions & 2 deletions src/ol/render/webgl/CircleReplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ WebGLCircleReplay.prototype.finish = function(context) {
WebGLCircleReplay.prototype.getDeleteResourcesFunction = function(context) {
// We only delete our stuff here. The shaders and the program may
// 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 module:ol/webgl/Context~WebGLContext
// object.
const verticesBuffer = this.verticesBuffer;
const indicesBuffer = this.indicesBuffer;
Expand Down Expand Up @@ -311,7 +311,7 @@ WebGLCircleReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, contex
/**
* @private
* @param {WebGLRenderingContext} gl gl.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {Object} skippedFeaturesHash Ids of features to skip.
*/
WebGLCircleReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
Expand Down
2 changes: 1 addition & 1 deletion src/ol/render/webgl/Immediate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import WebGLReplayGroup from '../webgl/ReplayGroup.js';
/**
* @constructor
* @extends {ol.render.VectorContext}
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {module:ol/coordinate~Coordinate} center Center.
* @param {number} resolution Resolution.
* @param {number} rotation Rotation.
Expand Down
2 changes: 1 addition & 1 deletion src/ol/render/webgl/LineStringReplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ WebGLLineStringReplay.prototype.drawReplay = function(gl, context, skippedFeatur
/**
* @private
* @param {WebGLRenderingContext} gl gl.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {Object} skippedFeaturesHash Ids of features to skip.
*/
WebGLLineStringReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
Expand Down
72 changes: 44 additions & 28 deletions src/ol/render/webgl/PolygonReplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ import RBush from '../../structs/RBush.js';
import {FLOAT} from '../../webgl.js';
import WebGLBuffer from '../../webgl/Buffer.js';


/**
* @typedef {Object} PolygonVertex
* @property {number} x
* @property {number} y
* @property {number} i
* @property {boolean} [reflex]
*/

/**
* @typedef {Object} PolygonSegment
* @property {module:ol/render/webgl/PolygonReplay~PolygonVertex} p0
* @property {module:ol/render/webgl/PolygonReplay~PolygonVertex} p1
*/


/**
* @constructor
* @extends {ol.render.webgl.Replay}
Expand Down Expand Up @@ -144,11 +160,11 @@ WebGLPolygonReplay.prototype.processFlatCoordinates_ = function(
0, flatCoordinates.length, stride);
let i, ii;
let n = this.vertices.length / 2;
/** @type {ol.WebglPolygonVertex} */
/** @type {module:ol/render/webgl/PolygonReplay~PolygonVertex} */
let start;
/** @type {ol.WebglPolygonVertex} */
/** @type {module:ol/render/webgl/PolygonReplay~PolygonVertex} */
let p0;
/** @type {ol.WebglPolygonVertex} */
/** @type {module:ol/render/webgl/PolygonReplay~PolygonVertex} */
let p1;
const extents = [];
const segments = [];
Expand Down Expand Up @@ -260,11 +276,11 @@ WebGLPolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
}

const p1 = seg.p1;
/** @type {ol.WebglPolygonVertex} */
/** @type {module:ol/render/webgl/PolygonReplay~PolygonVertex} */
const p2 = {x: listMaxX, y: p1.y, i: -1};
let minDist = Infinity;
let i, ii, bestPoint;
/** @type {ol.WebglPolygonVertex} */
/** @type {module:ol/render/webgl/PolygonReplay~PolygonVertex} */
let p5;

const intersectingSegments = this.getIntersections_({p0: p1, p1: p2}, rtree, true);
Expand Down Expand Up @@ -586,13 +602,13 @@ WebGLPolygonReplay.prototype.splitPolygon_ = function(list, rtree) {
* @param {number} x X coordinate.
* @param {number} y Y coordinate.
* @param {number} i Index.
* @return {ol.WebglPolygonVertex} List item.
* @return {module:ol/render/webgl/PolygonReplay~PolygonVertex} List item.
*/
WebGLPolygonReplay.prototype.createPoint_ = function(x, y, i) {
let numVertices = this.vertices.length;
this.vertices[numVertices++] = x;
this.vertices[numVertices++] = y;
/** @type {ol.WebglPolygonVertex} */
/** @type {module:ol/render/webgl/PolygonReplay~PolygonVertex} */
const p = {
x: x,
y: y,
Expand All @@ -605,11 +621,11 @@ WebGLPolygonReplay.prototype.createPoint_ = function(x, y, i) {

/**
* @private
* @param {ol.WebglPolygonVertex} p0 First point of segment.
* @param {ol.WebglPolygonVertex} p1 Second point of segment.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p0 First point of segment.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p1 Second point of segment.
* @param {ol.structs.LinkedList} list Polygon ring.
* @param {ol.structs.RBush=} opt_rtree Insert the segment into the R-Tree.
* @return {ol.WebglPolygonSegment} segment.
* @return {module:ol/render/webgl/PolygonReplay~PolygonSegment} segment.
*/
WebGLPolygonReplay.prototype.insertItem_ = function(p0, p1, list, opt_rtree) {
const seg = {
Expand All @@ -627,8 +643,8 @@ WebGLPolygonReplay.prototype.insertItem_ = function(p0, p1, list, opt_rtree) {

/**
* @private
* @param {ol.WebglPolygonSegment} s0 Segment before the remove candidate.
* @param {ol.WebglPolygonSegment} s1 Remove candidate segment.
* @param {module:ol/render/webgl/PolygonReplay~PolygonSegment} s0 Segment before the remove candidate.
* @param {module:ol/render/webgl/PolygonReplay~PolygonSegment} s1 Remove candidate segment.
* @param {ol.structs.LinkedList} list Polygon ring.
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
*/
Expand All @@ -645,12 +661,12 @@ WebGLPolygonReplay.prototype.removeItem_ = function(s0, s1, list, rtree) {

/**
* @private
* @param {ol.WebglPolygonVertex} p0 First point.
* @param {ol.WebglPolygonVertex} p1 Second point.
* @param {ol.WebglPolygonVertex} p2 Third point.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p0 First point.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p1 Second point.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p2 Third point.
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
* @param {boolean=} opt_reflex Only include reflex points.
* @return {Array.<ol.WebglPolygonVertex>} Points in the triangle.
* @return {Array.<module:ol/render/webgl/PolygonReplay~PolygonVertex>} Points in the triangle.
*/
WebGLPolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1, p2, rtree, opt_reflex) {
const result = [];
Expand All @@ -675,10 +691,10 @@ WebGLPolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1, p2, rtree,

/**
* @private
* @param {ol.WebglPolygonSegment} segment Segment.
* @param {module:ol/render/webgl/PolygonReplay~PolygonSegment} segment Segment.
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
* @param {boolean=} opt_touch Touching segments should be considered an intersection.
* @return {Array.<ol.WebglPolygonSegment>} Intersecting segments.
* @return {Array.<module:ol/render/webgl/PolygonReplay~PolygonSegment>} Intersecting segments.
*/
WebGLPolygonReplay.prototype.getIntersections_ = function(segment, rtree, opt_touch) {
const p0 = segment.p0;
Expand All @@ -702,10 +718,10 @@ WebGLPolygonReplay.prototype.getIntersections_ = function(segment, rtree, opt_to
* @see http://paulbourke.net/geometry/pointlineplane/
*
* @private
* @param {ol.WebglPolygonVertex} p0 First point.
* @param {ol.WebglPolygonVertex} p1 Second point.
* @param {ol.WebglPolygonVertex} p2 Third point.
* @param {ol.WebglPolygonVertex} p3 Fourth point.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p0 First point.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p1 Second point.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p2 Third point.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p3 Fourth point.
* @param {boolean=} opt_touch Touching segments should be considered an intersection.
* @return {Array.<number>|undefined} Intersection coordinates.
*/
Expand All @@ -726,11 +742,11 @@ WebGLPolygonReplay.prototype.calculateIntersection_ = function(p0, p1, p2, p3, o

/**
* @private
* @param {ol.WebglPolygonVertex} p0 Point before the start of the diagonal.
* @param {ol.WebglPolygonVertex} p1 Start point of the diagonal.
* @param {ol.WebglPolygonVertex} p2 Ear candidate.
* @param {ol.WebglPolygonVertex} p3 End point of the diagonal.
* @param {ol.WebglPolygonVertex} p4 Point after the end of the diagonal.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p0 Point before the start of the diagonal.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p1 Start point of the diagonal.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p2 Ear candidate.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p3 End point of the diagonal.
* @param {module:ol/render/webgl/PolygonReplay~PolygonVertex} p4 Point after the end of the diagonal.
* @return {boolean} Diagonal is inside the polygon.
*/
WebGLPolygonReplay.prototype.diagonalIsInside_ = function(p0, p1, p2, p3, p4) {
Expand Down Expand Up @@ -986,7 +1002,7 @@ WebGLPolygonReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, conte
/**
* @private
* @param {WebGLRenderingContext} gl gl.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {Object} skippedFeaturesHash Ids of features to skip.
*/
WebGLPolygonReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
Expand Down
22 changes: 11 additions & 11 deletions src/ol/render/webgl/Replay.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const WebGLReplay = function(tolerance, maxExtent) {

/**
* @protected
* @type {?ol.webgl.Buffer}
* @type {?module:ol/webgl/Buffer~WebGLBuffer}
*/
this.indicesBuffer = null;

Expand All @@ -107,7 +107,7 @@ const WebGLReplay = function(tolerance, maxExtent) {

/**
* @protected
* @type {?ol.webgl.Buffer}
* @type {?module:ol/webgl/Buffer~WebGLBuffer}
*/
this.verticesBuffer = null;

Expand All @@ -125,15 +125,15 @@ inherits(WebGLReplay, VectorContext);

/**
* @abstract
* @param {ol.webgl.Context} context WebGL context.
* @param {module:ol/webgl/Context~WebGLContext} context WebGL context.
* @return {function()} Delete resources function.
*/
WebGLReplay.prototype.getDeleteResourcesFunction = function(context) {};


/**
* @abstract
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
*/
WebGLReplay.prototype.finish = function(context) {};

Expand All @@ -142,7 +142,7 @@ WebGLReplay.prototype.finish = function(context) {};
* @abstract
* @protected
* @param {WebGLRenderingContext} gl gl.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {module:ol/size~Size} size Size.
* @param {number} pixelRatio Pixel ratio.
* @return {ol.render.webgl.circlereplay.defaultshader.Locations|
Expand All @@ -169,7 +169,7 @@ WebGLReplay.prototype.shutDownProgram = function(gl, locations) {};
* @abstract
* @protected
* @param {WebGLRenderingContext} gl gl.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
* to skip.
* @param {boolean} hitDetection Hit detection mode.
Expand All @@ -181,7 +181,7 @@ WebGLReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hi
* @abstract
* @protected
* @param {WebGLRenderingContext} gl gl.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
* to skip.
* @param {function((module:ol/Feature~Feature|ol.render.Feature)): T|undefined} featureCallback Feature callback.
Expand All @@ -196,7 +196,7 @@ WebGLReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, ski
/**
* @protected
* @param {WebGLRenderingContext} gl gl.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
* to skip.
* @param {function((module:ol/Feature~Feature|ol.render.Feature)): T|undefined} featureCallback Feature callback.
Expand All @@ -223,7 +223,7 @@ WebGLReplay.prototype.drawHitDetectionReplay = function(gl, context, skippedFeat
/**
* @protected
* @param {WebGLRenderingContext} gl gl.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
* to skip.
* @param {function((module:ol/Feature~Feature|ol.render.Feature)): T|undefined} featureCallback Feature callback.
Expand All @@ -245,7 +245,7 @@ WebGLReplay.prototype.drawHitDetectionReplayAll = function(gl, context, skippedF


/**
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {module:ol/coordinate~Coordinate} center Center.
* @param {number} resolution Resolution.
* @param {number} rotation Rotation.
Expand Down Expand Up @@ -353,7 +353,7 @@ WebGLReplay.prototype.replay = function(context,
/**
* @protected
* @param {WebGLRenderingContext} gl gl.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {number} start Start index.
* @param {number} end End index.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/ol/render/webgl/ReplayGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ WebGLReplayGroup.prototype.addDeclutter = function(style, group) {};


/**
* @param {ol.webgl.Context} context WebGL context.
* @param {module:ol/webgl/Context~WebGLContext} context WebGL context.
* @return {function()} Delete resources function.
*/
WebGLReplayGroup.prototype.getDeleteResourcesFunction = function(context) {
Expand All @@ -106,7 +106,7 @@ WebGLReplayGroup.prototype.getDeleteResourcesFunction = function(context) {


/**
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
*/
WebGLReplayGroup.prototype.finish = function(context) {
let zKey;
Expand Down Expand Up @@ -151,7 +151,7 @@ WebGLReplayGroup.prototype.isEmpty = function() {


/**
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {module:ol/coordinate~Coordinate} center Center.
* @param {number} resolution Resolution.
* @param {number} rotation Rotation.
Expand Down Expand Up @@ -186,7 +186,7 @@ WebGLReplayGroup.prototype.replay = function(context,

/**
* @private
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {module:ol/coordinate~Coordinate} center Center.
* @param {number} resolution Resolution.
* @param {number} rotation Rotation.
Expand Down Expand Up @@ -232,7 +232,7 @@ WebGLReplayGroup.prototype.replayHitDetection_ = function(context,

/**
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {module:ol/coordinate~Coordinate} center Center.
* @param {number} resolution Resolution.
* @param {number} rotation Rotation.
Expand Down Expand Up @@ -287,7 +287,7 @@ WebGLReplayGroup.prototype.forEachFeatureAtCoordinate = function(

/**
* @param {module:ol/coordinate~Coordinate} coordinate Coordinate.
* @param {ol.webgl.Context} context Context.
* @param {module:ol/webgl/Context~WebGLContext} context Context.
* @param {module:ol/coordinate~Coordinate} center Center.
* @param {number} resolution Resolution.
* @param {number} rotation Rotation.
Expand Down
Loading

0 comments on commit 02d2e97

Please sign in to comment.