New PDF backend.

Add PDF surface constructors.
New file - generic array implementation.
Add cairo_array prototypes.
Add cairo_array.c and cairo_pdf_surface.c.
This commit is contained in:
Kristian Høgsberg 2005-01-05 14:29:31 +00:00
parent c90bd12ec7
commit b1ec8ae13e
12 changed files with 2985 additions and 0 deletions

View file

@ -7,6 +7,7 @@ Richard Henderson <rth@twiddle.net> "slim" macros for better shared libraries
James Henstridge <james@daa.com.au> Build fixes related to freetype
Graydon Hoare <graydon@redhat.com> Support for non-render X server, first real text support
Thomas Hunger <info@teh-web.de> Initial version of cairo_in_stroke/fill
Kristian Høgsberg <krh@redhat.com> PDF backend
Alexander Larsson <alexl@redhat.com> Profiling and performance fixes.
Jordi Mas <jordi@ximian.com> Bug fix for cairo_show_text
Keith Packard <keithp@keithp.com> Original concept, polygon tessellation, dashing

View file

@ -1,3 +1,11 @@
2005-01-05 Kristian Høgsberg <krh@redhat.com>
* src/cairo_pdf_surface.c: New PDF backend.
* src/cairo.h: Add PDF surface constructors.
* src/cairo_array.c: New file - generic array implementation.
* src/cairoint.h: Add cairo_array prototypes.
* src/Makefile.am (libcairo_la_SOURCES): Add cairo_array.c and cairo_pdf_surface.c.
2004-12-23 Carl Worth <cworth@cworth.org>
* src/cairo_traps.c: Remove unused CAIRO_TRAPS_GROWTH_INC.

View file

