summaryrefslogtreecommitdiff
path: root/boilerplate/cairo-boilerplate-pdf.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-07-04 21:43:27 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-07-04 21:43:27 +0100
commit88cb69b10c66751f687c3745c8e9861b105de3a2 (patch)
tree3887fc1f4f4cf61b9111b62f6e85af0b72534782 /boilerplate/cairo-boilerplate-pdf.c
parent8a10ab1c04298d6c22ae8aabec5d762141a8e98f (diff)
[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.
Diffstat (limited to 'boilerplate/cairo-boilerplate-pdf.c')
-rw-r--r--boilerplate/cairo-boilerplate-pdf.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
index 3ac380c2..166ba1c9 100644
--- a/boilerplate/cairo-boilerplate-pdf.c
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -24,18 +24,12 @@
* Author: Carl D. Worth <cworth@cworth.org>
*/
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-pdf-private.h"
+#include "cairo-boilerplate-private.h"
#include <cairo-pdf.h>
#include <cairo-pdf-surface-private.h>
#include <cairo-paginated-surface-private.h>
-#if HAVE_SIGNAL_H
-#include <stdlib.h>
-#include <signal.h>
-#endif
-
static const cairo_user_data_key_t pdf_closure_key;
typedef struct _pdf_target_closure
@@ -48,7 +42,7 @@ typedef struct _pdf_target_closure
#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
-cairo_surface_t *
+static cairo_surface_t *
_cairo_boilerplate_pdf_create_surface (const char *name,
cairo_content_t content,
double width,
@@ -107,7 +101,7 @@ _cairo_boilerplate_pdf_create_surface (const char *name,
return surface;
}
-cairo_status_t
+static cairo_status_t
_cairo_boilerplate_pdf_finish_surface (cairo_surface_t *surface)
{
pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface,
@@ -151,7 +145,7 @@ _cairo_boilerplate_pdf_finish_surface (cairo_surface_t *surface)
return CAIRO_STATUS_SUCCESS;
}
-cairo_status_t
+static cairo_status_t
_cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const char *filename)
{
pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, &pdf_closure_key);
@@ -181,7 +175,7 @@ _cairo_boilerplate_pdf_convert_to_image (cairo_surface_t *surface, int page)
return cairo_boilerplate_convert_to_image (ptc->filename, page+1);
}
-cairo_surface_t *
+static cairo_surface_t *
_cairo_boilerplate_pdf_get_image_surface (cairo_surface_t *surface,
int page,
int width,
@@ -199,7 +193,7 @@ _cairo_boilerplate_pdf_get_image_surface (cairo_surface_t *surface,
return surface;
}
-void
+static void
_cairo_boilerplate_pdf_cleanup (void *closure)
{
pdf_target_closure_t *ptc = closure;
@@ -209,8 +203,7 @@ _cairo_boilerplate_pdf_cleanup (void *closure)
free (ptc);
}
-
-void
+static void
_cairo_boilerplate_pdf_force_fallbacks (cairo_surface_t *abstract_surface,
unsigned int flags)
{
@@ -227,3 +220,30 @@ _cairo_boilerplate_pdf_force_fallbacks (cairo_surface_t *abstract_surface,
surface = (cairo_pdf_surface_t*) paginated->target;
surface->force_fallbacks = TRUE;
}
+
+static const cairo_boilerplate_target_t targets[] = {
+ {
+ "pdf", "pdf", ".pdf", NULL,
+ CAIRO_SURFACE_TYPE_PDF,
+ CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
+ _cairo_boilerplate_pdf_create_surface,
+ _cairo_boilerplate_pdf_force_fallbacks,
+ _cairo_boilerplate_pdf_finish_surface,
+ _cairo_boilerplate_pdf_get_image_surface,
+ _cairo_boilerplate_pdf_surface_write_to_png,
+ _cairo_boilerplate_pdf_cleanup,
+ NULL, TRUE, TRUE
+ },
+ {
+ "pdf", "pdf", ".pdf", NULL,
+ CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
+ _cairo_boilerplate_pdf_create_surface,
+ _cairo_boilerplate_pdf_force_fallbacks,
+ _cairo_boilerplate_pdf_finish_surface,
+ _cairo_boilerplate_pdf_get_image_surface,
+ _cairo_boilerplate_pdf_surface_write_to_png,
+ _cairo_boilerplate_pdf_cleanup,
+ NULL, TRUE, TRUE
+ },
+};
+CAIRO_BOILERPLATE (pdf, targets)