-
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
AtlasEngine: Implement remaining underlines and builtin glyphs for D2D #17278
Conversation
@@ -1183,13 +1177,13 @@ void BuiltinGlyphs::DrawBuiltinGlyph(ID2D1Factory* factory, ID2D1DeviceContext* | |||
} | |||
case Shape_FilledEllipsis: | |||
{ | |||
const D2D1_ELLIPSE e{ { begXabs, begYabs }, endX, endY }; | |||
const D2D1_ELLIPSE e{ { rectX + begX, rectY + begY }, endX, endY }; |
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.
why this change? it doesn't take into account the line offsets any longer
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.
Filled shapes don't have any line width, so this will work just fine.
This change ensures that the rounded powerline glyphs aren't slightly cut off anymore.
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.
okay but the empty glyphs DO have a line width - how does this apply on line 1186R?
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.
(looks fine on my screen)
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.
Ah right. More generally speaking, the lineOffsetX/Y
code is only for snapping the coordinates of lines. In case of the "arc" shape glyph, this probably doesn't matter much because the entire glyph uses a lot of anti-aliasing anyway.
|
||
_curlyLineHalfHeight = height * 0.5f; | ||
_curlyUnderline.position = gsl::narrow_cast<u16>(lrintf(top)); | ||
_curlyUnderline.height = gsl::narrow_cast<u16>(lrintf(height)); | ||
_curlyUnderline.position = gsl::narrow_cast<u16>(position); |
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.
no more rounding - all this math now uses truncation. is that 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.
(I don't 100% know why the changes to the D3D backend were needed -- can you explain? Did you test them again at different font sizes and scalings?)
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 did this because I copied the code over to D2D. While doing so I noticed that this code doesn't actually do any floating point math whatsoever. As you can see I don't need to do any explicit integer/float casts anywhere in the preceding lines (which would normally be required during AuditMode). I changed the D3D part so that it's mostly identical to the D2D part.
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.
tested, can't turn em off!
@@ -1183,13 +1177,13 @@ void BuiltinGlyphs::DrawBuiltinGlyph(ID2D1Factory* factory, ID2D1DeviceContext* | |||
} | |||
case Shape_FilledEllipsis: | |||
{ | |||
const D2D1_ELLIPSE e{ { begXabs, begYabs }, endX, endY }; | |||
const D2D1_ELLIPSE e{ { rectX + begX, rectY + begY }, endX, endY }; |
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.
okay but the empty glyphs DO have a line width - how does this apply on line 1186R?
@@ -1183,13 +1177,13 @@ void BuiltinGlyphs::DrawBuiltinGlyph(ID2D1Factory* factory, ID2D1DeviceContext* | |||
} | |||
case Shape_FilledEllipsis: | |||
{ | |||
const D2D1_ELLIPSE e{ { begXabs, begYabs }, endX, endY }; | |||
const D2D1_ELLIPSE e{ { rectX + begX, rectY + begY }, endX, endY }; |
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.
(looks fine on my screen)
src/renderer/atlas/BackendD2D.cpp
Outdated
|
||
void BackendD2D::_prepareBuiltinGlyphRenderTarget(const RenderingPayload& p) | ||
{ | ||
if (!_builtinGlyphBatch || _builtinGlyphsRenderTarget) |
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.
if (!_builtinGlyphBatch || _builtinGlyphsRenderTarget) | |
if (!_builtinGlyphBatch || !_builtinGlyphsRenderTarget) |
(I'm only like half-understanding what's going on so correct me if I'm wrong) Wouldn't we want to exit early if _buildinGlyphsRenderTarget
is not defined? I see we overwrite it a few lines later. Curious.
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.
Ah, yeah that condition sucks. Let me split it apart and add comments!
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 be much better now!
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.
these comments are amazing
#17278) This implements builtin glyphs for our Direct2D renderer, as well as dashed and curly underlines. With this in place the only two features it doesn't support are inverted cursors and VT soft fonts. This allows us to remove the `_hack*` members introduced in a6a0e44. The implementation of dashed underlines is trivial, while curly underlines use quadratic bezier curves. Caching the curve as a sprite is possible, however I feel like that can be done in the future. Builtin glyphs on the other hand require a cache, because otherwise filling the entire viewport with shaded glyphs would result in poor performance. This is why it's built on top of `ID2D1SpriteBatch`. Unfortunately the API causes an eager flush of other pending graphics instructions, which is why there's still a decent perf hit. Finally, as a little extra, this fixes the rounded powerline glyph shapes being slightly cut off. The fix is to simply don't round the position and radius of the ellipsis/semi-circle. Closes #17224 ## Validation Steps Performed * RenderingTests.exe updated ✅ * All supported builtin glyphs look sorta right at different sizes ✅ (cherry picked from commit 3486111) Service-Card-Id: 92572076 Service-Version: 1.21
This implements builtin glyphs for our Direct2D renderer, as well as
dashed and curly underlines. With this in place the only two features
it doesn't support are inverted cursors and VT soft fonts.
This allows us to remove the
_hack*
members introduced in a6a0e44.The implementation of dashed underlines is trivial, while curly
underlines use quadratic bezier curves. Caching the curve as a sprite
is possible, however I feel like that can be done in the future.
Builtin glyphs on the other hand require a cache, because otherwise
filling the entire viewport with shaded glyphs would result in poor
performance. This is why it's built on top of
ID2D1SpriteBatch
.Unfortunately the API causes an eager flush of other pending graphics
instructions, which is why there's still a decent perf hit.
Finally, as a little extra, this fixes the rounded powerline glyph
shapes being slightly cut off. The fix is to simply don't round the
position and radius of the ellipsis/semi-circle.
Closes #17224
Validation Steps Performed