summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopengl_p.h
diff options
context:
space:
mode:
authorSean Harmer <[email protected]>2012-07-20 16:21:47 +0100
committerQt by Nokia <[email protected]>2012-08-07 18:55:43 +0200
commit46212d657e2e989dddd361a732e65b05748e8e91 (patch)
treecf63240dd6a273a9fd6516cb17cc9f2229af1d35 /src/gui/opengl/qopengl_p.h
parente81d7fd1e57fe2ce11cbe07636f890973116f7ab (diff)
Improve the QOpenGLExtensionMatcher class
Using a QSet<QByteArray> internally means that checking for the presence of an extension no longer uses an O(N) search. This patch also allows users of this class to easily get a list of the supported extensions. Change-Id: I02194e5345573c47be0876f3ea6eb6b69a2ead81 Reviewed-by: Samuel Rødal <[email protected]> Reviewed-by: Gunnar Sletta <[email protected]>
Diffstat (limited to 'src/gui/opengl/qopengl_p.h')
-rw-r--r--src/gui/opengl/qopengl_p.h28
1 files changed, 7 insertions, 21 deletions
diff --git a/src/gui/opengl/qopengl_p.h b/src/gui/opengl/qopengl_p.h
index 1860fb16833..b59e6c0fc5a 100644
--- a/src/gui/opengl/qopengl_p.h
+++ b/src/gui/opengl/qopengl_p.h
@@ -44,9 +44,7 @@
#include <qopengl.h>
#include <private/qopenglcontext_p.h>
-
-#include <qthreadstorage.h>
-#include <qcache.h>
+#include <QtCore/qset.h>
QT_BEGIN_HEADER
@@ -55,29 +53,17 @@ QT_BEGIN_NAMESPACE
class QOpenGLExtensionMatcher
{
public:
- QOpenGLExtensionMatcher(const char *str);
QOpenGLExtensionMatcher();
- bool match(const char *str) const {
- int str_length = qstrlen(str);
-
- Q_ASSERT(str);
- Q_ASSERT(str_length > 0);
- Q_ASSERT(str[str_length-1] != ' ');
-
- for (int i = 0; i < m_offsets.size(); ++i) {
- const char *extension = m_extensions.constData() + m_offsets.at(i);
- if (qstrncmp(extension, str, str_length) == 0 && extension[str_length] == ' ')
- return true;
- }
- return false;
+ bool match(const QByteArray &extension) const
+ {
+ return m_extensions.contains(extension);
}
-private:
- void init(const char *str);
+ QSet<QByteArray> extensions() const { return m_extensions; }
- QByteArray m_extensions;
- QVector<int> m_offsets;
+private:
+ QSet<QByteArray> m_extensions;
};
QT_END_NAMESPACE