From 88cb69b10c66751f687c3745c8e9861b105de3a2 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 4 Jul 2009 21:43:27 +0100 Subject: [boilerpate] Move target definition to backends. By moving the backend target definition out of the massive amlagamated block in cairo-boilerplate.c and into each of the cairo-boilerplate-backend.c, we make it much easier to add new targets as the information need only be entered in a single file and not scattered across three. However, updating the target interface means trawling across all the files -- except given that I found it difficult maintaining the single massive array I do not see this as an increase in the maintenance burden. --- boilerplate/cairo-boilerplate-qt.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'boilerplate/cairo-boilerplate-qt.cpp') diff --git a/boilerplate/cairo-boilerplate-qt.cpp b/boilerplate/cairo-boilerplate-qt.cpp index addcb12e..5d8d3f93 100644 --- a/boilerplate/cairo-boilerplate-qt.cpp +++ b/boilerplate/cairo-boilerplate-qt.cpp @@ -31,7 +31,6 @@ */ #include "cairo-boilerplate.h" -#include "cairo-boilerplate-qt-private.h" #include @@ -43,7 +42,7 @@ typedef struct _qt_closure { QApplication *app; } qt_closure_t; -void +static void _cairo_boilerplate_qt_cleanup (void *closure) { qt_closure_t *qtc = (qt_closure_t *) closure; @@ -53,7 +52,7 @@ _cairo_boilerplate_qt_cleanup (void *closure) free (qtc); } -cairo_surface_t * +static cairo_surface_t * _cairo_boilerplate_qt_create_surface (const char *name, cairo_content_t content, double width, @@ -81,10 +80,32 @@ _cairo_boilerplate_qt_create_surface (const char *name, return cairo_qt_surface_create_with_qpixmap (content, width, height); } -void +static void _cairo_boilerplate_qt_synchronize (void *closure) { qt_closure_t *qtc = (qt_closure_t *) closure; qtc->app->flush (); /* not sure if this is sufficient */ } + +static const cairo_boilerplate_target_t targets[] = { + { + "qt", "qt", NULL, 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, 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 + }, +}; +CAIRO_BOILERPLATE (qt, targets) -- cgit v1.2.3