1 /* Cairo - a vector graphics library with display and print output
3 * Copyright © 2009 Chris Wilson
5 * This library is free software; you can redistribute it and/or
6 * modify it either under the terms of the GNU Lesser General Public
7 * License version 2.1 as published by the Free Software Foundation
8 * (the "LGPL") or, at your option, under the terms of the Mozilla
9 * Public License Version 1.1 (the "MPL"). If you do not alter this
10 * notice, a recipient may use your version of this file under either
11 * the MPL or the LGPL.
13 * You should have received a copy of the LGPL along with this library
14 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License at
22 * http://www.mozilla.org/MPL/
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26 * the specific language governing rights and limitations.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is Chris Wilson.
33 #include "cairo-boilerplate-private.h"
37 #include <qapplication.h>
40 typedef struct _qt_closure {
46 _cairo_boilerplate_qt_cleanup (void *closure)
48 qt_closure_t *qtc = (qt_closure_t *) closure;
51 XCloseDisplay (qtc->dpy);
55 static cairo_surface_t *
56 _cairo_boilerplate_qt_create_surface (const char *name,
57 cairo_content_t content,
62 cairo_boilerplate_mode_t mode,
67 qtc = (qt_closure_t *) xcalloc (1, sizeof (qt_closure_t));
68 qtc->dpy = XOpenDisplay (NULL);
69 if (qtc->dpy == NULL) {
74 if (mode == CAIRO_BOILERPLATE_MODE_TEST)
75 XSynchronize (qtc->dpy, True);
77 qtc->app = new QApplication (qtc->dpy);
79 return cairo_qt_surface_create_with_qpixmap (content, width, height);
83 _cairo_boilerplate_qt_synchronize (void *closure)
85 qt_closure_t *qtc = (qt_closure_t *) closure;
87 qtc->app->flush (); /* not sure if this is sufficient */
90 static const cairo_boilerplate_target_t targets[] = {
92 "qt", "qt", NULL, NULL,
93 CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR_ALPHA, 0,
94 "cairo_qt_surface_create",
95 _cairo_boilerplate_qt_create_surface,
97 _cairo_boilerplate_get_image_surface,
98 cairo_surface_write_to_png,
99 _cairo_boilerplate_qt_cleanup
102 "qt", "qt", NULL, NULL,
103 CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR, 0,
104 "cairo_qt_surface_create",
105 _cairo_boilerplate_qt_create_surface,
107 _cairo_boilerplate_get_image_surface,
108 cairo_surface_write_to_png,
109 _cairo_boilerplate_qt_cleanup
113 CAIRO_BOILERPLATE (qt, targets)