summaryrefslogtreecommitdiffstats
path: root/src/plugins/graphicssystems
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2010-01-19 16:27:42 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2010-01-19 16:37:17 (GMT)
commita8cf2de36dc570d2e73248d4cbe88ee3eb330dc0 (patch)
tree33a55118d757489476314f9e11585279f710ecc0 /src/plugins/graphicssystems
parent49e5181ea9da13439200720f51c8abbe4d8141c1 (diff)
downloadQt-a8cf2de36dc570d2e73248d4cbe88ee3eb330dc0.zip
Qt-a8cf2de36dc570d2e73248d4cbe88ee3eb330dc0.tar.gz
Qt-a8cf2de36dc570d2e73248d4cbe88ee3eb330dc0.tar.bz2
Enable MIT SHM and implement scrolling in the window surface
Stealing a bit from the Qt X11 source code...
Diffstat (limited to 'src/plugins/graphicssystems')
-rw-r--r--src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp59
-rw-r--r--src/plugins/graphicssystems/testlite/x11util.cpp14
2 files changed, 64 insertions, 9 deletions
diff --git a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp
index c0a0cc9..0afbf2f 100644
--- a/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp
+++ b/src/plugins/graphicssystems/testlite/qwindowsurface_testlite.cpp
@@ -114,11 +114,68 @@ void QTestLiteWindowSurface::setGeometry(const QRect &rect)
xw->setGeometry(rect.x(), rect.y(), rect.width(), rect.height());
}
+//### scroll logic copied from QRasterWindowSurface, we should make better API for this
+
+void copied_qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
+{
+ // make sure we don't detach
+ uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits());
+
+ int lineskip = img.bytesPerLine();
+ int depth = img.depth() >> 3;
+
+ const QRect imageRect(0, 0, img.width(), img.height());
+ const QRect r = rect & imageRect & imageRect.translated(-offset);
+ const QPoint p = rect.topLeft() + offset;
+
+ if (r.isEmpty())
+ return;
+
+ const uchar *src;
+ uchar *dest;
+
+ if (r.top() < p.y()) {
+ src = mem + r.bottom() * lineskip + r.left() * depth;
+ dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth;
+ lineskip = -lineskip;
+ } else {
+ src = mem + r.top() * lineskip + r.left() * depth;
+ dest = mem + p.y() * lineskip + p.x() * depth;
+ }
+
+ const int w = r.width();
+ int h = r.height();
+ const int bytes = w * depth;
+
+ // overlapping segments?
+ if (offset.y() == 0 && qAbs(offset.x()) < w) {
+ do {
+ ::memmove(dest, src, bytes);
+ dest += lineskip;
+ src += lineskip;
+ } while (--h);
+ } else {
+ do {
+ ::memcpy(dest, src, bytes);
+ dest += lineskip;
+ src += lineskip;
+ } while (--h);
+ }
+}
+
bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
- return QWindowSurface::scroll(area, dx, dy);
+ if (!xw->image() || xw->image()->isNull())
+ return false;
+
+ const QVector<QRect> rects = area.rects();
+ for (int i = 0; i < rects.size(); ++i)
+ copied_qt_scrollRectInImage(*xw->image(), rects.at(i), QPoint(dx, dy));
+
+ return true;
}
+
void QTestLiteWindowSurface::beginPaint(const QRegion &region)
{
Q_UNUSED(region);
diff --git a/src/plugins/graphicssystems/testlite/x11util.cpp b/src/plugins/graphicssystems/testlite/x11util.cpp
index f3b6dc2..de2a6d9 100644
--- a/src/plugins/graphicssystems/testlite/x11util.cpp
+++ b/src/plugins/graphicssystems/testlite/x11util.cpp
@@ -73,9 +73,7 @@
//#define MYX11_DEBUG
-//MIT SHM disabled by default, since we haven't implemented ShmCompletion synchronization yet
-
-#define DONT_USE_MIT_SHM
+//#define DONT_USE_MIT_SHM
static int (*original_x_errhandler)(Display *dpy, XErrorEvent *);
static bool seen_badwindow;
@@ -506,14 +504,14 @@ void MyWindow::paintEvent()
//qDebug() << "Here we go" << image_info->image->width << image_info->image->height;
int x = 0;
int y = 0;
- // We should really set send_event to true, and then use the XShmCompletionEvent
- // to synchronize painting
+
+ // We could set send_event to true, and then use the ShmCompletion to synchronize,
+ // but let's do like Qt/11 and just use XSync
XShmPutImage (xd->display, window, gc, image_info->image, 0, 0,
x, y, image_info->image->width, image_info->image->height,
- /*send_event*/ false);
+ /*send_event*/ False);
- //### This makes output visible, probably not ideal from a performance point of view...
- XFlush(xd->display);
+ XSync(xd->display, False);
}
#endif
}