Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AtlasEngine: Implement remaining underlines and builtin glyphs for D2D #17278

Merged
merged 6 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/renderer/atlas/AtlasEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ try
_handleSettingsUpdate();
}

if (ATLAS_DEBUG_DISABLE_PARTIAL_INVALIDATION || _hackTriggerRedrawAll)
if constexpr (ATLAS_DEBUG_DISABLE_PARTIAL_INVALIDATION)
{
_hackTriggerRedrawAll = false;
_api.invalidatedRows = invalidatedRowsAll;
_api.scrollOffset = 0;
}
Expand Down Expand Up @@ -703,8 +702,6 @@ void AtlasEngine::_recreateFontDependentResources()
_api.textFormatAxes[i] = { fontAxisValues.data(), fontAxisValues.size() };
}
}

_hackWantsBuiltinGlyphs = _p.s->font->builtinGlyphs && !_hackIsBackendD2D;
DHowett marked this conversation as resolved.
Show resolved Hide resolved
}

void AtlasEngine::_recreateCellCountDependentResources()
Expand Down Expand Up @@ -765,18 +762,13 @@ void AtlasEngine::_flushBufferLine()
// This would seriously blow us up otherwise.
Expects(_api.bufferLineColumn.size() == _api.bufferLine.size() + 1);

const auto builtinGlyphs = _p.s->font->builtinGlyphs;
const auto beg = _api.bufferLine.data();
const auto len = _api.bufferLine.size();
size_t segmentBeg = 0;
size_t segmentEnd = 0;
bool custom = false;

if (!_hackWantsBuiltinGlyphs)
{
_mapRegularText(0, len);
return;
}

while (segmentBeg < len)
{
segmentEnd = segmentBeg;
Expand All @@ -789,7 +781,7 @@ void AtlasEngine::_flushBufferLine()
codepoint = til::combine_surrogates(codepoint, beg[i++]);
}

const auto c = BuiltinGlyphs::IsBuiltinGlyph(codepoint) || BuiltinGlyphs::IsSoftFontChar(codepoint);
const auto c = (builtinGlyphs && BuiltinGlyphs::IsBuiltinGlyph(codepoint)) || BuiltinGlyphs::IsSoftFontChar(codepoint);
if (custom != c)
{
break;
Expand Down
12 changes: 0 additions & 12 deletions src/renderer/atlas/AtlasEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,6 @@ namespace Microsoft::Console::Render::Atlas
std::unique_ptr<IBackend> _b;
RenderingPayload _p;

// _p.s->font->builtinGlyphs is the setting which decides whether we should map box drawing glyphs to
// our own builtin versions. There's just one problem: BackendD2D doesn't have this functionality.
// But since AtlasEngine shapes the text before it's handed to the backends, it would need to know
// whether BackendD2D is in use, before BackendD2D even exists. These two flags solve the issue
// by triggering a complete, immediate redraw whenever the backend type changes.
//
// The proper solution is to move text shaping into the backends.
// Someone just needs to write a generic "TextBuffer to DWRITE_GLYPH_RUN" function.
bool _hackIsBackendD2D = false;
bool _hackWantsBuiltinGlyphs = true;
bool _hackTriggerRedrawAll = false;

struct ApiState
{
GenerationalSettings s = DirtyGenerationalSettings();
Expand Down
8 changes: 1 addition & 7 deletions src/renderer/atlas/AtlasEngine.r.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ CATCH_RETURN()

[[nodiscard]] bool AtlasEngine::RequiresContinuousRedraw() noexcept
{
return ATLAS_DEBUG_CONTINUOUS_REDRAW || (_b && _b->RequiresContinuousRedraw()) || _hackTriggerRedrawAll;
return ATLAS_DEBUG_CONTINUOUS_REDRAW || (_b && _b->RequiresContinuousRedraw());
}

void AtlasEngine::WaitUntilCanRender() noexcept
Expand Down Expand Up @@ -282,21 +282,15 @@ void AtlasEngine::_recreateBackend()
{
case GraphicsAPI::Direct2D:
_b = std::make_unique<BackendD2D>();
_hackIsBackendD2D = true;
break;
default:
_b = std::make_unique<BackendD3D>(_p);
_hackIsBackendD2D = false;
break;
}

// This ensures that the backends redraw their entire viewports whenever a new swap chain is created,
// EVEN IF we got called when no actual settings changed (i.e. rendering failure, etc.).
_p.MarkAllAsDirty();

const auto hackWantsBuiltinGlyphs = _p.s->font->builtinGlyphs && !_hackIsBackendD2D;
_hackTriggerRedrawAll = _hackWantsBuiltinGlyphs != hackWantsBuiltinGlyphs;
_hackWantsBuiltinGlyphs = hackWantsBuiltinGlyphs;
}

void AtlasEngine::_handleSwapChainUpdate()
Expand Down
Loading
Loading