render scrolling text only if necessary

Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
Vincent-FK 2020-03-14 12:16:38 +01:00
parent ebc035c869
commit 5b51c7de41
2 changed files with 29 additions and 21 deletions

View File

@ -59,6 +59,7 @@ ReloadableScrollingText::ReloadableScrollingText(Configuration &config, bool sys
, displayOffset_(displayOffset)
, scrollForward_(true)
, needScrolling_(true)
, needRender_(false)
{
text_.clear( );
@ -99,6 +100,8 @@ void ReloadableScrollingText::update(float dt)
{
currentPosition_ += scrollingSpeed_ * dt * scaleY_;
}
needRender_ = true;
}
}
@ -141,6 +144,7 @@ void ReloadableScrollingText::initializeFonts( )
void ReloadableScrollingText::reloadTexture( )
{
needRender_ = true;
if (direction_ == "horizontal")
{
@ -730,6 +734,7 @@ void ReloadableScrollingText::draw( )
{
waitEndTime_ = endTime_;
scrollForward_ = false;
needRender_ = true;
}
else if(!scrollForward_ &&
waitEndTime_ <= 0 &&
@ -738,6 +743,7 @@ void ReloadableScrollingText::draw( )
waitStartTime_ = startTime_;
currentPosition_ = -startPosition_ * scaleX_;
scrollForward_ = true;
needRender_ = true;
}
}
}
@ -959,8 +965,9 @@ bool ReloadableScrollingText::mustRender( )
{
if ( Component::mustRender( ) ) return true;
if (!text_.empty( ) && baseViewInfo.Alpha > 0.0f)
if (!text_.empty( ) && baseViewInfo.Alpha > 0.0f && needRender_)
{
needRender_ = false;
return true;
}

View File

@ -65,4 +65,5 @@ private:
int displayOffset_;
bool scrollForward_;
bool needScrolling_;
bool needRender_;
};