Bug 612662 patch 3: Drop cairo_quartz_surface_t's "imageSurfaceEquiv" member if we fail to create it. r=roc a=blocking-final+
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 19 Nov 2010 08:56:06 -0800
changeset 57901 eea80e8a690199843efd939ecf04189409cfbc21
parent 57900 cb7fca54ac45a658ca575f3979195b09a2b833cb
child 57902 d66f56009e9bc9031230555a9e8e9e1729fa65e8
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersroc, blocking-final
bugs612662
milestone2.0b8pre
Bug 612662 patch 3: Drop cairo_quartz_surface_t's "imageSurfaceEquiv" member if we fail to create it. r=roc a=blocking-final+
gfx/cairo/README
gfx/cairo/cairo/src/cairo-quartz-surface.c
gfx/cairo/quartz-check-imageSurfaceEquiv.patch
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -147,16 +147,18 @@ quartz-refactor-surface-setup.patch: Ext
 quartz-fix-PAD.patch: Treat PAD like NONE instead of REPEAT
 
 quartz-mask-non-OVER.patch: Don't use CGContextSetAlpha to optimize alpha masking for non-OVER operators
 
 quartz-layers-content.patch: Store cairo content type in CGLayer surfaces
 
 quartz-optimize-OVER.patch: Optimize OVER to SOURCE for opaque patterns
 
+quartz-check-imageSurfaceEquiv.patch: Drop cairo_quartz_surface_t's "imageSurfaceEquiv" member variable if we have problems creating it
+
 ==== pixman patches ====
 
 pixman-android-cpu-detect.patch: Add CPU detection support for Android, where we can't reliably access /proc/self/auxv.
 
 pixman-rename-and-endian.patch: include cairo-platform.h for renaming of external symbols and endian macros
 
 NOTE: we previously supported ARM assembler on MSVC, this has been removed because of the maintenance burden
 
--- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
@@ -3152,17 +3152,28 @@ cairo_quartz_surface_create (cairo_forma
     if (surf->base.status) {
 	CGContextRelease (cgc);
 	free (imageData);
 	// create_internal will have set an error
 	return (cairo_surface_t*) surf;
     }
 
     surf->imageData = imageData;
-    surf->imageSurfaceEquiv = cairo_image_surface_create_for_data (imageData, format, width, height, stride);
+
+    cairo_surface_t* tmpImageSurfaceEquiv =
+      cairo_image_surface_create_for_data (imageData, format,
+                                           width, height, stride);
+
+    if (cairo_surface_status (tmpImageSurfaceEquiv)) {
+        // Tried & failed to create an imageSurfaceEquiv!
+        cairo_surface_destroy (tmpImageSurfaceEquiv);
+        surf->imageSurfaceEquiv = NULL;
+    } else {
+        surf->imageSurfaceEquiv = tmpImageSurfaceEquiv;
+    }
 
     return (cairo_surface_t *) surf;
 }
 
 /**
  * cairo_quartz_surface_get_cg_context
  * @surface: the Cairo Quartz surface
  *
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/quartz-check-imageSurfaceEquiv.patch
@@ -0,0 +1,36 @@
+From: Daniel Holbert <dholbert@cs.stanford.edu>
+Bug 612662 patch 3: Drop cairo_quartz_surface_t's "imageSurfaceEquiv" member if we fail to create it. r=roc a=blocking-final+
+
+diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
+--- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
++++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
+@@ -3152,17 +3152,28 @@ cairo_quartz_surface_create (cairo_forma
+     if (surf->base.status) {
+ 	CGContextRelease (cgc);
+ 	free (imageData);
+ 	// create_internal will have set an error
+ 	return (cairo_surface_t*) surf;
+     }
+ 
+     surf->imageData = imageData;
+-    surf->imageSurfaceEquiv = cairo_image_surface_create_for_data (imageData, format, width, height, stride);
++
++    cairo_surface_t* tmpImageSurfaceEquiv =
++      cairo_image_surface_create_for_data (imageData, format,
++                                           width, height, stride);
++
++    if (cairo_surface_status (tmpImageSurfaceEquiv)) {
++        // Tried & failed to create an imageSurfaceEquiv!
++        cairo_surface_destroy (tmpImageSurfaceEquiv);
++        surf->imageSurfaceEquiv = NULL;
++    } else {
++        surf->imageSurfaceEquiv = tmpImageSurfaceEquiv;
++    }
+ 
+     return (cairo_surface_t *) surf;
+ }
+ 
+ /**
+  * cairo_quartz_surface_get_cg_context
+  * @surface: the Cairo Quartz surface
+  *