From 5230af4e5ad1faee3bb340ce4495e935a807b399 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 16 Jun 2004 18:16:04 +0000 Subject: [PATCH] Fix image data length computation (XCB doesn't do this part). --- ChangeLog | 6 ++++++ src/cairo-xcb-surface.c | 4 ++-- src/cairo_xcb_surface.c | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index cea35f9fb..c06ff8c77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-06-16 Keith Packard + + * src/cairo_xcb_surface.c: (bytes_per_line), + (_cairo_xcb_surface_set_image): + Fix image data length computation (XCB doesn't do this part). + 2004-06-11 David Reveman * configure.in: Require glitz 0.1.4. diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c index 61218f3c7..1fd217510 100644 --- a/src/cairo-xcb-surface.c +++ b/src/cairo-xcb-surface.c @@ -315,7 +315,7 @@ static int bytes_per_line(XCBConnection *c, int width, int bpp) { int bitmap_pad = XCBGetSetup(c)->bitmap_format_scanline_pad; - return (bpp * width + bitmap_pad - 1) & -bitmap_pad; + return ((bpp * width + bitmap_pad - 1) & -bitmap_pad) >> 3; } static cairo_image_surface_t * @@ -401,7 +401,7 @@ _cairo_xcb_surface_set_image (void *abstract_surface, _cairo_xcb_surface_ensure_gc (surface); bpp = bits_per_pixel(surface->dpy, image->depth); - data_len = bytes_per_line(surface->dpy, surface->width, bpp) * surface->height; + data_len = bytes_per_line(surface->dpy, image->width, bpp) * image->height; XCBPutImage(surface->dpy, ZPixmap, surface->drawable, surface->gc, image->width, image->height, diff --git a/src/cairo_xcb_surface.c b/src/cairo_xcb_surface.c index 61218f3c7..1fd217510 100644 --- a/src/cairo_xcb_surface.c +++ b/src/cairo_xcb_surface.c @@ -315,7 +315,7 @@ static int bytes_per_line(XCBConnection *c, int width, int bpp) { int bitmap_pad = XCBGetSetup(c)->bitmap_format_scanline_pad; - return (bpp * width + bitmap_pad - 1) & -bitmap_pad; + return ((bpp * width + bitmap_pad - 1) & -bitmap_pad) >> 3; } static cairo_image_surface_t * @@ -401,7 +401,7 @@ _cairo_xcb_surface_set_image (void *abstract_surface, _cairo_xcb_surface_ensure_gc (surface); bpp = bits_per_pixel(surface->dpy, image->depth); - data_len = bytes_per_line(surface->dpy, surface->width, bpp) * surface->height; + data_len = bytes_per_line(surface->dpy, image->width, bpp) * image->height; XCBPutImage(surface->dpy, ZPixmap, surface->drawable, surface->gc, image->width, image->height,