-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
AtlasEngine: Implement remaining grid lines #13587
Changes from 4 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 |
---|---|---|
|
@@ -394,14 +394,17 @@ namespace Microsoft::Console::Render | |
struct FontMetrics | ||
{ | ||
wil::com_ptr<IDWriteFontCollection> fontCollection; | ||
wil::unique_process_heap_string fontName; | ||
std::wstring fontName; | ||
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. whhhyy? 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.
|
||
float baselineInDIP = 0.0f; | ||
float fontSizeInDIP = 0.0f; | ||
u16x2 cellSize; | ||
u16 fontWeight = 0; | ||
u16 underlinePos = 0; | ||
u16 underlineWidth = 0; | ||
u16 strikethroughPos = 0; | ||
u16 lineThickness = 0; | ||
u16 strikethroughWidth = 0; | ||
u16x2 doubleUnderlinePos; | ||
u16 thinLineWidth = 0; | ||
}; | ||
|
||
// These flags are shared with shader_ps.hlsl. | ||
|
@@ -823,8 +826,12 @@ namespace Microsoft::Console::Render | |
alignas(sizeof(f32)) f32 enhancedContrast = 0; | ||
alignas(sizeof(u32)) u32 cellCountX = 0; | ||
alignas(sizeof(u32x2)) u32x2 cellSize; | ||
alignas(sizeof(u32x2)) u32x2 underlinePos; | ||
alignas(sizeof(u32x2)) u32x2 strikethroughPos; | ||
alignas(sizeof(u32)) u32 underlinePos = 0; | ||
alignas(sizeof(u32)) u32 underlineWidth = 0; | ||
alignas(sizeof(u32)) u32 strikethroughPos = 0; | ||
alignas(sizeof(u32)) u32 strikethroughWidth = 0; | ||
alignas(sizeof(u32x2)) u32x2 doubleUnderlinePos; | ||
alignas(sizeof(u32)) u32 thinLineWidth = 0; | ||
alignas(sizeof(u32)) u32 backgroundColor = 0; | ||
alignas(sizeof(u32)) u32 cursorColor = 0; | ||
alignas(sizeof(u32)) u32 selectionColor = 0; | ||
|
@@ -943,12 +950,9 @@ namespace Microsoft::Console::Render | |
Buffer<Cell, 32> cells; // invalidated by ApiInvalidations::Size | ||
Buffer<TileHashMap::iterator> cellGlyphMapping; // invalidated by ApiInvalidations::Size | ||
f32x2 cellSizeDIP; // invalidated by ApiInvalidations::Font, caches _api.cellSize but in DIP | ||
u16x2 cellSize; // invalidated by ApiInvalidations::Font, caches _api.cellSize | ||
u16x2 cellCount; // invalidated by ApiInvalidations::Font|Size, caches _api.cellCount | ||
u16 underlinePos = 0; | ||
u16 strikethroughPos = 0; | ||
u16 lineThickness = 0; | ||
u16 dpi = USER_DEFAULT_SCREEN_DPI; // invalidated by ApiInvalidations::Font, caches _api.dpi | ||
FontMetrics fontMetrics; // invalidated by ApiInvalidations::Font, cached _api.fontMetrics | ||
u16x2 atlasSizeInPixel; // invalidated by ApiInvalidations::Font | ||
TileHashMap glyphs; | ||
TileAllocator tileAllocator; | ||
|
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.
all throwing -- OK?
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.
Technically I only want to throw if the result is out of bounds for an
uint16_t
. This code should work becausefloat
s can represent 16-bit integers exactly (i.e. converting back and forth yields the same result). I could convert them toint32_t
first and then do the narrowing, e.g. withlround
. What do you think?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.
Whatever you think strikes the best clarity vs work balance. This is fine with me :)
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.
Is this perhaps being unnecessarily cautious? I means is there any scenario here where a simple
narrow_cast
would actually produce a worse outcome than a throw?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.
Personally, I tend to prefer
gsl::narrow
overgsl::narrow_cast
unless I need the latter for performance or exception safety (or I just want narrowing). I don't think the cost of the narrowing check is particularly high in most cases, so I'm fine with it.In this case I'm a bit afraid that these values could be negative or larger than
UINT16_MAX
(since they come from the font file which might specify anything). I'll probably modify this PR to usegsl::narrow<u16>(lroundf(...))
which is even more excessively cautious, but it avoids any potential rounding errors, while catching any weird behavior (e.g. font size of >9000 leads to cell size >65536) and is fast enough (this code is only called once and eachlroundf
is <10ns).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.
What I was getting at is say you have some kind of overflow, and your underline position is now so large that it's off screen, is that a big deal? Is it likely to crash? If not, and the alternative is that the font just doesn't work at all, it doesn't seem like the
narrow_cast
is really an improvement. But it's not important. It was just a passing thought.