Bug 550673 - Fix glyphs rendering for cairo-qpainter-surface. r=jmuizelaar
authorOleg Romashin <romaxa@gmail.com>
Sat, 17 Jul 2010 09:52:35 +0300
changeset 47854 460e93847f2d862a75b6a03241f441bc7ee69035
parent 47853 6768c40a2c55f946ff4753c25c9415c46e696cf5
child 47855 95c013f6c9629cd1c353cb7373e021f3b8579b52
push id14448
push userromaxa@gmail.com
push dateSat, 17 Jul 2010 07:27:17 +0000
treeherdermozilla-central@460e93847f2d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar
bugs550673
milestone2.0b2pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 550673 - Fix glyphs rendering for cairo-qpainter-surface. r=jmuizelaar
gfx/cairo/README
gfx/cairo/cairo/src/cairo-qt-surface.cpp
gfx/cairo/cairo_qt_glyphs.patch
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -121,16 +121,18 @@ fix-ps-output.patch: PS: Add missing 'q'
 ensure-text-flushed.patch: PDF-operators: ensure text operations flushed before emitting clip (42b5cac7668625c9761113ff72b47af5cfd10377)
 
 fix-xcopyarea-with-clips.patch: 5d07307b691afccccbb15f773d5231669ba44f5a
 
 cairo-x-visual.patch: make valid visua for cairo_xlib_surface_create_with_xrender_format (55037bfb2454a671332d961e061c712ab5471580)
 
 win32-transparent-surface.patch: add API so we can create a win32 surface for an HDC and indicate the surface has an alpha channel
 
+cairo_qt_glyphs.patch: Drop X surface from Qt surface, add support for new qt glyphs api
+
 ==== 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-qt-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-qt-surface.cpp
@@ -38,41 +38,39 @@
 #define __STDC_LIMIT_MACROS
 
 #include "cairoint.h"
 #include "cairo-types-private.h"
 #include "cairo-clip-private.h"
 #include "cairo-surface-clipper-private.h"
 #include "cairo-region-private.h"
 
+#include "cairo-ft.h"
 #include "cairo-qt.h"
 
 #include <memory>
 
 #include <QtGui/QPainter>
 #include <QtGui/QPaintEngine>
 #include <QtGui/QPaintDevice>
 #include <QtGui/QImage>
 #include <QtGui/QPixmap>
 #include <QtGui/QBrush>
 #include <QtGui/QPen>
 #include <QtGui/QWidget>
 #include <QtGui/QX11Info>
-
-#if CAIRO_HAS_XLIB_XRENDER_SURFACE
-#include "cairo-xlib.h"
-#include "cairo-xlib-xrender.h"
-// I hate X
-#undef Status
-#undef CursorShape
-#undef Bool
-#endif
+#include <QtCore/QVarLengthArray>
 
 #include <sys/time.h>
 
+
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) || defined(QT_GLYPHS_API_BACKPORT)
+extern void qt_draw_glyphs(QPainter *, const quint32 *glyphs, const QPointF *positions, int count);
+#endif
+
 /* Enable workaround slow regional Qt paths */
 #define ENABLE_FAST_FILL 0
 #define ENABLE_FAST_CLIP 0
 
 #if 0
 #define D(x)  x
 static const char *
 _opstr (cairo_operator_t op)
