From 11b2481862e15a2cdedae347eab4347f7b63f715 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 24 May 2006 14:02:30 -0700 Subject: [PATCH] PDF: Add new, private test function: cairo_pdf_test_force_fallbacks --- doc/public/Makefile.am | 1 + src/Makefile.am | 2 +- src/cairo-pdf-surface.c | 26 ++++++++++++++++++- src/cairo-pdf-test.h | 55 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/cairo-pdf-test.h diff --git a/doc/public/Makefile.am b/doc/public/Makefile.am index 289029f15..98d370672 100644 --- a/doc/public/Makefile.am +++ b/doc/public/Makefile.am @@ -28,6 +28,7 @@ IGNORE_HFILES= \ cairo-hash-private.h \ cairo-meta-surface-private.h \ cairo-path-fixed-private.h \ + cairo-pdf-test.h \ cairo-private.h \ cairo-win32-private.h \ cairo-xlib-private.h \ diff --git a/src/Makefile.am b/src/Makefile.am index 29603a0ff..42ae71ff1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,7 @@ endif if CAIRO_HAS_PDF_SURFACE libcairo_pdf_headers = cairo-pdf.h -libcairo_pdf_sources = cairo-pdf-surface.c +libcairo_pdf_sources = cairo-pdf-surface.c cairo-pdf-test.h libcairo_font_subset_sources = cairo-font-subset.c cairo-font-subset-private.h endif diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index fa530a07f..810899380 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -38,6 +38,7 @@ #include "cairoint.h" #include "cairo-pdf.h" +#include "cairo-pdf-test.h" #include "cairo-scaled-font-subsets-private.h" #include "cairo-ft-private.h" #include "cairo-paginated-surface-private.h" @@ -760,7 +761,7 @@ emit_image (cairo_pdf_surface_t *surface, * future). */ /* These are the only image formats we currently support, (which - * makes things a lot simpler here). This is enforeced through + * makes things a lot simpler here). This is enforced through * _analyze_operation which only accept source surfaces of * CONTENT_COLOR or CONTENT_COLOR_ALPHA. */ @@ -2022,11 +2023,34 @@ _pattern_supported (cairo_pattern_t *pattern) return FALSE; } +static cairo_bool_t cairo_pdf_force_fallbacks = FALSE; + +/** + * cairo_pdf_test_force_fallbacks + * + * Force the PDF surface backend to use image fallbacks for every + * operation. + * + * + * This function is only intended for internal + * testing use within the cairo distribution. It is not installed in + * any public header file. + * + **/ +void +cairo_pdf_test_force_fallbacks (void) +{ + cairo_pdf_force_fallbacks = TRUE; +} + static cairo_int_status_t _operation_supported (cairo_pdf_surface_t *surface, cairo_operator_t op, cairo_pattern_t *pattern) { + if (cairo_pdf_force_fallbacks) + return FALSE; + if (! _pattern_supported (pattern)) return FALSE; diff --git a/src/cairo-pdf-test.h b/src/cairo-pdf-test.h new file mode 100644 index 000000000..7299be3aa --- /dev/null +++ b/src/cairo-pdf-test.h @@ -0,0 +1,55 @@ +/* cairo - a vector graphics library with display and print output + * + * Copyright © 2006 Red Hat, Inc. + * + * 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 University of Southern + * California. + * + * Contributor(s): + * Carl D. Worth + */ + +#ifndef CAIRO_PDF_TEST_H +#define CAIRO_PDF_TEST_H + +#include + +#if CAIRO_HAS_PDF_SURFACE + +#include + +CAIRO_BEGIN_DECLS + +void +cairo_pdf_test_force_fallbacks (void); + +CAIRO_END_DECLS + +#endif /* CAIRO_HAS_PDF_SURFACE */ +#endif /* CAIRO_PDF_TEST_H */ +