[cairo-commit] 5 commits - boilerplate/cairo-boilerplate-xcb.c src/cairo-surface.c src/cairo-xcb-connection.c src/cairo-xcb-surface.c src/cairo-xcb-surface-render.c src/cairo-xlib-surface.c

Uli Schlachter psychon at kemper.freedesktop.org
Fri Jun 24 07:01:58 PDT 2011


 boilerplate/cairo-boilerplate-xcb.c |    3 ++-
 src/cairo-surface.c                 |    2 ++
 src/cairo-xcb-connection.c          |    3 ++-
 src/cairo-xcb-surface-render.c      |    8 +++++---
 src/cairo-xcb-surface.c             |    9 ++++++++-
 src/cairo-xlib-surface.c            |   10 +++++-----
 6 files changed, 24 insertions(+), 11 deletions(-)

New commits:
commit 77b6563c218dcff641820d2555ac93ad10a095e8
Author: Uli Schlachter <psychon at znc.in>
Date:   Fri Jun 24 15:59:08 2011 +0200

    xcb: Use defines instead of magic numbers
    
    render.h gives us nice descriptive names for the precise/imprecise poly modes.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c
index 7cccbda..8ce0e8a 100644
--- a/boilerplate/cairo-boilerplate-xcb.c
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -92,7 +92,8 @@ _cairo_boilerplate_xcb_setup_test_surface (cairo_surface_t *surface)
     /* For testing purposes, tell the X server to strictly adhere to the
      * Render specification.
      */
