diff options
author | Gilbert Gonzales <gilbert@lindenlab.com> | 2013-04-30 11:37:16 -0700 |
---|---|---|
committer | Gilbert Gonzales <gilbert@lindenlab.com> | 2013-04-30 11:37:16 -0700 |
commit | 8189c27cfad6f498966dc99dd483df8466330ccd (patch) | |
tree | 46ad47709db80448b0a9a48efa552f7690eda355 | |
parent | 5d80f70a9cbcf5cb923c34ea4a2619e3d3df1aa9 (diff) |
ACME-252 Create AvatarFolderItemView: Optimization. Now the widths for the personview are computed once and stored staticically since they don't change per control.
-rw-r--r-- | indra/newview/llpersontabview.cpp | 48 | ||||
-rw-r--r-- | indra/newview/llpersontabview.h | 14 |
2 files changed, 45 insertions, 17 deletions
diff --git a/indra/newview/llpersontabview.cpp b/indra/newview/llpersontabview.cpp index fa7bc09e10..2bc436226d 100644 --- a/indra/newview/llpersontabview.cpp +++ b/indra/newview/llpersontabview.cpp @@ -116,6 +116,9 @@ void LLPersonTabView::drawHighlight() static LLDefaultChildRegistry::Register<LLPersonView> r_person_view("person_view"); +bool LLPersonView::sChildrenWidthsInitialized = false; +ChildWidthVec LLPersonView::mChildWidthVec; + LLPersonView::Params::Params() : avatar_icon("avatar_icon"), last_interaction_time_textbox("last_interaction_time_textbox"), @@ -163,7 +166,13 @@ LLPersonView::~LLPersonView() BOOL LLPersonView::postBuild() { - initChildrenWidths(this); + if(!sChildrenWidthsInitialized) + { + initChildrenWidthVec(this); + sChildrenWidthsInitialized = true; + } + + initChildVec(); updateChildren(); return LLFolderViewItem::postBuild(); } @@ -275,7 +284,7 @@ void LLPersonView::initFromParams(const LLPersonView::Params & params) addChild(mOutputMonitorCtrl); } -void LLPersonView::initChildrenWidths(LLPersonView* self) +void LLPersonView::initChildrenWidthVec(LLPersonView* self) { S32 output_monitor_width = self->getRect().getWidth() - self->mOutputMonitorCtrl->getRect().mLeft; S32 profile_btn_width = self->mOutputMonitorCtrl->getRect().mLeft - self->mProfileBtn->getRect().mLeft; @@ -286,15 +295,26 @@ void LLPersonView::initChildrenWidths(LLPersonView* self) S32 permission_edit_theirs_icon_width = self->mPermissionEditMineIcon->getRect().mLeft - self->mPermissionEditTheirsIcon->getRect().mLeft; S32 last_interaction_time_textbox_width = self->mPermissionEditTheirsIcon->getRect().mLeft - self->mLastInteractionTimeTextbox->getRect().mLeft; - self->mChildAndWidthVec.push_back(std::pair<LLView *, S32>(self->mOutputMonitorCtrl, output_monitor_width)); - self->mChildAndWidthVec.push_back(std::pair<LLView *, S32>(self->mProfileBtn, profile_btn_width)); - self->mChildAndWidthVec.push_back(std::pair<LLView *, S32>(self->mInfoBtn, info_btn_width)); - self->mChildAndWidthVec.push_back(std::pair<LLView *, S32>(self->mPermissionOnlineIcon, permission_online_icon_width)); - self->mChildAndWidthVec.push_back(std::pair<LLView *, S32>(self->mPermissionMapIcon, permissions_map_icon_width)); - self->mChildAndWidthVec.push_back(std::pair<LLView *, S32>(self->mPermissionEditMineIcon, permission_edit_mine_icon_width)); - self->mChildAndWidthVec.push_back(std::pair<LLView *, S32>(self->mPermissionEditTheirsIcon, permission_edit_theirs_icon_width)); - self->mChildAndWidthVec.push_back(std::pair<LLView *, S32>(self->mLastInteractionTimeTextbox, last_interaction_time_textbox_width)); + self->mChildWidthVec.push_back(output_monitor_width); + self->mChildWidthVec.push_back(profile_btn_width); + self->mChildWidthVec.push_back(info_btn_width); + self->mChildWidthVec.push_back(permission_online_icon_width); + self->mChildWidthVec.push_back(permissions_map_icon_width); + self->mChildWidthVec.push_back(permission_edit_mine_icon_width); + self->mChildWidthVec.push_back(permission_edit_theirs_icon_width); + self->mChildWidthVec.push_back(last_interaction_time_textbox_width); +} +void LLPersonView::initChildVec() +{ + mChildVec.push_back(mOutputMonitorCtrl); + mChildVec.push_back(mProfileBtn); + mChildVec.push_back(mInfoBtn); + mChildVec.push_back(mPermissionOnlineIcon); + mChildVec.push_back(mPermissionMapIcon); + mChildVec.push_back(mPermissionEditMineIcon); + mChildVec.push_back(mPermissionEditTheirsIcon); + mChildVec.push_back(mLastInteractionTimeTextbox); } void LLPersonView::updateChildren() @@ -304,16 +324,18 @@ void LLPersonView::updateChildren() S32 control_width; LLRect control_rect; - for(S32 i = 0; i < mChildAndWidthVec.size(); ++i) + llassert(mChildWidthVec.size() == mChildVec.size()); + + for(S32 i = 0; i < mChildWidthVec.size(); ++i) { - control = mChildAndWidthVec[i].first; + control = mChildVec[i]; if(!control->getVisible()) { continue; } - control_width = mChildAndWidthVec[i].second; + control_width = mChildWidthVec[i]; mLabelPaddingRight += control_width; control_rect = control->getRect(); diff --git a/indra/newview/llpersontabview.h b/indra/newview/llpersontabview.h index 56d7f4eade..80020073d7 100644 --- a/indra/newview/llpersontabview.h +++ b/indra/newview/llpersontabview.h @@ -64,6 +64,9 @@ private: }; +typedef std::vector<S32> ChildWidthVec; +typedef std::vector<LLView *> ChildVec; + class LLPersonView : public LLFolderViewItem { @@ -127,11 +130,14 @@ private: ALIC_COUNT, } EAvatarListItemChildIndex; - typedef std::vector<std::pair<LLView *, S32>> ChildAndWidthVec; - ChildAndWidthVec mChildAndWidthVec; + //Widths of controls are same for every instance so can be static + static ChildWidthVec mChildWidthVec; + //Control pointers are different for each instance so non-static + ChildVec mChildVec; - static bool sStaticInitialized; - static void initChildrenWidths(LLPersonView* self); + static bool sChildrenWidthsInitialized; + static void initChildrenWidthVec(LLPersonView* self); + void initChildVec(); void updateChildren(); }; |