Bug 1025553, part 4 - Add some missing Moz2D Matrix API to gfxMatrix. r=Bas

This commit is contained in:
Jonathan Watt 2014-07-11 08:06:39 +01:00
parent 91e483122f
commit b45be5817c
2 changed files with 33 additions and 0 deletions

View File

@ -58,6 +58,22 @@ gfxMatrix::PreMultiply(const gfxMatrix& m)
return *this;
}
/* static */ gfxMatrix
gfxMatrix::Rotation(gfxFloat aAngle)
{
gfxMatrix newMatrix;
gfxFloat s = sin(aAngle);
gfxFloat c = cos(aAngle);
newMatrix._11 = c;
newMatrix._12 = s;
newMatrix._21 = -s;
newMatrix._22 = c;
return newMatrix;
}
gfxPoint
gfxMatrix::Transform(const gfxPoint& point) const
{

View File

@ -144,6 +144,23 @@ public:
*/
const gfxMatrix& PreMultiply(const gfxMatrix& m);
static gfxMatrix Translation(gfxFloat aX, gfxFloat aY)
{
return gfxMatrix(1.0, 0.0, 0.0, 1.0, aX, aY);
}
static gfxMatrix Translation(gfxPoint aPoint)
{
return Translation(aPoint.x, aPoint.y);
}
static gfxMatrix Rotation(gfxFloat aAngle);
static gfxMatrix Scaling(gfxFloat aX, gfxFloat aY)
{
return gfxMatrix(aX, 0.0, 0.0, aY, 0.0, 0.0);
}
/**
* Transforms a point according to this matrix.
*/