CHUI-531 FIXED Poor fps in CHUI viewer

master
maksymsproductengine 2012-11-21 01:41:49 +02:00
parent 7f19e6de5c
commit edeeed9541
14 changed files with 129 additions and 51 deletions

View File

@ -105,6 +105,7 @@ LLButton::Params::Params()
badge("badge"),
handle_right_mouse("handle_right_mouse"),
held_down_delay("held_down_delay"),
button_flash_enable("button_flash_enable", false),
button_flash_count("button_flash_count"),
button_flash_rate("button_flash_rate")
{
@ -170,15 +171,24 @@ LLButton::LLButton(const LLButton::Params& p)
mMouseUpSignal(NULL),
mHeldDownSignal(NULL),
mUseDrawContextAlpha(p.use_draw_context_alpha),
mHandleRightMouse(p.handle_right_mouse)
mHandleRightMouse(p.handle_right_mouse),
mFlashingTimer(NULL)
{
// If optional parameter "p.button_flash_count" is not provided, LLFlashTimer will be
// used instead it a "default" value from gSavedSettings.getS32("FlashCount")).
// Likewise, missing "p.button_flash_rate" is replaced by gSavedSettings.getF32("FlashPeriod").
// Note: flashing should be allowed in settings.xml (boolean key "EnableButtonFlashing").
S32 flash_count = p.button_flash_count.isProvided()? p.button_flash_count : 0;
F32 flash_rate = p.button_flash_rate.isProvided()? p.button_flash_rate : 0.0;
mFlashingTimer = new LLFlashTimer ((LLFlashTimer::callback_t)NULL, flash_count, flash_rate);
if (p.button_flash_enable)
{
// If optional parameter "p.button_flash_count" is not provided, LLFlashTimer will be
// used instead it a "default" value from gSavedSettings.getS32("FlashCount")).
// Likewise, missing "p.button_flash_rate" is replaced by gSavedSettings.getF32("FlashPeriod").
// Note: flashing should be allowed in settings.xml (boolean key "EnableButtonFlashing").
S32 flash_count = p.button_flash_count.isProvided()? p.button_flash_count : 0;
F32 flash_rate = p.button_flash_rate.isProvided()? p.button_flash_rate : 0.0;
mFlashingTimer = new LLFlashTimer ((LLFlashTimer::callback_t)NULL, flash_count, flash_rate);
}
else
{
mButtonFlashCount = p.button_flash_count;
mButtonFlashRate = p.button_flash_rate;
}
static LLUICachedControl<S32> llbutton_orig_h_pad ("UIButtonOrigHPad", 0);
static Params default_params(LLUICtrlFactory::getDefaultParams<LLButton>());
@ -273,7 +283,11 @@ LLButton::~LLButton()
delete mMouseDownSignal;
delete mMouseUpSignal;
delete mHeldDownSignal;
delete mFlashingTimer;
if (mFlashingTimer)
{
delete mFlashingTimer;
}
}
// HACK: Committing a button is the same as instantly clicking it.
@ -599,10 +613,29 @@ void LLButton::draw()
static LLCachedControl<bool> sEnableButtonFlashing(*LLUI::sSettingGroups["config"], "EnableButtonFlashing", true);
F32 alpha = mUseDrawContextAlpha ? getDrawContext().mAlpha : getCurrentTransparency();
mFlashing = mFlashingTimer->isFlashing();
bool flash = mFlashing &&
(!sEnableButtonFlashing || mFlashingTimer->isHighlight());
bool flash = false;
if (mFlashingTimer)
{
mFlashing = mFlashingTimer->isFlashingInProgress();
flash = mFlashing && (!sEnableButtonFlashing || mFlashingTimer->isCurrentlyHighlighted());
}
else
{
if(mFlashing)
{
if ( sEnableButtonFlashing)
{
F32 elapsed = mFrameTimer.getElapsedTimeF32();
S32 flash_count = S32(elapsed * mButtonFlashRate * 2.f);
// flash on or off?
flash = (flash_count % 2 == 0) || flash_count > S32((F32)mButtonFlashCount * 2.f);
}
else
{ // otherwise just highlight button in flash color
flash = true;
}
}
}
bool pressed_by_keyboard = FALSE;
if (hasFocus())
@ -945,19 +978,26 @@ void LLButton::setToggleState(BOOL b)
}
}
void LLButton::setFlashing( BOOL b )
void LLButton::setFlashing( bool b )
{
if (b)
if (mFlashingTimer)
{
mFlashingTimer->startFlashing();
if (b)
{
mFlashingTimer->startFlashing();
}
else
{
mFlashingTimer->stopFlashing();
}
}
else
else if (b != mFlashing)
{
mFlashingTimer->stopFlashing();
mFlashing = b;
mFrameTimer.reset();
}
}
BOOL LLButton::toggleState()
{
bool flipped = ! getToggleState();

View File

@ -134,6 +134,7 @@ public:
Optional<bool> handle_right_mouse;
Optional<bool> button_flash_enable;
Optional<S32> button_flash_count;
Optional<F32> button_flash_rate;
@ -200,7 +201,7 @@ public:
void setToggleState(BOOL b);
void setHighlight(bool b);
void setFlashing( BOOL b );
void setFlashing( bool b );
BOOL getFlashing() const { return mFlashing; }
LLFlashTimer* getFlashTimer() {return mFlashingTimer;}
@ -287,6 +288,8 @@ protected:
LLFrameTimer mMouseDownTimer;
bool mNeedsHighlight;
S32 mButtonFlashCount;
F32 mButtonFlashRate;
void drawBorder(LLUIImage* imagep, const LLColor4& color, S32 size);
void resetMouseDownTimer();
@ -373,7 +376,8 @@ protected:
bool mForcePressedState;
bool mDisplayPressedState;
LLFlashTimer* mFlashingTimer;
LLFrameTimer mFrameTimer;
LLFlashTimer * mFlashingTimer;
bool mHandleRightMouse;
};

