diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-10-01 02:25:34 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-10-01 02:25:34 -0400 |
commit | 8ae177c92e3fcb05552d1ae1b71b7e856df87e57 (patch) | |
tree | a64d647e30e22674c5172986c7dd7bac4e002500 | |
parent | 53d119c357451e812b3d0b184ae2c5152540fadd (diff) |
handle strokes through buffer
-rw-r--r-- | src/cairo-pixman-surface.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/src/cairo-pixman-surface.c b/src/cairo-pixman-surface.c index b2502230..0b9b6000 100644 --- a/src/cairo-pixman-surface.c +++ b/src/cairo-pixman-surface.c @@ -394,6 +394,7 @@ typedef union { command_type_t type; int id; + cairo_antialias_t antialias; int n_traps; pixman_trapezoid_t * traps; } new_traps; @@ -575,6 +576,7 @@ command_buffer_new_region (command_buffer_t **buffer, pixman_region32_t *region) static int command_buffer_new_traps (command_buffer_t **buffer, + cairo_antialias_t antialias, int n_traps, pixman_trapezoid_t *traps) { command_t *command; @@ -582,6 +584,7 @@ command_buffer_new_traps (command_buffer_t **buffer, *buffer = command_buffer_append (*buffer, &command, NEW_TRAPS); command->new_traps.id = (*buffer)->id++; + command->new_traps.antialias = antialias; command->new_traps.n_traps = n_traps; command->new_traps.traps = traps; @@ -688,8 +691,28 @@ command_buffer_process (command_buffer_t *buffer, int width, int height) break; case NEW_TRAPS: + switch (command->new_traps.antialias) + { + case CAIRO_ANTIALIAS_NONE: + format = PIXMAN_a1; + break; + + case CAIRO_ANTIALIAS_FAST: + format = PIXMAN_a4; + break; + + default: + case CAIRO_ANTIALIAS_GRAY: + case CAIRO_ANTIALIAS_DEFAULT: + case CAIRO_ANTIALIAS_SUBPIXEL: + case CAIRO_ANTIALIAS_GOOD: + case CAIRO_ANTIALIAS_BEST: + format = PIXMAN_a8; + break; + } + if (!(img = pixman_image_create_bits ( - PIXMAN_a8, width, height, NULL, -1))) + format, width, height, NULL, -1))) { goto out; } @@ -1700,8 +1723,12 @@ create_clip_image2 (command_buffer_t **buffer, trap->right.p2.x = _cairo_fixed_to_16_16 (box->p2.x); trap->right.p2.y = _cairo_fixed_to_16_16 (box->p2.y); } - - boxes = command_buffer_new_traps (buffer, clip->num_boxes, ptraps); + + /* FIXME: is CAIRO_ANTIALIAS_DEFAULT correct here? It seems to be + * what the image surface is using + */ + boxes = command_buffer_new_traps ( + buffer, CAIRO_ANTIALIAS_DEFAULT, clip->num_boxes, ptraps); clip_id = command_buffer_new_blank (buffer, boxes); wh = command_buffer_new_white (buffer); @@ -1735,7 +1762,8 @@ create_clip_image2 (command_buffer_t **buffer, goto exit_loop; } - tmp = command_buffer_new_traps (buffer, traps.num_traps, ptraps); + tmp = command_buffer_new_traps ( + buffer, clip_path->antialias, traps.num_traps, ptraps); command_buffer_composite (buffer, clip_id, PIXMAN_OP_IN, wh, tmp); @@ -2204,6 +2232,9 @@ cairo_pixman_surface_stroke (void *abstract_surface, cairo_pixman_surface_t *psurface = abstract_surface; cairo_int_status_t status; cairo_traps_t traps; + command_buffer_t *buffer = command_buffer_new (); + int width = pixman_image_get_width (psurface->pimage); + int height = pixman_image_get_height (psurface->pimage); _cairo_traps_init (&traps); @@ -2212,12 +2243,21 @@ cairo_pixman_surface_stroke (void *abstract_surface, if (status == CAIRO_INT_STATUS_SUCCESS) { - status = clip_and_composite_traps ( - psurface, op, source, &traps, antialias, clip); + pixman_trapezoid_t *ptraps; + int mask_id; + + ptraps = traps_to_pixman_trapezoids (&traps); + + mask_id = command_buffer_new_traps ( + &buffer, antialias, traps.num_traps, ptraps); + + clip_and_composite2 ( + &buffer, psurface, op, source, mask_id, clip); } _cairo_traps_fini (&traps); - return status; + + return command_buffer_process (buffer, width, height); } static cairo_int_status_t |