Skip to content

Commit

Permalink
Use source UID in cacheKey to support multiple sources in webgl renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
sweepline committed Apr 29, 2024
1 parent 647eb94 commit 8bd79fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ol/renderer/webgl/TileLayer.js
Expand Up @@ -319,7 +319,7 @@ class WebGLTileLayerRenderer extends WebGLBaseTileLayerRenderer {
--z
) {
const tileCoord = tileGrid.getTileCoordForCoordAndZ(coordinate, z);
const cacheKey = getCacheKey(tileCoord);
const cacheKey = getCacheKey(source, tileCoord);
if (!tileTextureCache.containsKey(cacheKey)) {
continue;
}
Expand Down
14 changes: 10 additions & 4 deletions src/ol/renderer/webgl/TileLayerBase.js
Expand Up @@ -125,8 +125,13 @@ function getRenderExtent(frameState, extent) {
return extent;
}

export function getCacheKey(tileCoord) {
return getTileCoordKey(tileCoord);
/**
* @param {import("../../source.js").Source} source Source.
* @param {import("../../tilecoord.js").TileCoord} tileCoord Tile coordinate.
* @return {string} Cachekey string.
*/
export function getCacheKey(source, tileCoord) {
return `${getUid(source)},${getTileCoordKey(tileCoord)}`;
}

/**
Expand Down Expand Up @@ -317,7 +322,7 @@ class WebGLBaseTileLayerRenderer extends WebGLLayerRenderer {
for (let x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (let y = tileRange.minY; y <= tileRange.maxY; ++y) {
const tileCoord = createTileCoord(z, x, y, this.tempTileCoord_);
const cacheKey = getCacheKey(tileCoord);
const cacheKey = getCacheKey(tileSource, tileCoord);

/** @type {TileRepresentation} */
let tileRepresentation;
Expand Down Expand Up @@ -763,9 +768,10 @@ class WebGLBaseTileLayerRenderer extends WebGLLayerRenderer {

let covered = true;
const tileRepresentationCache = this.tileRepresentationCache;
const source = this.getLayer().getRenderSource();
for (let x = tileRange.minX; x <= tileRange.maxX; ++x) {
for (let y = tileRange.minY; y <= tileRange.maxY; ++y) {
const cacheKey = getCacheKey([altZ, x, y]);
const cacheKey = getCacheKey(source, [altZ, x, y]);
let loaded = false;
if (tileRepresentationCache.containsKey(cacheKey)) {
const tileRepresentation = tileRepresentationCache.get(cacheKey);
Expand Down

0 comments on commit 8bd79fb

Please sign in to comment.