@@ -111,25 +109,16 @@ static const char *
 #define DOT_LENGTH  1.0
 #define DASH_LENGTH 3.0
 
 struct cairo_qt_surface_t {
     cairo_surface_t base;
 
     cairo_bool_t supports_porter_duff;
 
-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-    /* temporary, so that we can share the xlib surface's glyphs code */
-    bool xlib_has_clipping;
-    cairo_surface_t *xlib_equiv;
-    QRect xlib_clip_bounds;
-    int xlib_clip_serial;
-    QPoint redir_offset;
-#endif
-
     QPainter *p;
 
     /* The pixmap/image constructors will store their objects here */
     QPixmap *pixmap;
     QImage *image;
 
     QRect window;
 
@@ -138,21 +127,16 @@ struct cairo_qt_surface_t {
     cairo_surface_t *image_equiv;
 };
 
 /* Will be true if we ever try to create a QPixmap and end
  * up with one without an alpha channel.
  */
 static cairo_bool_t _qpixmaps_have_no_alpha = FALSE;
 
-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-slim_hidden_proto (cairo_xlib_surface_create);
-slim_hidden_proto (cairo_xlib_surface_create_with_xrender_format);
-#endif
-
 /**
  ** Helper methods
  **/
 
 static QPainter::CompositionMode
 _qpainter_compositionmode_from_cairo_op (cairo_operator_t op)
 {
     switch (op) {
@@ -488,21 +472,16 @@ static cairo_status_t
     else
 	qs->p->restore ();
 
     if (qs->image_equiv)
         cairo_surface_destroy (qs->image_equiv);
 
     _cairo_surface_clipper_reset (&qs->clipper);
 
-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-    if (qs->xlib_equiv)
-        cairo_surface_destroy (qs->xlib_equiv);
-#endif
-
     if (qs->image)
         delete qs->image;
 
     if (qs->pixmap)
         delete qs->pixmap;
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -1382,43 +1361,50 @@ static cairo_int_status_t
 			       cairo_operator_t op,
 			       const cairo_pattern_t *source,
 			       cairo_glyph_t *glyphs,
 			       int num_glyphs,
 			       cairo_scaled_font_t *scaled_font,
 			       cairo_clip_t *clip,
 			       int *remaining_glyphs)
 {
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) || defined(QT_GLYPHS_API_BACKPORT)
     cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
 
-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-    /* If we have an equivalent X surface, let the xlib surface handle this
-     * until we figure out how to do this natively with Qt.
-     */
-    if (qs->xlib_equiv) {
-	D(fprintf(stderr, "q[%p] show_glyphs (x11 equiv) op:%s nglyphs: %d\n", abstract_surface, _opstr(op), num_glyphs));
-
-	for (int i = 0; i < num_glyphs; i++) {
-	    glyphs[i].x -= qs->redir_offset.x();
-	    glyphs[i].y -= qs->redir_offset.y();
-	}
+    // pick out the colour to use from the cairo source
+    cairo_solid_pattern_t *solid = (cairo_solid_pattern_t*) source;
+    cairo_scaled_glyph_t* glyph;
+    // documentation says you have to freeze the cache, but I don't believe it
+    _cairo_scaled_font_freeze_cache(scaled_font);
 
-        return (cairo_int_status_t)
-               _cairo_surface_show_text_glyphs (qs->xlib_equiv,
-						op, source,
-						NULL, 0,
-						glyphs, num_glyphs,
-						NULL, 0,
-						(cairo_text_cluster_flags_t) 0,
-						scaled_font,
-						clip);
+    QColor tempColour(solid->color.red * 255, solid->color.green * 255, solid->color.blue * 255);
+    QVarLengthArray<QPointF> positions(num_glyphs);
+    QVarLengthArray<unsigned int> glyphss(num_glyphs);
+    FT_Face face = cairo_ft_scaled_font_lock_face (scaled_font);
+    const FT_Size_Metrics& ftMetrics = face->size->metrics;
+    QFont font(face->family_name);
+    font.setStyleStrategy(QFont::NoFontMerging);
+    font.setBold(face->style_flags & FT_STYLE_FLAG_BOLD);
+    font.setItalic(face->style_flags & FT_STYLE_FLAG_ITALIC);
+    font.setKerning(face->face_flags & FT_FACE_FLAG_KERNING);
+    font.setPixelSize(ftMetrics.y_ppem);
+    cairo_ft_scaled_font_unlock_face(scaled_font);
+    qs->p->setFont(font);
+    qs->p->setPen(tempColour);
+    for (int currentGlyph = 0; currentGlyph < num_glyphs; currentGlyph++) {
+        positions[currentGlyph].setX(glyphs[currentGlyph].x);
+        positions[currentGlyph].setY(glyphs[currentGlyph].y);
+        glyphss[currentGlyph] = glyphs[currentGlyph].index;
     }
+    qt_draw_glyphs(qs->p, glyphss.data(), positions.data(), num_glyphs);
+    _cairo_scaled_font_thaw_cache(scaled_font);
+    return CAIRO_INT_STATUS_SUCCESS;
+#else
+    return CAIRO_INT_STATUS_UNSUPPORTED;
 #endif
-
-    return CAIRO_INT_STATUS_UNSUPPORTED;
 }
 
 static cairo_int_status_t
 _cairo_qt_surface_mask (void *abstract_surface,
 			cairo_operator_t op,
 			const cairo_pattern_t *source,
 			const cairo_pattern_t *mask,
 			cairo_clip_t	    *clip)
@@ -1545,34 +1531,16 @@ static cairo_int_status_t
     } else {
         return CAIRO_INT_STATUS_UNSUPPORTED;
     }
 
     return CAIRO_INT_STATUS_SUCCESS;
 }
 
 static cairo_status_t
