summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-08-31 11:28:14 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-09-08 16:36:14 (GMT)
commitb7963df603a315136b32297b861f089c0cd49acd (patch)
tree797d95a3be461b1b76585cf67a09a02ae092f184 /src/opengl
parent7c59abc1883a24e54ac3bb2193acc2cac5ad416a (diff)
downloadQt-b7963df603a315136b32297b861f089c0cd49acd.zip
Qt-b7963df603a315136b32297b861f089c0cd49acd.tar.gz
Qt-b7963df603a315136b32297b861f089c0cd49acd.tar.bz2
Make QGLPixelBuffer work again using new QGLPaintDevice API
Add a new QGLPBufferGLPaintDevice implementation which allows the GL engines to target QGLPixelBuffers again.
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qglpaintdevice.cpp7
-rw-r--r--src/opengl/qglpixelbuffer.cpp8
-rw-r--r--src/opengl/qglpixelbuffer.h2
-rw-r--r--src/opengl/qglpixelbuffer_p.h13
4 files changed, 29 insertions, 1 deletions
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index f7bd2a3..9815add 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -41,6 +41,7 @@
#include <private/qglpaintdevice_p.h>
#include <private/qgl_p.h>
+#include <private/qglpixelbuffer_p.h>
QGLPaintDevice::QGLPaintDevice()
: m_context(0)
@@ -85,11 +86,12 @@ void QGLPaintDevice::beginPaint()
void QGLPaintDevice::endPaint()
{
+ glFlush();
}
QColor QGLPaintDevice::backgroundColor() const
{
- return QColor();
+ return QApplication::palette().brush(QPalette::Background).color();
}
bool QGLPaintDevice::autoFillBackground() const
@@ -181,6 +183,9 @@ QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd)
Q_ASSERT(qobject_cast<QGLWidget*>(static_cast<QWidget*>(pd)));
glpd = &(static_cast<QGLWidget*>(pd)->d_func()->glDevice);
break;
+ case QInternal::Pbuffer:
+ glpd = &(static_cast<QGLPixelBuffer*>(pd)->d_func()->glDevice);
+ break;
default:
qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType());
break;
diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp
index f082ff0..f7cb3cc 100644
--- a/src/opengl/qglpixelbuffer.cpp
+++ b/src/opengl/qglpixelbuffer.cpp
@@ -100,6 +100,13 @@ void qgl_cleanup_glyph_cache(QGLContext *) {}
extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool);
+
+void QGLPBufferGLPaintDevice::setPBuffer(QGLPixelBuffer* pb)
+{
+ pbuf = pb;
+ setContext(pb->d_func()->qctx);
+}
+
void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget)
{
Q_Q(QGLPixelBuffer);
@@ -115,6 +122,7 @@ void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &form
shareWidget->d_func()->glcx->d_func()->sharing = true;
}
+ glDevice.setPBuffer(q);
qctx->d_func()->paintDevice = q;
qctx->d_func()->valid = true;
#if defined(Q_WS_WIN) && !defined(QT_OPENGL_ES)
diff --git a/src/opengl/qglpixelbuffer.h b/src/opengl/qglpixelbuffer.h
index 5e81ea3..fe313a6 100644
--- a/src/opengl/qglpixelbuffer.h
+++ b/src/opengl/qglpixelbuffer.h
@@ -110,6 +110,8 @@ private:
QScopedPointer<QGLPixelBufferPrivate> d_ptr;
friend class QGLDrawable;
friend class QGLWindowSurface;
+ friend class QGLPaintDevice;
+ friend class QGLPBufferGLPaintDevice;
};
QT_END_NAMESPACE
diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h
index 74cb330..e24d1ea 100644
--- a/src/opengl/qglpixelbuffer_p.h
+++ b/src/opengl/qglpixelbuffer_p.h
@@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE
QT_BEGIN_INCLUDE_NAMESPACE
#include "QtOpenGL/qglpixelbuffer.h"
#include <private/qgl_p.h>
+#include <private/qglpaintdevice_p.h>
#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
#include <GL/glx.h>
@@ -135,6 +136,17 @@ QT_END_INCLUDE_NAMESPACE
class QEglContext;
+
+class QGLPBufferGLPaintDevice : public QGLPaintDevice
+{
+public:
+ virtual QPaintEngine* paintEngine() const {return pbuf->paintEngine();}
+ virtual QSize size() const {return pbuf->size();}
+ void setPBuffer(QGLPixelBuffer* pb);
+private:
+ QGLPixelBuffer* pbuf;
+};
+
class QGLPixelBufferPrivate {
Q_DECLARE_PUBLIC(QGLPixelBuffer)
public:
@@ -154,6 +166,7 @@ public:
QGLPixelBuffer *q_ptr;
bool invalid;
QGLContext *qctx;
+ QGLPBufferGLPaintDevice glDevice;
QGLFormat format;
QGLFormat req_format;