diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-09-01 14:24:06 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-09-01 14:24:06 +0100 |
commit | 1bcc3a3fa00445667adc47d4852237271c7eec0f (patch) | |
tree | 2eba1d7f1f30b5cc9bebe8ea89fa9f2e015951b0 | |
parent | af82670dd3bfdb661de5a01a6856ec01bdf80040 (diff) |
[tee] Rename 'append' to 'add' and add symmetric 'remove'
-rw-r--r-- | src/cairo-tee-surface.c | 51 | ||||
-rw-r--r-- | src/cairo.h | 8 | ||||
-rw-r--r-- | util/cairo-fdr/fdr.c | 2 | ||||
-rw-r--r-- | util/cairo-sphinx/fdr.c | 2 |
4 files changed, 54 insertions, 9 deletions
diff --git a/src/cairo-tee-surface.c b/src/cairo-tee-surface.c index 0a7842f7..56f3cc26 100644 --- a/src/cairo-tee-surface.c +++ b/src/cairo-tee-surface.c @@ -51,7 +51,7 @@ typedef struct _cairo_tee_surface { } cairo_tee_surface_t; slim_hidden_proto (cairo_tee_surface_create); -slim_hidden_proto (cairo_tee_surface_append); +slim_hidden_proto (cairo_tee_surface_add); static cairo_surface_t * _cairo_tee_surface_create_similar (void *abstract_surface, @@ -80,7 +80,7 @@ _cairo_tee_surface_create_similar (void *abstract_surface, similar = _cairo_surface_wrapper_create_similar (&slaves[n], content, width, height); - cairo_tee_surface_append (surface, similar); + cairo_tee_surface_add (surface, similar); cairo_surface_destroy (similar); } @@ -457,8 +457,8 @@ cairo_tee_surface_create (cairo_surface_t *master) slim_hidden_def (cairo_tee_surface_create); void -cairo_tee_surface_append (cairo_surface_t *abstract_surface, - cairo_surface_t *target) +cairo_tee_surface_add (cairo_surface_t *abstract_surface, + cairo_surface_t *target) { cairo_tee_surface_t *surface; cairo_surface_wrapper_t slave; @@ -487,7 +487,48 @@ cairo_tee_surface_append (cairo_surface_t *abstract_surface, status = _cairo_surface_set_error (&surface->base, status); } } -slim_hidden_def (cairo_tee_surface_append); +slim_hidden_def (cairo_tee_surface_add); + +void +cairo_tee_surface_remove (cairo_surface_t *abstract_surface, + cairo_surface_t *target) +{ + cairo_tee_surface_t *surface; + cairo_surface_wrapper_t *slaves; + int n, num_slaves; + cairo_status_t status; + + if (abstract_surface->backend != &cairo_tee_surface_backend) { + status = _cairo_surface_set_error (abstract_surface, + _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH)); + return; + } + + surface = (cairo_tee_surface_t *) abstract_surface; + if (target == surface->master.target) { + status = _cairo_surface_set_error (abstract_surface, + _cairo_error (CAIRO_STATUS_INVALID_INDEX)); + return; + } + + num_slaves = _cairo_array_num_elements (&surface->slaves); + slaves = _cairo_array_index (&surface->slaves, 0); + for (n = 0; n < num_slaves; n++) { + if (slaves[n].target == target) + break; + } + + if (n == num_slaves) { + status = _cairo_surface_set_error (abstract_surface, + _cairo_error (CAIRO_STATUS_INVALID_INDEX)); + return; + } + + _cairo_surface_wrapper_fini (&slaves[n]); + for (n++; n < num_slaves; n++) + slaves[n-1] = slaves[n]; + surface->slaves.num_elements--; /* XXX: cairo_array_remove()? */ +} cairo_surface_t * cairo_tee_surface_index (cairo_surface_t *abstract_surface, diff --git a/src/cairo.h b/src/cairo.h index a046a471..3b5eb36e 100644 --- a/src/cairo.h +++ b/src/cairo.h @@ -2199,11 +2199,15 @@ cairo_public cairo_surface_t * cairo_tee_surface_create (cairo_surface_t *master); cairo_public void -cairo_tee_surface_append (cairo_surface_t *surface, +cairo_tee_surface_add (cairo_surface_t *surface, + cairo_surface_t *target); + +cairo_public void +cairo_tee_surface_remove (cairo_surface_t *surface, cairo_surface_t *target); cairo_public cairo_surface_t * -cairo_tee_surface_index (cairo_surface_t *abstract_surface, +cairo_tee_surface_index (cairo_surface_t *surface, int index); /* Pattern creation functions */ diff --git a/util/cairo-fdr/fdr.c b/util/cairo-fdr/fdr.c index 46754731..98900241 100644 --- a/util/cairo-fdr/fdr.c +++ b/util/cairo-fdr/fdr.c @@ -164,7 +164,7 @@ cairo_create (cairo_surface_t *surface) tee = DLCALL (cairo_tee_surface_create, surface); record = DLCALL (cairo_meta_surface_create, content, &extents); - DLCALL (cairo_tee_surface_append, tee, record); + DLCALL (cairo_tee_surface_add, tee, record); DLCALL (cairo_surface_set_user_data, surface, &fdr_key, tee, fdr_surface_destroy); diff --git a/util/cairo-sphinx/fdr.c b/util/cairo-sphinx/fdr.c index 993baba3..9c66608a 100644 --- a/util/cairo-sphinx/fdr.c +++ b/util/cairo-sphinx/fdr.c @@ -136,7 +136,7 @@ cairo_create (cairo_surface_t *surface) tee = DLCALL (cairo_tee_surface_create, surface); script = DLCALL (cairo_script_surface_create, fdr_context, content, extents.width, extents.height); - DLCALL (cairo_tee_surface_append, tee, script); + DLCALL (cairo_tee_surface_add, tee, script); DLCALL (cairo_surface_set_user_data, surface, &fdr_key, tee, fdr_surface_destroy); |