summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-05 03:51:10 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-05 03:51:10 (GMT)
commit48fd47f64f3f73e82016161d82cdf67908a9c653 (patch)
treee337d89e525d3a55d2b9aca8c19d2b3b43c65c50 /src/opengl
parenta7b46bda37a428ae2e5554aa8e58469c92b310a9 (diff)
parentc9b3309ae1d3a34790d71fdfd7dcaab79433f049 (diff)
downloadQt-48fd47f64f3f73e82016161d82cdf67908a9c653.zip
Qt-48fd47f64f3f73e82016161d82cdf67908a9c653.tar.gz
Qt-48fd47f64f3f73e82016161d82cdf67908a9c653.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts: tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl_egl.cpp33
-rw-r--r--src/opengl/qgl_p.h9
-rw-r--r--src/opengl/qgl_x11egl.cpp7
-rw-r--r--src/opengl/qglpixelbuffer.h1
4 files changed, 36 insertions, 14 deletions
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index f1abab8..7bfcf27 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -40,8 +40,14 @@
****************************************************************************/
#include <QtOpenGL/qgl.h>
+#include <QtOpenGL/qglpixelbuffer.h>
#include "qgl_p.h"
#include "qgl_egl_p.h"
+#include "qglpixelbuffer_p.h"
+
+#ifdef Q_WS_X11
+#include <QtGui/private/qpixmap_x11_p.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -154,12 +160,12 @@ void QGLContext::reset()
void QGLContext::makeCurrent()
{
Q_D(QGLContext);
- if (!d->valid || !d->eglContext || d->eglSurface == EGL_NO_SURFACE) {
+ if (!d->valid || !d->eglContext || d->eglSurfaceForDevice() == EGL_NO_SURFACE) {
qWarning("QGLContext::makeCurrent(): Cannot make invalid context current");
return;
}
- if (d->eglContext->makeCurrent(d->eglSurface))
+ if (d->eglContext->makeCurrent(d->eglSurfaceForDevice()))
QGLContextPrivate::setCurrentContext(this);
}
@@ -179,7 +185,7 @@ void QGLContext::swapBuffers() const
if (!d->valid || !d->eglContext)
return;
- d->eglContext->swapBuffers(d->eglSurface);
+ d->eglContext->swapBuffers(d->eglSurfaceForDevice());
}
void QGLContextPrivate::destroyEglSurfaceForDevice()
@@ -202,6 +208,27 @@ void QGLContextPrivate::destroyEglSurfaceForDevice()
}
}
+EGLSurface QGLContextPrivate::eglSurfaceForDevice() const
+{
+ if (paintDevice->devType() == QInternal::Widget)
+ return eglSurface;
+ if (paintDevice->devType() == QInternal::Pixmap) {
+#ifdef Q_WS_X11
+ QPixmapData *pmd = static_cast<QPixmap*>(paintDevice)->data_ptr().data();
+ if (pmd->classId() == QPixmapData::X11Class) {
+ QX11PixmapData* x11PixmapData = static_cast<QX11PixmapData*>(pmd);
+ return (EGLSurface)x11PixmapData->gl_surface;
+ } else
+#endif
+ return eglSurface;
+ }
+ if (paintDevice->devType() == QInternal::Pbuffer) {
+ QGLPixelBuffer* pbuf = static_cast<QGLPixelBuffer*>(paintDevice);
+ return pbuf->d_func()->pbuf;
+ }
+ return EGL_NO_SURFACE;
+}
+
void QGLWidget::setMouseTracking(bool enable)
{
QWidget::setMouseTracking(enable);
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index ecd8b43..c142715 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -65,13 +65,7 @@
#include "qglpaintdevice_p.h"
#ifdef QT_OPENGL_ES
-QT_BEGIN_INCLUDE_NAMESPACE
-#if defined(QT_OPENGL_ES_2)
-#include <EGL/egl.h>
-#else
-#include <GLES/egl.h>
-#endif
-QT_END_INCLUDE_NAMESPACE
+#include <QtGui/private/qegl_p.h>
#endif
QT_BEGIN_NAMESPACE
@@ -356,6 +350,7 @@ public:
QEglContext *eglContext;
EGLSurface eglSurface;
void destroyEglSurfaceForDevice();
+ EGLSurface eglSurfaceForDevice() const;
#elif defined(Q_WS_X11) || defined(Q_WS_MAC)
void* cx;
#endif
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index bcde8c4..123bbdd 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -229,7 +229,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
// QWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface
// QGLWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface
// QPixmap - yes, create the EGLSurface but store it in QX11PixmapData::gl_surface
- // QGLPixelBuffer - no, it creates the surface itself
+ // QGLPixelBuffer - no, it creates the surface itself and stores it in QGLPixelBufferPrivate::pbuf
if (devType == QInternal::Widget) {
if (d->eglSurface != EGL_NO_SURFACE)
@@ -404,7 +404,7 @@ EGLConfig Q_OPENGL_EXPORT qt_chooseEGLConfigForPixmap(bool hasAlpha, bool readOn
if (configCount > 0) {
// Got one
qDebug() << "Found an" << (hasAlpha ? "ARGB" : "RGB") << (readOnly ? "readonly" : "target" )
- << "config (" << int(*targetConfig) << ") to create a pixmap surface:";
+ << "config to create a pixmap surface:";
// QEglProperties configProps(*targetConfig);
// qDebug() << configProps.toString();
@@ -446,8 +446,7 @@ bool Q_OPENGL_EXPORT qt_createEGLSurfaceForPixmap(QPixmapData* pmd, bool readOnl
// qDebug("qt_createEGLSurfaceForPixmap() created surface 0x%x for pixmap 0x%x",
// pixmapSurface, pixmapData->handle());
if (pixmapSurface == EGL_NO_SURFACE) {
- qWarning() << "Failed to create a pixmap surface using config" << (int)pixmapConfig
- << ":" << QEgl::errorString();
+ qWarning() << "Failed to create a pixmap surface:" << QEgl::errorString();
return false;
}
diff --git a/src/opengl/qglpixelbuffer.h b/src/opengl/qglpixelbuffer.h
index 3304dd8..d9c7e3e 100644
--- a/src/opengl/qglpixelbuffer.h
+++ b/src/opengl/qglpixelbuffer.h
@@ -112,6 +112,7 @@ private:
friend class QGLWindowSurface;
friend class QGLPaintDevice;
friend class QGLPBufferGLPaintDevice;
+ friend class QGLContextPrivate;
};
QT_END_NAMESPACE