View File

@ -63,6 +63,7 @@ LLCommand::Params::Params()
, is_running_parameters("is_running_parameters")
, is_starting_function("is_starting_function")
, is_starting_parameters("is_starting_parameters")
, is_flashing_allowed("is_flashing_allowed", false)
{
}
@ -83,6 +84,7 @@ LLCommand::LLCommand(const LLCommand::Params& p)
, mIsRunningParameters(p.is_running_parameters)
, mIsStartingFunction(p.is_starting_function)
, mIsStartingParameters(p.is_starting_parameters)
, mIsFlashingAllowed(p.is_flashing_allowed)
{
}

View File

@ -111,6 +111,8 @@ public:
Optional<std::string> is_starting_function;
Optional<LLSD> is_starting_parameters;
Optional<bool> is_flashing_allowed;
Params();
};
@ -138,6 +140,8 @@ public:
const std::string& isStartingFunctionName() const { return mIsStartingFunction; }
const LLSD& isStartingParameters() const { return mIsStartingParameters; }
bool isFlashingAllowed() const { return mIsFlashingAllowed; }
private:
LLCommandId mIdentifier;
@ -161,6 +165,8 @@ private:
std::string mIsStartingFunction;
LLSD mIsStartingParameters;
bool mIsFlashingAllowed;
};

View File

