From 48218fec48d1bfa2a93cc21f8f9df569e40ca79e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 8 Nov 2005 17:16:21 +0000 Subject: [PATCH] Add support to cairo_meta_surface for the 5 basic drawing operations. Remove _cairo_meta_surface_get_extents and _cairo_meta_surface_old_show_glyphs. Remove size for _cairo_meta_surface_create. It is no longer needed now that get_extents is not a required backend function. Track change in cairo_meta_surface_create no longer requiring a size Qualify the glyphs argument to backend->show_glyphs as const. Whitespace style cleanup. --- ChangeLog | 31 ++ src/cairo-meta-surface-private.h | 99 ++++-- src/cairo-meta-surface.c | 553 +++++++++++++++++++------------ src/cairo-ps-surface.c | 6 +- src/cairo-scaled-font.c | 4 +- src/cairo-surface.c | 10 +- src/cairoint.h | 8 +- 7 files changed, 451 insertions(+), 260 deletions(-) diff --git a/ChangeLog b/ChangeLog index 920489bb3..7b34bd3ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2005-11-08 Carl Worth + + * src/cairo-meta-surface-private.h: + * src/cairo-meta-surface.c: (_cairo_meta_surface_finish), + (_cairo_meta_surface_paint), + (_cairo_meta_surface_mask), (_cairo_meta_surface_stroke), + (_cairo_meta_surface_fill), (_cairo_meta_surface_show_glyphs), + (_cairo_meta_surface_replay): Add support to cairo_meta_surface + for the 5 basic drawing operations. Remove + _cairo_meta_surface_get_extents and + _cairo_meta_surface_old_show_glyphs. + + * src/cairo-meta-surface.c: (_cairo_meta_surface_create), + (_cairo_meta_surface_create_similar): Remove size for + _cairo_meta_surface_create. It is no longer needed now that + get_extents is not a required backend function. + + * src/cairo-ps-surface.c: + (_cairo_ps_surface_create_for_stream_internal), + (_cairo_ps_surface_show_page): Track change in + cairo_meta_surface_create no longer requiring a size + + * src/cairoint.h: + * src/cairo-scaled-font.c: (_cairo_scaled_font_show_glyphs): + * src/cairo-surface.c: (_cairo_surface_old_show_glyphs_draw_func), + (_fallback_show_glyphs), (_cairo_surface_show_glyphs): Qualify the + glyphs argument to backend->show_glyphs as const. + + * src/cairo-meta-surface.c: (_init_pattern_with_snapshot): + Whitespace style cleanup. + 2005-11-08 Carl Worth * ROADMAP: Split the 1.2.0 features into "essential" and diff --git a/src/cairo-meta-surface-private.h b/src/cairo-meta-surface-private.h index 344312e61..1a27b483e 100644 --- a/src/cairo-meta-surface-private.h +++ b/src/cairo-meta-surface-private.h @@ -40,15 +40,71 @@ #include "cairo-path-fixed-private.h" typedef enum { + /* The 5 basic drawing operations. */ + CAIRO_COMMAND_PAINT, + CAIRO_COMMAND_MASK, + CAIRO_COMMAND_STROKE, + CAIRO_COMMAND_FILL, + CAIRO_COMMAND_SHOW_GLYPHS, + + /* Other junk. For most of these, we should be able to assert that + * they never get called except as part of fallbacks for the 5 + * basic drawing operations (which we implement already so the + * fallbacks should never get triggered). So the plan is to + * eliminate as many of these as possible. */ + CAIRO_COMMAND_COMPOSITE, CAIRO_COMMAND_FILL_RECTANGLES, CAIRO_COMMAND_COMPOSITE_TRAPEZOIDS, CAIRO_COMMAND_SET_CLIP_REGION, CAIRO_COMMAND_INTERSECT_CLIP_PATH, - CAIRO_COMMAND_SHOW_GLYPHS, - CAIRO_COMMAND_FILL + CAIRO_COMMAND_OLD_SHOW_GLYPHS, } cairo_command_type_t; +typedef struct _cairo_command_paint { + cairo_command_type_t type; + cairo_operator_t operator; + cairo_pattern_union_t source; +} cairo_command_paint_t; + +typedef struct _cairo_command_mask { + cairo_command_type_t type; + cairo_operator_t operator; + cairo_pattern_union_t source; + cairo_pattern_union_t mask; +} cairo_command_mask_t; + +typedef struct _cairo_command_stroke { + cairo_command_type_t type; + cairo_operator_t operator; + cairo_pattern_union_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_command_stroke_t; + +typedef struct _cairo_command_fill { + cairo_command_type_t type; + cairo_operator_t operator; + cairo_pattern_union_t source; + cairo_path_fixed_t path; + cairo_fill_rule_t fill_rule; + double tolerance; + cairo_antialias_t antialias; +} cairo_command_fill_t; + +typedef struct _cairo_command_show_glyphs { + cairo_command_type_t type; + cairo_operator_t operator; + cairo_pattern_union_t source; + cairo_glyph_t *glyphs; + int num_glyphs; + cairo_scaled_font_t *scaled_font; +} cairo_command_show_glyphs_t; + typedef struct _cairo_command_composite { cairo_command_type_t type; cairo_operator_t operator; @@ -103,50 +159,31 @@ typedef struct _cairo_command_intersect_clip_path { cairo_antialias_t antialias; } cairo_command_intersect_clip_path_t; -typedef struct _cairo_command_show_glyphs { - cairo_command_type_t type; - cairo_scaled_font_t *scaled_font; - cairo_operator_t operator; - cairo_pattern_union_t pattern; - int source_x; - int source_y; - int dest_x; - int dest_y; - unsigned int width; - unsigned int height; - cairo_glyph_t *glyphs; - int num_glyphs; -} cairo_command_show_glyphs_t; - -typedef struct _cairo_command_fill { - cairo_command_type_t type; - cairo_operator_t operator; - cairo_pattern_union_t pattern; - cairo_path_fixed_t path; - cairo_fill_rule_t fill_rule; - double tolerance; - cairo_antialias_t antialias; -} cairo_command_fill_t; - typedef union _cairo_command { cairo_command_type_t type; + + /* The 5 basic drawing operations. */ + cairo_command_paint_t paint; + cairo_command_mask_t mask; + cairo_command_stroke_t stroke; + cairo_command_fill_t fill; + cairo_command_show_glyphs_t show_glyphs; + + /* The other junk. */ cairo_command_composite_t composite; cairo_command_fill_rectangles_t fill_rectangles; cairo_command_composite_trapezoids_t composite_trapezoids; cairo_command_set_clip_region_t set_clip_region; cairo_command_intersect_clip_path_t intersect_clip_path; - cairo_command_show_glyphs_t show_glyphs; - cairo_command_fill_t fill; } cairo_command_t; typedef struct _cairo_meta_surface { cairo_surface_t base; - double width, height; cairo_array_t commands; } cairo_meta_surface_t; cairo_private cairo_surface_t * -_cairo_meta_surface_create (double width, double height); +_cairo_meta_surface_create (void); cairo_private cairo_int_status_t _cairo_meta_surface_replay (cairo_surface_t *surface, diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c index 681f10831..f5f0c0336 100644 --- a/src/cairo-meta-surface.c +++ b/src/cairo-meta-surface.c @@ -31,6 +31,7 @@ * * Contributor(s): * Kristian Høgsberg + * Carl Worth */ #include "cairoint.h" @@ -40,7 +41,7 @@ static const cairo_surface_backend_t cairo_meta_surface_backend; cairo_surface_t * -_cairo_meta_surface_create (double width, double height) +_cairo_meta_surface_create (void) { cairo_meta_surface_t *meta; @@ -50,8 +51,6 @@ _cairo_meta_surface_create (double width, double height) return (cairo_surface_t*) &_cairo_surface_nil; } - meta->width = width; - meta->height = height; _cairo_surface_init (&meta->base, &cairo_meta_surface_backend); _cairo_array_init (&meta->commands, sizeof (cairo_command_t *)); @@ -64,7 +63,7 @@ _cairo_meta_surface_create_similar (void *abstract_surface, int width, int height) { - return _cairo_meta_surface_create (width, height); + return _cairo_meta_surface_create (); } static cairo_status_t @@ -80,6 +79,42 @@ _cairo_meta_surface_finish (void *abstract_surface) for (i = 0; i < num_elements; i++) { command = elements[i]; switch (command->type) { + + /* 5 basic drawing operations */ + + case CAIRO_COMMAND_PAINT: + _cairo_pattern_fini (&command->paint.source.base); + free (command); + break; + + case CAIRO_COMMAND_MASK: + _cairo_pattern_fini (&command->mask.source.base); + _cairo_pattern_fini (&command->mask.mask.base); + free (command); + break; + + case CAIRO_COMMAND_STROKE: + _cairo_pattern_fini (&command->stroke.source.base); + _cairo_path_fixed_fini (&command->stroke.path); + _cairo_stroke_style_fini (&command->stroke.style); + free (command); + break; + + case CAIRO_COMMAND_FILL: + _cairo_pattern_fini (&command->fill.source.base); + _cairo_path_fixed_fini (&command->fill.path); + free (command); + break; + + case CAIRO_COMMAND_SHOW_GLYPHS: + _cairo_pattern_fini (&command->show_glyphs.source.base); + free (command->show_glyphs.glyphs); + cairo_scaled_font_destroy (command->show_glyphs.scaled_font); + free (command); + break; + + /* Other junk. */ + case CAIRO_COMMAND_COMPOSITE: _cairo_pattern_fini (&command->composite.src_pattern.base); if (command->composite.mask_pattern_pointer) @@ -104,19 +139,6 @@ _cairo_meta_surface_finish (void *abstract_surface) free (command); break; - case CAIRO_COMMAND_SHOW_GLYPHS: - cairo_scaled_font_destroy (command->show_glyphs.scaled_font); - _cairo_pattern_fini (&command->show_glyphs.pattern.base); - free (command->show_glyphs.glyphs); - free (command); - break; - - case CAIRO_COMMAND_FILL: - _cairo_pattern_fini (&command->fill.pattern.base); - _cairo_path_fixed_fini (&command->fill.path); - free (command); - break; - default: ASSERT_NOT_REACHED; } @@ -134,7 +156,8 @@ _init_pattern_with_snapshot (cairo_pattern_t *pattern, _cairo_pattern_init_copy (pattern, other); if (pattern->type == CAIRO_PATTERN_SURFACE) { - cairo_surface_pattern_t *surface_pattern = (cairo_surface_pattern_t *) pattern; + cairo_surface_pattern_t *surface_pattern = + (cairo_surface_pattern_t *) pattern; cairo_surface_t *surface = surface_pattern->surface; surface_pattern->surface = _cairo_surface_snapshot (surface); @@ -148,6 +171,232 @@ _init_pattern_with_snapshot (cairo_pattern_t *pattern, return CAIRO_STATUS_SUCCESS; } +static cairo_int_status_t +_cairo_meta_surface_paint (void *abstract_surface, + cairo_operator_t operator, + cairo_pattern_t *source) +{ + cairo_status_t status; + cairo_meta_surface_t *meta = abstract_surface; + cairo_command_paint_t *command; + + command = malloc (sizeof (cairo_command_paint_t)); + if (command == NULL) + return CAIRO_STATUS_NO_MEMORY; + + command->type = CAIRO_COMMAND_PAINT; + command->operator = operator; + + status = _init_pattern_with_snapshot (&command->source.base, source); + if (status) + goto CLEANUP_COMMAND; + + status = _cairo_array_append (&meta->commands, &command); + if (status) + goto CLEANUP_SOURCE; + + return CAIRO_STATUS_SUCCESS; + + CLEANUP_SOURCE: + _cairo_pattern_fini (&command->source.base); + CLEANUP_COMMAND: + free (command); + return status; +} + +static cairo_int_status_t +_cairo_meta_surface_mask (void *abstract_surface, + cairo_operator_t operator, + cairo_pattern_t *source, + cairo_pattern_t *mask) +{ + cairo_status_t status; + cairo_meta_surface_t *meta = abstract_surface; + cairo_command_mask_t *command; + + command = malloc (sizeof (cairo_command_mask_t)); + if (command == NULL) + return CAIRO_STATUS_NO_MEMORY; + + command->type = CAIRO_COMMAND_MASK; + command->operator = operator; + + status = _init_pattern_with_snapshot (&command->source.base, source); + if (status) + goto CLEANUP_COMMAND; + + status = _init_pattern_with_snapshot (&command->mask.base, mask); + if (status) + goto CLEANUP_SOURCE; + + status = _cairo_array_append (&meta->commands, &command); + if (status) + goto CLEANUP_MASK; + + return CAIRO_STATUS_SUCCESS; + + CLEANUP_MASK: + _cairo_pattern_fini (&command->mask.base); + CLEANUP_SOURCE: + _cairo_pattern_fini (&command->source.base); + CLEANUP_COMMAND: + free (command); + return status; +} + +static cairo_int_status_t +_cairo_meta_surface_stroke (void *abstract_surface, + cairo_operator_t operator, + 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_status_t status; + cairo_meta_surface_t *meta = abstract_surface; + cairo_command_stroke_t *command; + + command = malloc (sizeof (cairo_command_stroke_t)); + if (command == NULL) + return CAIRO_STATUS_NO_MEMORY; + + command->type = CAIRO_COMMAND_STROKE; + command->operator = operator; + + status = _init_pattern_with_snapshot (&command->source.base, source); + if (status) + goto CLEANUP_COMMAND; + + status = _cairo_path_fixed_init_copy (&command->path, path); + if (status) + goto CLEANUP_SOURCE; + + status = _cairo_stroke_style_init_copy (&command->style, style); + if (status) + goto CLEANUP_PATH; + + command->ctm = *ctm; + command->ctm_inverse = *ctm_inverse; + command->tolerance = tolerance; + command->antialias = antialias; + + status = _cairo_array_append (&meta->commands, &command); + if (status) + goto CLEANUP_STYLE; + + return CAIRO_STATUS_SUCCESS; + + CLEANUP_STYLE: + _cairo_stroke_style_fini (&command->style); + CLEANUP_PATH: + _cairo_path_fixed_fini (&command->path); + CLEANUP_SOURCE: + _cairo_pattern_fini (&command->source.base); + CLEANUP_COMMAND: + free (command); + return status; +} + +static cairo_int_status_t +_cairo_meta_surface_fill (void *abstract_surface, + cairo_operator_t operator, + cairo_pattern_t *source, + cairo_path_fixed_t *path, + cairo_fill_rule_t fill_rule, + double tolerance, + cairo_antialias_t antialias) +{ + cairo_status_t status; + cairo_meta_surface_t *meta = abstract_surface; + cairo_command_fill_t *command; + + command = malloc (sizeof (cairo_command_fill_t)); + if (command == NULL) + return CAIRO_STATUS_NO_MEMORY; + + command->type = CAIRO_COMMAND_FILL; + command->operator = operator; + + status = _init_pattern_with_snapshot (&command->source.base, source); + if (status) + goto CLEANUP_COMMAND; + + status = _cairo_path_fixed_init_copy (&command->path, path); + if (status) + goto CLEANUP_SOURCE; + + command->fill_rule = fill_rule; + command->tolerance = tolerance; + command->antialias = antialias; + + status = _cairo_array_append (&meta->commands, &command); + if (status) + goto CLEANUP_PATH; + + return CAIRO_STATUS_SUCCESS; + + CLEANUP_PATH: + _cairo_path_fixed_fini (&command->path); + CLEANUP_SOURCE: + _cairo_pattern_fini (&command->source.base); + CLEANUP_COMMAND: + free (command); + return status; +} + +static cairo_int_status_t +_cairo_meta_surface_show_glyphs (void *abstract_surface, + cairo_operator_t operator, + cairo_pattern_t *source, + const cairo_glyph_t *glyphs, + int num_glyphs, + cairo_scaled_font_t *scaled_font) +{ + cairo_status_t status; + cairo_meta_surface_t *meta = abstract_surface; + cairo_command_show_glyphs_t *command; + + command = malloc (sizeof (cairo_command_show_glyphs_t)); + if (command == NULL) + return CAIRO_STATUS_NO_MEMORY; + + command->type = CAIRO_COMMAND_SHOW_GLYPHS; + command->operator = operator; + + status = _init_pattern_with_snapshot (&command->source.base, source); + if (status) + goto CLEANUP_COMMAND; + + command->glyphs = malloc (sizeof (cairo_glyph_t) * num_glyphs); + if (command->glyphs == NULL) { + status = CAIRO_STATUS_NO_MEMORY; + goto CLEANUP_SOURCE; + } + memcpy (command->glyphs, glyphs, sizeof (cairo_glyph_t) * num_glyphs); + + command->num_glyphs = num_glyphs; + + command->scaled_font = cairo_scaled_font_reference (scaled_font); + + status = _cairo_array_append (&meta->commands, &command); + if (status) + goto CLEANUP_SCALED_FONT; + + return CAIRO_STATUS_SUCCESS; + + CLEANUP_SCALED_FONT: + cairo_scaled_font_destroy (command->scaled_font); + free (command->glyphs); + CLEANUP_SOURCE: + _cairo_pattern_fini (&command->source.base); + CLEANUP_COMMAND: + free (command); + return status; +} + static cairo_int_status_t _cairo_meta_surface_composite (cairo_operator_t operator, cairo_pattern_t *src_pattern, @@ -345,120 +594,6 @@ _cairo_meta_surface_intersect_clip_path (void *dst, return CAIRO_STATUS_SUCCESS; } -static cairo_int_status_t -_cairo_meta_surface_get_extents (void *abstract_surface, - cairo_rectangle_t *rectangle) -{ - cairo_meta_surface_t *meta = abstract_surface; - - /* Currently this is used for getting the extents of the surface - * before calling cairo_paint(). This is the only this that - * requires the meta surface to have an explicit size. If paint - * was just a backend function, this would not be necessary. */ - - rectangle->x = 0; - rectangle->y = 0; - rectangle->width = meta->width; - rectangle->height = meta->height; - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_int_status_t -_cairo_meta_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font, - cairo_operator_t operator, - cairo_pattern_t *pattern, - void *abstract_surface, - int source_x, - int source_y, - int dest_x, - int dest_y, - unsigned int width, - unsigned int height, - const cairo_glyph_t *glyphs, - int num_glyphs) -{ - cairo_status_t status; - cairo_meta_surface_t *meta = abstract_surface; - cairo_command_show_glyphs_t *command; - - command = malloc (sizeof (cairo_command_show_glyphs_t)); - if (command == NULL) - return CAIRO_STATUS_NO_MEMORY; - - command->type = CAIRO_COMMAND_SHOW_GLYPHS; - command->scaled_font = cairo_scaled_font_reference (scaled_font); - command->operator = operator; - _init_pattern_with_snapshot (&command->pattern.base, pattern); - command->source_x = source_x; - command->source_y = source_y; - command->dest_x = dest_x; - command->dest_y = dest_y; - command->width = width; - command->height = height; - - command->glyphs = malloc (sizeof (cairo_glyph_t) * num_glyphs); - if (command->glyphs == NULL) { - _cairo_pattern_fini (&command->pattern.base); - free (command); - return CAIRO_STATUS_NO_MEMORY; - } - memcpy (command->glyphs, glyphs, sizeof (cairo_glyph_t) * num_glyphs); - - command->num_glyphs = num_glyphs; - - status = _cairo_array_append (&meta->commands, &command); - if (status) { - _cairo_pattern_fini (&command->pattern.base); - free (command->glyphs); - free (command); - return status; - } - - return CAIRO_STATUS_SUCCESS; -} - -static cairo_int_status_t -_cairo_meta_surface_fill (void *abstract_surface, - cairo_operator_t operator, - cairo_pattern_t *pattern, - cairo_path_fixed_t *path, - cairo_fill_rule_t fill_rule, - double tolerance, - cairo_antialias_t antialias) -{ - cairo_meta_surface_t *meta = abstract_surface; - cairo_command_fill_t *command; - cairo_status_t status; - - command = malloc (sizeof (cairo_command_fill_t)); - if (command == NULL) - return CAIRO_STATUS_NO_MEMORY; - - command->type = CAIRO_COMMAND_FILL; - command->operator = operator; - _init_pattern_with_snapshot (&command->pattern.base, pattern); - status = _cairo_path_fixed_init_copy (&command->path, path); - if (status) { - _cairo_pattern_fini (&command->pattern.base); - free (command); - return CAIRO_STATUS_NO_MEMORY; - } - command->fill_rule = fill_rule; - command->tolerance = tolerance; - command->antialias = antialias; - - status = _cairo_array_append (&meta->commands, &command); - if (status) { - _cairo_path_fixed_fini (&command->path); - _cairo_pattern_fini (&command->pattern.base); - free (command); - return status; - } - - return CAIRO_STATUS_SUCCESS; -} - /** * _cairo_surface_is_meta: * @surface: a #cairo_surface_t @@ -488,23 +623,23 @@ static const cairo_surface_backend_t cairo_meta_surface_backend = { NULL, /* show_page */ NULL, /* set_clip_region */ _cairo_meta_surface_intersect_clip_path, - _cairo_meta_surface_get_extents, - _cairo_meta_surface_old_show_glyphs, + 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 */ - /* Here are the drawing functions, (which are in some sense the - * only things that cairo_meta_surface should need to + /* Here are the 5 basic drawing operations, (which are in some + * sense the only things that cairo_meta_surface should need to * implement). */ - NULL, /* paint */ - NULL, /* mask */ - NULL, /* stroke */ + _cairo_meta_surface_paint, + _cairo_meta_surface_mask, + _cairo_meta_surface_stroke, _cairo_meta_surface_fill, - NULL /* show_glyphs */ + _cairo_meta_surface_show_glyphs }; cairo_int_status_t @@ -515,7 +650,6 @@ _cairo_meta_surface_replay (cairo_surface_t *surface, cairo_command_t *command, **elements; int i, num_elements; cairo_int_status_t status; - cairo_traps_t traps; cairo_clip_t clip; meta = (cairo_meta_surface_t *) surface; @@ -528,6 +662,70 @@ _cairo_meta_surface_replay (cairo_surface_t *surface, for (i = 0; i < num_elements; i++) { command = elements[i]; switch (command->type) { + case CAIRO_COMMAND_PAINT: + status = _cairo_surface_set_clip (target, &clip); + if (status) + break; + + status = _cairo_surface_paint (target, + command->paint.operator, + &command->paint.source.base); + break; + + case CAIRO_COMMAND_MASK: + status = _cairo_surface_set_clip (target, &clip); + if (status) + break; + + status = _cairo_surface_mask (target, + command->mask.operator, + &command->mask.source.base, + &command->mask.mask.base); + break; + + case CAIRO_COMMAND_STROKE: + status = _cairo_surface_set_clip (target, &clip); + if (status) + break; + + status = _cairo_surface_stroke (target, + command->stroke.operator, + &command->stroke.source.base, + &command->stroke.path, + &command->stroke.style, + &command->stroke.ctm, + &command->stroke.ctm_inverse, + command->stroke.tolerance, + command->stroke.antialias); + break; + + case CAIRO_COMMAND_FILL: + status = _cairo_surface_set_clip (target, &clip); + if (status) + break; + + status = _cairo_surface_fill (target, + command->fill.operator, + &command->fill.source.base, + &command->fill.path, + command->fill.fill_rule, + command->fill.tolerance, + command->fill.antialias); + break; + + case CAIRO_COMMAND_SHOW_GLYPHS: + status = _cairo_surface_set_clip (target, &clip); + if (status) + break; + + status = _cairo_surface_show_glyphs (target, + command->show_glyphs.operator, + &command->show_glyphs.source.base, + command->show_glyphs.glyphs, + command->show_glyphs.num_glyphs, + command->show_glyphs.scaled_font); + break; + case CAIRO_COMMAND_COMPOSITE: status = _cairo_surface_set_clip (target, &clip); if (status) @@ -595,79 +793,6 @@ _cairo_meta_surface_replay (cairo_surface_t *surface, target); break; - case CAIRO_COMMAND_SHOW_GLYPHS: - status = _cairo_surface_set_clip (target, &clip); - if (status) - break; - - status = _cairo_surface_old_show_glyphs - (command->show_glyphs.scaled_font, - command->show_glyphs.operator, - &command->show_glyphs.pattern.base, - target, - command->show_glyphs.source_x, - command->show_glyphs.source_y, - command->show_glyphs.dest_x, - command->show_glyphs.dest_y, - command->show_glyphs.width, - command->show_glyphs.height, - command->show_glyphs.glyphs, - command->show_glyphs.num_glyphs); - if (status != CAIRO_INT_STATUS_UNSUPPORTED) - break; - - status = (*command->show_glyphs.scaled_font->backend-> - show_glyphs) (command->show_glyphs.scaled_font, - command->show_glyphs.operator, - &command->show_glyphs.pattern.base, - target, - command->show_glyphs.source_x, - command->show_glyphs.source_y, - command->show_glyphs.dest_x, - command->show_glyphs.dest_y, - command->show_glyphs.width, - command->show_glyphs.height, - command->show_glyphs.glyphs, - command->show_glyphs.num_glyphs); - - break; - - case CAIRO_COMMAND_FILL: - status = _cairo_surface_set_clip (target, &clip); - if (status) - break; - - status = _cairo_surface_fill (target, - command->fill.operator, - &command->fill.pattern.base, - &command->fill.path, - command->fill.fill_rule, - command->fill.tolerance, - command->fill.antialias); - if (status != CAIRO_INT_STATUS_UNSUPPORTED) - break; - - _cairo_traps_init (&traps); - - status = _cairo_path_fixed_fill_to_traps (&command->fill.path, - command->fill.fill_rule, - command->fill.tolerance, - &traps); - if (status) { - _cairo_traps_fini (&traps); - break; - } - - status = _cairo_surface_clip_and_composite_trapezoids (&command->fill.pattern.base, - command->fill.operator, - target, - &traps, - &clip, - command->fill.antialias); - - _cairo_traps_fini (&traps); - break; - default: ASSERT_NOT_REACHED; } diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index e17b606c8..7b9ec7253 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -106,8 +106,7 @@ _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream, surface->base.device_x_scale = surface->x_dpi / 72.0; surface->base.device_y_scale = surface->y_dpi / 72.0; - surface->current_page = _cairo_meta_surface_create (width, - height); + surface->current_page = _cairo_meta_surface_create (); if (surface->current_page->status) { free (surface); _cairo_error (CAIRO_STATUS_NO_MEMORY); @@ -344,8 +343,7 @@ _cairo_ps_surface_show_page (void *abstract_surface) if (status) return status; - surface->current_page = _cairo_meta_surface_create (surface->width, - surface->height); + surface->current_page = _cairo_meta_surface_create (); if (surface->current_page->status) return CAIRO_STATUS_NO_MEMORY; diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c index 4b321555c..3fc619878 100644 --- a/src/cairo-scaled-font.c +++ b/src/cairo-scaled-font.c @@ -1,4 +1,4 @@ -/* $Id: cairo-scaled-font.c,v 1.7 2005-09-13 22:53:19 cworth Exp $ +/* $Id: cairo-scaled-font.c,v 1.8 2005-11-09 01:16:21 cworth Exp $ * * Copyright © 2005 Keith Packard * @@ -785,7 +785,7 @@ _cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font, int dest_y, unsigned int width, unsigned int height, - cairo_glyph_t *glyphs, + const cairo_glyph_t *glyphs, int num_glyphs) { cairo_status_t status; diff --git a/src/cairo-surface.c b/src/cairo-surface.c index ca81918d4..34dff5dd1 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -1826,7 +1826,7 @@ _cairo_surface_get_extents (cairo_surface_t *surface, typedef struct { cairo_scaled_font_t *font; - cairo_glyph_t *glyphs; + const cairo_glyph_t *glyphs; int num_glyphs; } cairo_show_glyphs_info_t; @@ -1852,8 +1852,8 @@ _cairo_surface_old_show_glyphs_draw_func (void *closure, for (i = 0; i < glyph_info->num_glyphs; ++i) { - glyph_info->glyphs[i].x -= dst_x; - glyph_info->glyphs[i].y -= dst_y; + ((cairo_glyph_t *) glyph_info->glyphs)[i].x -= dst_x; + ((cairo_glyph_t *) glyph_info->glyphs)[i].y -= dst_y; } } @@ -1893,7 +1893,7 @@ static cairo_status_t _fallback_show_glyphs (cairo_surface_t *surface, cairo_operator_t operator, cairo_pattern_t *source, - cairo_glyph_t *glyphs, + const cairo_glyph_t *glyphs, int num_glyphs, cairo_scaled_font_t *scaled_font) { @@ -1939,7 +1939,7 @@ cairo_status_t _cairo_surface_show_glyphs (cairo_surface_t *surface, cairo_operator_t operator, cairo_pattern_t *source, - cairo_glyph_t *glyphs, + const cairo_glyph_t *glyphs, int num_glyphs, cairo_scaled_font_t *scaled_font) { diff --git a/src/cairoint.h b/src/cairoint.h index 37ae1dc40..45cdcfeaa 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -787,7 +787,7 @@ struct _cairo_surface_backend { (*show_glyphs) (void *surface, cairo_operator_t operator, cairo_pattern_t *source, - cairo_glyph_t *glyphs, + const cairo_glyph_t *glyphs, int num_glyphs, cairo_scaled_font_t *scaled_font); }; @@ -1528,7 +1528,7 @@ _cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font, int dest_y, unsigned int width, unsigned int height, - cairo_glyph_t *glyphs, + const cairo_glyph_t *glyphs, int num_glyphs); cairo_private cairo_status_t @@ -1651,7 +1651,7 @@ _cairo_surface_stroke (cairo_surface_t *surface, cairo_operator_t operator, cairo_pattern_t *source, cairo_path_fixed_t *path, - cairo_stroke_style_t *stroke_style, + cairo_stroke_style_t *style, cairo_matrix_t *ctm, cairo_matrix_t *ctm_inverse, double tolerance, @@ -1670,7 +1670,7 @@ cairo_private cairo_status_t _cairo_surface_show_glyphs (cairo_surface_t *surface, cairo_operator_t operator, cairo_pattern_t *source, - cairo_glyph_t *glyphs, + const cairo_glyph_t *glyphs, int num_glyphs, cairo_scaled_font_t *scaled_font);