From 4ba1f8dd6a49f639a49d4aeb5a56042fd0cd0678 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Fri, 8 Jul 2022 05:06:44 +0200 Subject: [PATCH] Fix TileAllocator not responding correctly to resizes --- src/renderer/atlas/AtlasEngine.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/renderer/atlas/AtlasEngine.h b/src/renderer/atlas/AtlasEngine.h index f85b5ab185b..f75fb093402 100644 --- a/src/renderer/atlas/AtlasEngine.h +++ b/src/renderer/atlas/AtlasEngine.h @@ -686,6 +686,11 @@ namespace Microsoft::Console::Render return false; } + // We need to backup _pos/_size in case our resize below exceeds _maxArea. + // In that case we have to restore _pos/_size so that if _maxArea is increased + // (window resize for instance), we can pick up were we previously left off. + const auto pos = _pos; + _pos.x += _tileSize.x; if (_pos.x <= _limit.x) { @@ -717,10 +722,19 @@ namespace Microsoft::Console::Render _size.y *= 2; _pos.x = 0; } - _limit = { gsl::narrow_cast(_size.x - _tileSize.x), gsl::narrow_cast(_size.y - _tileSize.y) }; - _originX = _pos.x; _updateCanGenerate(); + if (_canGenerate) + { + _limit = { gsl::narrow_cast(_size.x - _tileSize.x), gsl::narrow_cast(_size.y - _tileSize.y) }; + _originX = _pos.x; + } + else + { + _size = size; + _pos = pos; + } + return _canGenerate; }