From 4a79b52bde74ed7332d92543b8cf1ac810e19c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 23 Mar 2012 08:51:15 +0100 Subject: [PATCH] Make QEglFSBackingStore use QtGui-only APIs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now have better replacements for QGLPaintDevice etc. Change-Id: I3ac563f0ac26a563b3c788d16c77e0237d9d96d9 Reviewed-by: Donald Carr Reviewed-by: Jørgen Lind Reviewed-by: Andy Nichols --- src/plugins/platforms/eglfs/eglfs.pro | 4 - .../platforms/eglfs/qeglfsbackingstore.cpp | 81 ++++++++----------- .../platforms/eglfs/qeglfsbackingstore.h | 17 ++-- 3 files changed, 45 insertions(+), 57 deletions(-) diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro index 86a1b8239c..c12d612c98 100644 --- a/src/plugins/platforms/eglfs/eglfs.pro +++ b/src/plugins/platforms/eglfs/eglfs.pro @@ -3,10 +3,6 @@ load(qt_plugin) QT += core-private gui-private platformsupport-private -!contains(QT_CONFIG, no-widgets) { - QT += opengl opengl-private widgets-private -} - DESTDIR = $$QT.gui.plugins/platforms #DEFINES += QEGL_EXTRA_DEBUG diff --git a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp index d2e4a47e56..8e9e5f76e0 100644 --- a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp +++ b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp @@ -41,67 +41,54 @@ #include "qeglfsbackingstore.h" -#ifndef QT_NO_WIDGETS -#include -#include -#endif //QT_NO_WIDGETS - -#include -#include +#include +#include QT_BEGIN_NAMESPACE -#ifndef QT_NO_WIDGETS -class QEglFSPaintDevice : public QGLPaintDevice -{ -public: - QEglFSPaintDevice(QEglFSScreen *screen) - :QGLPaintDevice(), m_screen(screen) - { - #ifdef QEGL_EXTRA_DEBUG - qWarning("QEglPaintDevice %p, %p",this, screen); - #endif - } - - QSize size() const { return m_screen->geometry().size(); } - QGLContext* context() const { return QGLContext::fromOpenGLContext(m_screen->platformContext()->context()); } - - QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); } - - void beginPaint(){ - QGLPaintDevice::beginPaint(); - } -private: - QEglFSScreen *m_screen; - QGLContext *m_context; -}; -#endif //QT_NO_WIDGETS - QEglFSBackingStore::QEglFSBackingStore(QWindow *window) - : QPlatformBackingStore(window), - m_paintDevice(0) + : QPlatformBackingStore(window) + , m_context(new QOpenGLContext) { -#ifdef QEGL_EXTRA_DEBUG - qWarning("QEglBackingStore %p, %p", window, window->screen()); -#endif -#ifdef QT_NO_WIDGETS - m_paintDevice = new QImage(0,0); -#else - m_paintDevice = new QEglFSPaintDevice(static_cast(window->screen()->handle())); -#endif //QT_NO_WIDGETS + m_context->setFormat(window->requestedFormat()); + m_context->setScreen(window->screen()); + m_context->create(); +} + +QEglFSBackingStore::~QEglFSBackingStore() +{ + delete m_context; +} + +QPaintDevice *QEglFSBackingStore::paintDevice() +{ + return m_device; } void QEglFSBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { - Q_UNUSED(window); Q_UNUSED(region); Q_UNUSED(offset); + #ifdef QEGL_EXTRA_DEBUG qWarning("QEglBackingStore::flush %p", window); #endif -#ifndef QT_NO_WIDGETS - static_cast(m_paintDevice)->context()->swapBuffers(); -#endif //QT_NO_WIDGETS + + m_context->swapBuffers(window); +} + +void QEglFSBackingStore::beginPaint(const QRegion &) +{ + // needed to prevent QOpenGLContext::makeCurrent() from failing + window()->setSurfaceType(QSurface::OpenGLSurface); + + m_context->makeCurrent(window()); + m_device = new QOpenGLPaintDevice(window()->size()); +} + +void QEglFSBackingStore::endPaint() +{ + delete m_device; } void QEglFSBackingStore::resize(const QSize &size, const QRegion &staticContents) diff --git a/src/plugins/platforms/eglfs/qeglfsbackingstore.h b/src/plugins/platforms/eglfs/qeglfsbackingstore.h index 1ae3ecdc61..1eb4d8d79a 100644 --- a/src/plugins/platforms/eglfs/qeglfsbackingstore.h +++ b/src/plugins/platforms/eglfs/qeglfsbackingstore.h @@ -42,25 +42,30 @@ #ifndef QEGLWINDOWSURFACE_H #define QEGLWINDOWSURFACE_H -#include "qeglfsintegration.h" -#include "qeglfswindow.h" - #include QT_BEGIN_NAMESPACE +class QOpenGLContext; +class QOpenGLPaintDevice; + class QEglFSBackingStore : public QPlatformBackingStore { public: QEglFSBackingStore(QWindow *window); - ~QEglFSBackingStore() { delete m_paintDevice; } + ~QEglFSBackingStore(); + + QPaintDevice *paintDevice(); + + void beginPaint(const QRegion &); + void endPaint(); - QPaintDevice *paintDevice() { return m_paintDevice; } void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); void resize(const QSize &size, const QRegion &staticContents); private: - QPaintDevice *m_paintDevice; + QOpenGLContext *m_context; + QOpenGLPaintDevice *m_device; }; QT_END_NAMESPACE