Skip to content

Commit

Permalink
OSD: Fix subtitle window painting order.
Browse files Browse the repository at this point in the history
The order of iterating over a QHash is arbitrary and the fact that
subtitle and interactive screens have (mostly) been drawn in the correct
order since the OSD re-write is pure luck.

So switch to a QMap which, while marginally slower, will order on the
basis of the key (QString) and force the subtitle/interactive screens to
be painted first by adding some numerics to their identifiers.

Should fix the ordering issue seen in #9822 and occasionally in the yet
to be enabled blu-ray HDMV navigation mode.

Refs #9822
  • Loading branch information
Mark Kendall committed Jun 12, 2011
1 parent 5bcddfd commit be25039
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
12 changes: 8 additions & 4 deletions mythtv/libs/libmythtv/osd.cpp
Expand Up @@ -202,7 +202,7 @@ void OSD::SetPainter(MythPainter *painter)
return;

m_CurrentPainter = painter;
QHashIterator<QString, MythScreenType*> it(m_Children);
QMapIterator<QString, MythScreenType*> it(m_Children);
while (it.hasNext())
{
it.next();
Expand Down Expand Up @@ -278,7 +278,7 @@ bool OSD::IsVisible(void)

void OSD::HideAll(bool keepsubs, MythScreenType* except)
{
QMutableHashIterator<QString, MythScreenType*> it(m_Children);
QMutableMapIterator<QString, MythScreenType*> it(m_Children);
while (it.hasNext())
{
it.next();
Expand Down Expand Up @@ -542,7 +542,7 @@ bool OSD::DrawDirect(MythPainter* painter, QSize size, bool repaint)
QTime now = QTime::currentTime();

CheckExpiry();
QHash<QString,MythScreenType*>::iterator it;
QMap<QString,MythScreenType*>::const_iterator it;
for (it = m_Children.begin(); it != m_Children.end(); ++it)
{
if (it.value()->IsVisible())
Expand Down Expand Up @@ -598,7 +598,7 @@ QRegion OSD::Draw(MythPainter* painter, QPaintDevice *device, QSize size,
CheckExpiry();

// first update for alpha pulse and fade
QHash<QString,MythScreenType*>::iterator it;
QMap<QString,MythScreenType*>::const_iterator it;
for (it = m_Children.begin(); it != m_Children.end(); ++it)
{
if (it.value()->IsVisible())
Expand Down Expand Up @@ -1007,6 +1007,8 @@ TeletextScreen* OSD::InitTeletext(void)
if (tt->Create())
{
m_Children.insert(OSD_WIN_TELETEXT, tt);
VERBOSE(VB_PLAYBACK, LOC + QString("Created window %1")
.arg(OSD_WIN_TELETEXT));
}
else
{
Expand Down Expand Up @@ -1083,6 +1085,8 @@ SubtitleScreen* OSD::InitSubtitles(void)
if (sub->Create())
{
m_Children.insert(OSD_WIN_SUBTITLE, sub);
VERBOSE(VB_PLAYBACK, LOC + QString("Created window %1")
.arg(OSD_WIN_SUBTITLE));
}
else
{
Expand Down
14 changes: 9 additions & 5 deletions mythtv/libs/libmythtv/osd.h
Expand Up @@ -16,10 +16,14 @@
#define OSD_DLG_CUTPOINT "OSD_CUTPOINT"
#define OSD_DLG_DELETE "OSD_DELETE"
#define OSD_DLG_CONFIRM "mythconfirmpopup"
#define OSD_WIN_TELETEXT "OSD_TELETEXT"
#define OSD_WIN_SUBTITLE "OSD_SUBTITLES"
#define OSD_WIN_INTERACT "OSD_INTERACTIVE"
#define OSD_WIN_BDOVERLAY "OSD_BDOVERLAY"
// Force subtitle/interactive screens to be drawn first (i.e. at the back) by
// prepending their identifiers with a low numeric (may not always work as
// QMap/QString ordering is based on unicode values)
#define OSD_WIN_TELETEXT "00_OSD_TELETEXT"
#define OSD_WIN_SUBTITLE "00_OSD_SUBTITLES"
// MHEG and blu-ray overlay should cover subtitles
#define OSD_WIN_INTERACT "01_OSD_INTERACTIVE"
#define OSD_WIN_BDOVERLAY "01_OSD_BDOVERLAY"

#define kOSDFadeTime 1000

Expand Down Expand Up @@ -208,7 +212,7 @@ class OSD
enum OSDFunctionalType m_FunctionalType;
QString m_FunctionalWindow;

QHash<QString, MythScreenType*> m_Children;
QMap<QString, MythScreenType*> m_Children;
QHash<MythScreenType*, QDateTime> m_ExpireTimes;
};

Expand Down

0 comments on commit be25039

Please sign in to comment.