Merge pull request #7733 from Robyt3/Textrender-Selection-Quad-Reuse

More efficient text selection rendering
This commit is contained in:
Dennis Felsing 2023-12-27 23:13:49 +00:00 committed by GitHub
commit 02331d1986
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1532,6 +1532,7 @@ public:
const float CursorOuterInnerDiff = (CursorOuterWidth - CursorInnerWidth) / 2;
std::vector<IGraphics::CQuadItem> vSelectionQuads;
int SelectionQuadLine = -1;
bool SelectionStarted = false;
bool SelectionUsedPress = false;
bool SelectionUsedRelease = false;
@ -1866,8 +1867,18 @@ public:
if(SelectionStarted && IsRendered)
{
const float SelectionHeight = pCursor->m_AlignedFontSize + pCursor->m_AlignedLineSpacing;
vSelectionQuads.emplace_back(SelX, DrawY + (1.0f - pCursor->m_SelectionHeightFactor) * SelectionHeight, SelWidth, pCursor->m_SelectionHeightFactor * SelectionHeight);
if(!vSelectionQuads.empty() && SelectionQuadLine == pCursor->m_LineCount)
{
vSelectionQuads.back().m_Width += SelWidth;
}
else
{
const float SelectionHeight = pCursor->m_AlignedFontSize + pCursor->m_AlignedLineSpacing;
const float SelectionY = DrawY + (1.0f - pCursor->m_SelectionHeightFactor) * SelectionHeight;
const float ScaledSelectionHeight = pCursor->m_SelectionHeightFactor * SelectionHeight;
vSelectionQuads.emplace_back(SelX, SelectionY, SelWidth, ScaledSelectionHeight);
SelectionQuadLine = pCursor->m_LineCount;
}
}
LastSelX = SelX;