Permalink
Browse files

Gfx: Add GDI+ specific temporary solution for transformations

  • Loading branch information...
1 parent 6f81e31 commit 349988e5dd0c1e22966ba19f5af87dc46960dda3 @poiru poiru committed Mar 29, 2013
Showing with 37 additions and 12 deletions.
  1. +6 −0 Common/Gfx/Canvas.h
  2. +20 −0 Common/Gfx/CanvasGDIP.cpp
  3. +5 −0 Common/Gfx/CanvasGDIP.h
  4. +4 −6 Library/MeterString.cpp
  5. +2 −6 Library/MeterWindow.cpp
View
@@ -57,6 +57,12 @@ class __declspec(novtable) Canvas
virtual bool IsTransparentPixel(int x, int y) = 0;
+ // TODO: Implement proper solution.
+ virtual void SetTransform(const Gdiplus::Matrix& matrix) {}
+ virtual void ResetTransform() {}
+ virtual void RotateTransform(float angle) {}
+ virtual void TranslateTransform(float dx, float dy) {}
+
virtual void SetAntiAliasing(bool enable) = 0;
virtual void SetTextAntiAliasing(bool enable) = 0;
View
@@ -128,6 +128,26 @@ bool CanvasGDIP::IsTransparentPixel(int x, int y)
return false;
}
+void CanvasGDIP::SetTransform(const Gdiplus::Matrix& matrix)
+{
+ m_Graphics->SetTransform(&matrix);
+}
+
+void CanvasGDIP::ResetTransform()
+{
+ m_Graphics->ResetTransform();
+}
+
+void CanvasGDIP::RotateTransform(float angle)
+{
+ m_Graphics->RotateTransform(angle);
+}
+
+void CanvasGDIP::TranslateTransform(float dx, float dy)
+{
+ m_Graphics->TranslateTransform(dx, dy);
+}
+
void CanvasGDIP::SetAntiAliasing(bool enable)
{
m_Graphics->SetSmoothingMode(
View
@@ -48,6 +48,11 @@ class CanvasGDIP : public Canvas
virtual bool IsTransparentPixel(int x, int y) override;
+ virtual void SetTransform(const Gdiplus::Matrix& matrix) override;
+ virtual void ResetTransform() override;
+ virtual void RotateTransform(float angle) override;
+ virtual void TranslateTransform(float dx, float dy) override;
+
virtual void SetAntiAliasing(bool enable) override;
virtual void SetTextAntiAliasing(bool enable) override;
View
@@ -542,10 +542,9 @@ bool CMeterString::DrawString(Gfx::Canvas& canvas, RectF* rect)
if (m_Angle != 0.0f)
{
- // TODO FIXME
- //graphics.TranslateTransform((Gdiplus::REAL)CMeter::GetX(), y);
- //graphics.RotateTransform(CONVERT_TO_DEGREES(m_Angle));
- //graphics.TranslateTransform(-(Gdiplus::REAL)CMeter::GetX(), -y);
+ canvas.TranslateTransform((Gdiplus::REAL)CMeter::GetX(), y);
+ canvas.RotateTransform(CONVERT_TO_DEGREES(m_Angle));
+ canvas.TranslateTransform(-(Gdiplus::REAL)CMeter::GetX(), -y);
}
if (m_Effect != EFFECT_NONE)
@@ -576,8 +575,7 @@ bool CMeterString::DrawString(Gfx::Canvas& canvas, RectF* rect)
if (m_Angle != 0.0f)
{
- // TODO FIXME
- //graphics.ResetTransform();
+ canvas.ResetTransform();
}
}
View
@@ -2527,13 +2527,9 @@ void CMeterWindow::Redraw()
const Matrix* matrix = (*j)->GetTransformationMatrix();
if (matrix && !matrix->IsIdentity())
{
- // TODO FIXME: Change the world matrix
- //m_Canvas->GetGraphics().SetTransform(matrix);
-
+ m_Canvas->SetTransform(*matrix);
(*j)->Draw(*m_Canvas);
-
- // TODO FIXME: Set back to identity matrix
- //m_Canvas->GetGraphics().ResetTransform();
+ m_Canvas->ResetTransform();
}
else
{

0 comments on commit 349988e

Please sign in to comment.