precalculate
This commit is contained in:
parent
5bcbde25a4
commit
48f619992c
|
@ -232,6 +232,11 @@ void ColorFix::_ToRGB()
|
|||
// - The foreground color after performing any necessary changes to make it more perceivable
|
||||
COLORREF ColorFix::GetPerceivableColor(COLORREF fg, COLORREF bg)
|
||||
{
|
||||
// If the colors are the same, don't do any adjusting
|
||||
if (fg == bg)
|
||||
{
|
||||
return fg;
|
||||
}
|
||||
ColorFix backLab(bg);
|
||||
ColorFix frontLab(fg);
|
||||
double de1 = GetDeltaE(frontLab, backLab);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "../../inc/argb.h"
|
||||
#include "../../types/inc/utils.hpp"
|
||||
#include "../../types/inc/colorTable.hpp"
|
||||
#include "ColorFix.hpp"
|
||||
|
||||
#include <winrt/Microsoft.Terminal.Core.h>
|
||||
|
||||
|
@ -182,6 +183,7 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
|||
{
|
||||
_colorTable.at(i) = til::color{ appearance.GetColorTableEntry(i) };
|
||||
}
|
||||
_MakeAdjustedColorMap();
|
||||
|
||||
CursorType cursorShape = CursorType::VerticalBar;
|
||||
switch (appearance.CursorShape())
|
||||
|
@ -1276,3 +1278,15 @@ const size_t Microsoft::Terminal::Core::Terminal::GetTaskbarProgress() const noe
|
|||
{
|
||||
return _taskbarProgress;
|
||||
}
|
||||
|
||||
void Terminal::_MakeAdjustedColorMap()
|
||||
{
|
||||
// for each pair of <fg, bg>, map it to the adjusted fg
|
||||
for (const auto fg : _colorTable)
|
||||
{
|
||||
for (const auto bg : _colorTable)
|
||||
{
|
||||
_adjustedColorMap[std::pair<COLORREF, COLORREF>(fg, bg)] = ColorFix::GetPerceivableColor(fg, bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,6 +370,9 @@ private:
|
|||
|
||||
void _NotifyTerminalCursorPositionChanged() noexcept;
|
||||
|
||||
std::map<std::pair<COLORREF, COLORREF>, COLORREF> _adjustedColorMap;
|
||||
void _MakeAdjustedColorMap();
|
||||
|
||||
#pragma region TextSelection
|
||||
// These methods are defined in TerminalSelection.cpp
|
||||
std::vector<SMALL_RECT> _GetSelectionRects() const noexcept;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "pch.h"
|
||||
#include "Terminal.hpp"
|
||||
#include <DefaultSettings.h>
|
||||
#include "ColorFix.hpp"
|
||||
|
||||
using namespace Microsoft::Terminal::Core;
|
||||
using namespace Microsoft::Console::Types;
|
||||
|
@ -54,6 +53,10 @@ std::pair<COLORREF, COLORREF> Terminal::GetAttributeColors(const TextAttribute&
|
|||
_screenReversed,
|
||||
_blinkingState.IsBlinkingFaint(),
|
||||
_intenseIsBright);
|
||||
if (_perceptualColorNudging && _adjustedColorMap.find(colors) != _adjustedColorMap.end())
|
||||
{
|
||||
colors.first = _adjustedColorMap.at(colors);
|
||||
}
|
||||
colors.first |= 0xff000000;
|
||||
// We only care about alpha for the default BG (which enables acrylic)
|
||||
// If the bg isn't the default bg color, or reverse video is enabled, make it fully opaque.
|
||||
|
@ -61,16 +64,7 @@ std::pair<COLORREF, COLORREF> Terminal::GetAttributeColors(const TextAttribute&
|
|||
{
|
||||
colors.second |= 0xff000000;
|
||||
}
|
||||
std::pair<COLORREF, COLORREF> result;
|
||||
if (_perceptualColorNudging)
|
||||
{
|
||||
result = std::pair<COLORREF, COLORREF>(ColorFix::GetPerceivableColor(colors.first, colors.second), colors.second);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = colors;
|
||||
}
|
||||
return result;
|
||||
return colors;
|
||||
}
|
||||
|
||||
COORD Terminal::GetCursorPosition() const noexcept
|
||||
|
|
Loading…
Reference in a new issue