Bug 1151145 - Add assertions to detect unbalanced calls to CGContextSaveGState / CGContextRestoreGState. r=jrmuizel

--HG--
extra : rebase_source : d5f12fa26ec4524ec798704f3851c47215a79f31
This commit is contained in:
Markus Stange 2015-04-04 18:12:12 -04:00
parent 4355f36a4c
commit b0398aca4b
2 changed files with 19 additions and 0 deletions

View File

@ -1961,6 +1961,10 @@ DrawTargetCG::PushClipRect(const Rect &aRect)
return;
}
#ifdef DEBUG
mSavedClipBounds.push_back(CGContextGetClipBoundingBox(mCg));
#endif
CGContextSaveGState(mCg);
/* We go through a bit of trouble to temporarilly set the transform
@ -1979,6 +1983,10 @@ DrawTargetCG::PushClip(const Path *aPath)
return;
}
#ifdef DEBUG
mSavedClipBounds.push_back(CGContextGetClipBoundingBox(mCg));
#endif
CGContextSaveGState(mCg);
CGContextBeginPath(mCg);
@ -2013,6 +2021,13 @@ void
DrawTargetCG::PopClip()
{
CGContextRestoreGState(mCg);
#ifdef DEBUG
MOZ_ASSERT(!mSavedClipBounds.empty(), "Unbalanced PopClip");
MOZ_ASSERT(CGRectEqualToRect(mSavedClipBounds.back(), CGContextGetClipBoundingBox(mCg)),
"PopClip didn't restore original clip");
mSavedClipBounds.pop_back();
#endif
}
void

View File

@ -207,6 +207,10 @@ private:
RefPtr<SourceSurfaceCGContext> mSnapshot;
bool mMayContainInvalidPremultipliedData;
#ifdef DEBUG
std::vector<CGRect> mSavedClipBounds;
#endif
};
}