Skip to content

Commit 28d108b

Browse files
Set DxRenderer non-text alias mode (#5149)
There are two antialias modes that can be set on the ID2D1RenderTarget: - one for text/glyph drawing [1] - one for everything else [2] We had to configure that in the RenderTarget. Additionally, when clipping the background color rect, we need to make sure that's aliased too. [3] ## References [1] ID2D1RenderTarget::SetTextAntialiasMode https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-settextantialiasmode [2] ID2D1RenderTarget::SetAntialiasMode https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-setantialiasmode) [3] ID2D1CommandSink::PushAxisAlignedClip https://docs.microsoft.com/en-us/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1commandsink-pushaxisalignedclip) ## Validation Open and interact with midnight commander with the display scaling set to... - 100% - 125% - 150% - 175% - 200% Closes #3626
1 parent 91b84f1 commit 28d108b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/renderer/dx/CustomTextRenderer.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,12 @@ using namespace Microsoft::Console::Render;
273273
rect.right = std::accumulate(advancesSpan.cbegin(), advancesSpan.cend(), rect.right);
274274

275275
// Clip all drawing in this glyph run to where we expect.
276-
d2dContext->PushAxisAlignedClip(rect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
276+
// We need the AntialiasMode here to be Aliased to ensure
277+
// that background boxes line up with each other and don't leave behind
278+
// stray colors.
279+
// See GH#3626 for more details.
280+
d2dContext->PushAxisAlignedClip(rect, D2D1_ANTIALIAS_MODE_ALIASED);
281+
277282
// Ensure we pop it on the way out
278283
auto popclip = wil::scope_exit([&d2dContext]() noexcept {
279284
d2dContext->PopAxisAlignedClip();

src/renderer/dx/DxRenderer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ void DxEngine::_ComputePixelShaderSettings() noexcept
533533
&props,
534534
&_d2dRenderTarget));
535535

536+
// We need the AntialiasMode for non-text object to be Aliased to ensure
537+
// that background boxes line up with each other and don't leave behind
538+
// stray colors.
539+
// See GH#3626 for more details.
540+
_d2dRenderTarget->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
536541
_d2dRenderTarget->SetTextAntialiasMode(_antialiasingMode);
537542

538543
RETURN_IF_FAILED(_d2dRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::DarkRed),

0 commit comments

Comments
 (0)