Re: [PATCH] xcb: make use of _cairo_surface_is_xcb to check for surface type

RAVI NANJUNDAPPA <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Thank you Uli for reviewing this patch. 
Please find attached the patch updated with the changes to take care of the
cairo coding style.

Thanks and Best Regards, 
N Ravi

> -----Original Message-----
> From: Uli Schlachter [mailto:[email protected]]
> Sent: Thursday, July 03, 2014 5:18 PM
> To: RAVI NANJUNDAPPA; [email protected]
> Subject: Re: [cairo] [PATCH] xcb: make use of _cairo_surface_is_xcb to
check
> for surface type
> 
> On 02.07.2014 10:46, RAVI NANJUNDAPPA wrote:
> > Hi,
> >
> > Please find attached the updated patch incorporated with review
> > comments from Uli.
> > Thanking him for taking time to review the patch.
> > Please help me in reviewing the attached patch.
> >
> > Thanks and Best Regards,
> > N Ravi
> >
> [...]
> 
> With one minor comment:
> 
> Reviewed-by: Uli Schlachter <[email protected]>
> 
> > diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c index
> > c900edc..3b0c422 100644
> > --- a/src/cairo-xcb-surface.c
> > +++ b/src/cairo-xcb-surface.c
> > @@ -1432,7 +1432,7 @@ cairo_xcb_surface_set_size (cairo_surface_t
> *abstract_surface,
> >      }
> >
> >
> > -    if (abstract_surface->type != CAIRO_SURFACE_TYPE_XCB) {
> > +    if (!_cairo_surface_is_xcb(abstract_surface)) {
> >  	_cairo_surface_set_error (abstract_surface,
> >  				  _cairo_error
> (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
> >  	return;
> 
> Here (and in the other change in cairo-xcb-surface.c) it should be "( !"
instead
> of "(!". Just to match the normal cairo coding style.
> 
> Uli
> --
> Homophobia - The fear that another man will treat you the way you treat
> women.

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
0001-xcb-make-use-of-_cairo_surface_is_xcb-to-check-for-s.patch (application/octet-stream, 3.4 KB)
From a8451cfc2fb2aed2a28ec11510bde0cc94f56d78 Mon Sep 17 00:00:00 2001
From: Ravi Nanjundappa <[email protected]>
Date: Wed, 2 Jul 2014 14:13:58 +0530
Subject: [PATCH] xcb: make use of _cairo_surface_is_xcb to check for surface
 type

Introduced a new inline function _cairo_surface_is_xcb() as similar to
_cairo_surface_is_image() and used the same to check for xcb surface
type

Signed-off-by: Ravi Nanjundappa <[email protected]>
---
 src/cairo-xcb-private.h        |   15 +++++++++++++++
 src/cairo-xcb-surface-core.c   |    2 +-
 src/cairo-xcb-surface-render.c |    2 +-
 src/cairo-xcb-surface.c        |    4 ++--
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/cairo-xcb-private.h b/src/cairo-xcb-private.h
index 5f04803..134100a 100644
--- a/src/cairo-xcb-private.h
+++ b/src/cairo-xcb-private.h
@@ -267,6 +267,21 @@ enum {
 
 cairo_private extern const cairo_surface_backend_t _cairo_xcb_surface_backend;
 
+/**
+ * _cairo_surface_is_xcb:
+ * @surface: a #cairo_surface_t
+ *
+ * Checks if a surface is an #cairo_xcb_surface_t
+ *
+ * Return value: %TRUE if the surface is an xcb surface
+ **/
+static inline cairo_bool_t
+_cairo_surface_is_xcb (const cairo_surface_t *surface)
+{
+    /* _cairo_surface_nil sets a NULL backend so be safe */
+    return surface->backend && surface->backend->type == CAIRO_SURFACE_TYPE_XCB;
+}
+
 cairo_private cairo_xcb_connection_t *
 _cairo_xcb_connection_get (xcb_connection_t *connection);
 
diff --git a/src/cairo-xcb-surface-core.c b/src/cairo-xcb-surface-core.c
index c608c9a..545fd28 100644
--- a/src/cairo-xcb-surface-core.c
+++ b/src/cairo-xcb-surface-core.c
@@ -406,7 +406,7 @@ _cairo_xcb_surface_pixmap (cairo_xcb_surface_t *target,
     if (pixmap != NULL && pixmap->screen == target->screen)
 	return (cairo_xcb_pixmap_t *) cairo_surface_reference (&pixmap->base);
 
-    if (source->type == CAIRO_SURFACE_TYPE_XCB &&
+    if (_cairo_surface_is_xcb(source) &&
 	((cairo_xcb_surface_t *) source)->screen == target->screen)
     {
 	cairo_xcb_surface_t *xcb_source = (cairo_xcb_surface_t *) source;
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 75455e5..3f2fc43 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -1154,7 +1154,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target,
 
     if (source->type == CAIRO_SURFACE_TYPE_XCB)
     {
-	if (source->backend->type == CAIRO_SURFACE_TYPE_XCB) {
+	if (_cairo_surface_is_xcb(source)) {
 	    cairo_xcb_surface_t *xcb = (cairo_xcb_surface_t *) source;
 	    if (xcb->screen == target->screen && xcb->fallback == NULL) {
 		picture = _copy_to_picture ((cairo_xcb_surface_t *) source);
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index c900edc..02e7a19 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1432,7 +1432,7 @@ cairo_xcb_surface_set_size (cairo_surface_t *abstract_surface,
     }
 
 
-    if (abstract_surface->type != CAIRO_SURFACE_TYPE_XCB) {
+    if ( !_cairo_surface_is_xcb(abstract_surface)) {
 	_cairo_surface_set_error (abstract_surface,
 				  _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
 	return;
@@ -1486,7 +1486,7 @@ cairo_xcb_surface_set_drawable (cairo_surface_t *abstract_surface,
     }
 
 
-    if (abstract_surface->type != CAIRO_SURFACE_TYPE_XCB) {
+    if ( !_cairo_surface_is_xcb(abstract_surface)) {
 	_cairo_surface_set_error (abstract_surface,
 				  _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH));
 	return;
-- 
1.7.9.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.