summaryrefslogtreecommitdiffstats
path: root/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp67
1 files changed, 23 insertions, 44 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index 2f240fb..9de1ca5 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -48,8 +48,6 @@
#include <qpaintdevice.h>
#include <qvarlengtharray.h>
-//#define QT_DIRECTFB_DEBUG_SURFACES 1
-
QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr)
: QDirectFBPaintDevice(scr)
#ifndef QT_NO_DIRECTFB_WM
@@ -245,22 +243,19 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect)
QByteArray QDirectFBWindowSurface::permanentState() const
{
- QByteArray state;
#ifdef QT_DIRECTFB_WM
- QDataStream ds(&state, QIODevice::WriteOnly);
- ds << reinterpret_cast<quintptr>(this);
-#endif
+ QByteArray state(sizeof(this), 0);
+ *reinterpret_cast<const QDirectFBWindowSurface**>(state.data()) = this;
return state;
+#endif
+ return QByteArray();
}
void QDirectFBWindowSurface::setPermanentState(const QByteArray &state)
{
#ifdef QT_DIRECTFB_WM
- if (state.size() == sizeof(quintptr)) {
- QDataStream ds(state);
- quintptr ptr;
- ds >> ptr;
- sibling = reinterpret_cast<QDirectFBWindowSurface*>(ptr);
+ if (state.size() == sizeof(this)) {
+ sibling = *reinterpret_cast<QDirectFBWindowSurface *const*>(state.constData());
}
#else
Q_UNUSED(state);
@@ -418,7 +413,6 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion &region,
#endif
}
-
void QDirectFBWindowSurface::beginPaint(const QRegion &)
{
if (!engine)
@@ -427,43 +421,28 @@ void QDirectFBWindowSurface::beginPaint(const QRegion &)
void QDirectFBWindowSurface::endPaint(const QRegion &)
{
-#ifdef QT_DIRECTFB_DEBUG_SURFACES
- if (bufferImages.count()) {
- qDebug("QDirectFBWindowSurface::endPaint() this=%p", this);
-
- foreach(QImage* bufferImg, bufferImages)
- qDebug(" Deleting buffer image %p", bufferImg);
- }
-#endif
-
- qDeleteAll(bufferImages);
- bufferImages.clear();
unlockDirectFB();
}
-
-QImage *QDirectFBWindowSurface::buffer(const QWidget *widget)
+IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget, QRect *rect) const
{
- if (!lockedImage)
+ Q_ASSERT(widget);
+ if (!dfbSurface) {
+ if (sibling && (!sibling->sibling || sibling->dfbSurface))
+ return sibling->surfaceForWidget(widget, rect);
return 0;
-
- const QRect rect = QRect(offset(widget), widget->size())
- & lockedImage->rect();
- if (rect.isEmpty())
- return 0;
-
- QImage *img = new QImage(lockedImage->scanLine(rect.y())
- + rect.x() * (lockedImage->depth() / 8),
- rect.width(), rect.height(),
- lockedImage->bytesPerLine(),
- lockedImage->format());
- bufferImages.append(img);
-
-#ifdef QT_DIRECTFB_DEBUG_SURFACES
- qDebug("QDirectFBWindowSurface::buffer() Created & returned %p", img);
-#endif
-
- return img;
+ }
+ QWidget *win = window();
+ Q_ASSERT(win);
+ if (rect) {
+ if (win == widget) {
+ *rect = widget->rect();
+ } else {
+ *rect = QRect(widget->mapTo(win, QPoint(0, 0)), widget->size());
+ }
+ }
+ Q_ASSERT(win == widget || widget->isAncestorOf(win));
+ return dfbSurface;
}
void QDirectFBWindowSurface::updateFormat()