summaryrefslogtreecommitdiffstats
path: root/src/opengl/qwindowsurface_x11gl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qwindowsurface_x11gl.cpp')
-rw-r--r--src/opengl/qwindowsurface_x11gl.cpp54
1 files changed, 42 insertions, 12 deletions
diff --git a/src/opengl/qwindowsurface_x11gl.cpp b/src/opengl/qwindowsurface_x11gl.cpp
index 27b91ba..7befe03 100644
--- a/src/opengl/qwindowsurface_x11gl.cpp
+++ b/src/opengl/qwindowsurface_x11gl.cpp
@@ -51,14 +51,16 @@
QT_BEGIN_NAMESPACE
QX11GLWindowSurface::QX11GLWindowSurface(QWidget* window)
- : QWindowSurface(window), m_GC(0), m_window(window)
+ : QWindowSurface(window), m_windowGC(0), m_pixmapGC(0), m_window(window)
{
}
QX11GLWindowSurface::~QX11GLWindowSurface()
{
- if (m_GC)
- XFree(m_GC);
+ if (m_windowGC)
+ XFree(m_windowGC);
+ if (m_pixmapGC)
+ XFree(m_pixmapGC);
}
QPaintDevice *QX11GLWindowSurface::paintDevice()
@@ -92,16 +94,22 @@ void QX11GLWindowSurface::flush(QWidget *widget, const QRegion &widgetRegion, co
// for (int i = 0; i < num; ++i)
// qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height;
- if (m_GC == 0) {
- m_GC = XCreateGC(X11->display, m_window->handle(), 0, 0);
- XSetGraphicsExposures(X11->display, m_GC, False);
+ if (m_windowGC == 0) {
+ m_windowGC = XCreateGC(X11->display, m_window->handle(), 0, 0);
+ XSetGraphicsExposures(X11->display, m_windowGC, False);
}
- XSetClipRectangles(X11->display, m_GC, 0, 0, rects, rectCount, YXBanded);
- XCopyArea(X11->display, m_backBuffer.handle(), m_window->handle(), m_GC,
+ XSetClipRectangles(X11->display, m_windowGC, 0, 0, rects, rectCount, YXBanded);
+ XCopyArea(X11->display, m_backBuffer.handle(), m_window->handle(), m_windowGC,
boundingRect.x() + offset.x(), boundingRect.y() + offset.y(),
boundingRect.width(), boundingRect.height(),
windowBoundingRect.x(), windowBoundingRect.y());
+
+ QX11GLPixmapData* pmd = static_cast<QX11GLPixmapData*>(m_backBuffer.data_ptr().data());
+ Q_ASSERT(pmd->context());
+ pmd->context()->makeCurrent();
+ XSync(X11->display, False);
+ eglWaitNative(EGL_CORE_NATIVE_ENGINE);
}
void QX11GLWindowSurface::setGeometry(const QRect &rect)
@@ -113,6 +121,8 @@ void QX11GLWindowSurface::setGeometry(const QRect &rect)
QX11GLPixmapData *pd = new QX11GLPixmapData;
pd->resize(newSize.width(), newSize.height());
m_backBuffer = QPixmap(pd);
+ if (window()->testAttribute(Qt::WA_TranslucentBackground))
+ m_backBuffer.fill(Qt::transparent);
}
// if (gc)
@@ -124,10 +134,30 @@ void QX11GLWindowSurface::setGeometry(const QRect &rect)
bool QX11GLWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
- Q_UNUSED(area);
- Q_UNUSED(dx);
- Q_UNUSED(dy);
- return false;
+ if (m_backBuffer.isNull())
+ return false;
+
+ Q_ASSERT(m_backBuffer.data_ptr()->classId() == QPixmapData::X11Class);
+
+ QX11GLPixmapData* pmd = static_cast<QX11GLPixmapData*>(m_backBuffer.data_ptr().data());
+ Q_ASSERT(pmd->context());
+ pmd->context()->makeCurrent();
+ glFinish();
+ eglWaitClient();
+
+ if (!m_pixmapGC)
+ m_pixmapGC = XCreateGC(X11->display, m_backBuffer.handle(), 0, 0);
+
+ foreach (const QRect& rect, area.rects()) {
+ XCopyArea(X11->display, m_backBuffer.handle(), m_backBuffer.handle(), m_pixmapGC,
+ rect.x(), rect.y(), rect.width(), rect.height(),
+ rect.x()+dx, rect.y()+dy);
+ }
+
+ XSync(X11->display, False);
+ eglWaitNative(EGL_CORE_NATIVE_ENGINE);
+
+ return true;
}
/*