From 6e8a2adbd993a72c0d0cb56f0c747a4546654d73 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 10 Nov 2021 16:20:13 -0600 Subject: [PATCH] MIKE YOU HAVE TEST CASES HERE This works for opacity for all Terminal cases. Need to still fix conhost. ```json "persistedWindowLayouts" : [ { "initialPosition" : "149,43", "initialSize" : { "height" : 901.0, "width" : 1499.0 }, "tabLayout" : [ { "action" : "newTab", "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "profile" : "One Half Light + cleartype + acrylic", "startingDirectory" : null, "suppressApplicationTitle" : false, "tabTitle" : "One Half Light + cleartype + acrylic" }, { "action" : "splitPane", "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "profile" : "One Half Light + cleartype + vintage", "size" : 0.5, "split" : "right", "splitMode" : "manual", "startingDirectory" : null, "suppressApplicationTitle" : false, "tabTitle" : "One Half Light + cleartype + vintage" }, { "action" : "moveFocus", "direction" : "previousInOrder" }, { "action" : "splitPane", "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "profile" : "One Half Light + grayscale + acrylic", "size" : 0.70000004768371582, "split" : "down", "splitMode" : "manual", "startingDirectory" : null, "suppressApplicationTitle" : false, "tabTitle" : "One Half Light + grayscale + acrylic" }, { "action" : "splitPane", "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "profile" : "One Half Light + cleartype + acrylic(100)", "size" : 0.5, "split" : "down", "splitMode" : "manual", "startingDirectory" : null, "suppressApplicationTitle" : false, "tabTitle" : "One Half Light + cleartype + acrylic(100)" }, { "action" : "moveFocus", "direction" : "nextInOrder" }, { "action" : "splitPane", "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "profile" : "One Half Light + grayscale + vintage", "size" : 0.70000004768371582, "split" : "down", "splitMode" : "manual", "startingDirectory" : null, "suppressApplicationTitle" : false, "tabTitle" : "One Half Light + grayscale + vintage" }, { "action" : "splitPane", "commandline" : "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "profile" : "One Half Light + cleartype + vintage(100)", "size" : 0.5, "split" : "down", "splitMode" : "manual", "startingDirectory" : null, "suppressApplicationTitle" : false, "tabTitle" : "One Half Light + cleartype + vintage(100)" }, { "action" : "focusPane", "id" : 5 }, ] } ] ``` with the following profiles: ```json { "antialiasingMode": "cleartype", "colorScheme": "One Half Light", "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "font": { "size": 8 }, "guid": "{e7f732da-f5c2-5f52-afd2-82518887a012}", "name": "One Half Light + cleartype + acrylic", "opacity": 50, "useAcrylic": true }, { "antialiasingMode": "cleartype", "colorScheme": "One Half Light", "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "font": { "size": 8 }, "guid": "{e52bc30c-4fa8-5650-9c00-b619544efa5e}", "name": "One Half Light + cleartype + vintage", "opacity": 50, "useAcrylic": false }, { "antialiasingMode": "grayscale", "colorScheme": "One Half Light", "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "font": { "size": 8 }, "guid": "{a870263b-0a3f-561f-82d2-bafc1163f1fc}", "name": "One Half Light + grayscale + acrylic", "opacity": 50, "useAcrylic": true }, { "antialiasingMode": "grayscale", "colorScheme": "One Half Light", "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "font": { "size": 8 }, "guid": "{58a6ffb9-ead3-53ae-a696-c3eb27292578}", "name": "One Half Light + grayscale + vintage", "opacity": 50, "useAcrylic": false }, { "antialiasingMode": "cleartype", "colorScheme": "One Half Light", "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "font": { "size": 8 }, "name": "One Half Light + cleartype + acrylic(100)", "opacity": 100, "useAcrylic": true }, { "antialiasingMode": "cleartype", "colorScheme": "One Half Light", "commandline": "c:\\windows\\system32\\cmd.exe /k colortool.exe -c", "font": { "size": 8 }, "name": "One Half Light + cleartype + vintage(100)", "opacity": 100, "useAcrylic": false }, ``` --- src/cascadia/TerminalControl/ControlCore.cpp | 11 +++-------- src/renderer/dx/DxRenderer.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index d912795f6..540b9f792 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -451,16 +451,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation // is what the Terminal did prior to 1.12. if (!IsVintageOpacityAvailable()) { - // const auto oldUseAcrylic{ UseAcrylic() }; _runtimeUseAcrylic = newOpacity < 1.0; - // // If they've changed the value of UseAcrylic, then update the - // // renderer as well. - // if (oldUseAcrylic != UseAcrylic() && _renderEngine) - // { - // // GH#5098: Inform the engine of the new opacity of the default - // // text background. - // } } + + // Update the renderer as well. It might need to fall back from + // cleartype -> grayscale if the BG is transparent / acrylic. _renderEngine->SetDefaultTextBackgroundOpacity(_correctForTransparency()); auto eventArgs = winrt::make_self(newOpacity); diff --git a/src/renderer/dx/DxRenderer.cpp b/src/renderer/dx/DxRenderer.cpp index 1428e8d45..547eb604f 100644 --- a/src/renderer/dx/DxRenderer.cpp +++ b/src/renderer/dx/DxRenderer.cpp @@ -1941,11 +1941,16 @@ CATCH_RETURN() { const auto [colorForeground, colorBackground] = pData->GetAttributeColors(textAttributes); + const bool usingCleartype = _antialiasingMode == D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE; + const bool usingTransparency = _defaultBackgroundIsTransparent != 0; + const bool forceOpaqueBG = usingCleartype && !usingTransparency; + // (usingCleartype && !(_defaultBackgroundIsTransparent == 0)) -> wrong, both acry(50)&vint(50) got solid BGs, as well as acry(100) + _foregroundColor = _ColorFFromColorRef(OPACITY_OPAQUE | colorForeground); // October 2021: small changes were made to the way BG color interacts with // grayscale AA, esp. with regards to acrylic and GH#5098. See comment in // _ShouldForceGrayscaleAA for more details. - _backgroundColor = _ColorFFromColorRef(colorBackground); + _backgroundColor = _ColorFFromColorRef((forceOpaqueBG ? OPACITY_OPAQUE : 0) | colorBackground); _d2dBrushForeground->SetColor(_foregroundColor); _d2dBrushBackground->SetColor(_backgroundColor);