third_party/cairo/src/cairo-xcb-surface.c
cairo_surface_t *
cairo_xcb_surface_create_with_xrender_format (xcb_connection_t	    *connection,
					      xcb_screen_t	    *screen,
					      xcb_drawable_t	     drawable,
					      xcb_render_pictforminfo_t *format,
					      int		     width,
					      int		     height)
{
    cairo_xcb_screen_t *cairo_xcb_screen;
    cairo_format_masks_t image_masks;
    pixman_format_code_t pixman_format;

    if (xcb_connection_has_error (connection))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_WRITE_ERROR));

    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;
    image_masks.red_mask =
	(unsigned long) format->direct.red_mask << format->direct.red_shift;
    image_masks.green_mask =
	(unsigned long) format->direct.green_mask << format->direct.green_shift;
    image_masks.blue_mask =
	(unsigned long) format->direct.blue_mask << format->direct.blue_shift;
#if 0
    image_masks.bpp = format->depth;
#else
    if (format->depth > 16)
	image_masks.bpp = 32;
    else if (format->depth > 8)
	image_masks.bpp = 16;
    else if (format->depth > 1)
	image_masks.bpp = 8;
    else
	image_masks.bpp = 1;
#endif

    if (! _pixman_format_from_masks (&image_masks, &pixman_format))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));

    cairo_xcb_screen = _cairo_xcb_screen_get (connection, screen);
    if (unlikely (cairo_xcb_screen == NULL))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));

    return _cairo_xcb_surface_create_internal (cairo_xcb_screen,
					       drawable,
					       FALSE,
					       pixman_format,
					       format->id,
					       width, height);
}
/**
 * cairo_xcb_surface_create_with_xrender_format:
 * @connection: an XCB connection
 * @drawable: an XCB drawable
 * @screen: the XCB screen associated with @drawable
 * @format: the picture format to use for drawing to @drawable. The
 *          depth of @format mush match the depth of the drawable.
 * @width: the current width of @drawable
 * @height: the current height of @drawable
 *
 * Creates an XCB surface that draws to the given drawable.
 * The way that colors are represented in the drawable is specified
 * by the provided picture format.
 *
 * Note: If @drawable is a Window, then the function
 * cairo_xcb_surface_set_size() must be called whenever the size of the
 * window changes.
 *
 * When @drawable is a Window containing child windows then drawing to
 * the created surface will be clipped by those child windows.  When
 * the created surface is used as a source, the contents of the
 * children will be included.
 *
 * Return value: a pointer to the newly created surface. The caller
 * owns the surface and should call cairo_surface_destroy() when done
 * with it.
 *
 * This function always returns a valid pointer, but it will return a
 * pointer to a "nil" surface if an error such as out of memory
 * occurs. You can use cairo_surface_status() to check for this.
 *
 * Since: 1.12
 **/


Creates an XCB surface that draws to the given drawable.
The way that colors are represented in the drawable is specified
by the provided picture format.

If @drawable is a Window, then the function
cairo_xcb_surface_set_size() must be called whenever the size of the
window changes.

When @drawable is a Window containing child windows then drawing to
the created surface will be clipped by those child windows.  When
the created surface is used as a source, the contents of the
children will be included.

Return value: a pointer to the newly created surface. The caller
owns the surface and should call cairo_surface_destroy() when done
with it.

This function always returns a valid pointer, but it will return a
pointer to a "nil" surface if an error such as out of memory
occurs. You can use cairo_surface_status() to check for this.