-_cairo_qt_surface_flush (void *abstract_surface)
-{
-    cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
-
-    if (qs->p == NULL)
-	return CAIRO_STATUS_SUCCESS;
-
-    if (qs->image || qs->pixmap) {
-	qs->p->end ();
-	qs->p->begin (qs->p->device ());
-    } else {
-	qs->p->restore ();
-    }
-
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_status_t
 _cairo_qt_surface_mark_dirty (void *abstract_surface,
 			      int x, int y,
 			      int width, int height)
 {
     cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
 
     if (qs->p && !(qs->image || qs->pixmap))
 	qs->p->save ();
@@ -1599,17 +1567,17 @@ static const cairo_surface_backend_t cai
     NULL, /* composite_trapezoids */
     NULL, /* create_span_renderer */
     NULL, /* check_span_renderer */
     NULL, /* copy_page */
     NULL, /* show_page */
     _cairo_qt_surface_get_extents,
     NULL, /* old_show_glyphs */
     NULL, /* get_font_options */
-    _cairo_qt_surface_flush,
+    NULL, /* flush */
     _cairo_qt_surface_mark_dirty,
     NULL, /* scaled_font_fini */
     NULL, /* scaled_glyph_fini */
 
     _cairo_qt_surface_paint,
     _cairo_qt_surface_mask,
     _cairo_qt_surface_stroke,
     _cairo_qt_surface_fill,
@@ -1619,74 +1587,16 @@ static const cairo_surface_backend_t cai
     NULL, /* is_similar */
     NULL, /* fill_stroke */
     NULL, /* create_solid_pattern_surface */
     NULL, /* can_repaint_solid_pattern_surface */
     NULL, /* has_show_text_glyphs */
     NULL, /* show_text_glyphs */
 };
 
-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-static cairo_surface_t *
-_cairo_qt_create_xlib_surface (cairo_qt_surface_t *qs)
-{
-    if (!qs->p)
-	return NULL;
-
-    QPaintDevice *pd = qs->p->device();
-    if (!pd)
-	return NULL;
-
-    QPoint offs;
-    QPaintDevice *rpd = QPainter::redirected(pd, &offs);
-    if (rpd) {
-	pd = rpd;
-	qs->redir_offset = offs;
-    }
-
-    if (pd->devType() == QInternal::Widget) {
-	QWidget *w = (QWidget*) pd;
-	QX11Info xinfo = w->x11Info();
-
-	return cairo_xlib_surface_create (xinfo.display(),
-					  (Drawable) w->handle (),
-					  (Visual *) xinfo.visual (),
-					  w->width (), w->height ());
-    } else if (pd->devType() == QInternal::Pixmap) {
-	QPixmap *pixmap = (QPixmap*) pd;
-	QX11Info xinfo = pixmap->x11Info ();
-	XRenderPictFormat *xrender_format;
-	int pict_format;
-
-	switch (pixmap->depth ()) {
-	case 1:
-	    pict_format = PictStandardA1; break;
-	case 8:
-	    pict_format = PictStandardA8; break;
-	case 24:
-	    pict_format = PictStandardRGB24; break;
-	default:
-	    ASSERT_NOT_REACHED;
-	case 32:
-	    pict_format = PictStandardARGB32; break;
-	}
-	xrender_format = XRenderFindStandardFormat (xinfo.display (),
-		                                    pict_format);
-
-	return cairo_xlib_surface_create_with_xrender_format (xinfo.display(),
-					  (Drawable) pixmap->handle (),
-					  ScreenOfDisplay (xinfo.display (),
-							   xinfo.screen ()),
-					  xrender_format,
-					  pixmap->width (), pixmap->height ());
-    } else
-	return NULL;
-}
-#endif
-
 cairo_surface_t *
 cairo_qt_surface_create (QPainter *painter)
 {
     cairo_qt_surface_t *qs;
 
     qs = (cairo_qt_surface_t *) malloc (sizeof(cairo_qt_surface_t));
     if (qs == NULL)
         return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -1706,20 +1616,16 @@ cairo_qt_surface_create (QPainter *paint
     else
         qs->supports_porter_duff = FALSE;
 
     // Save so that we can always get back to the original state
     qs->p->save();
 
     qs->window = painter->window();
 
-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-    qs->xlib_equiv = _cairo_qt_create_xlib_surface (qs);
-#endif
-
     D(fprintf(stderr, "qpainter_surface_create: window: [%d %d %d %d] pd:%d\n",
               qs->window.x(), qs->window.y(), qs->window.width(), qs->window.height(),
               qs->supports_porter_duff));
 
     return &qs->base;
 }
 
 cairo_surface_t *
@@ -1804,20 +1710,16 @@ cairo_qt_surface_create_with_qpixmap (ca
 
     if (!pixmap->isNull()) {
         qs->p = new QPainter(pixmap);
         qs->supports_porter_duff = qs->p->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
     }
 
     qs->window = QRect(0, 0, width, height);
 
-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
-    qs->xlib_equiv = _cairo_qt_create_xlib_surface (qs);
-#endif
-
     D(fprintf(stderr, "qpainter_surface_create: qpixmap: [%d %d %d %d] pd:%d\n",
               qs->window.x(), qs->window.y(), qs->window.width(), qs->window.height(),
               qs->supports_porter_duff));
 
     return &qs->base;
 }
 
 QPainter *
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/cairo_qt_glyphs.patch
@@ -0,0 +1,256 @@
+Bug 29092 - Fix glyphs rendering for cairo-qpainter-surface
+diff --git a/src/cairo-qt-surface.cpp b/src/cairo-qt-surface.cpp
+index 2ac06ef..5b61b42 100644
+--- a/src/cairo-qt-surface.cpp
++++ b/src/cairo-qt-surface.cpp
+@@ -45,6 +45,7 @@
+ #include "cairo-surface-clipper-private.h"
+ #include "cairo-types-private.h"
+ 
++#include "cairo-ft.h"
+ #include "cairo-qt.h"
+ 
+ #include <memory>
+@@ -58,14 +59,10 @@
+ #include <QtGui/QPen>
+ #include <QtGui/QWidget>
+ #include <QtGui/QX11Info>
++#include <QtCore/QVarLengthArray>
+ 
+-#if CAIRO_HAS_XLIB_XRENDER_SURFACE
+-#include "cairo-xlib.h"
+-#include "cairo-xlib-xrender.h"
+-// I hate X
+-#undef Status
+-#undef CursorShape
+-#undef Bool
++#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) || defined(QT_GLYPHS_API_BACKPORT)
++extern void qt_draw_glyphs(QPainter *, const quint32 *glyphs, const QPointF *positions, int count);
+ #endif
+ 
+ #include <sys/time.h>
+@@ -118,15 +115,6 @@ struct cairo_qt_surface_t {
+ 
+     cairo_bool_t supports_porter_duff;
+ 
+-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
+-    /* temporary, so that we can share the xlib surface's glyphs code */
+-    bool xlib_has_clipping;
+-    cairo_surface_t *xlib_equiv;
+-    QRect xlib_clip_bounds;
+-    int xlib_clip_serial;
+-    QPoint redir_offset;
+-#endif
+-
+     QPainter *p;
+ 
+     /* The pixmap/image constructors will store their objects here */
+@@ -145,11 +133,6 @@ struct cairo_qt_surface_t {
+  */
+ static cairo_bool_t _qpixmaps_have_no_alpha = FALSE;
+ 
+-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
+-slim_hidden_proto (cairo_xlib_surface_create);
+-slim_hidden_proto (cairo_xlib_surface_create_with_xrender_format);
+-#endif
+-
+ /**
+  ** Helper methods
+  **/
+@@ -498,11 +481,6 @@ _cairo_qt_surface_finish (void *abstract_surface)
+ 
+     _cairo_surface_clipper_reset (&qs->clipper);
+ 
+-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
+-    if (qs->xlib_equiv)
+-        cairo_surface_destroy (qs->xlib_equiv);
+-#endif
+-
+     if (qs->image)
+         delete qs->image;
+ 
+@@ -1392,33 +1370,40 @@ _cairo_qt_surface_show_glyphs (void *abstract_surface,
+ 			       cairo_clip_t *clip,
+ 			       int *remaining_glyphs)
+ {
++#if (QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)) || defined(QT_GLYPHS_API_BACKPORT)
+     cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
+ 
+-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
+-    /* If we have an equivalent X surface, let the xlib surface handle this
+-     * until we figure out how to do this natively with Qt.
+-     */
+-    if (qs->xlib_equiv) {
+-	D(fprintf(stderr, "q[%p] show_glyphs (x11 equiv) op:%s nglyphs: %d\n", abstract_surface, _opstr(op), num_glyphs));
+-
+-	for (int i = 0; i < num_glyphs; i++) {
+-	    glyphs[i].x -= qs->redir_offset.x();
+-	    glyphs[i].y -= qs->redir_offset.y();
+-	}
+-
+-        return (cairo_int_status_t)
+-               _cairo_surface_show_text_glyphs (qs->xlib_equiv,
+-						op, source,
+-						NULL, 0,
+-						glyphs, num_glyphs,
+-						NULL, 0,
+-						(cairo_text_cluster_flags_t) 0,
+-						scaled_font,
+-						clip);
++    // pick out the colour to use from the cairo source
++    cairo_solid_pattern_t *solid = (cairo_solid_pattern_t*) source;
++    cairo_scaled_glyph_t* glyph;
++    // documentation says you have to freeze the cache, but I don't believe it
++    _cairo_scaled_font_freeze_cache(scaled_font);
++
++    QColor tempColour(solid->color.red * 255, solid->color.green * 255, solid->color.blue * 255);
++    QVarLengthArray<QPointF> positions(num_glyphs);
++    QVarLengthArray<unsigned int> glyphss(num_glyphs);
++    FT_Face face = cairo_ft_scaled_font_lock_face (scaled_font);
++    const FT_Size_Metrics& ftMetrics = face->size->metrics;
++    QFont font(face->family_name);
++    font.setStyleStrategy(QFont::NoFontMerging);
++    font.setBold(face->style_flags & FT_STYLE_FLAG_BOLD);
++    font.setItalic(face->style_flags & FT_STYLE_FLAG_ITALIC);
++    font.setKerning(face->face_flags & FT_FACE_FLAG_KERNING);
++    font.setPixelSize(ftMetrics.y_ppem);
++    cairo_ft_scaled_font_unlock_face(scaled_font);
++    qs->p->setFont(font);
++    qs->p->setPen(tempColour);
++    for (int currentGlyph = 0; currentGlyph < num_glyphs; currentGlyph++) {
++        positions[currentGlyph].setX(glyphs[currentGlyph].x);
++        positions[currentGlyph].setY(glyphs[currentGlyph].y);
++        glyphss[currentGlyph] = glyphs[currentGlyph].index;
+     }
+-#endif
+-
++    qt_draw_glyphs(qs->p, glyphss.data(), positions.data(), num_glyphs);
++    _cairo_scaled_font_thaw_cache(scaled_font);
++    return CAIRO_INT_STATUS_SUCCESS;
++#else
+     return CAIRO_INT_STATUS_UNSUPPORTED;
++#endif
+ }
+ 
+ static cairo_int_status_t
+@@ -1555,24 +1540,6 @@ _cairo_qt_surface_composite (cairo_operator_t op,
+ }
+ 
+ static cairo_status_t
+-_cairo_qt_surface_flush (void *abstract_surface)
+-{
+-    cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface;
+-
+-    if (qs->p == NULL)
+-	return CAIRO_STATUS_SUCCESS;
+-
+-    if (qs->image || qs->pixmap) {
+-	qs->p->end ();
+-	qs->p->begin (qs->p->device ());
+-    } else {
+-	qs->p->restore ();
+-    }
+-
+-    return CAIRO_STATUS_SUCCESS;
+-}
+-
+-static cairo_status_t
+ _cairo_qt_surface_mark_dirty (void *abstract_surface,
+ 			      int x, int y,
+ 			      int width, int height)
+@@ -1609,7 +1576,7 @@ static const cairo_surface_backend_t cairo_qt_surface_backend = {
+     _cairo_qt_surface_get_extents,
+     NULL, /* old_show_glyphs */
+     NULL, /* get_font_options */
+-    _cairo_qt_surface_flush,
++    NULL, /* flush */
+     _cairo_qt_surface_mark_dirty,
+     NULL, /* scaled_font_fini */
+     NULL, /* scaled_glyph_fini */
+@@ -1629,64 +1596,6 @@ static const cairo_surface_backend_t cairo_qt_surface_backend = {
+     NULL, /* show_text_glyphs */
+ };
+ 
+-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
+-static cairo_surface_t *
+-_cairo_qt_create_xlib_surface (cairo_qt_surface_t *qs)
+-{
+-    if (!qs->p)
+-	return NULL;
+-
+-    QPaintDevice *pd = qs->p->device();
+-    if (!pd)
+-	return NULL;
+-
+-    QPoint offs;
+-    QPaintDevice *rpd = QPainter::redirected(pd, &offs);
+-    if (rpd) {
+-	pd = rpd;
+-	qs->redir_offset = offs;
+-    }
+-
+-    if (pd->devType() == QInternal::Widget) {
+-	QWidget *w = (QWidget*) pd;
+-	QX11Info xinfo = w->x11Info();
+-
+-	return cairo_xlib_surface_create (xinfo.display(),
+-					  (Drawable) w->handle (),
+-					  (Visual *) xinfo.visual (),
+-					  w->width (), w->height ());
+-    } else if (pd->devType() == QInternal::Pixmap) {
+-	QPixmap *pixmap = (QPixmap*) pd;
+-	QX11Info xinfo = pixmap->x11Info ();
+-	XRenderPictFormat *xrender_format;
+-	int pict_format;
+-
+-	switch (pixmap->depth ()) {
+-	case 1:
+-	    pict_format = PictStandardA1; break;
+-	case 8:
+-	    pict_format = PictStandardA8; break;
+-	case 24:
+-	    pict_format = PictStandardRGB24; break;
+-	default:
+-	    ASSERT_NOT_REACHED;
+-	case 32:
+-	    pict_format = PictStandardARGB32; break;
+-	}
+-	xrender_format = XRenderFindStandardFormat (xinfo.display (),
+-		                                    pict_format);
+-
+-	return cairo_xlib_surface_create_with_xrender_format (xinfo.display(),
+-					  (Drawable) pixmap->handle (),
+-					  ScreenOfDisplay (xinfo.display (),
+-							   xinfo.screen ()),
+-					  xrender_format,
+-					  pixmap->width (), pixmap->height ());
+-    } else
+-	return NULL;
+-}
+-#endif
+-
+ cairo_surface_t *
+ cairo_qt_surface_create (QPainter *painter)
+ {
+@@ -1717,10 +1626,6 @@ cairo_qt_surface_create (QPainter *painter)
+ 
+     qs->window = painter->window();
+ 
+-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
+-    qs->xlib_equiv = _cairo_qt_create_xlib_surface (qs);
+-#endif
+-
+     D(fprintf(stderr, "qpainter_surface_create: window: [%d %d %d %d] pd:%d\n",
+               qs->window.x(), qs->window.y(), qs->window.width(), qs->window.height(),
+               qs->supports_porter_duff));
+@@ -1819,10 +1724,6 @@ cairo_qt_surface_create_with_qpixmap (cairo_content_t content,
+ 
+     qs->window = QRect(0, 0, width, height);
+ 
+-#if defined(Q_WS_X11) && CAIRO_HAS_XLIB_XRENDER_SURFACE
+-    qs->xlib_equiv = _cairo_qt_create_xlib_surface (qs);
+-#endif
+-
+     D(fprintf(stderr, "qpainter_surface_create: qpixmap: [%d %d %d %d] pd:%d\n",
+               qs->window.x(), qs->window.y(), qs->window.width(), qs->window.height(),
+               qs->supports_porter_duff));