Optimization and cleanup of various color finds during draw

master
Rye Mutt 2024-08-03 10:10:17 -04:00
parent 874794ea58
commit c4e921828a
17 changed files with 96 additions and 71 deletions

View File

@ -43,7 +43,7 @@ namespace ll
virtual ~SearchableControl()
{ }
LLColor4 getHighlightColor( ) const
const LLColor4& getHighlightColor( ) const
{
static LLUIColor highlight_color = LLUIColorTable::instance().getColor("SearchableControlHighlightColor", LLColor4::red);
return highlight_color.get();

View File

@ -584,9 +584,8 @@ void LLTextBase::drawCursor()
if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode() && !hasSelection() && text[mCursorPos] != '\n')
{
LLColor4 text_color;
const LLFontGL* fontp;
text_color = segmentp->getColor();
const LLColor4& text_color = segmentp->getColor();
fontp = segmentp->getStyle()->getFont();
fontp->render(text, mCursorPos, cursor_rect,
LLColor4(1.f - text_color.mV[VRED], 1.f - text_color.mV[VGREEN], 1.f - text_color.mV[VBLUE], alpha),
@ -1368,7 +1367,7 @@ void LLTextBase::draw()
{
bg_rect.intersectWith(text_rect);
}
LLColor4 bg_color = mReadOnly
const LLColor4& bg_color = mReadOnly
? mReadOnlyBgColor.get()
: hasFocus()
? mFocusBgColor.get()
@ -1379,7 +1378,7 @@ void LLTextBase::draw()
// Draw highlighted if needed
if( ll::ui::SearchableControl::getHighlighted() )
{
LLColor4 bg_color = ll::ui::SearchableControl::getHighlightColor();
const LLColor4& bg_color = ll::ui::SearchableControl::getHighlightColor();
LLRect bg_rect = mVisibleTextRect;
if( mScroller )
bg_rect.intersectWith( text_rect );

View File

@ -693,7 +693,7 @@ public:
mNeedsTimeBox = false;
user_name->setValue(mFrom);
updateMinUserNameWidth();
LLColor4 sep_color = LLUIColorTable::instance().getColor("ChatTeleportSeparatorColor");
LLUIColor sep_color = LLUIColorTable::instance().getColor("ChatTeleportSeparatorColor");
setTransparentColor(sep_color);
mTimeBoxTextBox->setVisible(false);
}
@ -739,7 +739,7 @@ public:
std::string username = chat.mFromName.substr(username_start + 2);
username = username.substr(0, username.length() - 1);
LLStyle::Params style_params_name;
LLColor4 userNameColor = LLUIColorTable::instance().getColor("EmphasisColor");
LLUIColor userNameColor = LLUIColorTable::instance().getColor("EmphasisColor");
style_params_name.color(userNameColor);
style_params_name.font.name("SansSerifSmall");
style_params_name.font.style("NORMAL");
@ -1037,7 +1037,7 @@ private:
!av_name.isDisplayNameDefault())
{
LLStyle::Params style_params_name;
LLColor4 userNameColor = LLUIColorTable::instance().getColor("EmphasisColor");
LLUIColor userNameColor = LLUIColorTable::instance().getColor("EmphasisColor");
style_params_name.color(userNameColor);
style_params_name.font.name("SansSerifSmall");
style_params_name.font.style("NORMAL");
@ -1239,8 +1239,8 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
mMoreChatPanel->reshape(mMoreChatPanel->getRect().getWidth(), height);
}
LLColor4 txt_color = LLUIColorTable::instance().getColor("White");
LLColor4 name_color(txt_color);
LLUIColor txt_color = LLUIColorTable::instance().getColor("White");
LLUIColor name_color(txt_color);
LLViewerChat::getChatColor(chat,txt_color);
LLFontGL* fontp = LLViewerChat::getChatFont();
@ -1317,7 +1317,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
{
if (!message_from_log)
{
LLColor4 timestamp_color = LLUIColorTable::instance().getColor("ChatTimestampColor");
LLUIColor timestamp_color = LLUIColorTable::instance().getColor("ChatTimestampColor");
timestamp_style.color(timestamp_color);
timestamp_style.readonly_color(timestamp_color);
}
@ -1344,7 +1344,7 @@ void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LL
// set the link for the object name to be the objectim SLapp
// (don't let object names with hyperlinks override our objectim Url)
LLStyle::Params link_params(body_message_params);
LLColor4 link_color = LLUIColorTable::instance().getColor("HTMLLinkColor");
LLUIColor link_color = LLUIColorTable::instance().getColor("HTMLLinkColor");
link_params.color = link_color;
link_params.readonly_color = link_color;
link_params.is_link = true;

View File

@ -652,6 +652,7 @@ void LLConversationViewParticipant::draw()
static LLUIColor sFlashBgColor = LLUIColorTable::instance().getColor("MenuItemFlashBgColor", DEFAULT_WHITE);
static LLUIColor sFocusOutlineColor = LLUIColorTable::instance().getColor("InventoryFocusOutlineColor", DEFAULT_WHITE);
static LLUIColor sMouseOverColor = LLUIColorTable::instance().getColor("InventoryMouseOverColor", DEFAULT_WHITE);
static LLUIColor sFriendColor = LLUIColorTable::instance().getColor("ConversationFriendColor");;
const bool show_context = (getRoot() ? getRoot()->getShowSelectionContext() : false);
@ -661,23 +662,23 @@ void LLConversationViewParticipant::draw()
F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)mTextPad;
F32 text_left = (F32)getLabelXPos();
LLColor4 color;
LLUIColor* color;
LLLocalSpeakerMgr *speakerMgr = LLLocalSpeakerMgr::getInstance();
if (speakerMgr && speakerMgr->isSpeakerToBeRemoved(mUUID))
{
color = sFgDisabledColor;
color = &sFgDisabledColor;
}
else
{
if (LLAvatarActions::isFriend(mUUID))
{
color = LLUIColorTable::instance().getColor("ConversationFriendColor");
color = &sFriendColor;
}
else
{
color = mIsSelected ? sHighlightFgColor : sFgColor;
color = mIsSelected ? &sHighlightFgColor : &sFgColor;
}
}
@ -688,7 +689,7 @@ void LLConversationViewParticipant::draw()
}
drawHighlight(show_context, mIsSelected, sHighlightBgColor, sFlashBgColor, sFocusOutlineColor, sMouseOverColor);
drawLabel(font, text_left, y, color, right_x);
drawLabel(font, text_left, y, color->get(), right_x);
LLView::draw();
}

