More cleanup in the WebGL tile layer's dispose method

This commit is contained in:
Tim Schaub
2021-09-23 11:05:16 +00:00
parent 2ebbee2340
commit a332842540
6 changed files with 61 additions and 0 deletions
+2
View File
@@ -77,6 +77,8 @@ class WebGLLayerRenderer extends LayerRenderer {
*/
disposeInternal() {
this.helper.dispose();
delete this.helper;
super.disposeInternal();
}
+28
View File
@@ -181,6 +181,11 @@ class WebGLTileLayerRenderer extends WebGLLayerRenderer {
this.indices_ = indices;
const cacheSize = options.cacheSize !== undefined ? options.cacheSize : 512;
/**
* @type {import("../../structs/LRUCache.js").default<import("../../webgl/TileTexture.js").default>}
* @private
*/
this.tileTextureCache_ = new LRUCache(cacheSize);
this.renderedOpacity_ = NaN;
@@ -533,6 +538,29 @@ class WebGLTileLayerRenderer extends WebGLLayerRenderer {
}
return covered;
}
/**
* Clean up.
*/
disposeInternal() {
const helper = this.helper;
const gl = helper.getGL();
helper.deleteBuffer(this.indices_);
delete this.indices_;
gl.deleteProgram(this.program_);
delete this.program_;
const tileTextureCache = this.tileTextureCache_;
tileTextureCache.forEach(function (tileTexture) {
tileTexture.dispose();
});
tileTextureCache.clear();
delete this.tileTextureCache_;
super.disposeInternal();
}
}
/**