src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
changeset 18 2f34d5167611
parent 0 1918ee327afb
child 19 fcece45ef507
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp	Tue Feb 02 00:43:10 2010 +0200
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp	Fri Apr 16 15:50:13 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -470,6 +470,7 @@
         return QPixmap();
 
     QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
+    data->setSerialNumber(++global_ser_no);
     DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
     data->alpha = alpha;
     if (alpha) {
@@ -551,6 +552,34 @@
     return &lockedImage;
 }
 
+
+bool QDirectFBPixmapData::scroll(int dx, int dy, const QRect &rect)
+{
+    if (!dfbSurface) {
+        return false;
+    }
+    unlockSurface();
+    DFBResult result = dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
+    if (result != DFB_OK) {
+        DirectFBError("QDirectFBPixmapData::scroll", result);
+        return false;
+    }
+    result = dfbSurface->SetPorterDuff(dfbSurface, DSPD_NONE);
+    if (result != DFB_OK) {
+        DirectFBError("QDirectFBPixmapData::scroll", result);
+        return false;
+    }
+
+    const DFBRectangle source = { rect.x(), rect.y(), rect.width(), rect.height() };
+    result = dfbSurface->Blit(dfbSurface, dfbSurface, &source, source.x + dx, source.y + dy);
+    if (result != DFB_OK) {
+        DirectFBError("QDirectFBPixmapData::scroll", result);
+        return false;
+    }
+
+    return true;
+}
+
 void QDirectFBPixmapData::invalidate()
 {
     if (dfbSurface) {
@@ -564,9 +593,17 @@
     imageFormat = QImage::Format_Invalid;
 }
 
+#ifndef QT_DIRECTFB_PLUGIN
+Q_GUI_EXPORT IDirectFBSurface *qt_directfb_surface_for_pixmap(const QPixmap &pixmap)
+{
+    const QPixmapData *data = pixmap.pixmapData();
+    if (!data || data->classId() != QPixmapData::DirectFBClass)
+        return 0;
+    const QDirectFBPixmapData *dfbData = static_cast<const QDirectFBPixmapData*>(data);
+    return dfbData->directFBSurface();
+}
+#endif
+
 QT_END_NAMESPACE
 
 #endif // QT_NO_QWS_DIRECTFB
-
-
-