@ -112,6 +112,22 @@ AC_SUBST(PS_LIBS)
dnl ===========================================================================
AC_ARG_ENABLE(pdf,
[ --disable-pdf Disable cairo's PDF backend],
[use_pdf=$enableval], [use_pdf=yes])
if test "x$use_pdf" != "xyes"; then
PDF_SURFACE_FEATURE=CAIRO_HAS_NO_PDF_SURFACE
AM_CONDITIONAL(CAIRO_HAS_PDF_SURFACE, false)
else
PDF_SURFACE_FEATURE=CAIRO_HAS_PDF_SURFACE
AM_CONDITIONAL(CAIRO_HAS_PDF_SURFACE, true)
fi
AC_SUBST(PDF_SURFACE_FEATURE)
dnl ===========================================================================
AC_ARG_ENABLE(png,
[ --disable-png Disable cairo's PNG backend],
[use_png=$enableval], [use_png=yes])
@ -270,6 +286,7 @@ echo "cairo will be compiled with the following backends:"
echo " Xlib: $use_xlib"
echo " XCB: $use_xcb"
echo " PostScript: $use_ps"
echo " PDF: $use_pdf"
echo " PNG: $use_png"
echo " glitz: $use_glitz"
echo ""

View file

@ -5,6 +5,10 @@ if CAIRO_HAS_PS_SURFACE
libcairo_ps_sources = cairo_ps_surface.c
endif
if CAIRO_HAS_PDF_SURFACE
libcairo_pdf_sources = cairo_pdf_surface.c
endif
if CAIRO_HAS_PNG_SURFACE
libcairo_png_sources = cairo_png_surface.c
endif
@ -31,6 +35,7 @@ XRENDER_LIBS=@XRENDER_LIBS@
libcairo_la_SOURCES = \
cairo.c \
cairo.h \
cairo_array.c \
cairo_cache.c \
cairo_color.c \
cairo_fixed.c \
@ -54,6 +59,7 @@ libcairo_la_SOURCES = \
cairo_wideint.c \
cairo_wideint.h \
$(libcairo_ps_sources) \
$(libcairo_pdf_sources) \
$(libcairo_png_sources) \
$(libcairo_xlib_sources)\
$(libcairo_xcb_sources) \

130
src/cairo-array.c Normal file
View file

@ -0,0 +1,130 @@
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2004 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):
* Kristian Høgsberg <krh@redhat.com>
*/
#include "cairoint.h"
void
_cairo_array_init (cairo_array_t *array, int element_size)
{
array->size = 0;
array->num_elements = 0;
array->element_size = element_size;
array->elements = NULL;
}
void
_cairo_array_fini (cairo_array_t *array)
{
free (array->elements);
}
cairo_status_t
_cairo_array_grow_by (cairo_array_t *array, int additional)
{
char *new_elements;
int old_size = array->size;
int required_size = array->num_elements + additional;
int new_size;
if (required_size <= old_size)
return CAIRO_STATUS_SUCCESS;
if (old_size == 0)
new_size = 1;
else
new_size = old_size * 2;
while (new_size < required_size)
new_size = old_size * 2;
array->size = new_size;
new_elements = realloc (array->elements,
array->size * array->element_size);
if (new_elements == NULL) {
array->size = old_size;
return CAIRO_STATUS_NO_MEMORY;
}
array->elements = new_elements;
return CAIRO_STATUS_SUCCESS;
}
void
_cairo_array_truncate (cairo_array_t *array, int num_elements)
{
if (num_elements < array->num_elements)
array->num_elements = num_elements;
}
void *
_cairo_array_index (cairo_array_t *array, int index)
{
assert (0 <= index && index < array->num_elements);
return (void *) &array->elements[index * array->element_size];
}
void
_cairo_array_copy_element (cairo_array_t *array, int index, void *dst)
{
memcpy (dst, _cairo_array_index (array, index), array->element_size);
}
cairo_status_t
_cairo_array_append (cairo_array_t *array, void *elements, int num_elements)
{
cairo_status_t status;
status = _cairo_array_grow_by (array, num_elements);
if (status != CAIRO_STATUS_SUCCESS)
return status;
assert (array->num_elements + num_elements <= array->size);
memcpy (&array->elements[array->num_elements * array->element_size],
elements, num_elements * array->element_size);
array->num_elements += num_elements;
return CAIRO_STATUS_SUCCESS;
}
int
_cairo_array_num_elements (cairo_array_t *array)
{
return array->num_elements;
}

View file

@ -39,6 +39,8 @@
#define @PS_SURFACE_FEATURE@
#define @PDF_SURFACE_FEATURE@
#define @PNG_SURFACE_FEATURE@
#define @XLIB_SURFACE_FEATURE@

1314
src/cairo-pdf-surface.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -112,6 +112,20 @@ cairo_set_target_ps (cairo_t *cr,
#endif /* CAIRO_HAS_PS_SURFACE */
#ifdef CAIRO_HAS_PDF_SURFACE
#include <stdio.h>
void
cairo_set_target_pdf (cairo_t *cr,
FILE *file,
double width_inches,
double height_inches,
double x_pixels_per_inch,
double y_pixels_per_inch);
#endif /* CAIRO_HAS_PDF_SURFACE */
#ifdef CAIRO_HAS_PNG_SURFACE
#include <stdio.h>
@ -748,6 +762,17 @@ cairo_ps_surface_create (FILE *file,
#endif /* CAIRO_HAS_PS_SURFACE */
#ifdef CAIRO_HAS_PDF_SURFACE
cairo_surface_t *
cairo_pdf_surface_create (FILE *file,
double width_inches,
double height_inches,
double x_pixels_per_inch,
double y_pixels_per_inch);
#endif /* CAIRO_HAS_PDF_SURFACE */
#ifdef CAIRO_HAS_PNG_SURFACE
/* PNG-surface functions */

130
src/cairo_array.c Normal file
View file

@ -0,0 +1,130 @@
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2004 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):
* Kristian Høgsberg <krh@redhat.com>
*/
#include "cairoint.h"
void
_cairo_array_init (cairo_array_t *array, int element_size)
{
array->size = 0;
array->num_elements = 0;
array->element_size = element_size;
array->elements = NULL;
}
void
_cairo_array_fini (cairo_array_t *array)
{
free (array->elements);
}
cairo_status_t
_cairo_array_grow_by (cairo_array_t *array, int additional)
{
char *new_elements;
int old_size = array->size;
int required_size = array->num_elements + additional;
int new_size;
if (required_size <= old_size)
return CAIRO_STATUS_SUCCESS;
if (old_size == 0)
new_size = 1;
else
new_size = old_size * 2;
while (new_size < required_size)
new_size = old_size * 2;
array->size = new_size;
new_elements = realloc (array->elements,
array->size * array->element_size);
if (new_elements == NULL) {
array->size = old_size;
return CAIRO_STATUS_NO_MEMORY;
}
array->elements = new_elements;
return CAIRO_STATUS_SUCCESS;
}
void
_cairo_array_truncate (cairo_array_t *array, int num_elements)
{
if (num_elements < array->num_elements)
array->num_elements = num_elements;
}
void *
_cairo_array_index (cairo_array_t *array, int index)
{
assert (0 <= index && index < array->num_elements);
return (void *) &array->elements[index * array->element_size];
}
void
_cairo_array_copy_element (cairo_array_t *array, int index, void *dst)
{
memcpy (dst, _cairo_array_index (array, index), array->element_size);
}
cairo_status_t
_cairo_array_append (cairo_array_t *array, void *elements, int num_elements)
{
cairo_status_t status;
status = _cairo_array_grow_by (array, num_elements);
if (status != CAIRO_STATUS_SUCCESS)
return status;
assert (array->num_elements + num_elements <= array->size);
memcpy (&array->elements[array->num_elements * array->element_size],
elements, num_elements * array->element_size);
array->num_elements += num_elements;
return CAIRO_STATUS_SUCCESS;
}
int
_cairo_array_num_elements (cairo_array_t *array)
{
return array->num_elements;
}

View file

@ -53,6 +53,10 @@ extern "C" {
#pragma comment(linker, "/EXPORT:_cairo_set_target_ps")
#endif
#ifdef CAIRO_HAS_PS_SURFACE
#pragma comment(linker, "/EXPORT:_cairo_set_target_pdf")
#endif
#ifdef CAIRO_HAS_PNG_SURFACE
#pragma comment(linker, "/EXPORT:_cairo_set_target_png")
#endif

1314
src/cairo_pdf_surface.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -254,6 +254,40 @@ typedef struct cairo_pen {
typedef struct cairo_color cairo_color_t;
typedef struct cairo_image_surface cairo_image_surface_t;
/* cairo_array.c structures and functions */
typedef struct cairo_array cairo_array_t;
struct cairo_array {
int size;
int num_elements;
int element_size;
char *elements;
};
cairo_private void
_cairo_array_init (cairo_array_t *array, int element_size);
cairo_private void
_cairo_array_fini (cairo_array_t *array);
cairo_private cairo_status_t
_cairo_array_grow_by (cairo_array_t *array, int additional);
cairo_private void
_cairo_array_truncate (cairo_array_t *array, int length);
cairo_private cairo_status_t
_cairo_array_append (cairo_array_t *array, void *elements, int num_elements);
cairo_private void *
_cairo_array_index (cairo_array_t *array, int index);
cairo_private void
_cairo_array_copy_element (cairo_array_t *array, int index, void *dst);
cairo_private int
_cairo_array_num_elements (cairo_array_t *array);
/* cairo_cache.c structures and functions */
typedef struct cairo_cache_backend {