summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkamel5 <vdr.kamel5 (at) gmx (dot) net>2021-06-11 14:37:00 +0200
committerkamel5 <vdr.kamel5 (at) gmx (dot) net>2021-07-12 13:40:39 +0200
commit4358bf876579464772f98cc3aa43af345d127880 (patch)
tree4d74690d42f9e3be2a81a316dd2926b6c05cf298
parent97fa0bc7ff041c102975fcf19b82c1e4eb623efa (diff)
downloadskin-nopacity-4358bf876579464772f98cc3aa43af345d127880.tar.gz
skin-nopacity-4358bf876579464772f98cc3aa43af345d127880.tar.bz2
Optimize Flush in display tracks
Changes in Flush(): This ensures that only one flush is active when the thread is running. Changes in Acton(): Since the first Pixmap::Lock() takes so much longer than the following, the first Pixmap::Lock() was moved before the while loop. This makes the fade-in softer. Add cNopacityDisplayReplay::SetAlpha() for simplification.
-rw-r--r--displaytracks.c55
-rw-r--r--displaytracks.h1
-rw-r--r--menuitem.c1
3 files changed, 37 insertions, 20 deletions
diff --git a/displaytracks.c b/displaytracks.c
index becbb50..c53ecc7 100644
--- a/displaytracks.c
+++ b/displaytracks.c
@@ -25,6 +25,8 @@ cNopacityDisplayTracks::~cNopacityDisplayTracks() {
osd->DestroyPixmap(pixmapContainer);
osd->DestroyPixmap(pixmapHeader);
osd->DestroyPixmap(pixmapHeaderAudio);
+ if (pixmapIcon)
+ osd->DestroyPixmap(pixmapIcon);
menuItems.clear();
delete osd;
}
@@ -82,14 +84,10 @@ void cNopacityDisplayTracks::CreatePixmaps(void) {
pixmapContainer = osd->CreatePixmap(1, cRect(0, 0, width, height));
pixmapHeader = osd->CreatePixmap(2, cRect(2, 2, menuItemWidth, menuItemHeight));
pixmapHeaderAudio = osd->CreatePixmap(3, cRect(menuItemWidth - menuItemHeight, 2, menuItemHeight, menuItemHeight));
- if (FadeTime) {
- pixmapContainer->SetAlpha(0);
- pixmapHeader->SetAlpha(0);
- pixmapHeaderAudio->SetAlpha(0);
- }
}
void cNopacityDisplayTracks::DrawHeader(const char *Title) {
+ pixmapHeaderAudio->Fill(clrTransparent);
pixmapContainer->Fill(Theme.Color(clrMenuBorder));
pixmapContainer->DrawRectangle(cRect(1, 1, width-2, height-2), Theme.Color(clrMenuBack));
if (config.GetValue("displayType") == dtBlending) {
@@ -111,7 +109,22 @@ void cNopacityDisplayTracks::DrawHeader(const char *Title) {
cImage *imgTracks = imgCache->GetSkinIcon("skinIcons/tracks", menuItemHeight-6, menuItemHeight-6);
if (imgTracks)
pixmapIcon->DrawImage(cPoint(3,3), *imgTracks);
- pixmapIcon->DrawText(cPoint((width - fontManager->trackHeader->Width(Title)) / 2, (menuItemHeight - fontManager->trackHeader->Height()) / 2), Title, Theme.Color(clrTracksFontHead), clrTransparent, fontManager->trackHeader);
+ pixmapHeader->DrawText(cPoint((width - fontManager->trackHeader->Width(Title)) / 2, (menuItemHeight - fontManager->trackHeader->Height()) / 2), Title, Theme.Color(clrTracksFontHead), clrTransparent, fontManager->trackHeader);
+}
+
+void cNopacityDisplayTracks::SetAlpha(int Alpha) {
+ if (config.GetValue("tracksFadeTime")) {
+ pixmapContainer->SetAlpha(Alpha);
+ pixmapHeader->SetAlpha(Alpha);
+ pixmapHeaderAudio->SetAlpha(Alpha);
+ pixmapIcon->SetAlpha(Alpha);
+ for (auto i = menuItems.begin(); i != menuItems.end(); ++i) {
+ if (*i && Running()) {
+ cNopacityMenuItem *item = i->get();
+ item->SetAlpha(Alpha);
+ }
+ }
+ }
}
void cNopacityDisplayTracks::SetItem(const char *Text, int Index, bool Current) {
@@ -127,6 +140,8 @@ void cNopacityDisplayTracks::SetItem(const char *Text, int Index, bool Current)
if (config.GetValue("displayType") == dtGraphical)
item->CreatePixmapForeground();
item->Render();
+ if (initial && config.GetValue("tracksFadeTime"))
+ item->SetAlpha(0);
}
void cNopacityDisplayTracks::SetTrack(int Index, const char * const *Tracks) {
@@ -166,32 +181,32 @@ void cNopacityDisplayTracks::SetAudioChannel(int AudioChannel) {
}
void cNopacityDisplayTracks::Flush(void) {
- if (initial)
- if (FadeTime)
- Start();
+ if (Running())
+ return;
+ if (initial && config.GetValue("tracksFadeTime")) {
+ SetAlpha(0);
+ Start();
+ }
initial = false;
osd->Flush();
}
void cNopacityDisplayTracks::Action(void) {
+ uint64_t First = cTimeMs::Now();
+ cPixmap::Lock();
+ cPixmap::Unlock();
uint64_t Start = cTimeMs::Now();
+ dsyslog ("skinnopacity: First Lock(): %lims \n", Start - First);
while (Running()) {
uint64_t Now = cTimeMs::Now();
- cPixmap::Lock();
double t = std::min(double(Now - Start) / FadeTime, 1.0);
int Alpha = t * ALPHA_OPAQUE;
- pixmapContainer->SetAlpha(Alpha);
- pixmapHeader->SetAlpha(Alpha);
- pixmapHeaderAudio->SetAlpha(Alpha);
- for (auto i = menuItems.begin(); i != menuItems.end(); ++i) {
- if (*i && Running()) {
- cNopacityMenuItem *item = i->get();
- item->SetAlpha(Alpha);
- }
+ cPixmap::Lock();
+ SetAlpha(Alpha);
+ if (Running()) {
+ osd->Flush();
}
cPixmap::Unlock();
- if (Running())
- osd->Flush();
int Delta = cTimeMs::Now() - Now;
if (Running() && (Delta < FrameTime))
cCondWait::SleepMs(FrameTime - Delta);
diff --git a/displaytracks.h b/displaytracks.h
index 8d1459f..79183b7 100644
--- a/displaytracks.h
+++ b/displaytracks.h
@@ -29,6 +29,7 @@ private:
void SetGeometry(void);
void CreatePixmaps(void);
void DrawHeader(const char *Title);
+ void SetAlpha(int Alpha = 0);
public:
cNopacityDisplayTracks(const char *Title, int NumTracks, const char * const *Tracks);
virtual ~cNopacityDisplayTracks();
diff --git a/menuitem.c b/menuitem.c
index 22a02ba..718e304 100644
--- a/menuitem.c
+++ b/menuitem.c
@@ -81,6 +81,7 @@ void cNopacityMenuItem::CreatePixmapTextScroller(int totalWidth) {
void cNopacityMenuItem::SetAlpha(int alpha) {
pixmapBackground->SetAlpha(alpha);
+ if (pixmapForeground) pixmapForeground->SetAlpha(alpha);
if (pixmapStatic) pixmapStatic->SetAlpha(alpha);
if (pixmapTextScroller) pixmapTextScroller->SetAlpha(alpha);
if (infoTextWindow) infoTextWindow->SetAlpha(alpha);