optimized shifting

This commit is contained in:
louis 2016-03-28 16:10:19 +02:00
parent 11f5697032
commit 858b489cfb
8 changed files with 50 additions and 20 deletions

View File

@ -14,6 +14,7 @@ cAnimation::cAnimation(cScrollable *scrollable) : cThread("scroller") {
keepSleeping = false; keepSleeping = false;
doAnimation = true; doAnimation = true;
modeIn = false; modeIn = false;
doFlush = true;
blinkFunc = -1; blinkFunc = -1;
} }
@ -27,6 +28,7 @@ cAnimation::cAnimation(cDetachable *detachable, bool wait, bool animation) : cTh
keepSleeping = false; keepSleeping = false;
doAnimation = animation; doAnimation = animation;
modeIn = false; modeIn = false;
doFlush = true;
blinkFunc = -1; blinkFunc = -1;
} }
@ -40,10 +42,11 @@ cAnimation::cAnimation(cFadable *fadable, bool fadein) : cThread("fadable") {
keepSleeping = false; keepSleeping = false;
doAnimation = true; doAnimation = true;
modeIn = fadein; modeIn = fadein;
doFlush = true;
blinkFunc = -1; blinkFunc = -1;
} }
cAnimation::cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin) : cThread("shiftable") { cAnimation::cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin, bool doFlush) : cThread("shiftable") {
this->scrollable = NULL; this->scrollable = NULL;
this->detachable = NULL; this->detachable = NULL;
this->fadable = NULL; this->fadable = NULL;
@ -55,6 +58,7 @@ cAnimation::cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool s
modeIn = shiftin; modeIn = shiftin;
shiftstart = start; shiftstart = start;
shiftend = end; shiftend = end;
this->doFlush = doFlush;
blinkFunc = -1; blinkFunc = -1;
} }
@ -68,6 +72,7 @@ cAnimation::cAnimation(cBlinkable *blinkable, int func) : cThread("blinking") {
keepSleeping = false; keepSleeping = false;
doAnimation = true; doAnimation = true;
modeIn = false; modeIn = false;
doFlush = true;
blinkFunc = func; blinkFunc = func;
} }
@ -317,12 +322,14 @@ void cAnimation::Shift(void) {
if (delay > 0) if (delay > 0)
Sleep(delay); Sleep(delay);
} }
shiftable->SetStartShifting();
uint64_t start = cTimeMs::Now(); uint64_t start = cTimeMs::Now();
while (Running() || !modeIn) { while (Running() || !modeIn) {
uint64_t now = cTimeMs::Now(); uint64_t now = cTimeMs::Now();
if (Running() || !modeIn) if (Running() || !modeIn)
shiftable->SetPosition(pos, shiftend); shiftable->SetPosition(pos, shiftend);
if (Running() || !modeIn) if ((Running() || !modeIn) && doFlush)
shiftable->Flush(); shiftable->Flush();
int delta = cTimeMs::Now() - now; int delta = cTimeMs::Now() - now;
if ((Running() || !modeIn) && (delta < frametime)) { if ((Running() || !modeIn) && (delta < frametime)) {
@ -347,7 +354,7 @@ void cAnimation::Shift(void) {
pos.Set(pos.X() - stepX, pos.Y() - stepY); pos.Set(pos.X() - stepX, pos.Y() - stepY);
} }
} }
shiftable->SetEndShifting();
} }
void cAnimation::Blink(void) { void cAnimation::Blink(void) {

View File

@ -70,6 +70,8 @@ public:
virtual int ShiftTime(void) = 0; virtual int ShiftTime(void) = 0;
virtual int ShiftMode(void) = 0; virtual int ShiftMode(void) = 0;
virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false) = 0; virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false) = 0;
virtual void SetStartShifting(void) = 0;
virtual void SetEndShifting(void) = 0;
virtual void Flush(void) = 0; virtual void Flush(void) = 0;
}; };
@ -104,6 +106,7 @@ private:
int blinkFunc; int blinkFunc;
cPoint shiftstart; cPoint shiftstart;
cPoint shiftend; cPoint shiftend;
bool doFlush;
void Sleep(int duration); void Sleep(int duration);
void Wait(void); void Wait(void);
void Scroll(void); void Scroll(void);
@ -115,7 +118,7 @@ public:
cAnimation(cScrollable *scrollable); cAnimation(cScrollable *scrollable);
cAnimation(cDetachable *detachable, bool wait, bool animation); cAnimation(cDetachable *detachable, bool wait, bool animation);
cAnimation(cFadable *fadable, bool fadein); cAnimation(cFadable *fadable, bool fadein);
cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin); cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin, bool doFlush = true);
cAnimation(cBlinkable *blinkable, int func); cAnimation(cBlinkable *blinkable, int func);
~cAnimation(void); ~cAnimation(void);
void WakeUp(void); void WakeUp(void);

