[cairo-commit] 2 commits - src/cairo-xlib.h src/cairo-xlib-surface.c

Carl Worth cworth at kemper.freedesktop.org
Thu May 4 04:06:59 PDT 2006


 src/cairo-xlib-surface.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++
 src/cairo-xlib.h         |   15 ++++++++++
 2 files changed, 80 insertions(+)

New commits:
diff-tree 1431a9d4d3655f488b6f6698fdc18c6d65d733b5 (from 4a4603d5517f4e0b014a34ec05bee42fc3640ed3)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu May 4 04:01:06 2006 -0700

    Clean up error management of xlib surface getter functions.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 827efac..7fae110 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2009,44 +2009,41 @@ cairo_xlib_surface_set_drawable (cairo_s
     surface->height = height;
 }
 
-static cairo_bool_t _is_valid_xlib_surface (cairo_surface_t *abstract_surface)
+Display *
+cairo_xlib_surface_get_display (cairo_surface_t *abstract_surface)
 {
-    return _cairo_surface_is_xlib (abstract_surface) &&
-        abstract_surface->status == CAIRO_STATUS_SUCCESS;
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
+
+    if (! _cairo_surface_is_xlib (abstract_surface)) {
+	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return NULL;
+    }
+
+    return surface->dpy;
 }
 
 Drawable
 cairo_xlib_surface_get_drawable (cairo_surface_t *abstract_surface)
 {
-    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
 
-    /* XXX: How do we want to handle this error case? */
-    if (! _is_valid_xlib_surface (abstract_surface))
-  return 0;
+    if (! _cairo_surface_is_xlib (abstract_surface)) {
+	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return 0;
+    }
 
     return surface->drawable;
 }
 
-Display *
-cairo_xlib_surface_get_display (cairo_surface_t *abstract_surface)
-{
-    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
-
-    /* XXX: How do we want to handle this error case? */
-    if (! _is_valid_xlib_surface (abstract_surface))
-  return NULL;
-
-    return surface->dpy;
-}
-
 Screen *
 cairo_xlib_surface_get_screen (cairo_surface_t *abstract_surface)
 {
-    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
 
-    /* XXX: How do we want to handle this error case? */
-    if (! _is_valid_xlib_surface (abstract_surface))
-  return NULL;
+    if (! _cairo_surface_is_xlib (abstract_surface)) {
+	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return NULL;
+    }
 
     return surface->screen;
 }
