[cairo-commit] cairo/src cairo-xlib-surface.c,1.71,1.72
Keith Packard
commit at pdx.freedesktop.org
Tue May 17 12:21:58 PDT 2005
Committed by: keithp
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv32477/src
Modified Files:
cairo-xlib-surface.c
Log Message:
2005-05-17 Keith Packard <keithp at keithp.com>
* src/cairo-xlib-surface.c: (_get_image_surface):
Add some comments about how and why masks are computed.
Generalize overflow detection in mask computation.
Expand on pixman format conversion comment.
Index: cairo-xlib-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xlib-surface.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- cairo-xlib-surface.c 17 May 2005 18:28:26 -0000 1.71
+++ cairo-xlib-surface.c 17 May 2005 19:21:56 -0000 1.72
@@ -362,18 +362,19 @@
if (!ximage)
return CAIRO_STATUS_NO_MEMORY;
+ /*
+ * Compute the pixel format masks from either a visual or a
+ * XRenderFormat, failing we assume the drawable is an
+ * alpha-only pixmap as it could only have been created
+ * that way through the cairo_xlib_surface_create_for_bitmap
+ * function.
+ */
if (surface->visual) {
masks.bpp = ximage->bits_per_pixel;
masks.alpha_mask = 0;
masks.red_mask = surface->visual->red_mask;
masks.green_mask = surface->visual->green_mask;
masks.blue_mask = surface->visual->blue_mask;
-
- image = _cairo_image_surface_create_with_masks ((unsigned char *) ximage->data,
- &masks,
- ximage->width,
- ximage->height,
- ximage->bytes_per_line);
} else if (surface->format) {
masks.bpp = ximage->bits_per_pixel;
masks.red_mask = surface->format->direct.redMask << surface->format->direct.red;
@@ -385,12 +386,16 @@
masks.red_mask = 0;
masks.green_mask = 0;
masks.blue_mask = 0;
- if (surface->depth == 32)
- masks.alpha_mask = 0xffffffff;
- else
+ if (surface->depth < 32)
masks.alpha_mask = (1 << surface->depth) - 1;
+ else
+ masks.alpha_mask = 0xffffffff;
}
+ /*
+ * Prefer to use a standard pixman format instead of the
+ * general masks case.
+ */
if (_CAIRO_MASK_FORMAT (&masks, &format))
{
image = (cairo_image_surface_t *) cairo_image_surface_create_for_data ((unsigned char *) ximage->data,
@@ -401,8 +406,11 @@
}
else
{
- /* XXX This can't work. We must convert the data to one of the
- * supported pixman formats
+ /*
+ * XXX This can't work. We must convert the data to one of the
+ * supported pixman formats. Pixman needs another function
+ * which takes data in an arbitrary format and converts it
+ * to something supported by that library.
*/
image = _cairo_image_surface_create_with_masks ((unsigned char *) ximage->data,
&masks,
@@ -1125,7 +1133,7 @@
/**
* cairo_xlib_surface_create_for_bitmap:
* @dpy: an X Display
- * @bitmap: an X bitmap (a depth-1 Pixmap)
+ * @bitmap: an X Drawable, (a depth-1 Pixmap)
* @width: the current width of @bitmap.
* @height: the current height of @bitmap.
*
More information about the cairo-commit
mailing list