From 169099b5e9c77c6633deb3c7bb949800a5f80ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 18 Sep 2009 14:48:00 +0200 Subject: Fixed broken scrolling of cached graphics items on X11. The scrolling was broken in other graphics systems than the native, since _q_scrollPixmap assumed that all QPixmaps were using the X11 backend. We can just use QPixmap::scroll instead, which should also make it faster with the raster paint engine than creating a temporary painter and doing a blit. Also, _q_scrollPixmap would do blending instead of blitting for non-opaque pixmaps. Reviewed-by: Olivier Goffart --- src/gui/graphicsview/qgraphicsitem.cpp | 42 +--------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 81eeb39..31c106b 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -5075,46 +5075,6 @@ void QGraphicsItem::update(const QRectF &rect) } /*! - \internal - - Scrolls \a rect in \a pix by \a dx, \a dy. - - ### This can be done much more efficiently by using XCopyArea on X11 with - the same dst and src, and through moving pixels in the raster engine. It - can probably also be done much better on the other paint engines. -*/ -void _q_scrollPixmap(QPixmap *pix, const QRect &rect, int dx, int dy) -{ -#if 0 - QPainter painter(pix); - painter.setClipRect(rect); - painter.drawPixmap(rect.translated(dx, dy), *pix, rect); - painter.end(); -#elif defined Q_WS_X11 - GC gc = XCreateGC(X11->display, pix->handle(), 0, 0); - - XRectangle xrect; - xrect.x = rect.x(); - xrect.y = rect.y(); - xrect.width = rect.width(); - xrect.height = rect.height(); - XSetClipRectangles(X11->display, gc, 0, 0, &xrect, 1, YXBanded); - - XCopyArea(X11->display, pix->handle(), pix->handle(), gc, - rect.x(), rect.y(), rect.width(), rect.height(), - rect.x()+dx, rect.y()+dy); - XFreeGC(X11->display, gc); -#else - QPixmap newPix = *pix; - QPainter painter(&newPix); - painter.setClipRect(rect); - painter.drawPixmap(rect.translated(dx, dy), *pix, rect); - painter.end(); - *pix = newPix; -#endif -} - -/*! \since 4.4 Scrolls the contents of \a rect by \a dx, \a dy. If \a rect is a null rect (the default), the item's bounding rect is scrolled. @@ -5154,7 +5114,7 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect) QRectF br = boundingRect().adjusted(-adjust, -adjust, adjust, adjust); QRect irect = rect.toRect().translated(-br.x(), -br.y()); - _q_scrollPixmap(&pix, irect, dx, dy); + pix.scroll(dx, dy, irect); QPixmapCache::replace(c->key, pix); -- cgit v0.12