summaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2015-03-13 17:17:47 +0000
committerJose Fonseca <jfonseca@vmware.com>2015-03-13 17:17:47 +0000
commit0e1d41b29b32dcdffe2bb58cc83c24088219e6e1 (patch)
tree6421b43bba0df2ac79947f734450b08221f3fae4 /helpers
parent8a460c5003ff2626de410572bc9a82bbc8a56a66 (diff)
glretrace: Cleanup Profile::matches.
Diffstat (limited to 'helpers')
-rw-r--r--helpers/glprofile.cpp42
-rw-r--r--helpers/glprofile.hpp27
2 files changed, 44 insertions, 25 deletions
diff --git a/helpers/glprofile.cpp b/helpers/glprofile.cpp
index de996b33..8004add4 100644
--- a/helpers/glprofile.cpp
+++ b/helpers/glprofile.cpp
@@ -35,6 +35,48 @@
namespace glprofile {
+bool
+Profile::matches(const Profile expected) const
+{
+ if (api != expected.api) {
+ return false;
+ }
+
+ if (!versionGreaterOrEqual(expected.major, expected.minor)) {
+ return false;
+ }
+
+ /*
+ * GLX_ARB_create_context/WGL_ARB_create_context specs state that
+ *
+ * "If version 3.1 is requested, the context returned may implement
+ * any of the following versions:
+ *
+ * * Version 3.1. The GL_ARB_compatibility extension may or may not
+ * be implemented, as determined by the implementation.
+ *
+ * * The core profile of version 3.2 or greater."
+ */
+ if (core != expected.core &&
+ (expected.major != 3 || expected.minor != 1)) {
+ return false;
+ }
+
+ /*
+ * Only check forward-compatible flag prior to 3.2 contexts.
+ *
+ * Note that on MacOSX all 3.2+ context must be forward-compatible.
+ */
+#ifndef __APPLE__
+ if (forwardCompatible > expected.forwardCompatible) {
+ return false;
+ }
+#endif
+
+ return true;
+}
+
+
std::ostream &
operator << (std::ostream &os, const Profile & profile) {
os << "OpenGL";
diff --git a/helpers/glprofile.hpp b/helpers/glprofile.hpp
index d81fe863..b662f3af 100644
--- a/helpers/glprofile.hpp
+++ b/helpers/glprofile.hpp
@@ -85,31 +85,8 @@ struct Profile {
(major == refMajor && minor >= refMinor);
}
- inline bool
- matches(const Profile expected) const {
- /*
- * GLX_ARB_create_context/WGL_ARB_create_context specs state that
- *
- * "If version 3.1 is requested, the context returned may implement
- * any of the following versions:
- *
- * * Version 3.1. The GL_ARB_compatibility extension may or may not
- * be implemented, as determined by the implementation.
- *
- * * The core profile of version 3.2 or greater."
- */
- return api == expected.api &&
- versionGreaterOrEqual(expected.major, expected.minor) &&
- (core == expected.core ||
- (expected.major == 3 && expected.minor == 1)) &&
-#ifdef __APPLE__
- /* All 3.2+ contexts on MacOSX are forward-compatible */
- true
-#else
- forwardCompatible <= expected.forwardCompatible
-#endif
- ;
- }
+ bool
+ matches(const Profile expected) const;
// Comparison operator, mainly for use in std::map
inline bool