-
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
Reuse text layout for performance #2980
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,6 +26,8 @@ namespace Microsoft::Console::Render | |||||
const std::basic_string_view<::Microsoft::Console::Render::Cluster> clusters, | ||||||
size_t const width); | ||||||
|
||||||
void SetData(std::basic_string_view<Cluster> const clustor); | ||||||
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.
Suggested change
typo and didn't match cpp name |
||||||
|
||||||
[[nodiscard]] HRESULT STDMETHODCALLTYPE GetColumns(_Out_ UINT32* columns); | ||||||
|
||||||
// IDWriteTextLayout methods (but we don't actually want to implement them all, so just this one matching the existing interface) | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
#include "precomp.h" | ||
|
||
#include "DxRenderer.hpp" | ||
#include "CustomTextLayout.h" | ||
|
||
#include "../../interactivity/win32/CustomWindowMessages.h" | ||
#include "../../types/inc/Viewport.hpp" | ||
|
@@ -959,12 +958,20 @@ void DxEngine::_InvalidOr(RECT rc) noexcept | |
origin.y = static_cast<float>(coord.Y * _glyphCell.cy); | ||
|
||
// Create the text layout | ||
CustomTextLayout layout(_dwriteFactory.Get(), | ||
_dwriteTextAnalyzer.Get(), | ||
_dwriteTextFormat.Get(), | ||
_dwriteFontFace.Get(), | ||
clusters, | ||
_glyphCell.cx); | ||
if (_drawingTextLayout == nullptr) | ||
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. Nothing is invalidating the For instance, if 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. 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. 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. 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. And let’s also take a look at #2960 which is even more harmless but still powerful |
||
{ | ||
_drawingTextLayout = ::Microsoft::WRL::Details::Make<CustomTextLayout>(_dwriteFactory.Get(), | ||
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. Why is this |
||
_dwriteTextAnalyzer.Get(), | ||
_dwriteTextFormat.Get(), | ||
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. Should we be using |
||
_dwriteFontFace.Get(), | ||
clusters, | ||
_glyphCell.cx); | ||
} | ||
else | ||
{ | ||
_drawingTextLayout->SetData(clusters); | ||
} | ||
|
||
|
||
// Get the baseline for this font as that's where we draw from | ||
DWRITE_LINE_SPACING spacing; | ||
|
@@ -980,7 +987,7 @@ void DxEngine::_InvalidOr(RECT rc) noexcept | |
D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT); | ||
|
||
// Layout then render the text | ||
RETURN_IF_FAILED(layout.Draw(&context, _customRenderer.Get(), origin.x, origin.y)); | ||
RETURN_IF_FAILED(_drawingTextLayout->Draw(&context, _customRenderer.Get(), origin.x, origin.y)); | ||
} | ||
CATCH_RETURN(); | ||
|
||
|
@@ -1274,6 +1281,8 @@ enum class CursorPaintType | |
|
||
_glyphCell.cx = size.X; | ||
_glyphCell.cy = size.Y; | ||
|
||
_drawingTextLayout = nullptr; | ||
} | ||
CATCH_RETURN(); | ||
|
||
|
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.
Should probably also reset
_breakpoints
and_numberSubstitution
just for completeness.