diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-09-14 02:30:44 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-09-14 05:06:06 (GMT) |
commit | 9e3fb515207f8d80fe87b6e34e78d3d201b0b438 (patch) | |
tree | e89933d4ba8f65f5099e1beaab33a514c247e2cd /src/opengl/qgl_mac.mm | |
parent | 732660e89af34c76f6aa8a46ce8507dfd5fad077 (diff) | |
download | Qt-9e3fb515207f8d80fe87b6e34e78d3d201b0b438.zip Qt-9e3fb515207f8d80fe87b6e34e78d3d201b0b438.tar.gz Qt-9e3fb515207f8d80fe87b6e34e78d3d201b0b438.tar.bz2 |
Performance: reduce TLS overhead of QGLContext::currentContext()
The handling for the current QGLContext was looking up the same
TLS data several times per call (hasLocalData() and localData()
calls particularly).
This change also refactors the code a little so that the
setting of the QGLContext within makeCurrent() and doneCurrent()
is in one location in the code instead of six (one per platform).
Reviewed-by: Michael Brasser
Reviewed-by: Sarah Smith
Diffstat (limited to 'src/opengl/qgl_mac.mm')
-rw-r--r-- | src/opengl/qgl_mac.mm | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm index dd9d9ff..063082b 100644 --- a/src/opengl/qgl_mac.mm +++ b/src/opengl/qgl_mac.mm @@ -493,11 +493,7 @@ void QGLContext::makeCurrent() #else [static_cast<NSOpenGLContext *>(d->cx) makeCurrentContext]; #endif - currentCtx = this; - if (!qgl_context_storage.hasLocalData() && QThread::currentThread()) - qgl_context_storage.setLocalData(new QGLThreadContext); - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = this; + QGLContextPrivate::setCurrentContext(this); } #ifndef QT_MAC_USE_COCOA @@ -656,9 +652,7 @@ void QGLContext::doneCurrent() ) return; - currentCtx = 0; - if (qgl_context_storage.hasLocalData()) - qgl_context_storage.localData()->context = 0; + QGLContextPrivate::setCurrentContext(0); #ifndef QT_MAC_USE_COCOA aglSetCurrentContext(0); #else |