terminal/src/renderer/dx
Mike Griese c803893c22
Use grayscale AA always on non-opaque backgrounds (#5277)
## Summary of the Pull Request

When we're on acrylic, we can't have cleartype text unfortunately. This PR changes the DX renderer to force cleartype runs of text that are on a non-opaque background to use grayscale AA instead.

## References

Here are some of the URLS I was referencing as writing this:

* https://stackoverflow.com/q/23587787
* https://docs.microsoft.com/en-us/windows/win32/direct2d/supported-pixel-formats-and-alpha-modes#cleartype-and-alpha-modes
* https://devblogs.microsoft.com/oldnewthing/20150129-00/?p=44803
* https://docs.microsoft.com/en-us/windows/win32/api/d2d1/ne-d2d1-d2d1_layer_options
* https://docs.microsoft.com/en-us/windows/win32/direct2d/direct2d-layers-overview#d2d1_layer_parameters1-and-d2d1_layer_options1
* https://docs.microsoft.com/en-us/windows/win32/api/dcommon/ne-dcommon-d2d1_alpha_mode?redirectedfrom=MSDN#cleartype-and-alpha-modes
* https://stackoverflow.com/a/26523006

Additionally:
* This was introduced in #4711 

## PR Checklist
* [x] Closes #5098
* [x] I work here
* [ ] Tests added/passed
* [n/a] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments

Basically, if you use cleartype on a light background, what you'll get today is the text foreground color _added_ to the background. This will make the text look basically invisible. 

So, what I did was use some trickery with `PushLayer` to basically create a layer where the text would be forced to render in grayscale AA. I only enable this layer pushing business when both:
  * The user has enabled cleartype text
  * The background opacity < 1.0

This plumbs some information through from the TermControl to the DX Renderer to make this smooth.

## Validation Steps Performed

Opened both cleartype and grayscale panes SxS, and messed with the opacity liberally.
2020-04-24 17:16:34 +00:00
..
lib Add experimental retro terminal effects (#3468) 2019-12-12 13:44:01 +00:00
ut_dx Import build fix changes from OS for sync to a34a957cf 2020-03-16 18:26:48 +00:00
CustomTextLayout.cpp ci: run spell check in CI, fix remaining issues (#4799) 2020-03-25 11:02:53 -07:00
CustomTextLayout.h Improve glyph scaling correction (#4747) 2020-03-02 19:21:07 +00:00
CustomTextRenderer.cpp Use grayscale AA always on non-opaque backgrounds (#5277) 2020-04-24 17:16:34 +00:00
CustomTextRenderer.h Use grayscale AA always on non-opaque backgrounds (#5277) 2020-04-24 17:16:34 +00:00
dirs Import build fix changes from OS for sync to a34a957cf 2020-03-16 18:26:48 +00:00
DxRenderer.cpp Use grayscale AA always on non-opaque backgrounds (#5277) 2020-04-24 17:16:34 +00:00
DxRenderer.hpp Use grayscale AA always on non-opaque backgrounds (#5277) 2020-04-24 17:16:34 +00:00
precomp.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.h Render row-by-row instead of invalidating entire screen (#5185) 2020-04-13 20:09:02 +00:00
ScreenPixelShader.h Scale retro terminal scan lines (#4716) 2020-02-26 00:08:45 +00:00
ScreenVertexShader.h Merged PR 4182306: [Git2Git] Merged PR 4182266: conhost: don't use D3DCompiler on inside-windows builds (and delete the shaders) 2020-01-23 00:42:56 +00:00
sources.inc Merged PR 4182306: [Git2Git] Merged PR 4182266: conhost: don't use D3DCompiler on inside-windows builds (and delete the shaders) 2020-01-23 00:42:56 +00:00