optimized flushes when more animations are running in parallel

This commit is contained in:
louis 2016-05-01 06:35:13 +02:00
parent f45af8f826
commit 5b2401caf1
34 changed files with 156 additions and 76 deletions

View File

@ -14,7 +14,6 @@ cAnimation::cAnimation(cScrollable *scrollable) : cThread("scroller") {
keepSleeping = false;
doAnimation = true;
modeIn = false;
doFlush = true;
blinkFunc = -1;
}
@ -28,7 +27,6 @@ cAnimation::cAnimation(cDetachable *detachable, bool wait, bool animation) : cTh
keepSleeping = false;
doAnimation = animation;
modeIn = false;
doFlush = true;
blinkFunc = -1;
}
@ -42,11 +40,10 @@ cAnimation::cAnimation(cFadable *fadable, bool fadein) : cThread("fadable") {
keepSleeping = false;
doAnimation = true;
modeIn = fadein;
doFlush = true;
blinkFunc = -1;
}
cAnimation::cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin, bool doFlush) : cThread("shiftable") {
cAnimation::cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin) : cThread("shiftable") {
this->scrollable = NULL;
this->detachable = NULL;
this->fadable = NULL;
@ -58,7 +55,6 @@ cAnimation::cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool s
modeIn = shiftin;
shiftstart = start;
shiftend = end;
this->doFlush = doFlush;
blinkFunc = -1;
}
@ -72,7 +68,6 @@ cAnimation::cAnimation(cBlinkable *blinkable, int func) : cThread("blinking") {
keepSleeping = false;
doAnimation = true;
modeIn = false;
doFlush = true;
blinkFunc = func;
}
@ -100,14 +95,19 @@ void cAnimation::Stop(bool deletePixmaps) {
void cAnimation::Action(void) {
if (scrollable) {
Scroll();
scrollable->UnregisterAnimation();
} else if (detachable) {
Detach();
} else if (fadable) {
Fade();
fadable->UnregisterAnimation();
} else if (shiftable) {
Shift();
shiftable->UnregisterAnimation();
} else if (blinkable) {
blinkable->RegisterAnimation();
Blink();
blinkable->UnregisterAnimation();
}
}
@ -129,7 +129,8 @@ void cAnimation::Wait(void) {
void cAnimation::Scroll(void) {
int delay = scrollable->ScrollDelay();
Sleep(delay);
if (!Running()) return;
scrollable->RegisterAnimation();
if (!Running()) return;
eOrientation orientation = scrollable->ScrollOrientation();
int scrollTotal = 0;
@ -200,7 +201,7 @@ void cAnimation::Scroll(void) {
scrollable->SetDrawPort(drawPortPoint);
if (!Running()) return;
scrollable->Flush();
scrollable->Flush(true);
if (orientation == eOrientation::horizontal && !carriageReturn && (drawPortX == 0)) {
scrollDelta *= -1;
@ -229,7 +230,7 @@ void cAnimation::Detach(void) {
detachable->RenderDetached();
if (!Running()) return;
if (!doAnimation)
detachable->Flush();
detachable->Flush(false);
if (!Running()) return;
if (doAnimation) {
detachable->StartAnimation();
@ -253,12 +254,13 @@ void cAnimation::Fade(void) {
if (delay > 0)
Sleep(delay);
}
fadable->RegisterAnimation();
while (Running() || !modeIn) {
uint64_t now = cTimeMs::Now();
if (Running() || !modeIn)
fadable->SetTransparency(transparency, !modeIn);
if (Running() || !modeIn)
fadable->Flush();
fadable->Flush(true);
int delta = cTimeMs::Now() - now;
if ((Running() || !modeIn) && (delta < frametime)) {
Sleep(frametime - delta);
@ -266,10 +268,10 @@ void cAnimation::Fade(void) {
if ((int)(now - start) > fadetime) {
if ((Running() && modeIn) && transparency > 0) {
fadable->SetTransparency(0);
fadable->Flush();
fadable->Flush(true);
} else if (!modeIn && transparency < 100) {
fadable->SetTransparency(100, true);
fadable->Flush();
fadable->Flush(true);
}
break;
}
@ -322,7 +324,7 @@ void cAnimation::Shift(void) {
if (delay > 0)
Sleep(delay);
}
shiftable->RegisterAnimation();
shiftable->SetStartShifting();
uint64_t start = cTimeMs::Now();
bool finished = false;
@ -330,8 +332,8 @@ void cAnimation::Shift(void) {
uint64_t now = cTimeMs::Now();
if (Running() || !modeIn)
shiftable->SetPosition(pos, shiftend);
if ((Running() || !modeIn) && doFlush)
shiftable->Flush();
if (Running() || !modeIn)
shiftable->Flush(true);
int delta = cTimeMs::Now() - now;
if ((Running() || !modeIn) && (delta < frametime)) {
cCondWait::SleepMs(frametime - delta);
@ -340,7 +342,7 @@ void cAnimation::Shift(void) {
finished = true;
if ((Running() && modeIn) && pos != shiftend) {
shiftable->SetPosition(shiftend, shiftend);
shiftable->Flush();
shiftable->Flush(true);
}
break;
}
@ -370,7 +372,7 @@ void cAnimation::Blink(void) {
if (Running())
blinkable->DoBlink(blinkFunc, blinkOn);
if (Running())
blinkable->Flush();
blinkable->Flush(true);
blinkOn = !blinkOn;
}
}

View File

@ -24,7 +24,9 @@ public:
virtual void StartScrolling(void) = 0;
virtual void StopScrolling(void) = 0;
virtual void SetDrawPort(cPoint &point) = 0;
virtual void Flush(void) = 0;
virtual void RegisterAnimation(void) = 0;
virtual void UnregisterAnimation(void) = 0;
virtual void Flush(bool animFlush) = 0;
};
/******************************************************************
@ -39,7 +41,9 @@ public:
virtual void ParseDetached(void) = 0;
virtual void RenderDetached(void) = 0;
virtual void StartAnimation(void) = 0;
virtual void Flush(void) = 0;
virtual void RegisterAnimation(void) = 0;
virtual void UnregisterAnimation(void) = 0;
virtual void Flush(bool animFlush) = 0;
};
/******************************************************************
@ -54,7 +58,9 @@ public:
virtual int Delay(void) = 0;
virtual int FadeTime(void) = 0;
virtual void SetTransparency(int transparency, bool force = false) = 0;
virtual void Flush(void) = 0;
virtual void RegisterAnimation(void) = 0;
virtual void UnregisterAnimation(void) = 0;
virtual void Flush(bool animFlush) = 0;
};
/******************************************************************
@ -72,7 +78,9 @@ public:
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 RegisterAnimation(void) = 0;
virtual void UnregisterAnimation(void) = 0;
virtual void Flush(bool animFlush) = 0;
};
/******************************************************************
@ -85,7 +93,9 @@ protected:
public:
virtual int BlinkFreq(int func) = 0;
virtual void DoBlink(int func, bool on) = 0;
virtual void Flush(void) = 0;
virtual void RegisterAnimation(void) = 0;
virtual void UnregisterAnimation(void) = 0;
virtual void Flush(bool animFlush) = 0;
};
/******************************************************************
@ -106,7 +116,6 @@ private:
int blinkFunc;
cPoint shiftstart;
cPoint shiftend;
bool doFlush;
void Sleep(int duration);
void Wait(void);
void Scroll(void);
@ -118,7 +127,7 @@ public:
cAnimation(cScrollable *scrollable);
cAnimation(cDetachable *detachable, bool wait, bool animation);
cAnimation(cFadable *fadable, bool fadein);
cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin, bool doFlush = true);
cAnimation(cShiftable *shiftable, cPoint &start, cPoint &end, bool shiftin);
cAnimation(cBlinkable *blinkable, int func);
~cAnimation(void);
void WakeUp(void);

View File

@ -491,8 +491,11 @@ void cArea::Debug(bool full) {
}
}
void cArea::Flush(void) {
sdOsd->Flush();
void cArea::Flush(bool animFlush) {
if (animFlush)
sdOsd->AnimatedFlush();
else
sdOsd->Flush();
}
/******************************************************************
* Private Functions
@ -570,6 +573,14 @@ void cArea::StopBlinkers(void) {
blinkers.Clear();
}
void cArea::RegisterAnimation(void) {
sdOsd->AddAnimation();
}
void cArea::UnregisterAnimation(void) {
sdOsd->RemoveAnimation();
}
/******************************************************************
* cAreaContainer
******************************************************************/

View File

@ -133,9 +133,11 @@ public:
void DoBlink(int func, bool on);
void StopBlinkers(void);
//Common
void RegisterAnimation(void);
void UnregisterAnimation(void);
const char *Name(void) { return attribs->Name(); };
bool BackgroundArea(void) { return attribs->BackgroundArea(); };
void Flush(void);
void Flush(bool animFlush);
void Debug(bool full = false);
};

View File

@ -3,6 +3,8 @@
cSdOsd::cSdOsd(void) {
osd = NULL;
flushLocked = false;
animsRunning = 0;
animsFlushed = 0;
}
cSdOsd::~cSdOsd(void) {
@ -48,6 +50,10 @@ void cSdOsd::DeleteOsd(void) {
delete osd;
osd = NULL;
Unlock();
animsRunningMutex.Lock();
animsRunning = 0;
animsFlushed = 0;
animsRunningMutex.Unlock();
}
cPixmap *cSdOsd::CreatePixmap(int layer, cRect &viewPort, cRect &drawPort) {
@ -63,7 +69,33 @@ void cSdOsd::DestroyPixmap(cPixmap *pix) {
}
}
void cSdOsd::Flush(void) {
if (osd && !flushLocked)
osd->Flush();
void cSdOsd::AddAnimation(void) {
animsRunningMutex.Lock();
animsRunning++;
animsRunningMutex.Unlock();
}
void cSdOsd::RemoveAnimation(void) {
animsRunningMutex.Lock();
animsRunning--;
animsRunningMutex.Unlock();
}
void cSdOsd::AnimatedFlush(void) {
if (osd && !flushLocked) {
animsRunningMutex.Lock();
if (animsFlushed + 1 >= animsRunning) {
animsFlushed = 0;
osd->Flush();
} else {
animsFlushed++;
}
animsRunningMutex.Unlock();
}
}
void cSdOsd::Flush(void) {
if (osd && !flushLocked) {
osd->Flush();
}
}

View File

@ -9,6 +9,9 @@ private:
cOsd *osd;
cMutex mutex;
bool flushLocked;
int animsRunning;
int animsFlushed;
cMutex animsRunningMutex;
public:
cSdOsd(void);
virtual ~cSdOsd(void);
@ -20,6 +23,9 @@ public:
void DeleteOsd(void);
cPixmap *CreatePixmap(int layer, cRect &viewPort, cRect &drawPort);
void DestroyPixmap(cPixmap *pix);
void AddAnimation(void);
void RemoveAnimation(void);
void AnimatedFlush(void);
void Flush(void);
};

View File

@ -160,8 +160,6 @@ void cView::PreCache(void) {
for (int i=0; i < numViewElements; i++) {
if (!viewElements[i])
continue;
if (FadeTime() > 0 || ShiftTime() > 0)
viewElements[i]->SetAnimatedView();
viewElements[i]->SetContainer(contX, contY, attribs->Width(), attribs->Height());
viewElements[i]->Cache();
}
@ -169,8 +167,6 @@ void cView::PreCache(void) {
for (int i=0; i < numViewElements; i++) {
if (!viewElementsHorizontal[i])
continue;
if (FadeTime() > 0 || ShiftTime() > 0)
viewElementsHorizontal[i]->SetAnimatedView();
viewElementsHorizontal[i]->SetContainer(contX, contY, attribs->Width(), attribs->Height());
viewElementsHorizontal[i]->Cache();
}
@ -278,7 +274,15 @@ void cView::SetPosition(cPoint &position, cPoint &reference, bool force) {
}
}
void cView::Flush(void) {
void cView::RegisterAnimation(void) {
sdOsd.AddAnimation();
}
void cView::UnregisterAnimation(void) {
sdOsd.RemoveAnimation();
}
void cView::Flush(bool animFlush) {
if (init) {
init = false;
StartAnimation();
@ -292,7 +296,10 @@ void cView::Flush(void) {
WakeViewElements();
menuInit = false;
}
sdOsd.Flush();
if (animFlush)
sdOsd.AnimatedFlush();
else
sdOsd.Flush();
}
void cView::Debug(void) {

View File

@ -78,7 +78,7 @@ public:
void Clear(int ve, bool forceClearBackground = false);
void Render(int ve, bool force = false);
virtual void Close(void);
virtual void Flush(void);
virtual void Flush(bool animFlush);
virtual void Debug(void);
bool Detached(void) { return false; };
int Delay(void) { return 0; };
@ -91,6 +91,8 @@ public:
virtual void SetPosition(cPoint &position, cPoint &reference, bool force = false);
void SetStartShifting(void) { shifting = true; };
void SetEndShifting(void) { shifting = false; };
void RegisterAnimation(void);
void UnregisterAnimation(void);
};
#endif //__VIEW_H

View File

@ -166,7 +166,7 @@ void cViewChannel::SetMessage(eMessageType type, const char *text) {
}
}
void cViewChannel::Flush(void) {
void cViewChannel::Flush(bool animFlush) {
if (init) {
sdOsd.LockFlush();
Render((int)eVeDisplayChannel::background);
@ -198,6 +198,6 @@ void cViewChannel::Flush(void) {
Render((int)eVeDisplayChannel::time);
}
channelChange = false;
cView::Flush();
cView::Flush(animFlush);
}

View File

@ -25,7 +25,7 @@ public:
void SetChannel(const cChannel *channel, int number);
void SetEvents(const cEvent *present, const cEvent *following);
void SetMessage(eMessageType type, const char *text);
void Flush(void);
void Flush(bool animFlush);
};
#endif //__VIEWDISPLAYCHANNEL_H

View File

@ -566,7 +566,7 @@ void cViewMenu::Clear(void) {
activeSubview->ClearViewList();
}
void cViewMenu::Flush(void) {
void cViewMenu::Flush(bool animFlush) {
if (init) {
sdOsd.LockFlush();
}
@ -591,7 +591,7 @@ void cViewMenu::Flush(void) {
detailViewInit = false;
}
activeSubview->DrawDynamicVEs();
cView::Flush();
cView::Flush(animFlush);
}
void cViewMenu::SetTransparency(int transparency, bool forceDetached) {

View File

@ -101,7 +101,7 @@ public:
bool Init(void);
void Close(void);
void Clear(void);
void Flush(void);
void Flush(bool animFlush);
void SetTransparency(int transparency, bool forceDetached = false);
void Debug(void);
};

View File

@ -43,12 +43,12 @@ void cViewMessage::SetMessage(eMessageType type, const char *text) {
veMessage->Set(type, text);
}
void cViewMessage::Flush(void) {
void cViewMessage::Flush(bool animFlush) {
if (init) {
sdOsd.LockFlush();
Render((int)eVeDisplayMessage::background);
}
Render((int)eVeDisplayMessage::message);
cView::Flush();
cView::Flush(animFlush);
}

View File

@ -13,7 +13,7 @@ public:
cViewMessage(void);
virtual ~cViewMessage(void);
void SetMessage(eMessageType type, const char *text);
void Flush(void);
void Flush(bool animFlush);
};
#endif //__VIEWDISPLAYMESSAGE_H

View File

@ -352,13 +352,13 @@ void cViewPlugin::ClearTab(int viewId) {
tab->Clear();
}
void cViewPlugin::Flush(void) {
void cViewPlugin::Flush(bool animFlush) {
if (viewChanged) {
viewChanged = false;
newTvFrame = views[newViewId]->GetTvFrame();
menuInit = true;
}
cView::Flush();
cView::Flush(animFlush);
}
bool cViewPlugin::ChannelLogoExists(string channelId) {

View File

@ -64,7 +64,7 @@ public:
void TabDown(int viewId);
void DisplayTabs(int viewId);
void ClearTab(int viewId);
void Flush(void);
void Flush(bool animFlush);
bool ChannelLogoExists(string channelId);
string GetEpgImagePath(void);
};

View File

@ -276,7 +276,7 @@ void cViewReplay::DelayOnPause(void) {
veOnPause->ResetSleep();
}
void cViewReplay::Flush(void) {
void cViewReplay::Flush(bool animFlush) {
if (init) {
sdOsd.LockFlush();
if (!modeOnly) {
@ -303,7 +303,7 @@ void cViewReplay::Flush(void) {
SetProgressModeOnly();
}
cView::Flush();
cView::Flush(animFlush);
}
void cViewReplay::SetProgressModeOnly(void) {

View File

@ -53,7 +53,7 @@ public:
void StartOnPause(const char *recfilename);
void ClearOnPause(void);
void DelayOnPause(void);
void Flush(void);
void Flush(bool animFlush);
};
#endif //__VIEWDISPLAYREPLAY_H1

View File

@ -107,7 +107,7 @@ void cViewTracks::SetCurrentTrack(int index) {
change = true;
}
void cViewTracks::Flush(void) {
void cViewTracks::Flush(bool animFlush) {
if (init) {
sdOsd.LockFlush();
Render((int)eVeDisplayTracks::background);
@ -118,5 +118,5 @@ void cViewTracks::Flush(void) {
viewList->Draw();
change = false;
}
cView::Flush();
cView::Flush(animFlush);
}

View File

@ -23,7 +23,7 @@ public:
void SetTracks(const char * const *tracks);
void SetAudiochannel(int audioChannel);
void SetCurrentTrack(int index);
void Flush(void);
void Flush(bool animFlush);
};
#endif //__VIEWDISPLAYTRACKS_H

View File

@ -40,13 +40,13 @@ void cViewVolume::SetVolume(int current, int total, bool mute) {
veVolume->Set(current, total, mute);
}
void cViewVolume::Flush(void) {
void cViewVolume::Flush(bool animFlush) {
if (init) {
sdOsd.LockFlush();
Render((int)eVeDisplayVolume::background);
}
Render((int)eVeDisplayVolume::volume);
cView::Flush();
cView::Flush(animFlush);
}

View File

@ -13,7 +13,7 @@ public:
cViewVolume(void);
virtual ~cViewVolume(void);
void SetVolume(int current, int total, bool mute);
void Flush(void);
void Flush(bool animFlush);
};
#endif //__VIEWDISPLAYVOLUME_H

View File

@ -15,7 +15,6 @@ cViewElement::cViewElement(void) {
detached = false;
waitOnWakeup = true;
startAnimation = true;
viewAnimated = false;
globals = NULL;
tokenContainer = NULL;
attribs = new cViewElementAttribs((int)eViewElementAttribs::count);
@ -35,7 +34,6 @@ cViewElement::cViewElement(const cViewElement &other) {
detached = false;
waitOnWakeup = true;
startAnimation = true;
viewAnimated = false;
globals = other.globals;
container.Set(other.container.X(), other.container.Y(), other.container.Width(), other.container.Height());
tokenContainer = NULL;
@ -436,7 +434,7 @@ void cViewElement::StartAnimation(void) {
SetPosition(start, ref);
sdOsd->Flush();
delete shifter;
shifter = new cAnimation((cShiftable*)this, start, ref, true, !viewAnimated);
shifter = new cAnimation((cShiftable*)this, start, ref, true);
shifter->Start();
} else if (FadeTime() > 0) {
SetTransparency(100);
@ -471,8 +469,19 @@ cRect cViewElement::CoveredArea(void) {
return unionArea;
}
void cViewElement::Flush(void) {
sdOsd->Flush();
void cViewElement::RegisterAnimation(void) {
sdOsd->AddAnimation();
}
void cViewElement::UnregisterAnimation(void) {
sdOsd->RemoveAnimation();
}
void cViewElement::Flush(bool animFlush) {
if (animFlush)
sdOsd->AnimatedFlush();
else
sdOsd->Flush();
}
bool cViewElement::Parse(bool forced) {

View File

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

View File

@ -32,5 +32,5 @@ void cSDDisplayChannel::SetMessage(eMessageType Type, const char *Text) {
void cSDDisplayChannel::Flush(void) {
if (!ok)
return;
view->Flush();
view->Flush(false);
}

View File

@ -165,7 +165,7 @@ bool cSDDisplayMenu::SetPluginText(skindesignerapi::cTokenContainer *tk) {
void cSDDisplayMenu::Flush(void) {
if (view)
view->Flush();
view->Flush(false);
}
void cSDDisplayMenu::SetCurrentRecording(void) {

View File

@ -21,5 +21,5 @@ void cSDDisplayMessage::SetMessage(eMessageType Type, const char *Text) {
void cSDDisplayMessage::Flush(void) {
if (!ok)
return;
view->Flush();
view->Flush(false);
}

View File

@ -78,7 +78,7 @@ void cSDDisplayReplay::SetMessage(eMessageType Type, const char *Text) {
void cSDDisplayReplay::Flush(void) {
if (!ok)
return;
view->Flush();
view->Flush(false);
}
void cSDDisplayReplay::SetTimeShiftValues(const cRecording *recording) {

View File

@ -27,5 +27,5 @@ void cSDDisplayTracks::SetAudioChannel(int AudioChannel) {
void cSDDisplayTracks::Flush(void) {
if (!ok)
return;
view->Flush();
view->Flush(false);
}

View File

@ -22,5 +22,5 @@ void cSDDisplayVolume::SetVolume(int Current, int Total, bool Mute) {
void cSDDisplayVolume::Flush(void) {
if (!ok)
return;
view->Flush();
view->Flush(false);
}

View File

@ -3,7 +3,7 @@
NAME = skindesignerapi
LIBNAME = lib$(NAME)
MAJOR = 0
MINOR = 1.0
MINOR = 1.1
VERSION = $(MAJOR).$(MINOR)
SONAME = $(LIBNAME).so.$(MAJOR)

View File

@ -198,5 +198,5 @@ skindesignerapi::cViewTab *skindesignerapi::cOsdView::GetViewTabs(void) {
void skindesignerapi::cOsdView::Display(void) {
if (displayPlugin)
displayPlugin->Flush();
displayPlugin->Flush(false);
}

View File

@ -47,7 +47,7 @@ public:
virtual void TabDown(int viewId) = 0;
virtual void DisplayTabs(int viewId) = 0;
virtual void ClearTab(int viewId) = 0;
virtual void Flush(void) = 0;
virtual void Flush(bool animFlush) = 0;
virtual bool ChannelLogoExists(string channelId) = 0;
virtual string GetEpgImagePath(void) = 0;
};

View File

@ -22,7 +22,7 @@ private:
//token containers
char **stringTokens;
int *intTokens;
vector<char***>loopTokens;
vector<char***> loopTokens;
//mapping id --> name
string *stNames;
string *itNames;