summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-03 09:39:48 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-03 09:39:48 (GMT)
commit2808823eafe3b9773a84039c38e9f149a578a4f3 (patch)
treed10c0ae3d6d970962ca6aa3e982f5992afb9d6ea /src
parent46dbe721c8a9efc555eb4c449141071825f2f747 (diff)
parente614e3548bbe505c75e8b3a54f44f07522a6ecf5 (diff)
downloadQt-2808823eafe3b9773a84039c38e9f149a578a4f3.zip
Qt-2808823eafe3b9773a84039c38e9f149a578a4f3.tar.gz
Qt-2808823eafe3b9773a84039c38e9f149a578a4f3.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Add and use QGLContextPrivate::eglSurfaceForDevice() QMetaType: Now we can register typedefs.
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qmetatype.cpp60
-rw-r--r--src/corelib/kernel/qmetatype.h37
-rw-r--r--src/opengl/qgl_egl.cpp33
-rw-r--r--src/opengl/qgl_p.h1
-rw-r--r--src/opengl/qgl_x11egl.cpp2
-rw-r--r--src/opengl/qglpixelbuffer.h1
6 files changed, 126 insertions, 8 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 779b69b..be506b4 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -352,6 +352,7 @@ public:
QMetaType::SaveOperator saveOp;
QMetaType::LoadOperator loadOp;
#endif
+ int alias;
};
Q_DECLARE_TYPEINFO(QCustomTypeInfo, Q_MOVABLE_TYPE);
@@ -436,8 +437,11 @@ static int qMetaTypeCustomType_unlocked(const char *typeName, int length)
return 0;
for (int v = 0; v < ct->count(); ++v) {
- if ((length == ct->at(v).typeName.size())
- && !strcmp(typeName, ct->at(v).typeName.constData())) {
+ const QCustomTypeInfo &customInfo = ct->at(v);
+ if ((length == customInfo.typeName.size())
+ && !strcmp(typeName, customInfo.typeName.constData())) {
+ if (customInfo.alias >= 0)
+ return customInfo.alias;
return v + QMetaType::User;
}
}
@@ -475,6 +479,7 @@ int QMetaType::registerType(const char *typeName, Destructor destructor,
inf.typeName = normalizedTypeName;
inf.constr = constructor;
inf.destr = destructor;
+ inf.alias = -1;
idx = ct->size() + User;
ct->append(inf);
}
@@ -482,6 +487,51 @@ int QMetaType::registerType(const char *typeName, Destructor destructor,
return idx;
}
+/*! \internal
+ \since 4.7
+
+ Registers a user type for marshalling, as an alias of another type (typedef)
+*/
+int QMetaType::registerTypedef(const char* typeName, int aliasId)
+{
+ QVector<QCustomTypeInfo> *ct = customTypes();
+ if (!ct || !typeName)
+ return -1;
+
+#ifdef QT_NO_QOBJECT
+ NS(QByteArray) normalizedTypeName = typeName;
+#else
+ NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
+#endif
+
+ int idx = qMetaTypeStaticType(normalizedTypeName.constData(),
+ normalizedTypeName.size());
+
+ if (idx) {
+ Q_ASSERT(idx == aliasId);
+ return idx;
+ }
+
+ QWriteLocker locker(customTypesLock());
+ idx = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(),
+ normalizedTypeName.size());
+
+ if (idx) {
+ Q_ASSERT(idx == aliasId);
+ return idx;
+ }
+
+ if (!idx) {
+ QCustomTypeInfo inf;
+ inf.typeName = normalizedTypeName;
+ inf.alias = aliasId;
+ inf.constr = 0;
+ inf.destr = 0;
+ ct->append(inf);
+ }
+ return aliasId;
+}
+
/*!
\since 4.4
@@ -507,6 +557,7 @@ void QMetaType::unregisterType(const char *typeName)
inf.typeName.clear();
inf.constr = 0;
inf.destr = 0;
+ inf.alias = -1;
}
}
}
@@ -1349,6 +1400,11 @@ void QMetaType::destroy(int type, void *data)
\snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 4
+ This function is usefull to register typedefs so they can be used
+ by QMetaProperty, or in QueuedConnections
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qmetatype.cpp 9
+
\sa qRegisterMetaTypeStreamOperators(), QMetaType::isRegistered(),
Q_DECLARE_METATYPE()
*/
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 33126e8..2ed4a1f 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -113,6 +113,7 @@ public:
#endif
static int registerType(const char *typeName, Destructor destructor,
Constructor constructor);
+ static int registerTypedef(const char *typeName, int aliasId);
static int type(const char *typeName);
static const char *typeName(int type);
static bool isRegistered(int type);
@@ -154,13 +155,31 @@ void qMetaTypeLoadHelper(QDataStream &stream, T *t)
}
#endif // QT_NO_DATASTREAM
+template <typename T> struct QMetaTypeId2;
+
+namespace QtPrivate {
+ template <typename T, bool Defined = QMetaTypeId2<T>::Defined>
+ struct QMetaTypeIdHelper {
+ static inline int qt_metatype_id()
+ { return QMetaTypeId2<T>::qt_metatype_id(); }
+ };
+ template <typename T> struct QMetaTypeIdHelper<T, false> {
+ static inline int qt_metatype_id()
+ { return -1; }
+ };
+}
+
template <typename T>
int qRegisterMetaType(const char *typeName
#ifndef qdoc
- , T * /* dummy */ = 0
+ , typename QMetaTypeId2<T>::CustomType * dummy = 0
#endif
)
{
+ const int typedefOf = dummy ? -1 : QtPrivate::QMetaTypeIdHelper<T>::qt_metatype_id();
+ if (typedefOf != -1)
+ return QMetaType::registerTypedef(typeName, typedefOf);
+
typedef void*(*ConstructPtr)(const T*);
ConstructPtr cptr = qMetaTypeConstructHelper<T>;
typedef void(*DeletePtr)(T*);
@@ -170,6 +189,17 @@ int qRegisterMetaType(const char *typeName
reinterpret_cast<QMetaType::Constructor>(cptr));
}
+template <typename T>
+int qRegisterMetaType(const char *typeName
+#ifndef qdoc
+ , typename QMetaTypeId2<T>::BuiltinType * /* dummy */ = 0
+#endif
+)
+{
+ return QMetaType::registerTypedef(typeName, QMetaTypeId2<T>::MetaType);
+}
+
+
#ifndef QT_NO_DATASTREAM
template <typename T>
void qRegisterMetaTypeStreamOperators(const char *typeName
@@ -198,6 +228,7 @@ struct QMetaTypeId
template <typename T>
struct QMetaTypeId2
{
+ typedef T CustomType;
enum { Defined = QMetaTypeId<T>::Defined };
static inline int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
};
@@ -254,7 +285,8 @@ inline int qRegisterMetaTypeStreamOperators()
{ \
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \
if (!metatype_id) \
- metatype_id = qRegisterMetaType< TYPE >(#TYPE); \
+ metatype_id = qRegisterMetaType< TYPE >(#TYPE, \
+ reinterpret_cast< TYPE *>(quintptr(-1))); \
return metatype_id; \
} \
}; \
@@ -264,6 +296,7 @@ inline int qRegisterMetaTypeStreamOperators()
QT_BEGIN_NAMESPACE \
template<> struct QMetaTypeId2<TYPE> \
{ \
+ typedef TYPE BuiltinType; \
enum { Defined = 1, MetaType = QMetaType::NAME }; \
static inline int qt_metatype_id() { return QMetaType::NAME; } \
}; \
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..b828bea 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -356,6 +356,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..ba05e72 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)
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