Skip to content

Commit

Permalink
maybe it's because we're treating the foreground as having an alpha?
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Apr 7, 2020
1 parent 4f8acb4 commit d714a10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src/renderer/dx/DxRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/dx/DxRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d714a10

Please sign in to comment.