summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/waffle_config.3.xml34
-rw-r--r--src/waffle/core/wcore_config_attrs.c69
2 files changed, 76 insertions, 27 deletions
diff --git a/man/waffle_config.3.xml b/man/waffle_config.3.xml
index 00631af..082ed92 100644
--- a/man/waffle_config.3.xml
+++ b/man/waffle_config.3.xml
@@ -354,7 +354,7 @@ struct waffle_config;
<para>
The default value for each size attribute is <constant>0</constant>.
- The range of valid values is the non-negative integers.
+ Valid values are the non-negative integers and <constant>WAFFLE_DONT_CARE</constant>.
If the requested size
for a channel is 0, then any surface created with the config will lack that channel. If the requested size
@@ -369,10 +369,20 @@ struct waffle_config;
<term><constant>WAFFLE_SAMPLES</constant></term>
<listitem>
<para>
- The valid values for <constant>WAFFLE_SAMPLE_BUFFERS</constant> are true and false. The default value is
- false. If false, then any surface created with the config will not be multisampled. If true, the any surface
+ The default value of <constant>WAFFLE_SAMPLE_BUFFERS</constant> is false(0).
+
+ Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>.
+
+ The attribute specifies if a surface created with this config is double-buffered.
+
+ If false, then any surface created with the config will not be multisampled. If true, the any surface
created with the config will be multisampled, where the number of samples will be at least
- <constant>WAFFLE_SAMPLES</constant>. The default value of <constant>WAFFLE_SAMPLES</constant> is 0.
+ <constant>WAFFLE_SAMPLES</constant>.
+ </para>
+ <para>
+ The default value of <constant>WAFFLE_SAMPLES</constant> is <constant>0</constant>.
+
+ Valid values are the non-negative integers and <constant>WAFFLE_DONT_CARE</constant>.
</para>
</listitem>
</varlistentry>
@@ -381,8 +391,11 @@ struct waffle_config;
<term><constant>WAFFLE_DOUBLE_BUFFERED</constant></term>
<listitem>
<para>
- The valid values are true and false. The default is true. This attribute specifies if a surface created with
- this config is double-buffered.
+ The default value is true(1).
+
+ Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>.
+
+ This attribute specifies if a surface created with this config is double-buffered.
</para>
</listitem>
</varlistentry>
@@ -391,12 +404,15 @@ struct waffle_config;
<term><constant>WAFFLE_ACCUM_BUFFER</constant></term>
<listitem>
<para>
- The valid values are true and false. The default is false. This attribute specifies if a surface created with
- this config possesses an accumulation buffer.
+ The default value is false(0).
+
+ Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>.
+
+ This attribute specifies if a surface created with this config possesses an accumulation buffer.
</para>
</listitem>
</varlistentry>
-
+
</variablelist>
</refsect1>
diff --git a/src/waffle/core/wcore_config_attrs.c b/src/waffle/core/wcore_config_attrs.c
index 918ad31..bb9a0a1 100644
--- a/src/waffle/core/wcore_config_attrs.c
+++ b/src/waffle/core/wcore_config_attrs.c
@@ -35,6 +35,12 @@
#include "wcore_config_attrs.h"
#include "wcore_error.h"
+enum {
+ DEFAULT_ACCUM_BUFFERS = false,
+ DEFAULT_DOUBLE_BUFFERED = true,
+ DEFAULT_SAMPLE_BUFFERS = false,
+};
+
static bool
check_keys(const int32_t attrib_list[])
{
@@ -312,23 +318,43 @@ parse_misc(struct wcore_config_attrs *attrs,
#define CASE_INT(enum_name, struct_memb) \
case enum_name: \
- if (value < 0) { \
+ if (value < -1) { \
wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE, \
#enum_name " has bad value %d", value); \
return false; \
} \
- attrs->struct_memb = value; \
+ else { \
+ /* \
+ * Pass WAFFLE_DONT_CARE to platform module. \
+ * \
+ * From the GLX 1.4 (2005.12.16) spec: \
+ * GLX_DONT_CARE may be specified for all \
+ * attributes except GLX_LEVEL. \
+ * \
+ * From the EGL 1.4 (2011.04.06) spec: \
+ * EGL_DONT_CARE may be specified for all \
+ * attributes except EGL_LEVEL and \
+ * EGL_MATCH_NATIVE_PIXMAP. \
+ */ \
+ attrs->struct_memb = value; \
+ } \
break;
- #define CASE_BOOL(enum_name, struct_memb) \
+ #define CASE_BOOL(enum_name, struct_memb, default_value) \
case enum_name: \
- if (value != true && value != false) { \
- wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE, \
- #enum_name " has bad value 0x%x, must be " \
- "true(1) or false(0)", value); \
- return false; \
+ switch (value) { \
+ case WAFFLE_DONT_CARE: \
+ case true: \
+ case false: \
+ attrs->struct_memb = value; \
+ break; \
+ default: \
+ wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE, \
+ #enum_name " has bad value 0x%x, must be "\
+ "true(1) or false(0), or " \
+ "WAFFLE_DONT_CARE(-1)", value); \
+ return false; \
} \
- attrs->struct_memb = value; \
break;
case WAFFLE_CONTEXT_API:
@@ -346,9 +372,9 @@ parse_misc(struct wcore_config_attrs *attrs,
CASE_INT(WAFFLE_STENCIL_SIZE, stencil_size)
CASE_INT(WAFFLE_SAMPLES, samples)
- CASE_BOOL(WAFFLE_SAMPLE_BUFFERS, sample_buffers);
- CASE_BOOL(WAFFLE_DOUBLE_BUFFERED, double_buffered);
- CASE_BOOL(WAFFLE_ACCUM_BUFFER, accum_buffer);
+ CASE_BOOL(WAFFLE_SAMPLE_BUFFERS, sample_buffers, DEFAULT_SAMPLE_BUFFERS);
+ CASE_BOOL(WAFFLE_DOUBLE_BUFFERED, double_buffered, DEFAULT_DOUBLE_BUFFERED);
+ CASE_BOOL(WAFFLE_ACCUM_BUFFER, accum_buffer, DEFAULT_ACCUM_BUFFER);
default:
wcore_error_internal("%s", "bad attribute key should have "
@@ -361,12 +387,19 @@ parse_misc(struct wcore_config_attrs *attrs,
}
}
- attrs->rgb_size = attrs->red_size
- + attrs->green_size
- + attrs->blue_size;
-
- attrs->rgba_size = attrs->rgb_size
- + attrs->alpha_size;
+ // Calculate rgb_size.
+ attrs->rgb_size = 0;
+ if (attrs->red_size != WAFFLE_DONT_CARE)
+ attrs->rgb_size += attrs->red_size;
+ if (attrs->green_size != WAFFLE_DONT_CARE)
+ attrs->rgb_size += attrs->green_size;
+ if (attrs->blue_size != WAFFLE_DONT_CARE)
+ attrs->rgb_size += attrs->blue_size;
+
+ // Calculate rgba_size.
+ attrs->rgba_size = attrs->rgb_size;
+ if (attrs->alpha_size != WAFFLE_DONT_CARE)
+ attrs->rgba_size += attrs->alpha_size;
return true;
}