From d714a10095cbd2cc3029ccdf53cf1588f7686e02 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 7 Apr 2020 09:01:43 -0500 Subject: [PATCH] maybe it's because we're treating the foreground as having an alpha? --- src/renderer/dx/DxRenderer.cpp | 21 ++++++++++++++------- src/renderer/dx/DxRenderer.hpp | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/renderer/dx/DxRenderer.cpp b/src/renderer/dx/DxRenderer.cpp index 77c5bffb755..6829e88674e 100644 --- a/src/renderer/dx/DxRenderer.cpp +++ b/src/renderer/dx/DxRenderer.cpp @@ -1282,7 +1282,7 @@ void DxEngine::_InvalidOr(RECT rc) noexcept const auto existingColor = _d2dBrushForeground->GetColor(); const auto restoreBrushOnExit = wil::scope_exit([&]() noexcept { _d2dBrushForeground->SetColor(existingColor); }); - _d2dBrushForeground->SetColor(_ColorFFromColorRef(color)); + _d2dBrushForeground->SetColor(_ColorFFromColorRef(color, false)); const auto font = _GetFontSize(); D2D_POINT_2F target; @@ -1549,7 +1549,7 @@ CATCH_RETURN() const ExtendedAttributes /*extendedAttrs*/, bool const isSettingDefaultBrushes) noexcept { - _foregroundColor = _ColorFFromColorRef(colorForeground); + _foregroundColor = _ColorFFromColorRef(colorForeground, false); _backgroundColor = _ColorFFromColorRef(colorBackground); _d2dBrushForeground->SetColor(_foregroundColor); @@ -2128,7 +2128,7 @@ float DxEngine::GetScaling() const noexcept // - color - GDI color // Return Value: // - D2D color -[[nodiscard]] D2D1_COLOR_F DxEngine::_ColorFFromColorRef(const COLORREF color) noexcept +[[nodiscard]] D2D1_COLOR_F DxEngine::_ColorFFromColorRef(const COLORREF color, const bool useAlpha) noexcept { // Converts BGR color order to RGB. const UINT32 rgb = ((color & 0x0000FF) << 16) | (color & 0x00FF00) | ((color & 0xFF0000) >> 16); @@ -2141,11 +2141,18 @@ float DxEngine::GetScaling() const noexcept } case SwapChainMode::ForComposition: { - // Get the A value we've snuck into the highest byte - const BYTE a = ((color >> 24) & 0xFF); - const float aFloat = a / 255.0f; + if (useAlpha) + { + // Get the A value we've snuck into the highest byte + const BYTE a = ((color >> 24) & 0xFF); + const float aFloat = a / 255.0f; - return D2D1::ColorF(rgb, aFloat); + return D2D1::ColorF(rgb, aFloat); + } + else + { + return D2D1::ColorF(rgb, 1.0f); + } } default: FAIL_FAST_HR(E_NOTIMPL); diff --git a/src/renderer/dx/DxRenderer.hpp b/src/renderer/dx/DxRenderer.hpp index b8521d9b1ee..0ca9c8b1a92 100644 --- a/src/renderer/dx/DxRenderer.hpp +++ b/src/renderer/dx/DxRenderer.hpp @@ -248,7 +248,7 @@ namespace Microsoft::Console::Render [[nodiscard]] SIZE _GetClientSize() const noexcept; - [[nodiscard]] D2D1_COLOR_F _ColorFFromColorRef(const COLORREF color) noexcept; + [[nodiscard]] D2D1_COLOR_F _ColorFFromColorRef(const COLORREF color, const bool useAlpha = true) noexcept; // Routine Description: // - Helps convert a Direct2D ColorF into a DXGI RGBA