79684bf821
## Summary of the Pull Request Adjusts DirectX renderer to use `til::bitmap` to track invalidation regions. Uses special modification to invalidate a row-at-a-time to ensure ligatures and NxM glyphs continue to work. ## References Likely helps #1064 ## PR Checklist * [x] Closes #778 * [x] I work here. * [x] Manual testing performed. See Performance traces in #778. * [x] Automated tests for `til` changes. * [x] Am core contributor. And discussed with @DHowett-MSFT. ## Detailed Description of the Pull Request / Additional comments - Applies `til::bitmap` as the new invalidation scheme inside the DirectX renderer and updates all entrypoints for collecting invalidation data to coalesce into this structure. - Semi-permanently routes all invalidations through a helper method `_InvalidateRectangle` that will expand any invalidation to cover the entire line. This ensures that ligatures and NxM glyphs will continue to render appropriately while still allowing us to dramatically reduce the number of lines drawn overall. In the future, we may come up with a tighter solution than line-by-line invalidation and can modify this helper method appropriately at that later date to further scope the invalid region. - Ensures that the `experimental.retroTerminalEffects` feature continues to invalidate the entire display on start of frame as the shader is applied at the end of the frame composition and will stack on itself in an amusing fashion when we only redraw part of the display. - Moves many member variables inside the DirectX renderer into the new `til::size`, `til::point`, and `til::rectangle` methods to facilitate easier management and mathematical operations. Consequently adds `try/catch` blocks around many of the already-existing `noexcept` methods to deal with mathematical or casting failures now detected by using the support classes. - Corrects `TerminalCore` redraw triggers to appropriately communicate scrolling circumstances to the renderer so it can optimize the draw regions appropriately. - Fixes an issue in the base `Renderer` that was causing overlapping scroll regions due to behavior of `Viewport::TrimToViewport` modifying the local. This fix is "good enough" for now and should go away when `Viewport` is fully migrated to `til::rectangle`. - Adds multiplication and division operators to `til::rectangle` and supporting tests. These operates will help scale back and forth between a cell-based rectangle and a pixel-based rectangle. They take special care to ensure that a pixel rectangle being divided downward back to cells will expand (with the ceiling division methods) to cover a full cell when even one pixel inside the cell is touched (as is how a redraw would have to occur). - Blocks off trace logging of invalid regions if no one is listening to optimize performance. - Restores full usage of `IDXGISwapChain1::Present1` to accurately and fully communicate dirty and scroll regions to the underlying DirectX framework. This additional information allows the framework to optimize drawing between frames by eliminating data transfer of regions that aren't modified and shuffling frames in place. See [Remarks](https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_2/nf-dxgi1_2-idxgiswapchain1-present1#remarks) for more details. - Updates `til::bitmap` set methods to use more optimized versions of the setters on the `dynamic_bitset<>` that can bulk fill bits as the existing algorithm was noticeably slow after applying the "expand-to-row" helper to the DirectX renderer invalidation. - All `til` import hierarchy is now handled in the parent `til.h` file and not in the child files to prevent circular imports from happening. We don't expect the import of any individual library file, only the base one. So this should be OK for now. ## Validation Steps Performed - Ran `cmatrix`, `cmatrix -u0`, and `cacafire` after changes were made. - Made a bunch of ligatures with `Cascadia Code` in the Terminal before/after the changes and confirmed they still ligate. - Ran `dir` in Powershell and fixed the scrolling issues - Clicked all over the place and dragged to make sure selection works. - Checked retro terminal effect manually with Powershell.
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
|
|
namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
|
{
|
|
// Operators go here when they involve two headers that can't/don't include each other.
|
|
|
|
#pragma region POINT VS SIZE
|
|
// This is a convenience and will take X vs WIDTH and Y vs HEIGHT.
|
|
_TIL_INLINEPREFIX point operator+(const point& lhs, const size& rhs)
|
|
{
|
|
return lhs + til::point{ rhs.width(), rhs.height() };
|
|
}
|
|
|
|
_TIL_INLINEPREFIX point operator-(const point& lhs, const size& rhs)
|
|
{
|
|
return lhs - til::point{ rhs.width(), rhs.height() };
|
|
}
|
|
|
|
_TIL_INLINEPREFIX point operator*(const point& lhs, const size& rhs)
|
|
{
|
|
return lhs * til::point{ rhs.width(), rhs.height() };
|
|
}
|
|
|
|
_TIL_INLINEPREFIX point operator/(const point& lhs, const size& rhs)
|
|
{
|
|
return lhs / til::point{ rhs.width(), rhs.height() };
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region SIZE VS POINT
|
|
// This is a convenience and will take WIDTH vs X and HEIGHT vs Y.
|
|
_TIL_INLINEPREFIX size operator+(const size& lhs, const point& rhs)
|
|
{
|
|
return lhs + til::size(rhs.x(), rhs.y());
|
|
}
|
|
|
|
_TIL_INLINEPREFIX size operator-(const size& lhs, const point& rhs)
|
|
{
|
|
return lhs - til::size(rhs.x(), rhs.y());
|
|
}
|
|
|
|
_TIL_INLINEPREFIX size operator*(const size& lhs, const point& rhs)
|
|
{
|
|
return lhs * til::size(rhs.x(), rhs.y());
|
|
}
|
|
|
|
_TIL_INLINEPREFIX size operator/(const size& lhs, const point& rhs)
|
|
{
|
|
return lhs / til::size(rhs.x(), rhs.y());
|
|
}
|
|
#pragma endregion
|
|
}
|