[waffle] [PATCH 09/11] waffle: Add public func waffle_window_create2()
Frank Henigman
fjhenigman at google.com
Tue Dec 23 16:24:17 PST 2014
On Tue, Dec 16, 2014 at 3:18 AM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> Today, waffle_window() has only two parameters: width and height.
>
> Frank Henigman wants to extend Waffle's GBM backend with the ability to
> post window contents to the display. Multiple methods exist for posting
> content to the screen with the drm API, and that method should be
> configurable per waffle_window. Therefore, we need to be able to pass
> additional attributes to waffle_window_create().
>
> It would also be nice to specify at time of creation that the
> waffle_window should be full screen. Again, we need to pass additional
> attributes to waffle_window_create().
>
> The new function waffle_window_create2() is conceptually equivalent to
> the original waffle_window_create() with the addition of an attrib_list
> parameter. The only supported attributes are currently
> WAFFLE_WINDOW_WIDTH and WAFFLE_WINDOW_HEIGHT.
>
> See the manpage changes for more details.
>
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
> ---
> include/waffle/waffle.h | 14 +++++++++
> man/waffle_enum.3.xml | 7 +++++
> man/waffle_window.3.xml | 27 ++++++++++++++++
> src/waffle/api/waffle_window.c | 71 ++++++++++++++++++++++++++++++++++++++++++
> src/waffle/core/wcore_util.c | 2 ++
> 5 files changed, 121 insertions(+)
>
> diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
> index e04b23f..820d012 100644
> --- a/include/waffle/waffle.h
> +++ b/include/waffle/waffle.h
> @@ -150,6 +150,13 @@ enum waffle_enum {
> WAFFLE_DL_OPENGL_ES1 = 0x0302,
> WAFFLE_DL_OPENGL_ES2 = 0x0303,
> WAFFLE_DL_OPENGL_ES3 = 0x0304,
> +
> + // ------------------------------------------------------------------
> + // For waffle_window
> + // ------------------------------------------------------------------
> +
> + WAFFLE_WINDOW_WIDTH = 0x0310,
> + WAFFLE_WINDOW_HEIGHT = 0x0311,
> };
>
> const char*
> @@ -221,6 +228,13 @@ waffle_context_get_native(struct waffle_context *self);
> // waffle_window
> // ---------------------------------------------------------------------------
>
> +#if WAFFLE_API_VERSION >= 0x0106
> +struct waffle_window*
> +waffle_window_create2(
> + struct waffle_config *config,
> + const intptr_t attrib_list[]);
> +#endif
> +
> struct waffle_window*
> waffle_window_create(
> struct waffle_config *config,
> diff --git a/man/waffle_enum.3.xml b/man/waffle_enum.3.xml
> index a96bd20..ee5f236 100644
> --- a/man/waffle_enum.3.xml
> +++ b/man/waffle_enum.3.xml
> @@ -141,6 +141,13 @@ enum waffle_enum {
> WAFFLE_DL_OPENGL = 0x0301,
> WAFFLE_DL_OPENGL_ES1 = 0x0302,
> WAFFLE_DL_OPENGL_ES2 = 0x0303,
> +
> + // ------------------------------------------------------------------
> + // For waffle_window
> + // ------------------------------------------------------------------
> +
> + WAFFLE_WINDOW_WIDTH = 0x0310,
> + WAFFLE_WINDOW_HEIGHT = 0x0311,
> };
> ]]>
> </programlisting>
> diff --git a/man/waffle_window.3.xml b/man/waffle_window.3.xml
> index de046fa..795152a 100644
> --- a/man/waffle_window.3.xml
> +++ b/man/waffle_window.3.xml
> @@ -56,6 +56,12 @@ struct waffle_window;
> </funcprototype>
>
> <funcprototype>
> + <funcdef>struct waffle_window* <function>waffle_window_create2</function></funcdef>
> + <paramdef>struct waffle_window *<parameter>config</parameter></paramdef>
> + <paramdef>const intptr_t <parameter>attrib_list</parameter>[]</paramdef>
> + </funcprototype>
> +
> + <funcprototype>
> <funcdef>bool <function>waffle_window_destroy</function></funcdef>
> <paramdef>struct waffle_window *<parameter>self</parameter></paramdef>
> </funcprototype>
> @@ -104,6 +110,27 @@ struct waffle_window;
> </varlistentry>
>
> <varlistentry>
> + <term><function>waffle_window_create2()</function></term>
> + <listitem>
> + <para>
> + Feature test macro: <code>WAFFLE_API_VERSION >= 0x0106</code>.
> + (See <citerefentry><refentrytitle>waffle_feature_test_macros</refentrytitle><manvolnum>7</manvolnum></citerefentry>).
> + </para>
> + <para>
> + Create a window with the properties specified by
> + <parameter>config</parameter> and
> + <parameter>attrib_list</parameter>.
> +
> + <parameter>attrib_list</parameter> must contain the attributes
> + <constant>WAFFLE_WINDOW_WIDTH</constant> and
> + <constant>WAFFLE_WINDOW_HEIGHT</constant>,
> + whose values must be positive
> + and no greater than <constant>INT32_MAX</constant>.
> + </para>
> + </listitem>
> + </varlistentry>
> +
> + <varlistentry>
> <term><function>waffle_window_destroy()</function></term>
> <listitem>
> <para>
> diff --git a/src/waffle/api/waffle_window.c b/src/waffle/api/waffle_window.c
> index 34ecc4a..e04cadb 100644
> --- a/src/waffle/api/waffle_window.c
> +++ b/src/waffle/api/waffle_window.c
> @@ -27,12 +27,83 @@
>
> #include "api_priv.h"
>
> +#include "wcore_attrib_list.h"
> #include "wcore_config.h"
> #include "wcore_error.h"
> #include "wcore_platform.h"
> #include "wcore_window.h"
>
> WAFFLE_API struct waffle_window*
> +waffle_window_create2(
> + struct waffle_config *config,
> + const intptr_t attrib_list[])
> +{
> + struct wcore_window *wc_self = NULL;
> + struct wcore_config *wc_config = wcore_config(config);
> + intptr_t width, height;
> + intptr_t *filtered_attribs = NULL;
> +
> + const struct api_object *obj_list[] = {
> + wc_config ? &wc_config->api : NULL,
> + };
> +
> + if (!api_check_entry(obj_list, 1)) {
> + goto done;
> + }
> +
> + filtered_attribs = wcore_attrib_list_copy(attrib_list);
> +
> + if (!wcore_attrib_list_pop(filtered_attribs,
> + WAFFLE_WINDOW_WIDTH, &width)) {
> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
> + "required attribute WAFFLE_WINDOW_WIDTH is missing");
> + goto done;
> + }
> +
> + if (!wcore_attrib_list_pop(filtered_attribs,
> + WAFFLE_WINDOW_HEIGHT, &height)) {
> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
> + "required attribute WAFFLE_WINDOW_HEIGHT is missing");
> + goto done;
> + }
> +
> + if (width <= 0) {
> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
> + "WAFFLE_WINDOW_WIDTH is not positive");
> + goto done;
> + } else if (width > INT32_MAX) {
> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
> + "WAFFLE_WINDOW_WIDTH is greater than INT32_MAX");
> + goto done;
> + }
> +
> + if (height <= 0) {
> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
> + "WAFFLE_WINDOW_HEIGHT is not positive");
> + goto done;
> + } else if (height > INT32_MAX) {
> + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
> + "WAFFLE_WINDOW_HEIGHT is greater than INT32_MAX");
> + goto done;
> + }
> +
> + wc_self = api_platform->vtbl->window.create(api_platform,
> + wc_config,
> + (int32_t) width,
> + (int32_t) height,
> + filtered_attribs);
I think we want the other way around: move the old
waffle_window_create() code to the new waffle_window_create2()
function, then have create call create2. The limited/specific
function calls the more general one.
> +
> +done:
> + free(filtered_attribs);
> +
> + if (!wc_self) {
> + return NULL;
> + }
> +
> + return waffle_window(wc_self);
> +}
> +
> +WAFFLE_API struct waffle_window*
> waffle_window_create(
> struct waffle_config *config,
> int32_t width, int32_t height)
> diff --git a/src/waffle/core/wcore_util.c b/src/waffle/core/wcore_util.c
> index deee1bf..6c4ef43 100644
> --- a/src/waffle/core/wcore_util.c
> +++ b/src/waffle/core/wcore_util.c
> @@ -88,6 +88,8 @@ wcore_enum_to_string(int32_t e)
> CASE(WAFFLE_DL_OPENGL_ES1);
> CASE(WAFFLE_DL_OPENGL_ES2);
> CASE(WAFFLE_DL_OPENGL_ES3);
> + CASE(WAFFLE_WINDOW_WIDTH);
> + CASE(WAFFLE_WINDOW_HEIGHT);
>
> default: return NULL;
>
> --
> 2.2.0
>
> _______________________________________________
> waffle mailing list
> waffle at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/waffle
More information about the waffle
mailing list