diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-07-04 22:00:09 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-07-04 22:00:09 +0100 |
commit | ee8c50f2d6f1dba41f829c715b7bc59b5eeda50d (patch) | |
tree | 4ac93f48418a5cfb8073bb67ead648726b59225d | |
parent | 88cb69b10c66751f687c3745c8e9861b105de3a2 (diff) |
Remove the defunct test-meta surface
Replace the internal test-meta surface will the freshly exported,
real meta-surface.
-rw-r--r-- | boilerplate/cairo-boilerplate-test-surfaces.c | 38 | ||||
-rw-r--r-- | boilerplate/cairo-boilerplate.c | 35 | ||||
-rw-r--r-- | src/Makefile.sources | 2 | ||||
-rw-r--r-- | src/test-meta-surface.c | 358 | ||||
-rw-r--r-- | src/test-meta-surface.h | 50 | ||||
-rw-r--r-- | util/cairo-trace/trace.c | 49 |
6 files changed, 69 insertions, 463 deletions
diff --git a/boilerplate/cairo-boilerplate-test-surfaces.c b/boilerplate/cairo-boilerplate-test-surfaces.c index 844991c9..849627fd 100644 --- a/boilerplate/cairo-boilerplate-test-surfaces.c +++ b/boilerplate/cairo-boilerplate-test-surfaces.c @@ -30,7 +30,6 @@ #include <test-fallback-surface.h> #include <test-fallback16-surface.h> -#include <test-meta-surface.h> #include <test-paginated-surface.h> #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,9,3) #include <test-null-surface.h> @@ -69,21 +68,6 @@ _cairo_boilerplate_test_fallback16_create_surface (const char *name, } static cairo_surface_t * -_cairo_boilerplate_test_meta_create_surface (const char *name, - cairo_content_t content, - double width, - double height, - double max_width, - double max_height, - cairo_boilerplate_mode_t mode, - int id, - void **closure) -{ - *closure = NULL; - return _cairo_test_meta_surface_create (content, width, height); -} - -static cairo_surface_t * _cairo_boilerplate_test_null_create_surface (const char *name, cairo_content_t content, double width, @@ -297,28 +281,6 @@ static const cairo_boilerplate_target_t targets[] = { cairo_surface_write_to_png }, { - "test-meta", "image", NULL, NULL, - CAIRO_INTERNAL_SURFACE_TYPE_TEST_META, - CAIRO_CONTENT_COLOR_ALPHA, 0, - _cairo_boilerplate_test_meta_create_surface, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, - FALSE, TRUE - }, - { - "test-meta", "image", NULL, NULL, - CAIRO_INTERNAL_SURFACE_TYPE_TEST_META, - CAIRO_CONTENT_COLOR, 0, - _cairo_boilerplate_test_meta_create_surface, - NULL, NULL, - _cairo_boilerplate_get_image_surface, - cairo_surface_write_to_png, - NULL, NULL, - FALSE, TRUE - }, - { "test-paginated", "image", NULL, NULL, CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED, CAIRO_CONTENT_COLOR_ALPHA, 0, diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c index dfca1dbf..ea88c691 100644 --- a/boilerplate/cairo-boilerplate.c +++ b/boilerplate/cairo-boilerplate.c @@ -125,6 +125,21 @@ _cairo_boilerplate_image_create_surface (const char *name, return cairo_image_surface_create (format, ceil (width), ceil (height)); } +static cairo_surface_t * +_cairo_boilerplate_meta_create_surface (const char *name, + cairo_content_t content, + double width, + double height, + double max_width, + double max_height, + cairo_boilerplate_mode_t mode, + int id, + void **closure) +{ + *closure = NULL; + return cairo_meta_surface_create (content, width, height); +} + cairo_surface_t * _cairo_boilerplate_get_image_surface (cairo_surface_t *src, int page, @@ -255,6 +270,26 @@ static const cairo_boilerplate_target_t builtin_targets[] = { _cairo_boilerplate_get_image_surface, cairo_surface_write_to_png }, + { + "meta", "image", NULL, NULL, + CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR_ALPHA, 0, + _cairo_boilerplate_meta_create_surface, + NULL, NULL, + _cairo_boilerplate_get_image_surface, + cairo_surface_write_to_png, + NULL, NULL, + FALSE, TRUE + }, + { + "meta", "image", NULL, NULL, + CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0, + _cairo_boilerplate_meta_create_surface, + NULL, NULL, + _cairo_boilerplate_get_image_surface, + cairo_surface_write_to_png, + NULL, NULL, + FALSE, TRUE + }, }; CAIRO_BOILERPLATE (builtin, builtin_targets) diff --git a/src/Makefile.sources b/src/Makefile.sources index 5648f25a..ef4e1c8f 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -192,14 +192,12 @@ cairo_ft_sources = cairo-ft-font.c cairo_test_surfaces_private = \ test-fallback-surface.h \ test-fallback16-surface.h \ - test-meta-surface.h \ test-null-surface.h \ test-paginated-surface.h \ $(NULL) cairo_test_surfaces_sources = \ test-fallback-surface.c \ test-fallback16-surface.c \ - test-meta-surface.c \ test-null-surface.c \ test-paginated-surface.c \ $(NULL) diff --git a/src/test-meta-surface.c b/src/test-meta-surface.c deleted file mode 100644 index 80e56f31..00000000 --- a/src/test-meta-surface.c +++ /dev/null @@ -1,358 +0,0 @@ -/* 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 <cworth@cworth.org> - */ - -/* This isn't a "real" surface, but just something to be used by the - * test suite to help exercise the meta-surface paths in cairo. - * - * The defining feature of this backend is that it uses a meta surface - * to record all operations, and then replays everything to an image - * surface. - * - * It's possible that this code might serve as a good starting point - * for someone working on bringing up a new meta-surface-based - * backend. - */ - -#include "cairoint.h" - -#include "test-meta-surface.h" - -#include "cairo-meta-surface-private.h" - -typedef struct _test_meta_surface { - cairo_surface_t base; - - /* This is a cairo_meta_surface to record all operations. */ - cairo_surface_t *meta; - int width, height; - - /* And this is a cairo_image_surface to hold the final result. */ - cairo_surface_t *image; - - cairo_bool_t image_reflects_meta; -} test_meta_surface_t; - -static cairo_int_status_t -_test_meta_surface_show_page (void *abstract_surface); - -slim_hidden_proto (_cairo_test_meta_surface_create); - -static cairo_surface_t * -_test_meta_surface_create_similar (void *abstract_surface, - cairo_content_t content, - int width, int height) -{ - return _cairo_test_meta_surface_create (content, width, height); -} - -static cairo_status_t -_test_meta_surface_finish (void *abstract_surface) -{ - test_meta_surface_t *surface = abstract_surface; - - cairo_surface_destroy (surface->meta); - cairo_surface_destroy (surface->image); - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_status_t -_test_meta_surface_acquire_source_image (void *abstract_surface, - cairo_image_surface_t **image_out, - void **image_extra) -{ - test_meta_surface_t *surface = abstract_surface; - cairo_status_t status; - - if (! surface->image_reflects_meta) { - status = _test_meta_surface_show_page (abstract_surface); - if (status) - return status; - } - - return _cairo_surface_acquire_source_image (surface->image, - image_out, image_extra); -} - -static void -_test_meta_surface_release_source_image (void *abstract_surface, - cairo_image_surface_t *image, - void *image_extra) -{ - test_meta_surface_t *surface = abstract_surface; - - _cairo_surface_release_source_image (surface->image, - image, image_extra); -} - -static cairo_int_status_t -_test_meta_surface_show_page (void *abstract_surface) -{ - test_meta_surface_t *surface = abstract_surface; - cairo_status_t status; - - if (surface->image_reflects_meta) - return CAIRO_STATUS_SUCCESS; - - if (surface->image == NULL) { - surface->image = - _cairo_image_surface_create_with_content (surface->base.content, - surface->width, - surface->height); - status = surface->image->status; - if (status) - return status; - } - - status = cairo_meta_surface_replay (surface->meta, surface->image); - if (status) - return status; - - surface->image_reflects_meta = TRUE; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_int_status_t -_test_meta_surface_intersect_clip_path (void *abstract_surface, - cairo_path_fixed_t *path, - cairo_fill_rule_t fill_rule, - double tolerance, - cairo_antialias_t antialias) -{ - test_meta_surface_t *surface = abstract_surface; - - return _cairo_surface_intersect_clip_path (surface->meta, - path, fill_rule, - tolerance, antialias); -} - -static cairo_int_status_t -_test_meta_surface_get_extents (void *abstract_surface, - cairo_rectangle_int_t *rectangle) -{ - test_meta_surface_t *surface = abstract_surface; - - rectangle->x = 0; - rectangle->y = 0; - rectangle->width = surface->width; - rectangle->height = surface->height; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_int_status_t -_test_meta_surface_paint (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_rectangle_int_t *extents) -{ - test_meta_surface_t *surface = abstract_surface; - - surface->image_reflects_meta = FALSE; - - return _cairo_surface_paint (surface->meta, op, source, extents); -} - -static cairo_int_status_t -_test_meta_surface_mask (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - const cairo_pattern_t *mask, - cairo_rectangle_int_t *extents) -{ - test_meta_surface_t *surface = abstract_surface; - - surface->image_reflects_meta = FALSE; - - return _cairo_surface_mask (surface->meta, op, source, mask, extents); -} - -static cairo_int_status_t -_test_meta_surface_stroke (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_path_fixed_t *path, - cairo_stroke_style_t *style, - cairo_matrix_t *ctm, - cairo_matrix_t *ctm_inverse, - double tolerance, - cairo_antialias_t antialias, - cairo_rectangle_int_t *extents) -{ - test_meta_surface_t *surface = abstract_surface; - - surface->image_reflects_meta = FALSE; - - return _cairo_surface_stroke (surface->meta, op, source, - path, style, - ctm, ctm_inverse, - tolerance, antialias, extents); -} - -static cairo_int_status_t -_test_meta_surface_fill (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - cairo_path_fixed_t *path, - cairo_fill_rule_t fill_rule, - double tolerance, - cairo_antialias_t antialias, - cairo_rectangle_int_t *extents) -{ - test_meta_surface_t *surface = abstract_surface; - - surface->image_reflects_meta = FALSE; - - return _cairo_surface_fill (surface->meta, op, source, - path, fill_rule, - tolerance, antialias, extents); -} - -static cairo_bool_t -_test_meta_surface_has_show_text_glyphs (void *abstract_surface) -{ - test_meta_surface_t *surface = abstract_surface; - - return cairo_surface_has_show_text_glyphs (surface->meta); -} - -static cairo_int_status_t -_test_meta_surface_show_text_glyphs (void *abstract_surface, - cairo_operator_t op, - const cairo_pattern_t *source, - const char *utf8, - int utf8_len, - cairo_glyph_t *glyphs, - int num_glyphs, - const cairo_text_cluster_t *clusters, - int num_clusters, - cairo_text_cluster_flags_t cluster_flags, - cairo_scaled_font_t *scaled_font, - cairo_rectangle_int_t *extents) -{ - test_meta_surface_t *surface = abstract_surface; - - surface->image_reflects_meta = FALSE; - - return _cairo_surface_show_text_glyphs (surface->meta, op, source, - utf8, utf8_len, - glyphs, num_glyphs, - clusters, num_clusters, cluster_flags, - scaled_font, extents); -} - - -static cairo_surface_t * -_test_meta_surface_snapshot (void *abstract_other) -{ - test_meta_surface_t *other = abstract_other; - - return _cairo_surface_snapshot (other->meta); -} - -static const cairo_surface_backend_t test_meta_surface_backend = { - CAIRO_INTERNAL_SURFACE_TYPE_TEST_META, - _test_meta_surface_create_similar, - _test_meta_surface_finish, - _test_meta_surface_acquire_source_image, - _test_meta_surface_release_source_image, - NULL, /* acquire_dest_image */ - NULL, /* release_dest_image */ - NULL, /* clone_similar */ - NULL, /* composite */ - NULL, /* fill_rectangles */ - NULL, /* composite_trapezoids */ - NULL, /* create_span_renderer */ - NULL, /* check_span_renderer */ - NULL, /* copy_page */ - _test_meta_surface_show_page, - NULL, /* set_clip_region */ - _test_meta_surface_intersect_clip_path, - _test_meta_surface_get_extents, - NULL, /* old_show_glyphs */ - NULL, /* get_font_options */ - NULL, /* flush */ - NULL, /* mark_dirty_rectangle */ - NULL, /* scaled_font_fini */ - NULL, /* scaled_glyph_fini */ - _test_meta_surface_paint, - _test_meta_surface_mask, - _test_meta_surface_stroke, - _test_meta_surface_fill, - NULL, /* show_glyphs */ - _test_meta_surface_snapshot, - NULL, /* is_similar */ - NULL, /* reset */ - NULL, /* fill_stroke */ - NULL, /* create_solid_pattern_surface */ - NULL, /* can_repaint_solid_pattern_surface */ - _test_meta_surface_has_show_text_glyphs, - _test_meta_surface_show_text_glyphs -}; - -cairo_surface_t * -_cairo_test_meta_surface_create (cairo_content_t content, - int width, - int height) -{ - test_meta_surface_t *surface; - cairo_status_t status; - - surface = malloc (sizeof (test_meta_surface_t)); - if (unlikely (surface == NULL)) - return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY)); - - _cairo_surface_init (&surface->base, &test_meta_surface_backend, - content); - - surface->meta = cairo_meta_surface_create (content, width, height); - status = cairo_surface_status (surface->meta); - if (status) - goto FAIL; - - surface->width = width; - surface->height = height; - - surface->image_reflects_meta = FALSE; - surface->image = NULL; - - return &surface->base; - - FAIL: - free (surface); - return _cairo_surface_create_in_error (status); -} -slim_hidden_def (_cairo_test_meta_surface_create); diff --git a/src/test-meta-surface.h b/src/test-meta-surface.h deleted file mode 100644 index 4cd27d86..00000000 --- a/src/test-meta-surface.h +++ /dev/null @@ -1,50 +0,0 @@ -/* 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 <cworth@cworth.org> - */ - -#ifndef TEST_META_SURFACE_H -#define TEST_META_SURFACE_H - -#include "cairo.h" - -CAIRO_BEGIN_DECLS - -cairo_surface_t * -_cairo_test_meta_surface_create (cairo_content_t content, - int width, - int height); - -CAIRO_END_DECLS - -#endif /* TEST_META_SURFACE_H */ diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c index e910d9ee..b29b57fe 100644 --- a/util/cairo-trace/trace.c +++ b/util/cairo-trace/trace.c @@ -4264,30 +4264,25 @@ _cairo_test_paginated_surface_create_for_data (unsigned char *data, return ret; } -#include <test-meta-surface.h> + +#include <test-null-surface.h> cairo_surface_t * -_cairo_test_meta_surface_create (cairo_content_t content, - int width, - int height) +_cairo_test_null_surface_create (cairo_content_t content) { cairo_surface_t *ret; long surface_id; - ret = DLCALL (_cairo_test_meta_surface_create, content, width, height); + ret = DLCALL (_cairo_test_null_surface_create, content); surface_id = _create_surface_id (ret); _emit_line_info (); if (_write_lock ()) { _trace_printf ("dict\n" - " /type /test-meta set\n" + " /type /test-null set\n" " /content //%s set\n" - " /width %d set\n" - " /height %d set\n" " surface dup /s%ld exch def\n", _content_to_string (content), - width, height, surface_id); - _surface_object_set_size (ret, width, height); _get_object (SURFACE, ret)->defined = true; _push_operand (SURFACE, ret); _write_unlock (); @@ -4295,25 +4290,31 @@ _cairo_test_meta_surface_create (cairo_content_t content, return ret; } +#endif -#include <test-null-surface.h> cairo_surface_t * -_cairo_test_null_surface_create (cairo_content_t content) +cairo_meta_surface_create (cairo_content_t content, + double width, + double height) { cairo_surface_t *ret; long surface_id; - ret = DLCALL (_cairo_test_null_surface_create, content); + ret = DLCALL (cairo_meta_surface_create, content, width, height); surface_id = _create_surface_id (ret); _emit_line_info (); if (_write_lock ()) { _trace_printf ("dict\n" - " /type /test-null set\n" + " /type /meta set\n" " /content //%s set\n" + " /width %f set\n" + " /height %f set\n" " surface dup /s%ld exch def\n", _content_to_string (content), + width, height, surface_id); + _surface_object_set_size (ret, width, height); _get_object (SURFACE, ret)->defined = true; _push_operand (SURFACE, ret); _write_unlock (); @@ -4321,4 +4322,22 @@ _cairo_test_null_surface_create (cairo_content_t content) return ret; } -#endif + +cairo_status_t +cairo_meta_surface_replay (cairo_surface_t *meta, cairo_surface_t *target) +{ + cairo_status_t + + ret = DLCALL (cairo_meta_surface_replay, meta, target); + + _emit_line_info (); + if (_write_lock ()) { + + _emit_surface (target); + _emit_surface (meta); + _trace_printf ("replay"); + _consume_operand (); + } + + return ret; +} |