[Piglit] [PATCH 2/6] cmake,util: Add Android Waffle support
groleo at gmail.com
groleo at gmail.com
Wed Oct 24 06:11:28 PDT 2012
From: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>
Signed-off-by: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>
---
:100644 100644 a4784b1... 56c5593... M tests/util/CMakeLists.txt
:000000 100644 0000000... 5752d3a... A tests/util/piglit-framework-gl/piglit_android_framework.c
:000000 100644 0000000... d7faf0c... A tests/util/piglit-framework-gl/piglit_android_framework.h
:100644 100644 600ac08... fedec2c... M tests/util/piglit-framework-gl/piglit_wfl_framework.c
:100644 100644 ebc938c... 426605c... M tests/util/piglit-framework-gl/piglit_winsys_framework.c
tests/util/CMakeLists.txt | 5 ++
.../piglit-framework-gl/piglit_android_framework.c | 96 ++++++++++++++++++++++
.../piglit-framework-gl/piglit_android_framework.h | 29 +++++++
.../piglit-framework-gl/piglit_wfl_framework.c | 11 +++
.../piglit-framework-gl/piglit_winsys_framework.c | 3 +
5 files changed, 144 insertions(+)
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index a4784b1..56c5593 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -40,6 +40,11 @@ if(PIGLIT_USE_WAFFLE)
piglit-framework-gl/piglit_x11_framework.c
)
endif()
+ if(PIGLIT_HAS_ANDROID)
+ list(APPEND UTIL_GL_SOURCES
+ piglit-framework-gl/piglit_android_framework.c
+ )
+ endif()
else()
list(APPEND UTIL_GL_SOURCES
piglit-framework-gl/piglit_glut_framework.c
diff --git a/tests/util/piglit-framework-gl/piglit_android_framework.c b/tests/util/piglit-framework-gl/piglit_android_framework.c
new file mode 100644
index 0000000..5752d3a
--- /dev/null
+++ b/tests/util/piglit-framework-gl/piglit_android_framework.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "piglit-util-gl-common.h"
+#include "piglit_android_framework.h"
+
+static void
+enter_event_loop(struct piglit_winsys_framework *winsys_fw)
+{
+ const struct piglit_gl_test_config *test_config = winsys_fw->wfl_fw.gl_fw.test_config;
+
+ /* The Wayland window fails to appear on the first call to
+ * swapBuffers (which occured in display_cb above). This is
+ * likely due to swapBuffers being called before receiving an
+ * expose event. Until piglit has proper Wayland support,
+ * redraw as a workaround.
+ */
+ /* XXX: see if this is true on Android */
+ if (test_config->display)
+ test_config->display();
+
+ /* FINISHME: Write event loop for Android.
+ *
+ * Until we have proper Android support, give the user enough time
+ * to view the window by sleeping.
+ */
+ sleep(8);
+}
+
+static void
+show_window(struct piglit_winsys_framework *winsys_fw)
+{
+ waffle_window_show(winsys_fw->wfl_fw.window);
+}
+
+static void
+destroy(struct piglit_gl_framework *gl_fw)
+{
+ struct piglit_winsys_framework *winsys_fw= piglit_winsys_framework(gl_fw);
+
+ if (winsys_fw == NULL)
+ return;
+
+ piglit_winsys_framework_teardown(winsys_fw);
+ free(winsys_fw);
+}
+
+struct piglit_gl_framework*
+piglit_android_framework_create(const struct piglit_gl_test_config *test_config)
+{
+ struct piglit_winsys_framework *winsys_fw = NULL;
+ struct piglit_gl_framework *gl_fw = NULL;
+ bool ok = true;
+
+ winsys_fw = calloc(1, sizeof(*winsys_fw));
+ gl_fw = &winsys_fw->wfl_fw.gl_fw;
+
+ ok = piglit_winsys_framework_init(winsys_fw, test_config,
+ WAFFLE_PLATFORM_ANDROID);
+ if (!ok)
+ goto fail;
+
+ winsys_fw->show_window = show_window;
+ winsys_fw->enter_event_loop = enter_event_loop;
+ gl_fw->destroy = destroy;
+
+ return gl_fw;
+
+fail:
+ destroy(gl_fw);
+ return NULL;
+}
diff --git a/tests/util/piglit-framework-gl/piglit_android_framework.h b/tests/util/piglit-framework-gl/piglit_android_framework.h
new file mode 100644
index 0000000..d7faf0c
--- /dev/null
+++ b/tests/util/piglit-framework-gl/piglit_android_framework.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#pragma once
+
+#include "piglit_winsys_framework.h"
+
+struct piglit_gl_framework*
+piglit_android_framework_create(const struct piglit_gl_test_config *test_config);
diff --git a/tests/util/piglit-framework-gl/piglit_wfl_framework.c b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
index 600ac08..fedec2c 100644
--- a/tests/util/piglit-framework-gl/piglit_wfl_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
@@ -96,6 +96,17 @@ piglit_wfl_framework_choose_platform(void)
#endif
}
+ else if (strcmp(env, "android") == 0) {
+#ifdef PIGLIT_HAS_ANDROID
+ return WAFFLE_PLATFORM_ANDROID;
+#else
+ fprintf(stderr, "environment var PIGLIT_PLATFORM=android, "
+ "but piglit was built without Android support\n");
+ piglit_report_result(PIGLIT_FAIL);
+#endif
+ }
+
+
else {
fprintf(stderr, "environment var PIGLIT_PLATFORM has bad "
"value \"%s\"\n", env);
diff --git a/tests/util/piglit-framework-gl/piglit_winsys_framework.c b/tests/util/piglit-framework-gl/piglit_winsys_framework.c
index ebc938c..426605c 100644
--- a/tests/util/piglit-framework-gl/piglit_winsys_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_winsys_framework.c
@@ -32,6 +32,7 @@
#include "piglit_winsys_framework.h"
#include "piglit_wl_framework.h"
#include "piglit_x11_framework.h"
+#include "piglit_android_framework.h"
struct piglit_winsys_framework*
piglit_winsys_framework(struct piglit_gl_framework *gl_fw)
@@ -152,6 +153,8 @@ piglit_winsys_framework_factory(const struct piglit_gl_test_config *test_config)
*/
case WAFFLE_PLATFORM_WAYLAND:
return piglit_wl_framework_create(test_config);
+ case WAFFLE_PLATFORM_ANDROID:
+ return piglit_android_framework_create(test_config);
default:
assert(0);
return NULL;
--
1.8.0
More information about the Piglit
mailing list