mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-06-08 16:18:22 +02:00
Merge branch 'svg-rewrite'
This commit is contained in:
commit
2cea3a2710
10 changed files with 822 additions and 857 deletions
14
configure.in
14
configure.in
|
|
@ -545,17 +545,6 @@ CAIRO_BACKEND_ENABLE(svg, SVG, auto, svg, [], [
|
|||
fi
|
||||
])
|
||||
|
||||
if test "x$use_svg" = "xyes" ; then
|
||||
use_svg="no (SVG backend requires libxml2)"
|
||||
if $PKG_CONFIG --exists libxml-2.0 ; then
|
||||
# Sets XML_CFLAGS, XML_LIBS
|
||||
PKG_CHECK_MODULES(XML, libxml-2.0)
|
||||
use_svg=yes
|
||||
else
|
||||
AC_MSG_WARN([SVG requires libxml2, which is not found in pkg-config search path, disabling])
|
||||
fi
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(CAIRO_HAS_SVG_SURFACE, test "x$use_svg" = "xyes")
|
||||
if test "x$use_svg" = "xyes"; then
|
||||
SVG_SURFACE_FEATURE="#define CAIRO_HAS_SVG_SURFACE 1"
|
||||
|
|
@ -572,9 +561,6 @@ AM_CONDITIONAL(CAIRO_CAN_TEST_SVG_SURFACE, test "x$test_svg" = "xyes")
|
|||
AC_SUBST(LIBRSVG_CFLAGS)
|
||||
AC_SUBST(LIBRSVG_LIBS)
|
||||
|
||||
CAIRO_CFLAGS="$CAIRO_CFLAGS $XML_CFLAGS"
|
||||
CAIRO_LIBS="$CAIRO_LIBS $XML_LIBS"
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
dnl This check should default to 'yes' once we have code to actually
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@
|
|||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-output-stream-private.h"
|
||||
|
||||
typedef struct _cairo_base85_stream {
|
||||
cairo_output_stream_t base;
|
||||
cairo_output_stream_t *output;
|
||||
unsigned char four_tuple[4];
|
||||
int pending;
|
||||
|
|
@ -63,11 +65,11 @@ _expand_four_tuple_to_five (unsigned char four_tuple[4],
|
|||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_base85_stream_write (void *closure,
|
||||
const unsigned char *data,
|
||||
unsigned int length)
|
||||
_cairo_base85_stream_write (cairo_output_stream_t *base,
|
||||
const unsigned char *data,
|
||||
unsigned int length)
|
||||
{
|
||||
cairo_base85_stream_t *stream = closure;
|
||||
cairo_base85_stream_t *stream = (cairo_base85_stream_t *) base;
|
||||
const unsigned char *ptr = data;
|
||||
unsigned char five_tuple[5];
|
||||
cairo_bool_t is_zero;
|
||||
|
|
@ -89,10 +91,9 @@ _cairo_base85_stream_write (void *closure,
|
|||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_base85_stream_close (void *closure)
|
||||
_cairo_base85_stream_close (cairo_output_stream_t *base)
|
||||
{
|
||||
cairo_status_t status;
|
||||
cairo_base85_stream_t *stream = closure;
|
||||
cairo_base85_stream_t *stream = (cairo_base85_stream_t *) base;
|
||||
unsigned char five_tuple[5];
|
||||
|
||||
if (stream->pending) {
|
||||
|
|
@ -104,11 +105,7 @@ _cairo_base85_stream_close (void *closure)
|
|||
/* Mark end of base85 data */
|
||||
_cairo_output_stream_printf (stream->output, "~>");
|
||||
|
||||
status = _cairo_output_stream_get_status (stream->output);
|
||||
|
||||
free (stream);
|
||||
|
||||
return status;
|
||||
return _cairo_output_stream_get_status (stream->output);
|
||||
}
|
||||
|
||||
cairo_output_stream_t *
|
||||
|
|
@ -120,10 +117,11 @@ _cairo_base85_stream_create (cairo_output_stream_t *output)
|
|||
if (stream == NULL)
|
||||
return (cairo_output_stream_t *) &cairo_output_stream_nil;
|
||||
|
||||
_cairo_output_stream_init (&stream->base,
|
||||
_cairo_base85_stream_write,
|
||||
_cairo_base85_stream_close);
|
||||
stream->output = output;
|
||||
stream->pending = 0;
|
||||
|
||||
return _cairo_output_stream_create (_cairo_base85_stream_write,
|
||||
_cairo_base85_stream_close,
|
||||
stream);
|
||||
return &stream->base;
|
||||
}
|
||||
|
|
|
|||
156
src/cairo-output-stream-private.h
Normal file
156
src/cairo-output-stream-private.h
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
/* 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 cairo_output_stream.c as distributed with the
|
||||
* cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Author(s):
|
||||
* Kristian Høgsberg <krh@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_OUTPUT_STREAM_PRIVATE_H
|
||||
#define CAIRO_OUTPUT_STREAM_PRIVATE_H
|
||||
|
||||
typedef struct _cairo_output_stream cairo_output_stream_t;
|
||||
|
||||
typedef cairo_status_t (*cairo_output_stream_write_func_t) (cairo_output_stream_t *output_stream,
|
||||
const unsigned char *data,
|
||||
unsigned int length);
|
||||
|
||||
typedef cairo_status_t (*cairo_output_stream_close_func_t) (cairo_output_stream_t *output_stream);
|
||||
|
||||
struct _cairo_output_stream {
|
||||
cairo_output_stream_write_func_t write_func;
|
||||
cairo_output_stream_close_func_t close_func;
|
||||
unsigned long position;
|
||||
cairo_status_t status;
|
||||
cairo_bool_t closed;
|
||||
};
|
||||
|
||||
extern const cairo_private cairo_output_stream_t cairo_output_stream_nil;
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_init (cairo_output_stream_t *stream,
|
||||
cairo_output_stream_write_func_t write_func,
|
||||
cairo_output_stream_close_func_t close_func);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_fini (cairo_output_stream_t *stream);
|
||||
|
||||
|
||||
/* We already have the following declared in cairo.h:
|
||||
|
||||
typedef cairo_status_t (*cairo_write_func_t) (void *closure,
|
||||
const unsigned char *data,
|
||||
unsigned int length);
|
||||
*/
|
||||
typedef cairo_status_t (*cairo_close_func_t) (void *closure);
|
||||
|
||||
|
||||
/* This function never returns NULL. If an error occurs (NO_MEMORY)
|
||||
* while trying to create the output stream this function returns a
|
||||
* valid pointer to a nil output stream.
|
||||
*
|
||||
* Note that even with a nil surface, the close_func callback will be
|
||||
* called by a call to _cairo_output_stream_close or
|
||||
* _cairo_output_stream_destroy.
|
||||
*/
|
||||
cairo_private cairo_output_stream_t *
|
||||
_cairo_output_stream_create (cairo_write_func_t write_func,
|
||||
cairo_close_func_t close_func,
|
||||
void *closure);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_close (cairo_output_stream_t *stream);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_destroy (cairo_output_stream_t *stream);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_write (cairo_output_stream_t *stream,
|
||||
const void *data, size_t length);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_write_hex_string (cairo_output_stream_t *stream,
|
||||
const char *data,
|
||||
size_t length);
|
||||
|
||||
cairo_private int
|
||||
_cairo_dtostr (char *buffer, size_t size, double d);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_vprintf (cairo_output_stream_t *stream,
|
||||
const char *fmt, va_list ap);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_printf (cairo_output_stream_t *stream,
|
||||
const char *fmt, ...);
|
||||
|
||||
cairo_private long
|
||||
_cairo_output_stream_get_position (cairo_output_stream_t *stream);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_output_stream_get_status (cairo_output_stream_t *stream);
|
||||
|
||||
/* This function never returns NULL. If an error occurs (NO_MEMORY or
|
||||
* WRITE_ERROR) while trying to create the output stream this function
|
||||
* returns a valid pointer to a nil output stream.
|
||||
*
|
||||
* NOTE: Even if a nil surface is returned, the caller should still
|
||||
* call _cairo_output_stream_destroy (or _cairo_output_stream_close at
|
||||
* least) in order to ensure that everything is properly cleaned up.
|
||||
*/
|
||||
cairo_private cairo_output_stream_t *
|
||||
_cairo_output_stream_create_for_filename (const char *filename);
|
||||
|
||||
/* This function never returns NULL. If an error occurs (NO_MEMORY or
|
||||
* WRITE_ERROR) while trying to create the output stream this function
|
||||
* returns a valid pointer to a nil output stream.
|
||||
*
|
||||
* The caller still "owns" file and is responsible for calling fclose
|
||||
* on it when finished. The stream will not do this itself.
|
||||
*/
|
||||
cairo_private cairo_output_stream_t *
|
||||
_cairo_output_stream_create_for_file (FILE *file);
|
||||
|
||||
cairo_private cairo_output_stream_t *
|
||||
_cairo_memory_stream_create (void);
|
||||
|
||||
cairo_private void
|
||||
_cairo_memory_stream_copy (cairo_output_stream_t *base,
|
||||
cairo_output_stream_t *dest);
|
||||
|
||||
cairo_private int
|
||||
_cairo_memory_stream_length (cairo_output_stream_t *stream);
|
||||
|
||||
/* cairo_base85_stream.c */
|
||||
cairo_private cairo_output_stream_t *
|
||||
_cairo_base85_stream_create (cairo_output_stream_t *output);
|
||||
|
||||
#endif /* CAIRO_OUTPUT_STREAM_PRIVATE_H */
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* cairo_output_stream.c: Output stream abstraction
|
||||
/* cairo-output-stream.c: Output stream abstraction
|
||||
*
|
||||
* Copyright © 2005 Red Hat, Inc
|
||||
*
|
||||
|
|
@ -38,24 +38,35 @@
|
|||
#include <locale.h>
|
||||
#include <ctype.h>
|
||||
#include "cairoint.h"
|
||||
#include "cairo-output-stream-private.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
struct _cairo_output_stream {
|
||||
cairo_write_func_t write_func;
|
||||
cairo_close_func_t close_func;
|
||||
void *closure;
|
||||
unsigned long position;
|
||||
cairo_status_t status;
|
||||
cairo_bool_t closed;
|
||||
};
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_init (cairo_output_stream_t *stream,
|
||||
cairo_output_stream_write_func_t write_func,
|
||||
cairo_output_stream_close_func_t close_func)
|
||||
{
|
||||
stream->write_func = write_func;
|
||||
stream->close_func = close_func;
|
||||
stream->position = 0;
|
||||
stream->status = CAIRO_STATUS_SUCCESS;
|
||||
stream->closed = FALSE;
|
||||
}
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_fini (cairo_output_stream_t *stream)
|
||||
{
|
||||
_cairo_output_stream_close (stream);
|
||||
}
|
||||
|
||||
|
||||
const cairo_output_stream_t cairo_output_stream_nil = {
|
||||
NULL, /* write_func */
|
||||
NULL, /* close_func */
|
||||
NULL, /* closure */
|
||||
0, /* position */
|
||||
CAIRO_STATUS_NO_MEMORY,
|
||||
FALSE /* closed */
|
||||
|
|
@ -64,31 +75,56 @@ const cairo_output_stream_t cairo_output_stream_nil = {
|
|||
static const cairo_output_stream_t cairo_output_stream_nil_write_error = {
|
||||
NULL, /* write_func */
|
||||
NULL, /* close_func */
|
||||
NULL, /* closure */
|
||||
0, /* position */
|
||||
CAIRO_STATUS_WRITE_ERROR,
|
||||
FALSE /* closed */
|
||||
};
|
||||
|
||||
typedef struct _cairo_output_stream_with_closure {
|
||||
cairo_output_stream_t base;
|
||||
cairo_write_func_t write_func;
|
||||
cairo_close_func_t close_func;
|
||||
void *closure;
|
||||
} cairo_output_stream_with_closure_t;
|
||||
|
||||
|
||||
static cairo_status_t
|
||||
closure_write (cairo_output_stream_t *stream,
|
||||
const unsigned char *data, unsigned int length)
|
||||
{
|
||||
cairo_output_stream_with_closure_t *stream_with_closure =
|
||||
(cairo_output_stream_with_closure_t *) stream;
|
||||
|
||||
return stream_with_closure->write_func (stream_with_closure->closure,
|
||||
data, length);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
closure_close (cairo_output_stream_t *stream)
|
||||
{
|
||||
cairo_output_stream_with_closure_t *stream_with_closure =
|
||||
(cairo_output_stream_with_closure_t *) stream;
|
||||
|
||||
return stream_with_closure->close_func (stream_with_closure->closure);
|
||||
}
|
||||
|
||||
cairo_output_stream_t *
|
||||
_cairo_output_stream_create (cairo_write_func_t write_func,
|
||||
cairo_close_func_t close_func,
|
||||
void *closure)
|
||||
{
|
||||
cairo_output_stream_t *stream;
|
||||
cairo_output_stream_with_closure_t *stream;
|
||||
|
||||
stream = malloc (sizeof (cairo_output_stream_t));
|
||||
stream = malloc (sizeof (cairo_output_stream_with_closure_t));
|
||||
if (stream == NULL)
|
||||
return (cairo_output_stream_t *) &cairo_output_stream_nil;
|
||||
|
||||
_cairo_output_stream_init (&stream->base, closure_write, closure_close);
|
||||
stream->write_func = write_func;
|
||||
stream->close_func = close_func;
|
||||
stream->closure = closure;
|
||||
stream->position = 0;
|
||||
stream->status = CAIRO_STATUS_SUCCESS;
|
||||
stream->closed = FALSE;
|
||||
|
||||
return stream;
|
||||
return &stream->base;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -106,7 +142,7 @@ _cairo_output_stream_close (cairo_output_stream_t *stream)
|
|||
}
|
||||
|
||||
if (stream->close_func) {
|
||||
status = stream->close_func (stream->closure);
|
||||
status = stream->close_func (stream);
|
||||
if (status)
|
||||
stream->status = status;
|
||||
}
|
||||
|
|
@ -120,7 +156,7 @@ _cairo_output_stream_destroy (cairo_output_stream_t *stream)
|
|||
if (stream == NULL)
|
||||
return;
|
||||
|
||||
_cairo_output_stream_close (stream);
|
||||
_cairo_output_stream_fini (stream);
|
||||
free (stream);
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +170,7 @@ _cairo_output_stream_write (cairo_output_stream_t *stream,
|
|||
if (stream->status)
|
||||
return;
|
||||
|
||||
stream->status = stream->write_func (stream->closure, data, length);
|
||||
stream->status = stream->write_func (stream, data, length);
|
||||
stream->position += length;
|
||||
}
|
||||
|
||||
|
|
@ -329,39 +365,46 @@ _cairo_output_stream_get_status (cairo_output_stream_t *stream)
|
|||
/* Maybe this should be a configure time option, so embedded targets
|
||||
* don't have to pull in stdio. */
|
||||
|
||||
static cairo_status_t
|
||||
stdio_write (void *closure, const unsigned char *data, unsigned int length)
|
||||
{
|
||||
FILE *file = closure;
|
||||
|
||||
if (fwrite (data, 1, length, file) != length)
|
||||
typedef struct _stdio_stream {
|
||||
cairo_output_stream_t base;
|
||||
FILE *file;
|
||||
} stdio_stream_t;
|
||||
|
||||
static cairo_status_t
|
||||
stdio_write (cairo_output_stream_t *base,
|
||||
const unsigned char *data, unsigned int length)
|
||||
{
|
||||
stdio_stream_t *stream = (stdio_stream_t *) base;
|
||||
|
||||
if (fwrite (data, 1, length, stream->file) != length)
|
||||
return CAIRO_STATUS_WRITE_ERROR;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
stdio_flush (void *closure)
|
||||
stdio_flush (cairo_output_stream_t *base)
|
||||
{
|
||||
FILE *file = closure;
|
||||
stdio_stream_t *stream = (stdio_stream_t *) base;
|
||||
|
||||
fflush (file);
|
||||
fflush (stream->file);
|
||||
|
||||
if (ferror (file))
|
||||
if (ferror (stream->file))
|
||||
return CAIRO_STATUS_WRITE_ERROR;
|
||||
else
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
stdio_close (void *closure)
|
||||
stdio_close (cairo_output_stream_t *base)
|
||||
{
|
||||
cairo_status_t status;
|
||||
FILE *file = closure;
|
||||
stdio_stream_t *stream = (stdio_stream_t *) base;
|
||||
|
||||
status = stdio_flush (closure);
|
||||
status = stdio_flush (base);
|
||||
|
||||
fclose (file);
|
||||
fclose (stream->file);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
@ -369,20 +412,96 @@ stdio_close (void *closure)
|
|||
cairo_output_stream_t *
|
||||
_cairo_output_stream_create_for_file (FILE *file)
|
||||
{
|
||||
stdio_stream_t *stream;
|
||||
|
||||
if (file == NULL)
|
||||
return (cairo_output_stream_t *) &cairo_output_stream_nil_write_error;
|
||||
|
||||
return _cairo_output_stream_create (stdio_write, stdio_flush, file);
|
||||
stream = malloc (sizeof *stream);
|
||||
if (stream == NULL)
|
||||
return (cairo_output_stream_t *) &cairo_output_stream_nil;
|
||||
|
||||
_cairo_output_stream_init (&stream->base, stdio_write, stdio_flush);
|
||||
stream->file = file;
|
||||
|
||||
return &stream->base;
|
||||
}
|
||||
|
||||
cairo_output_stream_t *
|
||||
_cairo_output_stream_create_for_filename (const char *filename)
|
||||
{
|
||||
stdio_stream_t *stream;
|
||||
FILE *file;
|
||||
|
||||
file = fopen (filename, "wb");
|
||||
if (file == NULL)
|
||||
return (cairo_output_stream_t *) &cairo_output_stream_nil_write_error;
|
||||
|
||||
return _cairo_output_stream_create (stdio_write, stdio_close, file);
|
||||
stream = malloc (sizeof *stream);
|
||||
if (stream == NULL)
|
||||
return (cairo_output_stream_t *) &cairo_output_stream_nil;
|
||||
|
||||
_cairo_output_stream_init (&stream->base, stdio_write, stdio_close);
|
||||
stream->file = file;
|
||||
|
||||
return &stream->base;
|
||||
}
|
||||
|
||||
|
||||
typedef struct _memory_stream {
|
||||
cairo_output_stream_t base;
|
||||
cairo_array_t array;
|
||||
} memory_stream_t;
|
||||
|
||||
static cairo_status_t
|
||||
memory_write (cairo_output_stream_t *base,
|
||||
const unsigned char *data, unsigned int length)
|
||||
{
|
||||
memory_stream_t *stream = (memory_stream_t *) base;
|
||||
|
||||
return _cairo_array_append_multiple (&stream->array, data, length);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
memory_close (cairo_output_stream_t *base)
|
||||
{
|
||||
memory_stream_t *stream = (memory_stream_t *) base;
|
||||
|
||||
_cairo_array_fini (&stream->array);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
cairo_output_stream_t *
|
||||
_cairo_memory_stream_create (void)
|
||||
{
|
||||
memory_stream_t *stream;
|
||||
|
||||
stream = malloc (sizeof *stream);
|
||||
if (stream == NULL)
|
||||
return (cairo_output_stream_t *) &cairo_output_stream_nil;
|
||||
|
||||
_cairo_output_stream_init (&stream->base, memory_write, memory_close);
|
||||
_cairo_array_init (&stream->array, 1);
|
||||
|
||||
return &stream->base;
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_memory_stream_copy (cairo_output_stream_t *base,
|
||||
cairo_output_stream_t *dest)
|
||||
{
|
||||
memory_stream_t *stream = (memory_stream_t *) base;
|
||||
|
||||
_cairo_output_stream_write (dest,
|
||||
_cairo_array_index (&stream->array, 0),
|
||||
_cairo_array_num_elements (&stream->array));
|
||||
}
|
||||
|
||||
int
|
||||
_cairo_memory_stream_length (cairo_output_stream_t *base)
|
||||
{
|
||||
memory_stream_t *stream = (memory_stream_t *) base;
|
||||
|
||||
return _cairo_array_num_elements (&stream->array);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
#include "cairo-ft-private.h"
|
||||
#include "cairo-paginated-surface-private.h"
|
||||
#include "cairo-path-fixed-private.h"
|
||||
#include "cairo-output-stream-private.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <zlib.h>
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include "cairo-paginated-surface-private.h"
|
||||
#include "cairo-meta-surface-private.h"
|
||||
#include "cairo-ft-private.h"
|
||||
#include "cairo-output-stream-private.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <zlib.h>
|
||||
|
|
@ -99,6 +100,7 @@ typedef struct cairo_ps_surface {
|
|||
* max_column it will not be broken up.
|
||||
*/
|
||||
typedef struct _word_wrap_stream {
|
||||
cairo_output_stream_t base;
|
||||
cairo_output_stream_t *output;
|
||||
int max_column;
|
||||
int column;
|
||||
|
|
@ -121,11 +123,11 @@ _count_word_up_to (const unsigned char *s, int length)
|
|||
}
|
||||
|
||||
static cairo_status_t
|
||||
_word_wrap_stream_write (void *closure,
|
||||
_word_wrap_stream_write (cairo_output_stream_t *base,
|
||||
const unsigned char *data,
|
||||
unsigned int length)
|
||||
{
|
||||
word_wrap_stream_t *stream = closure;
|
||||
word_wrap_stream_t *stream = (word_wrap_stream_t *) base;
|
||||
cairo_bool_t newline;
|
||||
int word;
|
||||
|
||||
|
|
@ -166,16 +168,11 @@ _word_wrap_stream_write (void *closure,
|
|||
}
|
||||
|
||||
static cairo_status_t
|
||||
_word_wrap_stream_close (void *closure)
|
||||
_word_wrap_stream_close (cairo_output_stream_t *base)
|
||||
{
|
||||
cairo_status_t status;
|
||||
word_wrap_stream_t *stream = closure;
|
||||
word_wrap_stream_t *stream = (word_wrap_stream_t *) base;
|
||||
|
||||
status = _cairo_output_stream_get_status (stream->output);
|
||||
|
||||
free (stream);
|
||||
|
||||
return status;
|
||||
return _cairo_output_stream_get_status (stream->output);
|
||||
}
|
||||
|
||||
static cairo_output_stream_t *
|
||||
|
|
@ -187,13 +184,15 @@ _word_wrap_stream_create (cairo_output_stream_t *output, int max_column)
|
|||
if (stream == NULL)
|
||||
return (cairo_output_stream_t *) &cairo_output_stream_nil;
|
||||
|
||||
_cairo_output_stream_init (&stream->base,
|
||||
_word_wrap_stream_write,
|
||||
_word_wrap_stream_close);
|
||||
stream->output = output;
|
||||
stream->max_column = max_column;
|
||||
stream->column = 0;
|
||||
stream->last_write_was_space = FALSE;
|
||||
|
||||
return _cairo_output_stream_create (_word_wrap_stream_write,
|
||||
_word_wrap_stream_close, stream);
|
||||
return &stream->base;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
|
|
@ -1271,17 +1270,18 @@ _analyze_operation (cairo_ps_surface_t *surface,
|
|||
#define STRING_ARRAY_MAX_COLUMN 72
|
||||
|
||||
typedef struct _string_array_stream {
|
||||
cairo_output_stream_t base;
|
||||
cairo_output_stream_t *output;
|
||||
int column;
|
||||
int string_size;
|
||||
} string_array_stream_t;
|
||||
|
||||
static cairo_status_t
|
||||
_string_array_stream_write (void *closure,
|
||||
const unsigned char *data,
|
||||
unsigned int length)
|
||||
_string_array_stream_write (cairo_output_stream_t *base,
|
||||
const unsigned char *data,
|
||||
unsigned int length)
|
||||
{
|
||||
string_array_stream_t *stream = closure;
|
||||
string_array_stream_t *stream = (string_array_stream_t *) base;
|
||||
unsigned char c;
|
||||
const unsigned char backslash = '\\';
|
||||
|
||||
|
|
@ -1324,17 +1324,15 @@ _string_array_stream_write (void *closure,
|
|||
}
|
||||
|
||||
static cairo_status_t
|
||||
_string_array_stream_close (void *closure)
|
||||
_string_array_stream_close (cairo_output_stream_t *base)
|
||||
{
|
||||
cairo_status_t status;
|
||||
string_array_stream_t *stream = closure;
|
||||
string_array_stream_t *stream = (string_array_stream_t *) base;
|
||||
|
||||
_cairo_output_stream_printf (stream->output, ")\n");
|
||||
|
||||
status = _cairo_output_stream_get_status (stream->output);
|
||||
|
||||
free (stream);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
@ -1361,13 +1359,14 @@ _string_array_stream_create (cairo_output_stream_t *output)
|
|||
if (stream == NULL)
|
||||
return (cairo_output_stream_t *) &cairo_output_stream_nil;
|
||||
|
||||
_cairo_output_stream_init (&stream->base,
|
||||
_string_array_stream_write,
|
||||
_string_array_stream_close);
|
||||
stream->output = output;
|
||||
stream->column = 0;
|
||||
stream->string_size = 0;
|
||||
|
||||
return _cairo_output_stream_create (_string_array_stream_write,
|
||||
_string_array_stream_close,
|
||||
stream);
|
||||
return &stream->base;
|
||||
}
|
||||
|
||||
/* PS Output - this section handles output of the parts of the meta
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-scaled-font-subsets-private.h"
|
||||
#include "cairo-output-stream-private.h"
|
||||
|
||||
/* XXX: Eventually, we need to handle other font backends */
|
||||
#include "cairo-ft-private.h"
|
||||
|
|
|
|||
|
|
@ -2191,90 +2191,6 @@ _cairo_utf8_to_utf16 (const unsigned char *str,
|
|||
uint16_t **result,
|
||||
int *items_written);
|
||||
|
||||
/* cairo_output_stream.c */
|
||||
|
||||
typedef struct _cairo_output_stream cairo_output_stream_t;
|
||||
|
||||
extern const cairo_private cairo_output_stream_t cairo_output_stream_nil;
|
||||
|
||||
/* We already have the following declared in cairo.h:
|
||||
|
||||
typedef cairo_status_t (*cairo_write_func_t) (void *closure,
|
||||
const unsigned char *data,
|
||||
unsigned int length);
|
||||
*/
|
||||
typedef cairo_status_t (*cairo_close_func_t) (void *closure);
|
||||
|
||||
/* This function never returns NULL. If an error occurs (NO_MEMORY)
|
||||
* while trying to create the output stream this function returns a
|
||||
* valid pointer to a nil output stream.
|
||||
*
|
||||
* Note that even with a nil surface, the close_func callback will be
|
||||
* called by a call to _cairo_output_stream_close or
|
||||
* _cairo_output_stream_destroy.
|
||||
*/
|
||||
cairo_private cairo_output_stream_t *
|
||||
_cairo_output_stream_create (cairo_write_func_t write_func,
|
||||
cairo_close_func_t close_func,
|
||||
void *closure);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_close (cairo_output_stream_t *stream);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_destroy (cairo_output_stream_t *stream);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_write (cairo_output_stream_t *stream,
|
||||
const void *data, size_t length);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_write_hex_string (cairo_output_stream_t *stream,
|
||||
const char *data,
|
||||
size_t length);
|
||||
|
||||
cairo_private unsigned char *
|
||||
_cairo_lzw_compress (unsigned char *data, unsigned long *data_size_in_out);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_vprintf (cairo_output_stream_t *stream,
|
||||
const char *fmt, va_list ap);
|
||||
|
||||
cairo_private void
|
||||
_cairo_output_stream_printf (cairo_output_stream_t *stream,
|
||||
const char *fmt, ...) CAIRO_PRINTF_FORMAT(2, 3);
|
||||
|
||||
cairo_private long
|
||||
_cairo_output_stream_get_position (cairo_output_stream_t *status);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_output_stream_get_status (cairo_output_stream_t *stream);
|
||||
|
||||
/* This function never returns NULL. If an error occurs (NO_MEMORY or
|
||||
* WRITE_ERROR) while trying to create the output stream this function
|
||||
* returns a valid pointer to a nil output stream.
|
||||
*
|
||||
* NOTE: Even if a nil surface is returned, the caller should still
|
||||
* call _cairo_output_stream_destroy (or _cairo_output_stream_close at
|
||||
* least) in order to ensure that everything is properly cleaned up.
|
||||
*/
|
||||
cairo_private cairo_output_stream_t *
|
||||
_cairo_output_stream_create_for_filename (const char *filename);
|
||||
|
||||
/* This function never returns NULL. If an error occurs (NO_MEMORY or
|
||||
* WRITE_ERROR) while trying to create the output stream this function
|
||||
* returns a valid pointer to a nil output stream.
|
||||
*
|
||||
* The caller still "owns" file and is responsible for calling fclose
|
||||
* on it when finished. The stream will not do this itself.
|
||||
*/
|
||||
cairo_private cairo_output_stream_t *
|
||||
_cairo_output_stream_create_for_file (FILE *file);
|
||||
|
||||
/* cairo_base85_stream.c */
|
||||
cairo_output_stream_t *
|
||||
_cairo_base85_stream_create (cairo_output_stream_t *output);
|
||||
|
||||
cairo_private void
|
||||
_cairo_error (cairo_status_t status);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ dash-offset-negative \
|
|||
dash-zero-length \
|
||||
device-offset \
|
||||
extend-reflect \
|
||||
fallback-resolution \
|
||||
fill-and-stroke \
|
||||
fill-and-stroke-alpha \
|
||||
fill-and-stroke-alpha-add \
|
||||
|
|
@ -109,6 +108,14 @@ if CAIRO_HAS_MULTI_PAGE_SURFACES
|
|||
TESTS += multi-page
|
||||
endif
|
||||
|
||||
if CAIRO_HAS_SVG_SURFACE
|
||||
if CAIRO_HAS_PDF_SURFACE
|
||||
if CAIRO_HAS_PS_SURFACE
|
||||
TESTS += fallback-resolution
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# XXX: Here are some existing tests that are currently disabled for
|
||||
# one reason or another.
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue