Store rendererd source on the layer instead of the layer state

This commit is contained in:
Tim Schaub
2022-03-26 10:12:03 -06:00
parent f7605f538a
commit b8c04ee7c5
4 changed files with 35 additions and 6 deletions

View File

@@ -57,7 +57,6 @@ import {listen, unlistenByKey} from '../events.js';
* @typedef {Object} State
* @property {import("./Layer.js").default} layer Layer.
* @property {number} opacity Opacity, the value is rounded to two digits to appear after the decimal point.
* @property {import("../source/Source.js").default|undefined} source Source being rendered (only for multi-source layers).
* @property {boolean} visible Visible.
* @property {boolean} managed Managed.
* @property {import("../extent.js").Extent} [extent] Extent.

View File

@@ -325,6 +325,12 @@ class WebGLTileLayer extends BaseTileLayer {
*/
this.sources_ = options.sources;
/**
* @type {SourceType|null}
* @private
*/
this.renderedSource_ = null;
/**
* @type {number}
* @private
@@ -373,10 +379,7 @@ class WebGLTileLayer extends BaseTileLayer {
* @return {SourceType} The source being rendered.
*/
getRenderSource() {
return (
/** @type {SourceType} */ (this.getLayerState().source) ||
this.getSource()
);
return this.renderedSource_ || this.getSource();
}
/**
@@ -426,7 +429,7 @@ class WebGLTileLayer extends BaseTileLayer {
const layerRenderer = this.getRenderer();
let canvas;
for (let i = 0, ii = sources.length; i < ii; ++i) {
this.getLayerState().source = sources[i];
this.renderedSource_ = sources[i];
if (layerRenderer.prepareFrame(frameState)) {
canvas = layerRenderer.renderFrame(frameState);
}