summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Versace <chad.versace@intel.com>2015-01-04 13:36:38 -0800
committerChad Versace <chad.versace@intel.com>2015-01-27 09:36:06 -0800
commit6642aaef9d2038dcdef046cb6c62859c68e7e158 (patch)
tree4997ccc69964f3748ad5e8d25ad9c15a97acaea1
parent793dc9b7b81cd110d61af2027284ba4eb41d7f87 (diff)
waffle: Add public func waffle_window_create2()
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@intel.com> Tested-by: Emil Velikov <emil.l.velikov@gmail.com> (msvc/wgl) Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r--include/waffle/waffle.h14
-rw-r--r--man/waffle_enum.3.xml7
-rw-r--r--man/waffle_window.3.xml27
-rw-r--r--src/waffle/api/waffle_window.c77
-rw-r--r--src/waffle/core/wcore_util.c2
-rw-r--r--src/waffle/waffle.def.in1
6 files changed, 119 insertions, 9 deletions
diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
index b19c53b..80cb793 100644
--- a/include/waffle/waffle.h
+++ b/include/waffle/waffle.h
@@ -165,6 +165,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*
@@ -236,6 +243,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 07edd6c..4874fe7 100644
--- a/man/waffle_enum.3.xml
+++ b/man/waffle_enum.3.xml
@@ -142,6 +142,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..9ab63ca 100644
--- a/src/waffle/api/waffle_window.c
+++ b/src/waffle/api/waffle_window.c
@@ -27,37 +27,96 @@
#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_create(
+waffle_window_create2(
struct waffle_config *config,
- int32_t width, int32_t height)
+ const intptr_t attrib_list[])
{
- struct wcore_window *wc_self;
+ struct wcore_window *wc_self = NULL;
struct wcore_config *wc_config = wcore_config(config);
+ intptr_t *attrib_list_filtered = NULL;
+ intptr_t width = 0, height = 0;
const struct api_object *obj_list[] = {
wc_config ? &wc_config->api : NULL,
};
- if (!api_check_entry(obj_list, 1))
- return NULL;
+ if (!api_check_entry(obj_list, 1)) {
+ goto done;
+ }
+
+ attrib_list_filtered = wcore_attrib_list_copy(attrib_list);
+
+ if (!wcore_attrib_list_pop(attrib_list_filtered,
+ WAFFLE_WINDOW_WIDTH, &width)) {
+ wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
+ "required attribute WAFFLE_WINDOW_WIDTH is missing");
+ goto done;
+ }
+
+ if (!wcore_attrib_list_pop(attrib_list_filtered,
+ 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,
- width,
- height,
- NULL /*attrib_list*/);
- if (!wc_self)
+ (int32_t) width,
+ (int32_t) height,
+ attrib_list_filtered);
+
+done:
+ free(attrib_list_filtered);
+
+ 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)
+{
+ const intptr_t attrib_list[] = {
+ WAFFLE_WINDOW_WIDTH, width,
+ WAFFLE_WINDOW_HEIGHT, height,
+ 0,
+ };
+
+ return waffle_window_create2(config, attrib_list);
+}
+
WAFFLE_API bool
waffle_window_destroy(struct waffle_window *self)
{
diff --git a/src/waffle/core/wcore_util.c b/src/waffle/core/wcore_util.c
index eee064d..b7809a3 100644
--- a/src/waffle/core/wcore_util.c
+++ b/src/waffle/core/wcore_util.c
@@ -111,6 +111,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;
diff --git a/src/waffle/waffle.def.in b/src/waffle/waffle.def.in
index db8464f..ca3078a 100644
--- a/src/waffle/waffle.def.in
+++ b/src/waffle/waffle.def.in
@@ -20,6 +20,7 @@ EXPORTS
waffle_context_destroy
waffle_context_get_native
waffle_window_create
+ waffle_window_create2
waffle_window_destroy
waffle_window_show
waffle_window_swap_buffers