Creates an XCB surface that draws to the given drawable . The way that colors are represented in the drawable is specified by the provided picture format . If @drawable is a Window then the function cairo_xcb_surface_set_size () must be called whenever the size of the window changes . When @drawable is a Window containing child windows then drawing to the created surface will be clipped by those child windows . When the created surface is used as a source the contents of the children will be included . Return value : a pointer to the newly created surface . The caller owns the surface and should call cairo_surface_destroy () when done with it . This function always returns a valid pointer but it will return a pointer to a " nil " surface if an error such as out of memory occurs . You can use cairo_surface_status () to check for this .
cairo_surface_t *
cairo_xcb_surface_create_with_xrender_format (xcb_connection_t	    *connection,
					      xcb_screen_t	    *screen,
					      xcb_drawable_t	     drawable,
					      xcb_render_pictforminfo_t *format,
					      int		     width,
					      int		     height)
{
    cairo_xcb_screen_t *cairo_xcb_screen;
    cairo_format_masks_t image_masks;
    pixman_format_code_t pixman_format;
    if (xcb_connection_has_error (connection))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_WRITE_ERROR));
    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;
    image_masks.red_mask =
	(unsigned long) format->direct.red_mask << format->direct.red_shift;
    image_masks.green_mask =
	(unsigned long) format->direct.green_mask << format->direct.green_shift;
    image_masks.blue_mask =
	(unsigned long) format->direct.blue_mask << format->direct.blue_shift;
#if 0
    image_masks.bpp = format->depth;
#else
    if (format->depth > 16)
	image_masks.bpp = 32;
    else if (format->depth > 8)
	image_masks.bpp = 16;
    else if (format->depth > 1)
	image_masks.bpp = 8;
    else
	image_masks.bpp = 1;
#endif
    if (! _pixman_format_from_masks (&image_masks, &pixman_format))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
    cairo_xcb_screen = _cairo_xcb_screen_get (connection, screen);
    if (unlikely (cairo_xcb_screen == NULL))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
    return _cairo_xcb_surface_create_internal (cairo_xcb_screen,
					       drawable,
					       FALSE,
					       pixman_format,
					       format->id,
					       width, height);
}
cairo_surface_t * cairo_xcb_surface_create_with_xrender_format ( xcb_connection_t * connection , xcb_screen_t * screen , xcb_drawable_t drawable , xcb_render_pictforminfo_t * format , int width , int height ) { cairo_xcb_screen_t * cairo_xcb_screen ; cairo_format_masks_t image_masks ; pixman_format_code_t pixman_format ; if ( xcb_connection_has_error ( connection ) ) return _cairo_surface_create_in_error ( _cairo_error ( CAIRO_STATUS_WRITE_ERROR ) ) ; 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 ; image_masks . red_mask = ( unsigned long ) format -> direct . red_mask << format -> direct . red_shift ; image_masks . green_mask = ( unsigned long ) format -> direct . green_mask << format -> direct . green_shift ; image_masks . blue_mask = ( unsigned long ) format -> direct . blue_mask << format -> direct . blue_shift ; #if 0 image_masks . bpp = format -> depth ; #else if ( format -> depth > 16 ) image_masks . bpp = 32 ; else if ( format -> depth > 8 ) image_masks . bpp = 16 ; else if ( format -> depth > 1 ) image_masks . bpp = 8 ; else image_masks . bpp = 1 ; #endif if ( ! _pixman_format_from_masks ( & image_masks , & pixman_format ) ) return _cairo_surface_create_in_error ( _cairo_error ( CAIRO_STATUS_INVALID_FORMAT ) ) ; cairo_xcb_screen = _cairo_xcb_screen_get ( connection , screen ) ; if ( unlikely ( cairo_xcb_screen == NULL ) ) return _cairo_surface_create_in_error ( _cairo_error ( CAIRO_STATUS_NO_MEMORY ) ) ; return _cairo_xcb_surface_create_internal ( cairo_xcb_screen , drawable , FALSE , pixman_format , format -> id , width , height ) ; }
cairo_xcb_surface_create_with_xrender_format:
 @connection: an XCB connection
 @drawable: an XCB drawable
 @screen: the XCB screen associated with @drawable
 @format: the picture format to use for drawing to @drawable.
cairo_xcb_surface_create_with_xrender_format : @connection : an XCB connection @drawable : an XCB drawable @screen : the XCB screen associated with @drawable @format : the picture format to use for drawing to @drawable .