Bug 950550. Restore the transform in DrawTargetCairo::PopClip. r=jrmuizel
authorNicholas Cameron <ncameron@mozilla.com>
Tue, 07 Jan 2014 11:27:03 +1300
changeset 162287 1fa9d7cf6d623552d4a4c86b374eaccd5c3354eb
parent 162286 d0aced80aa982bb0386cc4c47c39fe0a7c6baf40
child 162288 2c5fcba9480cbfcac8841d239596df9aed0b2a45
push idunknown
push userunknown
push dateunknown
reviewersjrmuizel
bugs950550
milestone29.0a1
Bug 950550. Restore the transform in DrawTargetCairo::PopClip. r=jrmuizel
gfx/2d/DrawTargetCairo.cpp
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -990,17 +990,28 @@ DrawTargetCairo::PushClipRect(const Rect
   cairo_rectangle(mContext, aRect.X(), aRect.Y(), aRect.Width(), aRect.Height());
   cairo_clip_preserve(mContext);
 }
 
 void
 DrawTargetCairo::PopClip()
 {
   // save/restore does not affect the path, so no need to call WillChange()
+
+  // cairo_restore will restore the transform too and we don't want to do that
+  // so we'll save it now and restore it after the cairo_restore
+  cairo_matrix_t mat;
+  cairo_get_matrix(mContext, &mat);
+
   cairo_restore(mContext);
+
+  cairo_set_matrix(mContext, &mat);
+
+  MOZ_ASSERT(GetTransform() == Matrix(mat.xx, mat.yx, mat.xy, mat.yy, mat.x0, mat.y0),
+             "Transforms are out of sync");
 }
 
 TemporaryRef<PathBuilder>
 DrawTargetCairo::CreatePathBuilder(FillRule aFillRule /* = FILL_WINDING */) const
 {
   RefPtr<PathBuilderCairo> builder = new PathBuilderCairo(aFillRule);
 
   return builder;