Make QEglFSBackingStore use QtGui-only APIs.

We now have better replacements for QGLPaintDevice etc.

Change-Id: I3ac563f0ac26a563b3c788d16c77e0237d9d96d9
Reviewed-by: Donald Carr <donald.carr@nokia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Reviewed-by: Andy Nichols <andy.nichols@nokia.com>
This commit is contained in:
Samuel Rødal 2012-03-23 08:51:15 +01:00 committed by Qt by Nokia
parent 400e59201b
commit 4a79b52bde
3 changed files with 45 additions and 57 deletions

View File

@ -3,10 +3,6 @@ load(qt_plugin)
QT += core-private gui-private platformsupport-private QT += core-private gui-private platformsupport-private
!contains(QT_CONFIG, no-widgets) {
QT += opengl opengl-private widgets-private
}
DESTDIR = $$QT.gui.plugins/platforms DESTDIR = $$QT.gui.plugins/platforms
#DEFINES += QEGL_EXTRA_DEBUG #DEFINES += QEGL_EXTRA_DEBUG

View File

@ -41,67 +41,54 @@
#include "qeglfsbackingstore.h" #include "qeglfsbackingstore.h"
#ifndef QT_NO_WIDGETS #include <QtGui/QOpenGLContext>
#include <QtOpenGL/private/qgl_p.h> #include <QtGui/QOpenGLPaintDevice>
#include <QtOpenGL/private/qglpaintdevice_p.h>
#endif //QT_NO_WIDGETS
#include <QtGui/QPlatformOpenGLContext>
#include <QtGui/QScreen>
QT_BEGIN_NAMESPACE 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) QEglFSBackingStore::QEglFSBackingStore(QWindow *window)
: QPlatformBackingStore(window), : QPlatformBackingStore(window)
m_paintDevice(0) , m_context(new QOpenGLContext)
{ {
#ifdef QEGL_EXTRA_DEBUG m_context->setFormat(window->requestedFormat());
qWarning("QEglBackingStore %p, %p", window, window->screen()); m_context->setScreen(window->screen());
#endif m_context->create();
#ifdef QT_NO_WIDGETS }
m_paintDevice = new QImage(0,0);
#else QEglFSBackingStore::~QEglFSBackingStore()
m_paintDevice = new QEglFSPaintDevice(static_cast<QEglFSScreen *>(window->screen()->handle())); {
#endif //QT_NO_WIDGETS delete m_context;
}
QPaintDevice *QEglFSBackingStore::paintDevice()
{
return m_device;
} }
void QEglFSBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset) void QEglFSBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{ {
Q_UNUSED(window);
Q_UNUSED(region); Q_UNUSED(region);
Q_UNUSED(offset); Q_UNUSED(offset);
#ifdef QEGL_EXTRA_DEBUG #ifdef QEGL_EXTRA_DEBUG
qWarning("QEglBackingStore::flush %p", window); qWarning("QEglBackingStore::flush %p", window);
#endif #endif
#ifndef QT_NO_WIDGETS
static_cast<QEglFSPaintDevice *>(m_paintDevice)->context()->swapBuffers(); m_context->swapBuffers(window);
#endif //QT_NO_WIDGETS }
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) void QEglFSBackingStore::resize(const QSize &size, const QRegion &staticContents)

View File

@ -42,25 +42,30 @@
#ifndef QEGLWINDOWSURFACE_H #ifndef QEGLWINDOWSURFACE_H
#define QEGLWINDOWSURFACE_H #define QEGLWINDOWSURFACE_H
#include "qeglfsintegration.h"
#include "qeglfswindow.h"
#include <QtGui/qplatformbackingstore_qpa.h> #include <QtGui/qplatformbackingstore_qpa.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QOpenGLContext;
class QOpenGLPaintDevice;
class QEglFSBackingStore : public QPlatformBackingStore class QEglFSBackingStore : public QPlatformBackingStore
{ {
public: public:
QEglFSBackingStore(QWindow *window); 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 &region, const QPoint &offset); void flush(QWindow *window, const QRegion &region, const QPoint &offset);
void resize(const QSize &size, const QRegion &staticContents); void resize(const QSize &size, const QRegion &staticContents);
private: private:
QPaintDevice *m_paintDevice; QOpenGLContext *m_context;
QOpenGLPaintDevice *m_device;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE