Bug 602171 - CAIRO_FORMAT_A8 not allowed for cairo-qt image backend r=jmuizelaar a=npodb
authorOleg Romashin <romaxa@gmail.com>
Sat, 04 Dec 2010 00:04:47 +0200
changeset 58578 bb9d8fb1805feca56f48d846376c65b7d28d99ee
parent 58577 cb897c736451fafe99bb7165df81c0119fedbb2f
child 58579 566832c6b2845b2c54c12c940ce871d7a3d2ea32
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersjmuizelaar, npodb
bugs602171
milestone2.0b8pre
Bug 602171 - CAIRO_FORMAT_A8 not allowed for cairo-qt image backend r=jmuizelaar a=npodb
gfx/cairo/cairo/src/cairo-qt-surface.cpp
gfx/cairo/cairo_qt_a8_fallback.diff
--- a/gfx/cairo/cairo/src/cairo-qt-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-qt-surface.cpp
@@ -459,17 +459,17 @@ static cairo_status_t
 {
     cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
 
     D(fprintf(stderr, "q[%p] finish\n", abstract_surface));
 
     /* Only delete p if we created it */
     if (qs->image || qs->pixmap)
         delete qs->p;
-    else
+    else if (qs->p)
 	qs->p->restore ();
 
     if (qs->image_equiv)
         cairo_surface_destroy (qs->image_equiv);
 
     _cairo_surface_clipper_reset (&qs->clipper);
 
     if (qs->image)
@@ -736,17 +736,17 @@ static void
 }
 
 static cairo_int_status_t
 _cairo_qt_surface_set_clip (cairo_qt_surface_t *qs,
 			    cairo_clip_t *clip)
 {
     cairo_int_status_t status;
 
-    D(fprintf(stderr, "q[%p] intersect_clip_path %s\n", abstract_surface, path ? "(path)" : "(clear)"));
+    D(fprintf(stderr, "q[%p] intersect_clip_path %s\n", qs, clip ? "(path)" : "(clear)"));
 
     if (clip == NULL) {
 	_cairo_surface_clipper_reset (&qs->clipper);
         // How the clip path is reset depends on whether we own p or not
         if (qs->pixmap || qs->image) {
             // we own p
             qs->p->setClipping (false);
         } else {
@@ -1605,16 +1605,25 @@ cairo_qt_surface_create_with_qimage (cai
 
     _cairo_surface_init (&qs->base,
 			 &cairo_qt_surface_backend,
 			 _cairo_content_from_format (format));
 
     _cairo_surface_clipper_init (&qs->clipper,
 				 _cairo_qt_surface_clipper_intersect_clip_path);
 
+    if (CAIRO_FORMAT_A8 == format) {
+        qs->image = NULL;
+        qs->image_equiv = cairo_image_surface_create(format,
+                                                     width, height);
+        qs->p = NULL;
+        qs->supports_porter_duff = false;
+        qs->window = QRect(0, 0, width, height);
+        return &qs->base;
+    }
 
     QImage *image = new QImage (width, height,
 				_qimage_format_from_cairo_format (format));
 
     qs->image = image;
 
     if (!image->isNull()) {
         qs->p = new QPainter(image);
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/cairo_qt_a8_fallback.diff
@@ -0,0 +1,68 @@
+CAIRO_FORMAT_A8 not allowed for cairo-qt image backend
+diff --git a/gfx/cairo/cairo/src/cairo-qt-surface.cpp b/gfx/cairo/cairo/src/cairo-qt-surface.cpp
+--- a/gfx/cairo/cairo/src/cairo-qt-surface.cpp
++++ b/gfx/cairo/cairo/src/cairo-qt-surface.cpp
+@@ -459,17 +459,17 @@ _cairo_qt_surface_finish (void *abstract
+ {
+     cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
+ 
+     D(fprintf(stderr, "q[%p] finish\n", abstract_surface));
+ 
+     /* Only delete p if we created it */
+     if (qs->image || qs->pixmap)
+         delete qs->p;
+-    else
++    else if (qs->p)
+ 	qs->p->restore ();
+ 
+     if (qs->image_equiv)
+         cairo_surface_destroy (qs->image_equiv);
+ 
+     _cairo_surface_clipper_reset (&qs->clipper);
+ 
+     if (qs->image)
+@@ -736,17 +736,17 @@ _cairo_qt_surface_set_clip_region (cairo
+ }
+ 
+ static cairo_int_status_t
+ _cairo_qt_surface_set_clip (cairo_qt_surface_t *qs,
+ 			    cairo_clip_t *clip)
+ {
+     cairo_int_status_t status;
+ 
+-    D(fprintf(stderr, "q[%p] intersect_clip_path %s\n", abstract_surface, path ? "(path)" : "(clear)"));
++    D(fprintf(stderr, "q[%p] intersect_clip_path %s\n", qs, clip ? "(path)" : "(clear)"));
+ 
+     if (clip == NULL) {
+ 	_cairo_surface_clipper_reset (&qs->clipper);
+         // How the clip path is reset depends on whether we own p or not
+         if (qs->pixmap || qs->image) {
+             // we own p
+             qs->p->setClipping (false);
+         } else {
+@@ -1605,16 +1605,25 @@ cairo_qt_surface_create_with_qimage (cai
+ 
+     _cairo_surface_init (&qs->base,
+ 			 &cairo_qt_surface_backend,
+ 			 _cairo_content_from_format (format));
+ 
+     _cairo_surface_clipper_init (&qs->clipper,
+ 				 _cairo_qt_surface_clipper_intersect_clip_path);
+ 
++    if (CAIRO_FORMAT_A8 == format) {
++        qs->image = NULL;
++        qs->image_equiv = cairo_image_surface_create(format,
++                                                     width, height);
++        qs->p = NULL;
++        qs->supports_porter_duff = false;
++        qs->window = QRect(0, 0, width, height);
++        return &qs->base;
++    }
+ 
+     QImage *image = new QImage (width, height,
+ 				_qimage_format_from_cairo_format (format));
+ 
+     qs->image = image;
+ 
+     if (!image->isNull()) {
+         qs->p = new QPainter(image);