From 1cf7f417f8c2a47e51d8fbca7de87ae93db035d2 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Mon, 12 Sep 2022 03:31:45 +0200 Subject: [PATCH 1/2] AtlasEngine: Fix a crash when drawing double width rows --- src/renderer/atlas/AtlasEngine.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/renderer/atlas/AtlasEngine.cpp b/src/renderer/atlas/AtlasEngine.cpp index 983b4cd082b..05f4cbfe356 100644 --- a/src/renderer/atlas/AtlasEngine.cpp +++ b/src/renderer/atlas/AtlasEngine.cpp @@ -935,6 +935,21 @@ void AtlasEngine::_recreateSizeDependentResources() _api.glyphProps = Buffer{ projectedGlyphSize }; _api.glyphAdvances = Buffer{ projectedGlyphSize }; _api.glyphOffsets = Buffer{ projectedGlyphSize }; + + // Initialize cellGlyphMapping with valid data (whitespace), so that it can be + // safely used by the TileHashMap refresh logic via makeNewest() in StartPaint(). + { + u16x2* coords; + AtlasKey key{ { .cellCount = 1 }, 1, L" " }; + AtlasValue value{ CellFlags::None, 1, &coords }; + + coords[0] = _r.tileAllocator.allocate(_r.glyphs); + + const auto it = _r.glyphs.insert(std::move(key), std::move(value)); + _r.glyphQueue.emplace_back(it); + + std::ranges::fill(_r.cellGlyphMapping, it); + } } if (!_r.d2dMode) @@ -1176,6 +1191,15 @@ void AtlasEngine::_flushBufferLine() // This would seriously blow us up otherwise. Expects(_api.bufferLineColumn.size() == _api.bufferLine.size() + 1); + // GH#13962: With the lack of proper LineRendition support, just fill + // the remaining columns with whitespace to prevent any weird artifacts. + for (auto lastColumn = _api.bufferLineColumn.back(); lastColumn < _api.cellCount.x;) + { + ++lastColumn; + _api.bufferLine.emplace_back(L' '); + _api.bufferLineColumn.emplace_back(lastColumn); + } + // NOTE: // This entire function is one huge hack to see if it works. From c21e35aebc5961d8aff8e19dc98b15042f6fd470 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Tue, 13 Sep 2022 03:19:04 +0200 Subject: [PATCH 2/2] Address feedback, Fix AuditMode --- src/renderer/atlas/AtlasEngine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/atlas/AtlasEngine.cpp b/src/renderer/atlas/AtlasEngine.cpp index 05f4cbfe356..9d0cc9f4e97 100644 --- a/src/renderer/atlas/AtlasEngine.cpp +++ b/src/renderer/atlas/AtlasEngine.cpp @@ -939,7 +939,7 @@ void AtlasEngine::_recreateSizeDependentResources() // Initialize cellGlyphMapping with valid data (whitespace), so that it can be // safely used by the TileHashMap refresh logic via makeNewest() in StartPaint(). { - u16x2* coords; + u16x2* coords{}; AtlasKey key{ { .cellCount = 1 }, 1, L" " }; AtlasValue value{ CellFlags::None, 1, &coords }; @@ -948,7 +948,7 @@ void AtlasEngine::_recreateSizeDependentResources() const auto it = _r.glyphs.insert(std::move(key), std::move(value)); _r.glyphQueue.emplace_back(it); - std::ranges::fill(_r.cellGlyphMapping, it); + std::fill(_r.cellGlyphMapping.begin(), _r.cellGlyphMapping.end(), it); } }