Merge pull request #30 from elemoine/webgl-point-delete
[webgl-point] Add ol.renderer.webgl.VectorLayer#disposeInternal
This commit is contained in:
@@ -3,6 +3,7 @@ goog.provide('ol.render.webgl.ReplayGroup');
|
|||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
|
goog.require('goog.functions');
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
goog.require('goog.vec.Mat4');
|
goog.require('goog.vec.Mat4');
|
||||||
goog.require('ol.color.Matrix');
|
goog.require('ol.color.Matrix');
|
||||||
@@ -194,34 +195,27 @@ ol.render.webgl.ImageReplay = function(tolerance, maxExtent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {ol.webgl.Context} context WebGL context.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @return {function()} Delete resources function.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.dispose = function(frameState, context) {
|
ol.render.webgl.ImageReplay.prototype.getDeleteResourcesFunction =
|
||||||
|
function(context) {
|
||||||
goog.asserts.assert(!goog.isNull(this.verticesBuffer_));
|
goog.asserts.assert(!goog.isNull(this.verticesBuffer_));
|
||||||
goog.asserts.assert(!goog.isNull(this.indicesBuffer_));
|
goog.asserts.assert(!goog.isNull(this.indicesBuffer_));
|
||||||
frameState.postRenderFunctions.push(
|
var verticesBuffer = this.verticesBuffer_;
|
||||||
goog.partial(
|
var indicesBuffer = this.indicesBuffer_;
|
||||||
/**
|
var textures = this.textures_;
|
||||||
* @param {WebGLRenderingContext} gl GL.
|
var gl = context.getGL();
|
||||||
* @param {Array.<WebGLTexture>} textures Textures.
|
return function() {
|
||||||
* @param {WebGLBuffer} verticesBuffer Vertices buffer.
|
if (!gl.isContextLost()) {
|
||||||
* @param {WebGLBuffer} indicesBuffer Indices buffer.
|
var i, ii;
|
||||||
*/
|
for (i = 0, ii = textures.length; i < ii; ++i) {
|
||||||
function(gl, textures, verticesBuffer, indicesBuffer) {
|
gl.deleteTexture(textures[i]);
|
||||||
if (!gl.isContextLost()) {
|
}
|
||||||
var i, ii;
|
gl.deleteBuffer(verticesBuffer);
|
||||||
for (i = 0, ii = textures.length; i < ii; ++i) {
|
gl.deleteBuffer(indicesBuffer);
|
||||||
gl.deleteTexture(textures[i]);
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
gl.deleteBuffer(verticesBuffer);
|
|
||||||
gl.deleteBuffer(indicesBuffer);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
context.getGL(), this.textures_, this.verticesBuffer_,
|
|
||||||
this.indicesBuffer_));
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -714,15 +708,18 @@ ol.render.webgl.ReplayGroup = function(tolerance, maxExtent) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {ol.webgl.Context} context WebGL context.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @return {function()} Delete resources function.
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ReplayGroup.prototype.dispose =
|
ol.render.webgl.ReplayGroup.prototype.getDeleteResourcesFunction =
|
||||||
function(frameState, context) {
|
function(context) {
|
||||||
|
var functions = [];
|
||||||
var replayKey;
|
var replayKey;
|
||||||
for (replayKey in this.replays_) {
|
for (replayKey in this.replays_) {
|
||||||
this.replays_[replayKey].dispose(frameState, context);
|
functions.push(
|
||||||
|
this.replays_[replayKey].getDeleteResourcesFunction(context));
|
||||||
}
|
}
|
||||||
|
return goog.functions.sequence.apply(null, functions);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,21 @@ ol.renderer.webgl.VectorLayer.prototype.composeFrame =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.renderer.webgl.VectorLayer.prototype.disposeInternal = function() {
|
||||||
|
var replayGroup = this.replayGroup_;
|
||||||
|
if (!goog.isNull(replayGroup)) {
|
||||||
|
var mapRenderer = this.getWebGLMapRenderer();
|
||||||
|
var context = mapRenderer.getContext();
|
||||||
|
replayGroup.getDeleteResourcesFunction(context)();
|
||||||
|
this.replayGroup_ = null;
|
||||||
|
}
|
||||||
|
goog.base(this, 'disposeInternal');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
@@ -146,7 +161,8 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame =
|
|||||||
extent[3] = frameStateExtent[3] + yBuffer;
|
extent[3] = frameStateExtent[3] + yBuffer;
|
||||||
|
|
||||||
if (!goog.isNull(this.replayGroup_)) {
|
if (!goog.isNull(this.replayGroup_)) {
|
||||||
this.replayGroup_.dispose(frameState, context);
|
frameState.postRenderFunctions.push(
|
||||||
|
this.replayGroup_.getDeleteResourcesFunction(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dirty_ = false;
|
this.dirty_ = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user