2006-08-30 22:56:36 -07:00
|
|
|
/*
|
2006-08-30 23:41:48 -07:00
|
|
|
* Copyright © 2004,2006 Red Hat, Inc.
|
2006-08-30 22:56:36 -07:00
|
|
|
*
|
|
|
|
|
* 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: Carl D. Worth <cworth@cworth.org>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _CAIRO_BOILERPLATE_H_
|
|
|
|
|
#define _CAIRO_BOILERPLATE_H_
|
|
|
|
|
|
2006-08-31 08:36:29 -07:00
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-08-31 08:53:58 -07:00
|
|
|
#include <stdio.h>
|
2006-08-31 10:27:20 -07:00
|
|
|
#include <stdlib.h>
|
2006-08-31 08:53:58 -07:00
|
|
|
#include <math.h>
|
2006-08-30 22:56:36 -07:00
|
|
|
#include <cairo.h>
|
2006-08-31 08:53:58 -07:00
|
|
|
#include <string.h>
|
2006-08-30 22:56:36 -07:00
|
|
|
|
2008-09-10 18:30:45 +01:00
|
|
|
#include "cairo-compiler-private.h"
|
|
|
|
|
|
2006-09-06 00:15:49 -07:00
|
|
|
#if HAVE_STDINT_H
|
|
|
|
|
# include <stdint.h>
|
|
|
|
|
#elif HAVE_INTTYPES_H
|
|
|
|
|
# include <inttypes.h>
|
|
|
|
|
#elif HAVE_SYS_INT_TYPES_H
|
|
|
|
|
# include <sys/int_types.h>
|
|
|
|
|
#elif defined(_MSC_VER)
|
2011-06-15 10:34:03 +02:00
|
|
|
# include <stdint.h>
|
2006-09-06 00:15:49 -07:00
|
|
|
typedef __int8 int8_t;
|
|
|
|
|
typedef unsigned __int8 uint8_t;
|
|
|
|
|
typedef __int16 int16_t;
|
|
|
|
|
typedef unsigned __int16 uint16_t;
|
|
|
|
|
typedef __int32 int32_t;
|
|
|
|
|
typedef unsigned __int32 uint32_t;
|
|
|
|
|
typedef __int64 int64_t;
|
|
|
|
|
typedef unsigned __int64 uint64_t;
|
|
|
|
|
#else
|
|
|
|
|
#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.)
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-08-18 12:53:43 +01:00
|
|
|
#ifndef HAVE_UINT64_T
|
|
|
|
|
# define HAVE_UINT64_T 1
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef INT16_MIN
|
|
|
|
|
# define INT16_MIN (-32767-1)
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef INT16_MAX
|
|
|
|
|
# define INT16_MAX (32767)
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef UINT16_MAX
|
|
|
|
|
# define UINT16_MAX (65535)
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-01-03 11:44:58 +00:00
|
|
|
#ifndef CAIRO_BOILERPLATE_DEBUG
|
2009-01-03 22:30:55 +00:00
|
|
|
#define CAIRO_BOILERPLATE_DEBUG(x)
|
2009-01-03 11:44:58 +00:00
|
|
|
#endif
|
|
|
|
|
|
2007-04-20 00:34:51 -04:00
|
|
|
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
|
|
|
|
|
#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index) \
|
|
|
|
|
__attribute__((__format__(__printf__, fmt_index, va_index)))
|
|
|
|
|
#else
|
|
|
|
|
#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index)
|
|
|
|
|
#endif
|
2006-08-30 22:56:36 -07:00
|
|
|
|
2006-08-30 23:41:48 -07:00
|
|
|
#ifndef FALSE
|
|
|
|
|
#define FALSE 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef TRUE
|
|
|
|
|
#define TRUE 1
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-02-01 18:45:59 -08:00
|
|
|
#ifndef M_PI
|
|
|
|
|
#define M_PI 3.14159265358979323846
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-06-14 20:43:05 +01:00
|
|
|
CAIRO_BEGIN_DECLS
|
2007-04-20 00:34:51 -04:00
|
|
|
|
|
|
|
|
/* A fake format we use for the flattened ARGB output of the PS and
|
|
|
|
|
* PDF surfaces. */
|
|
|
|
|
#define CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED ((unsigned int) -1)
|
|
|
|
|
|
Remove clip handling from generic surface layer.
Handling clip as part of the surface state, as opposed to being part of
the operation state, is cumbersome and a hindrance to providing true proxy
surface support. For example, the clip must be copied from the surface
onto the fallback image, but this was forgotten causing undue hassle in
each backend. Another example is the contortion the meta surface
endures to ensure the clip is correctly recorded. By contrast passing the
clip along with the operation is quite simple and enables us to write
generic handlers for providing surface wrappers. (And in the future, we
should be able to write more esoteric wrappers, e.g. automatic 2x FSAA,
trivially.)
In brief, instead of the surface automatically applying the clip before
calling the backend, the backend can call into a generic helper to apply
clipping. For raster surfaces, clip regions are handled automatically as
part of the composite interface. For vector surfaces, a clip helper is
introduced to replay and callback into an intersect_clip_path() function
as necessary.
Whilst this is not primarily a performance related change (the change
should just move the computation of the clip from the moment it is applied
by the user to the moment it is required by the backend), it is important
to track any potential regression:
ppc:
Speedups
========
image-rgba evolution-20090607-0 1026085.22 0.18% -> 672972.07 0.77%: 1.52x speedup
▌
image-rgba evolution-20090618-0 680579.98 0.12% -> 573237.66 0.16%: 1.19x speedup
▎
image-rgba swfdec-fill-rate-4xaa-0 460296.92 0.36% -> 407464.63 0.42%: 1.13x speedup
▏
image-rgba swfdec-fill-rate-2xaa-0 128431.95 0.47% -> 115051.86 0.42%: 1.12x speedup
▏
Slowdowns
=========
image-rgba firefox-periodic-table-0 56837.61 0.78% -> 66055.17 3.20%: 1.09x slowdown
▏
2009-07-23 15:32:13 +01:00
|
|
|
extern const cairo_user_data_key_t cairo_boilerplate_output_basename_key;
|
|
|
|
|
|
2008-04-11 11:36:24 +01:00
|
|
|
cairo_content_t
|
|
|
|
|
cairo_boilerplate_content (cairo_content_t content);
|
|
|
|
|
|
2007-04-20 00:34:51 -04:00
|
|
|
const char *
|
|
|
|
|
cairo_boilerplate_content_name (cairo_content_t content);
|
|
|
|
|
|
2007-04-20 00:50:48 -04:00
|
|
|
cairo_format_t
|
|
|
|
|
cairo_boilerplate_format_from_content (cairo_content_t content);
|
|
|
|
|
|
2006-09-09 16:40:58 -07:00
|
|
|
typedef enum {
|
|
|
|
|
CAIRO_BOILERPLATE_MODE_TEST,
|
|
|
|
|
CAIRO_BOILERPLATE_MODE_PERF
|
|
|
|
|
} cairo_boilerplate_mode_t;
|
|
|
|
|
|
2006-08-30 22:56:36 -07:00
|
|
|
typedef cairo_surface_t *
|
2006-09-09 16:40:58 -07:00
|
|
|
(*cairo_boilerplate_create_surface_t) (const char *name,
|
|
|
|
|
cairo_content_t content,
|
2009-06-27 17:53:18 +01:00
|
|
|
double width,
|
|
|
|
|
double height,
|
|
|
|
|
double max_width,
|
|
|
|
|
double max_height,
|
2010-06-24 14:59:18 +03:00
|
|
|
cairo_boilerplate_mode_t mode,
|
2006-09-09 16:40:58 -07:00
|
|
|
void **closure);
|
2006-08-30 22:56:36 -07:00
|
|
|
|
2011-06-01 23:03:36 +01:00
|
|
|
typedef cairo_surface_t *
|
|
|
|
|
(*cairo_boilerplate_create_similar_t) (cairo_surface_t *other,
|
|
|
|
|
cairo_content_t content,
|
|
|
|
|
int width,
|
|
|
|
|
int height);
|
|
|
|
|
|
2008-09-28 13:34:50 +01:00
|
|
|
typedef void
|
|
|
|
|
(*cairo_boilerplate_force_fallbacks_t) (cairo_surface_t *surface,
|
2010-11-24 21:43:07 +10:30
|
|
|
double x_pixels_per_inch,
|
|
|
|
|
double y_pixels_per_inch);
|
2008-09-28 13:34:50 +01:00
|
|
|
|
2008-08-20 19:44:30 +01:00
|
|
|
typedef cairo_status_t
|
|
|
|
|
(*cairo_boilerplate_finish_surface_t) (cairo_surface_t *surface);
|
|
|
|
|
|
2008-08-18 12:53:43 +01:00
|
|
|
typedef cairo_surface_t *
|
|
|
|
|
(*cairo_boilerplate_get_image_surface_t) (cairo_surface_t *surface,
|
2010-06-24 14:59:18 +03:00
|
|
|
int page,
|
2008-08-18 12:53:43 +01:00
|
|
|
int width,
|
|
|
|
|
int height);
|
|
|
|
|
|
2006-08-30 22:56:36 -07:00
|
|
|
typedef cairo_status_t
|
2008-08-18 12:53:43 +01:00
|
|
|
(*cairo_boilerplate_write_to_png_t) (cairo_surface_t *surface,
|
|
|
|
|
const char *filename);
|
2006-08-30 22:56:36 -07:00
|
|
|
|
|
|
|
|
typedef void
|
2006-09-09 14:55:57 -07:00
|
|
|
(*cairo_boilerplate_cleanup_t) (void *closure);
|
2006-08-30 22:56:36 -07:00
|
|
|
|
2006-09-09 20:17:08 -07:00
|
|
|
typedef void
|
|
|
|
|
(*cairo_boilerplate_wait_t) (void *closure);
|
|
|
|
|
|
2010-06-30 18:27:54 +02:00
|
|
|
typedef char *
|
|
|
|
|
(*cairo_boilerplate_describe_t) (void *closure);
|
|
|
|
|
|
2009-07-04 21:43:27 +01:00
|
|
|
typedef struct _cairo_boilerplate_target {
|
2008-08-18 12:53:43 +01:00
|
|
|
const char *name;
|
2008-09-03 16:38:03 +01:00
|
|
|
const char *basename;
|
2008-08-20 19:44:30 +01:00
|
|
|
const char *file_extension;
|
2010-06-24 14:59:18 +03:00
|
|
|
const char *reference_target;
|
2008-08-18 12:53:43 +01:00
|
|
|
cairo_surface_type_t expected_type;
|
|
|
|
|
cairo_content_t content;
|
|
|
|
|
unsigned int error_tolerance;
|
2009-08-23 15:25:42 +01:00
|
|
|
const char *probe; /* runtime dl check */
|
2008-08-18 12:53:43 +01:00
|
|
|
cairo_boilerplate_create_surface_t create_surface;
|
2011-06-01 23:03:36 +01:00
|
|
|
cairo_boilerplate_create_similar_t create_similar;
|
|
|
|
|
cairo_boilerplate_force_fallbacks_t force_fallbacks;
|
2008-08-20 19:44:30 +01:00
|
|
|
cairo_boilerplate_finish_surface_t finish_surface;
|
2008-08-18 12:53:43 +01:00
|
|
|
cairo_boilerplate_get_image_surface_t get_image_surface;
|
|
|
|
|
cairo_boilerplate_write_to_png_t write_to_png;
|
2011-06-01 23:03:36 +01:00
|
|
|
cairo_boilerplate_cleanup_t cleanup;
|
2008-08-18 12:53:43 +01:00
|
|
|
cairo_boilerplate_wait_t synchronize;
|
2010-06-30 18:27:54 +02:00
|
|
|
cairo_boilerplate_describe_t describe;
|
2010-03-27 21:52:16 +00:00
|
|
|
cairo_bool_t is_measurable;
|
2008-08-18 12:53:43 +01:00
|
|
|
cairo_bool_t is_vector;
|
2009-10-22 02:13:36 +03:00
|
|
|
cairo_bool_t is_recording;
|
2006-09-09 14:55:57 -07:00
|
|
|
} cairo_boilerplate_target_t;
|
2006-08-30 22:56:36 -07:00
|
|
|
|
2009-06-12 12:25:22 +01:00
|
|
|
const cairo_boilerplate_target_t *
|
|
|
|
|
cairo_boilerplate_get_image_target (cairo_content_t content);
|
|
|
|
|
|
2009-06-19 18:40:43 +01:00
|
|
|
const cairo_boilerplate_target_t *
|
2010-06-24 14:59:18 +03:00
|
|
|
cairo_boilerplate_get_target_by_name (const char *name,
|
|
|
|
|
cairo_content_t content);
|
2009-06-19 18:40:43 +01:00
|
|
|
|
2009-06-12 12:32:51 +01:00
|
|
|
const cairo_boilerplate_target_t **
|
2010-06-24 14:59:18 +03:00
|
|
|
cairo_boilerplate_get_targets (int *num_targets,
|
|
|
|
|
cairo_bool_t *limited_targets);
|
2007-04-18 19:46:30 -04:00
|
|
|
|
|
|
|
|
void
|
2009-06-12 12:32:51 +01:00
|
|
|
cairo_boilerplate_free_targets (const cairo_boilerplate_target_t **targets);
|
2006-08-30 22:56:36 -07:00
|
|
|
|
2008-08-18 12:53:43 +01:00
|
|
|
cairo_surface_t *
|
|
|
|
|
_cairo_boilerplate_get_image_surface (cairo_surface_t *src,
|
2010-06-24 14:59:18 +03:00
|
|
|
int page,
|
|
|
|
|
int width,
|
|
|
|
|
int height);
|
2008-08-18 12:53:43 +01:00
|
|
|
cairo_surface_t *
|
2010-06-24 14:59:18 +03:00
|
|
|
cairo_boilerplate_get_image_surface_from_png (const char *filename,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
cairo_bool_t flatten);
|
2008-08-18 12:53:43 +01:00
|
|
|
|
2008-08-11 21:12:45 +01:00
|
|
|
cairo_surface_t *
|
|
|
|
|
cairo_boilerplate_surface_create_in_error (cairo_status_t status);
|
2007-04-19 22:08:24 -04:00
|
|
|
|
2008-09-25 13:24:58 +01:00
|
|
|
enum {
|
|
|
|
|
CAIRO_BOILERPLATE_OPEN_NO_DAEMON = 0x1,
|
|
|
|
|
};
|
|
|
|
|
|
2008-08-18 18:50:00 +01:00
|
|
|
FILE *
|
2010-06-24 14:59:18 +03:00
|
|
|
cairo_boilerplate_open_any2ppm (const char *filename,
|
|
|
|
|
int page,
|
2011-11-11 12:20:28 +01:00
|
|
|
unsigned int flags,
|
|
|
|
|
int (**close_cb) (FILE *));
|
|
|
|
|
|
2008-08-18 18:50:00 +01:00
|
|
|
cairo_surface_t *
|
|
|
|
|
cairo_boilerplate_image_surface_create_from_ppm_stream (FILE *file);
|
|
|
|
|
|
2008-09-25 13:24:58 +01:00
|
|
|
cairo_surface_t *
|
2010-06-24 14:59:18 +03:00
|
|
|
cairo_boilerplate_convert_to_image (const char *filename,
|
|
|
|
|
int page);
|
2008-09-25 13:24:58 +01:00
|
|
|
|
2008-09-02 21:56:37 -04:00
|
|
|
int
|
|
|
|
|
cairo_boilerplate_version (void);
|
|
|
|
|
|
|
|
|
|
const char*
|
|
|
|
|
cairo_boilerplate_version_string (void);
|
|
|
|
|
|
2010-03-23 16:49:21 +00:00
|
|
|
void
|
|
|
|
|
cairo_boilerplate_fini (void);
|
|
|
|
|
|
2008-09-04 09:13:49 -04:00
|
|
|
#include "cairo-boilerplate-system.h"
|
2006-08-30 22:56:36 -07:00
|
|
|
|
2009-06-14 20:43:05 +01:00
|
|
|
CAIRO_END_DECLS
|
|
|
|
|
|
2006-08-30 22:56:36 -07:00
|
|
|
#endif
|