[waffle] [PATCH 2/4] waffle internals: Add helper functions for attrs versions
Jordan Justen
jordan.l.justen at intel.com
Sun May 4 10:14:19 PDT 2014
These functions make it easier to compare against known OpenGL and
OpenGLES versions since all known and expected future versions have a
minor version <= 9.
For example, to check that the attrs struct has a version >= 3.2, use
wcore_config_attrs_version_above_or_equals(attrs, 32)
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
src/waffle/core/wcore_config_attrs.c | 48 ++++++++++++++++++++++++++++++++++++
src/waffle/core/wcore_config_attrs.h | 25 +++++++++++++++++++
2 files changed, 73 insertions(+)
diff --git a/src/waffle/core/wcore_config_attrs.c b/src/waffle/core/wcore_config_attrs.c
index c4b37d9..0d27516 100644
--- a/src/waffle/core/wcore_config_attrs.c
+++ b/src/waffle/core/wcore_config_attrs.c
@@ -511,3 +511,51 @@ wcore_config_attrs_parse(
return true;
}
+
+bool
+wcore_config_attrs_version_equals(
+ const struct wcore_config_attrs *attrs,
+ int merged_version)
+{
+ return
+ attrs->context_major_version == (merged_version / 10) &&
+ attrs->context_minor_version == (merged_version % 10);
+}
+
+bool
+wcore_config_attrs_version_above(
+ const struct wcore_config_attrs *attrs,
+ int merged_version)
+{
+ return
+ attrs->context_major_version > (merged_version / 10) ||
+ (attrs->context_major_version == (merged_version / 10) &&
+ attrs->context_minor_version > (merged_version % 10));
+}
+
+bool
+wcore_config_attrs_version_above_or_equals(
+ const struct wcore_config_attrs *attrs,
+ int merged_version)
+{
+ return
+ attrs->context_major_version > (merged_version / 10) ||
+ (attrs->context_major_version == (merged_version / 10) &&
+ attrs->context_minor_version >= (merged_version % 10));
+}
+
+bool
+wcore_config_attrs_version_below(
+ const struct wcore_config_attrs *attrs,
+ int merged_version)
+{
+ return !wcore_config_attrs_version_above_or_equals(attrs, merged_version);
+}
+
+bool
+wcore_config_attrs_version_below_or_equals(
+ const struct wcore_config_attrs *attrs,
+ int merged_version)
+{
+ return !wcore_config_attrs_version_above(attrs, merged_version);
+}
diff --git a/src/waffle/core/wcore_config_attrs.h b/src/waffle/core/wcore_config_attrs.h
index 4021115..b7ff1f6 100644
--- a/src/waffle/core/wcore_config_attrs.h
+++ b/src/waffle/core/wcore_config_attrs.h
@@ -60,3 +60,28 @@ bool
wcore_config_attrs_parse(
const int32_t waffle_attrib_list[],
struct wcore_config_attrs *attrs);
+
+bool
+wcore_config_attrs_version_equals(
+ const struct wcore_config_attrs *attrs,
+ int merged_version);
+
+bool
+wcore_config_attrs_version_above(
+ const struct wcore_config_attrs *attrs,
+ int merged_version);
+
+bool
+wcore_config_attrs_version_above_or_equals(
+ const struct wcore_config_attrs *attrs,
+ int merged_version);
+
+bool
+wcore_config_attrs_version_below(
+ const struct wcore_config_attrs *attrs,
+ int merged_version);
+
+bool
+wcore_config_attrs_version_below_or_equals(
+ const struct wcore_config_attrs *attrs,
+ int merged_version);
--
1.9.2
More information about the waffle
mailing list