terminal/src/renderer/dx
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
..
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 Set DxRenderer non-text alias mode (#5149) 2020-03-28 00:15:50 +00:00
CustomTextRenderer.h remove null check from glyph run drawing as it's truly optional (#2791) 2019-09-17 10:25:22 -07:00
dirs Import build fix changes from OS for sync to a34a957cf 2020-03-16 18:26:48 +00:00
DxRenderer.cpp Adjusts High DPI scaling to enable differential rendering (#5345) 2020-04-22 14:59:51 -07:00
DxRenderer.hpp Adjusts High DPI scaling to enable differential rendering (#5345) 2020-04-22 14:59:51 -07: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