terminal/src/types
Michael Niksa 8ea9b327f3
Adjusts High DPI scaling to enable differential rendering (#5345)
## Summary of the Pull Request
- Adjusts scaling practices in `DxEngine` (and related scaling practices in `TerminalControl`) for pixel-perfect row baselines and spacing at High DPI such that differential row-by-row rendering can be applied at High DPI.

## References
- #5185 

## PR Checklist
* [x] Closes #5320, closes #3515, closes #1064
* [x] I work here.
* [x] Manually tested.
* [x] No doc.
* [x] Am core contributor. Also discussed with some of them already via Teams.

## Detailed Description of the Pull Request / Additional comments

**WAS:**
- We were using implicit DPI scaling on the `ID2D1RenderTarget` and running all of our processing in DIPs (Device-Independent Pixels). That's all well and good for getting things bootstrapped quickly, but it leaves the actual scaling of the draw commands up to the discretion of the rendering target.
- When we don't get to explicitly choose exactly how many pixels tall/wide and our X/Y placement perfectly, the nature of floating point multiplication and division required to do the presentation can cause us to drift off slightly out of our control depending on what the final display resolution actually is.
- Differential drawing cannot work unless we can know the exact integer pixels that need to be copied/moved/preserved/replaced between frames to give to the `IDXGISwapChain1::Present1` method. If things spill into fractional pixels or the sizes of rows/columns vary as they are rounded up and down implicitly, then we cannot do the differential rendering.

**NOW:**
- When deciding on a font, the `DxEngine` will take the scale factor into account and adjust the proposed height of the requested font. Then the remainder of the existing code that adjusts the baseline and integer-ifies each character cell will run naturally from there. That code already works correctly to align the height at normal DPI and scale out the font heights and advances to take an exact integer of pixels.
- `TermControl` has to use the scale now, in some places, and stop scaling in other places. This has to do with how the target's nature used to be implicit and is now explicit. For instance, determining where the cursor click hits must be scaled now. And determining the pixel size of the display canvas must no longer be scaled.
- `DxEngine` will no longer attempt to scale the invalid regions per my attempts in #5185 because the cell size is scaled. So it should work the same as at 96 DPI.
- The block is removed from the `DxEngine` that was causing a full invalidate on every frame at High DPI.
- A TODO was removed from `TermControl` that was invalidating everything when the DPI changed because the underlying renderer will already do that.

## Validation Steps Performed
* [x] Check at 150% DPI. Print text, scroll text down and up, do selection.
* [x] Check at 100% DPI. Print text, scroll text down and up, do selection.
* [x] Span two different DPI monitors and drag between them.
* [x] Giant pile of tests in https://github.com/microsoft/terminal/pull/5345#issuecomment-614127648

Co-authored-by: Dustin Howett <duhowett@microsoft.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
2020-04-22 14:59:51 -07:00
..
inc Make CodepointWidthDetector::GetWidth faster (#3727) 2020-04-04 00:56:22 +00:00
lib Import fmtlib/fmt@6.2.0, a C++20-style format library (#5336) 2020-04-14 13:04:23 -07:00
ut_types Implement til::u8u16 and til::u16u8 conversion functions (#4093) 2020-01-29 16:55:48 -08:00
CodepointWidthDetector.cpp Make CodepointWidthDetector::GetWidth faster (#3727) 2020-04-04 00:56:22 +00:00
convert.cpp Fix FillConsoleOutputCharacterA crash (#4309) 2020-02-10 14:09:08 -08:00
dirs Switch to v5 UUIDs as profile GUIDs for the default profiles (#913) 2019-05-21 13:29:16 -07:00
Environment.cpp Replace ConhostConnection with ConptyConnection (#3461) 2019-11-06 15:09:01 -08:00
FocusEvent.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
GlyphWidth.cpp Add GH issue IDs to all the suppress/disables that I left behind as they were a bit too challenging to solve with this giant PR 2019-09-05 11:14:43 -07:00
IBaseData.h Search - add search box control and implement search experience (#3590) 2019-12-17 15:52:37 +00:00
IConsoleWindow.hpp Accessibility: Set-up UIA Tree (#1691) 2019-07-29 15:21:15 -07:00
IControlAccessibilityInfo.h hook up UIA tree to WPF control (#4548) 2020-02-24 23:17:55 +00:00
IInputEvent.cpp Make loop in IInputEvent more consistent and modern (#4959) 2020-03-17 10:52:33 -07:00
IInputEventStreams.cpp Improve debugging experience of key events (#2872) 2019-09-24 13:50:53 -07:00
IUiaData.h Properly represent block selections in UIA (#4991) 2020-03-18 21:03:51 +00:00
IUiaEventDispatcher.h Attach UiaRenderer and Fire Selection Changed Events (#2989) 2019-12-11 13:52:49 -08:00
IUiaTraceable.h Add more object ID tracing for Accessibility (#5215) 2020-04-03 20:06:47 +00:00
IUiaWindow.h Accessibility: Set-up UIA Tree (#1691) 2019-07-29 15:21:15 -07:00
KeyEvent.cpp Improve debugging experience of key events (#2872) 2019-09-24 13:50:53 -07:00
MenuEvent.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ModifierKeyState.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
MouseEvent.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.h Accessibility: Set-up UIA Tree (#1691) 2019-07-29 15:21:15 -07:00
ScreenInfoUiaProviderBase.cpp Add more object ID tracing for Accessibility (#5215) 2020-04-03 20:06:47 +00:00
ScreenInfoUiaProviderBase.h Add more object ID tracing for Accessibility (#5215) 2020-04-03 20:06:47 +00:00
sources.inc Import build fix changes from OS for sync to a34a957cf 2020-03-16 18:26:48 +00:00
TermControlUiaProvider.cpp Properly represent block selections in UIA (#4991) 2020-03-18 21:03:51 +00:00
TermControlUiaProvider.hpp hook up UIA tree to WPF control (#4548) 2020-02-24 23:17:55 +00:00
TermControlUiaTextRange.cpp Adjusts High DPI scaling to enable differential rendering (#5345) 2020-04-22 14:59:51 -07:00
TermControlUiaTextRange.hpp Properly represent block selections in UIA (#4991) 2020-03-18 21:03:51 +00:00
ThemeUtils.cpp Use standard 1px window borders on NC Island Window (#3394) 2019-11-04 15:45:40 -08:00
UiaTextRangeBase.cpp UIA: Prevent crash from invalid UTR endpoint comparison (#5399) 2020-04-21 16:45:17 +00:00
UiaTextRangeBase.hpp Add more object ID tracing for Accessibility (#5215) 2020-04-03 20:06:47 +00:00
UiaTracing.cpp Add more object ID tracing for Accessibility (#5215) 2020-04-03 20:06:47 +00:00
UiaTracing.h Add more object ID tracing for Accessibility (#5215) 2020-04-03 20:06:47 +00:00
Utf16Parser.cpp C26447,C26440 - is noexcept but can throw or doesn't throw but not noexcept 2019-08-29 15:23:07 -07:00
utils.cpp Get rid of our hand-rolled sprintf->wstring helpers, prefer WIL (#3106) 2019-10-08 12:04:18 -07:00
viewport.cpp ci: run spell check in CI, fix remaining issues (#4799) 2020-03-25 11:02:53 -07:00
WindowBufferSizeEvent.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
WindowUiaProviderBase.cpp Upgrade UiaProviders to WRL::ComPtr (#3051) 2019-11-21 16:08:37 -08:00
WindowUiaProviderBase.hpp hygiene: change default specifiers of some functions to delete (#4962) 2020-03-18 17:30:50 -07:00