diff options
author | Trond Kjernåsen <trond@trolltech.com> | 2010-03-17 11:16:57 (GMT) |
---|---|---|
committer | Trond Kjernåsen <trond.kjernasen@nokia.com> | 2010-07-02 10:24:44 (GMT) |
commit | 9f72c297843459ab22eeb3af048baa9037aa9634 (patch) | |
tree | 1d92997378ee06095caa2be720ed09cc4e41e304 /src/opengl | |
parent | e9ac791e2afce05be68da5f7b0c00eac00811f29 (diff) | |
download | Qt-9f72c297843459ab22eeb3af048baa9037aa9634.zip Qt-9f72c297843459ab22eeb3af048baa9037aa9634.tar.gz Qt-9f72c297843459ab22eeb3af048baa9037aa9634.tar.bz2 |
Make qt_gl_paint_engine() thread-safe.
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5c5d3d1..b875fd1 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -5031,25 +5031,54 @@ void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QM } #endif -#ifndef QT_OPENGL_ES_1 -Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine) +#if !defined(QT_OPENGL_ES_1) +class QtGL2EngineStorage +{ +public: + QPaintEngine *engine() { + QPaintEngine *localEngine = storage.localData(); + if (!localEngine) { + localEngine = new QGL2PaintEngineEx; + storage.setLocalData(localEngine); + } + return localEngine; + } + +private: + QThreadStorage<QPaintEngine *> storage; +}; +Q_GLOBAL_STATIC(QtGL2EngineStorage, qt_gl_2_engine) #endif #ifndef QT_OPENGL_ES_2 -Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_engine) +class QtGL1EngineStorage +{ +public: + QPaintEngine *engine() { + QPaintEngine *localEngine = storage.localData(); + if (!localEngine) { + localEngine = new QOpenGLPaintEngine; + storage.setLocalData(localEngine); + } + return localEngine; + } +private: + QThreadStorage<QPaintEngine *> storage; +}; +Q_GLOBAL_STATIC(QtGL1EngineStorage, qt_gl_engine) #endif Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine() { #if defined(QT_OPENGL_ES_1) - return qt_gl_engine(); + return qt_gl_engine()->engine(); #elif defined(QT_OPENGL_ES_2) - return qt_gl_2_engine(); + return qt_gl_2_engine()->engine(); #else if (qt_gl_preferGL2Engine()) - return qt_gl_2_engine(); + return qt_gl_2_engine()->engine(); else - return qt_gl_engine(); + return qt_gl_engine()->engine(); #endif } |