summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-09-01 14:24:06 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-09-01 14:24:06 +0100
commit1bcc3a3fa00445667adc47d4852237271c7eec0f (patch)
tree2eba1d7f1f30b5cc9bebe8ea89fa9f2e015951b0 /src
parentaf82670dd3bfdb661de5a01a6856ec01bdf80040 (diff)
[tee] Rename 'append' to 'add' and add symmetric 'remove'
Diffstat (limited to 'src')
-rw-r--r--src/cairo-tee-surface.c51
-rw-r--r--src/cairo.h8
2 files changed, 52 insertions, 7 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 */