View File

@ -203,8 +203,7 @@ public:
F32 centerY = 0.5f * clientHeight;
drawIcon(centerX, centerY - 1, iconWidth);
static LLColor4 defaultColor(0.75f, 0.75f, 0.75f, 1.0f);
static LLUIColor textColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", defaultColor);
static LLUIColor textColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", LLColor4(0.75f, 0.75f, 0.75f, 1.0f));
S32 max_pixels = clientWidth - iconWidth;
drawName((F32)iconWidth, centerY, max_pixels, textColor.get());
}
@ -704,8 +703,7 @@ void LLFloaterEmojiPicker::fillEmojis(bool fromResize)
LLPanel::Params icon_params;
LLRect icon_rect(0, icon_size, icon_size, 0);
static LLColor4 default_color(0.75f, 0.75f, 0.75f, 1.0f);
LLColor4 bg_color = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", default_color);
static LLUIColor bg_color = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", LLColor4(0.75f, 0.75f, 0.75f, 1.0f));
if (!mSelectedGroupIndex)
{

View File

@ -279,8 +279,10 @@ void LLHUDNameTag::renderText(bool for_select)
mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f));
// *TODO: make this a per-text setting
LLColor4 bg_color = LLUIColorTable::instance().getColor("NameTagBackground");
bg_color.setAlpha(gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor);
static LLCachedControl<F32> bubble_opacity(gSavedSettings, "ChatBubbleOpacity");
static LLUIColor nametag_bg_color = LLUIColorTable::instance().getColor("NameTagBackground");
LLColor4 bg_color = nametag_bg_color;
bg_color.setAlpha(bubble_opacity * alpha_factor);
// scale screen size of borders down
//RN: for now, text on hud objects is never occluded
@ -340,8 +342,7 @@ void LLHUDNameTag::renderText(bool for_select)
x_offset = -0.5f * mWidth + (HORIZONTAL_PADDING / 2.f);
}
LLColor4 label_color(0.f, 0.f, 0.f, 1.f);
label_color.mV[VALPHA] = alpha_factor;
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);
}
}

View File

