diff options
author | Vladimir Vukicevic <vladimir@pobox.com> | 2009-06-14 20:43:05 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-06-16 11:03:46 +0100 |
commit | 22587f57bd5d1b4440d936cd4655a7e8fcebdf36 (patch) | |
tree | f7f4224e598d8a23b1a643016c880b7c91d5ff84 /boilerplate | |
parent | 7d3881114add18d5934073d0b04755d343ea38c6 (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')
-rw-r--r-- | boilerplate/Makefile.sources | 3 | ||||
-rw-r--r-- | boilerplate/Makefile.win32.features | 10 | ||||
-rw-r--r-- | boilerplate/cairo-boilerplate-qt-private.h | 60 | ||||
-rw-r--r-- | boilerplate/cairo-boilerplate-qt.cpp | 90 | ||||
-rw-r--r-- | boilerplate/cairo-boilerplate.c | 23 | ||||
-rw-r--r-- | boilerplate/cairo-boilerplate.h | 3 |
6 files changed, 189 insertions, 0 deletions
diff --git a/boilerplate/Makefile.sources b/boilerplate/Makefile.sources index 1b82bbda..1cccedad 100644 --- a/boilerplate/Makefile.sources +++ b/boilerplate/Makefile.sources @@ -37,6 +37,9 @@ cairo_boilerplate_pdf_sources = cairo-boilerplate-pdf.c cairo_boilerplate_ps_private = cairo-boilerplate-ps-private.h cairo_boilerplate_ps_sources = cairo-boilerplate-ps.c +cairo_boilerplate_qt_private = cairo-boilerplate-qt-private.h +cairo_boilerplate_qt_sources = cairo-boilerplate-qt.cpp + cairo_boilerplate_quartz_private = cairo-boilerplate-quartz-private.h cairo_boilerplate_quartz_sources = cairo-boilerplate-quartz.c diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features index d6d50650..e80bf034 100644 --- a/boilerplate/Makefile.win32.features +++ b/boilerplate/Makefile.win32.features @@ -49,6 +49,16 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_xcb_private) enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_sources) endif +unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers) +all_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers) +all_cairo_boilerplate_private += $(cairo_boilerplate_qt_private) +all_cairo_boilerplate_sources += $(cairo_boilerplate_qt_sources) +ifeq ($(CAIRO_HAS_QT_SURFACE),1) +enabled_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers) +enabled_cairo_boilerplate_private += $(cairo_boilerplate_qt_private) +enabled_cairo_boilerplate_sources += $(cairo_boilerplate_qt_sources) +endif + supported_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_headers) all_cairo_boilerplate_headers += $(cairo_boilerplate_quartz_headers) all_cairo_boilerplate_private += $(cairo_boilerplate_quartz_private) diff --git a/boilerplate/cairo-boilerplate-qt-private.h b/boilerplate/cairo-boilerplate-qt-private.h new file mode 100644 index 00000000..4ac87642 --- /dev/null +++ b/boilerplate/cairo-boilerplate-qt-private.h @@ -0,0 +1,60 @@ +/* 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. + */ + +#ifndef CAIRO_BOILERPLATE_QT_PRIVATE_H +#define CAIRO_BOILERPLATE_QT_PRIVATE_H + +#include <cairo.h> + +CAIRO_BEGIN_DECLS + +extern 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); + +extern void +_cairo_boilerplate_qt_cleanup (void* closure); + +extern void +_cairo_boilerplate_qt_synchronize (void *closure); + +CAIRO_END_DECLS + +#endif /* CAIRO_BOILERPLATE_QT_PRIVATE_H */ + 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 */ +} diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c index 6da28228..11c0833c 100644 --- a/boilerplate/cairo-boilerplate.c +++ b/boilerplate/cairo-boilerplate.c @@ -44,6 +44,9 @@ #if CAIRO_HAS_PS_SURFACE #include "cairo-boilerplate-ps-private.h" #endif +#if CAIRO_HAS_QT_SURFACE +#include "cairo-boilerplate-qt-private.h" +#endif #if CAIRO_HAS_QUARTZ_SURFACE #include "cairo-boilerplate-quartz-private.h" #endif @@ -446,6 +449,26 @@ static const cairo_boilerplate_target_t targets[] = }, #endif #endif /* CAIRO_HAS_GLITZ_SURFACE */ +#if CAIRO_HAS_QT_SURFACE + { + "qt", "qt", NULL, + CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR_ALPHA, 0, + _cairo_boilerplate_qt_create_surface, NULL, + NULL, + _cairo_boilerplate_get_image_surface, + cairo_surface_write_to_png, + _cairo_boilerplate_qt_cleanup + }, + { + "qt", "qt", NULL, + CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR, 0, + _cairo_boilerplate_qt_create_surface, NULL, + NULL, + _cairo_boilerplate_get_image_surface, + cairo_surface_write_to_png, + _cairo_boilerplate_qt_cleanup + }, +#endif #if CAIRO_HAS_QUARTZ_SURFACE { "quartz", "quartz", NULL, diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h index a2763bbf..aa96ab7b 100644 --- a/boilerplate/cairo-boilerplate.h +++ b/boilerplate/cairo-boilerplate.h @@ -93,6 +93,7 @@ #define M_PI 3.14159265358979323846 #endif +CAIRO_BEGIN_DECLS /* A fake format we use for the flattened ARGB output of the PS and * PDF surfaces. */ @@ -210,4 +211,6 @@ cairo_boilerplate_version_string (void); #include "cairo-boilerplate-system.h" +CAIRO_END_DECLS + #endif |