Skip to content

Commit

Permalink
Merge pull request xbmc#7277 from FernetMenta/subs
Browse files Browse the repository at this point in the history
fix subtitle positions
  • Loading branch information
MartijnKaijser committed Jun 14, 2015
2 parents 91a85f0 + 74ad4c1 commit daedd5f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
28 changes: 14 additions & 14 deletions xbmc/cores/VideoRenderers/OverlayRenderer.cpp
Expand Up @@ -188,20 +188,28 @@ void CRenderer::Render(int idx)
}

float total_height = 0.0f;
float cur_height = 0.0f;
int subalign = CSettings::Get().GetInt("subtitles.align");
for (std::vector<COverlay*>::iterator it = render.begin(); it != render.end(); ++it)
{
COverlay* o = *it;
o->PrepareRender();
if (o->m_align == COverlay::ALIGN_SUBTITLE)
total_height += o->m_height;
total_height += o->m_height;
}

for (std::vector<COverlay*>::iterator it = render.begin(); it != render.end(); ++it)
{
COverlay* o = *it;

float adjust_height = 0.0f;
if (o->m_align == COverlay::ALIGN_SUBTITLE)

if(subalign == SUBTITLE_ALIGN_TOP_INSIDE ||
subalign == SUBTITLE_ALIGN_TOP_OUTSIDE)
{
adjust_height = cur_height;
cur_height += o->m_height;
}
else
{
total_height -= o->m_height;
adjust_height = -total_height;
Expand Down Expand Up @@ -235,8 +243,8 @@ void CRenderer::Render(COverlay* o, float adjust_height)
if(align == COverlay::ALIGN_SCREEN
|| align == COverlay::ALIGN_SUBTITLE)
{
scale_x = (float)rd.Width();
scale_y = (float)rd.Height();
scale_x = (float)rv.Width();
scale_y = (float)rv.Height();
}

if(align == COverlay::ALIGN_VIDEO)
Expand All @@ -258,19 +266,11 @@ void CRenderer::Render(COverlay* o, float adjust_height)
if(align == COverlay::ALIGN_SCREEN
|| align == COverlay::ALIGN_SUBTITLE)
{
float scale_x = rv.Width() / rd.Width();
float scale_y = rv.Height() / rd.Height();

state.x *= scale_x;
state.y *= scale_y;
state.width *= scale_x;
state.height *= scale_y;

if(align == COverlay::ALIGN_SUBTITLE)
{
RESOLUTION_INFO res = g_graphicsContext.GetResInfo(g_renderManager.GetResolution());
state.x += rv.x1 + rv.Width() * 0.5f;
state.y += rv.y1 + (res.iSubtitles - res.Overscan.top) * scale_y;
state.y += rv.y1 + (res.iSubtitles - res.Overscan.top);
}
else
{
Expand Down
5 changes: 3 additions & 2 deletions xbmc/cores/VideoRenderers/OverlayRendererGUI.cpp
Expand Up @@ -170,15 +170,16 @@ void COverlayText::Render(OVERLAY::SRenderState &state)
mat.m[0][3] = rd.x1;
mat.m[1][3] = rd.y1;

float x = state.x, y = state.y;
float x = state.x;
float y = state.y;
mat.InverseTransformPosition(x, y);

g_graphicsContext.SetTransform(mat, 1.0f, 1.0f);

float width_max = (float) res.Overscan.right - res.Overscan.left;

if (m_subalign == SUBTITLE_ALIGN_MANUAL
|| m_subalign == SUBTITLE_ALIGN_TOP_OUTSIDE
|| m_subalign == SUBTITLE_ALIGN_BOTTOM_OUTSIDE
|| m_subalign == SUBTITLE_ALIGN_BOTTOM_INSIDE)
y -= m_height;

Expand Down

0 comments on commit daedd5f

Please sign in to comment.