Webgl points renderer / terminates worker & dispose helper

This commit is contained in:
Olivier Guyot
2019-09-24 17:42:48 +02:00
parent cb2c596a6d
commit 30f19f8317
3 changed files with 25 additions and 0 deletions

View File

@@ -70,6 +70,7 @@ class WebGLLayerRenderer extends LayerRenderer {
* @inheritDoc * @inheritDoc
*/ */
disposeInternal() { disposeInternal() {
this.helper.disposeInternal();
super.disposeInternal(); super.disposeInternal();
} }

View File

@@ -574,6 +574,14 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
const renderCount = this.indicesBuffer_.getSize(); const renderCount = this.indicesBuffer_.getSize();
this.helper.drawElements(0, renderCount); this.helper.drawElements(0, renderCount);
} }
/**
* @inheritDoc
*/
disposeInternal() {
this.worker_.terminate();
super.disposeInternal();
}
} }
export default WebGLPointsLayerRenderer; export default WebGLPointsLayerRenderer;

View File

@@ -254,4 +254,20 @@ describe('ol.renderer.webgl.PointsLayer', function() {
}); });
}); });
describe('#disposeInternal', function() {
it('terminates the worker and calls dispose on the helper', function() {
const layer = new VectorLayer({
source: new VectorSource()
});
const renderer = new WebGLPointsLayerRenderer(layer, {
});
const spyHelper = sinon.spy(renderer.helper, 'disposeInternal');
const spyWorker = sinon.spy(renderer.worker_, 'terminate');
renderer.disposeInternal();
expect(spyHelper.called).to.be(true);
expect(spyWorker.called).to.be(true);
});
});
}); });