summaryrefslogtreecommitdiff
path: root/indra/llrender/llfontvertexbuffer.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2026-07-16 19:22:02 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2026-07-16 19:22:02 +0300
commit72581ab99d2e891821f5266330ecd8a58a277eb7 (patch)
tree528629c8943a400bc1a6186b49cdabdb4b8ed507 /indra/llrender/llfontvertexbuffer.cpp
parentf5e788b1b4ff5fb45f20ee5fa5daad7cca42069f (diff)
parent1577ca1724787fdc0f0317ade3dab8ea3c5df7e7 (diff)
Merge branch 'release/26.3' into marchcat/slua-26.3
# Conflicts: # .github/workflows/build.yaml # autobuild.xml # indra/llcommon/llsys.cpp # indra/llrender/llimagegl.cpp # indra/llrender/llimagegl.h # indra/newview/CMakeLists.txt # indra/newview/featuretable.txt # indra/newview/featuretable_linux.txt # indra/newview/featuretable_mac.txt # indra/newview/llvoavatar.cpp # indra/newview/llvoiceclient.cpp # indra/newview/llvoicevivox.cpp # indra/newview/viewer_manifest.py
Diffstat (limited to 'indra/llrender/llfontvertexbuffer.cpp')
-rw-r--r--indra/llrender/llfontvertexbuffer.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/indra/llrender/llfontvertexbuffer.cpp b/indra/llrender/llfontvertexbuffer.cpp
index a223509d30..2a0115265f 100644
--- a/indra/llrender/llfontvertexbuffer.cpp
+++ b/indra/llrender/llfontvertexbuffer.cpp
@@ -237,3 +237,80 @@ void LLFontVertexBuffer::renderBuffers()
gGL.popUIMatrix();
}
+// LLFontWidthBuffer
+bool LLFontWidthBuffer::sEnableBufferCollection = true;
+
+LLFontWidthBuffer::LLFontWidthBuffer()
+{
+}
+
+LLFontWidthBuffer::~LLFontWidthBuffer()
+{
+}
+
+void LLFontWidthBuffer::reset()
+{
+ mLastFont = nullptr;
+ mLastOffset = 0;
+ mLastMaxChars = 0;
+ mLastNoPadding = false;
+ mWidth = -1.f;
+ mLastScaleX = 1.f;
+ mLastScaleY = 1.f;
+ mLastVertDPI = 0.f;
+ mLastHorizDPI = 0.f;
+ mLastResGeneration = 0;
+ mLastFontCacheGen = 0;
+}
+
+F32 LLFontWidthBuffer::getWidth(
+ const LLFontGL* fontp,
+ const llwchar* wchars,
+ S32 begin_offset,
+ S32 max_chars,
+ bool no_padding)
+{
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
+ if (!fontp || !wchars)
+ {
+ return 0.f;
+ }
+
+ if (!sEnableBufferCollection)
+ {
+ return fontp->getWidthF32(wchars, begin_offset, max_chars, no_padding);
+ }
+
+ // Check if we can use cached width
+ bool needs_recalc = (mWidth < 0.f)
+ || (mLastFont != fontp)
+ || (mLastOffset != begin_offset)
+ || (mLastMaxChars != max_chars)
+ || (mLastNoPadding != no_padding)
+ || (mLastScaleX != LLFontGL::sScaleX)
+ || (mLastScaleY != LLFontGL::sScaleY)
+ || (mLastVertDPI != LLFontGL::sVertDPI)
+ || (mLastHorizDPI != LLFontGL::sHorizDPI)
+ || (mLastResGeneration != LLFontGL::sResolutionGeneration)
+ || (mLastFontCacheGen != fontp->getCacheGeneration());
+
+ if (needs_recalc)
+ {
+ // Calculate width using the font
+ mWidth = fontp->getWidthF32(wchars, begin_offset, max_chars, no_padding);
+
+ // Cache the parameters
+ mLastFont = fontp;
+ mLastOffset = begin_offset;
+ mLastMaxChars = max_chars;
+ mLastNoPadding = no_padding;
+ mLastScaleX = LLFontGL::sScaleX;
+ mLastScaleY = LLFontGL::sScaleY;
+ mLastVertDPI = LLFontGL::sVertDPI;
+ mLastHorizDPI = LLFontGL::sHorizDPI;
+ mLastResGeneration = LLFontGL::sResolutionGeneration;
+ mLastFontCacheGen = fontp->getCacheGeneration();
+ }
+
+ return mWidth;
+}