static cairo_surface_t * _cairo_boilerplate_qt_create_surface (const char *name, cairo_content_t content, double width, double height, double max_width, double max_height, cairo_boilerplate_mode_t mode, void **closure) { qt_closure_t *qtc; qtc = (qt_closure_t *) xcalloc (1, sizeof (qt_closure_t)); qtc->dpy = XOpenDisplay (NULL); if (qtc->dpy == NULL) { free (qtc); return NULL; } if (mode == CAIRO_BOILERPLATE_MODE_TEST) XSynchronize (qtc->dpy, True); qtc->app = new QApplication (qtc->dpy); *closure = qtc; return cairo_qt_surface_create_with_qpixmap (content, width, height); }
gfxQPainterSurface::gfxQPainterSurface(const gfxIntSize& size, gfxContentType content) { cairo_surface_t *csurf = cairo_qt_surface_create_with_qpixmap ((cairo_content_t) content, size.width, size.height); mPainter = cairo_qt_surface_get_qpainter (csurf); Init (csurf); }
/** ** Surface backend methods **/ static cairo_surface_t * _cairo_qt_surface_create_similar (void *abstract_surface, cairo_content_t content, int width, int height) { cairo_qt_surface_t *qs = (cairo_qt_surface_t *) abstract_surface; bool use_pixmap; D(fprintf(stderr, "q[%p] create_similar: %d %d [%d] -> ", abstract_surface, width, height, content)); use_pixmap = qs->image == NULL; if (use_pixmap) { switch (content) { case CAIRO_CONTENT_ALPHA: use_pixmap = FALSE; break; case CAIRO_CONTENT_COLOR: break; case CAIRO_CONTENT_COLOR_ALPHA: use_pixmap = ! _qpixmaps_have_no_alpha; break; } } if (use_pixmap) { cairo_surface_t *result = cairo_qt_surface_create_with_qpixmap (content, width, height); /* XXX result->content is always content. ??? */ if (result->content == content) { D(fprintf(stderr, "qpixmap content: %d\n", content)); return result; } _qpixmaps_have_no_alpha = TRUE; cairo_surface_destroy (result); } D(fprintf (stderr, "qimage\n")); return cairo_qt_surface_create_with_qimage (_cairo_format_from_content (content), width, height); }