mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 08:42:13 +00:00
Bug 784573 - Create a RAII helper for temporary cairo matrices. r=joe
This commit is contained in:
parent
0ebc307776
commit
a362c2be73
@ -207,6 +207,32 @@ GfxFillRuleToCairoFillRule(FillRule rule)
|
||||
return CAIRO_FILL_RULE_WINDING;
|
||||
}
|
||||
|
||||
// RAII class for temporarily changing the cairo matrix transform. It will use
|
||||
// the given matrix transform while it is in scope. When it goes out of scope
|
||||
// it will put the cairo context back the way it was.
|
||||
|
||||
class CairoTempMatrix
|
||||
{
|
||||
public:
|
||||
CairoTempMatrix(cairo_t* aCtx, const Matrix& aMatrix)
|
||||
: mCtx(aCtx)
|
||||
{
|
||||
cairo_get_matrix(aCtx, &mSaveMatrix);
|
||||
cairo_matrix_t matrix;
|
||||
GfxMatrixToCairoMatrix(aMatrix, matrix);
|
||||
cairo_set_matrix(aCtx, &matrix);
|
||||
}
|
||||
|
||||
~CairoTempMatrix()
|
||||
{
|
||||
cairo_get_matrix(mCtx, &mSaveMatrix);
|
||||
}
|
||||
|
||||
private:
|
||||
cairo_t* mCtx;
|
||||
cairo_matrix_t mSaveMatrix;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user