diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-09-07 00:18:46 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-09-07 00:18:46 (GMT) |
commit | 6d908473ec1a8c72f4bbb9d772e801024c3a62a0 (patch) | |
tree | 235c45a19bbc22d0885ad2eb9b6978731e78569d /src/opengl/qgl_p.h | |
parent | 203158b2444c9eb98714292d057c0c87a037ce3b (diff) | |
download | Qt-6d908473ec1a8c72f4bbb9d772e801024c3a62a0.zip Qt-6d908473ec1a8c72f4bbb9d772e801024c3a62a0.tar.gz Qt-6d908473ec1a8c72f4bbb9d772e801024c3a62a0.tar.bz2 |
Performance: Convert QGLFormat to use implicit sharing
QGLFormat was being deep-copied many times per frame because of
code like this:
if (context()->format().doubleBuffer()) { ...
This change modifies QGLFormat to use implicit sharing to reduce
the overhead of the above type of checks.
Reviewed-by: Sarah Smith
Diffstat (limited to 'src/opengl/qgl_p.h')
-rw-r--r-- | src/opengl/qgl_p.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 72ec35e..d4b7597 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -59,6 +59,7 @@ #include "QtCore/qthread.h" #include "QtCore/qthreadstorage.h" #include "QtCore/qhash.h" +#include "QtCore/qatomic.h" #include "private/qwidget_p.h" #include "qcache.h" @@ -127,7 +128,9 @@ QT_END_INCLUDE_NAMESPACE class QGLFormatPrivate { public: - QGLFormatPrivate() { + QGLFormatPrivate() + : ref(1) + { opts = QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba | QGL::DirectRendering | QGL::StencilBuffer; #if defined(QT_OPENGL_ES_2) opts |= QGL::SampleBuffers; @@ -137,6 +140,22 @@ public: numSamples = -1; swapInterval = -1; } + QGLFormatPrivate(const QGLFormatPrivate *other) + : ref(1), + opts(other->opts), + pln(other->pln), + depthSize(other->depthSize), + accumSize(other->accumSize), + stencilSize(other->stencilSize), + redSize(other->redSize), + greenSize(other->greenSize), + blueSize(other->blueSize), + alphaSize(other->alphaSize), + numSamples(other->numSamples), + swapInterval(other->swapInterval) + { + } + QAtomicInt ref; QGL::FormatOptions opts; int pln; int depthSize; |