summaryrefslogtreecommitdiff
path: root/boilerplate/cairo-boilerplate-qt.cpp
diff options
context:
space:
mode:
authorVladimir Vukicevic <vladimir@pobox.com>2009-06-14 20:43:05 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-06-16 11:03:46 +0100
commit22587f57bd5d1b4440d936cd4655a7e8fcebdf36 (patch)
treef7f4224e598d8a23b1a643016c880b7c91d5ff84 /boilerplate/cairo-boilerplate-qt.cpp
parent7d3881114add18d5934073d0b04755d343ea38c6 (diff)
Import Qt backend by Mozilla
Written by Vladimir Vukicevic to enable integration with Qt embedded devices, this backend allows cairo code to target QPainter, and use it as a source for other cairo backends. This imports the sources from mozilla-central: http://mxr.mozilla.org/mozilla-central/find?text=&kind=text&string=cairo-qpainter renames them from cairo-qpainter to cairo-qt, and integrates the patch by Oleg Romashin: https://bugs.freedesktop.org/attachment.cgi?id=18953 And then attempts to restore 'make check' to full functionality. However: - C++ does not play well with the PLT symbol hiding, and leaks into the global namespace. 'make check' fails at check-plt.sh - Qt embeds a GUI into QApplication which it requires to construct any QPainter drawable, i.e. used by the boilerplate to create a cairo-qt surface, and this leaks fonts (cairo-ft-fonts no less) causing assertion failures that all cairo objects are accounted for upon destruction. [Updated by Chris Wilson] Acked-by: Jeff Muizelaar <jeff@infidigm.net> Acked-by: Carl Worth <cworth@cworth.org>
Diffstat (limited to 'boilerplate/cairo-boilerplate-qt.cpp')
-rw-r--r--boilerplate/cairo-boilerplate-qt.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/boilerplate/cairo-boilerplate-qt.cpp b/boilerplate/cairo-boilerplate-qt.cpp
new file mode 100644
index 00000000..0e0aa7db
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-qt.cpp
@@ -0,0 +1,90 @@
+/* Cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2009 Chris Wilson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is Chris Wilson.
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-qt-private.h"
+
+#include <cairo-qt.h>
+
+#include <qapplication.h>
+#include <X11/Xlib.h>
+
+typedef struct _qt_closure {
+ Display *dpy;
+ QApplication *app;
+} qt_closure_t;
+
+void
+_cairo_boilerplate_qt_cleanup (void *closure)
+{
+ qt_closure_t *qtc = (qt_closure_t *) closure;
+
+ delete qtc->app;
+ XCloseDisplay (qtc->dpy);
+ free (qtc);
+}
+
+cairo_surface_t *
+_cairo_boilerplate_qt_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ int max_width,
+ int max_height,
+ cairo_boilerplate_mode_t mode,
+ int id,
+ 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);
+}
+
+void
+_cairo_boilerplate_qt_synchronize (void *closure)
+{
+ qt_closure_t *qtc = (qt_closure_t *) closure;
+
+ qtc->app->flush (); /* not sure if this is sufficient */
+}