diff --git a/.gitignore b/.gitignore index da5b497cd..a1de0d62e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .deps .libs -cairo-manual-* +.perf +cairo-*.*.* ChangeLog* Makefile Makefile.in @@ -29,3 +30,4 @@ stamp-h.in *.la *.lo *.orig +*.rej diff --git a/RELEASING b/RELEASING index adc429224..0573b1ea6 100644 --- a/RELEASING +++ b/RELEASING @@ -42,7 +42,7 @@ Here are the steps to follow to create a new cairo release: the following command will show each patch that has changed a public header file since the given version: - find src/ -name '*.h' ! -name '*-private.h' ! -name '*-test.h' ! -name 'cairoint.h' | \ + find src/ -name '*.h' ! -name '*-private.h' ! -name 'cairoint.h' | \ xargs git log -p X.Y.Z.. -- 4) Increment cairo_version_{minor|micro} and LT_{CURRENT|VERSION|AGE} diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am index b541af3d6..a55412a6e 100644 --- a/boilerplate/Makefile.am +++ b/boilerplate/Makefile.am @@ -3,6 +3,7 @@ EXTRA_LTLIBRARIES = libcairoboilerplate.la libcairoboilerplate_la_SOURCES =\ cairo-boilerplate.c \ cairo-boilerplate.h \ +cairo-boilerplate-scaled-font.h \ xmalloc.c \ xmalloc.h libcairoboilerplate_la_LIBADD = $(top_builddir)/src/libcairo.la $(CAIRO_LDADD) @@ -38,11 +39,13 @@ endif if CAIRO_HAS_PDF_SURFACE libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf.c +libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf.h libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf-private.h endif if CAIRO_HAS_PS_SURFACE libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps.c +libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps.h libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps-private.h endif @@ -53,6 +56,7 @@ endif if CAIRO_HAS_SVG_SURFACE libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg.c +libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg.h libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg-private.h endif @@ -73,6 +77,7 @@ endif if CAIRO_HAS_XLIB_XRENDER_SURFACE libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib.c +libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib.h libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib-private.h endif diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c index 13f9ef863..e0a610e7e 100644 --- a/boilerplate/cairo-boilerplate-pdf.c +++ b/boilerplate/cairo-boilerplate-pdf.c @@ -25,9 +25,12 @@ */ #include "cairo-boilerplate.h" +#include "cairo-boilerplate-pdf.h" #include "cairo-boilerplate-pdf-private.h" #include +#include +#include cairo_user_data_key_t pdf_closure_key; @@ -132,3 +135,19 @@ _cairo_boilerplate_pdf_cleanup (void *closure) free (ptc->filename); free (ptc); } + +cairo_status_t +cairo_boilerplate_pdf_surface_force_fallbacks (cairo_surface_t *abstract_surface) +{ + cairo_paginated_surface_t *paginated = (cairo_paginated_surface_t*) abstract_surface; + cairo_pdf_surface_t *surface; + + if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_PDF) + return CAIRO_STATUS_SURFACE_TYPE_MISMATCH; + + surface = (cairo_pdf_surface_t*) paginated->target; + + surface->force_fallbacks = TRUE; + + return CAIRO_STATUS_SUCCESS; +} diff --git a/boilerplate/cairo-boilerplate-pdf.h b/boilerplate/cairo-boilerplate-pdf.h new file mode 100644 index 000000000..6aac40280 --- /dev/null +++ b/boilerplate/cairo-boilerplate-pdf.h @@ -0,0 +1,33 @@ +/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Red Hat, Inc. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Red Hat, Inc. makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Behdad Esfahbod + */ + +#ifndef _CAIRO_BOILERPLATE_PDF_H_ +#define _CAIRO_BOILERPLATE_PDF_H_ + +cairo_status_t +cairo_boilerplate_pdf_surface_force_fallbacks (cairo_surface_t *surface); + +#endif diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c index 676d3e863..0e7a764a1 100644 --- a/boilerplate/cairo-boilerplate-ps.c +++ b/boilerplate/cairo-boilerplate-ps.c @@ -25,9 +25,12 @@ */ #include "cairo-boilerplate.h" +#include "cairo-boilerplate-ps.h" #include "cairo-boilerplate-ps-private.h" #include +#include +#include cairo_user_data_key_t ps_closure_key; @@ -136,3 +139,19 @@ _cairo_boilerplate_ps_cleanup (void *closure) free (ptc->filename); free (ptc); } + +cairo_status_t +cairo_boilerplate_ps_surface_force_fallbacks (cairo_surface_t *abstract_surface) +{ + cairo_paginated_surface_t *paginated = (cairo_paginated_surface_t*) abstract_surface; + cairo_ps_surface_t *surface; + + if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_PS) + return CAIRO_STATUS_SURFACE_TYPE_MISMATCH; + + surface = (cairo_ps_surface_t*) paginated->target; + + surface->force_fallbacks = TRUE; + + return CAIRO_STATUS_SUCCESS; +} diff --git a/boilerplate/cairo-boilerplate-ps.h b/boilerplate/cairo-boilerplate-ps.h new file mode 100644 index 000000000..5cc5c18fb --- /dev/null +++ b/boilerplate/cairo-boilerplate-ps.h @@ -0,0 +1,33 @@ +/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Red Hat, Inc. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Red Hat, Inc. makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Behdad Esfahbod + */ + +#ifndef _CAIRO_BOILERPLATE_PS_H_ +#define _CAIRO_BOILERPLATE_PS_H_ + +cairo_status_t +cairo_boilerplate_ps_surface_force_fallbacks (cairo_surface_t *surface); + +#endif diff --git a/boilerplate/cairo-boilerplate-scaled-font.h b/boilerplate/cairo-boilerplate-scaled-font.h new file mode 100644 index 000000000..4d27cd0f7 --- /dev/null +++ b/boilerplate/cairo-boilerplate-scaled-font.h @@ -0,0 +1,34 @@ +/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Red Hat, Inc. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Red Hat, Inc. makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Behdad Esfahbod + */ + +#ifndef _CAIRO_BOILERPLATE_SCALED_FONT_H_ +#define _CAIRO_BOILERPLATE_SCALED_FONT_H_ + +void +cairo_boilerplate_scaled_font_set_max_glyphs_cached (cairo_scaled_font_t *scaled_font, + int max_glyphs); + +#endif diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c index cc344c935..b85a95e84 100644 --- a/boilerplate/cairo-boilerplate-svg.c +++ b/boilerplate/cairo-boilerplate-svg.c @@ -25,9 +25,12 @@ */ #include "cairo-boilerplate.h" +#include "cairo-boilerplate-svg.h" #include "cairo-boilerplate-svg-private.h" #include +#include +#include cairo_user_data_key_t svg_closure_key; @@ -127,3 +130,19 @@ _cairo_boilerplate_svg_cleanup (void *closure) free (ptc->filename); free (ptc); } + +cairo_status_t +cairo_boilerplate_svg_surface_force_fallbacks (cairo_surface_t *abstract_surface) +{ + cairo_paginated_surface_t *paginated = (cairo_paginated_surface_t*) abstract_surface; + cairo_svg_surface_t *surface; + + if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_PDF) + return CAIRO_STATUS_SURFACE_TYPE_MISMATCH; + + surface = (cairo_svg_surface_t*) paginated->target; + + surface->force_fallbacks = TRUE; + + return CAIRO_STATUS_SUCCESS; +} diff --git a/boilerplate/cairo-boilerplate-svg.h b/boilerplate/cairo-boilerplate-svg.h new file mode 100644 index 000000000..12299168b --- /dev/null +++ b/boilerplate/cairo-boilerplate-svg.h @@ -0,0 +1,33 @@ +/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Red Hat, Inc. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Red Hat, Inc. makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Behdad Esfahbod + */ + +#ifndef _CAIRO_BOILERPLATE_SVG_H_ +#define _CAIRO_BOILERPLATE_SVG_H_ + +cairo_status_t +cairo_boilerplate_svg_surface_force_fallbacks (cairo_surface_t *surface); + +#endif diff --git a/boilerplate/cairo-boilerplate-xlib-private.h b/boilerplate/cairo-boilerplate-xlib-private.h index 975782774..80826d5ae 100644 --- a/boilerplate/cairo-boilerplate-xlib-private.h +++ b/boilerplate/cairo-boilerplate-xlib-private.h @@ -28,12 +28,12 @@ #define _CAIRO_BOILERPLATE_XLIB_PRIVATE_H_ cairo_surface_t * -_cairo_boilerplate_xlib_create_surface (const char *name, - cairo_content_t content, - int width, - int height, - cairo_boilerplate_mode_t mode, - void **closure); +_cairo_boilerplate_xlib_create_surface (const char *name, + cairo_content_t content, + int width, + int height, + cairo_boilerplate_mode_t mode, + void **closure); void _cairo_boilerplate_xlib_cleanup (void *closure); diff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c index 302035d38..615fc98fa 100644 --- a/boilerplate/cairo-boilerplate-xlib.c +++ b/boilerplate/cairo-boilerplate-xlib.c @@ -25,9 +25,11 @@ */ #include "cairo-boilerplate.h" +#include "cairo-boilerplate-xlib.h" #include "cairo-boilerplate-xlib-private.h" #include +#include typedef struct _xlib_target_closure { @@ -194,3 +196,16 @@ _cairo_boilerplate_xlib_cleanup (void *closure) XCloseDisplay (xtc->dpy); free (xtc); } + +cairo_status_t +cairo_boilerplate_xlib_surface_disable_render (cairo_surface_t *abstract_surface) +{ + cairo_xlib_surface_t *surface = (cairo_xlib_surface_t*) abstract_surface; + + if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_XLIB) + return CAIRO_STATUS_SURFACE_TYPE_MISMATCH; + + surface->render_major = surface->render_minor = -1; + + return CAIRO_STATUS_SUCCESS; +} diff --git a/boilerplate/cairo-boilerplate-xlib.h b/boilerplate/cairo-boilerplate-xlib.h new file mode 100644 index 000000000..9a6391812 --- /dev/null +++ b/boilerplate/cairo-boilerplate-xlib.h @@ -0,0 +1,33 @@ +/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ +/* + * Copyright © 2007 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Red Hat, Inc. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Red Hat, Inc. makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Behdad Esfahbod + */ + +#ifndef _CAIRO_BOILERPLATE_XLIB_H_ +#define _CAIRO_BOILERPLATE_XLIB_H_ + +cairo_status_t +cairo_boilerplate_xlib_surface_disable_render (cairo_surface_t *surface); + +#endif diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c index 2a6d31c82..5c86a1d33 100644 --- a/boilerplate/cairo-boilerplate.c +++ b/boilerplate/cairo-boilerplate.c @@ -25,6 +25,7 @@ */ #include "cairo-boilerplate.h" +#include "cairo-boilerplate-scaled-font.h" #if CAIRO_HAS_BEOS_SURFACE #include "cairo-boilerplate-beos-private.h" @@ -60,6 +61,9 @@ #include "cairo-boilerplate-xlib-private.h" #endif +#include +#include + #include #include #include @@ -434,3 +438,10 @@ cairo_boilerplate_surface_set_user_data (cairo_surface_t *surface, exit (1); } } + +void +cairo_boilerplate_scaled_font_set_max_glyphs_cached (cairo_scaled_font_t *scaled_font, + int max_glyphs) +{ + scaled_font->glyphs->max_size = max_glyphs; +} diff --git a/doc/public/Headers.mk b/doc/public/Headers.mk index 106c998fb..9b8991df1 100644 --- a/doc/public/Headers.mk +++ b/doc/public/Headers.mk @@ -13,22 +13,25 @@ PRIVATE_TEST_HFILES = \ cairo-mutex-private.h \ cairo-os2-private.h \ cairo-output-stream-private.h \ + cairo-paginated-private.h \ cairo-paginated-surface-private.h \ cairo-path-fixed-private.h \ cairo-path-private.h \ - cairo-pdf-test.h \ + cairo-pdf-surface-private.h \ cairo-private.h \ - cairo-ps-test.h \ + cairo-ps-surface-private.h \ cairo-quartz-private.h \ + cairo-scaled-font-private.h \ cairo-scaled-font-subsets-private.h \ - cairo-scaled-font-test.h \ cairo-skiplist-private.h \ cairo-surface-fallback-private.h \ - cairo-svg-test.h \ + cairo-surface-private.h \ + cairo-svg-surface-private.h \ cairo-truetype-subset-private.h \ cairo-type1-private.h \ + cairo-types-private.h \ cairo-wideint-private.h \ cairo-win32-private.h \ cairo-xlib-private.h \ - cairo-xlib-test.h \ + cairo-xlib-surface-private.h \ cairoint.h diff --git a/src/Makefile.am b/src/Makefile.am index 3cf6b2b02..554c4fb44 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,14 +14,15 @@ backend_pkgconfigs = if CAIRO_HAS_PS_SURFACE libcairo_ps_headers = cairo-ps.h -libcairo_ps_sources = cairo-ps-surface.c cairo-ps-test.h +libcairo_ps_sources = cairo-ps-surface.c cairo-pdf-surface-private.h libcairo_font_subset_sources = $(font_subset_sources) backend_pkgconfigs += cairo-ps.pc endif if CAIRO_HAS_PDF_SURFACE libcairo_pdf_headers = cairo-pdf.h -libcairo_pdf_sources = cairo-pdf-surface.c cairo-deflate-stream.c cairo-pdf-test.h +libcairo_pdf_sources = cairo-pdf-surface.c cairo-pdf-surface-private.h \ + cairo-deflate-stream.c libcairo_font_subset_sources = $(font_subset_sources) backend_pkgconfigs += cairo-pdf.pc endif @@ -33,7 +34,7 @@ endif if CAIRO_HAS_SVG_SURFACE libcairo_svg_headers = cairo-svg.h -libcairo_svg_sources = cairo-svg-surface.c cairo-svg-test.h +libcairo_svg_sources = cairo-svg-surface.c cairo-svg-surface-private.h libcairo_font_subset_sources = $(font_subset_sources) backend_pkgconfigs += cairo-svg.pc endif @@ -46,7 +47,8 @@ endif if CAIRO_HAS_XLIB_SURFACE libcairo_xlib_headers = cairo-xlib.h cairo-xlib-xrender.h -libcairo_xlib_sources = cairo-xlib-surface.c cairo-xlib-screen.c cairo-xlib-private.h cairo-xlib-test.h +libcairo_xlib_sources = cairo-xlib-surface.c cairo-xlib-surface-private.h \ + cairo-xlib-screen.c cairo-xlib-private.h backend_pkgconfigs += cairo-xlib.pc endif @@ -203,7 +205,7 @@ libcairo_la_SOURCES = \ cairo-rectangle.c \ cairo-region.c \ cairo-scaled-font.c \ - cairo-scaled-font-test.h \ + cairo-scaled-font-private.h \ cairo-skiplist.c \ cairo-skiplist-private.h \ cairo-slope.c \ @@ -212,7 +214,9 @@ libcairo_la_SOURCES = \ cairo-surface.c \ cairo-surface-fallback.c \ cairo-surface-fallback-private.h \ + cairo-surface-private.h \ cairo-traps.c \ + cairo-types-private.h \ cairo-pattern.c \ cairo-unicode.c \ cairo-output-stream.c \ @@ -221,6 +225,7 @@ libcairo_la_SOURCES = \ cairo-wideint-private.h \ cairo-meta-surface.c \ cairo-meta-surface-private.h \ + cairo-paginated-private.h \ cairo-paginated-surface.c \ cairo-paginated-surface-private.h \ cairo-analysis-surface.c \ diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c index a89636efa..26a373fa6 100644 --- a/src/cairo-analysis-surface.c +++ b/src/cairo-analysis-surface.c @@ -35,7 +35,7 @@ #include "cairoint.h" #include "cairo-analysis-surface-private.h" -#include "cairo-paginated-surface-private.h" +#include "cairo-paginated-private.h" typedef struct { cairo_surface_t base; diff --git a/src/cairo-cache-private.h b/src/cairo-cache-private.h index 566dbe22d..7ab14e26c 100644 --- a/src/cairo-cache-private.h +++ b/src/cairo-cache-private.h @@ -39,7 +39,7 @@ #ifndef CAIRO_CACHE_PRIVATE_H #define CAIRO_CACHE_PRIVATE_H -typedef struct _cairo_cache cairo_cache_t; +#include "cairo-types-private.h" /** * cairo_cache_entry_t: diff --git a/src/cairo-cache.c b/src/cairo-cache.c index fa1f003a6..18c3d8cca 100644 --- a/src/cairo-cache.c +++ b/src/cairo-cache.c @@ -38,17 +38,6 @@ #include "cairoint.h" -struct _cairo_cache { - cairo_hash_table_t *hash_table; - - cairo_destroy_func_t entry_destroy; - - unsigned long max_size; - unsigned long size; - - int freeze_count; -}; - static void _cairo_cache_remove (cairo_cache_t *cache, cairo_cache_entry_t *entry); diff --git a/src/cairo-hash-private.h b/src/cairo-hash-private.h index 617b8410d..8ed3ba83a 100644 --- a/src/cairo-hash-private.h +++ b/src/cairo-hash-private.h @@ -39,51 +39,13 @@ #ifndef CAIRO_HASH_PRIVATE_H #define CAIRO_HASH_PRIVATE_H +#include "cairo-types-private.h" + /* XXX: I'd like this file to be self-contained in terms of * includeability, but that's not really possible with the current * monolithic cairoint.h. So, for now, just include cairoint.h instead * if you want to include this file. */ -typedef struct _cairo_hash_table cairo_hash_table_t; - -/** - * cairo_hash_entry_t: - * - * A #cairo_hash_entry_t contains both a key and a value for - * cairo_hash_table_t. User-derived types for cairo_hash_entry_t must - * be type-compatible with this structure (eg. they must have an - * unsigned long as the first parameter. The easiest way to get this - * is to use: - * - * typedef _my_entry { - * cairo_hash_entry_t base; - * ... Remainder of key and value fields here .. - * } my_entry_t; - * - * which then allows a pointer to my_entry_t to be passed to any of - * the cairo_hash_table functions as follows without requiring a cast: - * - * _cairo_hash_table_insert (hash_table, &my_entry->base); - * - * IMPORTANT: The caller is reponsible for initializing - * my_entry->base.hash with a hash code derived from the key. The - * essential property of the hash code is that keys_equal must never - * return TRUE for two keys that have different hashes. The best hash - * code will reduce the frequency of two keys with the same code for - * which keys_equal returns FALSE. - * - * Which parts of the entry make up the "key" and which part make up - * the value are entirely up to the caller, (as determined by the - * computation going into base.hash as well as the keys_equal - * function). A few of the cairo_hash_table functions accept an entry - * which will be used exclusively as a "key", (indicated by a - * parameter name of key). In these cases, the value-related fields of - * the entry need not be initialized if so desired. - **/ -typedef struct _cairo_hash_entry { - unsigned long hash; -} cairo_hash_entry_t; - typedef cairo_bool_t (*cairo_hash_keys_equal_func_t) (const void *key_a, const void *key_b); diff --git a/src/cairo-output-stream-private.h b/src/cairo-output-stream-private.h index 26c18cb58..0600431ea 100644 --- a/src/cairo-output-stream-private.h +++ b/src/cairo-output-stream-private.h @@ -37,7 +37,7 @@ #ifndef CAIRO_OUTPUT_STREAM_PRIVATE_H #define CAIRO_OUTPUT_STREAM_PRIVATE_H -typedef struct _cairo_output_stream cairo_output_stream_t; +#include "cairo-types-private.h" typedef cairo_status_t (*cairo_output_stream_write_func_t) (cairo_output_stream_t *output_stream, const unsigned char *data, diff --git a/src/cairo-paginated-private.h b/src/cairo-paginated-private.h new file mode 100644 index 000000000..42d100b4b --- /dev/null +++ b/src/cairo-paginated-private.h @@ -0,0 +1,136 @@ +/* cairo - a vector graphics library with display and print output + * + * Copyright © 2005 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 Red Hat, Inc. + * + * Contributor(s): + * Carl Worth + */ + +#ifndef CAIRO_PAGINATED_H +#define CAIRO_PAGINATED_H + +#include "cairoint.h" + +struct _cairo_paginated_surface_backend { + /* Optional. Will be called once for each page. + * + * NOTE: With respect to the order of drawing operations as seen + * by the target, this call will occur before any drawing + * operations for the relevant page. However, with respect to the + * function calls as made by the user, this call will be *after* + * any drawing operations for the page, (that is, it will occur + * during the user's call to cairo_show_page or cairo_copy_page). + */ + cairo_warn cairo_int_status_t + (*start_page) (void *surface); + + /* Required. Will be called twice for each page, once with an + * argument of CAIRO_PAGINATED_MODE_ANALYZE and once with + * CAIRO_PAGINATED_MODE_RENDER. See more details in the + * documentation for _cairo_paginated_surface_create below. + */ + void + (*set_paginated_mode) (void *surface, + cairo_paginated_mode_t mode); +}; + +/* A cairo_paginated_surface provides a very convenient wrapper that + * is well-suited for doing the analysis common to most surfaces that + * have paginated output, (that is, things directed at printers, or + * for saving content in files such as PostScript or PDF files). + * + * To use the paginated surface, you'll first need to create your + * 'real' surface using _cairo_surface_init and the standard + * cairo_surface_backend_t. Then you also call + * _cairo_paginated_surface_create which takes its own, much simpler, + * cairo_paginated_surface_backend. You are free to return the result + * of _cairo_paginated_surface_create from your public + * cairo__surface_create. The paginated backend will be careful + * to not let the user see that they really got a "wrapped" + * surface. See test-paginated-surface.c for a fairly minimal example + * of a paginated-using surface. That should be a reasonable example + * to follow. + * + * What the paginated surface does is first save all drawing + * operations for a page into a meta-surface. Then when the user calls + * cairo_show_page, the paginated surface performs the following + * sequence of operations (using the backend functions passed to + * cairo_paginated_surface_create): + * + * 1. Calls start_page (if non NULL). At this point, it is appropriate + * for the target to emit any page-specific header information into + * its output. + * + * 2. Calls set_paginated_mode with an argument of CAIRO_PAGINATED_MODE_ANALYZE + * + * 3. Replays the meta-surface to the target surface, (with an + * analysis surface inserted between which watches the return value + * from each operation). This analysis stage is used to decide which + * operations will require fallbacks. + * + * 4. Calls set_paginated_mode with an argument of CAIRO_PAGINATED_MODE_RENDER + * + * 5. Replays a subset of the meta-surface operations to the target surface + * + * 6. Replays the remaining operations to an image surface, sets an + * appropriate clip on the target, then paints the resulting image + * surface to the target. + * + * So, the target will see drawing operations during two separate + * stages, (ANALYZE and RENDER). During the ANALYZE phase the target + * should not actually perform any rendering, (for example, if + * performing output to a file, no output should be generated during + * this stage). Instead the drawing functions simply need to return + * CAIRO_STATUS_SUCCESS or CAIRO_INT_STATUS_UNSUPPORTED to indicate + * whether rendering would be supported. And it should do this as + * quickly as possible. + * + * NOTE: The paginated surface layer assumes that the target surface + * is "blank" by default at the beginning of each page, without any + * need for an explicit erasea operation, (as opposed to an image + * surface, for example, which might have uninitialized content + * originally). As such, it optimizes away CLEAR operations that + * happen at the beginning of each page---the target surface will not + * even see these operations. + */ +cairo_private cairo_surface_t * +_cairo_paginated_surface_create (cairo_surface_t *target, + cairo_content_t content, + int width, + int height, + const cairo_paginated_surface_backend_t *backend); + +cairo_private cairo_surface_t * +_cairo_paginated_surface_get_target (cairo_surface_t *surface); + +cairo_private cairo_bool_t +_cairo_surface_is_paginated (cairo_surface_t *surface); + +#endif /* CAIRO_PAGINATED_H */ diff --git a/src/cairo-paginated-surface-private.h b/src/cairo-paginated-surface-private.h index 1e07f59a4..b406cac15 100644 --- a/src/cairo-paginated-surface-private.h +++ b/src/cairo-paginated-surface-private.h @@ -36,106 +36,37 @@ #ifndef CAIRO_PAGINATED_SURFACE_H #define CAIRO_PAGINATED_SURFACE_H -#include "cairoint.h" +#include "cairo.h" -typedef enum { - CAIRO_PAGINATED_MODE_ANALYZE, /* analyze page regions */ - CAIRO_PAGINATED_MODE_RENDER /* render page contents */ -} cairo_paginated_mode_t; +#include "cairo-surface-private.h" -typedef struct _cairo_paginated_surface_backend { - /* Optional. Will be called once for each page. - * - * NOTE: With respect to the order of drawing operations as seen - * by the target, this call will occur before any drawing - * operations for the relevant page. However, with respect to the - * function calls as made by the user, this call will be *after* - * any drawing operations for the page, (that is, it will occur - * during the user's call to cairo_show_page or cairo_copy_page). - */ - cairo_warn cairo_int_status_t - (*start_page) (void *surface); +typedef struct _cairo_paginated_surface { + cairo_surface_t base; - /* Required. Will be called twice for each page, once with an - * argument of CAIRO_PAGINATED_MODE_ANALYZE and once with - * CAIRO_PAGINATED_MODE_RENDER. See more details in the - * documentation for _cairo_paginated_surface_create below. - */ - void - (*set_paginated_mode) (void *surface, - cairo_paginated_mode_t mode); -} cairo_paginated_surface_backend_t; + /* The target surface to hold the final result. */ + cairo_surface_t *target; -/* A cairo_paginated_surface provides a very convenient wrapper that - * is well-suited for doing the analysis common to most surfaces that - * have paginated output, (that is, things directed at printers, or - * for saving content in files such as PostScript or PDF files). - * - * To use the paginated surface, you'll first need to create your - * 'real' surface using _cairo_surface_init and the standard - * cairo_surface_backend_t. Then you also call - * _cairo_paginated_surface_create which takes its own, much simpler, - * cairo_paginated_surface_backend. You are free to return the result - * of _cairo_paginated_surface_create from your public - * cairo__surface_create. The paginated backend will be careful - * to not let the user see that they really got a "wrapped" - * surface. See test-paginated-surface.c for a fairly minimal example - * of a paginated-using surface. That should be a reasonable example - * to follow. - * - * What the paginated surface does is first save all drawing - * operations for a page into a meta-surface. Then when the user calls - * cairo_show_page, the paginated surface performs the following - * sequence of operations (using the backend functions passed to - * cairo_paginated_surface_create): - * - * 1. Calls start_page (if non NULL). At this point, it is appropriate - * for the target to emit any page-specific header information into - * its output. - * - * 2. Calls set_paginated_mode with an argument of CAIRO_PAGINATED_MODE_ANALYZE - * - * 3. Replays the meta-surface to the target surface, (with an - * analysis surface inserted between which watches the return value - * from each operation). This analysis stage is used to decide which - * operations will require fallbacks. - * - * 4. Calls set_paginated_mode with an argument of CAIRO_PAGINATED_MODE_RENDER - * - * 5. Replays a subset of the meta-surface operations to the target surface - * - * 6. Replays the remaining operations to an image surface, sets an - * appropriate clip on the target, then paints the resulting image - * surface to the target. - * - * So, the target will see drawing operations during two separate - * stages, (ANALYZE and RENDER). During the ANALYZE phase the target - * should not actually perform any rendering, (for example, if - * performing output to a file, no output should be generated during - * this stage). Instead the drawing functions simply need to return - * CAIRO_STATUS_SUCCESS or CAIRO_INT_STATUS_UNSUPPORTED to indicate - * whether rendering would be supported. And it should do this as - * quickly as possible. - * - * NOTE: The paginated surface layer assumes that the target surface - * is "blank" by default at the beginning of each page, without any - * need for an explicit erasea operation, (as opposed to an image - * surface, for example, which might have uninitialized content - * originally). As such, it optimizes away CLEAR operations that - * happen at the beginning of each page---the target surface will not - * even see these operations. - */ -cairo_private cairo_surface_t * -_cairo_paginated_surface_create (cairo_surface_t *target, - cairo_content_t content, - int width, - int height, - const cairo_paginated_surface_backend_t *backend); + cairo_content_t content; -cairo_private cairo_surface_t * -_cairo_paginated_surface_get_target (cairo_surface_t *surface); + /* XXX: These shouldn't actually exist. We inherit this ugliness + * from _cairo_meta_surface_create. The width/height parameters + * from that function also should not exist. The fix that will + * allow us to remove all of these is to fix acquire_source_image + * to pass an interest rectangle. */ + int width; + int height; -cairo_private cairo_bool_t -_cairo_surface_is_paginated (cairo_surface_t *surface); + /* Paginated-surface specific functions for the target */ + const cairo_paginated_surface_backend_t *backend; + + /* A cairo_meta_surface to record all operations. To be replayed + * against target, and also against image surface as necessary for + * fallbacks. */ + cairo_surface_t *meta; + + int page_num; + cairo_bool_t page_is_blank; + +} cairo_paginated_surface_t; #endif /* CAIRO_PAGINATED_SURFACE_H */ diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c index f788dc2fd..c9584b618 100644 --- a/src/cairo-paginated-surface.c +++ b/src/cairo-paginated-surface.c @@ -36,45 +36,17 @@ /* The paginated surface layer exists to provide as much code sharing * as possible for the various paginated surface backends in cairo - * (PostScript, PDF, etc.). See cairo-paginated-surface-private.h for + * (PostScript, PDF, etc.). See cairo-paginated-private.h for * more details on how it works and how to use it. */ #include "cairoint.h" +#include "cairo-paginated-private.h" #include "cairo-paginated-surface-private.h" #include "cairo-meta-surface-private.h" #include "cairo-analysis-surface-private.h" -typedef struct _cairo_paginated_surface { - cairo_surface_t base; - - /* The target surface to hold the final result. */ - cairo_surface_t *target; - - cairo_content_t content; - - /* XXX: These shouldn't actually exist. We inherit this ugliness - * from _cairo_meta_surface_create. The width/height parameters - * from that function also should not exist. The fix that will - * allow us to remove all of these is to fix acquire_source_image - * to pass an interest rectangle. */ - int width; - int height; - - /* Paginated-surface specific functions for the target */ - const cairo_paginated_surface_backend_t *backend; - - /* A cairo_meta_surface to record all operations. To be replayed - * against target, and also against image surface as necessary for - * fallbacks. */ - cairo_surface_t *meta; - - int page_num; - cairo_bool_t page_is_blank; - -} cairo_paginated_surface_t; - const cairo_private cairo_surface_backend_t cairo_paginated_surface_backend; static cairo_int_status_t diff --git a/src/cairo-xlib-test.h b/src/cairo-pdf-surface-private.h similarity index 51% rename from src/cairo-xlib-test.h rename to src/cairo-pdf-surface-private.h index ec167c15c..1fcf7745f 100644 --- a/src/cairo-xlib-test.h +++ b/src/cairo-pdf-surface-private.h @@ -1,6 +1,7 @@ /* cairo - a vector graphics library with display and print output * - * Copyright © 2005 Red Hat, Inc. + * Copyright © 2004 Red Hat, Inc + * 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 @@ -31,24 +32,60 @@ * California. * * Contributor(s): - * Carl D. Worth + * Kristian Høgsberg + * Carl Worth */ -#ifndef CAIRO_XLIB_TEST_H -#define CAIRO_XLIB_TEST_H +#ifndef CAIRO_PDF_SURFACE_PRIVATE_H +#define CAIRO_PDF_SURFACE_PRIVATE_H -#include +#include "cairo-pdf.h" -#if CAIRO_HAS_XLIB_SURFACE +#include "cairo-surface-private.h" -#include +typedef struct _cairo_pdf_resource { + unsigned int id; +} cairo_pdf_resource_t; -CAIRO_BEGIN_DECLS +typedef struct _cairo_pdf_surface cairo_pdf_surface_t; -cairo_public void -_cairo_xlib_test_disable_render (void); +struct _cairo_pdf_surface { + cairo_surface_t base; -CAIRO_END_DECLS + /* Prefer the name "output" here to avoid confusion over the + * structure within a PDF document known as a "stream". */ + cairo_output_stream_t *output; -#endif /* CAIRO_HAS_XLIB_SURFACE */ -#endif /* CAIRO_XLIB_H */ + double width; + double height; + + cairo_array_t objects; + cairo_array_t pages; + cairo_array_t patterns; + cairo_array_t xobjects; + cairo_array_t streams; + cairo_array_t alphas; + + cairo_scaled_font_subsets_t *font_subsets; + cairo_array_t fonts; + + cairo_pdf_resource_t next_available_resource; + cairo_pdf_resource_t pages_resource; + + struct { + cairo_bool_t active; + cairo_pdf_resource_t self; + cairo_pdf_resource_t length; + long start_offset; + cairo_bool_t compressed; + cairo_output_stream_t *old_output; + } current_stream; + + cairo_bool_t has_clip; + + cairo_paginated_mode_t paginated_mode; + + cairo_bool_t force_fallbacks; +}; + +#endif /* CAIRO_PDF_SURFACE_PRIVATE_H */ diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index f4e6f900d..073191e2e 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -38,9 +38,9 @@ #include "cairoint.h" #include "cairo-pdf.h" -#include "cairo-pdf-test.h" +#include "cairo-pdf-surface-private.h" #include "cairo-scaled-font-subsets-private.h" -#include "cairo-paginated-surface-private.h" +#include "cairo-paginated-private.h" #include "cairo-path-fixed-private.h" #include "cairo-output-stream-private.h" @@ -91,53 +91,12 @@ typedef struct _cairo_pdf_object { long offset; } cairo_pdf_object_t; -typedef struct _cairo_pdf_resource { - unsigned int id; -} cairo_pdf_resource_t; - typedef struct _cairo_pdf_font { unsigned int font_id; unsigned int subset_id; cairo_pdf_resource_t subset_resource; } cairo_pdf_font_t; -typedef struct _cairo_pdf_surface { - cairo_surface_t base; - - /* Prefer the name "output" here to avoid confusion over the - * structure within a PDF document known as a "stream". */ - cairo_output_stream_t *output; - - double width; - double height; - - cairo_array_t objects; - cairo_array_t pages; - cairo_array_t patterns; - cairo_array_t xobjects; - cairo_array_t streams; - cairo_array_t alphas; - - cairo_scaled_font_subsets_t *font_subsets; - cairo_array_t fonts; - - cairo_pdf_resource_t next_available_resource; - cairo_pdf_resource_t pages_resource; - - struct { - cairo_bool_t active; - cairo_pdf_resource_t self; - cairo_pdf_resource_t length; - long start_offset; - cairo_bool_t compressed; - cairo_output_stream_t *old_output; - } current_stream; - - cairo_bool_t has_clip; - - cairo_paginated_mode_t paginated_mode; -} cairo_pdf_surface_t; - static cairo_pdf_resource_t _cairo_pdf_surface_new_object (cairo_pdf_surface_t *surface); @@ -295,6 +254,8 @@ _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t *output, surface->paginated_mode = CAIRO_PAGINATED_MODE_ANALYZE; + surface->force_fallbacks = FALSE; + /* Document header */ _cairo_output_stream_printf (surface->output, "%%PDF-1.4\r\n"); @@ -2696,32 +2657,12 @@ _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 -__cairo_pdf_surface_operation_supported (cairo_pdf_surface_t *surface, +_cairo_pdf_surface_operation_supported (cairo_pdf_surface_t *surface, cairo_operator_t op, cairo_pattern_t *pattern) { - if (cairo_pdf_force_fallbacks) + if (surface->force_fallbacks) return FALSE; if (! _pattern_supported (pattern)) @@ -2740,7 +2681,7 @@ _cairo_pdf_surface_analyze_operation (cairo_pdf_surface_t *surface, cairo_operator_t op, cairo_pattern_t *pattern) { - if (__cairo_pdf_surface_operation_supported (surface, op, pattern)) + if (_cairo_pdf_surface_operation_supported (surface, op, pattern)) return CAIRO_STATUS_SUCCESS; else return CAIRO_INT_STATUS_UNSUPPORTED; @@ -2764,7 +2705,7 @@ _cairo_pdf_surface_paint (void *abstract_surface, * possible only because there is nothing between the fallback * images and the paper, nor is anything painted above. */ /* - assert (__cairo_pdf_surface_operation_supported (op, source)); + assert (_cairo_pdf_surface_operation_supported (op, source)); */ status = _cairo_pdf_surface_emit_pattern (surface, source); @@ -2878,7 +2819,7 @@ _cairo_pdf_surface_stroke (void *abstract_surface, if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) return _cairo_pdf_surface_analyze_operation (surface, op, source); - assert (__cairo_pdf_surface_operation_supported (surface, op, source)); + assert (_cairo_pdf_surface_operation_supported (surface, op, source)); status = _cairo_pdf_surface_emit_pattern (surface, source); if (status) @@ -2927,7 +2868,7 @@ _cairo_pdf_surface_fill (void *abstract_surface, if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) return _cairo_pdf_surface_analyze_operation (surface, op, source); - assert (__cairo_pdf_surface_operation_supported (surface, op, source)); + assert (_cairo_pdf_surface_operation_supported (surface, op, source)); status = _cairo_pdf_surface_emit_pattern (surface, source); if (status) @@ -2984,7 +2925,7 @@ _cairo_pdf_surface_show_glyphs (void *abstract_surface, if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) return _cairo_pdf_surface_analyze_operation (surface, op, source); - assert (__cairo_pdf_surface_operation_supported (surface, op, source)); + assert (_cairo_pdf_surface_operation_supported (surface, op, source)); status = _cairo_pdf_surface_emit_pattern (surface, source); if (status) diff --git a/src/cairo-ps-test.h b/src/cairo-ps-surface-private.h similarity index 54% rename from src/cairo-ps-test.h rename to src/cairo-ps-surface-private.h index 5d49eced7..2499b992f 100644 --- a/src/cairo-ps-test.h +++ b/src/cairo-ps-surface-private.h @@ -1,6 +1,7 @@ /* cairo - a vector graphics library with display and print output * - * Copyright © 2006 Red Hat, Inc. + * Copyright © 2003 University of Southern California + * Copyright © 2005 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 @@ -32,23 +33,48 @@ * * Contributor(s): * Carl D. Worth + * Kristian Høgsberg + * Keith Packard */ -#ifndef CAIRO_PS_TEST_H -#define CAIRO_PS_TEST_H +#ifndef CAIRO_PS_SURFACE_PRIVATE_H +#define CAIRO_PS_SURFACE_PRIVATE_H -#include +#include "cairo-ps.h" -#if CAIRO_HAS_PS_SURFACE +#include "cairo-surface-private.h" -#include +typedef struct cairo_ps_surface { + cairo_surface_t base; -CAIRO_BEGIN_DECLS + /* Here final_stream corresponds to the stream/file passed to + * cairo_ps_surface_create surface is built. Meanwhile stream is a + * temporary stream in which the file output is built, (so that + * the header can be built and inserted into the target stream + * before the contents of the temporary stream are copied). */ + cairo_output_stream_t *final_stream; -cairo_public void -_cairo_ps_test_force_fallbacks (void); + FILE *tmpfile; + cairo_output_stream_t *stream; -CAIRO_END_DECLS + double width; + double height; + double max_width; + double max_height; -#endif /* CAIRO_HAS_PS_SURFACE */ -#endif /* CAIRO_PS_TEST_H */ + int num_pages; + + cairo_paginated_mode_t paginated_mode; + + cairo_bool_t force_fallbacks; + + cairo_scaled_font_subsets_t *font_subsets; + + cairo_array_t dsc_header_comments; + cairo_array_t dsc_setup_comments; + cairo_array_t dsc_page_setup_comments; + + cairo_array_t *dsc_comment_target; +} cairo_ps_surface_t; + +#endif /* CAIRO_PS_SURFACE_PRIVATE_H */ diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 520c404c2..87566d233 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -39,9 +39,9 @@ #include "cairoint.h" #include "cairo-ps.h" -#include "cairo-ps-test.h" +#include "cairo-ps-surface-private.h" #include "cairo-scaled-font-subsets-private.h" -#include "cairo-paginated-surface-private.h" +#include "cairo-paginated-private.h" #include "cairo-meta-surface-private.h" #include "cairo-output-stream-private.h" @@ -52,38 +52,6 @@ static const cairo_surface_backend_t cairo_ps_surface_backend; static const cairo_paginated_surface_backend_t cairo_ps_surface_paginated_backend; -typedef struct cairo_ps_surface { - cairo_surface_t base; - - /* Here final_stream corresponds to the stream/file passed to - * cairo_ps_surface_create surface is built. Meanwhile stream is a - * temporary stream in which the file output is built, (so that - * the header can be built and inserted into the target stream - * before the contents of the temporary stream are copied). */ - cairo_output_stream_t *final_stream; - - FILE *tmpfile; - cairo_output_stream_t *stream; - - double width; - double height; - double max_width; - double max_height; - - int num_pages; - - cairo_paginated_mode_t paginated_mode; - - cairo_scaled_font_subsets_t *font_subsets; - - cairo_array_t dsc_header_comments; - cairo_array_t dsc_setup_comments; - cairo_array_t dsc_page_setup_comments; - - cairo_array_t *dsc_comment_target; - -} cairo_ps_surface_t; - /* A word wrap stream can be used as a filter to do word wrapping on * top of an existing output stream. The word wrapping is quite * simple, using isspace to determine characters that separate @@ -821,6 +789,7 @@ _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream, surface->max_width = width; surface->max_height = height; surface->paginated_mode = CAIRO_PAGINATED_MODE_ANALYZE; + surface->force_fallbacks = FALSE; surface->num_pages = 0; @@ -1383,32 +1352,12 @@ pattern_supported (const cairo_pattern_t *pattern) return FALSE; } -static cairo_bool_t cairo_ps_force_fallbacks = FALSE; - -/** - * _cairo_ps_test_force_fallbacks - * - * Force the PS 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_ps_test_force_fallbacks (void) -{ - cairo_ps_force_fallbacks = TRUE; -} - static cairo_int_status_t _cairo_ps_surface_operation_supported (cairo_ps_surface_t *surface, cairo_operator_t op, const cairo_pattern_t *pattern) { - if (cairo_ps_force_fallbacks) + if (surface->force_fallbacks) return FALSE; if (! pattern_supported (pattern)) @@ -1971,7 +1920,7 @@ _cairo_ps_surface_paint (void *abstract_surface, * possible only because there is nothing between the fallback * images and the paper, nor is anything painted above. */ /* - assert (__cairo_ps_surface_operation_supported (op, source)); + assert (_cairo_ps_surface_operation_supported (op, source)); */ _cairo_output_stream_printf (stream, diff --git a/src/cairo-scaled-font-private.h b/src/cairo-scaled-font-private.h new file mode 100644 index 000000000..6ff416db3 --- /dev/null +++ b/src/cairo-scaled-font-private.h @@ -0,0 +1,112 @@ +/* cairo - a vector graphics library with display and print output + * + * Copyright © 2002 University of Southern California + * Copyright © 2005 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_SCALED_FONT_PRIVATE_H +#define CAIRO_SCALED_FONT_PRIVATE_H + +#include "cairo.h" + +#include "cairo-types-private.h" +#include "cairo-mutex-private.h" + +struct _cairo_scaled_font { + /* For most cairo objects, the rule for multiple threads is that + * the user is responsible for any locking if the same object is + * manipulated from multiple threads simultaneously. + * + * However, with the caching that cairo does for scaled fonts, a + * user can easily end up with the same cairo_scaled_font object + * being manipulated from multiple threads without the user ever + * being aware of this, (and in fact, unable to control it). + * + * So, as a special exception, the cairo implementation takes care + * of all locking needed for cairo_scaled_font_t. Most of what is + * in the scaled font is immutable, (which is what allows for the + * sharing in the first place). The things that are modified and + * the locks protecting them are as follows: + * + * 1. The reference count (scaled_font->ref_count) + * + * Modifications to the reference count are protected by the + * _cairo_scaled_font_map_mutex. This is because the reference + * count of a scaled font is intimately related with the font + * map itself, (and the magic holdovers array). + * + * 2. The cache of glyphs (scaled_font->glyphs) + * 3. The backend private data (scaled_font->surface_backend, + * scaled_font->surface_private) + * + * Modifications to these fields are protected with locks on + * scaled_font->mutex in the generic scaled_font code. + */ + + /* must be first to be stored in a hash table */ + cairo_hash_entry_t hash_entry; + + /* useful bits for _cairo_scaled_font_nil */ + cairo_status_t status; + unsigned int ref_count; + cairo_user_data_array_t user_data; + + /* hash key members */ + cairo_font_face_t *font_face; /* may be NULL */ + cairo_matrix_t font_matrix; /* font space => user space */ + cairo_matrix_t ctm; /* user space => device space */ + cairo_font_options_t options; + + /* "live" scaled_font members */ + cairo_matrix_t scale; /* font space => device space */ + cairo_font_extents_t extents; /* user space */ + + /* The mutex protects modification to all subsequent fields. */ + cairo_mutex_t mutex; + + cairo_cache_t *glyphs; /* glyph index -> cairo_scaled_glyph_t */ + + /* + * One surface backend may store data in each glyph. + * Whichever surface manages to store its pointer here + * first gets to store data in each glyph + */ + const cairo_surface_backend_t *surface_backend; + void *surface_private; + + /* font backend managing this scaled font */ + const cairo_scaled_font_backend_t *backend; +}; + +#endif /* CAIRO_SCALED_FONT_PRIVATE_H */ diff --git a/src/cairo-scaled-font-subsets-private.h b/src/cairo-scaled-font-subsets-private.h index e4e320c71..5b9467a9f 100644 --- a/src/cairo-scaled-font-subsets-private.h +++ b/src/cairo-scaled-font-subsets-private.h @@ -39,8 +39,6 @@ #include "cairoint.h" -typedef struct _cairo_scaled_font_subsets cairo_scaled_font_subsets_t; - typedef struct _cairo_scaled_font_subsets_glyph { unsigned int font_id; unsigned int subset_id; diff --git a/src/cairo-scaled-font-test.h b/src/cairo-scaled-font-test.h deleted file mode 100644 index 03040782f..000000000 --- a/src/cairo-scaled-font-test.h +++ /dev/null @@ -1,49 +0,0 @@ -/* 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_SCALED_FONT_TEST_H -#define CAIRO_SCALED_FONT_TEST_H - -#include - -CAIRO_BEGIN_DECLS - -cairo_public void -_cairo_scaled_font_test_set_max_glyphs_cached_per_font (int max); - -CAIRO_END_DECLS - -#endif /* CAIRO_SCALED_FONT_TEST_H */ diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c index 48d93e44a..e3ad070fa 100644 --- a/src/cairo-scaled-font.c +++ b/src/cairo-scaled-font.c @@ -37,7 +37,7 @@ */ #include "cairoint.h" -#include "cairo-scaled-font-test.h" +#include "cairo-scaled-font-private.h" static cairo_bool_t _cairo_scaled_glyph_keys_equal (const void *abstract_key_a, const void *abstract_key_b) @@ -331,14 +331,7 @@ _cairo_scaled_font_keys_equal (const void *abstract_key_a, const void *abstract_ * separately is probably not what we want anyway. Would probably be * much better to have a single cache for glyphs with random * replacement across all glyphs of all fonts. */ -static int max_glyphs_cached_per_font = 256; - -/* For internal testing purposes only. Not part of the supported API. */ -void -_cairo_scaled_font_test_set_max_glyphs_cached_per_font (int max) -{ - max_glyphs_cached_per_font = max; -} +#define MAX_GLYPHS_CACHED_PER_FONT 256 /* * Basic cairo_scaled_font_t object management @@ -371,7 +364,7 @@ _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font, scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal, _cairo_scaled_glyph_destroy, - max_glyphs_cached_per_font); + MAX_GLYPHS_CACHED_PER_FONT); if (scaled_font->glyphs == NULL) return CAIRO_STATUS_NO_MEMORY; @@ -409,7 +402,7 @@ _cairo_scaled_font_reset_cache (cairo_scaled_font_t *scaled_font) _cairo_cache_destroy (scaled_font->glyphs); scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal, _cairo_scaled_glyph_destroy, - max_glyphs_cached_per_font); + MAX_GLYPHS_CACHED_PER_FONT); } void diff --git a/src/cairo-surface-private.h b/src/cairo-surface-private.h new file mode 100644 index 000000000..6193cf805 --- /dev/null +++ b/src/cairo-surface-private.h @@ -0,0 +1,96 @@ +/* cairo - a vector graphics library with display and print output + * + * Copyright © 2002 University of Southern California + * Copyright © 2005 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_SURFACE_PRIVATE_H +#define CAIRO_SURFACE_PRIVATE_H + +#include "cairo.h" + +#include "cairo-types-private.h" + +struct _cairo_surface { + const cairo_surface_backend_t *backend; + + /* We allow surfaces to override the backend->type by shoving something + * else into surface->type. This is for "wrapper" surfaces that want to + * hide their internal type from the user-level API. */ + cairo_surface_type_t type; + + cairo_content_t content; + + unsigned int ref_count; + cairo_status_t status; + cairo_bool_t finished; + cairo_user_data_array_t user_data; + + cairo_matrix_t device_transform; + cairo_matrix_t device_transform_inverse; + + double x_fallback_resolution; + double y_fallback_resolution; + + cairo_clip_t *clip; + + /* + * Each time a clip region is modified, it gets the next value in this + * sequence. This means that clip regions for this surface are uniquely + * identified and updates to the clip can be readily identified + */ + unsigned int next_clip_serial; + /* + * The serial number of the current clip. This is set when + * the surface clipping is set. The gstate can then cheaply + * check whether the surface clipping is already correct before + * performing a rendering operation. + * + * The special value '0' is reserved for the unclipped case. + */ + unsigned int current_clip_serial; + + /* A "snapshot" surface is immutable. See _cairo_surface_snapshot. */ + cairo_bool_t is_snapshot; + + /* + * Surface font options, falling back to backend's default options, + * and set using _cairo_surface_set_font_options(), and propagated by + * cairo_surface_create_similar(). + */ + cairo_bool_t has_font_options; + cairo_font_options_t font_options; +}; + +#endif /* CAIRO_SURFACE_PRIVATE_H */ diff --git a/src/cairo-pdf-test.h b/src/cairo-svg-surface-private.h similarity index 61% rename from src/cairo-pdf-test.h rename to src/cairo-svg-surface-private.h index 3d14c9d24..c2b2206b3 100644 --- a/src/cairo-pdf-test.h +++ b/src/cairo-svg-surface-private.h @@ -1,6 +1,8 @@ /* cairo - a vector graphics library with display and print output * - * Copyright © 2006 Red Hat, Inc. + * Copyright © 2004 Red Hat, Inc + * Copyright © 2005-2006 Emmanuel Pacaud + * 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 @@ -31,24 +33,41 @@ * California. * * Contributor(s): - * Carl D. Worth + * Kristian Høgsberg + * Emmanuel Pacaud + * Carl Worth */ -#ifndef CAIRO_PDF_TEST_H -#define CAIRO_PDF_TEST_H +#ifndef CAIRO_SVG_SURFACE_PRIVATE_H +#define CAIRO_SVG_SURFACE_PRIVATE_H -#include +#include "cairo-svg.h" -#if CAIRO_HAS_PDF_SURFACE +#include "cairo-surface-private.h" -#include +typedef struct cairo_svg_document cairo_svg_document_t; -CAIRO_BEGIN_DECLS +typedef struct cairo_svg_surface { + cairo_surface_t base; -cairo_public void -_cairo_pdf_test_force_fallbacks (void); + cairo_content_t content; -CAIRO_END_DECLS + unsigned int id; -#endif /* CAIRO_HAS_PDF_SURFACE */ -#endif /* CAIRO_PDF_TEST_H */ + double width; + double height; + + cairo_svg_document_t *document; + + cairo_output_stream_t *xml_node; + cairo_array_t page_set; + + unsigned int clip_level; + unsigned int base_clip; + + cairo_paginated_mode_t paginated_mode; + + cairo_bool_t force_fallbacks; +} cairo_svg_surface_t; + +#endif /* CAIRO_SVG_SURFACE_PRIVATE_H */ diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c index a582de360..e1230c3bd 100644 --- a/src/cairo-svg-surface.c +++ b/src/cairo-svg-surface.c @@ -40,15 +40,13 @@ #include "cairoint.h" #include "cairo-svg.h" -#include "cairo-svg-test.h" +#include "cairo-svg-surface-private.h" #include "cairo-path-fixed-private.h" #include "cairo-meta-surface-private.h" -#include "cairo-paginated-surface-private.h" +#include "cairo-paginated-private.h" #include "cairo-scaled-font-subsets-private.h" #include "cairo-output-stream-private.h" -typedef struct cairo_svg_document cairo_svg_document_t; -typedef struct cairo_svg_surface cairo_svg_surface_t; typedef struct cairo_svg_page cairo_svg_page_t; static const int invalid_pattern_id = -1; @@ -115,27 +113,6 @@ struct cairo_svg_document { cairo_scaled_font_subsets_t *font_subsets; }; -struct cairo_svg_surface { - cairo_surface_t base; - - cairo_content_t content; - - unsigned int id; - - double width; - double height; - - cairo_svg_document_t *document; - - cairo_output_stream_t *xml_node; - cairo_array_t page_set; - - unsigned int clip_level; - unsigned int base_clip; - - cairo_paginated_mode_t paginated_mode; -}; - typedef struct { unsigned int id; cairo_meta_surface_t *meta; @@ -398,6 +375,7 @@ _cairo_svg_surface_create_for_document (cairo_svg_document_t *document, } surface->paginated_mode = CAIRO_PAGINATED_MODE_ANALYZE; + surface->force_fallbacks = FALSE; surface->content = content; return _cairo_paginated_surface_create (&surface->base, @@ -726,26 +704,8 @@ _cairo_svg_document_emit_font_subsets (cairo_svg_document_t *document) static cairo_bool_t cairo_svg_force_fallbacks = FALSE; -/** - * _cairo_svg_test_force_fallbacks - * - * Force the SVG 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_svg_test_force_fallbacks (void) -{ - cairo_svg_force_fallbacks = TRUE; -} - static cairo_int_status_t -__cairo_svg_surface_operation_supported (cairo_svg_surface_t *surface, +_cairo_svg_surface_operation_supported (cairo_svg_surface_t *surface, cairo_operator_t op, const cairo_pattern_t *pattern) { @@ -766,7 +726,7 @@ _cairo_svg_surface_analyze_operation (cairo_svg_surface_t *surface, cairo_operator_t op, const cairo_pattern_t *pattern) { - if (__cairo_svg_surface_operation_supported (surface, op, pattern)) + if (_cairo_svg_surface_operation_supported (surface, op, pattern)) return CAIRO_STATUS_SUCCESS; else return CAIRO_INT_STATUS_UNSUPPORTED; @@ -1659,7 +1619,7 @@ _cairo_svg_surface_fill (void *abstract_surface, if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) return _cairo_svg_surface_analyze_operation (surface, op, source); - assert (__cairo_svg_surface_operation_supported (surface, op, source)); + assert (_cairo_svg_surface_operation_supported (surface, op, source)); _cairo_output_stream_printf (surface->xml_node, "paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) return _cairo_svg_surface_analyze_operation (surface, op, source); - assert (__cairo_svg_surface_operation_supported (surface, op, source)); + assert (_cairo_svg_surface_operation_supported (surface, op, source)); _cairo_svg_surface_emit_alpha_filter (document); @@ -1852,7 +1812,7 @@ _cairo_svg_surface_stroke (void *abstract_dst, if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) return _cairo_svg_surface_analyze_operation (surface, op, source); - assert (__cairo_svg_surface_operation_supported (surface, op, source)); + assert (_cairo_svg_surface_operation_supported (surface, op, source)); switch (stroke_style->line_cap) { case CAIRO_LINE_CAP_BUTT: @@ -1940,7 +1900,7 @@ _cairo_svg_surface_show_glyphs (void *abstract_surface, if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) return _cairo_svg_surface_analyze_operation (surface, op, pattern); - assert (__cairo_svg_surface_operation_supported (surface, op, pattern)); + assert (_cairo_svg_surface_operation_supported (surface, op, pattern)); if (num_glyphs <= 0) return CAIRO_STATUS_SUCCESS; diff --git a/src/cairo-svg-test.h b/src/cairo-svg-test.h deleted file mode 100644 index 396d45977..000000000 --- a/src/cairo-svg-test.h +++ /dev/null @@ -1,54 +0,0 @@ -/* 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_SVG_TEST_H -#define CAIRO_SVG_TEST_H - -#include - -#if CAIRO_HAS_SVG_SURFACE - -#include - -CAIRO_BEGIN_DECLS - -cairo_public void -_cairo_svg_test_force_fallbacks (void); - -CAIRO_END_DECLS - -#endif /* CAIRO_HAS_SVG_SURFACE */ -#endif /* CAIRO_SVG_TEST_H */ diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h new file mode 100644 index 000000000..37b131e13 --- /dev/null +++ b/src/cairo-types-private.h @@ -0,0 +1,128 @@ +/* cairo - a vector graphics library with display and print output + * + * Copyright © 2002 University of Southern California + * Copyright © 2005 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_TYPES_PRIVATE_H +#define CAIRO_TYPES_PRIVATE_H + +typedef struct _cairo_array cairo_array_t; +struct _cairo_array { + unsigned int size; + unsigned int num_elements; + unsigned int element_size; + char **elements; + + cairo_bool_t is_snapshot; +}; + +typedef cairo_array_t cairo_user_data_array_t; + +struct _cairo_font_options { + cairo_antialias_t antialias; + cairo_subpixel_order_t subpixel_order; + cairo_hint_style_t hint_style; + cairo_hint_metrics_t hint_metrics; +}; + +typedef struct _cairo_hash_table cairo_hash_table_t; + +typedef struct _cairo_cache { + cairo_hash_table_t *hash_table; + + cairo_destroy_func_t entry_destroy; + + unsigned long max_size; + unsigned long size; + + int freeze_count; +} cairo_cache_t; + +/** + * cairo_hash_entry_t: + * + * A #cairo_hash_entry_t contains both a key and a value for + * cairo_hash_table_t. User-derived types for cairo_hash_entry_t must + * be type-compatible with this structure (eg. they must have an + * unsigned long as the first parameter. The easiest way to get this + * is to use: + * + * typedef _my_entry { + * cairo_hash_entry_t base; + * ... Remainder of key and value fields here .. + * } my_entry_t; + * + * which then allows a pointer to my_entry_t to be passed to any of + * the cairo_hash_table functions as follows without requiring a cast: + * + * _cairo_hash_table_insert (hash_table, &my_entry->base); + * + * IMPORTANT: The caller is reponsible for initializing + * my_entry->base.hash with a hash code derived from the key. The + * essential property of the hash code is that keys_equal must never + * return TRUE for two keys that have different hashes. The best hash + * code will reduce the frequency of two keys with the same code for + * which keys_equal returns FALSE. + * + * Which parts of the entry make up the "key" and which part make up + * the value are entirely up to the caller, (as determined by the + * computation going into base.hash as well as the keys_equal + * function). A few of the cairo_hash_table functions accept an entry + * which will be used exclusively as a "key", (indicated by a + * parameter name of key). In these cases, the value-related fields of + * the entry need not be initialized if so desired. + **/ +typedef struct _cairo_hash_entry { + unsigned long hash; +} cairo_hash_entry_t; + + +typedef struct _cairo_surface_backend cairo_surface_backend_t; +typedef struct _cairo_clip cairo_clip_t; +typedef struct _cairo_output_stream cairo_output_stream_t; +typedef struct _cairo_scaled_font_subsets cairo_scaled_font_subsets_t; +typedef struct _cairo_paginated_surface_backend cairo_paginated_surface_backend_t; +typedef struct _cairo_scaled_font_backend cairo_scaled_font_backend_t; +typedef struct _cairo_font_face_backend cairo_font_face_backend_t; + + +typedef struct _cairo_xlib_screen_info cairo_xlib_screen_info_t; + +typedef enum { + CAIRO_PAGINATED_MODE_ANALYZE, /* analyze page regions */ + CAIRO_PAGINATED_MODE_RENDER /* render page contents */ +} cairo_paginated_mode_t; + +#endif /* CAIRO_TYPES_PRIVATE_H */ diff --git a/src/cairo-xlib-private.h b/src/cairo-xlib-private.h index e71534380..1fd47fa71 100644 --- a/src/cairo-xlib-private.h +++ b/src/cairo-xlib-private.h @@ -36,7 +36,6 @@ #include "cairoint.h" #include "cairo-xlib.h" -typedef struct _cairo_xlib_screen_info cairo_xlib_screen_info_t; typedef struct _cairo_xlib_hook cairo_xlib_hook_t; struct _cairo_xlib_hook { diff --git a/src/cairo-xlib-surface-private.h b/src/cairo-xlib-surface-private.h new file mode 100644 index 000000000..15724d347 --- /dev/null +++ b/src/cairo-xlib-surface-private.h @@ -0,0 +1,93 @@ +/* Cairo - a vector graphics library with display and print output + * + * Copyright © 2005 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 Red Hat, Inc. + */ + +#ifndef CAIRO_XLIB_SURFACE_PRIVATE_H +#define CAIRO_XLIB_SURFACE_PRIVATE_H + +#include "cairo-xlib.h" + +#include "cairo-surface-private.h" + +typedef struct _cairo_xlib_surface cairo_xlib_surface_t; + +struct _cairo_xlib_surface { + cairo_surface_t base; + + Display *dpy; + cairo_xlib_screen_info_t *screen_info; + + GC gc; + Drawable drawable; + Screen *screen; + cairo_bool_t owns_pixmap; + Visual *visual; + + int use_pixmap; + + int render_major; + int render_minor; + + /* TRUE if the server has a bug with repeating pictures + * + * https://bugs.freedesktop.org/show_bug.cgi?id=3566 + * + * We can't test for this because it depends on whether the + * picture is in video memory or not. + * + * We also use this variable as a guard against a second + * independent bug with transformed repeating pictures: + * + * http://lists.freedesktop.org/archives/cairo/2004-September/001839.html + * + * Both are fixed in xorg >= 6.9 and hopefully in > 6.8.2, so + * we can reuse the test for now. + */ + cairo_bool_t buggy_repeat; + + int width; + int height; + int depth; + + Picture dst_picture, src_picture; + + cairo_bool_t have_clip_rects; + XRectangle embedded_clip_rects[4]; + XRectangle *clip_rects; + int num_clip_rects; + + XRenderPictFormat *xrender_format; + cairo_filter_t filter; + int repeat; + XTransform xtransform; +}; + +#endif /* CAIRO_XLIB_SURFACE_PRIVATE_H */ diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 4d53bdb1b..8d9d1073b 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -39,8 +39,8 @@ #include "cairoint.h" #include "cairo-xlib.h" #include "cairo-xlib-xrender.h" -#include "cairo-xlib-test.h" #include "cairo-xlib-private.h" +#include "cairo-xlib-surface-private.h" #include "cairo-clip-private.h" #include #include @@ -49,8 +49,6 @@ typedef int (*cairo_xlib_error_func_t) (Display *display, XErrorEvent *event); -typedef struct _cairo_xlib_surface cairo_xlib_surface_t; - static cairo_status_t _cairo_xlib_surface_ensure_gc (cairo_xlib_surface_t *surface); @@ -82,57 +80,6 @@ _cairo_xlib_surface_show_glyphs (void *abstract_dst, #define CAIRO_ASSUME_PIXMAP 20 -struct _cairo_xlib_surface { - cairo_surface_t base; - - Display *dpy; - cairo_xlib_screen_info_t *screen_info; - - GC gc; - Drawable drawable; - Screen *screen; - cairo_bool_t owns_pixmap; - Visual *visual; - - int use_pixmap; - - int render_major; - int render_minor; - - /* TRUE if the server has a bug with repeating pictures - * - * https://bugs.freedesktop.org/show_bug.cgi?id=3566 - * - * We can't test for this because it depends on whether the - * picture is in video memory or not. - * - * We also use this variable as a guard against a second - * independent bug with transformed repeating pictures: - * - * http://lists.freedesktop.org/archives/cairo/2004-September/001839.html - * - * Both are fixed in xorg >= 6.9 and hopefully in > 6.8.2, so - * we can reuse the test for now. - */ - cairo_bool_t buggy_repeat; - - int width; - int height; - int depth; - - Picture dst_picture, src_picture; - - cairo_bool_t have_clip_rects; - XRectangle embedded_clip_rects[4]; - XRectangle *clip_rects; - int num_clip_rects; - - XRenderPictFormat *xrender_format; - cairo_filter_t filter; - int repeat; - XTransform xtransform; -}; - static const XTransform identity = { { { 1 << 16, 0x00000, 0x00000 }, { 0x00000, 1 << 16, 0x00000 }, @@ -161,25 +108,6 @@ static const XTransform identity = { { #define CAIRO_SURFACE_RENDER_HAS_PICTURE_TRANSFORM(surface) CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 6) #define CAIRO_SURFACE_RENDER_HAS_FILTERS(surface) CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 6) -static cairo_bool_t cairo_xlib_render_disabled = FALSE; - -/** - * _cairo_xlib_test_disable_render: - * - * Disables the use of the RENDER extension. - * - * - * This function is only intended for internal - * testing use within the cairo distribution. It is not installed in - * any public header file. - * - **/ -void -_cairo_xlib_test_disable_render (void) -{ - cairo_xlib_render_disabled = TRUE; -} - static int _CAIRO_FORMAT_DEPTH (cairo_format_t format) { @@ -1900,8 +1828,7 @@ _cairo_xlib_surface_create_internal (Display *dpy, ; } - if (cairo_xlib_render_disabled || - ! XRenderQueryVersion (dpy, &surface->render_major, &surface->render_minor)) { + if (! XRenderQueryVersion (dpy, &surface->render_major, &surface->render_minor)) { surface->render_major = -1; surface->render_minor = -1; } diff --git a/src/cairoint.h b/src/cairoint.h index 549cc5113..eba739848 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -244,6 +244,7 @@ be32_to_cpu(uint32_t v) #endif +#include "cairo-types-private.h" #include "cairo-hash-private.h" #include "cairo-cache-private.h" @@ -348,7 +349,6 @@ typedef enum _cairo_clip_mode { CAIRO_CLIP_MODE_MASK } cairo_clip_mode_t; typedef struct _cairo_clip_path cairo_clip_path_t; -typedef struct _cairo_clip cairo_clip_t; typedef struct _cairo_edge { cairo_line_t edge; @@ -400,8 +400,6 @@ typedef struct _cairo_pen { typedef struct _cairo_color cairo_color_t; typedef struct _cairo_image_surface cairo_image_surface_t; -typedef struct _cairo_surface_backend cairo_surface_backend_t; - cairo_private void _cairo_box_round_to_rectangle (cairo_box_t *box, cairo_rectangle_int16_t *rectangle); @@ -410,16 +408,6 @@ _cairo_rectangle_intersect (cairo_rectangle_int16_t *dest, cairo_rectangle_int16 /* cairo_array.c structures and functions */ -typedef struct _cairo_array cairo_array_t; -struct _cairo_array { - unsigned int size; - unsigned int num_elements; - unsigned int element_size; - char **elements; - - cairo_bool_t is_snapshot; -}; - cairo_private void _cairo_array_init (cairo_array_t *array, int element_size); @@ -461,8 +449,6 @@ _cairo_array_num_elements (cairo_array_t *array); cairo_private int _cairo_array_size (cairo_array_t *array); -typedef cairo_array_t cairo_user_data_array_t; - cairo_private void _cairo_user_data_array_init (cairo_user_data_array_t *array); @@ -483,8 +469,6 @@ cairo_private unsigned long _cairo_hash_string (const char *c); typedef struct _cairo_unscaled_font_backend cairo_unscaled_font_backend_t; -typedef struct _cairo_scaled_font_backend cairo_scaled_font_backend_t; -typedef struct _cairo_font_face_backend cairo_font_face_backend_t; /* * A cairo_unscaled_font_t is just an opaque handle we use in the @@ -496,13 +480,6 @@ typedef struct _cairo_unscaled_font { const cairo_unscaled_font_backend_t *backend; } cairo_unscaled_font_t; -struct _cairo_font_options { - cairo_antialias_t antialias; - cairo_subpixel_order_t subpixel_order; - cairo_hint_style_t hint_style; - cairo_hint_metrics_t hint_metrics; -}; - typedef struct _cairo_scaled_glyph { cairo_cache_entry_t cache_entry; /* hash is glyph index */ cairo_scaled_font_t *scaled_font; /* font the glyph lives in */ @@ -518,71 +495,7 @@ typedef struct _cairo_scaled_glyph { #define _cairo_scaled_glyph_index(g) ((g)->cache_entry.hash) #define _cairo_scaled_glyph_set_index(g,i) ((g)->cache_entry.hash = (i)) -struct _cairo_scaled_font { - /* For most cairo objects, the rule for multiple threads is that - * the user is responsible for any locking if the same object is - * manipulated from multiple threads simultaneously. - * - * However, with the caching that cairo does for scaled fonts, a - * user can easily end up with the same cairo_scaled_font object - * being manipulated from multiple threads without the user ever - * being aware of this, (and in fact, unable to control it). - * - * So, as a special exception, the cairo implementation takes care - * of all locking needed for cairo_scaled_font_t. Most of what is - * in the scaled font is immutable, (which is what allows for the - * sharing in the first place). The things that are modified and - * the locks protecting them are as follows: - * - * 1. The reference count (scaled_font->ref_count) - * - * Modifications to the reference count are protected by the - * _cairo_scaled_font_map_mutex. This is because the reference - * count of a scaled font is intimately related with the font - * map itself, (and the magic holdovers array). - * - * 2. The cache of glyphs (scaled_font->glyphs) - * 3. The backend private data (scaled_font->surface_backend, - * scaled_font->surface_private) - * - * Modifications to these fields are protected with locks on - * scaled_font->mutex in the generic scaled_font code. - */ - - /* must be first to be stored in a hash table */ - cairo_hash_entry_t hash_entry; - - /* useful bits for _cairo_scaled_font_nil */ - cairo_status_t status; - unsigned int ref_count; - cairo_user_data_array_t user_data; - - /* hash key members */ - cairo_font_face_t *font_face; /* may be NULL */ - cairo_matrix_t font_matrix; /* font space => user space */ - cairo_matrix_t ctm; /* user space => device space */ - cairo_font_options_t options; - - /* "live" scaled_font members */ - cairo_matrix_t scale; /* font space => device space */ - cairo_font_extents_t extents; /* user space */ - - /* The mutex protects modification to all subsequent fields. */ - cairo_mutex_t mutex; - - cairo_cache_t *glyphs; /* glyph index -> cairo_scaled_glyph_t */ - - /* - * One surface backend may store data in each glyph. - * Whichever surface manages to store its pointer here - * first gets to store data in each glyph - */ - const cairo_surface_backend_t *surface_backend; - void *surface_private; - - /* font backend managing this scaled font */ - const cairo_scaled_font_backend_t *backend; -}; +#include "cairo-scaled-font-private.h" struct _cairo_font_face { /* hash_entry must be first */ @@ -993,56 +906,7 @@ typedef struct _cairo_format_masks { unsigned long blue_mask; } cairo_format_masks_t; -struct _cairo_surface { - const cairo_surface_backend_t *backend; - - /* We allow surfaces to override the backend->type by shoving something - * else into surface->type. This is for "wrapper" surfaces that want to - * hide their internal type from the user-level API. */ - cairo_surface_type_t type; - - cairo_content_t content; - - unsigned int ref_count; - cairo_status_t status; - cairo_bool_t finished; - cairo_user_data_array_t user_data; - - cairo_matrix_t device_transform; - cairo_matrix_t device_transform_inverse; - - double x_fallback_resolution; - double y_fallback_resolution; - - cairo_clip_t *clip; - - /* - * Each time a clip region is modified, it gets the next value in this - * sequence. This means that clip regions for this surface are uniquely - * identified and updates to the clip can be readily identified - */ - unsigned int next_clip_serial; - /* - * The serial number of the current clip. This is set when - * the surface clipping is set. The gstate can then cheaply - * check whether the surface clipping is already correct before - * performing a rendering operation. - * - * The special value '0' is reserved for the unclipped case. - */ - unsigned int current_clip_serial; - - /* A "snapshot" surface is immutable. See _cairo_surface_snapshot. */ - cairo_bool_t is_snapshot; - - /* - * Surface font options, falling back to backend's default options, - * and set using _cairo_surface_set_font_options(), and propagated by - * cairo_surface_create_similar(). - */ - cairo_bool_t has_font_options; - cairo_font_options_t font_options; -}; +#include "cairo-surface-private.h" struct _cairo_image_surface { cairo_surface_t base; diff --git a/src/check-def.sh b/src/check-def.sh index 0b8e66532..235263d04 100755 --- a/src/check-def.sh +++ b/src/check-def.sh @@ -27,7 +27,7 @@ for def in $defs; do { echo EXPORTS - eval $get_cairo_syms | grep -v '^_cairo_.*test_\|^_fini\|^_init' | sort -u + eval $get_cairo_syms | grep -v '^_cairo_test_\|^_fini\|^_init' | sort -u # cheat: copy the last line from the def file! tail -n1 $def } | diff $def - || status=1 diff --git a/src/test-paginated-surface.c b/src/test-paginated-surface.c index 543422f87..53e97eba6 100644 --- a/src/test-paginated-surface.c +++ b/src/test-paginated-surface.c @@ -49,7 +49,7 @@ #include "test-paginated-surface.h" -#include "cairo-paginated-surface-private.h" +#include "cairo-paginated-private.h" typedef struct _test_paginated_surface { cairo_surface_t base; diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c index b8d7e04fb..37fd59199 100644 --- a/test/fallback-resolution.c +++ b/test/fallback-resolution.c @@ -27,13 +27,13 @@ #include #include -#include +#include #include -#include +#include #include -#include +#include #include "cairo-test.h" @@ -103,18 +103,18 @@ main (void) case PDF: surface = cairo_pdf_surface_create (backend_filename[backend], SIZE, SIZE); - _cairo_pdf_test_force_fallbacks (); + cairo_boilerplate_pdf_surface_force_fallbacks (surface); break; case PS: surface = cairo_ps_surface_create (backend_filename[backend], SIZE, SIZE); - _cairo_ps_test_force_fallbacks (); + cairo_boilerplate_ps_surface_force_fallbacks (surface); break; case SVG: surface = cairo_svg_surface_create (backend_filename[backend], SIZE, SIZE); + cairo_boilerplate_svg_surface_force_fallbacks (surface); cairo_svg_surface_restrict_to_version (surface, CAIRO_SVG_VERSION_1_2); - _cairo_svg_test_force_fallbacks (); break; } diff --git a/test/glyph-cache-pressure.c b/test/glyph-cache-pressure.c index ba90fa362..72044ee63 100644 --- a/test/glyph-cache-pressure.c +++ b/test/glyph-cache-pressure.c @@ -24,7 +24,7 @@ */ #include "cairo-test.h" -#include "cairo-scaled-font-test.h" +#include "cairo-boilerplate-scaled-font.h" #define TEXT_SIZE 12 @@ -67,8 +67,6 @@ draw (cairo_t *cr, int width, int height) cairo_paint (cr); cairo_restore (cr); - _cairo_scaled_font_test_set_max_glyphs_cached_per_font (1); - cairo_select_font_face (cr, "Bitstream Vera Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); @@ -76,6 +74,8 @@ draw (cairo_t *cr, int width, int height) cairo_set_source_rgb (cr, 0, 0, 0); /* black */ + cairo_boilerplate_scaled_font_set_max_glyphs_cached (cairo_get_scaled_font (cr), 1); + cairo_move_to (cr, 1, TEXT_SIZE); cairo_show_text (cr, "the five boxing wizards jump quickly"); diff --git a/test/xlib-surface.c b/test/xlib-surface.c index 3b6d1b503..a1578cdb3 100644 --- a/test/xlib-surface.c +++ b/test/xlib-surface.c @@ -30,7 +30,8 @@ #include "cairo-xlib.h" #include "cairo-xlib-xrender.h" #include "cairo-test.h" -#include "cairo-xlib-test.h" + +#include "cairo-boilerplate-xlib.h" #include "buffer-diff.h" @@ -123,6 +124,9 @@ do_test (Display *dpy, DefaultVisual (dpy, screen), SIZE, SIZE); + if (!use_render) + cairo_boilerplate_xlib_surface_disable_render (surface); + if (set_size) { cairo_xlib_surface_set_size (surface, SIZE, SIZE); @@ -257,8 +261,6 @@ main (void) result = status; } - _cairo_xlib_test_disable_render (); - for (set_size = 0; set_size <= 1; set_size++) for (use_pixmap = 0; use_pixmap <= 1; use_pixmap++) for (offscreen = 0; offscreen <= 1; offscreen++) {