Bug 929350 - Allow the context for gfxContextMatrixAutoSaveRestore to be set lazily. r=mattwoodrow

This commit is contained in:
Jonathan Watt 2013-10-22 10:37:45 +02:00
parent 7f64f7b53b
commit e744bbf378

View File

@ -900,6 +900,11 @@ private:
class gfxContextMatrixAutoSaveRestore
{
public:
gfxContextMatrixAutoSaveRestore() :
mContext(nullptr)
{
}
gfxContextMatrixAutoSaveRestore(gfxContext *aContext) :
mContext(aContext), mMatrix(aContext->CurrentMatrix())
{
@ -907,11 +912,28 @@ public:
~gfxContextMatrixAutoSaveRestore()
{
mContext->SetMatrix(mMatrix);
if (mContext) {
mContext->SetMatrix(mMatrix);
}
}
void SetContext(gfxContext *aContext)
{
NS_ASSERTION(!mContext, "Not going to restore the matrix on some context!");
mContext = aContext;
mMatrix = aContext->CurrentMatrix();
}
void Restore()
{
if (mContext) {
mContext->SetMatrix(mMatrix);
}
}
const gfxMatrix& Matrix()
{
MOZ_ASSERT(mContext, "mMatrix doesn't contain a useful matrix");
return mMatrix;
}