View File

@ -12,6 +12,7 @@ cView::cView(void) {
viewElementsHorizontal = NULL; viewElementsHorizontal = NULL;
fader = NULL; fader = NULL;
shifter = NULL; shifter = NULL;
shifting = false;
currentTvFrame = NULL; currentTvFrame = NULL;
newTvFrame = NULL; newTvFrame = NULL;
menuInit = false; menuInit = false;
@ -30,6 +31,7 @@ cView::~cView() {
free(viewName); free(viewName);
delete fader; delete fader;
delete shifter; delete shifter;
shifting = false;
sdOsd.DeleteOsd(); sdOsd.DeleteOsd();
} }
@ -158,6 +160,8 @@ void cView::PreCache(void) {
for (int i=0; i < numViewElements; i++) { for (int i=0; i < numViewElements; i++) {
if (!viewElements[i]) if (!viewElements[i])
continue; continue;
if (FadeTime() > 0 || ShiftTime() > 0)
viewElements[i]->SetAnimatedView();
viewElements[i]->SetContainer(contX, contY, attribs->Width(), attribs->Height()); viewElements[i]->SetContainer(contX, contY, attribs->Width(), attribs->Height());
viewElements[i]->Cache(); viewElements[i]->Cache();
} }
@ -165,6 +169,8 @@ void cView::PreCache(void) {
for (int i=0; i < numViewElements; i++) { for (int i=0; i < numViewElements; i++) {
if (!viewElementsHorizontal[i]) if (!viewElementsHorizontal[i])
continue; continue;
if (FadeTime() > 0 || ShiftTime() > 0)
viewElementsHorizontal[i]->SetAnimatedView();
viewElementsHorizontal[i]->SetContainer(contX, contY, attribs->Width(), attribs->Height()); viewElementsHorizontal[i]->SetContainer(contX, contY, attribs->Width(), attribs->Height());
viewElementsHorizontal[i]->Cache(); viewElementsHorizontal[i]->Cache();
} }
@ -240,6 +246,7 @@ void cView::Close(void) {
continue; continue;
viewElements[i]->Close(); viewElements[i]->Close();
} }
sdOsd.Flush();
sdOsd.DeleteOsd(); sdOsd.DeleteOsd();
} }

View File

@ -41,6 +41,7 @@ protected:
map<string,int> viewElementNames; map<string,int> viewElementNames;
cAnimation *fader; cAnimation *fader;
cAnimation *shifter; cAnimation *shifter;
bool shifting;
cRect tvFrame; cRect tvFrame;
cRect *currentTvFrame; cRect *currentTvFrame;
cRect *newTvFrame; cRect *newTvFrame;
@ -88,6 +89,8 @@ public:
int ShiftTime(void); int ShiftTime(void);
int ShiftMode(void); int ShiftMode(void);
virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false); virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false);
void SetStartShifting(void) { shifting = true; };
void SetEndShifting(void) { shifting = false; };
}; };
#endif //__VIEW_H #endif //__VIEW_H

View File

@ -174,24 +174,28 @@ void cViewChannel::Flush(void) {
if (!displayChannelGroups) { if (!displayChannelGroups) {
//normal display //normal display
Render((int)eVeDisplayChannel::channelinfo); if (!shifting) {
Render((int)eVeDisplayChannel::epginfo); Render((int)eVeDisplayChannel::channelinfo);
Render((int)eVeDisplayChannel::statusinfo); Render((int)eVeDisplayChannel::epginfo);
Render((int)eVeDisplayChannel::scrapercontent); Render((int)eVeDisplayChannel::statusinfo);
Render((int)eVeDisplayChannel::progressbar, channelChange); Render((int)eVeDisplayChannel::scrapercontent);
Render((int)eVeDisplayChannel::screenresolution); Render((int)eVeDisplayChannel::progressbar, channelChange);
Render((int)eVeDisplayChannel::signalquality); Render((int)eVeDisplayChannel::screenresolution);
Render((int)eVeDisplayChannel::audioinfo); Render((int)eVeDisplayChannel::signalquality);
Render((int)eVeDisplayChannel::ecminfo); Render((int)eVeDisplayChannel::audioinfo);
Render((int)eVeDisplayChannel::devices); Render((int)eVeDisplayChannel::ecminfo);
Render((int)eVeDisplayChannel::customtokens); Render((int)eVeDisplayChannel::devices);
Render((int)eVeDisplayChannel::message); Render((int)eVeDisplayChannel::customtokens);
Render((int)eVeDisplayChannel::message);
}
} else { } else {
//channelgroup display //channelgroup display
Render((int)eVeDisplayChannel::channelgroup); Render((int)eVeDisplayChannel::channelgroup);
} }
Render((int)eVeDisplayChannel::datetime); if (!shifting) {
Render((int)eVeDisplayChannel::time); Render((int)eVeDisplayChannel::datetime);
Render((int)eVeDisplayChannel::time);
}
channelChange = false; channelChange = false;
cView::Flush(); cView::Flush();
} }

