[cairo-commit] 2 commits - src/cairoint.h src/cairo-surface.c src/cairo-xcb-surface.c src/cairo-xlib-xcb-surface.c test/api-special-cases.c
Uli Schlachter
psychon at kemper.freedesktop.org
Mon Dec 5 14:01:00 PST 2011
src/cairo-surface.c | 2 +-
src/cairo-xcb-surface.c | 28 +++++++++++++++++++++++++---
src/cairo-xlib-xcb-surface.c | 6 +++++-
src/cairoint.h | 3 +++
test/api-special-cases.c | 8 ++++++++
5 files changed, 42 insertions(+), 5 deletions(-)
New commits:
commit 3ebe0ca876c10425b88033683d7f85dcddcc09be
Author: Uli Schlachter <psychon at znc.in>
Date: Mon Dec 5 22:55:58 2011 +0100
xlib-xcb: Implement surface_set_drawable
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/src/cairo-xlib-xcb-surface.c b/src/cairo-xlib-xcb-surface.c
index f4ddd97..5021cfc 100644
--- a/src/cairo-xlib-xcb-surface.c
+++ b/src/cairo-xlib-xcb-surface.c
@@ -647,7 +647,11 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface,
return;
}
- ASSERT_NOT_REACHED;
+ cairo_xcb_surface_set_drawable (&surface->xcb->base, drawable, width, height);
+ if (unlikely (surface->xcb->base.status)) {
+ status = _cairo_surface_set_error (abstract_surface,
+ _cairo_error (surface->xcb->base.status));
+ }
}
Display *
commit 9ec5e9fee64cb9dd835477e3565170c522863ea9
Author: Uli Schlachter <psychon at znc.in>
Date: Mon Dec 5 22:48:56 2011 +0100
xcb: Fixup some internal state in set_{drawable,size}
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index a7e0430..88f306a 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -380,7 +380,7 @@ _cairo_surface_has_snapshot (cairo_surface_t *surface,
return NULL;
}
-static void
+void
_cairo_surface_begin_modification (cairo_surface_t *surface)
{
assert (surface->status == CAIRO_STATUS_SUCCESS);
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index fd82514..282b8f8 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1379,6 +1379,18 @@ cairo_xcb_surface_create_with_xrender_format (xcb_connection_t *connection,
slim_hidden_def (cairo_xcb_surface_create_with_xrender_format);
#endif
+/* This does the necessary fixup when a surface's drawable or size changed. */
+static void
+_drawable_changed (cairo_xcb_surface_t *surface)
+{
+ _cairo_surface_begin_modification (&surface->base);
+ _cairo_boxes_clear (&surface->fallback_damage);
+ cairo_surface_destroy (&surface->fallback->base);
+
+ surface->deferred_clear = FALSE;
+ surface->fallback = NULL;
+}
+
/**
* cairo_xcb_surface_set_size:
* @surface: a #cairo_surface_t for the XCB backend
@@ -1394,6 +1406,9 @@ slim_hidden_def (cairo_xcb_surface_create_with_xrender_format);
*
* A pixmap can never change size, so it is never necessary to call
* this function on a surface created for a pixmap.
+ *
+ * If cairo_surface_flush() wasn't called, some pending operations
+ * might be discarded.
**/
void
cairo_xcb_surface_set_size (cairo_surface_t *abstract_surface,
@@ -1424,6 +1439,8 @@ cairo_xcb_surface_set_size (cairo_surface_t *abstract_surface,
}
surface = (cairo_xcb_surface_t *) abstract_surface;
+
+ _drawable_changed(surface);
surface->width = width;
surface->height = height;
}
@@ -1441,11 +1458,13 @@ slim_hidden_def (cairo_xcb_surface_set_size);
* Informs cairo of the new drawable and size of the XCB drawable underlying the
* surface.
*
+ * If cairo_surface_flush() wasn't called, some pending operations
+ * might be discarded.
**/
void
-cairo_xcb_surface_set_drawable (cairo_surface_t *abstract_surface,
- xcb_drawable_t drawable,
- int width,
+cairo_xcb_surface_set_drawable (cairo_surface_t *abstract_surface,
+ xcb_drawable_t drawable,
+ int width,
int height)
{
cairo_xcb_surface_t *surface;
@@ -1473,9 +1492,12 @@ cairo_xcb_surface_set_drawable (cairo_surface_t *abstract_surface,
surface = (cairo_xcb_surface_t *) abstract_surface;
+ /* XXX: and what about this case? */
if (surface->owns_pixmap)
return;
+ _drawable_changed (surface);
+
if (surface->drawable != drawable) {
cairo_status_t status;
status = _cairo_xcb_connection_acquire (surface->connection);
diff --git a/src/cairoint.h b/src/cairoint.h
index 1885a5b..8f4c370 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1374,6 +1374,9 @@ _cairo_surface_has_snapshot (cairo_surface_t *surface,
cairo_private void
_cairo_surface_detach_snapshot (cairo_surface_t *snapshot);
+cairo_private void
+_cairo_surface_begin_modification (cairo_surface_t *surface);
+
cairo_private_no_warn cairo_bool_t
_cairo_surface_get_extents (cairo_surface_t *surface,
cairo_rectangle_int_t *extents);
diff --git a/test/api-special-cases.c b/test/api-special-cases.c
index dbe9eb2..53891bd 100644
--- a/test/api-special-cases.c
+++ b/test/api-special-cases.c
@@ -561,6 +561,13 @@ test_cairo_xcb_surface_set_size (cairo_surface_t *surface)
return CAIRO_TEST_SUCCESS;
}
+static cairo_test_status_t
+test_cairo_xcb_surface_set_drawable (cairo_surface_t *surface)
+{
+ cairo_xcb_surface_set_drawable (surface, 0, 5, 5);
+ return CAIRO_TEST_SUCCESS;
+}
+
#endif
#if CAIRO_HAS_XLIB_SURFACE
@@ -704,6 +711,7 @@ struct {
#endif
#if CAIRO_HAS_XCB_SURFACE
TEST (cairo_xcb_surface_set_size, CAIRO_SURFACE_TYPE_XCB, TRUE),
+ TEST (cairo_xcb_surface_set_drawable, CAIRO_SURFACE_TYPE_XCB, TRUE),
#endif
#if CAIRO_HAS_XLIB_SURFACE
TEST (cairo_xlib_surface_set_size, CAIRO_SURFACE_TYPE_XLIB, TRUE),
More information about the cairo-commit
mailing list