Skip to content

Commit

Permalink
Gfx: Add GDI+ specific temporary solution for transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
poiru committed Mar 29, 2013
1 parent 6f81e31 commit 349988e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
6 changes: 6 additions & 0 deletions Common/Gfx/Canvas.h
Expand Up @@ -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;

Expand Down
20 changes: 20 additions & 0 deletions Common/Gfx/CanvasGDIP.cpp
Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions Common/Gfx/CanvasGDIP.h
Expand Up @@ -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;

Expand Down
10 changes: 4 additions & 6 deletions Library/MeterString.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -576,8 +575,7 @@ bool CMeterString::DrawString(Gfx::Canvas& canvas, RectF* rect)

if (m_Angle != 0.0f)
{
// TODO FIXME
//graphics.ResetTransform();
canvas.ResetTransform();
}
}

Expand Down
8 changes: 2 additions & 6 deletions Library/MeterWindow.cpp
Expand Up @@ -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
{
Expand Down

0 comments on commit 349988e

Please sign in to comment.