diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c index 38f12190..f2938074 100644 --- a/src/sna/sna_composite.c +++ b/src/sna/sna_composite.c @@ -526,49 +526,59 @@ sna_composite_fb(CARD8 op, src->filter != PictFilterConvolution && (op == PictOpSrc || (op == PictOpOver && !PICT_FORMAT_A(src->format))) && (dst->format == src->format || dst->format == alphaless(src->format)) && - sna_transform_is_integer_translation(src->transform, &tx, &ty) && - region->extents.x1 + src_x + tx >= 0 && - region->extents.y1 + src_y + ty >= 0 && - region->extents.x2 + src_x + tx <= src->pDrawable->width && - region->extents.y2 + src_y + ty <= src->pDrawable->height) { + sna_transform_is_integer_translation(src->transform, &tx, &ty)) { PixmapPtr dst_pixmap = get_drawable_pixmap(dst->pDrawable); PixmapPtr src_pixmap = get_drawable_pixmap(src->pDrawable); - int nbox = RegionNumRects(region); - BoxPtr box = RegionRects(region); + int16_t sx = src_x + tx, sy = src_y + ty; + if (region->extents.x1 + sx >= 0 && + region->extents.y1 + sy >= 0 && + region->extents.x2 + sx <= src->pDrawable->width && + region->extents.y2 + sy <= src->pDrawable->height) { + BoxPtr box = RegionRects(region); + int nbox = RegionNumRects(region); - src_x += tx; src_y += ty; + sx += src->pDrawable->x; + sy += src->pDrawable->y; + if (get_drawable_deltas(src->pDrawable, src_pixmap, &tx, &ty)) + sx += tx, sy += ty; - if (get_drawable_deltas(src->pDrawable, src_pixmap, &tx, &ty)) - src_x += tx, src_y += ty; + assert(region->extents.x1 + sx >= 0); + assert(region->extents.x2 + sx <= src_pixmap->drawable.width); + assert(region->extents.y1 + sy >= 0); + assert(region->extents.y2 + sy <= src_pixmap->drawable.height); - if (get_drawable_deltas(dst->pDrawable, dst_pixmap, &tx, &ty)) - dst_x += tx, dst_y += ty; + dst_x += dst->pDrawable->x; + dst_y += dst->pDrawable->y; + if (get_drawable_deltas(dst->pDrawable, dst_pixmap, &tx, &ty)) + dst_x += tx, dst_y += ty; - do { - assert(box->x1 + src_x >= 0); - assert(box->x2 + src_x <= src_pixmap->drawable.width); - assert(box->y1 + src_y >= 0); - assert(box->y2 + src_y <= src_pixmap->drawable.height); + assert(nbox); + do { + assert(box->x1 + sx >= 0); + assert(box->x2 + sx <= src_pixmap->drawable.width); + assert(box->y1 + sy >= 0); + assert(box->y2 + sy <= src_pixmap->drawable.height); - assert(box->x1 + dst_x >= 0); - assert(box->x2 + dst_x <= dst_pixmap->drawable.width); - assert(box->y1 + dst_y >= 0); - assert(box->y2 + dst_y <= dst_pixmap->drawable.height); + assert(box->x1 + dst_x >= 0); + assert(box->x2 + dst_x <= dst_pixmap->drawable.width); + assert(box->y1 + dst_y >= 0); + assert(box->y2 + dst_y <= dst_pixmap->drawable.height); - assert(box->x2 > box->x1 && box->y2 > box->y1); + assert(box->x2 > box->x1 && box->y2 > box->y1); - memcpy_blt(src_pixmap->devPrivate.ptr, - dst_pixmap->devPrivate.ptr, - dst_pixmap->drawable.bitsPerPixel, - src_pixmap->devKind, - dst_pixmap->devKind, - box->x1 + src_x, box->y1 + src_y, - box->x1 + dst_x, box->y1 + dst_y, - box->x2 - box->x1, box->y2 - box->y1); - box++; - } while (--nbox); + memcpy_blt(src_pixmap->devPrivate.ptr, + dst_pixmap->devPrivate.ptr, + dst_pixmap->drawable.bitsPerPixel, + src_pixmap->devKind, + dst_pixmap->devKind, + box->x1 + sx, box->y1 + sy, + box->x1 + dst_x, box->y1 + dst_y, + box->x2 - box->x1, box->y2 - box->y1); + box++; + } while (--nbox); - return; + return; + } } src_image = image_from_pict(src, FALSE, &src_xoff, &src_yoff);