From 400c21213acb050b653247f295975b9ab35b62ad Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Fri, 30 Aug 2024 00:48:02 +0200 Subject: [PATCH 01/19] #2454 Scrolling by the mouse wheel does not scroll up on the unopened Destination field --- indra/llui/llcombobox.cpp | 96 ++++++++++++++++++++++++++++----- indra/llui/llcombobox.h | 5 +- indra/llui/llscrolllistctrl.cpp | 22 ++++---- 3 files changed, 96 insertions(+), 27 deletions(-) diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index ee1700e009..6e2af4c853 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -498,9 +498,9 @@ void LLComboBox::setButtonVisible(bool visible) } } -bool LLComboBox::setCurrentByIndex( S32 index ) +bool LLComboBox::setCurrentByIndex(S32 index) { - bool found = mList->selectNthItem( index ); + bool found = mList->selectNthItem(index); if (found) { setLabel(getSelectedItemLabel()); @@ -511,14 +511,53 @@ bool LLComboBox::setCurrentByIndex( S32 index ) S32 LLComboBox::getCurrentIndex() const { - LLScrollListItem* item = mList->getFirstSelected(); - if( item ) + if (LLScrollListItem* item = mList->getFirstSelected()) { - return mList->getItemIndex( item ); + return mList->getItemIndex(item); } return -1; } +bool LLComboBox::selectNextItem() +{ + S32 last_index = getItemCount() - 1; + if (last_index < 0) + return false; + + S32 current_index = getCurrentIndex(); + if (current_index >= last_index) + return false; + + S32 new_index = llmax(current_index, -1); + while (++new_index <= last_index) + { + if (setCurrentByIndex(new_index)) + return true; + } + + return false; +} + +bool LLComboBox::selectPrevItem() +{ + S32 last_index = getItemCount() - 1; + if (last_index < 0) + return false; + + S32 current_index = getCurrentIndex(); + if (!current_index) + return false; + + S32 new_index = current_index > 0 ? current_index : last_index + 1; + while (--new_index >= 0) + { + if (setCurrentByIndex(new_index)) + return true; + } + + return false; +} + void LLComboBox::setEnabledByValue(const LLSD& value, bool enabled) { LLScrollListItem *found = mList->getItem(value); @@ -878,15 +917,46 @@ bool LLComboBox::handleUnicodeCharHere(llwchar uni_char) // virtual bool LLComboBox::handleScrollWheel(S32 x, S32 y, S32 clicks) { - if (mList->getVisible()) return mList->handleScrollWheel(x, y, clicks); - if (mAllowTextEntry) // We might be editable - if (!mList->getFirstSelected()) // We aren't in the list, don't kill their text - return false; + if (mList->getVisible()) + { + return mList->handleScrollWheel(x, y, clicks); + } - setCurrentByIndex(llclamp(getCurrentIndex() + clicks, 0, getItemCount() - 1)); - prearrangeList(); - onCommit(); - return true; + if (mAllowTextEntry) // We might be editable + { + if (!mList->getFirstSelected()) // We aren't in the list, don't kill their text + { + return false; + } + } + + S32 current_index = getCurrentIndex(); + if (clicks > 0) + { + for (S32 i = 0; i < clicks; ++i) + { + if (!selectNextItem()) + break; + } + } + else + { + for (S32 i = 0; i < -clicks; ++i) + { + if (!selectPrevItem()) + break; + } + } + S32 new_index = getCurrentIndex(); + + if (new_index != current_index) + { + prearrangeList(); + onCommit(); + return true; + } + + return false; } void LLComboBox::setTextEntry(const LLStringExplicit& text) diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index 9dc6fa9257..8be3eb57e4 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -163,9 +163,12 @@ public: bool remove(const std::string& name); // remove item "name", return true if found and removed - bool setCurrentByIndex( S32 index ); + bool setCurrentByIndex(S32 index); S32 getCurrentIndex() const; + bool selectNextItem(); + bool selectPrevItem(); + void setEnabledByValue(const LLSD& value, bool enabled); void createLineEditor(const Params&); diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index e711a6ed1b..5ae133a075 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -889,13 +889,13 @@ bool LLScrollListCtrl::selectFirstItem() // Deselects all other items // virtual -bool LLScrollListCtrl::selectNthItem( S32 target_index ) +bool LLScrollListCtrl::selectNthItem(S32 target_index) { return selectItemRange(target_index, target_index); } // virtual -bool LLScrollListCtrl::selectItemRange( S32 first_index, S32 last_index ) +bool LLScrollListCtrl::selectItemRange(S32 first_index, S32 last_index) { if (mItemList.empty()) { @@ -905,28 +905,24 @@ bool LLScrollListCtrl::selectItemRange( S32 first_index, S32 last_index ) // make sure sort is up to date updateSort(); - S32 listlen = (S32)mItemList.size(); - first_index = llclamp(first_index, 0, listlen-1); - - if (last_index < 0) - last_index = listlen-1; - else - last_index = llclamp(last_index, first_index, listlen-1); + S32 bottom = (S32)mItemList.size() - 1; + first_index = llclamp(first_index, 0, bottom); + last_index = last_index < 0 ? bottom : llclamp(last_index, first_index, bottom); bool success = false; S32 index = 0; for (item_list::iterator iter = mItemList.begin(); iter != mItemList.end(); ) { LLScrollListItem *itemp = *iter; - if(!itemp) + if (!itemp) { iter = mItemList.erase(iter); - continue ; + continue; } - if( index >= first_index && index <= last_index ) + if (index >= first_index && index <= last_index) { - if( itemp->getEnabled() ) + if (itemp->getEnabled()) { // TODO: support range selection for cells selectItem(itemp, -1, false); From 60142c1b2fa7961d6dbf9744ad1b5c78f956d7f5 Mon Sep 17 00:00:00 2001 From: AiraYumi Date: Fri, 30 Aug 2024 23:35:19 +0900 Subject: [PATCH 02/19] update OpenJPEG 2.5.2 (#2452) --- autobuild.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autobuild.xml b/autobuild.xml index 795eca92c9..f90f114601 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -2099,11 +2099,11 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors archive hash - c16deaf773cb2a5d001732122ee3ec74db1dceeb + 76444e37be0cfccdbb5921370ba150ded2bf3c59 hash_algorithm sha1 url - https://github.com/secondlife/3p-openjpeg/releases/download/v2.5.0.ea12248/openjpeg-2.5.0.ea12248-darwin64-ea12248.tar.zst + https://github.com/secondlife/3p-openjpeg/releases/download/v2.5.2-r1/openjpeg-2.5.2.10604495243-darwin64-10604495243.tar.zst name darwin64 @@ -2113,11 +2113,11 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors archive hash - 8c277dde6076fb682cb07264dd70f6f2298b633f + 6bd289a9c4564b80369ce40ecbb24a213c2732ff hash_algorithm sha1 url - https://github.com/secondlife/3p-openjpeg/releases/download/v2.5.0.ea12248/openjpeg-2.5.0.ea12248-linux64-ea12248.tar.zst + https://github.com/secondlife/3p-openjpeg/releases/download/v2.5.2-r1/openjpeg-2.5.2.10604495243-linux64-10604495243.tar.zst name linux64 @@ -2127,11 +2127,11 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors archive hash - 2abf9535adf21ebdf2295f8a680300432abe6280 + 5e6e0180adc01e07438cb98daec96543b5d85019 hash_algorithm sha1 url - https://github.com/secondlife/3p-openjpeg/releases/download/v2.5.0.ea12248/openjpeg-2.5.0.ea12248-windows64-ea12248.tar.zst + https://github.com/secondlife/3p-openjpeg/releases/download/v2.5.2-r1/openjpeg-2.5.2.10604495243-windows64-10604495243.tar.zst name windows64 From 89a45ef1cba9969b844d82da6ff2a751a5c35ef1 Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Fri, 30 Aug 2024 19:17:36 +0200 Subject: [PATCH 03/19] Fix background folder fetch pushing requests to wrong queue (#2436) --- .../llinventorymodelbackgroundfetch.cpp | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 9cb94b313e..8a0dd2c0a9 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -201,7 +201,7 @@ LLInventoryModelBackgroundFetch::LLInventoryModelBackgroundFetch(): LLInventoryModelBackgroundFetch::~LLInventoryModelBackgroundFetch() { - gIdleCallbacks.deleteFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + gIdleCallbacks.deleteFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } bool LLInventoryModelBackgroundFetch::isBulkFetchProcessingComplete() const @@ -241,7 +241,7 @@ bool LLInventoryModelBackgroundFetch::inventoryFetchCompleted() const bool LLInventoryModelBackgroundFetch::inventoryFetchInProgress() const { - return inventoryFetchStarted() && ! inventoryFetchCompleted(); + return inventoryFetchStarted() && !inventoryFetchCompleted(); } bool LLInventoryModelBackgroundFetch::isEverythingFetched() const @@ -254,35 +254,35 @@ bool LLInventoryModelBackgroundFetch::folderFetchActive() const return mFolderFetchActive; } -void LLInventoryModelBackgroundFetch::addRequestAtFront(const LLUUID & id, bool recursive, bool is_category) +void LLInventoryModelBackgroundFetch::addRequestAtFront(const LLUUID& id, bool recursive, bool is_category) { EFetchType recursion_type = recursive ? FT_RECURSIVE : FT_DEFAULT; if (is_category) { - mFetchFolderQueue.push_front(FetchQueueInfo(id, recursion_type, is_category)); + mFetchFolderQueue.emplace_front(id, recursion_type, is_category); } else { - mFetchItemQueue.push_front(FetchQueueInfo(id, recursion_type, is_category)); + mFetchItemQueue.emplace_front(id, recursion_type, is_category); } } -void LLInventoryModelBackgroundFetch::addRequestAtBack(const LLUUID & id, bool recursive, bool is_category) +void LLInventoryModelBackgroundFetch::addRequestAtBack(const LLUUID& id, bool recursive, bool is_category) { EFetchType recursion_type = recursive ? FT_RECURSIVE : FT_DEFAULT; if (is_category) { - mFetchFolderQueue.push_back(FetchQueueInfo(id, recursion_type, is_category)); + mFetchFolderQueue.emplace_back(id, recursion_type, is_category); } else { - mFetchItemQueue.push_back(FetchQueueInfo(id, recursion_type, is_category)); + mFetchItemQueue.emplace_back(id, recursion_type, is_category); } } void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) { - LLViewerInventoryCategory * cat(gInventory.getCategory(id)); + LLViewerInventoryCategory* cat(gInventory.getCategory(id)); if (cat || (id.isNull() && ! isEverythingFetched())) { @@ -294,7 +294,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) EFetchType recursion_type = recursive ? FT_RECURSIVE : FT_DEFAULT; if (id.isNull()) { - if (! mRecursiveInventoryFetchStarted) + if (!mRecursiveInventoryFetchStarted) { mRecursiveInventoryFetchStarted |= recursive; if (recursive && AISAPI::isAvailable()) @@ -302,19 +302,19 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) // Not only root folder can be massive, but // most system folders will be requested independently // so request root folder and content separately - mFetchFolderQueue.push_front(FetchQueueInfo(gInventory.getRootFolderID(), FT_FOLDER_AND_CONTENT)); + mFetchFolderQueue.emplace_front(gInventory.getRootFolderID(), FT_FOLDER_AND_CONTENT); } else { - mFetchFolderQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursion_type)); + mFetchFolderQueue.emplace_back(gInventory.getRootFolderID(), recursion_type); } - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } - if (! mRecursiveLibraryFetchStarted) + if (!mRecursiveLibraryFetchStarted) { mRecursiveLibraryFetchStarted |= recursive; - mFetchFolderQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursion_type)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + mFetchFolderQueue.emplace_back(gInventory.getLibraryRootFolderID(), recursion_type); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } } else if (recursive && cat && cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_LISTINGS) @@ -324,13 +324,13 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) if (recursive && AISAPI::isAvailable()) { // Request marketplace folder and content separately - mFetchFolderQueue.push_front(FetchQueueInfo(id, FT_FOLDER_AND_CONTENT)); + mFetchFolderQueue.emplace_front(id, FT_FOLDER_AND_CONTENT); } else { - mFetchFolderQueue.push_front(FetchQueueInfo(id, recursion_type)); + mFetchFolderQueue.emplace_front(id, recursion_type); } - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); mRecursiveMarketplaceFetchStarted = true; } } @@ -342,15 +342,15 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) { // On AIS make sure root goes to the top and follow up recursive // fetches, not individual requests - mFetchFolderQueue.push_back(FetchQueueInfo(id, recursion_type)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + mFetchFolderQueue.emplace_back(id, recursion_type); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } } else if (mFetchFolderQueue.empty() || mFetchFolderQueue.front().mUUID != id) { - // Specific folder requests go to front of queue. - mFetchFolderQueue.push_front(FetchQueueInfo(id, recursion_type)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + // Specific folder requests go to front of queue. + mFetchFolderQueue.emplace_front(id, recursion_type); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } if (id == gInventory.getLibraryRootFolderID()) @@ -363,9 +363,9 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& id, bool recursive) } } } - else if (LLViewerInventoryItem * itemp = gInventory.getItem(id)) + else if (LLViewerInventoryItem* itemp = gInventory.getItem(id)) { - if (! itemp->mIsComplete) + if (!itemp->mIsComplete) { scheduleItemFetch(id); } @@ -384,18 +384,18 @@ void LLInventoryModelBackgroundFetch::scheduleFolderFetch(const LLUUID& cat_id, // check if already requested if (mForceFetchSet.find(cat_id) == mForceFetchSet.end()) { - mForceFetchSet.insert(cat_id); - mFetchItemQueue.push_front(FetchQueueInfo(cat_id, FT_FORCED)); + mForceFetchSet.emplace(cat_id); + mFetchFolderQueue.emplace_front(cat_id, FT_FORCED); } } else { // Specific folder requests go to front of queue. // version presence acts as dupplicate prevention for normal fetches - mFetchItemQueue.push_front(FetchQueueInfo(cat_id, FT_DEFAULT)); + mFetchFolderQueue.emplace_front(cat_id, FT_DEFAULT); } - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } } @@ -409,17 +409,17 @@ void LLInventoryModelBackgroundFetch::scheduleItemFetch(const LLUUID& item_id, b // check if already requested if (mForceFetchSet.find(item_id) == mForceFetchSet.end()) { - mForceFetchSet.insert(item_id); - mFetchItemQueue.push_front(FetchQueueInfo(item_id, FT_FORCED, false)); + mForceFetchSet.emplace(item_id); + mFetchItemQueue.emplace_front(item_id, FT_FORCED, false); } } else { // 'isFinished' being set acts as dupplicate prevention for normal fetches - mFetchItemQueue.push_front(FetchQueueInfo(item_id, FT_DEFAULT, false)); + mFetchItemQueue.emplace_front(item_id, FT_DEFAULT, false); } - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } } @@ -432,7 +432,7 @@ void LLInventoryModelBackgroundFetch::fetchFolderAndLinks(const LLUUID& cat_id, cat->setFetching(LLViewerInventoryCategory::FETCH_RECURSIVE); } incrFetchFolderCount(1); - mExpectedFolderIds.push_back(cat_id); + mExpectedFolderIds.emplace_back(cat_id); // Assume that we have no relevant cache. Fetch folder, and items folder's links point to. AISAPI::FetchCategoryLinks(cat_id, @@ -462,7 +462,7 @@ void LLInventoryModelBackgroundFetch::fetchCOF(nullary_func_t callback) cat->setFetching(LLViewerInventoryCategory::FETCH_RECURSIVE); } incrFetchFolderCount(1); - mExpectedFolderIds.push_back(cat_id); + mExpectedFolderIds.emplace_back(cat_id); // For reliability assume that we have no relevant cache, so // fetch cof along with items cof's links point to. AISAPI::FetchCOF([callback](const LLUUID& id) @@ -475,15 +475,15 @@ void LLInventoryModelBackgroundFetch::fetchCOF(nullary_func_t callback) // start idle loop to track completion mBackgroundFetchActive = true; mFolderFetchActive = true; - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } void LLInventoryModelBackgroundFetch::findLostItems() { mBackgroundFetchActive = true; mFolderFetchActive = true; - mFetchFolderQueue.push_back(FetchQueueInfo(LLUUID::null, FT_RECURSIVE)); - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + mFetchFolderQueue.emplace_back(LLUUID::null, FT_RECURSIVE); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } void LLInventoryModelBackgroundFetch::setAllFoldersFetched() From 9004cf64bf5066a778eea39a4ab48623b04c6d42 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Fri, 30 Aug 2024 10:57:44 -0700 Subject: [PATCH 04/19] secondlife/viewer#2448: Fix crash rendering rigged PBR prims --- indra/newview/lldrawpoolpbropaque.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 4ea23412e6..07f8ccb549 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -62,8 +62,9 @@ void LLDrawPoolGLTFPBR::renderDeferred(S32 pass) gDeferredPBROpaqueProgram.bind(); pushGLTFBatches(mRenderType); - gDeferredPBROpaqueProgram.bind(true); LL::GLTFSceneManager::instance().render(true, true); + + gDeferredPBROpaqueProgram.bind(true); pushRiggedGLTFBatches(mRenderType + 1); } From 5b832291a8ea1f100e2caaffef3d162dd96bee50 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Fri, 30 Aug 2024 12:49:05 -0700 Subject: [PATCH 05/19] Introduce Khronos Neutral tonemapper as new default along with debug options to control tonemap mix (#2464) (#2468) --- indra/newview/app_settings/settings.xml | 22 ++++++++ .../deferred/postDeferredGammaCorrect.glsl | 2 - .../class1/deferred/postDeferredTonemap.glsl | 52 ++++++++++++++----- indra/newview/pipeline.cpp | 10 +++- 4 files changed, 70 insertions(+), 16 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index d2c3c96317..a52d21edb5 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9832,6 +9832,28 @@ Value 0.4 + RenderTonemapMix + + Comment + Mix between linear and tonemapped colors (0.0(Linear) - 1.0(Tonemapped) + Persist + 1 + Type + F32 + Value + 1.0 + + RenderTonemapType + + Comment + What tonemapper to use: 0 = Khronos Neutral, 1 = ACES + Persist + 1 + Type + U32 + Value + 0 + ReplaySession Comment diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 0673159ab7..befd2ae6da 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -29,9 +29,7 @@ out vec4 frag_color; uniform sampler2D diffuseRect; -uniform float exposure; uniform float gamma; -uniform float aces_mix; uniform vec2 screen_res; in vec2 vary_fragcoord; diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredTonemap.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredTonemap.glsl index c16ab2f9c4..fc6d4d7727 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredTonemap.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredTonemap.glsl @@ -95,9 +95,33 @@ vec3 toneMapACES_Hill(vec3 color) return color; } +// Khronos Neutral tonemapping +// https://github.com/KhronosGroup/ToneMapping/tree/main +// Input color is non-negative and resides in the Linear Rec. 709 color space. +// Output color is also Linear Rec. 709, but in the [0, 1] range. +vec3 PBRNeutralToneMapping( vec3 color ) +{ + const float startCompression = 0.8 - 0.04; + const float desaturation = 0.15; + + float x = min(color.r, min(color.g, color.b)); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + + float peak = max(color.r, max(color.g, color.b)); + if (peak < startCompression) return color; + + const float d = 1. - startCompression; + float newPeak = 1. - d * d / (peak + d - startCompression); + color *= newPeak / peak; + + float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.); + return mix(color, newPeak * vec3(1, 1, 1), g); +} + uniform float exposure; -uniform float gamma; -uniform float aces_mix; +uniform float tonemap_mix; +uniform int tonemap_type; vec3 toneMap(vec3 color) { @@ -106,8 +130,20 @@ vec3 toneMap(vec3 color) color *= exposure * exp_scale; - // mix ACES and Linear here as a compromise to avoid over-darkening legacy content - color = mix(toneMapACES_Hill(color), color, aces_mix); + vec3 clamped_color = clamp(color.rgb, vec3(0.0), vec3(1.0)); + + switch(tonemap_type) + { + case 0: + color = PBRNeutralToneMapping(color); + break; + case 1: + color = toneMapACES_Hill(color); + break; + } + + // mix tonemapped and linear here to provide adjustment + color = mix(clamped_color, color, tonemap_mix); #endif return color; @@ -125,14 +161,6 @@ void debugExposure(inout vec3 color) } } -vec3 legacyGamma(vec3 color) -{ - vec3 c = 1. - clamp(color, vec3(0.), vec3(1.)); - c = 1. - pow(c, vec3(gamma)); // s/b inverted already CPU-side - - return c; -} - void main() { //this is the one of the rare spots where diffuseRect contains linear color values (not sRGB) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 91ade0eef1..3b1da8668b 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7087,10 +7087,16 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst) F32 e = llclamp(exposure(), 0.5f, 4.f); static LLStaticHashedString s_exposure("exposure"); - static LLStaticHashedString aces_mix("aces_mix"); + static LLStaticHashedString tonemap_mix("tonemap_mix"); + static LLStaticHashedString tonemap_type("tonemap_type"); shader.uniform1f(s_exposure, e); - shader.uniform1f(aces_mix, gEXRImage.notNull() ? 0.f : 0.3f); + + static LLCachedControl tonemap_type_setting(gSavedSettings, "RenderTonemapType", 0U); + shader.uniform1i(tonemap_type, tonemap_type_setting); + + static LLCachedControl tonemap_mix_setting(gSavedSettings, "RenderTonemapMix", 1.f); + shader.uniform1f(tonemap_mix, tonemap_mix_setting); mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); From 12d60b3d9b15adc1d6a04eaacd65c71829b73c38 Mon Sep 17 00:00:00 2001 From: TJ Date: Tue, 3 Sep 2024 05:51:58 +1000 Subject: [PATCH 06/19] More styling fixes and other minor inconsistency fixes in inventorymodelbackgroundfetch code. (#2476) --- .../llinventorymodelbackgroundfetch.cpp | 162 +++++++++--------- .../newview/llinventorymodelbackgroundfetch.h | 10 +- 2 files changed, 86 insertions(+), 86 deletions(-) diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 8a0dd2c0a9..d8e6bf380e 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -113,7 +113,7 @@ class BGItemHttpHandler : public LLInventoryModel::FetchItemHttpHandler LOG_CLASS(BGItemHttpHandler); public: - BGItemHttpHandler(const LLSD & request_sd) + BGItemHttpHandler(const LLSD& request_sd) : LLInventoryModel::FetchItemHttpHandler(request_sd) { LLInventoryModelBackgroundFetch::instance().incrFetchCount(1); @@ -125,8 +125,8 @@ public: } protected: - BGItemHttpHandler(const BGItemHttpHandler &); // Not defined - void operator=(const BGItemHttpHandler &); // Not defined + BGItemHttpHandler(const BGItemHttpHandler&); // Not defined + void operator=(const BGItemHttpHandler&); // Not defined }; @@ -144,7 +144,7 @@ class BGFolderHttpHandler : public LLCore::HttpHandler LOG_CLASS(BGFolderHttpHandler); public: - BGFolderHttpHandler(const LLSD & request_sd, const uuid_vec_t & recursive_cats) + BGFolderHttpHandler(const LLSD& request_sd, const uuid_vec_t& recursive_cats) : LLCore::HttpHandler(), mRequestSD(request_sd), mRecursiveCatUUIDs(recursive_cats) @@ -158,18 +158,18 @@ public: } protected: - BGFolderHttpHandler(const BGFolderHttpHandler &); // Not defined - void operator=(const BGFolderHttpHandler &); // Not defined + BGFolderHttpHandler(const BGFolderHttpHandler&); // Not defined + void operator=(const BGFolderHttpHandler&); // Not defined public: - virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); + virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse* response); - bool getIsRecursive(const LLUUID & cat_id) const; + bool getIsRecursive(const LLUUID& cat_id) const; private: - void processData(LLSD & body, LLCore::HttpResponse * response); - void processFailure(LLCore::HttpStatus status, LLCore::HttpResponse * response); - void processFailure(const char * const reason, LLCore::HttpResponse * response); + void processData(LLSD& body, LLCore::HttpResponse* response); + void processFailure(LLCore::HttpStatus status, LLCore::HttpResponse* response); + void processFailure(const char* const reason, LLCore::HttpResponse* response); private: LLSD mRequestSD; @@ -177,7 +177,7 @@ private: }; -const char * const LOG_INV("Inventory"); +const char* const LOG_INV("Inventory"); } // end of namespace anonymous @@ -391,7 +391,7 @@ void LLInventoryModelBackgroundFetch::scheduleFolderFetch(const LLUUID& cat_id, else { // Specific folder requests go to front of queue. - // version presence acts as dupplicate prevention for normal fetches + // version presence acts as duplicate prevention for normal fetches mFetchFolderQueue.emplace_front(cat_id, FT_DEFAULT); } @@ -415,7 +415,7 @@ void LLInventoryModelBackgroundFetch::scheduleItemFetch(const LLUUID& item_id, b } else { - // 'isFinished' being set acts as dupplicate prevention for normal fetches + // 'isFinished' being set acts as duplicate prevention for normal fetches mFetchItemQueue.emplace_front(item_id, FT_DEFAULT, false); } @@ -449,7 +449,7 @@ void LLInventoryModelBackgroundFetch::fetchFolderAndLinks(const LLUUID& cat_id, // start idle loop to track completion mBackgroundFetchActive = true; mFolderFetchActive = true; - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } void LLInventoryModelBackgroundFetch::fetchCOF(nullary_func_t callback) @@ -513,7 +513,7 @@ boost::signals2::connection LLInventoryModelBackgroundFetch::setFetchCompletionC return mFoldersFetchedSignal.connect(cb); } -void LLInventoryModelBackgroundFetch::backgroundFetchCB(void *) +void LLInventoryModelBackgroundFetch::backgroundFetchCB(void*) { LLInventoryModelBackgroundFetch::instance().backgroundFetch(); } @@ -566,7 +566,7 @@ void LLInventoryModelBackgroundFetch::onAISContentCalback( const LLUUID& response_id, EFetchType fetch_type) { - // Don't push_front on failure - there is a chance it was fired from inside bulkFetchViaAis + // Don't emplace_front on failure - there is a chance it was fired from inside bulkFetchViaAis incrFetchFolderCount(-1); uuid_vec_t::const_iterator folder_iter = content_ids.begin(); @@ -587,7 +587,7 @@ void LLInventoryModelBackgroundFetch::onAISContentCalback( if (response_id.isNull()) { // Failed to fetch, get it individually - mFetchFolderQueue.push_back(FetchQueueInfo(*folder_iter, FT_RECURSIVE)); + mFetchFolderQueue.emplace_back(*folder_iter, FT_RECURSIVE); } else { @@ -601,7 +601,7 @@ void LLInventoryModelBackgroundFetch::onAISContentCalback( it != categories->end(); ++it) { - mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); + mFetchFolderQueue.emplace_back((*it)->getUUID(), FT_RECURSIVE); } } } @@ -613,12 +613,12 @@ void LLInventoryModelBackgroundFetch::onAISContentCalback( { mBackgroundFetchActive = true; mFolderFetchActive = true; - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } } -void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_id, const LLUUID &response_id, EFetchType fetch_type) +void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID& request_id, const LLUUID& response_id, EFetchType fetch_type) { - // Don't push_front on failure - there is a chance it was fired from inside bulkFetchViaAis + // Don't emplace_front on failure - there is a chance it was fired from inside bulkFetchViaAis incrFetchFolderCount(-1); std::list::const_iterator found = std::find(mExpectedFolderIds.begin(), mExpectedFolderIds.end(), request_id); if (found != mExpectedFolderIds.end()) @@ -634,7 +634,7 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i if (request_id.isNull()) { - // orhans, no other actions needed + // orphans, no other actions needed return; } @@ -647,12 +647,12 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i { // A full recursive request failed. // Try requesting folder and nested content separately - mFetchFolderQueue.push_back(FetchQueueInfo(request_id, FT_FOLDER_AND_CONTENT)); + mFetchFolderQueue.emplace_back(request_id, FT_FOLDER_AND_CONTENT); } else if (fetch_type == FT_FOLDER_AND_CONTENT) { LL_WARNS() << "Failed to download folder: " << request_id << " Requesting known content separately" << LL_ENDL; - mFetchFolderQueue.push_back(FetchQueueInfo(request_id, FT_CONTENT_RECURSIVE)); + mFetchFolderQueue.emplace_back(request_id, FT_CONTENT_RECURSIVE); // set folder's version to prevent viewer from trying to request folder indefinetely LLViewerInventoryCategory* cat(gInventory.getCategory(request_id)); @@ -670,15 +670,15 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i { // Got the folder and content, now verify content // Request content even for FT_RECURSIVE in case of changes, failures - // or if depth limit gets imlemented. + // or if depth limit gets implemented. // This shouldn't redownload folders if they already have version request_descendants = true; LL_DEBUGS(LOG_INV, "AIS3") << "Got folder " << request_id << ". Requesting content" << LL_ENDL; } else if (fetch_type == FT_FOLDER_AND_CONTENT) { - // readd folder for content request - mFetchFolderQueue.push_front(FetchQueueInfo(request_id, FT_CONTENT_RECURSIVE)); + // read folder for content request + mFetchFolderQueue.emplace_front(request_id, FT_CONTENT_RECURSIVE); } else { @@ -698,7 +698,7 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i it != categories->end(); ++it) { - mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); + mFetchFolderQueue.emplace_back((*it)->getUUID(), FT_RECURSIVE); } } } @@ -707,11 +707,11 @@ void LLInventoryModelBackgroundFetch::onAISFolderCalback(const LLUUID &request_i { mBackgroundFetchActive = true; mFolderFetchActive = true; - gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL); + gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, nullptr); } // done - LLViewerInventoryCategory * cat(gInventory.getCategory(request_id)); + LLViewerInventoryCategory* cat(gInventory.getCategory(request_id)); if (cat) { cat->setFetching(new_state); @@ -749,7 +749,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() while (!mFetchFolderQueue.empty() && (U32)mFetchCount < max_concurrent_fetches && curent_time < end_time) { - const FetchQueueInfo & fetch_info(mFetchFolderQueue.front()); + const FetchQueueInfo& fetch_info(mFetchFolderQueue.front()); bulkFetchViaAis(fetch_info); mFetchFolderQueue.pop_front(); curent_time = LLTimer::getTotalSeconds(); @@ -757,7 +757,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() // Ideally we shouldn't fetch items if recursive fetch isn't done, // but there is a chance some request will start timeouting and recursive - // fetch will get stuck on a signle folder, don't block item fetch in such case + // fetch will get stuck on a single folder, don't block item fetch in such case while (!mFetchItemQueue.empty() && (U32)mFetchCount < max_concurrent_fetches && curent_time < end_time) { const FetchQueueInfo& fetch_info(mFetchItemQueue.front()); @@ -815,7 +815,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis() const LLUUID& marketplacelistings_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MARKETPLACE_LISTINGS); if (marketplacelistings_id.notNull()) { - mFetchFolderQueue.push_front(FetchQueueInfo(marketplacelistings_id, FT_FOLDER_AND_CONTENT)); + mFetchFolderQueue.emplace_front(marketplacelistings_id, FT_FOLDER_AND_CONTENT); } else { @@ -835,11 +835,11 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc { if (fetch_info.mIsCategory) { - const LLUUID & cat_id(fetch_info.mUUID); + const LLUUID& cat_id(fetch_info.mUUID); if (cat_id.isNull()) { incrFetchFolderCount(1); - mExpectedFolderIds.push_back(cat_id); + mExpectedFolderIds.emplace_back(cat_id); // Lost and found // Should it actually be recursive? AISAPI::FetchOrphans([](const LLUUID& response_id) @@ -851,7 +851,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc } else { - LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); + LLViewerInventoryCategory* cat(gInventory.getCategory(cat_id)); if (cat) { if (fetch_info.mFetchType == FT_CONTENT_RECURSIVE) @@ -886,8 +886,8 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc continue; } - children.push_back(child_cat->getUUID()); - mExpectedFolderIds.push_back(child_cat->getUUID()); + children.emplace_back(child_cat->getUUID()); + mExpectedFolderIds.emplace_back(child_cat->getUUID()); child_cat->setFetching(target_state); if (children.size() >= batch_limit) @@ -921,7 +921,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc if (content_done) { // This will have a bit of overlap with onAISContentCalback, - // but something else might have dowloaded folders, so verify + // but something else might have downloaded folders, so verify // every child that is complete has it's children done as well for (LLInventoryModel::cat_array_t::iterator it = categories->begin(); it != categories->end(); @@ -930,14 +930,14 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc LLViewerInventoryCategory* child_cat = (*it); if (LLViewerInventoryCategory::VERSION_UNKNOWN != child_cat->getVersion()) { - mFetchFolderQueue.push_back(FetchQueueInfo(child_cat->getUUID(), FT_RECURSIVE)); + mFetchFolderQueue.emplace_back(child_cat->getUUID(), FT_RECURSIVE); } } } else { // send it back to get the rest - mFetchFolderQueue.push_back(FetchQueueInfo(cat_id, FT_CONTENT_RECURSIVE)); + mFetchFolderQueue.emplace_back(cat_id, FT_CONTENT_RECURSIVE); } } else if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion() @@ -954,7 +954,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc // increment before call in case of immediate callback incrFetchFolderCount(1); cat->setFetching(target_state); - mExpectedFolderIds.push_back(cat_id); + mExpectedFolderIds.emplace_back(cat_id); EFetchType type = fetch_info.mFetchType; LLUUID cat_cb_id = cat_id; @@ -978,15 +978,15 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc if (fetch_info.mFetchType == FT_RECURSIVE || fetch_info.mFetchType == FT_FOLDER_AND_CONTENT) { - LLInventoryModel::cat_array_t * categories(NULL); - LLInventoryModel::item_array_t * items(NULL); + LLInventoryModel::cat_array_t* categories(NULL); + LLInventoryModel::item_array_t* items(NULL); gInventory.getDirectDescendentsOf(cat_id, categories, items); for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); it != categories->end(); ++it) { - // not push_front to not cause an infinite loop - mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), FT_RECURSIVE)); + // not emplace_front to not cause an infinite loop + mFetchFolderQueue.emplace_back((*it)->getUUID(), FT_RECURSIVE); } } } @@ -995,7 +995,7 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc } else { - LLViewerInventoryItem * itemp(gInventory.getItem(fetch_info.mUUID)); + LLViewerInventoryItem* itemp(gInventory.getItem(fetch_info.mUUID)); if (itemp) { @@ -1033,7 +1033,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() //Background fetch is called from gIdleCallbacks in a loop until background fetch is stopped. //If there are items in mFetchQueue, we want to check the time since the last bulkFetch was //sent. If it exceeds our retry time, go ahead and fire off another batch. - LLViewerRegion * region(gAgent.getRegion()); + LLViewerRegion* region(gAgent.getRegion()); if (! region || gDisconnected || LLApp::isExiting()) { return; @@ -1053,7 +1053,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() // Just processed a bunch of items. // Note: do we really need notifyObservers() here? // OnIdle it will be called anyway due to Add flag for processed item. - // It seems like in some cases we are updaiting on fail (no flag), + // It seems like in some cases we are updating on fail (no flag), // but is there anything to update? gInventory.notifyObservers(); } @@ -1071,7 +1071,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() // *TODO: Think I'd like to get a shared pointer to this and share it // among all the folder requests. uuid_vec_t recursive_cats; - uuid_vec_t all_cats; // dupplicate avoidance + uuid_vec_t all_cats; // duplicate avoidance LLSD folder_request_body; LLSD folder_request_body_lib; @@ -1081,10 +1081,10 @@ void LLInventoryModelBackgroundFetch::bulkFetch() while (! mFetchFolderQueue.empty() && (item_count + folder_count) < max_batch_size) { - const FetchQueueInfo & fetch_info(mFetchFolderQueue.front()); + const FetchQueueInfo& fetch_info(mFetchFolderQueue.front()); if (fetch_info.mIsCategory) { - const LLUUID & cat_id(fetch_info.mUUID); + const LLUUID& cat_id(fetch_info.mUUID); if (cat_id.isNull()) //DEV-17797 Lost and found { LLSD folder_sd; @@ -1098,7 +1098,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() } else { - const LLViewerInventoryCategory * cat(gInventory.getCategory(cat_id)); + const LLViewerInventoryCategory* cat(gInventory.getCategory(cat_id)); if (cat) { if (LLViewerInventoryCategory::VERSION_UNKNOWN == cat->getVersion()) @@ -1128,14 +1128,14 @@ void LLInventoryModelBackgroundFetch::bulkFetch() // May already have this folder, but append child folders to list. if (fetch_info.mFetchType >= FT_CONTENT_RECURSIVE) { - LLInventoryModel::cat_array_t * categories(NULL); - LLInventoryModel::item_array_t * items(NULL); + LLInventoryModel::cat_array_t* categories(NULL); + LLInventoryModel::item_array_t* items(NULL); gInventory.getDirectDescendentsOf(cat_id, categories, items); for (LLInventoryModel::cat_array_t::const_iterator it = categories->begin(); it != categories->end(); ++it) { - mFetchFolderQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mFetchType)); + mFetchFolderQueue.emplace_back((*it)->getUUID(), fetch_info.mFetchType); } } } @@ -1143,9 +1143,9 @@ void LLInventoryModelBackgroundFetch::bulkFetch() } if (fetch_info.mFetchType >= FT_CONTENT_RECURSIVE) { - recursive_cats.push_back(cat_id); + recursive_cats.emplace_back(cat_id); } - all_cats.push_back(cat_id); + all_cats.emplace_back(cat_id); } mFetchFolderQueue.pop_front(); @@ -1155,9 +1155,9 @@ void LLInventoryModelBackgroundFetch::bulkFetch() while (!mFetchItemQueue.empty() && (item_count + folder_count) < max_batch_size) { - const FetchQueueInfo & fetch_info(mFetchItemQueue.front()); + const FetchQueueInfo& fetch_info(mFetchItemQueue.front()); - LLViewerInventoryItem * itemp(gInventory.getItem(fetch_info.mUUID)); + LLViewerInventoryItem* itemp(gInventory.getItem(fetch_info.mUUID)); if (itemp) { @@ -1245,13 +1245,13 @@ void LLInventoryModelBackgroundFetch::bulkFetch() } } -bool LLInventoryModelBackgroundFetch::fetchQueueContainsNoDescendentsOf(const LLUUID & cat_id) const +bool LLInventoryModelBackgroundFetch::fetchQueueContainsNoDescendentsOf(const LLUUID& cat_id) const { for (fetch_queue_t::const_iterator it = mFetchFolderQueue.begin(); it != mFetchFolderQueue.end(); ++it) { - const LLUUID & fetch_id = (*it).mUUID; + const LLUUID& fetch_id = (*it).mUUID; if (gInventory.isObjectDescendentOf(fetch_id, cat_id)) return false; } @@ -1259,7 +1259,7 @@ bool LLInventoryModelBackgroundFetch::fetchQueueContainsNoDescendentsOf(const LL it != mFetchItemQueue.end(); ++it) { - const LLUUID & fetch_id = (*it).mUUID; + const LLUUID& fetch_id = (*it).mUUID; if (gInventory.isObjectDescendentOf(fetch_id, cat_id)) return false; } @@ -1274,7 +1274,7 @@ namespace /// Class ::BGFolderHttpHandler ///---------------------------------------------------------------------------- -void BGFolderHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) +void BGFolderHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse* response) { do // Single-pass do-while used for common exit handling { @@ -1287,7 +1287,7 @@ void BGFolderHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRes } // Response body should be present. - LLCore::BufferArray * body(response->getBody()); + LLCore::BufferArray* body(response->getBody()); // body = NULL; // Dev tool to force error handling if (! body || ! body->size()) { @@ -1336,9 +1336,9 @@ void BGFolderHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRes } -void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * response) +void BGFolderHttpHandler::processData(LLSD& content, LLCore::HttpResponse* response) { - LLInventoryModelBackgroundFetch * fetcher(LLInventoryModelBackgroundFetch::getInstance()); + LLInventoryModelBackgroundFetch* fetcher(LLInventoryModelBackgroundFetch::getInstance()); // API V2 and earlier should probably be testing for "error" map // in response as an application-level error. @@ -1356,7 +1356,7 @@ void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * res //LLUUID agent_id = folder_sd["agent_id"]; - //if(agent_id != gAgent.getID()) //This should never happen. + //if (agent_id != gAgent.getID()) //This should never happen. //{ // LL_WARNS(LOG_INV) << "Got a UpdateInventoryItem for the wrong agent." // << LL_ENDL; @@ -1388,7 +1388,7 @@ void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * res LLInventoryModel::update_list_t update; LLInventoryModel::LLCategoryUpdate new_folder(lost_uuid, 1); - update.push_back(new_folder); + update.emplace_back(new_folder); gInventory.accountForUpdate(update); titem->setParent(lost_uuid); @@ -1398,7 +1398,7 @@ void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * res } } - LLViewerInventoryCategory * pcat(gInventory.getCategory(parent_id)); + LLViewerInventoryCategory* pcat(gInventory.getCategory(parent_id)); if (! pcat) { continue; @@ -1436,7 +1436,7 @@ void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * res } // Set version and descendentcount according to message. - LLViewerInventoryCategory * cat(gInventory.getCategory(parent_id)); + LLViewerInventoryCategory* cat(gInventory.getCategory(parent_id)); if (cat) { cat->setVersion(version); @@ -1469,9 +1469,9 @@ void BGFolderHttpHandler::processData(LLSD & content, LLCore::HttpResponse * res } -void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::HttpResponse * response) +void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::HttpResponse* response) { - const std::string & ct(response->getContentType()); + const std::string& ct(response->getContentType()); LL_WARNS(LOG_INV) << "Inventory folder fetch failure\n" << "[Status: " << status.toTerseString() << "]\n" << "[Reason: " << status.toString() << "]\n" @@ -1481,7 +1481,7 @@ void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::Http // Could use a 404 test here to try to detect revoked caps... - if(status == LLCore::HttpStatus(HTTP_FORBIDDEN)) + if (status == LLCore::HttpStatus(HTTP_FORBIDDEN)) { // Too large, split into two if possible if (gDisconnected || LLApp::isExiting()) @@ -1511,7 +1511,7 @@ void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::Http LLUUID folder_id = iter->get("folder_id").asUUID(); if (std::find(mRecursiveCatUUIDs.begin(), mRecursiveCatUUIDs.end(), folder_id) != mRecursiveCatUUIDs.end()) { - recursive_cats.push_back(folder_id); + recursive_cats.emplace_back(folder_id); } if (folders.size() == (size / 2)) { @@ -1542,9 +1542,9 @@ void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::Http // request which tested on HTTP_INTERNAL_ERROR status. This // retry logic was unbounded and lacked discrimination as to the // cause of the retry. The new http library should be doing - // adquately on retries but I want to keep the structure of a + // adequately on retries but I want to keep the structure of a // retry for reference. - LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance(); + LLInventoryModelBackgroundFetch* fetcher = LLInventoryModelBackgroundFetch::getInstance(); if (false) { // timed out or curl failure @@ -1568,7 +1568,7 @@ void BGFolderHttpHandler::processFailure(LLCore::HttpStatus status, LLCore::Http } -void BGFolderHttpHandler::processFailure(const char * const reason, LLCore::HttpResponse * response) +void BGFolderHttpHandler::processFailure(const char* const reason, LLCore::HttpResponse* response) { LL_WARNS(LOG_INV) << "Inventory folder fetch failure\n" << "[Status: internal error]\n" @@ -1582,7 +1582,7 @@ void BGFolderHttpHandler::processFailure(const char * const reason, LLCore::Http // the same but be aware that this may be a source of problems. // Philosophy is that inventory folders are so essential to // operation that this is a reasonable action. - LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance(); + LLInventoryModelBackgroundFetch* fetcher = LLInventoryModelBackgroundFetch::getInstance(); if (true) { for (LLSD::array_const_iterator folder_it = mRequestSD["folders"].beginArray(); @@ -1605,7 +1605,7 @@ void BGFolderHttpHandler::processFailure(const char * const reason, LLCore::Http } -bool BGFolderHttpHandler::getIsRecursive(const LLUUID & cat_id) const +bool BGFolderHttpHandler::getIsRecursive(const LLUUID& cat_id) const { return std::find(mRecursiveCatUUIDs.begin(), mRecursiveCatUUIDs.end(), cat_id) != mRecursiveCatUUIDs.end(); } diff --git a/indra/newview/llinventorymodelbackgroundfetch.h b/indra/newview/llinventorymodelbackgroundfetch.h index b3fbe66c69..2e9f69ee29 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.h +++ b/indra/newview/llinventorymodelbackgroundfetch.h @@ -54,7 +54,7 @@ public: void scheduleItemFetch(const LLUUID& item_id, bool forced = false); typedef boost::function nullary_func_t; - // AIS3 only, Fetches folder and everithing links inside the folder point to + // AIS3 only, Fetches folder and everything links inside the folder point to // Intended for outfits void fetchFolderAndLinks(const LLUUID& cat_id, nullary_func_t callback); // AIS3 only @@ -81,8 +81,8 @@ public: typedef boost::function folders_fetched_callback_t; boost::signals2::connection setFetchCompletionCallback(folders_fetched_callback_t cb); - void addRequestAtFront(const LLUUID & id, bool recursive, bool is_category); - void addRequestAtBack(const LLUUID & id, bool recursive, bool is_category); + void addRequestAtFront(const LLUUID& id, bool recursive, bool is_category); + void addRequestAtBack(const LLUUID& id, bool recursive, bool is_category); protected: bool isFolderFetchProcessingComplete() const; @@ -108,8 +108,8 @@ protected: }; typedef std::deque fetch_queue_t; - void onAISContentCalback(const LLUUID& request_id, const uuid_vec_t &content_ids, const LLUUID& response_id, EFetchType fetch_type); - void onAISFolderCalback(const LLUUID &request_id, const LLUUID &response_id, EFetchType fetch_type); + void onAISContentCalback(const LLUUID& request_id, const uuid_vec_t& content_ids, const LLUUID& response_id, EFetchType fetch_type); + void onAISFolderCalback(const LLUUID& request_id, const LLUUID& response_id, EFetchType fetch_type); void bulkFetchViaAis(); void bulkFetchViaAis(const FetchQueueInfo& fetch_info); void bulkFetch(); From 470f35b10937ff649b50fcacff4fe40a9c0e52de Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Mon, 2 Sep 2024 18:22:54 +0200 Subject: [PATCH 07/19] #2471 The Destinations ComboBox on Login Screen changes the selected item to the similar one --- indra/llui/llcombobox.cpp | 76 ++++++++++++------- indra/llui/llscrolllistctrl.cpp | 126 ++++++++++++++------------------ indra/llui/llscrolllistctrl.h | 9 ++- 3 files changed, 113 insertions(+), 98 deletions(-) diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index 6e2af4c853..b64794a244 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -107,7 +107,7 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p) button_params.follows.flags(FOLLOWS_LEFT|FOLLOWS_BOTTOM|FOLLOWS_RIGHT); button_params.rect(p.rect); - if(mAllowTextEntry) + if (mAllowTextEntry) { button_params.pad_right(2); } @@ -121,7 +121,7 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p) mButton = LLUICtrlFactory::create(button_params); - if(mAllowTextEntry) + if (mAllowTextEntry) { //redo to compensate for button hack that leaves space for a character //unless it is a "minimal combobox"(drop down) @@ -207,14 +207,27 @@ void LLComboBox::clear() void LLComboBox::onCommit() { - if (mAllowTextEntry && getCurrentIndex() != -1) + if (LLScrollListItem* item = mList->getFirstSelected()) { - // we have selected an existing item, blitz the manual text entry with - // the properly capitalized item - mTextEntry->setValue(getSimple()); - mTextEntry->setTentative(false); + if (mAllowTextEntry && mTextEntry) + { + // we have selected an existing item, blitz the manual text entry with + // the properly capitalized item + LLSD label = item->getColumn(0)->getValue(); + mTextEntry->setValue(label); + mTextEntry->setTentative(false); + } + setControlValue(item->getValue()); } - setControlValue(getValue()); + else if (mAllowTextEntry) + { + setControlValue(mTextEntry->getValue()); + } + else + { + setControlValue(LLSD()); + } + LLUICtrl::onCommit(); } @@ -349,6 +362,13 @@ bool LLComboBox::setSimple(const LLStringExplicit& name) // virtual void LLComboBox::setValue(const LLSD& value) { + if (LLScrollListItem* item = mList->getFirstSelected()) + { + LLSD item_value = item->getValue(); + if (item_value.asStringRef() == value.asStringRef()) + return; + } + bool found = mList->selectByValue(value); if (found) { @@ -372,10 +392,8 @@ const std::string LLComboBox::getSimple() const { return mTextEntry->getText(); } - else - { - return res; - } + + return res; } const std::string LLComboBox::getSelectedItemLabel(S32 column) const @@ -386,24 +404,22 @@ const std::string LLComboBox::getSelectedItemLabel(S32 column) const // virtual LLSD LLComboBox::getValue() const { - LLScrollListItem* item = mList->getFirstSelected(); - if( item ) + if (LLScrollListItem* item = mList->getFirstSelected()) { return item->getValue(); } - else if (mAllowTextEntry) + + if (mAllowTextEntry) { return mTextEntry->getValue(); } - else - { - return LLSD(); - } + + return LLSD(); } void LLComboBox::setLabel(const LLStringExplicit& name) { - if ( mTextEntry ) + if (mTextEntry) { mTextEntry->setText(name); if (mList->selectItemByLabel(name, false)) @@ -500,13 +516,23 @@ void LLComboBox::setButtonVisible(bool visible) bool LLComboBox::setCurrentByIndex(S32 index) { - bool found = mList->selectNthItem(index); - if (found) + if (LLScrollListItem* item = mList->getItemByIndex(index)) { - setLabel(getSelectedItemLabel()); - mLastSelectedIndex = index; + if (item->getEnabled()) + { + mList->selectItem(item, -1, true); + if (mTextEntry) + { + LLSD::String label = item->getColumn(0)->getValue().asString(); + mTextEntry->setText(label); + mTextEntry->setTentative(false); + } + mLastSelectedIndex = index; + return true; + } } - return found; + + return false; } S32 LLComboBox::getCurrentIndex() const diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 5ae133a075..445377d3a2 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -410,10 +410,8 @@ void LLScrollListCtrl::clearRows() LLScrollListItem* LLScrollListCtrl::getFirstSelected() const { - item_list::const_iterator iter; - for (iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem* item = *iter; if (item->getSelected()) { return item; @@ -425,10 +423,8 @@ LLScrollListItem* LLScrollListCtrl::getFirstSelected() const std::vector LLScrollListCtrl::getAllSelected() const { std::vector ret; - item_list::const_iterator iter; - for(iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem* item = *iter; if (item->getSelected()) { ret.push_back(item); @@ -441,9 +437,8 @@ S32 LLScrollListCtrl::getNumSelected() const { S32 numSelected = 0; - for(item_list::const_iterator iter = mItemList.begin(); iter != mItemList.end(); ++iter) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem* item = *iter; if (item->getSelected()) { ++numSelected; @@ -460,10 +455,8 @@ S32 LLScrollListCtrl::getFirstSelectedIndex() const // make sure sort is up to date before returning an index updateSort(); - item_list::const_iterator iter; - for (iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem* item = *iter; if (item->getSelected()) { return CurSelectedIndex; @@ -476,29 +469,19 @@ S32 LLScrollListCtrl::getFirstSelectedIndex() const LLScrollListItem* LLScrollListCtrl::getFirstData() const { - if (mItemList.size() == 0) - { - return NULL; - } - return mItemList[0]; + return mItemList.empty() ? NULL : mItemList.front(); } LLScrollListItem* LLScrollListCtrl::getLastData() const { - if (mItemList.size() == 0) - { - return NULL; - } - return mItemList[mItemList.size() - 1]; + return mItemList.empty() ? NULL : mItemList.back(); } std::vector LLScrollListCtrl::getAllData() const { std::vector ret; - item_list::const_iterator iter; - for(iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem* item = *iter; ret.push_back(item); } return ret; @@ -507,22 +490,20 @@ std::vector LLScrollListCtrl::getAllData() const // returns first matching item LLScrollListItem* LLScrollListCtrl::getItem(const LLSD& sd) const { - std::string string_val = sd.asString(); + const std::string& string_val = sd.asStringRef(); - item_list::const_iterator iter; - for(iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem* item = *iter; // assumes string representation is good enough for comparison - if (item->getValue().asString() == string_val) + if (item->getValue().asStringRef() == string_val) { return item; } } + return NULL; } - void LLScrollListCtrl::reshape( S32 width, S32 height, bool called_from_parent ) { LLUICtrl::reshape( width, height, called_from_parent ); @@ -567,15 +548,16 @@ void LLScrollListCtrl::updateLayout() void LLScrollListCtrl::fitContents(S32 max_width, S32 max_height) { S32 height = llmin( getRequiredRect().getHeight(), max_height ); - if(mPageLines) - height = llmin( mPageLines * mLineHeight + 2*mBorderThickness + (mDisplayColumnHeaders ? mHeadingHeight : 0), height ); + if (mPageLines) + { + height = llmin(mPageLines * mLineHeight + 2 * mBorderThickness + (mDisplayColumnHeaders ? mHeadingHeight : 0), height); + } S32 width = getRect().getWidth(); reshape( width, height ); } - LLRect LLScrollListCtrl::getRequiredRect() { S32 heading_size = (mDisplayColumnHeaders ? mHeadingHeight : 0); @@ -627,7 +609,8 @@ bool LLScrollListCtrl::addItem( LLScrollListItem* item, EAddPosition pos, bool r S32 i = 0; for (LLScrollListCell* cell = item->getColumn(i); i < num_cols; cell = item->getColumn(++i)) { - if (i >= (S32)mColumnsIndexed.size()) break; + if (i >= (S32)mColumnsIndexed.size()) + break; cell->setWidth(mColumnsIndexed[i]->getWidth()); } @@ -650,23 +633,21 @@ S32 LLScrollListCtrl::calcMaxContentWidth() S32 max_item_width = 0; - ordered_columns_t::iterator column_itor; - for (column_itor = mColumnsIndexed.begin(); column_itor != mColumnsIndexed.end(); ++column_itor) + for (LLScrollListColumn* column : mColumnsIndexed) { - LLScrollListColumn* column = *column_itor; - if (!column) continue; + if (!column) + continue; if (mColumnWidthsDirty) { // update max content width for this column, by looking at all items column->mMaxContentWidth = column->mHeader ? LLFontGL::getFontSansSerifSmall()->getWidth(column->mLabel.getWString().c_str()) + mColumnPadding + HEADING_TEXT_PADDING : 0; - item_list::iterator iter; - for (iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* item : mItemList) { - LLScrollListCell* cellp = (*iter)->getColumn(column->mIndex); - if (!cellp) continue; - - column->mMaxContentWidth = llmax(LLFontGL::getFontSansSerifSmall()->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth); + if (LLScrollListCell* cellp = item->getColumn(column->mIndex)) + { + column->mMaxContentWidth = llmax(LLFontGL::getFontSansSerifSmall()->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth); + } } } max_item_width += column->mMaxContentWidth; @@ -683,7 +664,8 @@ bool LLScrollListCtrl::updateColumnWidths() for (column_itor = mColumnsIndexed.begin(); column_itor != mColumnsIndexed.end(); ++column_itor) { LLScrollListColumn* column = *column_itor; - if (!column) continue; + if (!column) + continue; // update column width S32 new_width = 0; @@ -737,7 +719,6 @@ void LLScrollListCtrl::updateLineHeightInsert(LLScrollListItem* itemp) } } - void LLScrollListCtrl::updateColumns(bool force_update) { if (!mColumnsDirty && !force_update) @@ -810,7 +791,8 @@ void LLScrollListCtrl::updateColumns(bool force_update) S32 i = 0; for (LLScrollListCell* cell = itemp->getColumn(i); i < num_cols; cell = itemp->getColumn(++i)) { - if (i >= (S32)mColumnsIndexed.size()) break; + if (i >= (S32)mColumnsIndexed.size()) + break; cell->setWidth(mColumnsIndexed[i]->getWidth()); } @@ -837,8 +819,8 @@ void LLScrollListCtrl::setHeadingHeight(S32 heading_height) mHeadingHeight = heading_height; updateLayout(); - } + void LLScrollListCtrl::setPageLines(S32 new_page_lines) { mPageLines = new_page_lines; @@ -880,6 +862,7 @@ bool LLScrollListCtrl::selectFirstItem() } first_item = false; } + if (mCommitOnSelectionChange) { commitIfChanged(); @@ -1169,7 +1152,6 @@ void LLScrollListCtrl::selectPrevItem( bool extend_selection) mSearchString.clear(); } - void LLScrollListCtrl::selectNextItem( bool extend_selection) { LLScrollListItem* next_item = NULL; @@ -1213,8 +1195,6 @@ void LLScrollListCtrl::selectNextItem( bool extend_selection) mSearchString.clear(); } - - void LLScrollListCtrl::deselectAllItems(bool no_commit_on_change) { item_list::iterator iter; @@ -1286,16 +1266,14 @@ LLScrollListItem* LLScrollListCtrl::getItemByLabel(const std::string& label, boo LLStringUtil::toLower(target_text); } - item_list::iterator iter; - for (iter = mItemList.begin(); iter != mItemList.end(); iter++) + for (LLScrollListItem* item : mItemList) { - LLScrollListItem* item = *iter; std::string item_text = item->getColumn(column)->getValue().asString(); // Only select enabled items with matching names if (!case_sensitive) { LLStringUtil::toLower(item_text); } - if(item_text == target_text) + if (item_text == target_text) { return item; } @@ -1303,6 +1281,15 @@ LLScrollListItem* LLScrollListCtrl::getItemByLabel(const std::string& label, boo return NULL; } +LLScrollListItem* LLScrollListCtrl::getItemByIndex(S32 index) +{ + if (index >= 0 && index < (S32)mItemList.size()) + { + return mItemList[index]; + } + + return NULL; +} bool LLScrollListCtrl::selectItemByPrefix(const std::string& target, bool case_sensitive, S32 column) { @@ -1463,7 +1450,7 @@ U32 LLScrollListCtrl::searchItems(const LLWString& substring, bool case_sensitiv return found; } -const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const +std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const { LLScrollListItem* item; @@ -1507,7 +1494,10 @@ bool LLScrollListCtrl::setSelectedByValue(const LLSD& value, bool selected) { bool found = false; - if (selected && !mAllowMultipleSelection) deselectAllItems(true); + if (selected && !mAllowMultipleSelection) + { + deselectAllItems(true); + } item_list::iterator iter; for (iter = mItemList.begin(); iter != mItemList.end(); iter++) @@ -2634,9 +2624,7 @@ bool LLScrollListCtrl::isRepeatedChars(const LLWString& string) const void LLScrollListCtrl::selectItem(LLScrollListItem* itemp, S32 cell, bool select_single_item) { - if (!itemp) return; - - if (!itemp->getSelected()) + if (itemp && !itemp->getSelected()) { if (mLastSelected) { @@ -2670,9 +2658,7 @@ void LLScrollListCtrl::selectItem(LLScrollListItem* itemp, S32 cell, bool select void LLScrollListCtrl::deselectItem(LLScrollListItem* itemp) { - if (!itemp) return; - - if (itemp->getSelected()) + if (itemp && itemp->getSelected()) { if (mLastSelected == itemp) { @@ -2878,7 +2864,7 @@ void LLScrollListCtrl::updateStaticColumnWidth(LLScrollListColumn* col, S32 new_ // LLEditMenuHandler functions // virtual -void LLScrollListCtrl::copy() +void LLScrollListCtrl::copy() { std::string buffer; @@ -2892,26 +2878,26 @@ void LLScrollListCtrl::copy() } // virtual -bool LLScrollListCtrl::canCopy() const +bool LLScrollListCtrl::canCopy() const { return (getFirstSelected() != NULL); } // virtual -void LLScrollListCtrl::cut() +void LLScrollListCtrl::cut() { copy(); doDelete(); } // virtual -bool LLScrollListCtrl::canCut() const +bool LLScrollListCtrl::canCut() const { return canCopy() && canDoDelete(); } // virtual -void LLScrollListCtrl::selectAll() +void LLScrollListCtrl::selectAll() { // Deselects all other items item_list::iterator iter; @@ -2931,13 +2917,13 @@ void LLScrollListCtrl::selectAll() } // virtual -bool LLScrollListCtrl::canSelectAll() const +bool LLScrollListCtrl::canSelectAll() const { return getCanSelect() && mAllowMultipleSelection && !(mMaxSelectable > 0 && mItemList.size() > mMaxSelectable); } // virtual -void LLScrollListCtrl::deselect() +void LLScrollListCtrl::deselect() { deselectAllItems(); } diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index 1f9f26e08b..c24784338a 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -260,11 +260,12 @@ public: // one of which can be selected at a time. virtual LLScrollListItem* addSimpleElement(const std::string& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD()); - bool selectItemByLabel( const std::string& item, bool case_sensitive = true, S32 column = 0 ); // false if item not found + bool selectItemByLabel(const std::string& item, bool case_sensitive = true, S32 column = 0); // false if item not found bool selectItemByPrefix(const std::string& target, bool case_sensitive = true, S32 column = -1); bool selectItemByPrefix(const LLWString& target, bool case_sensitive = true, S32 column = -1); - LLScrollListItem* getItemByLabel( const std::string& item, bool case_sensitive = true, S32 column = 0 ); - const std::string getSelectedItemLabel(S32 column = 0) const; + LLScrollListItem* getItemByLabel(const std::string& item, bool case_sensitive = true, S32 column = 0); + LLScrollListItem* getItemByIndex(S32 index); + std::string getSelectedItemLabel(S32 column = 0) const; LLSD getSelectedValue(); // If multi select is on, select all element that include substring, @@ -559,6 +560,8 @@ private: sort_signal_t* mSortCallback; is_friend_signal_t* mIsFriendSignal; + + friend class LLComboBox; }; // end class LLScrollListCtrl #endif // LL_SCROLLLISTCTRL_H From ee9f7ec670c4c94f871f7abed68a573b844a69a6 Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Tue, 3 Sep 2024 00:55:55 +0200 Subject: [PATCH 08/19] #2403 Reset Skeleton issues --- indra/newview/llviewermenu.cpp | 40 +++++++++++-------- .../skins/default/xui/en/menu_viewer.xml | 2 +- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index e1664752e7..a32e5d23e3 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -6748,17 +6748,11 @@ class LLAvatarToggleSearch : public view_listener_t } }; -class LLAvatarResetSkeleton: public view_listener_t +class LLAvatarResetSkeleton : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLVOAvatar* avatar = NULL; - LLViewerObject *obj = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); - if (obj) - { - avatar = obj->getAvatar(); - } - if(avatar) + if (LLVOAvatar* avatar = find_avatar_from_object(LLSelectMgr::getInstance()->getSelection()->getPrimaryObject())) { avatar->resetSkeleton(false); } @@ -6766,12 +6760,11 @@ class LLAvatarResetSkeleton: public view_listener_t } }; -class LLAvatarEnableResetSkeleton: public view_listener_t +class LLAvatarEnableResetSkeleton : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLViewerObject *obj = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); - if (obj && obj->getAvatar()) + if (LLVOAvatar* avatar = find_avatar_from_object(LLSelectMgr::getInstance()->getSelection()->getPrimaryObject())) { return true; } @@ -6779,13 +6772,11 @@ class LLAvatarEnableResetSkeleton: public view_listener_t } }; - class LLAvatarResetSkeletonAndAnimations : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLVOAvatar* avatar = find_avatar_from_object(LLSelectMgr::getInstance()->getSelection()->getPrimaryObject()); - if (avatar) + if (LLVOAvatar* avatar = find_avatar_from_object(LLSelectMgr::getInstance()->getSelection()->getPrimaryObject())) { avatar->resetSkeleton(true); } @@ -6793,12 +6784,27 @@ class LLAvatarResetSkeletonAndAnimations : public view_listener_t } }; +class LLAvatarResetSelfSkeleton : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + if (LLVOAvatar* avatar = find_avatar_from_object(LLSelectMgr::getInstance()->getSelection()->getPrimaryObject())) + { + avatar->resetSkeleton(false); + } + else + { + gAgentAvatarp->resetSkeleton(false); + } + return true; + } +}; + class LLAvatarResetSelfSkeletonAndAnimations : public view_listener_t { bool handleEvent(const LLSD& userdata) { - LLVOAvatar* avatar = find_avatar_from_object(LLSelectMgr::getInstance()->getSelection()->getPrimaryObject()); - if (avatar) + if (LLVOAvatar* avatar = find_avatar_from_object(LLSelectMgr::getInstance()->getSelection()->getPrimaryObject())) { avatar->resetSkeleton(true); } @@ -6810,7 +6816,6 @@ class LLAvatarResetSelfSkeletonAndAnimations : public view_listener_t } }; - class LLAvatarAddContact : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -10106,6 +10111,7 @@ void initialize_menus() view_listener_t::addMenu(new LLAvatarResetSkeleton(), "Avatar.ResetSkeleton"); view_listener_t::addMenu(new LLAvatarEnableResetSkeleton(), "Avatar.EnableResetSkeleton"); view_listener_t::addMenu(new LLAvatarResetSkeletonAndAnimations(), "Avatar.ResetSkeletonAndAnimations"); + view_listener_t::addMenu(new LLAvatarResetSelfSkeleton(), "Avatar.ResetSelfSkeleton"); view_listener_t::addMenu(new LLAvatarResetSelfSkeletonAndAnimations(), "Avatar.ResetSelfSkeletonAndAnimations"); enable.add("Avatar.IsMyProfileOpen", boost::bind(&my_profile_visible)); enable.add("Avatar.IsPicksTabOpen", boost::bind(&picks_tab_visible)); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 40f3e51fca..82d2277dfa 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -483,7 +483,7 @@ layout="topleft" name="Reset Skeleton"> + function="Avatar.ResetSelfSkeleton" /> Date: Tue, 3 Sep 2024 08:16:22 +0300 Subject: [PATCH 09/19] viewer#2310 Fix snapshot's size string dropping color during upload --- indra/newview/llfloatersnapshot.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index f7c82621fb..1f52f1d180 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -324,7 +324,6 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) bool got_bytes = previewp && previewp->getDataSize() > 0; bool got_snap = previewp && previewp->getSnapshotUpToDate(); - // *TODO: Separate maximum size for Web images from postcards LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL; LLLocale locale(LLLocale::USER_LOCALE); @@ -343,7 +342,8 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) image_res_tb->setTextArg("[HEIGHT]", llformat("%d", previewp->getEncodedImageHeight())); } - floater->getChild("file_size_label")->setTextArg("[SIZE]", got_snap ? bytes_string : floater->getString("unknown")); + LLTextBox* file_size_label = floater->getChild("file_size_label"); + file_size_label->setTextArg("[SIZE]", got_snap ? bytes_string : floater->getString("unknown")); LLUIColor color = LLUIColorTable::instance().getColor( "LabelTextColor" ); if (shot_type == LLSnapshotModel::SNAPSHOT_POSTCARD @@ -359,7 +359,8 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) color = LLUIColor(LLColor4::red); } - floater->getChild("file_size_label")->setColor(color); + file_size_label->setColor(color); + file_size_label->setReadOnlyColor(color); // field gets disabled during upload // Update the width and height spinners based on the corresponding resolution combos. (?) switch(shot_type) From 821a7314b13127d0896fe0ba59ac3567b58245cc Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 3 Sep 2024 12:55:59 +0300 Subject: [PATCH 10/19] viewer#2311 Message about oversized snapshots wasn't shown in some cases --- indra/newview/llwebprofile.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp index feb5ecb1fb..4528ad012d 100644 --- a/indra/newview/llwebprofile.cpp +++ b/indra/newview/llwebprofile.cpp @@ -133,12 +133,12 @@ void LLWebProfile::uploadImageCoro(LLPointer image, std::strin if (!status) { + LL_WARNS("Snapshots") << "Failed to get image upload config" << LL_ENDL; + LLWebProfile::reportImageUploadStatus(false); if (image->getDataSize() > MAX_WEB_DATASIZE) { LLNotificationsUtil::add("CannotUploadSnapshotWebTooBig"); } - LL_WARNS("Snapshots") << "Failed to get image upload config" << LL_ENDL; - LLWebProfile::reportImageUploadStatus(false); return; } @@ -166,6 +166,10 @@ void LLWebProfile::uploadImageCoro(LLPointer image, std::strin { LL_WARNS("Snapshots") << "Failed to upload image data." << LL_ENDL; LLWebProfile::reportImageUploadStatus(false); + if (image->getDataSize() > MAX_WEB_DATASIZE) + { + LLNotificationsUtil::add("CannotUploadSnapshotWebTooBig"); + } return; } @@ -193,6 +197,10 @@ void LLWebProfile::uploadImageCoro(LLPointer image, std::strin { LL_WARNS("Snapshots") << "Failed to upload image." << LL_ENDL; LLWebProfile::reportImageUploadStatus(false); + if (image->getDataSize() > MAX_WEB_DATASIZE) + { + LLNotificationsUtil::add("CannotUploadSnapshotWebTooBig"); + } return; } @@ -201,8 +209,6 @@ void LLWebProfile::uploadImageCoro(LLPointer image, std::strin LL_INFOS("Snapshots") << "Image uploaded." << LL_ENDL; //LL_DEBUGS("Snapshots") << "Uploading image succeeded. Response: [" << raw.asString() << "]" << LL_ENDL; LLWebProfile::reportImageUploadStatus(true); - - } /*static*/ From e42e95d87896fa3be0b48108dc3b79af2e1caf66 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Tue, 3 Sep 2024 10:05:44 -0700 Subject: [PATCH 11/19] secondlife/viewer#2483: Fix label typo in PBR terrain texture transforms tab --- doc/contributions.txt | 1 + .../skins/default/xui/en/panel_settings_terrain_transform.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/contributions.txt b/doc/contributions.txt index 54817ca52d..1f911a8b39 100755 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -1210,6 +1210,7 @@ PanteraPolnocy SL-18937 SL-19207 SL-19681 + secondlife/viewer#2483 Parvati Silverweb Patric Mills VWR-2645 diff --git a/indra/newview/skins/default/xui/en/panel_settings_terrain_transform.xml b/indra/newview/skins/default/xui/en/panel_settings_terrain_transform.xml index 0bf0d8cffc..350e405732 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_terrain_transform.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_terrain_transform.xml @@ -288,7 +288,7 @@ left="10" top_pad="0" width="170"> - Offset y + Offset u Date: Tue, 3 Sep 2024 17:55:17 -0400 Subject: [PATCH 12/19] Fix visualizing luminance buffer and small cleanup --- indra/newview/pipeline.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3b1da8668b..7b8739c7df 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7871,7 +7871,6 @@ void LLPipeline::renderFinalize() renderDoF(&mPostMap, &mRT->screen); LLRenderTarget* finalBuffer = &mRT->screen; - static LLCachedControl aa_type(gSavedSettings, "RenderFSAAType", 2U); if (RenderFSAAType == 1) { applyFXAA(&mRT->screen, &mPostMap); @@ -7880,7 +7879,6 @@ void LLPipeline::renderFinalize() if (RenderBufferVisualization > -1) { - finalBuffer = &mPostMap; switch (RenderBufferVisualization) { case 0: @@ -7891,6 +7889,7 @@ void LLPipeline::renderFinalize() break; case 4: visualizeBuffers(&mLuminanceMap, finalBuffer, 0); + break; case 5: { if (RenderFSAAType > 0) From 4ae1de1f8a78d795958d67afab8356f9a13f707d Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 28 Aug 2024 23:05:58 +0300 Subject: [PATCH 13/19] viewer#2411 LLFontGL::render optimizations --- indra/llrender/CMakeLists.txt | 2 + indra/llrender/llfontgl.cpp | 124 +++++++++++++--- indra/llrender/llfontgl.h | 15 +- indra/llrender/llfontvertexbuffer.cpp | 157 ++++++++++++++++++++ indra/llrender/llfontvertexbuffer.h | 85 +++++++++++ indra/llrender/llrender.cpp | 201 +++++++++++++++++++++----- indra/llrender/llrender.h | 10 ++ indra/llui/llbutton.cpp | 45 +++++- indra/llui/llbutton.h | 14 +- indra/llwindow/llwindowwin32.cpp | 4 + indra/newview/llhudnametag.cpp | 4 +- indra/newview/llhudnametag.h | 3 + indra/newview/llhudrender.cpp | 13 +- indra/newview/llhudrender.h | 5 +- indra/newview/llhudtext.cpp | 2 +- indra/newview/llhudtext.h | 2 + indra/newview/llmanip.cpp | 10 +- indra/newview/llmaniprotate.cpp | 4 +- indra/newview/llmanipscale.cpp | 4 +- indra/newview/llmaniptranslate.cpp | 4 +- 20 files changed, 629 insertions(+), 79 deletions(-) create mode 100644 indra/llrender/llfontvertexbuffer.cpp create mode 100644 indra/llrender/llfontvertexbuffer.h diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt index 7f881c8bb3..ccff7c7a8c 100644 --- a/indra/llrender/CMakeLists.txt +++ b/indra/llrender/CMakeLists.txt @@ -17,6 +17,7 @@ set(llrender_SOURCE_FILES llfontfreetype.cpp llfontfreetypesvg.cpp llfontgl.cpp + llfontvertexbuffer.cpp llfontregistry.cpp llgl.cpp llglslshader.cpp @@ -43,6 +44,7 @@ set(llrender_HEADER_FILES llcubemap.h llcubemaparray.h llfontgl.h + llfontvertexbuffer.h llfontfreetype.h llfontfreetypesvg.h llfontbitmapcache.h diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index b6cdb81b33..481e35c16a 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -34,6 +34,7 @@ #include "llfontbitmapcache.h" #include "llfontregistry.h" #include "llgl.h" +#include "llglslshader.h" #include "llimagegl.h" #include "llrender.h" #include "llstl.h" @@ -41,6 +42,7 @@ #include "lltexture.h" #include "lldir.h" #include "llstring.h" +#include "llvertexbuffer.h" // Third party library includes #include @@ -143,7 +145,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, const LLRectf& rec S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, - ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, bool use_ellipses, bool use_color) const + ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, bool use_ellipses, bool use_color, + std::list *buffer_list) const { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -157,6 +160,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons return 0; } + gGL.flush(); // deliberately empty pending verts gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); S32 scaled_max_pixels = max_pixels == S32_MAX ? S32_MAX : llceil((F32)max_pixels * sScaleX); @@ -270,10 +274,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons const LLFontGlyphInfo* next_glyph = NULL; - const S32 GLYPH_BATCH_SIZE = 30; - LLVector3 vertices[GLYPH_BATCH_SIZE * 4]; - LLVector2 uvs[GLYPH_BATCH_SIZE * 4]; - LLColor4U colors[GLYPH_BATCH_SIZE * 4]; + static constexpr S32 GLYPH_BATCH_SIZE = 30; + static thread_local LLVector3 vertices[GLYPH_BATCH_SIZE * 4]; + static thread_local LLVector2 uvs[GLYPH_BATCH_SIZE * 4]; + static thread_local LLColor4U colors[GLYPH_BATCH_SIZE * 4]; LLColor4U text_color(color); // Preserve the transparency to render fading emojis in fading text (e.g. @@ -282,6 +286,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons std::pair bitmap_entry = std::make_pair(EFontGlyphType::Grayscale, -1); S32 glyph_count = 0; + S32 buffer_count = 0; + LLVertexBuffer* vb; + LLImageGL* font_image = nullptr; for (i = begin_offset; i < begin_offset + length; i++) { llwchar wch = wstr[i]; @@ -305,16 +312,35 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons // otherwise the queued glyphs will be taken from wrong textures. if (glyph_count > 0) { - gGL.begin(LLRender::QUADS); + if (buffer_list) { + vb = gGL.beginNoCache(LLRender::QUADS, buffer_count); + if (vb) + { + buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); + } + gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); + + vb = gGL.getBuffer(buffer_count); // instead of endNoCache to draw now + if (vb) + { + buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); + } + } + else + { + gGL.begin(LLRender::QUADS); + { + gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); + } + gGL.end(); } - gGL.end(); glyph_count = 0; } bitmap_entry = next_bitmap_entry; - LLImageGL* font_image = font_bitmap_cache->getImageGL(bitmap_entry.first, bitmap_entry.second); + font_image = font_bitmap_cache->getImageGL(bitmap_entry.first, bitmap_entry.second); gGL.getTexUnit(0)->bind(font_image); } @@ -338,11 +364,28 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons if (glyph_count >= GLYPH_BATCH_SIZE) { - gGL.begin(LLRender::QUADS); + if (buffer_list) { + vb = gGL.beginNoCache(LLRender::QUADS, buffer_count); + if (vb) + { + buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); + } gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); + vb = gGL.endNoCache(buffer_count); + if (vb) + { + buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); + } + } + else + { + gGL.begin(LLRender::QUADS); + { + gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); + } + gGL.end(); } - gGL.end(); glyph_count = 0; } @@ -376,11 +419,28 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons cur_render_y = cur_y; } - gGL.begin(LLRender::QUADS); + if (buffer_list) { + vb = gGL.beginNoCache(LLRender::QUADS, buffer_count); + if (vb) + { + buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); + } gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); + vb = gGL.endNoCache(buffer_count); + if (vb) + { + buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); + } + } + else + { + gGL.begin(LLRender::QUADS); + { + gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); + } + gGL.end(); } - gGL.end(); if (right_x) @@ -394,15 +454,42 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons F32 descender = (F32)llfloor(mFontFreetype->getDescenderHeight()); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.begin(LLRender::LINES); - gGL.vertex2f(start_x, cur_y - descender); - gGL.vertex2f(cur_x, cur_y - descender); - gGL.end(); + if (buffer_list) + { + vb = gGL.beginNoCache(LLRender::LINES, buffer_count); + if (vb) + { + buffer_list->emplace_back(vb, nullptr, LLRender::QUADS, buffer_count); + } + + gGL.vertex2f(start_x, cur_y - descender); + gGL.vertex2f(cur_x, cur_y - descender); + + vb = gGL.getBuffer(buffer_count); + if (vb) + { + buffer_list->emplace_back(vb, nullptr, LLRender::LINES, buffer_count); + } + } + else + { + gGL.begin(LLRender::LINES); + gGL.vertex2f(start_x, cur_y - descender); + gGL.vertex2f(cur_x, cur_y - descender); + gGL.end(); + } + } + else if (buffer_list) + { + vb = gGL.getBuffer(buffer_count); + if (vb) + { + buffer_list->emplace_back(vb, font_image, gGL.getMode(), buffer_count); + } } if (draw_ellipses) { - // recursively render ellipses at end of string // we've already reserved enough room gGL.pushUIMatrix(); @@ -417,7 +504,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons S32_MAX, max_pixels, right_x, false, - use_color); + use_color, + buffer_list); gGL.popUIMatrix(); } diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index de7529a583..5015601cf6 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -33,6 +33,7 @@ #include "llimagegl.h" #include "llpointer.h" #include "llrect.h" +#include "llvertexbuffer.h" #include "v2math.h" class LLColor4; @@ -42,6 +43,7 @@ class LLFontFreetype; // Structure used to store previously requested fonts. class LLFontRegistry; +class LLVertexBuffer; class LLFontGL { @@ -79,6 +81,16 @@ public: DROP_SHADOW_SOFT }; + struct LLVertexBufferData + { + LLVertexBufferData() : mBuffer(nullptr), mImage(nullptr), mMode(0), mCount(0) {} + LLVertexBufferData(LLVertexBuffer* buffer, LLImageGL* image, U8 mode, U32 count) : mBuffer(buffer), mImage(image), mMode(mode), mCount(count) {} + LLPointer mBuffer; + LLPointer mImage; // might be a better idea to store + U8 mMode; + U32 mCount; + }; + LLFontGL(); ~LLFontGL(); @@ -119,7 +131,8 @@ public: S32 max_chars = S32_MAX, S32 max_pixels = S32_MAX, F32* right_x=NULL, bool use_ellipses = false, - bool use_color = true) const; + bool use_color = true, + std::list* buffer_list = nullptr) const; S32 render(const LLWString &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color) const; diff --git a/indra/llrender/llfontvertexbuffer.cpp b/indra/llrender/llfontvertexbuffer.cpp new file mode 100644 index 0000000000..3ff0771795 --- /dev/null +++ b/indra/llrender/llfontvertexbuffer.cpp @@ -0,0 +1,157 @@ +/** + * @file llfontvertexbuffer.cpp + * @brief Buffer storage for font rendering. + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, 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$ + */ + +#include "linden_common.h" + +#include "llfontvertexbuffer.h" + +#include "llvertexbuffer.h" + + +LLFontVertexBuffer::LLFontVertexBuffer(bool track_changes) +: mTrackStringChanges(track_changes) +{ +} + +LLFontVertexBuffer::~LLFontVertexBuffer() +{ + reset(); +} + +void LLFontVertexBuffer::reset() +{ + mBufferList.clear(); +} + +S32 LLFontVertexBuffer::render( + 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 ) +{ + if (mBufferList.empty()) + { + genBuffers(fontp, text, begin_offset, x, y, color, halign, valign, + style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); + } + else if (mLastX != x || mLastY != y || mLastColor != color) // always track position and alphs + { + genBuffers(fontp, text, begin_offset, x, y, color, halign, valign, + style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); + } + else if (true //mTrackStringChanges + && (mLastOffset != begin_offset + || mLastMaxChars != max_chars + || mLastMaxPixels != max_pixels + || mLastStringHash != sStringHasher._Do_hash(text))) // todo, track all parameters? + { + genBuffers(fontp, text, begin_offset, x, y, color, halign, valign, + style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); + } + else + { + + gGL.flush(); // deliberately empty pending verts + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.pushUIMatrix(); + + gGL.loadUIIdentity(); + + // Depth translation, so that floating text appears 'in-world' + // and is correctly occluded. + gGL.translatef(0.f, 0.f, LLFontGL::sCurDepth); + + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + for (auto &buf_data : mBufferList) + { + if (buf_data.mImage) + { + gGL.getTexUnit(0)->bind(buf_data.mImage); + } + else + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + buf_data.mBuffer->setBuffer(); + + if (LLRender::sGLCoreProfile && buf_data.mMode == LLRender::QUADS) + { + buf_data.mBuffer->drawArrays(LLRender::TRIANGLES, 0, buf_data.mCount); + } + else + { + buf_data.mBuffer->drawArrays(buf_data.mMode, 0, buf_data.mCount); + } + } + if (right_x) + { + *right_x = mLastRightX; + } + + gGL.popUIMatrix(); + } + return mChars; +} + +void LLFontVertexBuffer::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) +{ + mBufferList.clear(); + mChars = fontp->render(text, begin_offset, x, y, color, halign, valign, + style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color, &mBufferList); + + mLastOffset = begin_offset; + mLastMaxChars = max_chars; + mLastMaxPixels = max_pixels; + mLastStringHash = sStringHasher._Do_hash(text); + mLastX = x; + mLastY = y; + mLastColor = color; + + if (right_x) + { + mLastRightX = *right_x; + } +} + 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 diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 7a52f9cfb5..8cd2d9cc15 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1570,6 +1570,51 @@ void LLRender::end() flush(); } } + +LLVertexBuffer* LLRender::beginNoCache(const GLuint& mode, S32& count) +{ + if (mode != mMode) + { + if (mode == LLRender::QUADS) + { + mQuadCycle = 1; + } + + if (mMode == LLRender::QUADS || + mMode == LLRender::LINES || + mMode == LLRender::TRIANGLES || + mMode == LLRender::POINTS) + { + return getBuffer(count); + } + else if (mCount != 0) + { + LL_ERRS() << "gGL.begin() called redundantly." << LL_ENDL; + } + mMode = mode; + } + return nullptr; +} + +LLVertexBuffer* LLRender::endNoCache(S32& count) +{ + if (mCount == 0) + { + return nullptr; + //IMM_ERRS << "GL begin and end called with no vertices specified." << LL_ENDL; + } + + if ((mMode != LLRender::QUADS && + mMode != LLRender::LINES && + mMode != LLRender::TRIANGLES && + mMode != LLRender::POINTS) || + mCount > 2048) + { + return getBuffer(count); + } + return nullptr; +} + void LLRender::flush() { STOP_GLERROR; @@ -1664,27 +1709,7 @@ void LLRender::flush() else { LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache miss"); - vb = new LLVertexBuffer(attribute_mask); - vb->allocateBuffer(count, 0); - - vb->setBuffer(); - - vb->setPositionData((LLVector4a*) mVerticesp.get()); - - if (attribute_mask & LLVertexBuffer::MAP_TEXCOORD0) - { - vb->setTexCoord0Data(mTexcoordsp.get()); - } - - if (attribute_mask & LLVertexBuffer::MAP_COLOR) - { - vb->setColorData(mColorsp.get()); - } - -#if LL_DARWIN - vb->unmapBuffer(); -#endif - vb->unbind(); + vb = genBuffer(attribute_mask, count); sVBCache[vhash] = { vb , std::chrono::steady_clock::now() }; @@ -1712,17 +1737,7 @@ void LLRender::flush() } } - vb->setBuffer(); - - if (mMode == LLRender::QUADS && sGLCoreProfile) - { - vb->drawArrays(LLRender::TRIANGLES, 0, count); - mQuadCycle = 1; - } - else - { - vb->drawArrays(mMode, 0, count); - } + drawBuffer(vb, mMode, count); } else { @@ -1730,13 +1745,129 @@ void LLRender::flush() LL_ERRS() << "A flush call from outside main rendering thread" << LL_ENDL; } + resetStriders(count); + } +} - mVerticesp[0] = mVerticesp[count]; - mTexcoordsp[0] = mTexcoordsp[count]; - mColorsp[0] = mColorsp[count]; +LLVertexBuffer* LLRender::genBuffer(U32 attribute_mask, S32 count) +{ + LLVertexBuffer * vb = new LLVertexBuffer(attribute_mask); + vb->allocateBuffer(count, 0); + + vb->setBuffer(); + + vb->setPositionData((LLVector4a*)mVerticesp.get()); + + if (attribute_mask & LLVertexBuffer::MAP_TEXCOORD0) + { + vb->setTexCoord0Data(mTexcoordsp.get()); + } + + if (attribute_mask & LLVertexBuffer::MAP_COLOR) + { + vb->setColorData(mColorsp.get()); + } + +#if LL_DARWIN + vb->unmapBuffer(); +#endif + vb->unbind(); + + return vb; +} + +void LLRender::drawBuffer(LLVertexBuffer* vb, U32 mode, S32 count) +{ + vb->setBuffer(); + + if (mode == LLRender::QUADS && sGLCoreProfile) + { + vb->drawArrays(LLRender::TRIANGLES, 0, count); + mQuadCycle = 1; + } + else + { + vb->drawArrays(mode, 0, count); + } +} + +void LLRender::resetStriders(S32 count) +{ + mVerticesp[0] = mVerticesp[count]; + mTexcoordsp[0] = mTexcoordsp[count]; + mColorsp[0] = mColorsp[count]; + + mCount = 0; +} + +LLVertexBuffer* LLRender::getBuffer(S32 & count) +{ + STOP_GLERROR; + LLVertexBuffer *vb; + if (mCount > 0) + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + llassert(LLGLSLShader::sCurBoundShaderPtr != nullptr); + if (!mUIOffset.empty()) + { + sUICalls++; + sUIVerts += mCount; + } + + //store mCount in a local variable to avoid re-entrance (drawArrays may call flush) + count = mCount; + + if (mMode == LLRender::QUADS && !sGLCoreProfile) + { + if (mCount % 4 != 0) + { + count -= (mCount % 4); + LL_WARNS() << "Incomplete quad requested." << LL_ENDL; + } + } + + if (mMode == LLRender::TRIANGLES) + { + if (mCount % 3 != 0) + { + count -= (mCount % 3); + LL_WARNS() << "Incomplete triangle requested." << LL_ENDL; + } + } + + if (mMode == LLRender::LINES) + { + if (mCount % 2 != 0) + { + count -= (mCount % 2); + LL_WARNS() << "Incomplete line requested." << LL_ENDL; + } + } mCount = 0; + + if (mBuffer) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache miss"); + + U32 attribute_mask = LLGLSLShader::sCurBoundShaderPtr->mAttributeMask; + vb = genBuffer(attribute_mask, count); + drawBuffer(vb, mMode, count); + } + else + { + // mBuffer is present in main thread and not present in an image thread + LL_ERRS() << "A flush call from outside main rendering thread" << LL_ENDL; + } + + resetStriders(count); } + else + { + count = 0; + } + + return vb; } void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 4aa33b7427..5f84a4a275 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -417,6 +417,12 @@ public: void begin(const GLuint& mode); void end(); + + LLVertexBuffer* beginNoCache(const GLuint& mode, S32& count); + LLVertexBuffer* endNoCache(S32& count); + LLVertexBuffer* getBuffer(S32& count); + U8 getMode() const { return mMode; } + void vertex2i(const GLint& x, const GLint& y); void vertex2f(const GLfloat& x, const GLfloat& y); void vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z); @@ -485,6 +491,10 @@ public: private: friend class LLLightState; + LLVertexBuffer* genBuffer(U32 attribute_mask, S32 count); + void drawBuffer(LLVertexBuffer* vb, U32 mode, S32 count); + void resetStriders(S32 count); + eMatrixMode mMatrixMode; U32 mMatIdx[NUM_MATRIX_MODES]; U32 mMatHash[NUM_MATRIX_MODES]; diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 30968225a8..3df7f83d49 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -120,8 +120,9 @@ LLButton::Params::Params() LLButton::LLButton(const LLButton::Params& p) -: LLUICtrl(p), + : LLUICtrl(p), LLBadgeOwner(getHandle()), + mFontBuffer(false), mMouseDownFrame(0), mMouseHeldDownCount(0), mBorderEnabled( false ), @@ -329,6 +330,30 @@ void LLButton::onCommit() LLUICtrl::onCommit(); } +void LLButton::setUnselectedLabelColor(const LLUIColor& c) +{ + mUnselectedLabelColor = c; + mFontBuffer.reset(); +} + +void LLButton::setSelectedLabelColor(const LLUIColor& c) +{ + mSelectedLabelColor = c; + mFontBuffer.reset(); +} + +void LLButton::setUseEllipses(bool use_ellipses) +{ + mUseEllipses = use_ellipses; + mFontBuffer.reset(); +} + +void LLButton::setUseFontColor(bool use_font_color) +{ + mUseFontColor = use_font_color; + mFontBuffer.reset(); +} + boost::signals2::connection LLButton::setClickedCallback(const CommitCallbackParam& cb) { return setClickedCallback(initCommitCallback(cb)); @@ -396,6 +421,15 @@ bool LLButton::postBuild() return LLUICtrl::postBuild(); } +void LLButton::onVisibilityChange(bool new_visibility) +{ + if (!new_visibility) + { + mFontBuffer.reset(); + } + return LLUICtrl::onVisibilityChange(new_visibility); +} + bool LLButton::handleUnicodeCharHere(llwchar uni_char) { bool handled = false; @@ -954,7 +988,7 @@ void LLButton::draw() // LLFontGL::render expects S32 max_chars variable but process in a separate way -1 value. // Due to U32_MAX is equal to S32 -1 value I have rest this value for non-ellipses mode. // Not sure if it is really needed. Probably S32_MAX should be always passed as max_chars. - mLastDrawCharsCount = mGLFont->render(label, 0, + mLastDrawCharsCount = mFontBuffer.render(mGLFont, label, 0, (F32)x, (F32)(getRect().getHeight() / 2 + mBottomVPad), label_color % alpha, @@ -996,6 +1030,7 @@ void LLButton::setToggleState(bool b) setFlashing(false); // stop flash state whenever the selected/unselected state if reset // Unselected label assignments autoResize(); + mFontBuffer.reset(); } } @@ -1025,11 +1060,13 @@ bool LLButton::toggleState() void LLButton::setLabel( const std::string& label ) { mUnselectedLabel = mSelectedLabel = label; + mFontBuffer.reset(); } void LLButton::setLabel( const LLUIString& label ) { mUnselectedLabel = mSelectedLabel = label; + mFontBuffer.reset(); } void LLButton::setLabel( const LLStringExplicit& label ) @@ -1043,17 +1080,20 @@ bool LLButton::setLabelArg( const std::string& key, const LLStringExplicit& text { mUnselectedLabel.setArg(key, text); mSelectedLabel.setArg(key, text); + mFontBuffer.reset(); return true; } void LLButton::setLabelUnselected( const LLStringExplicit& label ) { mUnselectedLabel = label; + mFontBuffer.reset(); } void LLButton::setLabelSelected( const LLStringExplicit& label ) { mSelectedLabel = label; + mFontBuffer.reset(); } bool LLButton::labelIsTruncated() const @@ -1113,6 +1153,7 @@ void LLButton::resize(const LLUIString& label) if (btn_width < min_width) { reshape(min_width, getRect().getHeight()); + mFontBuffer.reset(); } } } diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 4ecea6d473..f522281e30 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -35,6 +35,7 @@ #include "v4color.h" #include "llframetimer.h" #include "llfontgl.h" +#include "llfontvertexbuffer.h" #include "lluiimage.h" #include "lluistring.h" @@ -167,15 +168,17 @@ public: virtual void draw(); /*virtual*/ bool postBuild(); + /*virtual*/ void onVisibilityChange(bool visible); + virtual void onMouseLeave(S32 x, S32 y, MASK mask); virtual void onMouseCaptureLost(); virtual void onCommit(); - void setUnselectedLabelColor( const LLUIColor& c ) { mUnselectedLabelColor = c; } - void setSelectedLabelColor( const LLUIColor& c ) { mSelectedLabelColor = c; } - void setUseEllipses( bool use_ellipses ) { mUseEllipses = use_ellipses; } - void setUseFontColor( bool use_font_color) { mUseFontColor = use_font_color; } + void setUnselectedLabelColor(const LLUIColor& c); + void setSelectedLabelColor(const LLUIColor& c); + void setUseEllipses(bool use_ellipses); + void setUseFontColor(bool use_font_color); boost::signals2::connection setClickedCallback(const CommitCallbackParam& cb); @@ -223,7 +226,6 @@ public: const std::string getLabelUnselected() const { return wstring_to_utf8str(mUnselectedLabel); } const std::string getLabelSelected() const { return wstring_to_utf8str(mSelectedLabel); } - void setImageColor(const std::string& color_control); void setImageColor(const LLUIColor& c); /*virtual*/ void setColor(const LLUIColor& c); @@ -278,7 +280,6 @@ public: void setCommitOnReturn(bool commit) { mCommitOnReturn = commit; } bool getCommitOnReturn() const { return mCommitOnReturn; } - static void onHeldDown(void *userdata); // to be called by gIdleCallbacks static void toggleFloaterAndSetToggleState(LLUICtrl* ctrl, const LLSD& sdname); static void setFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname); static void setDockableFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname); @@ -306,6 +307,7 @@ protected: commit_signal_t* mHeldDownSignal; const LLFontGL* mGLFont; + LLFontVertexBuffer mFontBuffer; S32 mMouseDownFrame; S32 mMouseHeldDownCount; // Counter for parameter passed to held-down callback diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 76abf5eaa2..25ef1336c8 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -3710,6 +3710,10 @@ S32 OSMessageBoxWin32(const std::string& text, const std::string& caption, U32 t // // "This is why I'm doing it this way, instead of what you would think would be more obvious..." // (C) Nat Goodspeed + if (!IsWindow(sWindowHandleForMessageBox)) + { + sWindowHandleForMessageBox = NULL; + } int retval_win = MessageBoxW(sWindowHandleForMessageBox, // HWND ll_convert_string_to_wide(text).c_str(), ll_convert_string_to_wide(caption).c_str(), diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index 11f049564a..0c56582ea6 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -328,7 +328,7 @@ void LLHUDNameTag::renderText() } LLColor4 label_color(0.f, 0.f, 0.f, alpha_factor); - hud_render_text(segment_iter->getText(), render_position, *fontp, segment_iter->mStyle, LLFontGL::NO_SHADOW, x_offset, y_offset, label_color, false); + hud_render_text(segment_iter->getText(), render_position, &segment_iter->mFontBufferLabel, *fontp, segment_iter->mStyle, LLFontGL::NO_SHADOW, x_offset, y_offset, label_color, false); } } @@ -373,7 +373,7 @@ void LLHUDNameTag::renderText() text_color = segment_iter->mColor; text_color.mV[VALPHA] *= alpha_factor; - hud_render_text(segment_iter->getText(), render_position, *fontp, style, shadow, x_offset, y_offset, text_color, false); + hud_render_text(segment_iter->getText(), render_position, &segment_iter->mFontBufferText, *fontp, style, shadow, x_offset, y_offset, text_color, false); } } /// Reset the default color to white. The renderer expects this to be the default. diff --git a/indra/newview/llhudnametag.h b/indra/newview/llhudnametag.h index 5cb7fa877e..ee315f47af 100644 --- a/indra/newview/llhudnametag.h +++ b/indra/newview/llhudnametag.h @@ -37,6 +37,7 @@ #include "llrect.h" //#include "llframetimer.h" #include "llfontgl.h" +#include "llfontvertexbuffer.h" #include #include @@ -67,6 +68,8 @@ protected: LLColor4 mColor; LLFontGL::StyleFlags mStyle; const LLFontGL* mFont; + LLFontVertexBuffer mFontBufferLabel; + LLFontVertexBuffer mFontBufferText; private: LLWString mText; std::map mFontWidthMap; diff --git a/indra/newview/llhudrender.cpp b/indra/newview/llhudrender.cpp index 5608ab763f..f027aa5552 100644 --- a/indra/newview/llhudrender.cpp +++ b/indra/newview/llhudrender.cpp @@ -39,6 +39,7 @@ #include "llui.h" void hud_render_utf8text(const std::string &str, const LLVector3 &pos_agent, + LLFontVertexBuffer *font_buffer, const LLFontGL &font, const U8 style, const LLFontGL::ShadowType shadow, @@ -47,10 +48,11 @@ void hud_render_utf8text(const std::string &str, const LLVector3 &pos_agent, const bool orthographic) { LLWString wstr(utf8str_to_wstring(str)); - hud_render_text(wstr, pos_agent, font, style, shadow, x_offset, y_offset, color, orthographic); + hud_render_text(wstr, pos_agent, font_buffer, font, style, shadow, x_offset, y_offset, color, orthographic); } void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, + LLFontVertexBuffer *font_buffer, const LLFontGL &font, const U8 style, const LLFontGL::ShadowType shadow, @@ -138,7 +140,14 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, LLUI::translate((F32) winX*1.0f/LLFontGL::sScaleX, (F32) winY*1.0f/(LLFontGL::sScaleY), -(((F32) winZ*2.f)-1.f)); F32 right_x; - font.render(wstr, 0, 0, 1, color, LLFontGL::LEFT, LLFontGL::BASELINE, style, shadow, static_cast(wstr.length()), 1000, &right_x, /*use_ellipses*/false, /*use_color*/true); + if (font_buffer) + { + font_buffer->render(&font, wstr, 0, 0, 1, color, LLFontGL::LEFT, LLFontGL::BASELINE, style, shadow, static_cast(wstr.length()), 1000, &right_x, /*use_ellipses*/false, /*use_color*/true); + } + else + { + font.render(wstr, 0, 0, 1, color, LLFontGL::LEFT, LLFontGL::BASELINE, style, shadow, static_cast(wstr.length()), 1000, &right_x, /*use_ellipses*/false, /*use_color*/true); + } LLUI::popMatrix(); gGL.popMatrix(); diff --git a/indra/newview/llhudrender.h b/indra/newview/llhudrender.h index eb8f07e4d4..be9fc7f084 100644 --- a/indra/newview/llhudrender.h +++ b/indra/newview/llhudrender.h @@ -28,6 +28,7 @@ #define LL_LLHUDRENDER_H #include "llfontgl.h" +#include "llfontvertexbuffer.h" class LLVector3; class LLFontGL; @@ -35,6 +36,7 @@ class LLFontGL; // Utility classes for rendering HUD elements void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, + LLFontVertexBuffer *font_buffer, const LLFontGL &font, const U8 style, const LLFontGL::ShadowType, @@ -46,9 +48,10 @@ void hud_render_text(const LLWString &wstr, // Legacy, slower void hud_render_utf8text(const std::string &str, const LLVector3 &pos_agent, + LLFontVertexBuffer *font_buffer, const LLFontGL &font, const U8 style, - const LLFontGL::ShadowType, + const LLFontGL::ShadowType, const F32 x_offset, const F32 y_offset, const LLColor4& color, diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp index fd0d8b696f..92f09c34a0 100644 --- a/indra/newview/llhudtext.cpp +++ b/indra/newview/llhudtext.cpp @@ -231,7 +231,7 @@ void LLHUDText::renderText() } text_color.mV[VALPHA] *= alpha_factor; - hud_render_text(segment_iter->getText(), render_position, *fontp, style, shadow, x_offset, y_offset, text_color, mOnHUDAttachment); + hud_render_text(segment_iter->getText(), render_position, &mFontBuffer, *fontp, style, shadow, x_offset, y_offset, text_color, mOnHUDAttachment); } } /// Reset the default color to white. The renderer expects this to be the default. diff --git a/indra/newview/llhudtext.h b/indra/newview/llhudtext.h index a81fdebb17..224677736c 100644 --- a/indra/newview/llhudtext.h +++ b/indra/newview/llhudtext.h @@ -35,6 +35,7 @@ #include "v2math.h" #include "llrect.h" #include "llfontgl.h" +#include "llfontvertexbuffer.h" #include #include @@ -161,6 +162,7 @@ private: ETextAlignment mTextAlignment; EVertAlignment mVertAlignment; bool mHidden; + LLFontVertexBuffer mFontBuffer; static bool sDisplayText ; static std::set > sTextObjects; diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp index 0d617753c8..9a0b1bfcd6 100644 --- a/indra/newview/llmanip.cpp +++ b/indra/newview/llmanip.cpp @@ -519,9 +519,9 @@ void LLManip::renderTickText(const LLVector3& pos, const std::string& text, cons LLColor4 shadow_color = LLColor4::black; shadow_color.mV[VALPHA] = color.mV[VALPHA] * 0.5f; gViewerWindow->setup3DViewport(1, -1); - hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(text), 3.f, shadow_color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD); + hud_render_utf8text(text, render_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(text), 3.f, shadow_color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD); gViewerWindow->setup3DViewport(); - hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(text), 3.f, color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD); + hud_render_utf8text(text, render_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(text), 3.f, color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD); gGL.popMatrix(); } @@ -581,12 +581,12 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const std::string { fraction_string = llformat("%c%02d%s", LLResMgr::getInstance()->getDecimalPoint(), fractional_portion, suffix.c_str()); - hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, -1.f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection); - hud_render_utf8text(fraction_string, render_pos, *small_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, 1.f, 3.f, color, hud_selection); + hud_render_utf8text(val_string, render_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, -1.f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection); + hud_render_utf8text(fraction_string, render_pos, nullptr, *small_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, 1.f, 3.f, color, hud_selection); } else { - hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, -0.5f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection); + hud_render_utf8text(val_string, render_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, -0.5f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection); } } gGL.popMatrix(); diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp index 5bdf3f81b5..0d80b8d8ba 100644 --- a/indra/newview/llmaniprotate.cpp +++ b/indra/newview/llmaniprotate.cpp @@ -1169,10 +1169,10 @@ void LLManipRotate::renderSnapGuides() std::string help_text = LLTrans::getString("manip_hint1"); LLColor4 help_text_color = LLColor4::white; help_text_color.mV[VALPHA] = clamp_rescale(mHelpTextTimer.getElapsedTimeF32(), sHelpTextVisibleTime, sHelpTextVisibleTime + sHelpTextFadeTime, line_alpha, 0.f); - hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); + hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); help_text = LLTrans::getString("manip_hint2"); help_text_pos -= offset_dir * mRadiusMeters * 0.4f; - hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); + hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); } } } diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index ffb66dc6cc..19868f3c3e 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -1865,10 +1865,10 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) std::string help_text = LLTrans::getString("manip_hint1"); LLColor4 help_text_color = LLColor4::white; help_text_color.mV[VALPHA] = clamp_rescale(mHelpTextTimer.getElapsedTimeF32(), sHelpTextVisibleTime, sHelpTextVisibleTime + sHelpTextFadeTime, grid_alpha, 0.f); - hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); + hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); help_text = LLTrans::getString("manip_hint2"); help_text_pos -= LLViewerCamera::getInstance()->getUpAxis() * mSnapRegimeOffset * 0.4f; - hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); + hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); } } } diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index c11a98be50..c9c7d26d33 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -1449,10 +1449,10 @@ void LLManipTranslate::renderSnapGuides() std::string help_text = LLTrans::getString("manip_hint1"); LLColor4 help_text_color = LLColor4::white; help_text_color.mV[VALPHA] = clamp_rescale(mHelpTextTimer.getElapsedTimeF32(), sHelpTextVisibleTime, sHelpTextVisibleTime + sHelpTextFadeTime, line_alpha, 0.f); - hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); + hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); help_text = LLTrans::getString("manip_hint2"); help_text_pos -= LLViewerCamera::getInstance()->getUpAxis() * mSnapOffsetMeters * 0.2f; - hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); + hud_render_utf8text(help_text, help_text_pos, nullptr, *big_fontp, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, false); } } } From 2bae8dfb815cf4d04cb4882c2fb889e3fb9666b2 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 29 Aug 2024 17:03:00 +0300 Subject: [PATCH 14/19] Remove usused LLButton::mBorderEnabled --- indra/llui/llbutton.h | 3 --- indra/llui/llfloater.cpp | 15 --------------- indra/llui/llpanel.cpp | 22 ---------------------- 3 files changed, 40 deletions(-) diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index f522281e30..c8e2b941c9 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -264,8 +264,6 @@ public: void setDropShadowedText(bool b) { mDropShadowedText = b; } - void setBorderEnabled(bool b) { mBorderEnabled = b; } - void setHoverGlowStrength(F32 strength) { mHoverGlowStrength = strength; } void setImageUnselected(LLPointer image); @@ -360,7 +358,6 @@ protected: bool mAutoResize; bool mUseEllipses; bool mUseFontColor; - bool mBorderEnabled; bool mFlashing; LLFontGL::HAlign mHAlign; diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 6ad74c09e6..92fb4b75bf 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2042,21 +2042,6 @@ void LLFloater::draw() LLPanel::updateDefaultBtn(); - if( getDefaultButton() ) - { - if (hasFocus() && getDefaultButton()->getEnabled()) - { - LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus(); - // is this button a direct descendent and not a nested widget (e.g. checkbox)? - bool focus_is_child_button = dynamic_cast(focus_ctrl) != NULL && dynamic_cast(focus_ctrl)->getParent() == this; - // only enable default button when current focus is not a button - getDefaultButton()->setBorderEnabled(!focus_is_child_button); - } - else - { - getDefaultButton()->setBorderEnabled(false); - } - } if (isMinimized()) { for (S32 i = 0; i < BUTTON_COUNT; i++) diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 8e96bdde80..db314cae0f 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -242,20 +242,6 @@ void LLPanel::draw() void LLPanel::updateDefaultBtn() { - if( mDefaultBtn) - { - if (gFocusMgr.childHasKeyboardFocus( this ) && mDefaultBtn->getEnabled()) - { - LLButton* buttonp = dynamic_cast(gFocusMgr.getKeyboardFocus()); - bool focus_is_child_button = buttonp && buttonp->getCommitOnReturn(); - // only enable default button when current focus is not a return-capturing button - mDefaultBtn->setBorderEnabled(!focus_is_child_button); - } - else - { - mDefaultBtn->setBorderEnabled(false); - } - } } void LLPanel::refresh() @@ -266,15 +252,7 @@ void LLPanel::refresh() void LLPanel::setDefaultBtn(LLButton* btn) { - if (mDefaultBtn && mDefaultBtn->getEnabled()) - { - mDefaultBtn->setBorderEnabled(false); - } mDefaultBtn = btn; - if (mDefaultBtn) - { - mDefaultBtn->setBorderEnabled(true); - } } void LLPanel::setDefaultBtn(std::string_view id) From a638d9610d9f369eca6dff74e8860ca466c253c7 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 29 Aug 2024 18:49:10 +0300 Subject: [PATCH 15/19] viewer#2411 LLFontGL::render optimizations #2 --- indra/llrender/llfontgl.cpp | 3 + indra/llrender/llfontvertexbuffer.cpp | 119 +++++++++++++++++--------- indra/llrender/llfontvertexbuffer.h | 15 +++- indra/llui/llbutton.cpp | 64 ++++++++++++-- indra/llui/llbutton.h | 43 +++++----- indra/newview/llhudnametag.cpp | 19 ++++ indra/newview/llhudnametag.h | 1 + 7 files changed, 192 insertions(+), 72 deletions(-) diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 481e35c16a..701ab4d060 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -490,6 +490,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons if (draw_ellipses) { + // signal a separate context + buffer_list->emplace_back(nullptr, nullptr, 0, 0); + // recursively render ellipses at end of string // we've already reserved enough room gGL.pushUIMatrix(); diff --git a/indra/llrender/llfontvertexbuffer.cpp b/indra/llrender/llfontvertexbuffer.cpp index 3ff0771795..c4b68c4a6c 100644 --- a/indra/llrender/llfontvertexbuffer.cpp +++ b/indra/llrender/llfontvertexbuffer.cpp @@ -53,7 +53,8 @@ S32 LLFontVertexBuffer::render( 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, @@ -64,62 +65,33 @@ S32 LLFontVertexBuffer::render( genBuffers(fontp, text, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); } - else if (mLastX != x || mLastY != y || mLastColor != color) // always track position and alphs + else if (mLastX != x || mLastY != y + || mLastFont != fontp + || mLastColor != color // alphas change often + || mLastHalign != halign + || mLastValign != valign + || mLastOffset != begin_offset + || mLastMaxChars != max_chars + || mLastMaxPixels != max_pixels + || mLastStyle != style + || mLastShadow != shadow) // ex: buttons change shadow state { genBuffers(fontp, text, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); } - else if (true //mTrackStringChanges - && (mLastOffset != begin_offset - || mLastMaxChars != max_chars - || mLastMaxPixels != max_pixels - || mLastStringHash != sStringHasher._Do_hash(text))) // todo, track all parameters? + else if (mTrackStringChanges && mLastStringHash != sStringHasher._Do_hash(text)) { genBuffers(fontp, text, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); } else { + renderBuffers(); - gGL.flush(); // deliberately empty pending verts - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gGL.pushUIMatrix(); - - gGL.loadUIIdentity(); - - // Depth translation, so that floating text appears 'in-world' - // and is correctly occluded. - gGL.translatef(0.f, 0.f, LLFontGL::sCurDepth); - - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - for (auto &buf_data : mBufferList) - { - if (buf_data.mImage) - { - gGL.getTexUnit(0)->bind(buf_data.mImage); - } - else - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - } - buf_data.mBuffer->setBuffer(); - - if (LLRender::sGLCoreProfile && buf_data.mMode == LLRender::QUADS) - { - buf_data.mBuffer->drawArrays(LLRender::TRIANGLES, 0, buf_data.mCount); - } - else - { - buf_data.mBuffer->drawArrays(buf_data.mMode, 0, buf_data.mCount); - } - } if (right_x) { *right_x = mLastRightX; } - - gGL.popUIMatrix(); } return mChars; } @@ -141,6 +113,7 @@ void LLFontVertexBuffer::genBuffers( mChars = fontp->render(text, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color, &mBufferList); + mLastFont = fontp; mLastOffset = begin_offset; mLastMaxChars = max_chars; mLastMaxPixels = max_pixels; @@ -148,6 +121,10 @@ void LLFontVertexBuffer::genBuffers( mLastX = x; mLastY = y; mLastColor = color; + mLastHalign = halign; + mLastValign = valign; + mLastStyle = style; + mLastShadow = shadow; if (right_x) { @@ -155,3 +132,61 @@ void LLFontVertexBuffer::genBuffers( } } +void render_buffers(LLFontVertexBuffer::buffer_list_t::iterator iter, LLFontVertexBuffer::buffer_list_t::iterator end) +{ + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.pushUIMatrix(); + + gGL.loadUIIdentity(); + + // Depth translation, so that floating text appears 'in-world' + // and is correctly occluded. + gGL.translatef(0.f, 0.f, LLFontGL::sCurDepth); + + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + while (iter != end) + { + if (iter->mBuffer == nullptr) + { + // elipses indicator + iter++; + break; + } + if (iter->mImage) + { + gGL.getTexUnit(0)->bind(iter->mImage); + } + else + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + iter->mBuffer->setBuffer(); + + if (LLRender::sGLCoreProfile && iter->mMode == LLRender::QUADS) + { + iter->mBuffer->drawArrays(LLRender::TRIANGLES, 0, iter->mCount); + } + else + { + iter->mBuffer->drawArrays(iter->mMode, 0, iter->mCount); + } + iter++; + } + + if (iter != end) + { + gGL.pushUIMatrix(); + render_buffers(iter, end); + gGL.popUIMatrix(); + } + + gGL.popUIMatrix(); +} + +void LLFontVertexBuffer::renderBuffers() +{ + gGL.flush(); // deliberately empty pending verts + render_buffers(mBufferList.begin(), mBufferList.end()); +} + 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; diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 3df7f83d49..a9f1c10256 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -125,7 +125,6 @@ LLButton::LLButton(const LLButton::Params& p) mFontBuffer(false), mMouseDownFrame(0), mMouseHeldDownCount(0), - mBorderEnabled( false ), mFlashing( false ), mCurGlowStrength(0.f), mNeedsHighlight(false), @@ -423,11 +422,38 @@ bool LLButton::postBuild() void LLButton::onVisibilityChange(bool new_visibility) { - if (!new_visibility) + mFontBuffer.reset(); + return LLUICtrl::onVisibilityChange(new_visibility); +} + +void LLButton::reshape(S32 width, S32 height, bool called_from_parent) +{ + S32 delta_width = width - getRect().getWidth(); + S32 delta_height = height - getRect().getHeight(); + + if (delta_width || delta_height || sForceReshape) { + LLUICtrl::reshape(width, height, called_from_parent); mFontBuffer.reset(); } - return LLUICtrl::onVisibilityChange(new_visibility); +} + +void LLButton::translate(S32 x, S32 y) +{ + LLUICtrl::translate(x, y); + mFontBuffer.reset(); +} + +void LLButton::setRect(const LLRect& rect) +{ + LLUICtrl::setRect(rect); + mFontBuffer.reset(); +} + +void LLButton::dirtyRect() +{ + LLUICtrl::dirtyRect(); + mFontBuffer.reset(); } bool LLButton::handleUnicodeCharHere(llwchar uni_char) @@ -616,19 +642,25 @@ void LLButton::onMouseLeave(S32 x, S32 y, MASK mask) { LLUICtrl::onMouseLeave(x, y, mask); - mNeedsHighlight = false; + setHighlight(false); } void LLButton::setHighlight(bool b) { - mNeedsHighlight = b; + if (mNeedsHighlight != b) + { + mNeedsHighlight = b; + mFontBuffer.reset(); + } } bool LLButton::handleHover(S32 x, S32 y, MASK mask) { if (isInEnabledChain() && (!gFocusMgr.getMouseCapture() || gFocusMgr.getMouseCapture() == this)) - mNeedsHighlight = true; + { + setHighlight(true); + } if (!childrenHandleHover(x, y, mask)) { @@ -1096,6 +1128,18 @@ void LLButton::setLabelSelected( const LLStringExplicit& label ) mFontBuffer.reset(); } +void LLButton::setDisabledLabelColor(const LLUIColor& c) +{ + mDisabledLabelColor = c; + mFontBuffer.reset(); +} + +void LLButton::setFont(const LLFontGL* font) +{ + mGLFont = (font ? font : LLFontGL::getFontSansSerif()); + mFontBuffer.reset(); +} + bool LLButton::labelIsTruncated() const { return getCurrentLabel().getString().size() > mLastDrawCharsCount; @@ -1106,6 +1150,12 @@ const LLUIString& LLButton::getCurrentLabel() const return getToggleState() ? mSelectedLabel : mUnselectedLabel; } +void LLButton::setDropShadowedText(bool b) +{ + mDropShadowedText = b; + mFontBuffer.reset(); +} + void LLButton::setImageUnselected(LLPointer image) { mImageUnselected = image; @@ -1153,7 +1203,6 @@ void LLButton::resize(const LLUIString& label) if (btn_width < min_width) { reshape(min_width, getRect().getHeight()); - mFontBuffer.reset(); } } } @@ -1190,6 +1239,7 @@ void LLButton::setImageDisabledSelected(LLPointer image) mImageDisabledSelected = image; mDisabledImageColor = mImageColor; mFadeWhenDisabled = true; + mFontBuffer.reset(); } void LLButton::setImagePressed(LLPointer image) diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index c8e2b941c9..74ed922510 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -157,23 +157,27 @@ public: void addImageAttributeToXML(LLXMLNodePtr node, const std::string& imageName, const LLUUID& imageID,const std::string& xmlTagName) const; - virtual bool handleUnicodeCharHere(llwchar uni_char); - virtual bool handleKeyHere(KEY key, MASK mask); - virtual bool handleMouseDown(S32 x, S32 y, MASK mask); - virtual bool handleMouseUp(S32 x, S32 y, MASK mask); - virtual bool handleHover(S32 x, S32 y, MASK mask); - virtual bool handleRightMouseDown(S32 x, S32 y, MASK mask); - virtual bool handleRightMouseUp(S32 x, S32 y, MASK mask); - virtual bool handleDoubleClick(S32 x, S32 y, MASK mask); - virtual void draw(); - /*virtual*/ bool postBuild(); + virtual bool handleUnicodeCharHere(llwchar uni_char) override; + virtual bool handleKeyHere(KEY key, MASK mask) override; + virtual bool handleMouseDown(S32 x, S32 y, MASK mask) override; + virtual bool handleMouseUp(S32 x, S32 y, MASK mask) override; + virtual bool handleHover(S32 x, S32 y, MASK mask) override; + virtual bool handleRightMouseDown(S32 x, S32 y, MASK mask) override; + virtual bool handleRightMouseUp(S32 x, S32 y, MASK mask) override; + virtual bool handleDoubleClick(S32 x, S32 y, MASK mask) override; + virtual void draw() override; + /*virtual*/ bool postBuild() override; - /*virtual*/ void onVisibilityChange(bool visible); + void onVisibilityChange(bool visible) override; + void reshape(S32 width, S32 height, bool called_from_parent = true) override; + void translate(S32 x, S32 y) override; + void setRect(const LLRect& rect) override; + void dirtyRect() override; - virtual void onMouseLeave(S32 x, S32 y, MASK mask); - virtual void onMouseCaptureLost(); + virtual void onMouseLeave(S32 x, S32 y, MASK mask) override; + virtual void onMouseCaptureLost() override; - virtual void onCommit(); + virtual void onCommit() override; void setUnselectedLabelColor(const LLUIColor& c); void setSelectedLabelColor(const LLUIColor& c); @@ -227,7 +231,7 @@ public: const std::string getLabelSelected() const { return wstring_to_utf8str(mSelectedLabel); } void setImageColor(const LLUIColor& c); - /*virtual*/ void setColor(const LLUIColor& c); + /*virtual*/ void setColor(const LLUIColor& c) override; void setImages(const std::string &image_name, const std::string &selected_name); @@ -245,13 +249,12 @@ public: void setLabel(const std::string& label); void setLabel(const LLUIString& label); void setLabel( const LLStringExplicit& label); - virtual bool setLabelArg( const std::string& key, const LLStringExplicit& text ); + virtual bool setLabelArg( const std::string& key, const LLStringExplicit& text ) override; void setLabelUnselected(const LLStringExplicit& label); void setLabelSelected(const LLStringExplicit& label); - void setDisabledLabelColor( const LLUIColor& c ) { mDisabledLabelColor = c; } + void setDisabledLabelColor(const LLUIColor& c); - void setFont(const LLFontGL *font) - { mGLFont = ( font ? font : LLFontGL::getFontSansSerif()); } + void setFont(const LLFontGL* font); const LLFontGL* getFont() const { return mGLFont; } const std::string& getText() const { return getCurrentLabel().getString(); } @@ -262,7 +265,7 @@ public: void setScaleImage(bool scale) { mScaleImage = scale; } bool getScaleImage() const { return mScaleImage; } - void setDropShadowedText(bool b) { mDropShadowedText = b; } + void setDropShadowedText(bool b); void setHoverGlowStrength(F32 strength) { mHoverGlowStrength = strength; } diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index 0c56582ea6..19ae35813c 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -290,6 +290,15 @@ void LLHUDNameTag::renderText() LLVector3 render_position = mPositionAgent + (x_pixel_vec * screen_offset.mV[VX]) + (y_pixel_vec * screen_offset.mV[VY]); + bool reset_buffers = false; + const F32 treshold = 0.000001f; + if (abs(mLastRenderPosition.mV[VX] - render_position.mV[VX]) > treshold + || abs(mLastRenderPosition.mV[VY] - render_position.mV[VY]) > treshold + || abs(mLastRenderPosition.mV[VZ] - render_position.mV[VZ]) > treshold) + { + reset_buffers = true; + mLastRenderPosition = render_position; + } LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); LLRect screen_rect; @@ -313,6 +322,11 @@ void LLHUDNameTag::renderText() for(std::vector::iterator segment_iter = mLabelSegments.begin(); segment_iter != mLabelSegments.end(); ++segment_iter ) { + if (reset_buffers) + { + segment_iter->mFontBufferLabel.reset(); + } + // Label segments use default font const LLFontGL* fontp = (segment_iter->mStyle == LLFontGL::BOLD) ? mBoldFontp : mFontp; y_offset -= fontp->getLineHeight(); @@ -350,6 +364,11 @@ void LLHUDNameTag::renderText() for (std::vector::iterator segment_iter = mTextSegments.begin() + start_segment; segment_iter != mTextSegments.end(); ++segment_iter ) { + if (reset_buffers) + { + segment_iter->mFontBufferText.reset(); + } + const LLFontGL* fontp = segment_iter->mFont; y_offset -= fontp->getLineHeight(); y_offset -= LINE_PADDING; diff --git a/indra/newview/llhudnametag.h b/indra/newview/llhudnametag.h index ee315f47af..b48a606982 100644 --- a/indra/newview/llhudnametag.h +++ b/indra/newview/llhudnametag.h @@ -177,6 +177,7 @@ private: S32 mMaxLines; S32 mOffsetY; F32 mRadius; + LLVector3 mLastRenderPosition; std::vector mTextSegments; std::vector mLabelSegments; // LLFrameTimer mResizeTimer; From 5c64e5e13d9a75cac510aac3128fc6ee780ab243 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 30 Aug 2024 18:51:48 +0300 Subject: [PATCH 16/19] viewer#2411 LLFontGL::render optimizations #3 --- indra/llrender/llfontgl.cpp | 118 ++--------------- indra/llrender/llfontgl.h | 15 +-- indra/llrender/llfontvertexbuffer.cpp | 81 ++++-------- indra/llrender/llfontvertexbuffer.h | 12 +- indra/llrender/llrender.cpp | 175 ++++++++++++++++---------- indra/llrender/llrender.h | 9 +- indra/llrender/llvertexbuffer.cpp | 47 +++++++ indra/llrender/llvertexbuffer.h | 31 +++++ indra/newview/llhudnametag.h | 4 +- 9 files changed, 244 insertions(+), 248 deletions(-) diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 701ab4d060..7d74bb3e46 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -42,7 +42,6 @@ #include "lltexture.h" #include "lldir.h" #include "llstring.h" -#include "llvertexbuffer.h" // Third party library includes #include @@ -145,8 +144,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, const LLRectf& rec S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, - ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, bool use_ellipses, bool use_color, - std::list *buffer_list) const + ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, bool use_ellipses, bool use_color) const { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -160,7 +158,6 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons return 0; } - gGL.flush(); // deliberately empty pending verts gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); S32 scaled_max_pixels = max_pixels == S32_MAX ? S32_MAX : llceil((F32)max_pixels * sScaleX); @@ -286,9 +283,6 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons std::pair bitmap_entry = std::make_pair(EFontGlyphType::Grayscale, -1); S32 glyph_count = 0; - S32 buffer_count = 0; - LLVertexBuffer* vb; - LLImageGL* font_image = nullptr; for (i = begin_offset; i < begin_offset + length; i++) { llwchar wch = wstr[i]; @@ -312,35 +306,16 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons // otherwise the queued glyphs will be taken from wrong textures. if (glyph_count > 0) { - if (buffer_list) + gGL.begin(LLRender::QUADS); { - vb = gGL.beginNoCache(LLRender::QUADS, buffer_count); - if (vb) - { - buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); - } - gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); - - vb = gGL.getBuffer(buffer_count); // instead of endNoCache to draw now - if (vb) - { - buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); - } - } - else - { - gGL.begin(LLRender::QUADS); - { - gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); - } - gGL.end(); } + gGL.end(); glyph_count = 0; } bitmap_entry = next_bitmap_entry; - font_image = font_bitmap_cache->getImageGL(bitmap_entry.first, bitmap_entry.second); + LLImageGL* font_image = font_bitmap_cache->getImageGL(bitmap_entry.first, bitmap_entry.second); gGL.getTexUnit(0)->bind(font_image); } @@ -364,28 +339,11 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons if (glyph_count >= GLYPH_BATCH_SIZE) { - if (buffer_list) + gGL.begin(LLRender::QUADS); { - vb = gGL.beginNoCache(LLRender::QUADS, buffer_count); - if (vb) - { - buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); - } gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); - vb = gGL.endNoCache(buffer_count); - if (vb) - { - buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); - } - } - else - { - gGL.begin(LLRender::QUADS); - { - gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); - } - gGL.end(); } + gGL.end(); glyph_count = 0; } @@ -418,29 +376,11 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons cur_render_x = cur_x; cur_render_y = cur_y; } - - if (buffer_list) + gGL.begin(LLRender::QUADS); { - vb = gGL.beginNoCache(LLRender::QUADS, buffer_count); - if (vb) - { - buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); - } gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); - vb = gGL.endNoCache(buffer_count); - if (vb) - { - buffer_list->emplace_back(vb, font_image, LLRender::QUADS, buffer_count); - } - } - else - { - gGL.begin(LLRender::QUADS); - { - gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); - } - gGL.end(); } + gGL.end(); if (right_x) @@ -454,45 +394,14 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons F32 descender = (F32)llfloor(mFontFreetype->getDescenderHeight()); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - if (buffer_list) - { - vb = gGL.beginNoCache(LLRender::LINES, buffer_count); - if (vb) - { - buffer_list->emplace_back(vb, nullptr, LLRender::QUADS, buffer_count); - } - - gGL.vertex2f(start_x, cur_y - descender); - gGL.vertex2f(cur_x, cur_y - descender); - - vb = gGL.getBuffer(buffer_count); - if (vb) - { - buffer_list->emplace_back(vb, nullptr, LLRender::LINES, buffer_count); - } - } - else - { - gGL.begin(LLRender::LINES); - gGL.vertex2f(start_x, cur_y - descender); - gGL.vertex2f(cur_x, cur_y - descender); - gGL.end(); - } - } - else if (buffer_list) - { - vb = gGL.getBuffer(buffer_count); - if (vb) - { - buffer_list->emplace_back(vb, font_image, gGL.getMode(), buffer_count); - } + gGL.begin(LLRender::LINES); + gGL.vertex2f(start_x, cur_y - descender); + gGL.vertex2f(cur_x, cur_y - descender); + gGL.end(); } if (draw_ellipses) { - // signal a separate context - buffer_list->emplace_back(nullptr, nullptr, 0, 0); - // recursively render ellipses at end of string // we've already reserved enough room gGL.pushUIMatrix(); @@ -507,8 +416,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons S32_MAX, max_pixels, right_x, false, - use_color, - buffer_list); + use_color); gGL.popUIMatrix(); } diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index 5015601cf6..de7529a583 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -33,7 +33,6 @@ #include "llimagegl.h" #include "llpointer.h" #include "llrect.h" -#include "llvertexbuffer.h" #include "v2math.h" class LLColor4; @@ -43,7 +42,6 @@ class LLFontFreetype; // Structure used to store previously requested fonts. class LLFontRegistry; -class LLVertexBuffer; class LLFontGL { @@ -81,16 +79,6 @@ public: DROP_SHADOW_SOFT }; - struct LLVertexBufferData - { - LLVertexBufferData() : mBuffer(nullptr), mImage(nullptr), mMode(0), mCount(0) {} - LLVertexBufferData(LLVertexBuffer* buffer, LLImageGL* image, U8 mode, U32 count) : mBuffer(buffer), mImage(image), mMode(mode), mCount(count) {} - LLPointer mBuffer; - LLPointer mImage; // might be a better idea to store - U8 mMode; - U32 mCount; - }; - LLFontGL(); ~LLFontGL(); @@ -131,8 +119,7 @@ public: S32 max_chars = S32_MAX, S32 max_pixels = S32_MAX, F32* right_x=NULL, bool use_ellipses = false, - bool use_color = true, - std::list* buffer_list = nullptr) const; + bool use_color = true) const; S32 render(const LLWString &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color) const; diff --git a/indra/llrender/llfontvertexbuffer.cpp b/indra/llrender/llfontvertexbuffer.cpp index c4b68c4a6c..284762dc94 100644 --- a/indra/llrender/llfontvertexbuffer.cpp +++ b/indra/llrender/llfontvertexbuffer.cpp @@ -60,12 +60,17 @@ S32 LLFontVertexBuffer::render( bool use_ellipses, bool use_color ) { + if (!LLFontGL::sDisplayFont) //do not display texts + { + return static_cast(text.length()); + } if (mBufferList.empty()) { genBuffers(fontp, text, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); } - else if (mLastX != x || mLastY != y + else if (mLastX != x + || mLastY != y || mLastFont != fontp || mLastColor != color // alphas change often || mLastHalign != halign @@ -74,7 +79,10 @@ S32 LLFontVertexBuffer::render( || mLastMaxChars != max_chars || mLastMaxPixels != max_pixels || mLastStyle != style - || mLastShadow != shadow) // ex: buttons change shadow state + || mLastShadow != shadow // ex: buttons change shadow state + || mLastScaleX != LLFontGL::sScaleX + || mLastScaleY != LLFontGL::sScaleY + || mLastOrigin != LLFontGL::sCurOrigin) { genBuffers(fontp, text, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); @@ -110,8 +118,11 @@ void LLFontVertexBuffer::genBuffers( bool use_color) { mBufferList.clear(); + + gGL.beginList(&mBufferList); mChars = fontp->render(text, begin_offset, x, y, color, halign, valign, - style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color, &mBufferList); + style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); + gGL.endList(); mLastFont = fontp; mLastOffset = begin_offset; @@ -126,67 +137,25 @@ void LLFontVertexBuffer::genBuffers( mLastStyle = style; mLastShadow = shadow; + mLastScaleX = LLFontGL::sScaleX; + mLastScaleY = LLFontGL::sScaleY; + mLastOrigin = LLFontGL::sCurOrigin; + if (right_x) { mLastRightX = *right_x; } } -void render_buffers(LLFontVertexBuffer::buffer_list_t::iterator iter, LLFontVertexBuffer::buffer_list_t::iterator end) -{ - gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); - gGL.pushUIMatrix(); - - gGL.loadUIIdentity(); - - // Depth translation, so that floating text appears 'in-world' - // and is correctly occluded. - gGL.translatef(0.f, 0.f, LLFontGL::sCurDepth); - - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - while (iter != end) - { - if (iter->mBuffer == nullptr) - { - // elipses indicator - iter++; - break; - } - if (iter->mImage) - { - gGL.getTexUnit(0)->bind(iter->mImage); - } - else - { - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - } - iter->mBuffer->setBuffer(); - - if (LLRender::sGLCoreProfile && iter->mMode == LLRender::QUADS) - { - iter->mBuffer->drawArrays(LLRender::TRIANGLES, 0, iter->mCount); - } - else - { - iter->mBuffer->drawArrays(iter->mMode, 0, iter->mCount); - } - iter++; - } - - if (iter != end) - { - gGL.pushUIMatrix(); - render_buffers(iter, end); - gGL.popUIMatrix(); - } - - gGL.popUIMatrix(); -} - void LLFontVertexBuffer::renderBuffers() { gGL.flush(); // deliberately empty pending verts - render_buffers(mBufferList.begin(), mBufferList.end()); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.pushUIMatrix(); + for (LLVertexBufferData& buffer : mBufferList) + { + buffer.draw(); + } + gGL.popUIMatrix(); } 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; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 8cd2d9cc15..182f61f907 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -77,6 +77,7 @@ struct LLVBCache }; static std::unordered_map sVBCache; +static thread_local std::list *sBufferDataList = nullptr; static const GLenum sGLTextureType[] = { @@ -1528,6 +1529,25 @@ void LLRender::clearErrors() } } +void LLRender::beginList(std::list *list) +{ + flush(); + sBufferDataList = list; +} + +void LLRender::endList() +{ + if (sBufferDataList) + { + flush(); + sBufferDataList = nullptr; + } + else + { + llassert(false); // something failed to provide a list or closed it twice + } +} + void LLRender::begin(const GLuint& mode) { if (mode != mMode) @@ -1663,78 +1683,26 @@ void LLRender::flush() if (mBuffer) { - HBXXH64 hash; + LLVertexBuffer *vb; + U32 attribute_mask = LLGLSLShader::sCurBoundShaderPtr->mAttributeMask; + if (sBufferDataList) { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache hash"); - - hash.update((U8*)mVerticesp.get(), count * sizeof(LLVector4a)); - if (attribute_mask & LLVertexBuffer::MAP_TEXCOORD0) - { - hash.update((U8*)mTexcoordsp.get(), count * sizeof(LLVector2)); - } - - if (attribute_mask & LLVertexBuffer::MAP_COLOR) - { - hash.update((U8*)mColorsp.get(), count * sizeof(LLColor4U)); - } - - hash.finalize(); - } - - - U64 vhash = hash.digest(); - - // check the VB cache before making a new vertex buffer - // This is a giant hack to deal with (mostly) our terrible UI rendering code - // that was built on top of OpenGL immediate mode. Huge performance wins - // can be had by not uploading geometry to VRAM unless absolutely necessary. - // Most of our usage of the "immediate mode" style draw calls is actually - // sending the same geometry over and over again. - // To leverage this, we maintain a running hash of the vertex stream being - // built up before a flush, and then check that hash against a VB - // cache just before creating a vertex buffer in VRAM - std::unordered_map::iterator cache = sVBCache.find(vhash); - - LLPointer vb; - - if (cache != sVBCache.end()) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache hit"); - // cache hit, just use the cached buffer - vb = cache->second.vb; - cache->second.touched = std::chrono::steady_clock::now(); + vb = genBuffer(attribute_mask, count); + sBufferDataList->emplace_back( + vb, + mMode, + count, + gGL.getTexUnit(0)->mCurrTexture, + mMatrix[MM_MODELVIEW][mMatIdx[MM_MODELVIEW]], + mMatrix[MM_PROJECTION][mMatIdx[MM_PROJECTION]], + mMatrix[MM_TEXTURE0][mMatIdx[MM_TEXTURE0]] + ); } else { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache miss"); - vb = genBuffer(attribute_mask, count); - - sVBCache[vhash] = { vb , std::chrono::steady_clock::now() }; - - static U32 miss_count = 0; - miss_count++; - if (miss_count > 1024) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache clean"); - miss_count = 0; - auto now = std::chrono::steady_clock::now(); - - using namespace std::chrono_literals; - // every 1024 misses, clean the cache of any VBs that haven't been touched in the last second - for (std::unordered_map::iterator iter = sVBCache.begin(); iter != sVBCache.end(); ) - { - if (now - iter->second.touched > 1s) - { - iter = sVBCache.erase(iter); - } - else - { - ++iter; - } - } - } + vb = bufferfromCache(attribute_mask, count); } drawBuffer(vb, mMode, count); @@ -1749,6 +1717,81 @@ void LLRender::flush() } } +LLVertexBuffer* LLRender::bufferfromCache(U32 attribute_mask, U32 count) +{ + LLVertexBuffer *vb = nullptr; + HBXXH64 hash; + + { + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache hash"); + + hash.update((U8*)mVerticesp.get(), count * sizeof(LLVector4a)); + if (attribute_mask & LLVertexBuffer::MAP_TEXCOORD0) + { + hash.update((U8*)mTexcoordsp.get(), count * sizeof(LLVector2)); + } + + if (attribute_mask & LLVertexBuffer::MAP_COLOR) + { + hash.update((U8*)mColorsp.get(), count * sizeof(LLColor4U)); + } + + hash.finalize(); + } + + U64 vhash = hash.digest(); + + // check the VB cache before making a new vertex buffer + // This is a giant hack to deal with (mostly) our terrible UI rendering code + // that was built on top of OpenGL immediate mode. Huge performance wins + // can be had by not uploading geometry to VRAM unless absolutely necessary. + // Most of our usage of the "immediate mode" style draw calls is actually + // sending the same geometry over and over again. + // To leverage this, we maintain a running hash of the vertex stream being + // built up before a flush, and then check that hash against a VB + // cache just before creating a vertex buffer in VRAM + std::unordered_map::iterator cache = sVBCache.find(vhash); + + if (cache != sVBCache.end()) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache hit"); + // cache hit, just use the cached buffer + vb = cache->second.vb; + cache->second.touched = std::chrono::steady_clock::now(); + } + else + { + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache miss"); + vb = genBuffer(attribute_mask, count); + + sVBCache[vhash] = { vb , std::chrono::steady_clock::now() }; + + static U32 miss_count = 0; + miss_count++; + if (miss_count > 1024) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache clean"); + miss_count = 0; + auto now = std::chrono::steady_clock::now(); + + using namespace std::chrono_literals; + // every 1024 misses, clean the cache of any VBs that haven't been touched in the last second + for (std::unordered_map::iterator iter = sVBCache.begin(); iter != sVBCache.end(); ) + { + if (now - iter->second.touched > 1s) + { + iter = sVBCache.erase(iter); + } + else + { + ++iter; + } + } + } + } + return vb; +} + LLVertexBuffer* LLRender::genBuffer(U32 attribute_mask, S32 count) { LLVertexBuffer * vb = new LLVertexBuffer(attribute_mask); diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 5f84a4a275..aeee8685ab 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -50,7 +50,8 @@ class LLVertexBuffer; class LLCubeMap; class LLImageGL; class LLRenderTarget; -class LLTexture ; +class LLTexture; +class LLVertexBufferData; #define LL_MATRIX_STACK_DEPTH 32 @@ -415,6 +416,10 @@ public: void flush(); + // if list is set, will store buffers in list for later use, if list isn't set, will use cache + void beginList(std::list *list); + void endList(); + void begin(const GLuint& mode); void end(); @@ -491,6 +496,7 @@ public: private: friend class LLLightState; + LLVertexBuffer* bufferfromCache(U32 attribute_mask, U32 count); LLVertexBuffer* genBuffer(U32 attribute_mask, S32 count); void drawBuffer(LLVertexBuffer* vb, U32 mode, S32 count); void resetStriders(S32 count); @@ -525,7 +531,6 @@ private: std::vector mUIOffset; std::vector mUIScale; - }; extern F32 gGLModelView[16]; diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 02afcf12c6..11b41730aa 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -570,6 +570,53 @@ public: static LLVBOPool* sVBOPool = nullptr; +void LLVertexBufferData::draw() +{ + if (!mVB) + { + // signal for pushUIMatrix + return; // todo: find a better way? + } + + if (mTexName) + { + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTexName); + } + else + { + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadMatrix(mModelView.m); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadMatrix(mProjection.m); + gGL.matrixMode(LLRender::MM_TEXTURE0); + gGL.pushMatrix(); + gGL.loadMatrix(mTexture0.m); + + mVB->setBuffer(); + + if (mMode == LLRender::QUADS && LLRender::sGLCoreProfile) + { + mVB->drawArrays(LLRender::TRIANGLES, 0, mCount); + } + else + { + mVB->drawArrays(mMode, 0, mCount); + } + + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); +} + +//============================================================================ + //static U64 LLVertexBuffer::getBytesAllocated() { diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 4ada0c335b..2a4affdc60 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -53,6 +53,37 @@ //============================================================================ // base class class LLPrivateMemoryPool; +class LLVertexBuffer; + +class LLVertexBufferData +{ +public: + LLVertexBufferData() + : mVB(nullptr) + , mMode(0) + , mCount(0) + , mTexName(0) + {} + LLVertexBufferData(LLVertexBuffer* buffer, U8 mode, U32 count, U32 tex_name, glh::matrix4f model_view, glh::matrix4f projection, glh::matrix4f texture0) + : mVB(buffer) + , mMode(mode) + , mCount(count) + , mTexName(tex_name) + , mProjection(model_view) + , mModelView(projection) + , mTexture0(texture0) + {} + void draw(); + LLPointer mVB; + U8 mMode; + U32 mCount; + U32 mTexName; + glh::matrix4f mProjection; + glh::matrix4f mModelView; + glh::matrix4f mTexture0; +}; +typedef std::list buffer_data_list_t; + class LLVertexBuffer final : public LLRefCount { public: diff --git a/indra/newview/llhudnametag.h b/indra/newview/llhudnametag.h index b48a606982..0a882ac273 100644 --- a/indra/newview/llhudnametag.h +++ b/indra/newview/llhudnametag.h @@ -59,7 +59,9 @@ protected: : mColor(color), mStyle(style), mText(text), - mFont(font) + mFont(font), + mFontBufferLabel(false), + mFontBufferText(false) {} F32 getWidth(const LLFontGL* font); const LLWString& getText() const { return mText; } From 57ab1a410f9cb3534bb403e034743505758579d8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 2 Sep 2024 13:46:13 +0300 Subject: [PATCH 17/19] viewer#2411 A bit more coverage for font buffer --- indra/llrender/llfontgl.cpp | 3 +- indra/llrender/llfontvertexbuffer.cpp | 55 +++++++++++++++++++++ indra/llrender/llfontvertexbuffer.h | 26 ++++++++++ indra/llrender/llrender.cpp | 1 + indra/llrender/llvertexbuffer.cpp | 5 +- indra/llui/llbadge.cpp | 25 +++++----- indra/llui/llbadge.h | 3 ++ indra/llui/llbutton.cpp | 14 +----- indra/llui/llbutton.h | 13 +++-- indra/llui/llscrolllistcell.cpp | 60 ++++++++++++++++------- indra/llui/llscrolllistcell.h | 27 +++++----- indra/newview/llpanelmarketplaceinbox.cpp | 48 +++++++++++------- indra/newview/llpanelmarketplaceinbox.h | 2 + 13 files changed, 202 insertions(+), 80 deletions(-) diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 7d74bb3e46..9721b020c7 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -34,7 +34,6 @@ #include "llfontbitmapcache.h" #include "llfontregistry.h" #include "llgl.h" -#include "llglslshader.h" #include "llimagegl.h" #include "llrender.h" #include "llstl.h" @@ -376,6 +375,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons cur_render_x = cur_x; cur_render_y = cur_y; } + gGL.begin(LLRender::QUADS); { gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4); @@ -503,6 +503,7 @@ F32 LLFontGL::getWidthF32(const std::string& utf8text, S32 begin_offset, S32 max F32 LLFontGL::getWidthF32(const llwchar* wchars, S32 begin_offset, S32 max_chars, bool no_padding) const { + LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; const S32 LAST_CHARACTER = LLFontFreetype::LAST_CHAR_FULL; F32 cur_x = 0; diff --git a/indra/llrender/llfontvertexbuffer.cpp b/indra/llrender/llfontvertexbuffer.cpp index 284762dc94..417bacd69d 100644 --- a/indra/llrender/llfontvertexbuffer.cpp +++ b/indra/llrender/llfontvertexbuffer.cpp @@ -46,6 +46,60 @@ void LLFontVertexBuffer::reset() mBufferList.clear(); } +S32 LLFontVertexBuffer::render( + const LLFontGL* fontp, + const LLWString& text, + S32 begin_offset, + LLRect rect, + 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) +{ + LLRectf rect_float((F32)rect.mLeft, (F32)rect.mTop, (F32)rect.mRight, (F32)rect.mBottom); + return render(fontp, text, begin_offset, rect_float, color, halign, valign, style, shadow, max_chars, right_x, use_ellipses, use_color); +} + +S32 LLFontVertexBuffer::render( + const LLFontGL* fontp, + const LLWString& text, + S32 begin_offset, + LLRectf rect, + const LLColor4& color, + LLFontGL::HAlign halign, LLFontGL::VAlign valign, + U8 style, + LLFontGL::ShadowType shadow, + S32 max_chars, + F32* right_x, + bool use_ellipses, + bool use_color) +{ + F32 x = rect.mLeft; + F32 y = 0.f; + + switch (valign) + { + case LLFontGL::TOP: + y = rect.mTop; + break; + case LLFontGL::VCENTER: + y = rect.getCenterY(); + break; + case LLFontGL::BASELINE: + case LLFontGL::BOTTOM: + y = rect.mBottom; + break; + default: + y = rect.mBottom; + break; + } + return render(fontp, text, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, (S32)rect.getWidth(), right_x, use_ellipses, use_color); +} + S32 LLFontVertexBuffer::render( const LLFontGL* fontp, const LLWString& text, @@ -117,6 +171,7 @@ void LLFontVertexBuffer::genBuffers( bool use_ellipses, bool use_color) { + // todo: add a debug build assert if this triggers too often for to long? mBufferList.clear(); gGL.beginList(&mBufferList); 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, diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 182f61f907..b906563b08 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1531,6 +1531,7 @@ void LLRender::clearErrors() void LLRender::beginList(std::list *list) { + llassert(LLGLSLShader::sCurBoundShaderPtr == &gUIProgram); flush(); sBufferDataList = list; } diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 11b41730aa..156e300853 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -574,8 +574,9 @@ void LLVertexBufferData::draw() { if (!mVB) { - // signal for pushUIMatrix - return; // todo: find a better way? + llassert(false); + // Not supposed to happen, check buffer generation + return; } if (mTexName) diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index 399f79ad2e..48489db615 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -27,6 +27,8 @@ #define LLBADGE_CPP #include "llbadge.h" +#include "llfontgl.h" +#include "llfontvertexbuffer.h" #include "llscrollcontainer.h" #include "lluictrlfactory.h" @@ -103,6 +105,7 @@ LLBadge::LLBadge(const LLBadge::Params& p) , mPaddingVert(p.padding_vert) , mParentScroller(NULL) , mDrawAtParentTop(false) + , mFontBuffer(false) { if (mImage.isNull()) { @@ -351,17 +354,17 @@ void LLBadge::draw() // // Draw the label // - - mGLFont->render(mLabel.getWString(), - badge_label_begin_offset, - badge_center_x + mLabelOffsetHoriz, - badge_center_y + mLabelOffsetVert, - mLabelColor % alpha, - LLFontGL::HCENTER, LLFontGL::VCENTER, // centered around the position - LLFontGL::NORMAL, // normal text (not bold, italics, etc.) - LLFontGL::DROP_SHADOW_SOFT, - badge_char_length, badge_pixel_length, - right_position_out, do_not_use_ellipses); + mFontBuffer.render(mGLFont, + mLabel.getWString(), + badge_label_begin_offset, + badge_center_x + mLabelOffsetHoriz, + badge_center_y + mLabelOffsetVert, + mLabelColor % alpha, + LLFontGL::HCENTER, LLFontGL::VCENTER, // centered around the position + LLFontGL::NORMAL, // normal text (not bold, italics, etc.) + LLFontGL::DROP_SHADOW_SOFT, + badge_char_length, badge_pixel_length, + right_position_out, do_not_use_ellipses); } } } diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h index 77fe76f0da..636e2c9ded 100644 --- a/indra/llui/llbadge.h +++ b/indra/llui/llbadge.h @@ -34,12 +34,14 @@ #include "llstring.h" #include "lluiimage.h" #include "llview.h" +#include "llfontvertexbuffer.h" // // Declarations // class LLFontGL; +class LLFontVertexBuffer; class LLScrollContainer; class LLUICtrlFactory; @@ -144,6 +146,7 @@ private: LLUIColor mBorderColor; const LLFontGL* mGLFont; + LLFontVertexBuffer mFontBuffer; LLPointer< LLUIImage > mImage; LLUIColor mImageColor; diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index a9f1c10256..d4e5d501db 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -43,6 +43,8 @@ #include "llfloater.h" #include "llfloaterreg.h" #include "llfocusmgr.h" +#include "llfontgl.h" +#include "llfontvertexbuffer.h" #include "llwindow.h" #include "llnotificationsutil.h" #include "llrender.h" @@ -438,18 +440,6 @@ void LLButton::reshape(S32 width, S32 height, bool called_from_parent) } } -void LLButton::translate(S32 x, S32 y) -{ - LLUICtrl::translate(x, y); - mFontBuffer.reset(); -} - -void LLButton::setRect(const LLRect& rect) -{ - LLUICtrl::setRect(rect); - mFontBuffer.reset(); -} - void LLButton::dirtyRect() { LLUICtrl::dirtyRect(); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 74ed922510..23a3a05e65 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -34,8 +34,6 @@ #include "lluictrl.h" #include "v4color.h" #include "llframetimer.h" -#include "llfontgl.h" -#include "llfontvertexbuffer.h" #include "lluiimage.h" #include "lluistring.h" @@ -56,6 +54,8 @@ S32 round_up(S32 grid, S32 value); class LLUICtrlFactory; +class LLFontGL; +class LLFontVertexBuffer; // // Classes @@ -170,8 +170,6 @@ public: void onVisibilityChange(bool visible) override; void reshape(S32 width, S32 height, bool called_from_parent = true) override; - void translate(S32 x, S32 y) override; - void setRect(const LLRect& rect) override; void dirtyRect() override; virtual void onMouseLeave(S32 x, S32 y, MASK mask) override; @@ -307,9 +305,6 @@ protected: commit_signal_t* mMouseUpSignal; commit_signal_t* mHeldDownSignal; - const LLFontGL* mGLFont; - LLFontVertexBuffer mFontBuffer; - S32 mMouseDownFrame; S32 mMouseHeldDownCount; // Counter for parameter passed to held-down callback F32 mHeldDownDelay; // seconds, after which held-down callbacks get called @@ -392,6 +387,10 @@ protected: bool mForceFlashing; // Stick flashing color even if button is pressed bool mHandleRightMouse; +private: + const LLFontGL* mGLFont; + LLFontVertexBuffer mFontBuffer; + protected: virtual std::string _getSearchText() const { diff --git a/indra/llui/llscrolllistcell.cpp b/indra/llui/llscrolllistcell.cpp index 7ef2e54429..8b998971b6 100644 --- a/indra/llui/llscrolllistcell.cpp +++ b/indra/llui/llscrolllistcell.cpp @@ -30,6 +30,7 @@ #include "llscrolllistcell.h" #include "llcheckboxctrl.h" +#include "llfontvertexbuffer.h" #include "llui.h" // LLUIImage #include "lluictrlfactory.h" @@ -156,7 +157,7 @@ S32 LLScrollListIcon::getWidth() const } -void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_color) const +void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_color) { if (mIcon) { @@ -236,7 +237,7 @@ S32 LLScrollListBar::getWidth() const } -void LLScrollListBar::draw(const LLColor4& color, const LLColor4& highlight_color) const +void LLScrollListBar::draw(const LLColor4& color, const LLColor4& highlight_color) { S32 bar_width = getWidth() - mLeftPad - mRightPad; S32 left = (S32)(bar_width - bar_width * mRatio); @@ -255,6 +256,7 @@ LLScrollListText::LLScrollListText(const LLScrollListCell::Params& p) mText(p.label.isProvided() ? p.label() : p.value().asString()), mAltText(p.alt_value().asString()), mFont(p.font), + mFontBuffer(false), mColor(p.color), mUseColor(p.color.isProvided()), mFontAlignment(p.font_halign), @@ -308,6 +310,19 @@ bool LLScrollListText::needsToolTip() const return mFont->getWidth(mText.getWString().c_str()) > getWidth(); } +void LLScrollListText::setTextWidth(S32 value) +{ + mTextWidth = value; + mFontBuffer.reset(); +} + +void LLScrollListText::setWidth(S32 width) +{ + LLScrollListCell::setWidth(width); + mTextWidth = width; + mFontBuffer.reset(); +} + //virtual bool LLScrollListText::getVisible() const { @@ -341,6 +356,7 @@ void LLScrollListText::setColor(const LLColor4& color) void LLScrollListText::setText(const LLStringExplicit& text) { mText = text; + mFontBuffer.reset(); } void LLScrollListText::setFontStyle(const U8 font_style) @@ -348,6 +364,13 @@ void LLScrollListText::setFontStyle(const U8 font_style) LLFontDescriptor new_desc(mFont->getFontDesc()); new_desc.setStyle(font_style); mFont = LLFontGL::getFont(new_desc); + mFontBuffer.reset(); +} + +void LLScrollListText::setAlignment(LLFontGL::HAlign align) +{ + mFontAlignment = align; + mFontBuffer.reset(); } //virtual @@ -375,7 +398,7 @@ const LLSD LLScrollListText::getAltValue() const } -void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_color) const +void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_color) { LLColor4 display_color; if (mUseColor) @@ -426,17 +449,18 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col start_x = (F32)getWidth() * 0.5f; break; } - mFont->render(mText.getWString(), 0, - start_x, 0.f, - display_color, - mFontAlignment, - LLFontGL::BOTTOM, - 0, - LLFontGL::NO_SHADOW, - string_chars, - getTextWidth(), - &right_x, - true); + mFontBuffer.render(mFont, + mText.getWString(), 0, + start_x, 0.f, + display_color, + mFontAlignment, + LLFontGL::BOTTOM, + 0, + LLFontGL::NO_SHADOW, + string_chars, + getTextWidth(), + &right_x, + true); } // @@ -475,7 +499,7 @@ LLScrollListCheck::~LLScrollListCheck() mCheckBox = NULL; } -void LLScrollListCheck::draw(const LLColor4& color, const LLColor4& highlight_color) const +void LLScrollListCheck::draw(const LLColor4& color, const LLColor4& highlight_color) { mCheckBox->draw(); } @@ -592,7 +616,7 @@ void LLScrollListIconText::setWidth(S32 width) } -void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight_color) const +void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight_color) { LLColor4 display_color; if (mUseColor) @@ -650,7 +674,9 @@ void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight start_icon_x = (S32)(center - (((F32)icon_space + mFont->getWidth(mText.getWString().c_str())) * 0.5f)); break; } - mFont->render(mText.getWString(), 0, + mFontBuffer.render( + mFont, + mText.getWString(), 0, start_text_x, 0.f, display_color, mFontAlignment, diff --git a/indra/llui/llscrolllistcell.h b/indra/llui/llscrolllistcell.h index c5d785ae52..e7ff5c8424 100644 --- a/indra/llui/llscrolllistcell.h +++ b/indra/llui/llscrolllistcell.h @@ -29,6 +29,7 @@ #define LLSCROLLLISTCELL_H #include "llfontgl.h" // HAlign +#include "llfontvertexbuffer.h" // HAlign #include "llpointer.h" // LLPointer<> #include "lluistring.h" #include "v4color.h" @@ -96,7 +97,7 @@ public: LLScrollListCell(const LLScrollListCell::Params&); virtual ~LLScrollListCell() {}; - virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const {}; // truncate to given width, if possible + virtual void draw(const LLColor4& color, const LLColor4& highlight_color) {}; // truncate to given width, if possible virtual S32 getWidth() const {return mWidth;} virtual S32 getContentWidth() const { return 0; } virtual S32 getHeight() const { return 0; } @@ -127,7 +128,7 @@ class LLScrollListSpacer : public LLScrollListCell public: LLScrollListSpacer(const LLScrollListCell::Params& p) : LLScrollListCell(p) {} /*virtual*/ ~LLScrollListSpacer() {}; - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const {} + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) {} }; /* @@ -139,7 +140,7 @@ public: LLScrollListText(const LLScrollListCell::Params&); /*virtual*/ ~LLScrollListText(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color); /*virtual*/ S32 getContentWidth() const; /*virtual*/ S32 getHeight() const; /*virtual*/ void setValue(const LLSD& value); @@ -155,18 +156,20 @@ public: /*virtual*/ bool needsToolTip() const; S32 getTextWidth() const { return mTextWidth;} - void setTextWidth(S32 value) { mTextWidth = value;} - virtual void setWidth(S32 width) { LLScrollListCell::setWidth(width); mTextWidth = width; } + void setTextWidth(S32 value); + virtual void setWidth(S32 width); void setText(const LLStringExplicit& text); void setFontStyle(const U8 font_style); - void setAlignment(LLFontGL::HAlign align) { mFontAlignment = align; } + void setAlignment(LLFontGL::HAlign align); protected: + LLUIString mText; LLUIString mAltText; S32 mTextWidth; const LLFontGL* mFont; + LLFontVertexBuffer mFontBuffer; LLColor4 mColor; LLColor4 mHighlightColor; U8 mUseColor; @@ -188,7 +191,7 @@ class LLScrollListIcon : public LLScrollListCell public: LLScrollListIcon(const LLScrollListCell::Params& p); /*virtual*/ ~LLScrollListIcon(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color); /*virtual*/ S32 getWidth() const; /*virtual*/ S32 getHeight() const; /*virtual*/ const LLSD getValue() const; @@ -207,7 +210,7 @@ class LLScrollListBar : public LLScrollListCell public: LLScrollListBar(const LLScrollListCell::Params& p); /*virtual*/ ~LLScrollListBar(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color); /*virtual*/ S32 getWidth() const; /*virtual*/ S32 getHeight() const; /*virtual*/ const LLSD getValue() const; @@ -229,7 +232,7 @@ class LLScrollListCheck : public LLScrollListCell public: LLScrollListCheck( const LLScrollListCell::Params&); /*virtual*/ ~LLScrollListCheck(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color); /*virtual*/ S32 getHeight() const { return 0; } /*virtual*/ const LLSD getValue() const; /*virtual*/ void setValue(const LLSD& value); @@ -264,13 +267,11 @@ class LLScrollListIconText : public LLScrollListText public: LLScrollListIconText(const LLScrollListCell::Params& p); /*virtual*/ ~LLScrollListIconText(); - /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color); /*virtual*/ const LLSD getValue() const; /*virtual*/ void setValue(const LLSD& value); - - S32 getIconWidth() const; - /*virtual*/ void setWidth(S32 width);/* { LLScrollListCell::setWidth(width); mTextWidth = width - ; }*/ + /*virtual*/ void setWidth(S32 width); private: LLPointer mIcon; diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp index 35961da579..d10e12d3a8 100644 --- a/indra/newview/llpanelmarketplaceinbox.cpp +++ b/indra/newview/llpanelmarketplaceinbox.cpp @@ -52,6 +52,8 @@ LLPanelMarketplaceInbox::LLPanelMarketplaceInbox(const Params& p) , mInboxButton(NULL) , mInventoryPanel(NULL) , mSavedFolderState(NULL) + , mLastItemCount(-1) + , mLastFreshItemCount(-1) { mSavedFolderState = new LLSaveFolderState(); mSavedFolderState->setApply(false); @@ -253,28 +255,40 @@ void LLPanelMarketplaceInbox::draw() llassert(mFreshCountCtrl != NULL); - if (item_count > 0) + if (mLastItemCount != item_count) { - std::string item_count_str = llformat("%d", item_count); - - LLStringUtil::format_map_t args; - args["[NUM]"] = item_count_str; - mInboxButton->setLabel(getString("InboxLabelWithArg", args)); - - // set green text to fresh item count - U32 fresh_item_count = getFreshItemCount(); - mFreshCountCtrl->setVisible((fresh_item_count > 0)); - - if (fresh_item_count > 0) + mLastItemCount = item_count; + if (item_count > 0) { - mFreshCountCtrl->setTextArg("[NUM]", llformat("%d", fresh_item_count)); + std::string item_count_str = llformat("%d", item_count); + + LLStringUtil::format_map_t args; + args["[NUM]"] = item_count_str; + // setLabel is expensive, causes buffer regeneration + mInboxButton->setLabel(getString("InboxLabelWithArg", args)); + } + else + { + mInboxButton->setLabel(getString("InboxLabelNoArg")); + + mFreshCountCtrl->setVisible(false); } } - else - { - mInboxButton->setLabel(getString("InboxLabelNoArg")); - mFreshCountCtrl->setVisible(false); + if (item_count > 0) + { + // set green text to fresh item count + U32 fresh_item_count = getFreshItemCount(); + if (mLastFreshItemCount != fresh_item_count) + { + mLastFreshItemCount = fresh_item_count; + mFreshCountCtrl->setVisible((fresh_item_count > 0)); + + if (fresh_item_count > 0) + { + mFreshCountCtrl->setTextArg("[NUM]", llformat("%d", fresh_item_count)); + } + } } LLPanel::draw(); diff --git a/indra/newview/llpanelmarketplaceinbox.h b/indra/newview/llpanelmarketplaceinbox.h index e711bb5e5c..493801b96c 100644 --- a/indra/newview/llpanelmarketplaceinbox.h +++ b/indra/newview/llpanelmarketplaceinbox.h @@ -75,6 +75,8 @@ private: LLButton * mInboxButton; LLInventoryPanel * mInventoryPanel; LLSaveFolderState* mSavedFolderState; + S32 mLastItemCount; + S32 mLastFreshItemCount; }; From 4cc0edb189c4deaa205f986d20a6959aa83fb25c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 2 Sep 2024 22:14:42 +0300 Subject: [PATCH 18/19] viewer#2411 Cleanup --- indra/llrender/llfontvertexbuffer.cpp | 9 +- indra/llrender/llfontvertexbuffer.h | 7 +- indra/llrender/llrender.cpp | 114 -------------------------- indra/llrender/llrender.h | 4 +- indra/llui/llbadge.cpp | 1 - indra/llui/llbutton.cpp | 1 - indra/llui/llbutton.h | 6 +- indra/llui/llscrolllistcell.cpp | 1 - indra/newview/llhudnametag.h | 4 +- 9 files changed, 7 insertions(+), 140 deletions(-) diff --git a/indra/llrender/llfontvertexbuffer.cpp b/indra/llrender/llfontvertexbuffer.cpp index 417bacd69d..96ec94fe0f 100644 --- a/indra/llrender/llfontvertexbuffer.cpp +++ b/indra/llrender/llfontvertexbuffer.cpp @@ -31,8 +31,7 @@ #include "llvertexbuffer.h" -LLFontVertexBuffer::LLFontVertexBuffer(bool track_changes) -: mTrackStringChanges(track_changes) +LLFontVertexBuffer::LLFontVertexBuffer() { } @@ -141,11 +140,6 @@ S32 LLFontVertexBuffer::render( genBuffers(fontp, text, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); } - else if (mTrackStringChanges && mLastStringHash != sStringHasher._Do_hash(text)) - { - genBuffers(fontp, text, begin_offset, x, y, color, halign, valign, - style, shadow, max_chars, max_pixels, right_x, use_ellipses, use_color); - } else { renderBuffers(); @@ -183,7 +177,6 @@ void LLFontVertexBuffer::genBuffers( mLastOffset = begin_offset; mLastMaxChars = max_chars; mLastMaxPixels = max_pixels; - mLastStringHash = sStringHasher._Do_hash(text); mLastX = x; mLastY = y; mLastColor = color; 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 diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index b906563b08..a40a668a70 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1592,50 +1592,6 @@ void LLRender::end() } } -LLVertexBuffer* LLRender::beginNoCache(const GLuint& mode, S32& count) -{ - if (mode != mMode) - { - if (mode == LLRender::QUADS) - { - mQuadCycle = 1; - } - - if (mMode == LLRender::QUADS || - mMode == LLRender::LINES || - mMode == LLRender::TRIANGLES || - mMode == LLRender::POINTS) - { - return getBuffer(count); - } - else if (mCount != 0) - { - LL_ERRS() << "gGL.begin() called redundantly." << LL_ENDL; - } - mMode = mode; - } - return nullptr; -} - -LLVertexBuffer* LLRender::endNoCache(S32& count) -{ - if (mCount == 0) - { - return nullptr; - //IMM_ERRS << "GL begin and end called with no vertices specified." << LL_ENDL; - } - - if ((mMode != LLRender::QUADS && - mMode != LLRender::LINES && - mMode != LLRender::TRIANGLES && - mMode != LLRender::POINTS) || - mCount > 2048) - { - return getBuffer(count); - } - return nullptr; -} - void LLRender::flush() { STOP_GLERROR; @@ -1844,76 +1800,6 @@ void LLRender::resetStriders(S32 count) mCount = 0; } -LLVertexBuffer* LLRender::getBuffer(S32 & count) -{ - STOP_GLERROR; - LLVertexBuffer *vb; - if (mCount > 0) - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - llassert(LLGLSLShader::sCurBoundShaderPtr != nullptr); - if (!mUIOffset.empty()) - { - sUICalls++; - sUIVerts += mCount; - } - - //store mCount in a local variable to avoid re-entrance (drawArrays may call flush) - count = mCount; - - if (mMode == LLRender::QUADS && !sGLCoreProfile) - { - if (mCount % 4 != 0) - { - count -= (mCount % 4); - LL_WARNS() << "Incomplete quad requested." << LL_ENDL; - } - } - - if (mMode == LLRender::TRIANGLES) - { - if (mCount % 3 != 0) - { - count -= (mCount % 3); - LL_WARNS() << "Incomplete triangle requested." << LL_ENDL; - } - } - - if (mMode == LLRender::LINES) - { - if (mCount % 2 != 0) - { - count -= (mCount % 2); - LL_WARNS() << "Incomplete line requested." << LL_ENDL; - } - } - - mCount = 0; - - if (mBuffer) - { - LL_PROFILE_ZONE_NAMED_CATEGORY_VERTEX("vb cache miss"); - - U32 attribute_mask = LLGLSLShader::sCurBoundShaderPtr->mAttributeMask; - vb = genBuffer(attribute_mask, count); - drawBuffer(vb, mMode, count); - } - else - { - // mBuffer is present in main thread and not present in an image thread - LL_ERRS() << "A flush call from outside main rendering thread" << LL_ENDL; - } - - resetStriders(count); - } - else - { - count = 0; - } - - return vb; -} - void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) { //the range of mVerticesp, mColorsp and mTexcoordsp is [0, 4095] diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index aeee8685ab..39c13e328a 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -45,6 +45,7 @@ #include "glh/glh_linear.h" #include +#include class LLVertexBuffer; class LLCubeMap; @@ -423,9 +424,6 @@ public: void begin(const GLuint& mode); void end(); - LLVertexBuffer* beginNoCache(const GLuint& mode, S32& count); - LLVertexBuffer* endNoCache(S32& count); - LLVertexBuffer* getBuffer(S32& count); U8 getMode() const { return mMode; } void vertex2i(const GLint& x, const GLint& y); diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index 48489db615..c6654ee0aa 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -105,7 +105,6 @@ LLBadge::LLBadge(const LLBadge::Params& p) , mPaddingVert(p.padding_vert) , mParentScroller(NULL) , mDrawAtParentTop(false) - , mFontBuffer(false) { if (mImage.isNull()) { diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index d4e5d501db..387d2c0d07 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -124,7 +124,6 @@ LLButton::Params::Params() LLButton::LLButton(const LLButton::Params& p) : LLUICtrl(p), LLBadgeOwner(getHandle()), - mFontBuffer(false), mMouseDownFrame(0), mMouseHeldDownCount(0), mFlashing( false ), diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 23a3a05e65..6a389f0554 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -253,8 +253,8 @@ public: void setDisabledLabelColor(const LLUIColor& c); void setFont(const LLFontGL* font); - const LLFontGL* getFont() const { return mGLFont; } - const std::string& getText() const { return getCurrentLabel().getString(); } + const LLFontGL* getFont() const override { return mGLFont; } + const std::string& getText() const override { return getCurrentLabel().getString(); } S32 getLastDrawCharsCount() const { return mLastDrawCharsCount; } bool labelIsTruncated() const; @@ -392,7 +392,7 @@ private: LLFontVertexBuffer mFontBuffer; protected: - virtual std::string _getSearchText() const + virtual std::string _getSearchText() const override { return getLabelUnselected() + getToolTip(); } diff --git a/indra/llui/llscrolllistcell.cpp b/indra/llui/llscrolllistcell.cpp index 8b998971b6..a3108d77e8 100644 --- a/indra/llui/llscrolllistcell.cpp +++ b/indra/llui/llscrolllistcell.cpp @@ -256,7 +256,6 @@ LLScrollListText::LLScrollListText(const LLScrollListCell::Params& p) mText(p.label.isProvided() ? p.label() : p.value().asString()), mAltText(p.alt_value().asString()), mFont(p.font), - mFontBuffer(false), mColor(p.color), mUseColor(p.color.isProvided()), mFontAlignment(p.font_halign), diff --git a/indra/newview/llhudnametag.h b/indra/newview/llhudnametag.h index 0a882ac273..b48a606982 100644 --- a/indra/newview/llhudnametag.h +++ b/indra/newview/llhudnametag.h @@ -59,9 +59,7 @@ protected: : mColor(color), mStyle(style), mText(text), - mFont(font), - mFontBufferLabel(false), - mFontBufferText(false) + mFont(font) {} F32 getWidth(const LLFontGL* font); const LLWString& getText() const { return mText; } From 2fc8d5ff3cfa1b9ad00b310cd4a6cdb557b9415c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 3 Sep 2024 17:22:04 +0300 Subject: [PATCH 19/19] viewer#2411 Cleanup #2 --- indra/llrender/llrender.cpp | 6 +++++- indra/llui/llbutton.cpp | 12 ------------ indra/llui/llbutton.h | 1 - 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index a40a668a70..828a509971 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1531,6 +1531,10 @@ void LLRender::clearErrors() void LLRender::beginList(std::list *list) { + if (sBufferDataList) + { + LL_ERRS() << "beginList called while another list is open." << LL_ENDL; + } llassert(LLGLSLShader::sCurBoundShaderPtr == &gUIProgram); flush(); sBufferDataList = list; @@ -1545,7 +1549,7 @@ void LLRender::endList() } else { - llassert(false); // something failed to provide a list or closed it twice + llassert(false); // endList called without an open list } } diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 387d2c0d07..1bce31edb1 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -427,18 +427,6 @@ void LLButton::onVisibilityChange(bool new_visibility) return LLUICtrl::onVisibilityChange(new_visibility); } -void LLButton::reshape(S32 width, S32 height, bool called_from_parent) -{ - S32 delta_width = width - getRect().getWidth(); - S32 delta_height = height - getRect().getHeight(); - - if (delta_width || delta_height || sForceReshape) - { - LLUICtrl::reshape(width, height, called_from_parent); - mFontBuffer.reset(); - } -} - void LLButton::dirtyRect() { LLUICtrl::dirtyRect(); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 6a389f0554..890e7c2d1e 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -169,7 +169,6 @@ public: /*virtual*/ bool postBuild() override; void onVisibilityChange(bool visible) override; - void reshape(S32 width, S32 height, bool called_from_parent = true) override; void dirtyRect() override; virtual void onMouseLeave(S32 x, S32 y, MASK mask) override;