@ -138,8 +138,10 @@ void LLHUDText::renderText()
mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f));
// *TODO: make this a per-text setting
LLColor4 bg_color = LLUIColorTable::instance().getColor("ObjectBubbleColor");
bg_color.setAlpha(gSavedSettings.getF32("ChatBubbleOpacity") * alpha_factor);
static LLCachedControl<F32> bubble_opacity(gSavedSettings, "ChatBubbleOpacity");
static LLUIColor nametag_bg_color = LLUIColorTable::instance().getColor("ObjectBubbleColor");
LLColor4 bg_color = nametag_bg_color;
bg_color.setAlpha(bubble_opacity * alpha_factor);
const S32 border_height = 16;
const S32 border_width = 16;

View File

@ -2881,11 +2881,13 @@ void LLInventoryGalleryItem::draw()
LLPanel::draw();
// Draw border
LLUIColor border_color = LLUIColorTable::instance().getColor(mSelected ? "MenuItemHighlightBgColor" : "TextFgTentativeColor", LLColor4::white);
static LLUIColor menu_highlighted_color = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", LLColor4::white);;
static LLUIColor text_fg_tentative_color = LLUIColorTable::instance().getColor("TextFgTentativeColor", LLColor4::white);;
const LLColor4& border_color = mSelected ? menu_highlighted_color : text_fg_tentative_color;
LLRect border = mThumbnailCtrl->getRect();
border.mRight = border.mRight + 1;
border.mTop = border.mTop + 1;
gl_rect_2d(border, border_color.get(), false);
gl_rect_2d(border, border_color, false);
}
}

View File

