Skip to content
Browse files

[transforms] extend the UI transform with the font scaling amounts

  • Loading branch information...
1 parent ec6480f commit 645330b64c7a6f175b43270b036a1f004e1f0dc3 Jonathan Marshall committed Nov 14, 2013
Showing with 32 additions and 27 deletions.
  1. +8 −12 xbmc/guilib/GraphicContext.cpp
  2. +24 −15 xbmc/guilib/GraphicContext.h
View
20 xbmc/guilib/GraphicContext.cpp
@@ -53,15 +53,13 @@ CGraphicContext::CGraphicContext(void) :
m_bCalibrating(false),
m_Resolution(RES_INVALID),
/*m_windowResolution,*/
- m_guiScaleX(1.0f),
- m_guiScaleY(1.0f)
/*,m_cameras, */
/*m_origins, */
/*m_clipRegions,*/
/*m_guiTransform,*/
/*m_finalTransform, */
/*m_groupTransform*/
- , m_stereoView(RENDER_STEREO_VIEW_OFF)
+ m_stereoView(RENDER_STEREO_VIEW_OFF)
, m_stereoMode(RENDER_STEREO_MODE_OFF)
, m_nextStereoMode(RENDER_STEREO_MODE_OFF)
{
@@ -790,12 +788,10 @@ void CGraphicContext::SetScalingResolution(const RESOLUTION_INFO &res, bool need
Lock();
m_windowResolution = res;
if (needsScaling && m_Resolution != RES_INVALID)
- GetGUIScaling(res, m_guiScaleX, m_guiScaleY, &m_guiTransform);
+ GetGUIScaling(res, m_guiTransform.scaleX, m_guiTransform.scaleY, &m_guiTransform.matrix);
else
{
m_guiTransform.Reset();
- m_guiScaleX = 1.0f;
- m_guiScaleY = 1.0f;
}
// reset our origin and camera
@@ -838,14 +834,14 @@ void CGraphicContext::SetStereoView(RENDER_STEREO_VIEW view)
void CGraphicContext::InvertFinalCoords(float &x, float &y) const
{
- m_finalTransform.InverseTransformPosition(x, y);
+ m_finalTransform.matrix.InverseTransformPosition(x, y);
}
float CGraphicContext::GetScalingPixelRatio() const
{
// assume the resolutions are different - we want to return the aspect ratio of the video resolution
// but only once it's been corrected for the skin -> screen coordinates scaling
- return GetResInfo().fPixelRatio * (m_guiScaleY / m_guiScaleX);
+ return GetResInfo().fPixelRatio * (m_finalTransform.scaleY / m_finalTransform.scaleX);
}
void CGraphicContext::SetCameraPosition(const CPoint &camera)
@@ -917,9 +913,9 @@ void CGraphicContext::UpdateCameraPosition(const CPoint &camera)
bool CGraphicContext::RectIsAngled(float x1, float y1, float x2, float y2) const
{ // need only test 3 points, as they must be co-planer
- if (m_finalTransform.TransformZCoord(x1, y1, 0)) return true;
- if (m_finalTransform.TransformZCoord(x2, y2, 0)) return true;
- if (m_finalTransform.TransformZCoord(x1, y2, 0)) return true;
+ if (m_finalTransform.matrix.TransformZCoord(x1, y1, 0)) return true;
+ if (m_finalTransform.matrix.TransformZCoord(x2, y2, 0)) return true;
+ if (m_finalTransform.matrix.TransformZCoord(x1, y2, 0)) return true;
return false;
}
@@ -1004,7 +1000,7 @@ void CGraphicContext::Flip(const CDirtyRegionList& dirty)
void CGraphicContext::ApplyHardwareTransform()
{
- g_Windowing.ApplyHardwareTransform(m_finalTransform);
+ g_Windowing.ApplyHardwareTransform(m_finalTransform.matrix);
}
void CGraphicContext::RestoreHardwareTransform()
View
39 xbmc/guilib/GraphicContext.h
@@ -140,17 +140,17 @@ class CGraphicContext : public CCriticalSection,
float GetScalingPixelRatio() const;
void Flip(const CDirtyRegionList& dirty);
void InvertFinalCoords(float &x, float &y) const;
- inline float ScaleFinalXCoord(float x, float y) const XBMC_FORCE_INLINE { return m_finalTransform.TransformXCoord(x, y, 0); }
- inline float ScaleFinalYCoord(float x, float y) const XBMC_FORCE_INLINE { return m_finalTransform.TransformYCoord(x, y, 0); }
- inline float ScaleFinalZCoord(float x, float y) const XBMC_FORCE_INLINE { return m_finalTransform.TransformZCoord(x, y, 0); }
- inline void ScaleFinalCoords(float &x, float &y, float &z) const XBMC_FORCE_INLINE { m_finalTransform.TransformPosition(x, y, z); }
+ inline float ScaleFinalXCoord(float x, float y) const XBMC_FORCE_INLINE { return m_finalTransform.matrix.TransformXCoord(x, y, 0); }
+ inline float ScaleFinalYCoord(float x, float y) const XBMC_FORCE_INLINE { return m_finalTransform.matrix.TransformYCoord(x, y, 0); }
+ inline float ScaleFinalZCoord(float x, float y) const XBMC_FORCE_INLINE { return m_finalTransform.matrix.TransformZCoord(x, y, 0); }
+ inline void ScaleFinalCoords(float &x, float &y, float &z) const XBMC_FORCE_INLINE { m_finalTransform.matrix.TransformPosition(x, y, z); }
bool RectIsAngled(float x1, float y1, float x2, float y2) const;
- inline float GetGUIScaleX() const XBMC_FORCE_INLINE { return m_guiScaleX; }
- inline float GetGUIScaleY() const XBMC_FORCE_INLINE { return m_guiScaleY; }
+ inline float GetGUIScaleX() const XBMC_FORCE_INLINE { return m_finalTransform.scaleX; }
+ inline float GetGUIScaleY() const XBMC_FORCE_INLINE { return m_finalTransform.scaleY; }
inline color_t MergeAlpha(color_t color) const XBMC_FORCE_INLINE
{
- color_t alpha = m_finalTransform.TransformAlpha((color >> 24) & 0xff);
+ color_t alpha = m_finalTransform.matrix.TransformAlpha((color >> 24) & 0xff);
if (alpha > 255) alpha = 255;
return ((alpha << 24) & 0xff000000) | (color & 0xffffff);
}
@@ -206,13 +206,13 @@ class CGraphicContext : public CCriticalSection,
inline TransformMatrix AddTransform(const TransformMatrix &matrix)
{
m_transforms.push(m_finalTransform);
- m_finalTransform *= matrix;
- return m_finalTransform;
+ m_finalTransform.matrix *= matrix;
+ return m_finalTransform.matrix;
}
inline void SetTransform(const TransformMatrix &matrix)
{
m_transforms.push(m_finalTransform);
- m_finalTransform = matrix;
+ m_finalTransform.matrix = matrix;
}
inline void RemoveTransform()
{
@@ -243,17 +243,26 @@ class CGraphicContext : public CCriticalSection,
RESOLUTION m_Resolution;
private:
+ class UITransform
+ {
+ public:
+ UITransform() : matrix(), scaleX(1.0f), scaleY(1.0f) {};
+ UITransform(const TransformMatrix &m, const float sX = 1.0f, const float sY = 1.0f) : matrix(m), scaleX(sX), scaleY(sY) { };
+ void Reset() { matrix.Reset(); scaleX = scaleY = 1.0f; };
+
+ TransformMatrix matrix;
+ float scaleX;
+ float scaleY;
+ };
void UpdateCameraPosition(const CPoint &camera);
RESOLUTION_INFO m_windowResolution;
- float m_guiScaleX;
- float m_guiScaleY;
std::stack<CPoint> m_cameras;
std::stack<CPoint> m_origins;
std::stack<CRect> m_clipRegions;
- TransformMatrix m_guiTransform;
- TransformMatrix m_finalTransform;
- std::stack<TransformMatrix> m_transforms;
+ UITransform m_guiTransform;
+ UITransform m_finalTransform;
+ std::stack<UITransform> m_transforms;
RENDER_STEREO_VIEW m_stereoView;
RENDER_STEREO_MODE m_stereoMode;
RENDER_STEREO_MODE m_nextStereoMode;

0 comments on commit 645330b

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