-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjusts High DPI scaling to enable differential rendering #5345
Merged
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
7e8f039
Start moving dx renderer onto bitmap.
miniksa b46b5d0
it works!
miniksa 78c1bc1
try to get present1 working and get mad because std::vector<bool> is …
miniksa 39d67e3
Merge branch 'master' into dev/miniksa/dx_bitmap
miniksa 777524a
Change invalidation to full rows to restore ligature drawing.
miniksa a15af9b
Add tests for til and round out the operators.
miniksa ac01c0b
code format
miniksa c478983
code format and audit mode.
miniksa f39b352
Dustin's suggestion about helper for invalidating rectangles .
miniksa 0d863c2
Fix selection issues.
miniksa ea8e379
Restore scrolling by appropriately scaling dirty rectangles from cell…
miniksa 1d72e6b
Don't redraw everything. We're competent enough at scrolling in the D…
miniksa 1d51d86
Report the delta when scroll buffer circles as there is no implicit v…
miniksa b8c66dd
Invalidate all with retro terminal effects experimental feature turne…
miniksa 1e5e4eb
Don't use incremental drawing parameters on the first frame. Just use…
miniksa 46e526c
Add compensation for High DPI. Not perfect but way better.
miniksa f11c7a1
Remove unused constructor in float. Add scale tests to Rectangle (rem…
miniksa 162b516
Tests for rectangle constructors from floats + code formatting pass.
miniksa 45f8144
change to constexpr
miniksa 351dc9c
GetClient for composition now uses size scale factor directly (and I …
miniksa d42f609
Adjust the present1/present logic so it will retry if present1 fails …
miniksa 3e060e6
Literally clear everything, including the gutters, when the complete …
miniksa 4eddc8d
Fix selection invalidation issues. This was always broken but the nat…
miniksa f22577d
Fix issue with algorithm around re-using known previous viewport as r…
miniksa f4b39ec
code format
miniksa 8abf479
Use GDI Classic measuring mode to eliminate blended half-pixels at th…
miniksa d0e6dd1
separate concerns between updating viewport and scrolling.
miniksa b06720a
Disable incremental for High DPI as it doesn't work with the implicit…
miniksa 1207e80
Put natural rendering back.
miniksa 24ecd5b
Actually lock in selection code so it doesn't pull the rug out from u…
miniksa 0d5cfc7
Adjust DxRenderer and TerminalControl to change the area of concern o…
miniksa e476e5c
Remove block on incremental rendering for High DPI. Remove scale comp…
miniksa f8b6b72
Merge branch 'master' into dev/miniksa/dpi
miniksa 05bd203
rearrange items in terminalcontrol to not show delta. use scaling on …
miniksa f4ddf1f
code format
miniksa d330a00
remember previous scale transform and resize/recreate if different.
miniksa 767f491
Run dpi change through the font trigger in render base.
miniksa 9a5d257
wpf: Save the scale for HWND as well (avoid flicker); fix HTML
DHowett ca7ccf3
uia: fix dip/dpx calculations now that controls are in DPX
DHowett 79fdf25
Merge branch 'master' into dev/miniksa/dpi
miniksa cbe389f
Various Differential Drawing fixes for #5345 (#5427)
zadjii-msft acb9f4c
Remove tests against internal rectangle in BitmapTests as it is no lo…
miniksa e11d6a7
Add some til tests for the til things that Mike introduced.
miniksa 3d4b978
Typo.
miniksa ec614ab
Code format.
miniksa 4094d9b
Audit mode noexcept/constexpr possible.
miniksa 4337cf5
oops, missed these two foundation structs.
miniksa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,52 +175,69 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation | |
auto fontArgs = winrt::make_self<FontInfoEventArgs>(); | ||
_CurrentFontInfoHandlers(*this, *fontArgs); | ||
|
||
const auto fontWidth = fontArgs->FontSize().Width; | ||
const auto fontHeight = fontArgs->FontSize().Height; | ||
const til::size fontSize{ til::math::flooring, fontArgs->FontSize() }; | ||
|
||
// Convert text buffer cursor position to client coordinate position within the window | ||
COORD clientCursorPos; | ||
clientCursorPos.X = ::base::ClampMul(_currentTerminalCursorPos.x(), ::base::ClampedNumeric<ptrdiff_t>(fontWidth)); | ||
clientCursorPos.Y = ::base::ClampMul(_currentTerminalCursorPos.y(), ::base::ClampedNumeric<ptrdiff_t>(fontHeight)); | ||
// Convert text buffer cursor position to client coordinate position | ||
// within the window. This point is in _pixels_ | ||
const til::point clientCursorPos{ _currentTerminalCursorPos * fontSize }; | ||
|
||
// position textblock to cursor position | ||
Canvas().SetLeft(TextBlock(), clientCursorPos.X); | ||
Canvas().SetTop(TextBlock(), clientCursorPos.Y); | ||
// Get scale factor for view | ||
const double scaleFactor = DisplayInformation::GetForCurrentView().RawPixelsPerViewPixel(); | ||
|
||
const til::point clientCursorInDips{ clientCursorPos / scaleFactor }; | ||
|
||
// Position our TextBlock at the cursor position | ||
Canvas().SetLeft(TextBlock(), clientCursorInDips.x<double>()); | ||
Canvas().SetTop(TextBlock(), clientCursorInDips.y<double>()); | ||
|
||
// calculate FontSize in pixels from Points | ||
const double fontSizePx = (fontSize.height<double>() * 72) / USER_DEFAULT_SCREEN_DPI; | ||
|
||
// calculate FontSize in pixels from DPIs | ||
const double fontSizePx = (fontHeight * 72) / USER_DEFAULT_SCREEN_DPI; | ||
TextBlock().FontSize(fontSizePx); | ||
// Make sure to unscale the font size to correct for DPI! XAML needs | ||
// things in DIPs, and the fontSize is in pixels. | ||
TextBlock().FontSize(fontSizePx / scaleFactor); | ||
Comment on lines
+196
to
+198
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (unrelated to this PR, more for discussion) Should we eventually do what we did with |
||
TextBlock().FontFamily(Media::FontFamily(fontArgs->FontFace())); | ||
|
||
const auto widthToTerminalEnd = _currentCanvasWidth - ::base::ClampedNumeric<double>(clientCursorPos.X); | ||
const auto widthToTerminalEnd = _currentCanvasWidth - clientCursorInDips.x<double>(); | ||
// Make sure that we're setting the MaxWidth to a positive number - a | ||
// negative number here will crash us in mysterious ways with a useless | ||
// stack trace | ||
const auto newMaxWidth = std::max<double>(0.0, widthToTerminalEnd); | ||
TextBlock().MaxWidth(newMaxWidth); | ||
|
||
// Get window in screen coordinates, this is the entire window including tabs | ||
const auto windowBounds = CoreWindow::GetForCurrentThread().Bounds(); | ||
// Get window in screen coordinates, this is the entire window including | ||
// tabs. THIS IS IN DIPs | ||
const auto windowBounds{ CoreWindow::GetForCurrentThread().Bounds() }; | ||
const til::point windowOrigin{ til::math::flooring, windowBounds }; | ||
|
||
// Convert from client coordinate to screen coordinate by adding window position | ||
COORD screenCursorPos; | ||
screenCursorPos.X = ::base::ClampAdd(clientCursorPos.X, ::base::ClampedNumeric<short>(windowBounds.X)); | ||
screenCursorPos.Y = ::base::ClampAdd(clientCursorPos.Y, ::base::ClampedNumeric<short>(windowBounds.Y)); | ||
// Get the offset (margin + tabs, etc..) of the control within the window | ||
const til::point controlOrigin{ til::math::flooring, | ||
this->TransformToVisual(nullptr).TransformPoint(Point(0, 0)) }; | ||
|
||
// get any offset (margin + tabs, etc..) of the control within the window | ||
const auto offsetPoint = this->TransformToVisual(nullptr).TransformPoint(winrt::Windows::Foundation::Point(0, 0)); | ||
// The controlAbsoluteOrigin is the origin of the control relative to | ||
// the origin of the displays. THIS IS IN DIPs | ||
const til::point controlAbsoluteOrigin{ windowOrigin + controlOrigin }; | ||
|
||
// add the margin offsets if any | ||
screenCursorPos.X = ::base::ClampAdd(screenCursorPos.X, ::base::ClampedNumeric<short>(offsetPoint.X)); | ||
screenCursorPos.Y = ::base::ClampAdd(screenCursorPos.Y, ::base::ClampedNumeric<short>(offsetPoint.Y)); | ||
// Convert the control origin to pixels | ||
const til::point scaledFrameOrigin = controlAbsoluteOrigin * scaleFactor; | ||
|
||
// Get scale factor for view | ||
const double scaleFactor = DisplayInformation::GetForCurrentView().RawPixelsPerViewPixel(); | ||
const auto yOffset = ::base::ClampedNumeric<float>(_currentTextBlockHeight) - fontHeight; | ||
const auto textBottom = ::base::ClampedNumeric<float>(screenCursorPos.Y) + yOffset; | ||
// Get the location of the cursor in the display, in pixels. | ||
til::point screenCursorPos{ scaledFrameOrigin + clientCursorPos }; | ||
|
||
// GH #5007 - make sure to account for wrapping the IME composition at | ||
// the right side of the viewport. | ||
const ptrdiff_t textBlockHeight = ::base::ClampMul(_currentTextBlockHeight, scaleFactor); | ||
|
||
// Get the bounds of the composition text, in pixels. | ||
const til::rectangle textBounds{ til::point{ screenCursorPos.x(), screenCursorPos.y() }, | ||
til::size{ 0, textBlockHeight } }; | ||
|
||
_currentTextBounds = textBounds; | ||
|
||
_currentTextBounds = ScaleRect(Rect(screenCursorPos.X, textBottom, 0, fontHeight), scaleFactor); | ||
_currentControlBounds = ScaleRect(Rect(screenCursorPos.X, screenCursorPos.Y, 0, fontHeight), scaleFactor); | ||
_currentControlBounds = Rect(screenCursorPos.x<float>(), | ||
screenCursorPos.y<float>(), | ||
0, | ||
fontSize.height<float>()); | ||
} | ||
|
||
// Method Description: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been out of the til::point/size loop for a bit, so correct me if I'm wrong. Can't this throw if we get an overflow?