Merge pull request #9152 from ahocevar/vectortile-optimizations

Vector tile optimizations
This commit is contained in:
Andreas Hocevar
2019-01-25 17:03:42 +01:00
committed by GitHub
14 changed files with 19 additions and 21 deletions

View File

@@ -934,8 +934,9 @@ class PluggableMap extends BaseObject {
if (frameState) {
const hints = frameState.viewHints;
if (hints[ViewHint.ANIMATING] || hints[ViewHint.INTERACTING]) {
maxTotalLoading = 8;
maxNewLoads = 2;
const lowOnFrameBudget = Date.now() - frameState.time > 8;
maxTotalLoading = lowOnFrameBudget ? 0 : 8;
maxNewLoads = lowOnFrameBudget ? 0 : 2;
}
}
if (tileQueue.getTilesLoading() < maxTotalLoading) {
@@ -943,6 +944,7 @@ class PluggableMap extends BaseObject {
tileQueue.loadMoreTiles(maxTotalLoading, maxNewLoads);
}
}
if (frameState && this.hasListener(RenderEventType.RENDERCOMPLETE) && !frameState.animate &&
!this.tileQueue_.getTilesLoading() && !getLoading(this.getLayers().getArray())) {
this.renderer_.dispatchRenderEvent(RenderEventType.RENDERCOMPLETE, frameState);

View File

@@ -29,7 +29,7 @@ import {
makeInverse
} from '../../transform.js';
import CanvasExecutorGroup, {replayDeclutter} from '../../render/canvas/ExecutorGroup.js';
import {isEmpty} from '../../obj.js';
import {clear} from '../../obj.js';
/**
@@ -479,8 +479,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
for (let t = 0, tt = executorGroups.length; t < tt; ++t) {
const executorGroup = executorGroups[t];
if (!executorGroup.hasExecutors(replayTypes)) {
// sourceTile was not yet loaded when this.createReplayGroup_() was
// called, or it has no replays of the types we want to render
// sourceTile has no instructions of the types we want to render
continue;
}
const currentZ = tile.tileCoord[0];
@@ -550,10 +549,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
delete this.renderTileImageQueue_[uid];
this.renderTileImage_(tile, frameState.pixelRatio, frameState.viewState.projection);
}
if (!isEmpty(this.renderTileImageQueue_)) {
// If there's items left in the queue, render them in another frame
frameState.animate = true;
}
clear(this.renderTileImageQueue_);
}
/**

View File

@@ -50,7 +50,7 @@ const TOS_ATTRIBUTION = '<a class="ol-attribution-bing-tos" ' +
/**
* @typedef {Object} Options
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {boolean} [hidpi=false] If `true` hidpi tiles will be requested.
* @property {string} [culture='en-us'] Culture code.
* @property {string} key Bing Maps API key. Get yours at http://www.bingmapsportal.com/.

View File

@@ -9,7 +9,7 @@ import XYZ from './XYZ.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

View File

@@ -20,7 +20,7 @@ export const ATTRIBUTION = '&#169; ' +
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

View File

@@ -90,7 +90,7 @@ const ProviderConfig = {
/**
* @typedef {Object} Options
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {string} layer Layer name.
* @property {number} [minZoom] Minimum zoom.
* @property {number} [maxZoom] Maximum zoom.

View File

@@ -78,7 +78,7 @@ class TileSource extends Source {
const canUseScreen = 'screen ' in self;
const width = canUseScreen ? (screen.availWidth || screen.width) : 1920;
const height = canUseScreen ? (screen.availHeight || screen.height) : 1080;
cacheSize = 2 * Math.ceil(width / tileSize[0]) * Math.ceil(height / tileSize[1]);
cacheSize = 4 * Math.ceil(width / tileSize[0]) * Math.ceil(height / tileSize[1]);
}
/**

View File

@@ -13,7 +13,7 @@ import {appendParams} from '../uri.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

View File

@@ -18,7 +18,7 @@ import {getForProjection as getTileGridForProjection} from '../tilegrid.js';
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

View File

@@ -39,7 +39,7 @@ import {createXYZ, extentFromProjection} from '../tilegrid.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

View File

@@ -20,7 +20,7 @@ import {appendParams} from '../uri.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

View File

@@ -15,7 +15,7 @@ import {appendParams} from '../uri.js';
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

View File

@@ -9,7 +9,7 @@ import {createXYZ, extentFromProjection} from '../tilegrid.js';
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value if you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.

View File

@@ -82,7 +82,7 @@ export class CustomTile extends ImageTile {
/**
* @typedef {Object} Options
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
* @property {number} [cacheSize] Tile cache size. Default is twice as many tiles as a fullscreen map needs.
* @property {number} [cacheSize] Tile cache size. Default is four times as many tiles as a fullscreen map needs.
* @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that
* you must provide a `crossOrigin` value you want to access pixel data with the Canvas renderer.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.