Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[subs] scale subs rendered with our UI stuff correctly when in window…

…ed mode
  • Loading branch information...
commit 7a554ca4d3279f305ae3b338e81975a8d34b5d39 1 parent 645330b
Jonathan Marshall authored
View
25 xbmc/cores/VideoRenderers/OverlayRendererGUI.cpp
@@ -151,16 +151,28 @@ void COverlayText::Render(OVERLAY::SRenderState &state)
if(m_layout == NULL)
return;
- /* until we can get gfx scaling correct in windowed mode, we must disable this */
- if(!g_graphicsContext.IsFullScreenVideo())
- return;
-
CRect rs, rd;
g_renderManager.GetVideoRect(rs, rd);
RESOLUTION_INFO res = g_graphicsContext.GetResInfo();
+ /* our coordinates are in screen coordinates constrained to rd, but the font is sized suitably for fullscreen,
+ so we must scale up the positioning to screen coordinates, and then scale down to our final size and position
+ on render */
+
+ /* transform matrix is scale and translate */
+ float scale = rd.Width() / (res.Overscan.right - res.Overscan.left);
+ TransformMatrix mat;
+ mat.m[0][0] = mat.m[1][1] = scale;
+ mat.m[3][0] = rd.x1;
+ mat.m[3][1] = rd.y1;
+
+ float x = state.x, 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;
- float y, width, height;
+ float width, height;
m_layout->Update(m_text, width_max * 0.9f, false, true); // true to force LTR reading order (most Hebrew subs are this format)
m_layout->GetTextExtent(width, height);
@@ -175,5 +187,6 @@ void COverlayText::Render(OVERLAY::SRenderState &state)
y = std::max(y, (float) res.Overscan.top);
y = std::min(y, res.Overscan.bottom - height);
- m_layout->RenderOutline(state.x, y, 0, 0xFF000000, XBFONT_CENTER_X, width_max);
+ m_layout->RenderOutline(x, y, 0, 0xFF000000, XBFONT_CENTER_X, width_max);
+ g_graphicsContext.RemoveTransform();
}
View
7 xbmc/guilib/GraphicContext.h
@@ -214,6 +214,13 @@ class CGraphicContext : public CCriticalSection,
m_transforms.push(m_finalTransform);
m_finalTransform.matrix = matrix;
}
+ inline void SetTransform(const TransformMatrix &matrix, float scaleX, float scaleY)
+ {
+ m_transforms.push(m_finalTransform);
+ m_finalTransform.matrix = matrix;
+ m_finalTransform.scaleX = scaleX;
+ m_finalTransform.scaleY = scaleY;
+ }
inline void RemoveTransform()
{
if (!m_transforms.empty())

2 comments on commit 7a554ca

@EricV

given the fact that m is defined as float m[3][4]; line 166 and 167 are bogus!!!

@jmarshallnz

Thanks for the heads up - supposed to be [0][3] and [1][3] obv.

Please sign in to comment.
Something went wrong with that request. Please try again.