From abaf9890b8ad332fc97bf2f12674a8f6f79e8739 Mon Sep 17 00:00:00 2001 From: tobspr Date: Tue, 29 Sep 2020 19:30:03 +0200 Subject: [PATCH] Don't cache pattern --- src/js/game/map_view.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/js/game/map_view.js b/src/js/game/map_view.js index 0f2ceb89..296291e9 100644 --- a/src/js/game/map_view.js +++ b/src/js/game/map_view.js @@ -26,11 +26,6 @@ export class MapView extends BaseMap { /** @type {CanvasRenderingContext2D} */ this.cachedBackgroundContext = null; - /** - * Cached pattern of the stripes background - * @type {CanvasPattern} */ - this.cachedBackgroundPattern = null; - this.internalInitializeCachedBackgroundCanvases(); this.root.signals.aboutToDestruct.add(this.cleanup, this); @@ -42,7 +37,6 @@ export class MapView extends BaseMap { cleanup() { freeCanvas(this.cachedBackgroundCanvas); this.cachedBackgroundCanvas = null; - this.cachedBackgroundPattern = null; } /** @@ -191,19 +185,15 @@ export class MapView extends BaseMap { * @param {DrawParameters} parameters */ drawBackground(parameters) { - if (!this.cachedBackgroundPattern) { - this.cachedBackgroundPattern = parameters.context.createPattern( - this.cachedBackgroundCanvas, - "repeat" - ); - } - // Render tile grid if (!this.root.app.settings.getAllSettings().disableTileGrid) { const dpi = this.backgroundCacheDPI; parameters.context.scale(1 / dpi, 1 / dpi); - parameters.context.fillStyle = this.cachedBackgroundPattern; + parameters.context.fillStyle = parameters.context.createPattern( + this.cachedBackgroundCanvas, + "repeat" + ); parameters.context.fillRect( parameters.visibleRect.x * dpi, parameters.visibleRect.y * dpi,