mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-26 12:20:12 +01:00
Add a new CAIRO_HAS_MULTI_PAGE_SURFACES automake conditional.
Remove backend-specific tests (ps-surface, pdf-surface, and pdf-clip) that are now redundant with the ps and pdf support in the rest of the test suite. Add a new one-off test for testing show_page with both the ps and pdf backends.
This commit is contained in:
parent
3647ff95f9
commit
25882cd5e9
7 changed files with 95 additions and 283 deletions
17
ChangeLog
17
ChangeLog
|
|
@ -1,3 +1,20 @@
|
|||
2006-01-12 Carl Worth <cworth@cworth.org>
|
||||
|
||||
* configure.in: Add a new CAIRO_HAS_MULTI_PAGE_SURFACES automake
|
||||
conditional.
|
||||
|
||||
* test/.cvsignore:
|
||||
* test/Makefile.am:
|
||||
* test/pdf-clip.c:
|
||||
* test/pdf-surface.c:
|
||||
* test/ps-surface.c: Remove backend-specific tests (ps-surface,
|
||||
pdf-surface, and pdf-clip) that are now redundant with the ps and
|
||||
pdf support in the rest of the test suite.
|
||||
|
||||
* test/multi-page.c: (draw), (draw_five_pages), (main): Add a new
|
||||
one-off test for testing show_page with both the ps and pdf
|
||||
backends.
|
||||
|
||||
2006-01-12 Carl Worth <cworth@cworth.org>
|
||||
|
||||
Some fixes for the fact that multi-page output was totally broken
|
||||
|
|
|
|||
|
|
@ -515,6 +515,8 @@ AM_CONDITIONAL(CAIRO_CAN_TEST_PDF_SURFACE, test "x$test_pdf" = "xyes")
|
|||
AC_SUBST(POPPLER_CFLAGS)
|
||||
AC_SUBST(POPPLER_LIBS)
|
||||
|
||||
AM_CONDITIONAL(CAIRO_HAS_MULTI_PAGE_SURFACES, test "x$use_ps" = "xyes" -o "x$use_pdf" = "xyes")
|
||||
|
||||
CAIRO_LIBS="$CAIRO_LIBS $PDF_LIBS"
|
||||
|
||||
AC_SUBST(PDF_LIBS)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ mask
|
|||
mask-ctm
|
||||
mask-surface-ctm
|
||||
move-to-show-surface
|
||||
multi-page
|
||||
multi-page.pdf
|
||||
multi-page.ps
|
||||
nil-surface
|
||||
operator-clear
|
||||
operator-source
|
||||
|
|
@ -41,18 +44,12 @@ paint
|
|||
paint-with-alpha
|
||||
path-data
|
||||
pdf2png
|
||||
pdf-clip
|
||||
pdf-clip.pdf
|
||||
pdf-surface
|
||||
pdf-surface.pdf
|
||||
svg2png
|
||||
svg-clip
|
||||
svg-clip.svg
|
||||
svg-surface
|
||||
svg-surface.svg
|
||||
pixman-rotate
|
||||
ps-surface
|
||||
ps-surface.ps
|
||||
pthread-show-text
|
||||
rectangle-rounding-error
|
||||
rel-path
|
||||
|
|
|
|||
|
|
@ -69,22 +69,18 @@ if CAIRO_HAS_FT_FONT
|
|||
TESTS += ft-font-create-for-ft-face
|
||||
endif
|
||||
|
||||
if CAIRO_HAS_PDF_SURFACE
|
||||
TESTS += pdf-surface pdf-clip
|
||||
endif
|
||||
|
||||
if CAIRO_HAS_SVG_SURFACE
|
||||
TESTS += svg-surface svg-clip
|
||||
endif
|
||||
|
||||
if CAIRO_HAS_PS_SURFACE
|
||||
TESTS += ps-surface
|
||||
endif
|
||||
|
||||
if CAIRO_HAS_XLIB_SURFACE
|
||||
TESTS += xlib-surface
|
||||
endif
|
||||
|
||||
if CAIRO_HAS_MULTI_PAGE_SURFACES
|
||||
TESTS += multi-page
|
||||
endif
|
||||
|
||||
# All tests which have a reference image go here.
|
||||
# I really don't like having to repeat this list. Anyone know a good
|
||||
# way to avoid it? Can I use a wildcard here?
|
||||
|
|
@ -313,6 +309,7 @@ linear_gradient_LDADD = $(LDADDS)
|
|||
mask_LDADD = $(LDADDS)
|
||||
mask_ctm_LDADD = $(LDADDS)
|
||||
mask_surface_ctm_LDADD = $(LDADDS)
|
||||
multi_page_LDADD = $(LDADDS)
|
||||
move_to_show_surface_LDADD = $(LDADDS)
|
||||
nil_surface_LDADD = $(LDADDS)
|
||||
operator_clear_LDADD = $(LDADDS)
|
||||
|
|
@ -320,12 +317,9 @@ operator_source_LDADD = $(LDADDS)
|
|||
paint_LDADD = $(LDADDS)
|
||||
paint_with_alpha_LDADD = $(LDADDS)
|
||||
path_data_LDADD = $(LDADDS)
|
||||
pdf_surface_LDADD = $(LDADDS)
|
||||
svg_surface_LDADD = $(LDADDS)
|
||||
pdf_clip_LDADD = $(LDADDS)
|
||||
svg_clip_LDADD = $(LDADDS)
|
||||
pixman_rotate_LDADD = $(LDADDS)
|
||||
ps_surface_LDADD = $(LDADDS)
|
||||
pthread_show_text_LDADD = $(LDADDS)
|
||||
rectangle_rounding_error_LDADD = $(LDADDS)
|
||||
scale_source_surface_paint_LDADD = $(LDADDS)
|
||||
|
|
@ -374,10 +368,9 @@ CLEANFILES = \
|
|||
*-out.png \
|
||||
*-diff.png \
|
||||
*.log \
|
||||
ps-surface.ps \
|
||||
pdf-surface.pdf \
|
||||
multi-page.ps \
|
||||
multi-page.pdf \
|
||||
svg-surface.svg \
|
||||
pdf-clip.pdf \
|
||||
svg-clip.svg
|
||||
|
||||
check-valgrind:
|
||||
|
|
|
|||
|
|
@ -25,12 +25,26 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cairo.h>
|
||||
|
||||
#if CAIRO_HAS_PS_SURFACE
|
||||
#include <cairo-ps.h>
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_PDF_SURFACE
|
||||
#include <cairo-pdf.h>
|
||||
#endif
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
/* Pretty boring test just to make sure things aren't crashing ---
|
||||
* no verification that we're getting good results yet.
|
||||
* But you can manually view the image to make sure it looks happy.
|
||||
/* The PostScript and PDF backends are now integrated into the main
|
||||
* test suite, so we are getting good verification of most things
|
||||
* there.
|
||||
*
|
||||
* One thing that isn't supported there yet is multi-page output. So,
|
||||
* for now we have this one-off test. There's no automatic
|
||||
* verififcation here yet, but you can manually view the output to
|
||||
* make sure it looks happy.
|
||||
*/
|
||||
|
||||
#define WIDTH_IN_INCHES 3
|
||||
|
|
@ -88,23 +102,12 @@ draw (cairo_t *cr, double width, double height, double smile_ratio)
|
|||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
static void
|
||||
draw_five_pages (cairo_surface_t *surface)
|
||||
{
|
||||
cairo_t *cr;
|
||||
const char *filename = "ps-surface.ps";
|
||||
cairo_surface_t *surface;
|
||||
int i;
|
||||
|
||||
printf("\n");
|
||||
|
||||
surface = cairo_ps_surface_create (filename,
|
||||
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
|
||||
if (surface == NULL) {
|
||||
cairo_test_log ("Failed to create pdf surface for file %s\n", filename);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
|
||||
cr = cairo_create (surface);
|
||||
|
||||
#define NUM_PAGES 5
|
||||
|
|
@ -114,9 +117,54 @@ main (void)
|
|||
}
|
||||
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
char *filename;
|
||||
|
||||
printf("\n");
|
||||
|
||||
#if CAIRO_HAS_PS_SURFACE
|
||||
filename = "multi-page.ps";
|
||||
|
||||
surface = cairo_ps_surface_create (filename,
|
||||
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
|
||||
status = cairo_surface_status (surface);
|
||||
if (status) {
|
||||
cairo_test_log ("Failed to create ps surface for file %s: %s\n",
|
||||
filename, cairo_status_to_string (status));
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
|
||||
draw_five_pages (surface);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
printf ("ps-surface: Please check ps-surface.ps to make sure it looks happy.\n");
|
||||
printf ("multi-page: Please check %s to ensure it looks happy.\n", filename);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
#if CAIRO_HAS_PDF_SURFACE
|
||||
filename = "multi-page.pdf";
|
||||
|
||||
surface = cairo_pdf_surface_create (filename,
|
||||
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
|
||||
status = cairo_surface_status (surface);
|
||||
if (status) {
|
||||
cairo_test_log ("Failed to create pdf surface for file %s: %s\n",
|
||||
filename, cairo_status_to_string (status));
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
|
||||
draw_five_pages (surface);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
printf ("multi-page: Please check %s to ensure it looks happy.\n", filename);
|
||||
#endif
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
134
test/pdf-clip.c
134
test/pdf-clip.c
|
|
@ -1,134 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 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: Kristian Høgsberg <krh@redhat.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cairo-pdf.h>
|
||||
#include "cairo-test.h"
|
||||
|
||||
/* Test PDF clipping */
|
||||
|
||||
#define WIDTH_IN_POINTS 600
|
||||
#define HEIGHT_IN_POINTS 600
|
||||
|
||||
static void
|
||||
test_clip (cairo_t *cr, double width, double height)
|
||||
{
|
||||
cairo_t *cr2;
|
||||
|
||||
/* Basic test; set a square clip and draw a circle to be clipped
|
||||
* against it.*/
|
||||
|
||||
cairo_rectangle (cr, 100, 100, 400, 400);
|
||||
cairo_clip (cr);
|
||||
cairo_arc (cr, 300, 300, 210, 0, 2 * M_PI);
|
||||
cairo_set_source_rgb (cr, 1, 0, 0);
|
||||
cairo_fill (cr);
|
||||
|
||||
/* Add a plus shaped clip path to the square clip and draw a big
|
||||
* green square to test the new clip path. */
|
||||
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_rectangle (cr, 250, 100, 100, 400);
|
||||
cairo_rectangle (cr, 100, 250, 400, 100);
|
||||
cairo_clip (cr);
|
||||
|
||||
cairo_rectangle (cr, 0, 0, 600, 600);
|
||||
cairo_set_source_rgb (cr, 0, 1, 0);
|
||||
cairo_fill (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
|
||||
/* Set a bezier shape in addition to the rectangle clip set before
|
||||
* the cairo_save() to verify that we successfully removed the
|
||||
* plus shaped clip path and can set a new clip.*/
|
||||
|
||||
cairo_move_to (cr, 600, 0);
|
||||
cairo_curve_to (cr, 300, 600, 0, 300, 600, 0);
|
||||
cairo_clip (cr);
|
||||
|
||||
cairo_rectangle (cr, 0, 0, 600, 600);
|
||||
cairo_set_source_rgb (cr, 0, 0, 1);
|
||||
cairo_fill (cr);
|
||||
|
||||
/* Create a new context for this surface to test overlapped
|
||||
* drawing from two contexts */
|
||||
cr2 = cairo_create (cairo_get_target (cr));
|
||||
|
||||
/* Using the new context, draw a black vertical line, which should
|
||||
* appear unclipped on top of everything drawn so far. */
|
||||
cairo_move_to (cr2, 110, 0);
|
||||
cairo_line_to (cr2, 110, 600);
|
||||
cairo_stroke (cr2);
|
||||
|
||||
/* Using the first context, draw another black vertical line.
|
||||
* This line should be clipped agaist the bezier clipping path set
|
||||
* earlier. */
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
cairo_move_to (cr, 400, 0);
|
||||
cairo_line_to (cr, 400, 600);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_destroy (cr2);
|
||||
|
||||
/* Test reset clip. Draw a transparent black circle over
|
||||
* everything. Specifically, make sure the circle extends outside
|
||||
* the square clip set at the top of this function. */
|
||||
cairo_reset_clip (cr);
|
||||
cairo_arc (cr, 300, 300, 220, 0, 2 * M_PI);
|
||||
cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
cairo_t *cr;
|
||||
const char *filename = "pdf-clip.pdf";
|
||||
cairo_surface_t *surface;
|
||||
|
||||
printf("\n");
|
||||
|
||||
surface = cairo_pdf_surface_create (filename,
|
||||
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
|
||||
if (surface == NULL) {
|
||||
fprintf (stderr, "Failed to create pdf surface for file %s\n", filename);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
|
||||
cr = cairo_create (surface);
|
||||
|
||||
test_clip (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
|
||||
cairo_show_page (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
printf ("pdf-surface: Please check %s to make sure it looks happy.\n",
|
||||
filename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 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: Carl D. Worth <cworth@cworth.org>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cairo-pdf.h>
|
||||
#include "cairo-test.h"
|
||||
|
||||
/* Pretty boring test just to make sure things aren't crashing ---
|
||||
* no verification that we're getting good results yet.
|
||||
* But you can manually view the image to make sure it looks happy.
|
||||
*/
|
||||
|
||||
#define WIDTH_IN_INCHES 3
|
||||
#define HEIGHT_IN_INCHES 3
|
||||
#define WIDTH_IN_POINTS (WIDTH_IN_INCHES * 72.0)
|
||||
#define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72.0)
|
||||
|
||||
static void
|
||||
draw (cairo_t *cr, double width, double height)
|
||||
{
|
||||
#define STROKE_WIDTH .04
|
||||
|
||||
double size;
|
||||
|
||||
if (width > height)
|
||||
size = height;
|
||||
else
|
||||
size = width;
|
||||
|
||||
cairo_translate (cr, (width - size) / 2.0, (height - size) / 2.0);
|
||||
cairo_scale (cr, size, size);
|
||||
|
||||
/* Fill face */
|
||||
cairo_arc (cr, 0.5, 0.5, 0.5 - STROKE_WIDTH, 0, 2 * M_PI);
|
||||
cairo_set_source_rgb (cr, 1, 1, 0);
|
||||
cairo_fill_preserve (cr);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
|
||||
/* Stroke face */
|
||||
cairo_set_line_width (cr, STROKE_WIDTH / 2.0);
|
||||
cairo_stroke (cr);
|
||||
|
||||
/* Eyes */
|
||||
cairo_set_line_width (cr, STROKE_WIDTH);
|
||||
cairo_arc (cr, 0.3, 0.4, STROKE_WIDTH, 0, 2 * M_PI);
|
||||
cairo_fill (cr);
|
||||
cairo_arc (cr, 0.7, 0.4, STROKE_WIDTH, 0, 2 * M_PI);
|
||||
cairo_fill (cr);
|
||||
|
||||
/* Mouth */
|
||||
cairo_move_to (cr, 0.3, 0.7);
|
||||
cairo_curve_to (cr,
|
||||
0.4, 0.8,
|
||||
0.6, 0.8,
|
||||
0.7, 0.7);
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
cairo_t *cr;
|
||||
const char *filename = "pdf-surface.pdf";
|
||||
cairo_surface_t *surface;
|
||||
|
||||
printf("\n");
|
||||
|
||||
surface = cairo_pdf_surface_create (filename,
|
||||
WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
|
||||
if (surface == NULL) {
|
||||
fprintf (stderr, "Failed to create pdf surface for file %s\n", filename);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
|
||||
cr = cairo_create (surface);
|
||||
|
||||
draw (cr, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
|
||||
|
||||
cairo_show_page (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
printf ("pdf-surface: Please check pdf-surface.pdf to make sure it looks happy.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue