diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2012-04-08 14:00:34 -0700 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2012-04-09 08:55:09 -0700 |
commit | cb71190fb6f12480a279491a12d9e4089f124b92 (patch) | |
tree | 55e8125f10772a318612d1f6ff5fb7e9f00008fc | |
parent | 4312014a8bcfa902540bae21d92d2557d2f81789 (diff) |
waffle: Change some default values to WAFFLE_DONT_CARE
Change the default value of WAFFE_{RED,GREEN,BLUE,ALPHA}_SIZE to
WAFFLE_DONT_CARE. The egl module translates WAFFLE_DONT_CARE to
EGL_DONT_CARE.
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r-- | include/waffle/waffle_enum.h | 5 | ||||
-rw-r--r-- | src/waffle/core/wcore_config_attrs.c | 33 | ||||
-rw-r--r-- | src/waffle/egl/egl_no_native.c | 28 | ||||
-rw-r--r-- | tests/unittests/waffle/core/wcore_config_attrs_unittest.c | 19 |
4 files changed, 65 insertions, 20 deletions
diff --git a/include/waffle/waffle_enum.h b/include/waffle/waffle_enum.h index 0854b9b..f530db6 100644 --- a/include/waffle/waffle_enum.h +++ b/include/waffle/waffle_enum.h @@ -37,7 +37,7 @@ waffle_enum_to_string(int32_t e); /// enables better error detection at API entry points. enum waffle_enum { WAFFLE_LIST_END = 0x0000, - WAFFLE_DONT_CARE = 0x0001, + WAFFLE_DONT_CARE = 0x7777, /// @defgroup enums for waffle_init() /// @{ @@ -58,7 +58,8 @@ enum waffle_enum { /// @defgroup enums for waffle_config_choose() /// /// Choices for @c WAFFLE_DOUBLE_BUFFERED are 0 and 1; the default is 1. - /// For all other attributes, the default is 0. + /// The default value of WAFFLE_SAMPLE_BUFFERS and WAFFLE_SAMPLES is 0. + /// The default value of all other attributes is WAFFLE_DONT_CARE. /// @{ WAFFLE_RED_SIZE = 0x0201, diff --git a/src/waffle/core/wcore_config_attrs.c b/src/waffle/core/wcore_config_attrs.c index cb4fc21..e869b86 100644 --- a/src/waffle/core/wcore_config_attrs.c +++ b/src/waffle/core/wcore_config_attrs.c @@ -20,6 +20,22 @@ #include <waffle/waffle_enum.h> #include <waffle/core/wcore_error.h> +static const struct wcore_config_attrs wcore_config_attrs_default = { + .color_buffer_size = 0, + .red_size = WAFFLE_DONT_CARE, + .green_size = WAFFLE_DONT_CARE, + .blue_size = WAFFLE_DONT_CARE, + .alpha_size = WAFFLE_DONT_CARE, + + .depth_size = WAFFLE_DONT_CARE, + .stencil_size = WAFFLE_DONT_CARE, + + .sample_buffers = 0, + .samples = 0, + + .double_buffered = true, +}; + bool wcore_config_attrs_parse( const int32_t waffle_attrib_list[], @@ -27,9 +43,7 @@ wcore_config_attrs_parse( { const int32_t *i; - // Set defaults. - memset(attrs, 0, sizeof(*attrs)); - attrs->double_buffered = true; + memcpy(attrs, &wcore_config_attrs_default, sizeof(*attrs)); if (!waffle_attrib_list) { // Nothing to parse. Just return defaults. @@ -88,10 +102,15 @@ wcore_config_attrs_parse( } } - attrs->color_buffer_size = attrs->red_size - + attrs->green_size - + attrs->blue_size - + attrs->alpha_size; + attrs->color_buffer_size = 0; + if (attrs->red_size != WAFFLE_DONT_CARE) + attrs->color_buffer_size += attrs->red_size; + if (attrs->green_size != WAFFLE_DONT_CARE) + attrs->color_buffer_size += attrs->green_size; + if (attrs->blue_size != WAFFLE_DONT_CARE) + attrs->color_buffer_size += attrs->blue_size; + if (attrs->alpha_size != WAFFLE_DONT_CARE) + attrs->color_buffer_size += attrs->alpha_size; return attrs; }
\ No newline at end of file diff --git a/src/waffle/egl/egl_no_native.c b/src/waffle/egl/egl_no_native.c index 67f17cd..3500289 100644 --- a/src/waffle/egl/egl_no_native.c +++ b/src/waffle/egl/egl_no_native.c @@ -22,6 +22,16 @@ #include <waffle/core/wcore_config_attrs.h> #include <waffle/core/wcore_error.h> +static EGLint +egl_translate_attr_value(int32_t waffle_attr_value) +{ + switch(waffle_attr_value) { + case WAFFLE_DONT_CARE: return EGL_DONT_CARE; + default: return waffle_attr_value; + } +} + + void egl_get_error(const char *egl_func_call) { @@ -80,17 +90,17 @@ egl_choose_config( const int renderable_index = 19; EGLint attrib_list[] = { - EGL_BUFFER_SIZE, attrs->color_buffer_size, - EGL_RED_SIZE, attrs->red_size, - EGL_BLUE_SIZE, attrs->blue_size, - EGL_GREEN_SIZE, attrs->green_size, - EGL_ALPHA_SIZE, attrs->alpha_size, + EGL_BUFFER_SIZE, egl_translate_attr_value(attrs->color_buffer_size), + EGL_RED_SIZE, egl_translate_attr_value(attrs->red_size), + EGL_BLUE_SIZE, egl_translate_attr_value(attrs->blue_size), + EGL_GREEN_SIZE, egl_translate_attr_value(attrs->green_size), + EGL_ALPHA_SIZE, egl_translate_attr_value(attrs->alpha_size), - EGL_DEPTH_SIZE, attrs->depth_size, - EGL_STENCIL_SIZE, attrs->stencil_size, + EGL_DEPTH_SIZE, egl_translate_attr_value(attrs->depth_size), + EGL_STENCIL_SIZE, egl_translate_attr_value(attrs->stencil_size), - EGL_SAMPLE_BUFFERS, attrs->sample_buffers, - EGL_SAMPLES, attrs->samples, + EGL_SAMPLE_BUFFERS, egl_translate_attr_value(attrs->sample_buffers), + EGL_SAMPLES, egl_translate_attr_value(attrs->samples), EGL_RENDERABLE_TYPE, 31415926, diff --git a/tests/unittests/waffle/core/wcore_config_attrs_unittest.c b/tests/unittests/waffle/core/wcore_config_attrs_unittest.c index aa8e16a..78c34e1 100644 --- a/tests/unittests/waffle/core/wcore_config_attrs_unittest.c +++ b/tests/unittests/waffle/core/wcore_config_attrs_unittest.c @@ -23,6 +23,22 @@ static struct wcore_config_attrs actual_attrs; static struct wcore_config_attrs expect_attrs; +static const struct wcore_config_attrs default_attrs = { + .color_buffer_size = 0, + .red_size = WAFFLE_DONT_CARE, + .green_size = WAFFLE_DONT_CARE, + .blue_size = WAFFLE_DONT_CARE, + .alpha_size = WAFFLE_DONT_CARE, + + .depth_size = WAFFLE_DONT_CARE, + .stencil_size = WAFFLE_DONT_CARE, + + .sample_buffers = 0, + .samples = 0, + + .double_buffered = true, +}; + static void testgroup_wcore_config_attrs_setup(void) { @@ -30,8 +46,7 @@ testgroup_wcore_config_attrs_setup(void) memset(&actual_attrs, 0x99, sizeof(actual_attrs)); // Set expect_attrs to defaults. - memset(&expect_attrs, 0, sizeof(expect_attrs)); - expect_attrs.double_buffered = true; + memcpy(&expect_attrs, &default_attrs, sizeof(expect_attrs)); } static void |