Bug 796418 - Check cairo matrix before drawing. r=joe
authorAnthony Jones <ajones@mozilla.com>
Wed, 24 Oct 2012 22:03:21 -0400
changeset 111450 678e0066c0e1b4a4f587fa2a409b7fc68f59d883
parent 111449 d8cf15921d0384b32debe19e1eb30f4c7c1e5a41
child 111451 b448aae5a5d4d6b6ba779a7b4ebfc200d8e35511
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersjoe
bugs796418
milestone19.0a1
Bug 796418 - Check cairo matrix before drawing. r=joe
gfx/2d/DrawTargetCairo.cpp
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -39,28 +39,39 @@ namespace {
 class AutoPrepareForDrawing
 {
 public:
   AutoPrepareForDrawing(DrawTargetCairo* dt, cairo_t* ctx)
     : mCtx(ctx)
   {
     dt->PrepareForDrawing(ctx);
     cairo_save(mCtx);
+    MOZ_ASSERT(cairo_status(mCtx) || dt->GetTransform() == GetTransform());
   }
 
   AutoPrepareForDrawing(DrawTargetCairo* dt, cairo_t* ctx, const Path* path)
     : mCtx(ctx)
   {
     dt->PrepareForDrawing(ctx, path);
     cairo_save(mCtx);
+    MOZ_ASSERT(cairo_status(mCtx) || dt->GetTransform() == GetTransform());
   }
 
   ~AutoPrepareForDrawing() { cairo_restore(mCtx); }
 
 private:
+#ifdef DEBUG
+  Matrix GetTransform()
+  {
+    cairo_matrix_t mat;
+    cairo_get_matrix(mCtx, &mat);
+    return Matrix(mat.xx, mat.yx, mat.xy, mat.yy, mat.x0, mat.y0);
+  }
+#endif
+
   cairo_t* mCtx;
 };
 
 } // end anonymous namespace
 
 static bool
 GetCairoSurfaceSize(cairo_surface_t* surface, IntSize& size)
 {
@@ -431,17 +442,17 @@ DrawTargetCairo::DrawSurfaceWithShadow(S
     blur.Blur();
   } else {
     blursurf = sourcesurf;
     surf = sourcesurf;
   }
 
   WillChange();
   ClearSurfaceForUnboundedSource(aOperator);
-  
+
   cairo_save(mContext);
   cairo_set_operator(mContext, GfxOpToCairoOp(aOperator));
   cairo_identity_matrix(mContext);
   cairo_translate(mContext, aDest.x, aDest.y);
 
   if (OperatorAffectsUncoveredAreas(aOperator) ||
       aOperator == OP_SOURCE){
     cairo_push_group(mContext);
@@ -765,17 +776,17 @@ DrawTargetCairo::CreateSourceSurfaceFrom
                                              const IntSize &aSize,
                                              int32_t aStride,
                                              SurfaceFormat aFormat) const
 {
   cairo_surface_t* surf = cairo_image_surface_create(GfxFormatToCairoFormat(aFormat),
                                                      aSize.width,
                                                      aSize.height);
   CopyDataToCairoSurface(surf, aData, aSize, aStride, BytesPerPixel(aFormat));
-    
+
   RefPtr<SourceSurfaceCairo> source_surf = new SourceSurfaceCairo(surf, aSize, aFormat);
   cairo_surface_destroy(surf);
 
   return source_surf;
 }
 
 TemporaryRef<SourceSurface>
 DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const