[cairo-commit] Changes to 'ps-surface'
keithp
keithp at kemper.freedesktop.org
Mon Feb 27 14:18:42 PST 2006
src/Makefile.am | 2
src/cairo-analyze-surface-private.h | 55 +++++++
src/cairo-analyze-surface.c | 246 ++++++++++++++++++++++++++++++++++
src/cairo-paginated-surface-private.h | 2
src/cairo-paginated-surface.c | 210 +----------------------------
src/cairo-ps-surface.c | 10 -
6 files changed, 319 insertions(+), 206 deletions(-)
New commits:
diff-tree f9d4482137e7f13e634cc578c64d84ffdea16bca (from cb3a445150e3771d23854849c2a1c991eaee712c)
Author: Keith Packard <keithp at evo.keithp.com>
Date: Mon Feb 27 17:14:57 2006 -0500
rename evaluate surface to analyze surface, pull to separate files
diff --git a/src/Makefile.am b/src/Makefile.am
index 908bcb2..38947d4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -173,6 +173,8 @@ libcairo_la_SOURCES = \
cairo-meta-surface-private.h \
cairo-paginated-surface.c \
cairo-paginated-surface-private.h \
+ cairo-analyze-surface.c \
+ cairo-analyze-surface-private.h \
$(libcairo_atsui_sources) \
$(libcairo_ft_sources) \
$(libcairo_ps_sources) \
diff --git a/src/cairo-analyze-surface-private.h b/src/cairo-analyze-surface-private.h
new file mode 100644
index 0000000..1c90fc9
--- /dev/null
+++ b/src/cairo-analyze-surface-private.h
@@ -0,0 +1,55 @@
+/* $Id: $
+ *
+ * Copyright © 2005 Keith Packard
+ *
+ * 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 Keith Packard
+ *
+ * Contributor(s):
+ * Keith Packard <keithp at keithp.com>
+ */
+
+#ifndef CAIRO_ANALYZE_SURFACE_H
+#define CAIRO_ANALYZE_SURFACE_H
+
+#include "cairoint.h"
+
+cairo_private cairo_surface_t *
+_cairo_analyze_surface_create (cairo_surface_t *target,
+ int width,
+ int height);
+
+cairo_private pixman_region16_t *
+_cairo_analyze_surface_region_supported (cairo_surface_t *surface);
+
+cairo_private pixman_region16_t *
+_cairo_analyze_surface_region_unsupported (cairo_surface_t *unsupported);
+
+cairo_private cairo_bool_t
+_cairo_analyze_surface_has_unsupported (cairo_surface_t *unsupported);
+
+#endif /* CAIRO_ANALYZE_SURFACE_H */
diff --git a/src/cairo-analyze-surface.c b/src/cairo-analyze-surface.c
new file mode 100644
index 0000000..e2d5e84
--- /dev/null
+++ b/src/cairo-analyze-surface.c
@@ -0,0 +1,246 @@
+/*
+ * Copyright © 2006 Keith Packard
+ *
+ * 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 Keith Packard
+ *
+ * Contributor(s):
+ * Keith Packard <keithp at keithp.com>
+ */
+
+#include "cairoint.h"
+
+#include "cairo-analyze-surface-private.h"
+#include "cairo-paginated-surface-private.h"
+
+typedef struct {
+ cairo_surface_t base;
+ int width;
+ int height;
+
+ cairo_surface_t *target;
+
+ cairo_bool_t fallback;
+} cairo_analyze_surface_t;
+
+static cairo_int_status_t
+_cairo_analyze_surface_paint (void *abstract_surface,
+ cairo_operator_t op,
+ cairo_pattern_t *source)
+{
+ cairo_analyze_surface_t *surface = abstract_surface;
+ cairo_status_t status;
+
+ if (!surface->target->backend->paint)
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ else
+ status = (*surface->target->backend->paint) (surface->target, op,
+ source);
+ if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
+ surface->fallback = TRUE;
+ status = CAIRO_STATUS_SUCCESS;
+ }
+ return status;
+}
+
+static cairo_int_status_t
+_cairo_analyze_surface_mask (void *abstract_surface,
+ cairo_operator_t op,
+ cairo_pattern_t *source,
+ cairo_pattern_t *mask)
+{
+ cairo_analyze_surface_t *surface = abstract_surface;
+ cairo_status_t status;
+
+ if (!surface->target->backend->mask)
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ else
+ status = (*surface->target->backend->mask) (surface->target, op,
+ source, mask);
+ if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
+ surface->fallback = TRUE;
+ status = CAIRO_STATUS_SUCCESS;
+ }
+ return status;
+}
+
+static cairo_int_status_t
+_cairo_analyze_surface_stroke (void *abstract_surface,
+ cairo_operator_t op,
+ 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_analyze_surface_t *surface = abstract_surface;
+ cairo_status_t status;
+
+ if (!surface->target->backend->stroke)
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ else
+ status = (*surface->target->backend->stroke) (surface->target, op,
+ source, path, style,
+ ctm, ctm_inverse,
+ tolerance, antialias);
+ if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
+ surface->fallback = TRUE;
+ status = CAIRO_STATUS_SUCCESS;
+ }
+ return status;
+}
+
+static cairo_int_status_t
+_cairo_analyze_surface_fill (void *abstract_surface,
+ cairo_operator_t op,
+ cairo_pattern_t *source,
+ cairo_path_fixed_t *path,
+ cairo_fill_rule_t fill_rule,
+ double tolerance,
+ cairo_antialias_t antialias)
+{
+ cairo_analyze_surface_t *surface = abstract_surface;
+ cairo_status_t status;
+
+ if (!surface->target->backend->fill)
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ else
+ status = (*surface->target->backend->fill) (surface->target, op,
+ source, path, fill_rule,
+ tolerance, antialias);
+ if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
+ surface->fallback = TRUE;
+ status = CAIRO_STATUS_SUCCESS;
+ }
+ return status;
+}
+
+static cairo_int_status_t
+_cairo_analyze_surface_show_glyphs (void *abstract_surface,
+ cairo_operator_t op,
+ cairo_pattern_t *source,
+ const cairo_glyph_t *glyphs,
+ int num_glyphs,
+ cairo_scaled_font_t *scaled_font)
+{
+ cairo_analyze_surface_t *surface = abstract_surface;
+ cairo_status_t status;
+
+ if (!surface->target->backend->show_glyphs)
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ else
+ status = (*surface->target->backend->show_glyphs) (surface->target, op,
+ source,
+ glyphs, num_glyphs,
+ scaled_font);
+ if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
+ surface->fallback = TRUE;
+ status = CAIRO_STATUS_SUCCESS;
+ }
+ return status;
+}
+
+static const cairo_surface_backend_t cairo_analyze_surface_backend = {
+ NULL, /* create_similar */
+ NULL, /* finish_surface */
+ NULL, /* acquire_source_image */
+ NULL, /* release_source_image */
+ NULL, /* acquire_dest_image */
+ NULL, /* release_dest_image */
+ NULL, /* clone_similar */
+ NULL, /* composite */
+ NULL, /* fill_rectangles */
+ NULL, /* composite_trapezoids */
+ NULL, /* copy_page */
+ NULL, /* show_page */
+ NULL, /* set_clip_region */
+ NULL, /* clip_path */
+ NULL, /* get_extents */
+ NULL, /* old_show_glyphs */
+ NULL, /* get_font_options */
+ NULL, /* flush */
+ NULL, /* mark_dirty_rectangle */
+ NULL, /* scaled_font_fini */
+ NULL, /* scaled_glyph_fini */
+ _cairo_analyze_surface_paint,
+ _cairo_analyze_surface_mask,
+ _cairo_analyze_surface_stroke,
+ _cairo_analyze_surface_fill,
+ _cairo_analyze_surface_show_glyphs,
+ NULL, /* snapshot */
+};
+
+cairo_private cairo_surface_t *
+_cairo_analyze_surface_create (cairo_surface_t *target,
+ int width,
+ int height)
+{
+ cairo_analyze_surface_t *surface;
+
+ surface = malloc (sizeof (cairo_analyze_surface_t));
+ if (surface == NULL)
+ goto FAIL;
+
+ _cairo_surface_init (&surface->base, &cairo_analyze_surface_backend);
+
+ surface->width = width;
+ surface->height = height;
+
+ surface->target = target;
+ surface->fallback = FALSE;
+
+ return &surface->base;
+FAIL:
+ _cairo_error (CAIRO_STATUS_NO_MEMORY);
+ return NULL;
+}
+
+cairo_private pixman_region16_t *
+_cairo_analyze_surface_region_supported (cairo_surface_t *abstract_surface)
+{
+ /* XXX */
+ return NULL;
+}
+
+cairo_private pixman_region16_t *
+_cairo_analyze_surface_region_unsupported (cairo_surface_t *abstract_surface)
+{
+ /* XXX */
+ return NULL;
+}
+
+cairo_private cairo_bool_t
+_cairo_analyze_surface_has_unsupported (cairo_surface_t *abstract_surface)
+{
+ cairo_analyze_surface_t *surface = (cairo_analyze_surface_t *) abstract_surface;
+
+ return surface->fallback;
+}
+
+
diff --git a/src/cairo-paginated-surface-private.h b/src/cairo-paginated-surface-private.h
index c4c656b..b81b78b 100644
--- a/src/cairo-paginated-surface-private.h
+++ b/src/cairo-paginated-surface-private.h
@@ -39,7 +39,7 @@
#include "cairoint.h"
typedef enum {
- CAIRO_PAGINATED_MODE_EVALUATE, /* evaluate page regions */
+ CAIRO_PAGINATED_MODE_ANALYZE, /* analyze page regions */
CAIRO_PAGINATED_MODE_RENDER /* render page contents */
} cairo_paginated_mode_t;
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index 6d4c02e..a4979c1 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -69,6 +69,7 @@
#include "cairo-paginated-surface-private.h"
#include "cairo-meta-surface-private.h"
+#include "cairo-analyze-surface-private.h"
typedef struct _cairo_paginated_surface {
cairo_surface_t base;
@@ -101,21 +102,6 @@ const cairo_private cairo_surface_backen
static cairo_int_status_t
_cairo_paginated_surface_show_page (void *abstract_surface);
-typedef struct {
- cairo_surface_t base;
- int width;
- int height;
-
- cairo_surface_t *target;
-
- cairo_bool_t fallback;
-} cairo_evaluate_surface_t;
-
-static cairo_evaluate_surface_t *
-_cairo_evaluate_surface_create (cairo_surface_t *target,
- int width,
- int height);
-
cairo_surface_t *
_cairo_paginated_surface_create (cairo_surface_t *target,
cairo_content_t content,
@@ -215,25 +201,25 @@ _cairo_paginated_surface_release_source_
static cairo_int_status_t
_paint_page (cairo_paginated_surface_t *surface)
{
- cairo_evaluate_surface_t *evaluate;
+ cairo_surface_t *analyze;
cairo_surface_t *image;
cairo_pattern_t *pattern;
cairo_status_t status;
- evaluate = _cairo_evaluate_surface_create (surface->target,
- surface->width, surface->height);
+ analyze = _cairo_analyze_surface_create (surface->target,
+ surface->width, surface->height);
- surface->funcs->set_mode (surface->target, CAIRO_PAGINATED_MODE_EVALUATE);
- _cairo_meta_surface_replay (surface->meta, &evaluate->base);
+ surface->funcs->set_mode (surface->target, CAIRO_PAGINATED_MODE_ANALYZE);
+ _cairo_meta_surface_replay (surface->meta, analyze);
surface->funcs->set_mode (surface->target, CAIRO_PAGINATED_MODE_RENDER);
- if (evaluate->base.status) {
- status = evaluate->base.status;
- cairo_surface_destroy (&evaluate->base);
+ if (analyze->status) {
+ status = analyze->status;
+ cairo_surface_destroy (analyze);
return status;
}
- if (evaluate->fallback)
+ if (_cairo_analyze_surface_has_unsupported (analyze))
{
image = _cairo_image_surface_create_with_content (surface->content,
surface->width,
@@ -454,179 +440,3 @@ const cairo_surface_backend_t cairo_pagi
_cairo_paginated_surface_show_glyphs,
_cairo_paginated_surface_snapshot
};
-
-static cairo_int_status_t
-_cairo_evaluate_surface_paint (void *abstract_surface,
- cairo_operator_t op,
- cairo_pattern_t *source)
-{
- cairo_evaluate_surface_t *surface = abstract_surface;
- cairo_status_t status;
-
- if (!surface->target->backend->paint)
- status = CAIRO_INT_STATUS_UNSUPPORTED;
- else
- status = (*surface->target->backend->paint) (surface->target, op,
- source);
- if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
- surface->fallback = TRUE;
- status = CAIRO_STATUS_SUCCESS;
- }
- return status;
-}
-
-static cairo_int_status_t
-_cairo_evaluate_surface_mask (void *abstract_surface,
- cairo_operator_t op,
- cairo_pattern_t *source,
- cairo_pattern_t *mask)
-{
- cairo_evaluate_surface_t *surface = abstract_surface;
- cairo_status_t status;
-
- if (!surface->target->backend->mask)
- status = CAIRO_INT_STATUS_UNSUPPORTED;
- else
- status = (*surface->target->backend->mask) (surface->target, op,
- source, mask);
- if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
- surface->fallback = TRUE;
- status = CAIRO_STATUS_SUCCESS;
- }
- return status;
-}
-
-static cairo_int_status_t
-_cairo_evaluate_surface_stroke (void *abstract_surface,
- cairo_operator_t op,
- 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_evaluate_surface_t *surface = abstract_surface;
- cairo_status_t status;
-
- if (!surface->target->backend->stroke)
- status = CAIRO_INT_STATUS_UNSUPPORTED;
- else
- status = (*surface->target->backend->stroke) (surface->target, op,
- source, path, style,
- ctm, ctm_inverse,
- tolerance, antialias);
- if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
- surface->fallback = TRUE;
- status = CAIRO_STATUS_SUCCESS;
- }
- return status;
-}
-
-static cairo_int_status_t
-_cairo_evaluate_surface_fill (void *abstract_surface,
- cairo_operator_t op,
- cairo_pattern_t *source,
- cairo_path_fixed_t *path,
- cairo_fill_rule_t fill_rule,
- double tolerance,
- cairo_antialias_t antialias)
-{
- cairo_evaluate_surface_t *surface = abstract_surface;
- cairo_status_t status;
-
- if (!surface->target->backend->fill)
- status = CAIRO_INT_STATUS_UNSUPPORTED;
- else
- status = (*surface->target->backend->fill) (surface->target, op,
- source, path, fill_rule,
- tolerance, antialias);
- if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
- surface->fallback = TRUE;
- status = CAIRO_STATUS_SUCCESS;
- }
- return status;
-}
-
-static cairo_int_status_t
-_cairo_evaluate_surface_show_glyphs (void *abstract_surface,
- cairo_operator_t op,
- cairo_pattern_t *source,
- const cairo_glyph_t *glyphs,
- int num_glyphs,
- cairo_scaled_font_t *scaled_font)
-{
- cairo_evaluate_surface_t *surface = abstract_surface;
- cairo_status_t status;
-
- if (!surface->target->backend->show_glyphs)
- status = CAIRO_INT_STATUS_UNSUPPORTED;
- else
- status = (*surface->target->backend->show_glyphs) (surface->target, op,
- source,
- glyphs, num_glyphs,
- scaled_font);
- if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
- surface->fallback = TRUE;
- status = CAIRO_STATUS_SUCCESS;
- }
- return status;
-}
-
-static const cairo_surface_backend_t cairo_evaluate_surface_backend = {
- NULL, /* create_similar */
- NULL, /* finish_surface */
- NULL, /* acquire_source_image */
- NULL, /* release_source_image */
- NULL, /* acquire_dest_image */
- NULL, /* release_dest_image */
- NULL, /* clone_similar */
- NULL, /* composite */
- NULL, /* fill_rectangles */
- NULL, /* composite_trapezoids */
- NULL, /* copy_page */
- NULL, /* show_page */
- NULL, /* set_clip_region */
- NULL, /* clip_path */
- NULL, /* get_extents */
- NULL, /* old_show_glyphs */
- NULL, /* get_font_options */
- NULL, /* flush */
- NULL, /* mark_dirty_rectangle */
- NULL, /* scaled_font_fini */
- NULL, /* scaled_glyph_fini */
- _cairo_evaluate_surface_paint,
- _cairo_evaluate_surface_mask,
- _cairo_evaluate_surface_stroke,
- _cairo_evaluate_surface_fill,
- _cairo_evaluate_surface_show_glyphs,
- NULL, /* snapshot */
-};
-
-static cairo_evaluate_surface_t *
-_cairo_evaluate_surface_create (cairo_surface_t *target,
- int width,
- int height)
-{
- cairo_evaluate_surface_t *surface;
-
- surface = malloc (sizeof (cairo_evaluate_surface_t));
- if (surface == NULL)
- goto FAIL;
-
- _cairo_surface_init (&surface->base, &cairo_evaluate_surface_backend);
-
- surface->width = width;
- surface->height = height;
-
- surface->target = target;
- surface->fallback = FALSE;
-
- return surface;
-FAIL:
- _cairo_error (CAIRO_STATUS_NO_MEMORY);
- return NULL;
-}
-
-
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 2cf8a9d..f1ae414 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -144,7 +144,7 @@ _cairo_ps_surface_create_for_stream_inte
surface->height = height;
surface->x_dpi = PS_SURFACE_DPI_DEFAULT;
surface->y_dpi = PS_SURFACE_DPI_DEFAULT;
- surface->mode = CAIRO_PAGINATED_MODE_EVALUATE;
+ surface->mode = CAIRO_PAGINATED_MODE_ANALYZE;
#if DONE_ADDING_DEVICE_SCALE_SUPPORT_AFTER_SWITCHING_TO_PAGINATED
surface->base.device_x_scale = surface->x_dpi / 72.0;
surface->base.device_y_scale = surface->y_dpi / 72.0;
@@ -943,7 +943,7 @@ _cairo_ps_surface_intersect_clip_path (v
cairo_ps_surface_path_info_t info;
const char *ps_operator;
- if (surface->mode == CAIRO_PAGINATED_MODE_EVALUATE)
+ if (surface->mode == CAIRO_PAGINATED_MODE_ANALYZE)
return CAIRO_STATUS_SUCCESS;
_cairo_output_stream_printf (stream,
@@ -1084,7 +1084,7 @@ _cairo_ps_surface_paint (void *abstrac
cairo_output_stream_t *stream = surface->stream;
cairo_ps_surface_path_info_t info;
- if (surface->mode == CAIRO_PAGINATED_MODE_EVALUATE) {
+ if (surface->mode == CAIRO_PAGINATED_MODE_ANALYZE) {
if (!pattern_operation_supported (op, source))
return CAIRO_INT_STATUS_UNSUPPORTED;
return CAIRO_STATUS_SUCCESS;
@@ -1158,7 +1158,7 @@ _cairo_ps_surface_stroke (void *abstra
cairo_int_status_t status;
cairo_ps_surface_path_info_t info;
- if (surface->mode == CAIRO_PAGINATED_MODE_EVALUATE) {
+ if (surface->mode == CAIRO_PAGINATED_MODE_ANALYZE) {
if (!pattern_operation_supported (op, source))
return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -1236,7 +1236,7 @@ _cairo_ps_surface_fill (void *abstract_
cairo_ps_surface_path_info_t info;
const char *ps_operator;
- if (surface->mode == CAIRO_PAGINATED_MODE_EVALUATE) {
+ if (surface->mode == CAIRO_PAGINATED_MODE_ANALYZE) {
if (!pattern_operation_supported (op, source))
return CAIRO_INT_STATUS_UNSUPPORTED;
return CAIRO_STATUS_SUCCESS;
More information about the cairo-commit
mailing list