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);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

View File

@@ -0,0 +1,27 @@
import Group from '../../../../src/ol/layer/Group.js';
import Map from '../../../../src/ol/Map.js';
import OSM from '../../../../src/ol/source/OSM.js';
import TileLayer from '../../../../src/ol/layer/WebGLTile.js';
import View from '../../../../src/ol/View.js';
new Map({
layers: [
new Group({
visible: false,
layers: [
new TileLayer({
source: new OSM(),
}),
],
}),
],
target: 'map',
view: new View({
center: [0, 0],
zoom: 0,
}),
});
render({
message: 'webgl tile layer in an invisible group is not rendered',
});