From 4ae1de1f8a78d795958d67afab8356f9a13f707d Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 28 Aug 2024 23:05:58 +0300 Subject: viewer#2411 LLFontGL::render optimizations --- indra/llrender/llfontvertexbuffer.h | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 indra/llrender/llfontvertexbuffer.h (limited to 'indra/llrender/llfontvertexbuffer.h') diff --git a/indra/llrender/llfontvertexbuffer.h b/indra/llrender/llfontvertexbuffer.h new file mode 100644 index 0000000000..bd42cf6c2d --- /dev/null +++ b/indra/llrender/llfontvertexbuffer.h @@ -0,0 +1,85 @@ +/** + * @file llfontgl.h + * @author Andrii Kleshchev + * @brief Buffer storage for font rendering. + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFONTVERTEXBUFFER_H +#define LL_LLFONTVERTEXBUFFER_H + +#include "llfontgl.h" + +class LLVertexBuffer; + +class LLFontVertexBuffer +{ +public: + LLFontVertexBuffer(bool track_changes = true); + ~LLFontVertexBuffer(); + + void reset(); + + S32 render(const LLFontGL* fontp, + const LLWString& text, + S32 begin_offset, + F32 x, F32 y, + const LLColor4& color, + LLFontGL::HAlign halign = LLFontGL::LEFT, LLFontGL::VAlign valign = LLFontGL::BASELINE, + U8 style = LLFontGL::NORMAL, LLFontGL::ShadowType shadow = LLFontGL::NO_SHADOW, + S32 max_chars = S32_MAX, S32 max_pixels = S32_MAX, + F32* right_x = NULL, + bool use_ellipses = false, + bool use_color = true); + +private: + + void genBuffers(const LLFontGL* fontp, + const LLWString& text, + S32 begin_offset, + F32 x, F32 y, + const LLColor4& color, + LLFontGL::HAlign halign, LLFontGL::VAlign valign, + U8 style, LLFontGL::ShadowType shadow, + S32 max_chars, S32 max_pixels, + F32* right_x, + bool use_ellipses, + bool use_color); + + + std::list mBufferList; + S32 mChars = 0; + S32 mLastOffset = 0; + S32 mLastMaxChars = 0; + S32 mLastMaxPixels = 0; + size_t mLastStringHash = 0; + F32 mLastX = 0.f; + F32 mLastY = 0.f; + LLColor4 mLastColor; + F32 mLastRightX = 0.f; + bool mTrackStringChanges = true; + + static std::hash sStringHasher; +}; + +#endif -- cgit v1.2.3 From a638d9610d9f369eca6dff74e8860ca466c253c7 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 29 Aug 2024 18:49:10 +0300 Subject: viewer#2411 LLFontGL::render optimizations #2 --- indra/llrender/llfontvertexbuffer.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'indra/llrender/llfontvertexbuffer.h') diff --git a/indra/llrender/llfontvertexbuffer.h b/indra/llrender/llfontvertexbuffer.h index bd42cf6c2d..458b0a91bb 100644 --- a/indra/llrender/llfontvertexbuffer.h +++ b/indra/llrender/llfontvertexbuffer.h @@ -46,12 +46,14 @@ public: F32 x, F32 y, const LLColor4& color, LLFontGL::HAlign halign = LLFontGL::LEFT, LLFontGL::VAlign valign = LLFontGL::BASELINE, - U8 style = LLFontGL::NORMAL, LLFontGL::ShadowType shadow = LLFontGL::NO_SHADOW, + U8 style = LLFontGL::NORMAL, + LLFontGL::ShadowType shadow = LLFontGL::NO_SHADOW, S32 max_chars = S32_MAX, S32 max_pixels = S32_MAX, F32* right_x = NULL, bool use_ellipses = false, bool use_color = true); + typedef std::list buffer_list_t; private: void genBuffers(const LLFontGL* fontp, @@ -60,15 +62,18 @@ private: F32 x, F32 y, const LLColor4& color, LLFontGL::HAlign halign, LLFontGL::VAlign valign, - U8 style, LLFontGL::ShadowType shadow, + U8 style, + LLFontGL::ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, bool use_ellipses, bool use_color); + void renderBuffers(); - std::list mBufferList; + buffer_list_t mBufferList; S32 mChars = 0; + const LLFontGL *mLastFont = nullptr; S32 mLastOffset = 0; S32 mLastMaxChars = 0; S32 mLastMaxPixels = 0; @@ -76,6 +81,10 @@ private: F32 mLastX = 0.f; F32 mLastY = 0.f; LLColor4 mLastColor; + LLFontGL::HAlign mLastHalign = LLFontGL::LEFT; + LLFontGL::VAlign mLastValign = LLFontGL::BASELINE; + U8 mLastStyle = LLFontGL::NORMAL; + LLFontGL::ShadowType mLastShadow = LLFontGL::NO_SHADOW; F32 mLastRightX = 0.f; bool mTrackStringChanges = true; -- cgit v1.2.3 From 5c64e5e13d9a75cac510aac3128fc6ee780ab243 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 30 Aug 2024 18:51:48 +0300 Subject: viewer#2411 LLFontGL::render optimizations #3 --- indra/llrender/llfontvertexbuffer.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'indra/llrender/llfontvertexbuffer.h') diff --git a/indra/llrender/llfontvertexbuffer.h b/indra/llrender/llfontvertexbuffer.h index 458b0a91bb..7c29e1097b 100644 --- a/indra/llrender/llfontvertexbuffer.h +++ b/indra/llrender/llfontvertexbuffer.h @@ -30,7 +30,7 @@ #include "llfontgl.h" -class LLVertexBuffer; +class LLVertexBufferData; class LLFontVertexBuffer { @@ -52,8 +52,6 @@ public: F32* right_x = NULL, bool use_ellipses = false, bool use_color = true); - - typedef std::list buffer_list_t; private: void genBuffers(const LLFontGL* fontp, @@ -71,7 +69,7 @@ private: void renderBuffers(); - buffer_list_t mBufferList; + std::list mBufferList; S32 mChars = 0; const LLFontGL *mLastFont = nullptr; S32 mLastOffset = 0; @@ -86,6 +84,12 @@ private: U8 mLastStyle = LLFontGL::NORMAL; LLFontGL::ShadowType mLastShadow = LLFontGL::NO_SHADOW; F32 mLastRightX = 0.f; + + // LLFontGL's statics + F32 mLastScaleX = 1.f; + F32 mLastScaleY = 1.f; + LLCoordGL mLastOrigin; + bool mTrackStringChanges = true; static std::hash sStringHasher; -- cgit v1.2.3 From 57ab1a410f9cb3534bb403e034743505758579d8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 2 Sep 2024 13:46:13 +0300 Subject: viewer#2411 A bit more coverage for font buffer --- indra/llrender/llfontvertexbuffer.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'indra/llrender/llfontvertexbuffer.h') diff --git a/indra/llrender/llfontvertexbuffer.h b/indra/llrender/llfontvertexbuffer.h index 7c29e1097b..d41c6205ac 100644 --- a/indra/llrender/llfontvertexbuffer.h +++ b/indra/llrender/llfontvertexbuffer.h @@ -40,6 +40,32 @@ public: void reset(); + S32 render(const LLFontGL* fontp, + const LLWString& text, + S32 begin_offset, + LLRect rect, + const LLColor4& color, + LLFontGL::HAlign halign = LLFontGL::LEFT, LLFontGL::VAlign valign = LLFontGL::BASELINE, + U8 style = LLFontGL::NORMAL, + LLFontGL::ShadowType shadow = LLFontGL::NO_SHADOW, + S32 max_chars = S32_MAX, S32 max_pixels = S32_MAX, + F32* right_x = NULL, + bool use_ellipses = false, + bool use_color = true); + + S32 render(const LLFontGL* fontp, + const LLWString& text, + S32 begin_offset, + LLRectf rect, + const LLColor4& color, + LLFontGL::HAlign halign = LLFontGL::LEFT, LLFontGL::VAlign valign = LLFontGL::BASELINE, + U8 style = LLFontGL::NORMAL, + LLFontGL::ShadowType shadow = LLFontGL::NO_SHADOW, + S32 max_chars = S32_MAX, + F32* right_x = NULL, + bool use_ellipses = false, + bool use_color = true); + S32 render(const LLFontGL* fontp, const LLWString& text, S32 begin_offset, -- cgit v1.2.3 From 4cc0edb189c4deaa205f986d20a6959aa83fb25c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 2 Sep 2024 22:14:42 +0300 Subject: viewer#2411 Cleanup --- indra/llrender/llfontvertexbuffer.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'indra/llrender/llfontvertexbuffer.h') diff --git a/indra/llrender/llfontvertexbuffer.h b/indra/llrender/llfontvertexbuffer.h index d41c6205ac..67cf2ca13c 100644 --- a/indra/llrender/llfontvertexbuffer.h +++ b/indra/llrender/llfontvertexbuffer.h @@ -35,7 +35,7 @@ class LLVertexBufferData; class LLFontVertexBuffer { public: - LLFontVertexBuffer(bool track_changes = true); + LLFontVertexBuffer(); ~LLFontVertexBuffer(); void reset(); @@ -101,7 +101,6 @@ private: S32 mLastOffset = 0; S32 mLastMaxChars = 0; S32 mLastMaxPixels = 0; - size_t mLastStringHash = 0; F32 mLastX = 0.f; F32 mLastY = 0.f; LLColor4 mLastColor; @@ -115,10 +114,6 @@ private: F32 mLastScaleX = 1.f; F32 mLastScaleY = 1.f; LLCoordGL mLastOrigin; - - bool mTrackStringChanges = true; - - static std::hash sStringHasher; }; #endif -- cgit v1.2.3