summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2009-10-02 04:47:04 (GMT)
committerKurt Korbatits <kurt.korbatits@nokia.com>2009-10-02 04:47:04 (GMT)
commit8fa169202bf2bf169b65a72daee6b497f36be65c (patch)
tree45a0420caf4abc30f2463d70d271d0c61697125d
parent5d94ce44f19316ce1c30c23635bf9575d80aa4e2 (diff)
parentad90350d0ba3971591554f871ec17544be414038 (diff)
downloadQt-8fa169202bf2bf169b65a72daee6b497f36be65c.zip
Qt-8fa169202bf2bf169b65a72daee6b497f36be65c.tar.gz
Qt-8fa169202bf2bf169b65a72daee6b497f36be65c.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
-rw-r--r--src/opengl/qgl.cpp40
-rw-r--r--src/opengl/qgl_p.h12
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp13
3 files changed, 28 insertions, 37 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 665290c..0402268 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -4860,44 +4860,40 @@ void QGLShareRegister::addShare(const QGLContext *context, const QGLContext *sha
return;
// Make sure 'context' is not already shared with another group of contexts.
- Q_ASSERT(reg.find(context->d_ptr->group) == reg.end());
Q_ASSERT(context->d_ptr->group->m_refs == 1);
// Free 'context' group resources and make it use the same resources as 'share'.
+ QGLContextGroup *group = share->d_ptr->group;
delete context->d_ptr->group;
- context->d_ptr->group = share->d_ptr->group;
- context->d_ptr->group->m_refs.ref();
+ context->d_ptr->group = group;
+ group->m_refs.ref();
// Maintain a list of all the contexts in each group of sharing contexts.
- SharingHash::iterator it = reg.find(share->d_ptr->group);
- if (it == reg.end())
- it = reg.insert(share->d_ptr->group, ContextList() << share);
- it.value() << context;
+ // The list is empty if the "share" context wasn't sharing already.
+ if (group->m_shares.isEmpty())
+ group->m_shares.append(share);
+ group->m_shares.append(context);
}
QList<const QGLContext *> QGLShareRegister::shares(const QGLContext *context) {
- SharingHash::const_iterator it = reg.find(context->d_ptr->group);
- if (it == reg.end())
- return ContextList();
- return it.value();
+ return context->d_ptr->group->m_shares;
}
void QGLShareRegister::removeShare(const QGLContext *context) {
- SharingHash::iterator it = reg.find(context->d_ptr->group);
- if (it == reg.end())
+ // Remove the context from the group.
+ QGLContextGroup *group = context->d_ptr->group;
+ if (group->m_shares.isEmpty())
return;
-
- int count = it.value().removeAll(context);
- Q_ASSERT(count == 1);
- Q_UNUSED(count);
+ group->m_shares.removeAll(context);
// Update context group representative.
- if (context->d_ptr->group->m_context == context)
- context->d_ptr->group->m_context = it.value().first();
+ Q_ASSERT(group->m_shares.size() != 0);
+ if (group->m_context == context)
+ group->m_context = group->m_shares[0];
- Q_ASSERT(it.value().size() != 0);
- if (it.value().size() == 1)
- reg.erase(it);
+ // If there is only one context left, then make the list empty.
+ if (group->m_shares.size() == 1)
+ group->m_shares.clear();
}
QGLContextResource::QGLContextResource(FreeFunc f, QObject *parent)
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 9b09c7c..1957429 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -233,6 +233,7 @@ private:
QGLExtensionFuncs m_extensionFuncs;
const QGLContext *m_context; // context group's representative
+ QList<const QGLContext *> m_shares;
QAtomicInt m_refs;
friend class QGLShareRegister;
@@ -343,13 +344,11 @@ public:
#ifdef Q_WS_WIN
static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); }
- static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *ctx) { return ctx->extensionFuncs(); }
#endif
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
static QGLExtensionFuncs qt_extensionFuncs;
static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; }
- static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *) { return qt_extensionFuncs; }
#endif
static void setCurrentContext(QGLContext *context);
@@ -403,16 +402,11 @@ class Q_AUTOTEST_EXPORT QGLShareRegister
{
public:
QGLShareRegister() {}
- ~QGLShareRegister() { reg.clear(); }
+ ~QGLShareRegister() {}
void addShare(const QGLContext *context, const QGLContext *share);
QList<const QGLContext *> shares(const QGLContext *context);
void removeShare(const QGLContext *context);
-private:
- // Use a context's 'group' pointer to uniquely identify a group.
- typedef QList<const QGLContext *> ContextList;
- typedef QHash<const QGLContextGroup *, ContextList> SharingHash;
- SharingHash reg;
};
extern Q_OPENGL_EXPORT QGLShareRegister* qgl_share_reg();
@@ -490,8 +484,6 @@ private:
#ifdef Q_WS_QWS
extern QPaintEngine* qt_qgl_paint_engine();
-
-extern EGLDisplay qt_qgl_egl_display();
#endif
bool qt_gl_preferGL2Engine();
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
index 3698afd..afee77e 100644
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
@@ -157,18 +157,21 @@ QImage PvrEglWindowSurface::image() const
void *data = pvrQwsGetRenderBuffer(drawable);
if (data) {
return QImage((uchar *)data, pvrRect.width, pvrRect.height,
- pvrQwsGetStride(drawable), QImage::Format_RGB16);
+ pvrQwsGetStride(drawable), screen->pixelFormat());
}
}
- return QImage();
+ return QImage(16, 16, screen->pixelFormat());
}
QPaintDevice *PvrEglWindowSurface::paintDevice()
{
- // Return a dummy paint device because the widget itself
- // cannot be painted to this way.
+ QGLWidget *glWidget = qobject_cast<QGLWidget *>(window());
+ if (glWidget)
+ return glWidget;
+
+ // Should be a QGLWidget, but if not return a dummy paint device.
if (!pdevice)
- pdevice = new QImage(50, 50, QImage::Format_RGB16);
+ pdevice = new QImage(50, 50, screen->pixelFormat());
return pdevice;
}