summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-09-07 15:10:35 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-09-08 16:36:16 (GMT)
commite3e7cf545116c194bd5cfe79b28ea37c8bf78219 (patch)
tree72696f91453009c79ac0729a07fd63f09b7bad15
parent4feed48fdd738ed99cba86a4214e238a3e7275ed (diff)
downloadQt-e3e7cf545116c194bd5cfe79b28ea37c8bf78219.zip
Qt-e3e7cf545116c194bd5cfe79b28ea37c8bf78219.tar.gz
Qt-e3e7cf545116c194bd5cfe79b28ea37c8bf78219.tar.bz2
Make QGLWindowSurface use new QGLPaintDevice API
-rw-r--r--src/gui/kernel/qwidget.h1
-rw-r--r--src/opengl/qglpaintdevice.cpp9
-rw-r--r--src/opengl/qglpaintdevice_p.h4
-rw-r--r--src/opengl/qwindowsurface_gl.cpp65
-rw-r--r--src/opengl/qwindowsurface_gl_p.h19
5 files changed, 65 insertions, 33 deletions
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index 284558f..bd30cad 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -731,6 +731,7 @@ private:
friend class QGLContext;
friend class QGLWidget;
friend class QGLWindowSurface;
+ friend class QGLWindowSurfaceGLPaintDevice;
friend class QVGWindowSurface;
friend class QX11PaintEngine;
friend class QWin32PaintEngine;
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index 4f000ba..4cdeb76 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -43,6 +43,7 @@
#include <private/qgl_p.h>
#include <private/qglpixelbuffer_p.h>
#include <private/qglframebufferobject_p.h>
+#include <private/qwindowsurface_gl_p.h>
QGLPaintDevice::QGLPaintDevice()
{
@@ -106,10 +107,10 @@ QGLFormat QGLPaintDevice::format() const
return context()->format();
}
-QSize QGLPaintDevice::size() const
-{
- return QSize();
-}
+//QSize QGLPaintDevice::size() const
+//{
+// return QSize();
+//}
diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h
index 6d34b1b..b0e8826 100644
--- a/src/opengl/qglpaintdevice_p.h
+++ b/src/opengl/qglpaintdevice_p.h
@@ -62,6 +62,8 @@ public:
QGLPaintDevice();
virtual ~QGLPaintDevice();
+ int devType() const {return QInternal::OpenGL;}
+
virtual void beginPaint();
virtual void ensureActiveTarget();
virtual void endPaint();
@@ -74,7 +76,7 @@ public:
virtual QGLContext* context() const = 0;
QGLFormat format() const;
- virtual QSize size() const;
+ virtual QSize size() const = 0;
// returns the QGLPaintDevice for the given QPaintDevice
static QGLPaintDevice* getDevice(QPaintDevice*);
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index a85b9ae..3a6ed06 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -229,6 +229,7 @@ QGLWidget* qt_gl_share_widget()
return _qt_gl_share_widget()->shareWidget();
}
+
struct QGLWindowSurfacePrivate
{
QGLFramebufferObject *fbo;
@@ -248,10 +249,49 @@ struct QGLWindowSurfacePrivate
QSize size;
QList<QImage> buffers;
+ QGLWindowSurfaceGLPaintDevice glDevice;
+ QGLWindowSurface* q_ptr;
};
QGLFormat QGLWindowSurface::surfaceFormat;
+void QGLWindowSurfaceGLPaintDevice::endPaint()
+{
+ glFlush();
+ QGLPaintDevice::endPaint();
+}
+
+QSize QGLWindowSurfaceGLPaintDevice::size() const
+{
+ return d->size;
+}
+
+QGLContext* QGLWindowSurfaceGLPaintDevice::context() const
+{
+ return d->ctx;
+}
+
+
+int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const
+{
+ return d->q_ptr->window()->metric(m);
+}
+
+Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine)
+
+#if !defined (QT_OPENGL_ES_2)
+Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine)
+#endif
+
+QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
+{
+#if !defined(QT_OPENGL_ES_2)
+ if (!qt_gl_preferGL2Engine())
+ return qt_gl_window_surface_engine();
+#endif
+ return qt_gl_window_surface_2_engine();
+}
+
QGLWindowSurface::QGLWindowSurface(QWidget *window)
: QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate)
{
@@ -263,6 +303,8 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window)
d_ptr->tried_fbo = false;
d_ptr->tried_pb = false;
d_ptr->destructive_swap_buffers = qgetenv("QT_GL_SWAPBUFFER_PRESERVE").isNull();
+ d_ptr->glDevice.d = d_ptr;
+ d_ptr->q_ptr = this;
}
QGLWindowSurface::~QGLWindowSurface()
@@ -320,27 +362,6 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size();
}
-Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine)
-
-#if !defined (QT_OPENGL_ES_2)
-Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine)
-#endif
-
-/*! \reimp */
-QPaintEngine *QGLWindowSurface::paintEngine() const
-{
-#if !defined(QT_OPENGL_ES_2)
- if (!qt_gl_preferGL2Engine())
- return qt_gl_window_surface_engine();
-#endif
- return qt_gl_window_surface_2_engine();
-}
-
-int QGLWindowSurface::metric(PaintDeviceMetric m) const
-{
- return window()->metric(m);
-}
-
QGLContext *QGLWindowSurface::context() const
{
return d_ptr->ctx;
@@ -354,7 +375,7 @@ QPaintDevice *QGLWindowSurface::paintDevice()
return d_ptr->pb;
if (d_ptr->ctx)
- return this;
+ return &d_ptr->glDevice;
QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
ctx->makeCurrent();
diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h
index ad583b2..7b18f2e 100644
--- a/src/opengl/qwindowsurface_gl_p.h
+++ b/src/opengl/qwindowsurface_gl_p.h
@@ -56,6 +56,7 @@
#include <qglobal.h>
#include <qgl.h>
#include <private/qwindowsurface_p.h>
+#include <private/qglpaintdevice_p.h>
QT_BEGIN_NAMESPACE
@@ -65,7 +66,18 @@ class QRegion;
class QWidget;
struct QGLWindowSurfacePrivate;
-class QGLWindowSurface : public QObject, public QWindowSurface, public QPaintDevice
+class QGLWindowSurfaceGLPaintDevice : public QGLPaintDevice
+{
+public:
+ QPaintEngine* paintEngine() const;
+ void endPaint();
+ QSize size() const;
+ int metric(PaintDeviceMetric m) const;
+ QGLContext* context() const;
+ QGLWindowSurfacePrivate* d;
+};
+
+class QGLWindowSurface : public QObject, public QWindowSurface // , public QPaintDevice
{
Q_OBJECT
public:
@@ -87,11 +99,6 @@ public:
static QGLFormat surfaceFormat;
- QPaintEngine *paintEngine() const;
-
-protected:
- int metric(PaintDeviceMetric metric) const;
-
private slots:
void deleted(QObject *object);