@ -122,7 +122,7 @@ void LLScriptEditor::drawLineNumbers()
const LLWString ltext = utf8str_to_wstring(llformat("%d", line.mLineNum ));
bool is_cur_line = cursor_line == line.mLineNum;
const U8 style = is_cur_line ? LLFontGL::BOLD : LLFontGL::NORMAL;
const LLColor4 fg_color = is_cur_line ? mCursorColor : mReadOnlyFgColor;
const LLColor4& fg_color = is_cur_line ? mCursorColor : mReadOnlyFgColor;
getScriptFont()->render(
ltext, // string to draw
0, // begin offset

View File

@ -368,8 +368,8 @@ void LLSpeakerMgr::update(bool resort_ok)
return;
}
LLColor4 speaking_color = LLUIColorTable::instance().getColor("SpeakingColor");
LLColor4 overdriven_color = LLUIColorTable::instance().getColor("OverdrivenColor");
static const LLUIColor speaking_color = LLUIColorTable::instance().getColor("SpeakingColor");
static const LLUIColor overdriven_color = LLUIColorTable::instance().getColor("OverdrivenColor");
if(resort_ok) // only allow list changes when user is not interacting with it
{

View File

@ -566,7 +566,7 @@ void LLToolBarView::draw()
// Draw drop zones if drop of a tool is active
if (isToolDragged())
{
LLColor4 drop_color = LLUIColorTable::instance().getColor( "ToolbarDropZoneColor" );
static const LLUIColor drop_color = LLUIColorTable::instance().getColor( "ToolbarDropZoneColor" );
for (S32 i = LLToolBarEnums::TOOLBAR_FIRST; i <= LLToolBarEnums::TOOLBAR_LAST; i++)
{

View File

@ -536,9 +536,7 @@ void init_menus()
///
/// set up the colors
///
LLColor4 color;
LLColor4 context_menu_color = LLUIColorTable::instance().getColor("MenuPopupBgColor");
LLUIColor context_menu_color = LLUIColorTable::instance().getColor("MenuPopupBgColor");
gMenuAvatarSelf->setBackgroundColor( context_menu_color );
gMenuAvatarOther->setBackgroundColor( context_menu_color );
@ -548,7 +546,7 @@ void init_menus()
gMenuLand->setBackgroundColor( context_menu_color );
color = LLUIColorTable::instance().getColor( "MenuPopupBgColor" );
LLUIColor color = LLUIColorTable::instance().getColor( "MenuPopupBgColor" );
gPopupMenuView->setBackgroundColor( color );
// If we are not in production, use a different color to make it apparent.

View File

@ -1715,15 +1715,15 @@ void LLViewerObjectList::clearAllMapObjectsInRegion(LLViewerRegion* regionp)
void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap)
{
LLColor4 above_water_color = LLUIColorTable::instance().getColor( "NetMapOtherOwnAboveWater" );
LLColor4 below_water_color = LLUIColorTable::instance().getColor( "NetMapOtherOwnBelowWater" );
LLColor4 you_own_above_water_color =
static const LLUIColor above_water_color = LLUIColorTable::instance().getColor( "NetMapOtherOwnAboveWater" );
static const LLUIColor below_water_color = LLUIColorTable::instance().getColor( "NetMapOtherOwnBelowWater" );
static const LLUIColor you_own_above_water_color =
LLUIColorTable::instance().getColor( "NetMapYouOwnAboveWater" );
LLColor4 you_own_below_water_color =
static const LLUIColor you_own_below_water_color =
LLUIColorTable::instance().getColor( "NetMapYouOwnBelowWater" );
LLColor4 group_own_above_water_color =
static const LLUIColor group_own_above_water_color =
LLUIColorTable::instance().getColor( "NetMapGroupOwnAboveWater" );
LLColor4 group_own_below_water_color =
static const LLUIColor group_own_below_water_color =
LLUIColorTable::instance().getColor( "NetMapGroupOwnBelowWater" );
F32 max_radius = gSavedSettings.getF32("MiniMapPrimMaxRadius");
@ -1753,7 +1753,7 @@ void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap)
// See DEV-17370 and DEV-29869/SNOW-79 for details.
approx_radius = llmin(approx_radius, max_radius);
LLColor4U color = above_water_color;
LLColor4U color = above_water_color.get();
if( objectp->permYouOwner() )
{
const F32 MIN_RADIUS_FOR_OWNED_OBJECTS = 2.f;
@ -1766,29 +1766,29 @@ void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap)
{
if ( objectp->permGroupOwner() )
{
color = group_own_above_water_color;
color = group_own_above_water_color.get();
}
else
{
color = you_own_above_water_color;
color = you_own_above_water_color.get();
}
}
else
{
if ( objectp->permGroupOwner() )
{
color = group_own_below_water_color;
color = group_own_below_water_color.get();
}
else
{
color = you_own_below_water_color;
color = you_own_below_water_color.get();
}
}
}
else
if( pos.mdV[VZ] < water_height )
{
color = below_water_color;
color = below_water_color.get();
}
netmap.renderScaledPointGlobal(

View File

@ -53,6 +53,14 @@
static const U8 OVERLAY_IMG_COMPONENTS = 4;
static const F32 LINE_WIDTH = 0.0625f;
bool LLViewerParcelOverlay::sColorSetInitialized = false;
LLUIColor LLViewerParcelOverlay::sAvailColor;
LLUIColor LLViewerParcelOverlay::sOwnedColor;
LLUIColor LLViewerParcelOverlay::sGroupColor;
LLUIColor LLViewerParcelOverlay::sSelfColor;
LLUIColor LLViewerParcelOverlay::sForSaleColor;
LLUIColor LLViewerParcelOverlay::sAuctionColor;
LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_width_meters)
: mRegion( region ),
mParcelGridsPerEdge( S32( region_width_meters / PARCEL_GRID_STEP_METERS ) ),
@ -60,6 +68,17 @@ LLViewerParcelOverlay::LLViewerParcelOverlay(LLViewerRegion* region, F32 region_
mTimeSinceLastUpdate(),
mOverlayTextureIdx(-1)
{
if (!sColorSetInitialized)
{
sColorSetInitialized = true;
sAvailColor = LLUIColorTable::instance().getColor("PropertyColorAvail").get();
sOwnedColor = LLUIColorTable::instance().getColor("PropertyColorOther").get();
sGroupColor = LLUIColorTable::instance().getColor("PropertyColorGroup").get();
sSelfColor = LLUIColorTable::instance().getColor("PropertyColorSelf").get();
sForSaleColor = LLUIColorTable::instance().getColor("PropertyColorForSale").get();
sAuctionColor = LLUIColorTable::instance().getColor("PropertyColorAuction").get();
}
// Create a texture to hold color information.
// 4 components
// Use mipmaps = false, clamped, NEAREST filter, for sharp edges
@ -321,12 +340,12 @@ void LLViewerParcelOverlay::updateOverlayTexture()
mOverlayTextureIdx = 0;
}
const LLColor4U avail = LLUIColorTable::instance().getColor("PropertyColorAvail").get();
const LLColor4U owned = LLUIColorTable::instance().getColor("PropertyColorOther").get();
const LLColor4U group = LLUIColorTable::instance().getColor("PropertyColorGroup").get();
const LLColor4U self = LLUIColorTable::instance().getColor("PropertyColorSelf").get();
const LLColor4U for_sale = LLUIColorTable::instance().getColor("PropertyColorForSale").get();
const LLColor4U auction = LLUIColorTable::instance().getColor("PropertyColorAuction").get();
const LLColor4U avail = sAvailColor.get();
const LLColor4U owned = sOwnedColor.get();
const LLColor4U group = sGroupColor.get();
const LLColor4U self = sSelfColor.get();
const LLColor4U for_sale = sForSaleColor.get();
const LLColor4U auction = sAuctionColor.get();
// Create the base texture.
U8 *raw = mImageRaw->getData();
@ -339,7 +358,7 @@ void LLViewerParcelOverlay::updateOverlayTexture()
{
U8 ownership = mOwnership[i];
F32 r,g,b,a;
U8 r,g,b,a;
// Color stored in low three bits
switch( ownership & 0x7 )
@ -433,11 +452,11 @@ void LLViewerParcelOverlay::updatePropertyLines()
return;
LLColor4U colors[PARCEL_COLOR_MASK + 1];
colors[PARCEL_SELF] = LLUIColorTable::instance().getColor("PropertyColorSelf").get();
colors[PARCEL_OWNED] = LLUIColorTable::instance().getColor("PropertyColorOther").get();
colors[PARCEL_GROUP] = LLUIColorTable::instance().getColor("PropertyColorGroup").get();
colors[PARCEL_FOR_SALE] = LLUIColorTable::instance().getColor("PropertyColorForSale").get();
colors[PARCEL_AUCTION] = LLUIColorTable::instance().getColor("PropertyColorAuction").get();
colors[PARCEL_SELF] = sSelfColor.get();
colors[PARCEL_OWNED] = sOwnedColor.get();
colors[PARCEL_GROUP] = sGroupColor.get();
colors[PARCEL_FOR_SALE] = sForSaleColor.get();
colors[PARCEL_AUCTION] = sAuctionColor.get();
mEdges.clear();

View File

@ -35,6 +35,7 @@
#include "lluuid.h"
#include "llviewertexture.h"
#include "llgl.h"
#include "lluicolor.h"
class LLViewerRegion;
class LLVector3;
@ -123,6 +124,14 @@ private:
};
std::vector<Edge> mEdges;
static bool sColorSetInitialized;
static LLUIColor sAvailColor;
static LLUIColor sOwnedColor;
static LLUIColor sGroupColor;
static LLUIColor sSelfColor;
static LLUIColor sForSaleColor;
static LLUIColor sAuctionColor;
};
#endif

View File

@ -222,15 +222,9 @@ public:
image_rect.mTop = image_rect.mBottom + mImage->getHeight();
mImage->draw(LLRect((S32)image_rect.mLeft, (S32)image_rect.mTop, (S32)image_rect.mRight, (S32)image_rect.mBottom));
LLColor4 color;
if (mEditor.getReadOnly())
{
color = LLUIColorTable::instance().getColor("TextEmbeddedItemReadOnlyColor");
}
else
{
color = LLUIColorTable::instance().getColor("TextEmbeddedItemColor");
}
static const LLUIColor embedded_item_readonly_col = LLUIColorTable::instance().getColor("TextEmbeddedItemReadOnlyColor");
static const LLUIColor embedded_item_col = LLUIColorTable::instance().getColor("TextEmbeddedItemColor");
const LLColor4& color = mEditor.getReadOnly() ? embedded_item_readonly_col : embedded_item_col;
F32 right_x;
mStyle->getFont()->render(mLabel, 0, image_rect.mRight + EMBEDDED_ITEM_LABEL_PADDING, draw_rect.mTop, color, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::UNDERLINE, LLFontGL::NO_SHADOW, static_cast<S32>(mLabel.length()), S32_MAX, &right_x);

View File

@ -3531,7 +3531,9 @@ void LLVOAvatar::idleUpdateNameTagText(bool new_name)
std::deque<LLChat>::iterator chat_iter = mChats.begin();
mNameText->clearString();
LLColor4 new_chat = LLUIColorTable::instance().getColor( isSelf() ? "UserChatColor" : "AgentChatColor" );
static const LLUIColor user_chat_color = LLUIColorTable::instance().getColor("UserChatColor");
static const LLUIColor agent_chat_color = LLUIColorTable::instance().getColor("AgentChatColor");
const LLColor4& new_chat = isSelf() ? user_chat_color : agent_chat_color;
LLColor4 normal_chat = lerp(new_chat, LLColor4(0.8f, 0.8f, 0.8f, 1.f), 0.7f);
LLColor4 old_chat = lerp(normal_chat, LLColor4(0.6f, 0.6f, 0.6f, 1.f), 0.7f);
if (mTyping && mChats.size() >= MAX_BUBBLE_CHAT_UTTERANCES)