From 873b01bba547e09fb33f2fc0d1f10989c44a95ee Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Fri, 23 Mar 2018 13:22:51 +0100 Subject: [PATCH] Move WebGL typedefs out of src/ol/typedefs.js --- src/ol/render/webgl/PolygonReplay.js | 70 +++++++++++++++++----------- src/ol/render/webgl/TextReplay.js | 14 ++++-- src/ol/renderer/webgl/Map.js | 16 +++++-- src/ol/typedefs.js | 36 -------------- src/ol/webgl/Context.js | 10 +++- 5 files changed, 75 insertions(+), 71 deletions(-) diff --git a/src/ol/render/webgl/PolygonReplay.js b/src/ol/render/webgl/PolygonReplay.js index 8047c4f361..210325f4ca 100644 --- a/src/ol/render/webgl/PolygonReplay.js +++ b/src/ol/render/webgl/PolygonReplay.js @@ -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} @@ -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 = []; @@ -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); @@ -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, @@ -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 = { @@ -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. */ @@ -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.} Points in the triangle. + * @return {Array.} Points in the triangle. */ WebGLPolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1, p2, rtree, opt_reflex) { const result = []; @@ -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.} Intersecting segments. + * @return {Array.} Intersecting segments. */ WebGLPolygonReplay.prototype.getIntersections_ = function(segment, rtree, opt_touch) { const p0 = segment.p0; @@ -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.|undefined} Intersection coordinates. */ @@ -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) { diff --git a/src/ol/render/webgl/TextReplay.js b/src/ol/render/webgl/TextReplay.js index 57c1275c07..72f939e121 100644 --- a/src/ol/render/webgl/TextReplay.js +++ b/src/ol/render/webgl/TextReplay.js @@ -14,6 +14,14 @@ import WebGLTextureReplay from '../webgl/TextureReplay.js'; import AtlasManager from '../../style/AtlasManager.js'; import WebGLBuffer from '../../webgl/Buffer.js'; +/** + * @typedef {Object} GlyphAtlas + * @property {module:ol/style/AtlasManager~AtlasManager} atlas + * @property {Object.} width + * @property {number} height + */ + + /** * @constructor * @extends {ol.render.webgl.TextureReplay} @@ -100,13 +108,13 @@ const WebGLTextReplay = function(tolerance, maxExtent) { /** * @private - * @type {Object.} + * @type {Object.} */ this.atlases_ = {}; /** * @private - * @type {ol.WebglGlyphAtlas|undefined} + * @type {module:ol/render/webgl/TextReplay~GlyphAtlas|undefined} */ this.currAtlas_ = undefined; @@ -397,7 +405,7 @@ WebGLTextReplay.prototype.setTextStyle = function(textStyle) { /** * @private * @param {Object} state Font attributes. - * @return {ol.WebglGlyphAtlas} Glyph atlas. + * @return {module:ol/render/webgl/TextReplay~GlyphAtlas} Glyph atlas. */ WebGLTextReplay.prototype.getAtlas_ = function(state) { let params = []; diff --git a/src/ol/renderer/webgl/Map.js b/src/ol/renderer/webgl/Map.js index bf71762e50..a413c1cd13 100644 --- a/src/ol/renderer/webgl/Map.js +++ b/src/ol/renderer/webgl/Map.js @@ -25,6 +25,14 @@ import WebGLContext from '../../webgl/Context.js'; import ContextEventType from '../../webgl/ContextEventType.js'; +/** + * @typedef {Object} TextureCacheEntry + * @property {number} magFilter + * @property {number} minFilter + * @property {WebGLTexture} texture + */ + + /** * Texture cache high water mark. * @type {number} @@ -103,7 +111,7 @@ const WebGLMapRenderer = function(container, map) { /** * @private - * @type {ol.structs.LRUCache.} + * @type {ol.structs.LRUCache.} */ this.textureCache_ = new LRUCache(); @@ -295,9 +303,9 @@ WebGLMapRenderer.prototype.disposeInternal = function() { if (!gl.isContextLost()) { this.textureCache_.forEach( /** - * @param {?ol.WebglTextureCacheEntry} textureCacheEntry - * Texture cache entry. - */ + * @param {?module:ol/renderer/webgl/Map~TextureCacheEntry} textureCacheEntry + * Texture cache entry. + */ function(textureCacheEntry) { if (textureCacheEntry) { gl.deleteTexture(textureCacheEntry.texture); diff --git a/src/ol/typedefs.js b/src/ol/typedefs.js index 9ecced9bd2..eb7aa323c0 100644 --- a/src/ol/typedefs.js +++ b/src/ol/typedefs.js @@ -301,42 +301,6 @@ ol.StyleRenderFunction; ol.StyleImageOptions; -/** - * @typedef {{buf: module:ol/webgl/Buffer~WebGLBuffer, - * buffer: WebGLBuffer}} - */ -ol.WebglBufferCacheEntry; - - -/** - * @typedef {{atlas: ol.style.AtlasManager, - * width: Object., - * height: number}} - */ -ol.WebglGlyphAtlas; - - -/** - * @typedef {{p0: ol.WebglPolygonVertex, - * p1: ol.WebglPolygonVertex}} - */ -ol.WebglPolygonSegment; - -/** - * @typedef {{x: number, - * y: number, - * i: number, - * reflex: (boolean|undefined)}} - */ -ol.WebglPolygonVertex; - - -/** - * @typedef {{magFilter: number, minFilter: number, texture: WebGLTexture}} - */ -ol.WebglTextureCacheEntry; - - /** * Number of features; bounds/extent. * @typedef {{numberOfFeatures: number, diff --git a/src/ol/webgl/Context.js b/src/ol/webgl/Context.js index 9e79652aee..67bd829e8f 100644 --- a/src/ol/webgl/Context.js +++ b/src/ol/webgl/Context.js @@ -9,6 +9,14 @@ import {clear} from '../obj.js'; import {ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, TEXTURE_2D, TEXTURE_WRAP_S, TEXTURE_WRAP_T} from '../webgl.js'; import ContextEventType from '../webgl/ContextEventType.js'; + +/** + * @typedef {Object} BufferCacheEntry + * @property {module:ol/webgl/Buffer~WebGLBuffer} buf + * @property {WebGLBuffer} buffer + */ + + /** * @classdesc * A WebGL context for accessing low-level WebGL capabilities. @@ -34,7 +42,7 @@ const WebGLContext = function(canvas, gl) { /** * @private - * @type {!Object.} + * @type {!Object.} */ this.bufferCache_ = {};