@ -33,15 +33,15 @@ LLFlashTimer::LLFlashTimer(callback_t cb, S32 count, F32 period)
: LLEventTimer(period)
, mCallback(cb)
, mCurrentTickCount(0)
, mIsFlashing(false)
, mIsFlashingInProgress(false)
{
mEventTimer.stop();
// By default use settings from settings.xml to be able change them via Debug settings. See EXT-5973.
// Due to Timer is implemented as derived class from EventTimer it is impossible to change period
// in runtime. So, both settings are made as required restart.
mFlashCount = 2 * ((count>0)? count : gSavedSettings.getS32("FlashCount"));
if (mPeriod<=0)
mFlashCount = 2 * ((count > 0) ? count : gSavedSettings.getS32("FlashCount"));
if (mPeriod <= 0)
{
mPeriod = gSavedSettings.getF32("FlashPeriod");
}
@ -49,15 +49,18 @@ LLFlashTimer::LLFlashTimer(callback_t cb, S32 count, F32 period)
BOOL LLFlashTimer::tick()
{
mIsHighlight = !(mCurrentTickCount % 2);
mIsCurrentlyHighlighted = !mIsCurrentlyHighlighted;
if (mCallback)
{
mCallback(mIsHighlight);
mCallback(mIsCurrentlyHighlighted);
}
if (++mCurrentTickCount >= mFlashCount)
{
mEventTimer.stop();
mCurrentTickCount = 0;
mIsFlashingInProgress = false;
}
return FALSE;
@ -65,15 +68,14 @@ BOOL LLFlashTimer::tick()
void LLFlashTimer::startFlashing()
{
mCurrentTickCount = 0;
mIsFlashing = true;
mIsFlashingInProgress = true;
mEventTimer.start();
}
void LLFlashTimer::stopFlashing()
{
mIsFlashing = false;
mIsHighlight = false;
mIsFlashingInProgress = false;
mIsCurrentlyHighlighted = false;
mEventTimer.stop();
}

View File

@ -50,8 +50,8 @@ public:
void startFlashing();
void stopFlashing();
bool isFlashing() {return mIsFlashing;}
bool isHighlight() {return mIsHighlight;}
bool isFlashingInProgress() {return mIsFlashingInProgress;}
bool isCurrentlyHighlighted() {return mIsCurrentlyHighlighted;}
private:
callback_t mCallback;
@ -60,8 +60,8 @@ private:
*/
S32 mFlashCount;
S32 mCurrentTickCount;
bool mIsHighlight;
bool mIsFlashing;
bool mIsCurrentlyHighlighted;
bool mIsFlashingInProgress;
};
#endif /* LL_FLASHTIMER_H */

View File

@ -145,8 +145,6 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
mArrowSize(p.arrow_size),
mMaxFolderItemOverlap(p.max_folder_item_overlap)
{
mFlashTimer = new LLFlashTimer();
sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE);
sHighlightBgColor = LLUIColorTable::instance().getColor("MenuItemHighlightBgColor", DEFAULT_WHITE);
sHighlightFgColor = LLUIColorTable::instance().getColor("MenuItemHighlightFgColor", DEFAULT_WHITE);
@ -168,7 +166,6 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
// Destroys the object
LLFolderViewItem::~LLFolderViewItem()
{
delete mFlashTimer;
mViewModelItem = NULL;
}
@ -671,6 +668,16 @@ void LLFolderViewItem::drawOpenFolderArrow(const Params& default_params, const L
}
}
/*virtual*/ bool LLFolderViewItem::isHighlightAllowed()
{
return mIsSelected;
}
/*virtual*/ bool LLFolderViewItem::isHighlightActive()
{
return mIsCurSelection;
}
void LLFolderViewItem::drawHighlight(const BOOL showContent, const BOOL hasKeyboardFocus, const LLUIColor &bgColor,
const LLUIColor &focusOutlineColor, const LLUIColor &mouseOverColor)
{
@ -683,16 +690,13 @@ void LLFolderViewItem::drawHighlight(const BOOL showContent, const BOOL hasKeybo
const S32 focus_bottom = getRect().getHeight() - mItemHeight;
const bool folder_open = (getRect().getHeight() > mItemHeight + 4);
const S32 FOCUS_LEFT = 1;
bool flashing = mFlashTimer->isFlashing();
if (flashing? mFlashTimer->isHighlight() : mIsSelected) // always render "current" item (only render other selected items if
// mShowSingleSelection is FALSE) or flashing item
if (isHighlightAllowed()) // always render "current" item (only render other selected items if
// mShowSingleSelection is FALSE) or flashing item
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLColor4 bg_color = bgColor;
bool selection = flashing? mFlashTimer->isHighlight() : mIsCurSelection;
if (!selection)
if (!isHighlightActive())
{
// do time-based fade of extra objects
F32 fade_time = (getRoot() ? getRoot()->getSelectionFadeElapsedTime() : 0.0f);
@ -712,7 +716,7 @@ void LLFolderViewItem::drawHighlight(const BOOL showContent, const BOOL hasKeybo
getRect().getWidth() - 2,
focus_bottom,
bg_color, hasKeyboardFocus);
if (selection)
if (isHighlightActive())
{
gl_rect_2d(FOCUS_LEFT,
focus_top,

View File

@ -135,6 +135,8 @@ protected:
// no-op at this level, but reimplemented in derived classes.
virtual void addItem(LLFolderViewItem*) { }
virtual void addFolder(LLFolderViewFolder*) { }
virtual bool isHighlightAllowed();
virtual bool isHighlightActive();
static LLFontGL* getLabelFontForStyle(U8 style);
@ -163,7 +165,6 @@ public:
S32 getIconPad();
S32 getTextPad();
LLFlashTimer* getFlashTimer() {return mFlashTimer;}
// If 'selection' is 'this' then note that otherwise ignore.
// Returns TRUE if this item ends up being selected.
virtual BOOL setSelection(LLFolderViewItem* selection, BOOL openitem, BOOL take_keyboard_focus);
@ -274,8 +275,6 @@ public:
private:
static std::map<U8, LLFontGL*> sFonts; // map of styles to fonts
LLFlashTimer* mFlashTimer;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -506,8 +506,8 @@ void LLTabContainer::draw()
}
}
mPrevArrowBtn->getFlashTimer()->stopFlashing();
mNextArrowBtn->getFlashTimer()->stopFlashing();
mPrevArrowBtn->setFlashing(false);
mNextArrowBtn->setFlashing(false);
}

View File

@ -914,6 +914,7 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id)
button_p.label = LLTrans::getString(commandp->labelRef());
button_p.tool_tip = LLTrans::getString(commandp->tooltipRef());
button_p.image_overlay = LLUI::getUIImage(commandp->icon());
button_p.button_flash_enable = commandp->isFlashingAllowed();
button_p.overwriteFrom(mButtonParams[mButtonType]);
LLToolBarButton* button = LLUICtrlFactory::create<LLToolBarButton>(button_p);

View File

@ -44,6 +44,7 @@
/>
<command name="chat"
available_in_toybox="true"
is_flashing_allowed="true"
icon="Command_Chat_Icon"
label_ref="Command_Chat_Label"
tooltip_ref="Command_Conversations_Tooltip"

View File

@ -82,6 +82,7 @@ LLConversationViewSession::LLConversationViewSession(const LLConversationViewSes
mVoiceClientObserver(NULL),
mMinimizedMode(false)
{
mFlashTimer = new LLFlashTimer();
}
LLConversationViewSession::~LLConversationViewSession()
@ -92,6 +93,18 @@ LLConversationViewSession::~LLConversationViewSession()
{
LLVoiceClient::getInstance()->removeObserver(mVoiceClientObserver);
}
delete mFlashTimer;
}
bool LLConversationViewSession::isHighlightAllowed()
{
return mFlashTimer->isFlashingInProgress() || mIsSelected;
}
bool LLConversationViewSession::isHighlightActive()
{
return mFlashTimer->isFlashingInProgress() ? mFlashTimer->isCurrentlyHighlighted() : mIsCurSelection;
}
BOOL LLConversationViewSession::postBuild()

View File

@ -55,7 +55,10 @@ public:
protected:
friend class LLUICtrlFactory;
LLConversationViewSession( const Params& p );
/*virtual*/ bool isHighlightAllowed();
/*virtual*/ bool isHighlightActive();
LLFloaterIMContainer* mContainer;
public:
@ -82,6 +85,8 @@ public:
virtual void refresh();
LLFlashTimer * getFlashTimer() { return mFlashTimer; }
private:
void onCurrentVoiceSessionChanged(const LLUUID& session_id);
@ -90,6 +95,7 @@ private:
LLPanel* mCallIconLayoutPanel;
LLTextBox* mSessionTitle;
LLOutputMonitorCtrl* mSpeakingIndicator;
LLFlashTimer* mFlashTimer;
bool mMinimizedMode;

View File

@ -1611,7 +1611,7 @@ void LLFloaterIMContainer::reSelectConversation()
void LLFloaterIMContainer::flashConversationItemWidget(const LLUUID& session_id, bool is_flashes)
{
LLFolderViewItem* widget = get_ptr_in_map(mConversationsWidgets,session_id);
LLConversationViewSession * widget = dynamic_cast<LLConversationViewSession *>(get_ptr_in_map(mConversationsWidgets,session_id));
if (widget)
{
if (is_flashes)