Skip to content

Commit

Permalink
OSD: Remove unused Draw method
Browse files Browse the repository at this point in the history
- which was used for blended OSDs
- rename DrawDirect to Draw
  • Loading branch information
mark-kendall committed Nov 21, 2019
1 parent c9c16f4 commit 3251011
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 186 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/opengl/mythvideooutopengl.cpp
Expand Up @@ -640,11 +640,11 @@ void MythVideoOutputOpenGL::PrepareFrame(VideoFrame *Frame, FrameScanType Scan,
{
if (twopass)
m_render->SetViewPort(first, true);
Osd->DrawDirect(m_openGLPainter, GetTotalOSDBounds().size(), true);
Osd->Draw(m_openGLPainter, GetTotalOSDBounds().size(), true);
if (twopass)
{
m_render->SetViewPort(second, true);
Osd->DrawDirect(m_openGLPainter, GetTotalOSDBounds().size(), true);
Osd->Draw(m_openGLPainter, GetTotalOSDBounds().size(), true);
m_render->SetViewPort(main);
}
}
Expand Down
181 changes: 1 addition & 180 deletions mythtv/libs/libmythtv/osd.cpp
Expand Up @@ -648,7 +648,7 @@ void OSD::SetGraph(const QString &Window, const QString &Graph, int64_t Timecode
image->SetImage(mi);
}

bool OSD::DrawDirect(MythPainter* Painter, QSize Size, bool Repaint)
bool OSD::Draw(MythPainter* Painter, QSize Size, bool Repaint)
{
if (!Painter)
return false;
Expand Down Expand Up @@ -760,185 +760,6 @@ bool OSD::DrawDirect(MythPainter* Painter, QSize Size, bool Repaint)
return redraw;
}

QRegion OSD::Draw(MythPainter* Painter, QPaintDevice *Device, QSize Size,
QRegion &Changed, int AlignX, int AlignY)
{
bool redraw = m_Refresh;
QRegion visible = QRegion();
QRegion dirty = m_Refresh ? QRegion(QRect(QPoint(0,0), m_Rect.size())) :
QRegion();
m_Refresh = false;

if (!Painter || !Device)
return visible;

QTime now = MythDate::current().time();
CheckExpiry();

// first update for alpha pulse and fade
QMap<QString,MythScreenType*>::const_iterator it;
for (it = m_Children.begin(); it != m_Children.end(); ++it)
{
if ((*it)->IsVisible())
{
QRect vis = (*it)->GetArea().toQRect();
if (visible.isEmpty())
visible = QRegion(vis);
else
visible = visible.united(vis);

(*it)->Pulse();
if (m_ExpireTimes.contains((*it)))
{
QTime expires = m_ExpireTimes.value((*it)).time();
int left = now.msecsTo(expires);
if (left < m_FadeTime)
(*it)->SetAlpha((255 * left) / m_FadeTime);
}
}

if ((*it)->NeedsRedraw())
{
QRegion area = (*it)->GetDirtyArea();
dirty = dirty.united(area);
redraw = true;
}
}

MythNotificationCenter *nc = GetNotificationCenter();
QList<MythScreenType*> notifications;
nc->GetNotificationScreens(notifications);
QList<MythScreenType*>::iterator it2 = notifications.begin();
while (it2 != notifications.end())
{
if (!MythNotificationCenter::ScreenCreated(*it2))
{
if (!m_UIScaleOverride)
{
OverrideUIScale(false);
}
(*it2)->SetPainter(m_CurrentPainter);
if (!(*it2)->Create())
{
it2 = notifications.erase(it2);
continue;
}
}
if ((*it2)->IsVisible())
{
if (!m_UIScaleOverride)
{
OverrideUIScale(false);
}
nc->UpdateScreen(*it2);

QRect vis = (*it2)->GetArea().toQRect();
if (visible.isEmpty())
visible = QRegion(vis);
else
visible = visible.united(vis);

(*it2)->Pulse();
QTime expires = nc->ScreenExpiryTime(*it2).time();
int left = now.msecsTo(expires);
if (expires.isValid() && left < m_FadeTime)
(*it2)->SetAlpha((255 * left) / m_FadeTime);
}

if ((*it2)->NeedsRedraw())
{
QRegion area = (*it2)->GetDirtyArea();
dirty = dirty.united(area);
redraw = true;
}
++it2;
}
RevertUIScale();

if (redraw)
{
// clear the dirty area
Painter->Clear(Device, dirty);

// set redraw for any widgets that may now need a partial repaint
for (it = m_Children.begin(); it != m_Children.end(); ++it)
{
if ((*it)->IsVisible() && !(*it)->NeedsRedraw() &&
dirty.intersects((*it)->GetArea().toQRect()))
{
(*it)->SetRedraw();
}
}

for (it2 = notifications.begin(); it2 != notifications.end(); ++it2)
{
if ((*it2)->IsVisible() && !(*it2)->NeedsRedraw() &&
dirty.intersects((*it2)->GetArea().toQRect()))
{
(*it2)->SetRedraw();
}
}

// and finally draw
QRect cliprect = dirty.boundingRect();
Painter->Begin(Device);
Painter->SetClipRegion(dirty);
// TODO painting in reverse may be more efficient...
for (it = m_Children.begin(); it != m_Children.end(); ++it)
{
if ((*it)->NeedsRedraw())
{
if ((*it)->IsVisible())
(*it)->Draw(Painter, 0, 0, 255, cliprect);
(*it)->SetAlpha(255);
(*it)->ResetNeedsRedraw();
}
}

for (it2 = notifications.begin(); it2 != notifications.end(); ++it2)
{
if ((*it2)->NeedsRedraw())
{
if ((*it2)->IsVisible())
(*it2)->Draw(Painter, 0, 0, 255, cliprect);
(*it2)->SetAlpha(255);
(*it2)->ResetNeedsRedraw();
}
}

Painter->End();
}

Changed = dirty;

if (visible.isEmpty() || (!AlignX && !AlignY))
return visible;

// assist yuv blending with some friendly alignments
QRegion aligned;
#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
QVector<QRect> rects = visible.rects();
for (int i = 0; i < rects.size(); i++)
{
const QRect& r = rects[i];
#else
for (const QRect& r : visible)
{
#endif
int left = r.left() & ~(AlignX - 1);
int top = r.top() & ~(AlignY - 1);
int right = (r.left() + r.width());
int bot = (r.top() + r.height());
if (right & (AlignX - 1))
right += AlignX - (right & (AlignX - 1));
if (bot % AlignY)
bot += AlignY - (bot % AlignY);
aligned = aligned.united(QRegion(left, top, right - left, bot - top));
}

return aligned.intersected(QRect(QPoint(0,0), Size));
}

void OSD::CheckExpiry(void)
{
QDateTime now = MythDate::current();
Expand Down
4 changes: 1 addition & 3 deletions mythtv/libs/libmythtv/osd.h
Expand Up @@ -152,9 +152,7 @@ class OSD
void ResetWindow(const QString &Window);
void PositionWindow(MythScreenType *Window);
void RemoveWindow(const QString &Window);
bool DrawDirect(MythPainter* Painter, QSize Size, bool Repaint = false);
QRegion Draw(MythPainter* Painter, QPaintDevice *Device, QSize Size,
QRegion &Changed, int AlignX = 0, int AlignY = 0);
bool Draw(MythPainter* Painter, QSize Size, bool Repaint = false);

void SetValues(const QString &Window, const QHash<QString,int> &Map, OSDTimeout Timeout);
void SetValues(const QString &Window, const QHash<QString,float> &Map, OSDTimeout Timeout);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/videoout_d3d.cpp
Expand Up @@ -376,7 +376,7 @@ void VideoOutputD3D::PrepareFrame(VideoFrame *buffer, FrameScanType t,
m_visual->Draw(GetTotalOSDBounds(), m_osd_painter, nullptr);

if (osd && m_osd_painter && !m_window.IsEmbedding())
osd->DrawDirect(m_osd_painter, GetTotalOSDBounds().size(),
osd->Draw(m_osd_painter, GetTotalOSDBounds().size(),
true);
m_render->End();
}
Expand Down

0 comments on commit 3251011

Please sign in to comment.