diff options
Diffstat (limited to 'src/gui/image/qpixmap.cpp')
-rw-r--r-- | src/gui/image/qpixmap.cpp | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 7fcb2b9..8ed9e93 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -379,6 +379,56 @@ QPixmap QPixmap::copy(const QRect &rect) const } /*! + \fn QPixmap::scroll(int dx, int dy, int x, int y, int width, int height, QRegion *exposed) + + This convenience function is equivalent to calling QPixmap::scroll(\a dx, + \a dy, QRect(\a x, \a y, \a width, \a height), \a exposed). + + \sa QWidget::scroll(), QGraphicsItem::scroll() +*/ + +/*! + Scrolls the area \a rect of this pixmap by (\a dx, \a dy). The exposed + region is left unchanged. You can optionally pass a pointer to an empty + QRegion to get the region that is \a exposed by the scroll operation. + + \snippet doc/src/snippets/code/src_gui_image_qpixmap.cpp 2 + + You cannot scroll while there is an active painter on the pixmap. + + \sa QWidget::scroll(), QGraphicsItem::scroll() +*/ +void QPixmap::scroll(int dx, int dy, const QRect &rect, QRegion *exposed) +{ + if (isNull() || (dx == 0 && dy == 0)) + return; + QRect dest = rect & this->rect(); + QRect src = dest.translated(-dx, -dy) & dest; + if (src.isEmpty()) { + if (exposed) + *exposed += dest; + return; + } + + detach(); + + if (!data->scroll(dx, dy, src)) { + // Fallback + QPixmap pix = *this; + QPainter painter(&pix); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.drawPixmap(src.translated(dx, dy), *this, src); + painter.end(); + *this = pix; + } + + if (exposed) { + *exposed += dest; + *exposed -= src.translated(dx, dy); + } +} + +/*! Assigns the given \a pixmap to this pixmap and returns a reference to this pixmap. @@ -1309,14 +1359,6 @@ bool QPixmap::isDetached() const void QPixmap::deref() { if (data && !data->ref.deref()) { // Destroy image if last ref -#if !defined(QT_NO_DIRECT3D) && defined(Q_WS_WIN) - if (data->classId() == QPixmapData::RasterClass) { - QRasterPixmapData *rData = static_cast<QRasterPixmapData*>(data); - if (rData->texture) - rData->texture->Release(); - rData->texture = 0; - } -#endif if (data->is_cached && qt_pixmap_cleanup_hook_64) qt_pixmap_cleanup_hook_64(cacheKey()); delete data; @@ -1853,7 +1895,7 @@ int QPixmap::defaultDepth() return QScreen::instance()->depth(); #elif defined(Q_WS_X11) return QX11Info::appDepth(); -#elif defined(Q_OS_WINCE) +#elif defined(Q_WS_WINCE) return QColormap::instance().depth(); #elif defined(Q_WS_WIN) return 32; // XXX @@ -1888,12 +1930,6 @@ void QPixmap::detach() if (id == QPixmapData::RasterClass) { QRasterPixmapData *rasterData = static_cast<QRasterPixmapData*>(data); rasterData->image.detach(); -#if defined(Q_WS_WIN) && !defined(QT_NO_DIRECT3D) - if (rasterData->texture) { - rasterData->texture->Release(); - rasterData->texture = 0; - } -#endif } if (data->is_cached && qt_pixmap_cleanup_hook_64 && data->ref == 1) |