View File

@ -15,6 +15,7 @@ cViewElement::cViewElement(void) {
detached = false; detached = false;
waitOnWakeup = true; waitOnWakeup = true;
startAnimation = true; startAnimation = true;
viewAnimated = false;
globals = NULL; globals = NULL;
tokenContainer = NULL; tokenContainer = NULL;
attribs = new cViewElementAttribs((int)eViewElementAttribs::count); attribs = new cViewElementAttribs((int)eViewElementAttribs::count);
@ -34,6 +35,7 @@ cViewElement::cViewElement(const cViewElement &other) {
detached = false; detached = false;
waitOnWakeup = true; waitOnWakeup = true;
startAnimation = true; startAnimation = true;
viewAnimated = false;
globals = other.globals; globals = other.globals;
container.Set(other.container.X(), other.container.Y(), other.container.Width(), other.container.Height()); container.Set(other.container.X(), other.container.Y(), other.container.Width(), other.container.Height());
tokenContainer = NULL; tokenContainer = NULL;
@ -424,7 +426,7 @@ void cViewElement::StartAnimation(void) {
SetPosition(start, ref); SetPosition(start, ref);
sdOsd->Flush(); sdOsd->Flush();
delete shifter; delete shifter;
shifter = new cAnimation((cShiftable*)this, start, ref, true); shifter = new cAnimation((cShiftable*)this, start, ref, true, !viewAnimated);
shifter->Start(); shifter->Start();
} else if (FadeTime() > 0) { } else if (FadeTime() > 0) {
SetTransparency(100); SetTransparency(100);

View File

@ -27,6 +27,7 @@ protected:
bool waitOnWakeup; bool waitOnWakeup;
bool scrollingStarted; bool scrollingStarted;
bool startAnimation; bool startAnimation;
bool viewAnimated;
cGlobals *globals; cGlobals *globals;
cRect container; cRect container;
cViewElementAttribs *attribs; cViewElementAttribs *attribs;
@ -54,6 +55,7 @@ public:
bool Detached(void); bool Detached(void);
void SetContainer(int x, int y, int width, int height); void SetContainer(int x, int y, int width, int height);
void SetAttributes(vector<stringpair> &attributes); void SetAttributes(vector<stringpair> &attributes);
void SetAnimatedView(void) { viewAnimated = true; };
void AddArea(cAreaNode *area); void AddArea(cAreaNode *area);
void SetAreaX(int x); void SetAreaX(int x);
void SetAreaY(int y); void SetAreaY(int y);
@ -84,6 +86,8 @@ public:
void StartAnimation(void); void StartAnimation(void);
virtual void SetTransparency(int transparency, bool force = false); virtual void SetTransparency(int transparency, bool force = false);
virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false); virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false);
void SetStartShifting(void) { };
void SetEndShifting(void) { };
cRect CoveredArea(void); cRect CoveredArea(void);
void Flush(void); void Flush(void);
virtual bool Parse(bool forced = false); virtual bool Parse(bool forced = false);

View File

@ -250,7 +250,7 @@ bool cVeDevices::Parse(bool forced) {
if (light) if (light)
return false; return false;
//check if drawing is necessary //check if drawing is necessary
if (lastRefresh - cTimeMs::Now() < 500) if (cTimeMs::Now() - lastRefresh < 500)
return false; return false;
bool changed = false; bool changed = false;
for (int i = 0; i < numDevices; i++) { for (int i = 0; i < numDevices; i++) {