Permalink
Browse files

Subtitles: Rescale AV subs in place when the zoom factor is changed.

This gives the user immediate feedback on the zoom adjustment, without
making them wait for the next subtitle to be displayed.
Unfortunately, the rescaled subtitle ends up being shifted to the
upper left of the screen; this will be fixed later.  (Subsequent
subtitles are displayed properly.)
  • Loading branch information...
stichnot committed May 22, 2012
1 parent 375d12e commit 650b2728375fac7ae45039b2c7fa95208ff9a728
Showing with 23 additions and 0 deletions.
  1. +22 −0 mythtv/libs/libmythtv/subtitlescreen.cpp
  2. +1 −0 mythtv/libs/libmythtv/subtitlescreen.h
@@ -672,6 +672,7 @@ void SubtitleScreen::ClearDisplayedSubtitles(void)
Clear708Cache(i);
DeleteAllChildren();
m_expireTimes.clear();
+ m_avsubCache.clear();
SetRedraw();
}
@@ -686,6 +687,7 @@ void SubtitleScreen::ExpireSubtitles(void)
it.next();
if (it.value() < now)
{
+ m_avsubCache.remove(it.key());
DeleteChild(it.key());
it.remove();
SetRedraw();
@@ -729,6 +731,25 @@ void SubtitleScreen::DisplayAVSubtitles(void)
if (!m_player || !m_subreader)
return;
+ // Resize subtitles if the zoom factor has changed since the last
+ // update.
+ if (m_textFontZoom != m_textFontZoomPrev)
+ {
+ double factor = m_textFontZoom / (double)m_textFontZoomPrev;
+ QHash<MythUIType*, MythImage*>::iterator it;
+ for (it = m_avsubCache.begin(); it != m_avsubCache.end(); ++it)
+ {
+ MythUIImage *image = dynamic_cast<MythUIImage *>(it.key());
+ if (image)
+ {
+ QSize size = it.value()->size();
+ size *= factor;
+ it.value()->Resize(size);
+ }
+ }
+ m_refreshArea = true;
+ }
+
AVSubtitles* subs = m_subreader->GetAVSubtitles();
QMutexLocker lock(&(subs->lock));
if (subs->buffers.empty() && (kDisplayAVSubtitle != m_subtitleType))
@@ -994,6 +1015,7 @@ int SubtitleScreen::DisplayScaledAVSubtitles(const AVSubtitleRect *rect,
uiimage->SetImage(image);
uiimage->SetArea(MythRect(scaled));
m_expireTimes.insert(uiimage, displayuntil);
+ m_avsubCache.insert(uiimage, image);
}
}
if (uiimage)
@@ -90,6 +90,7 @@ class SubtitleScreen : public MythScreenType
QRegExp m_removeHTML;
int m_subtitleType;
QHash<MythUIType*, long long> m_expireTimes;
+ QHash<MythUIType*, MythImage*> m_avsubCache;
int m_fontSize;
int m_textFontZoom; // valid for 708 & text subs
int m_textFontZoomPrev;

0 comments on commit 650b272

Please sign in to comment.