From 5cf2e9c07206a0f01c87de504a541331b158a872 Mon Sep 17 00:00:00 2001 From: GaborFarkas Date: Wed, 5 Oct 2016 10:14:30 +0200 Subject: [PATCH] Add shutdown methods to replays --- src/ol/render/webgl/imagereplay/index.js | 12 ++++++++++++ src/ol/render/webgl/linestringreplay/index.js | 11 +++++++++++ src/ol/render/webgl/polygonreplay/index.js | 8 ++++++++ src/ol/render/webgl/replay.js | 17 ++++++++++++----- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/ol/render/webgl/imagereplay/index.js b/src/ol/render/webgl/imagereplay/index.js index 402546cf16..8a67843502 100644 --- a/src/ol/render/webgl/imagereplay/index.js +++ b/src/ol/render/webgl/imagereplay/index.js @@ -449,6 +449,18 @@ ol.render.webgl.ImageReplay.prototype.setUpProgram = function(gl, context, size, }; +/** + * @inheritDoc + */ +ol.render.webgl.ImageReplay.prototype.shutDownProgram_ = function(gl, locations) { + gl.disableVertexAttribArray(locations.a_position); + gl.disableVertexAttribArray(locations.a_offsets); + gl.disableVertexAttribArray(locations.a_texCoord); + gl.disableVertexAttribArray(locations.a_opacity); + gl.disableVertexAttribArray(locations.a_rotateWithView); +}; + + /** * @inheritDoc */ diff --git a/src/ol/render/webgl/linestringreplay/index.js b/src/ol/render/webgl/linestringreplay/index.js index 498121129b..70c694ece6 100644 --- a/src/ol/render/webgl/linestringreplay/index.js +++ b/src/ol/render/webgl/linestringreplay/index.js @@ -472,6 +472,17 @@ ol.render.webgl.LineStringReplay.prototype.setUpProgram = function(gl, context, }; +/** + * @inheritDoc + */ +ol.render.webgl.LineStringReplay.prototype.shutDownProgram_ = function(gl, locations) { + gl.disableVertexAttribArray(locations.a_lastPos); + gl.disableVertexAttribArray(locations.a_position); + gl.disableVertexAttribArray(locations.a_nextPos); + gl.disableVertexAttribArray(locations.a_direction); +}; + + /** * @inheritDoc */ diff --git a/src/ol/render/webgl/polygonreplay/index.js b/src/ol/render/webgl/polygonreplay/index.js index 427fd3e597..eaf89779cf 100644 --- a/src/ol/render/webgl/polygonreplay/index.js +++ b/src/ol/render/webgl/polygonreplay/index.js @@ -848,6 +848,14 @@ ol.render.webgl.PolygonReplay.prototype.setUpProgram = function(gl, context, siz }; +/** + * @inheritDoc + */ +ol.render.webgl.PolygonReplay.prototype.shutDownProgram_ = function(gl, locations) { + gl.disableVertexAttribArray(locations.a_position); +}; + + /** * @inheritDoc */ diff --git a/src/ol/render/webgl/replay.js b/src/ol/render/webgl/replay.js index 7caed3e343..71b228388c 100644 --- a/src/ol/render/webgl/replay.js +++ b/src/ol/render/webgl/replay.js @@ -143,6 +143,17 @@ ol.render.webgl.Replay.prototype.setUpProgram = function(gl, context, size, pixe * @abstract * @protected * @param {WebGLRenderingContext} gl gl. + * @param {ol.render.webgl.imagereplay.defaultshader.Locations| + ol.render.webgl.linestringreplay.defaultshader.Locations| + ol.render.webgl.polygonreplay.defaultshader.Locations} locations Locations. + */ +ol.render.webgl.Replay.prototype.shutDownProgram_ = function(gl, locations) {}; + + +/** + * @abstract + * @private + * @param {WebGLRenderingContext} gl gl. * @param {ol.webgl.Context} context Context. * @param {Object.} skippedFeaturesHash Ids of features * to skip. @@ -286,11 +297,7 @@ ol.render.webgl.Replay.prototype.replay = function(context, } // disable the vertex attrib arrays - for (var i in locations) { - if (typeof locations[i] === 'number') { - gl.disableVertexAttribArray(locations[i]); - } - } + this.shutDownProgram_(gl, locations); if (this.lineStringReplay) { this.lineStringReplay.replay(context,