@@ -2054,11 +2051,12 @@ cairo_xlib_surface_get_screen (cairo_sur
 Visual *
 cairo_xlib_surface_get_visual (cairo_surface_t *abstract_surface)
 {
-    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
 
-    /* XXX: How do we want to handle this error case? */
-    if (! _is_valid_xlib_surface (abstract_surface))
-  return NULL;
+    if (! _cairo_surface_is_xlib (abstract_surface)) {
+	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return NULL;
+    }
 
     return surface->visual;
 }
@@ -2066,11 +2064,12 @@ cairo_xlib_surface_get_visual (cairo_sur
 int
 cairo_xlib_surface_get_depth (cairo_surface_t *abstract_surface)
 {
-    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
 
-    /* XXX: How do we want to handle this error case? */
-    if (! _is_valid_xlib_surface (abstract_surface))
-  return -1;
+    if (! _cairo_surface_is_xlib (abstract_surface)) {
+	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return 0;
+    }
 
     return surface->depth;
 }
diff --git a/src/cairo-xlib.h b/src/cairo-xlib.h
index 085d43c..bff1c38 100644
--- a/src/cairo-xlib.h
+++ b/src/cairo-xlib.h
@@ -70,12 +70,12 @@ cairo_xlib_surface_set_drawable (cairo_s
 				 int              width,
 				 int              height);
 
-cairo_public Drawable
-cairo_xlib_surface_get_drawable (cairo_surface_t *surface);
-
 cairo_public Display *
 cairo_xlib_surface_get_display (cairo_surface_t *surface);
 
+cairo_public Drawable
+cairo_xlib_surface_get_drawable (cairo_surface_t *surface);
+
 cairo_public Screen *
 cairo_xlib_surface_get_screen (cairo_surface_t *surface);
 
@@ -83,7 +83,7 @@ cairo_public Visual *
 cairo_xlib_surface_get_visual (cairo_surface_t *surface);
 
 cairo_public int
-cairo_xlib_surface_get_depth (cairo_surface_t *abstract_surface);
+cairo_xlib_surface_get_depth (cairo_surface_t *surface);
 
 CAIRO_END_DECLS
 
diff-tree 4a4603d5517f4e0b014a34ec05bee42fc3640ed3 (from 68915fdfcb7a1c99ebd237b08192732a7409b5ec)
Author: Robert O'Callahan <rocallahan at novell.com>
Date:   Thu May 4 03:59:56 2006 -0700

    Add Xlib surface getter functions.
    
    Add the following five functions:
    
    cairo_public Display *
    cairo_xlib_surface_get_display (cairo_surface_t *surface);
    
    cairo_public Drawable
    cairo_xlib_surface_get_drawable (cairo_surface_t *surface);
    
    cairo_public Screen *
    cairo_xlib_surface_get_screen (cairo_surface_t *surface);
    
    cairo_public Visual *
    cairo_xlib_surface_get_visual (cairo_surface_t *surface);
    
    cairo_public int
    cairo_xlib_surface_get_depth (cairo_surface_t *surface);

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 8130cc6..827efac 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2009,6 +2009,72 @@ cairo_xlib_surface_set_drawable (cairo_s
     surface->height = height;
 }
 
+static cairo_bool_t _is_valid_xlib_surface (cairo_surface_t *abstract_surface)
+{
+    return _cairo_surface_is_xlib (abstract_surface) &&
+        abstract_surface->status == CAIRO_STATUS_SUCCESS;
+}
+
+Drawable
+cairo_xlib_surface_get_drawable (cairo_surface_t *abstract_surface)
+{
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
+
+    /* XXX: How do we want to handle this error case? */
+    if (! _is_valid_xlib_surface (abstract_surface))
+  return 0;
+
+    return surface->drawable;
+}
+
+Display *
+cairo_xlib_surface_get_display (cairo_surface_t *abstract_surface)
+{
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
+
+    /* XXX: How do we want to handle this error case? */
+    if (! _is_valid_xlib_surface (abstract_surface))
+  return NULL;
+
+    return surface->dpy;
+}
+
+Screen *
+cairo_xlib_surface_get_screen (cairo_surface_t *abstract_surface)
+{
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
+
+    /* XXX: How do we want to handle this error case? */
+    if (! _is_valid_xlib_surface (abstract_surface))
+  return NULL;
+
+    return surface->screen;
+}
+
+Visual *
+cairo_xlib_surface_get_visual (cairo_surface_t *abstract_surface)
+{
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
+
+    /* XXX: How do we want to handle this error case? */
+    if (! _is_valid_xlib_surface (abstract_surface))
+  return NULL;
+
+    return surface->visual;
+}
+
+int
+cairo_xlib_surface_get_depth (cairo_surface_t *abstract_surface)
+{
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
+
+    /* XXX: How do we want to handle this error case? */
+    if (! _is_valid_xlib_surface (abstract_surface))
+  return -1;
+
+    return surface->depth;
+}
+
 typedef struct _cairo_xlib_surface_font_private {
     Display		*dpy;
     GlyphSet		glyphset;
diff --git a/src/cairo-xlib.h b/src/cairo-xlib.h
index 078fe1d..085d43c 100644
--- a/src/cairo-xlib.h
+++ b/src/cairo-xlib.h
@@ -70,6 +70,21 @@ cairo_xlib_surface_set_drawable (cairo_s
 				 int              width,
 				 int              height);
 
+cairo_public Drawable
+cairo_xlib_surface_get_drawable (cairo_surface_t *surface);
+
+cairo_public Display *
+cairo_xlib_surface_get_display (cairo_surface_t *surface);
+
+cairo_public Screen *
+cairo_xlib_surface_get_screen (cairo_surface_t *surface);
+
+cairo_public Visual *
+cairo_xlib_surface_get_visual (cairo_surface_t *surface);
+
+cairo_public int
+cairo_xlib_surface_get_depth (cairo_surface_t *abstract_surface);
+
 CAIRO_END_DECLS
 
 #else  /* CAIRO_HAS_XLIB_SURFACE */


More information about the cairo-commit mailing list