-    cairo_xcb_device_debug_set_precision(cairo_surface_get_device(surface), 0);
+    cairo_xcb_device_debug_set_precision(cairo_surface_get_device(surface),
+					 XCB_RENDER_POLY_MODE_PRECISE);
 }
 
 static void
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 9272c1e..d1f2288 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -280,10 +280,10 @@ _cairo_xcb_surface_set_precision (cairo_xcb_surface_t	*surface,
     case CAIRO_ANTIALIAS_DEFAULT:
     case CAIRO_ANTIALIAS_GRAY:
     case CAIRO_ANTIALIAS_NONE:
-	precision = 1;
+	precision = XCB_RENDER_POLY_MODE_IMPRECISE;
 	break;
     case CAIRO_ANTIALIAS_SUBPIXEL:
-	precision = 0;
+	precision = XCB_RENDER_POLY_MODE_PRECISE;
 	break;
     }
 
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index fec7b75..261e6f3 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1087,7 +1087,7 @@ _cairo_xcb_surface_create_internal (cairo_xcb_screen_t		*screen,
     surface->depth  = PIXMAN_FORMAT_DEPTH (pixman_format);
 
     surface->picture = XCB_NONE;
-    surface->precision = 0;
+    surface->precision = XCB_RENDER_POLY_MODE_PRECISE;
 
     surface->pixman_format = pixman_format;
     surface->xrender_format = xrender_format;
commit 144c912860af6e60e1bdbeee31fe686c9c5e550d
Author: Uli Schlachter <psychon at znc.in>
Date:   Fri Jun 24 15:52:59 2011 +0200

    xcb: Initialize the new precision fields
    
    In 63bdae27a83, new fields were added to cairo_xcb_connection_t and
    cairo_xcb_surface_t. The same change was done in the xlib backend.
    
    However, in the xlib backend these new fields were properly initialized. This
    was forgotten in the xcb backend.
    
    Hopefully-Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=38482
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index 4830788..0c3bd5a 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -665,6 +665,7 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
     CAIRO_MUTEX_LOCK (connection->device.mutex);
 
     connection->flags = 0;
+    connection->force_precision = -1;
 
     xcb_prefetch_extension_data (xcb_connection, &xcb_big_requests_id);
     xcb_prefetch_extension_data (xcb_connection, &xcb_render_id);
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index a711d12..fec7b75 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1087,6 +1087,7 @@ _cairo_xcb_surface_create_internal (cairo_xcb_screen_t		*screen,
     surface->depth  = PIXMAN_FORMAT_DEPTH (pixman_format);
 
     surface->picture = XCB_NONE;
+    surface->precision = 0;
 
     surface->pixman_format = pixman_format;
     surface->xrender_format = xrender_format;
commit d246d97592fc9df7ac914e1f97e2d834c7b975a5
Author: Uli Schlachter <psychon at znc.in>
Date:   Mon Jun 13 11:26:55 2011 +0200

    xcb: Prettify some code
    
    Instead of having each case do the same thing, this code will now fall through
    to the default case.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index bc8f2a6..9272c1e 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -200,10 +200,12 @@ _render_operator (cairo_operator_t op)
     C(ADD, ADD);
     C(SATURATE, SATURATE);
 
+    /* PDF operators were added in RENDER 0.11, check if the xcb headers have
+     * the defines, else fall through to the default case. */
 #if CAIRO_XCB_RENDER_AT_LEAST(0, 11)
 #define BLEND(x,y) C(x,y)
 #else
-#define BLEND(x,y) case CAIRO_OPERATOR_##x: ASSERT_NOT_REACHED; return XCB_RENDER_PICT_OP_OVER
+#define BLEND(x,y) case CAIRO_OPERATOR_##x:
 #endif
     BLEND(MULTIPLY, MULTIPLY);
     BLEND(SCREEN, SCREEN);
commit cb3d91201c3de6c9cd1fd97b8471d322b75eec5a
Author: Uli Schlachter <psychon at znc.in>
Date:   Mon Jun 13 11:25:04 2011 +0200

    xcb: Don't hardcode the RENDER version number
    
    This now uses the macros XCB_RENDER_{MAJOR,MINOR}_VERSION which xcb defines.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index d6f355b..4830788 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -327,7 +327,7 @@ _cairo_xcb_connection_query_render (cairo_xcb_connection_t *connection)
     cairo_status_t status;
     cairo_bool_t present;
 
-    version_cookie = xcb_render_query_version (c, 0, 10);
+    version_cookie = xcb_render_query_version (c, XCB_RENDER_MAJOR_VERSION, XCB_RENDER_MINOR_VERSION);
     formats_cookie = xcb_render_query_pict_formats (c);
 
     present = has_required_depths (connection);
commit d938e744461f78d9030659b6672a79f06aaa12f8
Author: Uli Schlachter <psychon at znc.in>
Date:   Mon Jun 13 11:20:26 2011 +0200

    xcb,xlib,surface: Check for too small sizes
    
    This adds checks for negative sizes in cairo_surface_create_similar() and for
    non-positive sizes in all public surface-creation functions in the xcb and xlib
    backends.
    
    X11 doesn't allow 0 as width/height, so if anyone claims to have a drawable of
    that size, he can't be right. However, cairo allows such sizes which is why
    create_similar doesn't reject 0.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 91a5c50..695a63b 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -502,6 +502,8 @@ cairo_surface_create_similar (cairo_surface_t  *other,
 	return _cairo_surface_create_in_error (other->status);
     if (unlikely (other->finished))
 	return _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED);
+    if (unlikely (width < 0 || height < 0))
+	return _cairo_surface_create_in_error (CAIRO_STATUS_INVALID_SIZE);
 
     if (unlikely (! CAIRO_CONTENT_VALID (content)))
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_CONTENT));
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 6278773..a711d12 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1187,6 +1187,8 @@ cairo_xcb_surface_create (xcb_connection_t  *xcb_connection,
 
     if (unlikely (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX))
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
+    if (unlikely (width <= 0 || height <= 0))
+	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
 
     xcb_screen = _cairo_xcb_screen_from_visual (xcb_connection, visual, &depth);
     if (unlikely (xcb_screen == NULL))
@@ -1261,6 +1263,8 @@ cairo_xcb_surface_create_for_bitmap (xcb_connection_t	*xcb_connection,
 
     if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
+    if (unlikely (width <= 0 || height <= 0))
+	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
 
     screen = _cairo_xcb_screen_get (xcb_connection, xcb_screen);
     if (unlikely (screen == NULL))
@@ -1323,6 +1327,8 @@ cairo_xcb_surface_create_with_xrender_format (xcb_connection_t	    *xcb_connecti
 
     if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
+    if (unlikely (width <= 0 || height <= 0))
+	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
 
     image_masks.alpha_mask =
 	(unsigned long) format->direct.alpha_mask << format->direct.alpha_shift;
@@ -1402,7 +1408,7 @@ cairo_xcb_surface_set_size (cairo_surface_t *abstract_surface,
 	return;
     }
 
-    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX) {
+    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || width <= 0 || height <= 0) {
 	status_ignored = _cairo_surface_set_error (abstract_surface,
 						   _cairo_error (CAIRO_STATUS_INVALID_SIZE));
 	return;
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index f8caf83..1747be2 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -3370,7 +3370,7 @@ cairo_xlib_surface_create (Display     *dpy,
     cairo_xlib_screen_t *screen;
     cairo_status_t status;
 
-    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX) {
+    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || width <= 0 || height <= 0) {
 	/* you're lying, and you know it! */
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
     }
@@ -3413,7 +3413,7 @@ cairo_xlib_surface_create_for_bitmap (Display  *dpy,
     cairo_xlib_screen_t *screen;
     cairo_status_t status;
 
-    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX)
+    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || width <= 0 || height <= 0)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
 
     status = _cairo_xlib_screen_get (dpy, scr, &screen);
@@ -3459,7 +3459,7 @@ cairo_xlib_surface_create_with_xrender_format (Display		    *dpy,
     cairo_xlib_screen_t *screen;
     cairo_status_t status;
 
-    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX)
+    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || width <= 0 || height <= 0)
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
 
     status = _cairo_xlib_screen_get (dpy, scr, &screen);
@@ -3541,7 +3541,7 @@ cairo_xlib_surface_set_size (cairo_surface_t *abstract_surface,
 	return;
     }
 
-    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX) {
+    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || width <= 0 || height <= 0) {
 	status = _cairo_surface_set_error (abstract_surface,
 		                           _cairo_error (CAIRO_STATUS_INVALID_SIZE));
 	return;
@@ -3587,7 +3587,7 @@ cairo_xlib_surface_set_drawable (cairo_surface_t   *abstract_surface,
 	return;
     }
 
-    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX) {
+    if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || width <= 0 || height <= 0) {
 	status = _cairo_surface_set_error (abstract_surface,
 		                           _cairo_error (CAIRO_STATUS_INVALID_SIZE));
 	return;


More information about the cairo-commit mailing list