summaryrefslogtreecommitdiff
path: root/tests/wayland/test_reconnect.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/wayland/test_reconnect.c')
-rw-r--r--tests/wayland/test_reconnect.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/tests/wayland/test_reconnect.c b/tests/wayland/test_reconnect.c
index 737afb2..891d98b 100644
--- a/tests/wayland/test_reconnect.c
+++ b/tests/wayland/test_reconnect.c
@@ -2,9 +2,6 @@
* after "ready" and starts a new one after "lost". Windows must survive, keep
* their pixels, and accept new GL and Vulkan objects after DISPLAY_RESTORED. */
#include <yasl/yasl.h>
-#include <yasl/cpu.h>
-#include <yasl/gl.h>
-#include <yasl/native/wayland.h>
#if TEST_VULKAN
#include <yasl/vulkan.h>
#endif
@@ -58,29 +55,25 @@ static VkSurfaceKHR vulkan_surface(void)
int main(void)
{
- CHECK((yasl_init(&(struct yasl_options){.backend=YASL_BACKEND_WAYLAND}) == 0), "selecting Wayland");
- cpu = yasl_surface_create(&(struct yasl_surface_options){.title="reconnect CPU", .width=160, .height=120, .type=YASL_SURFACE_CPU, .flags=0});
+ CHECK(yasl_init(YASL_BACKEND_WAYLAND, NULL) == 0, "selecting Wayland");
+ cpu = yasl_surface_create(&(struct yasl_surface_options){.title="reconnect CPU", .width=160, .height=120});
CHECK(cpu, "creating CPU window");
- gl = yasl_gl_surface_create(&(struct yasl_surface_options){.title="reconnect GL", .width=160, .height=120, .type=YASL_SURFACE_NATIVE, .flags=0}, NULL);
+ gl = yasl_surface_create(&(struct yasl_surface_options){.title="reconnect GL", .width=160, .height=120, .type=YASL_SURFACE_GL});
CHECK(gl, "creating GL window");
expect(YASL_EVENT_REFRESH, cpu, 5000);
int w, h;
- struct yasl_cpu_buffer buffer;
- CHECK(yasl_cpu_acquire(cpu, &buffer) == 0, "acquire CPU buffer");
- w=buffer.width; h=buffer.height;
- uint32_t *pixels = buffer.pixels;
+ uint32_t *pixels = yasl_cpu_pixels(cpu, &w, &h);
CHECK(pixels, "getting pixels");
for (size_t i = 0; i < (size_t)w * h; i++) pixels[i] = 0xff336699u;
- CHECK((yasl_cpu_present(cpu, &buffer) == 0), "presenting");
+ CHECK(yasl_cpu_present(cpu) == 0, "presenting");
draw_gl(0.8f);
#if TEST_VULKAN
- CHECK((yasl_vulkan_init(vkGetInstanceProcAddr) == 0), "loading Vulkan");
- vk = yasl_surface_create(&(struct yasl_surface_options){.title="reconnect Vulkan", .width=160, .height=120, .type=YASL_SURFACE_NATIVE, .flags=0});
- CHECK(vk, "creating Vulkan window");
struct yasl_vulkan_requirements requirements;
- CHECK(yasl_vulkan_get_requirements(vk, &requirements) == 0, "Vulkan requirements");
+ CHECK(yasl_vulkan_init(vkGetInstanceProcAddr, &requirements) == 0, "loading Vulkan");
+ vk = yasl_surface_create(&(struct yasl_surface_options){.title="reconnect Vulkan", .width=160, .height=120, .type=YASL_SURFACE_NATIVE});
+ CHECK(vk, "creating Vulkan window");
VkInstanceCreateInfo info = {.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
.flags = requirements.flags, .enabledExtensionCount = requirements.extension_count,
.ppEnabledExtensionNames = requirements.extensions};
@@ -92,29 +85,29 @@ int main(void)
fflush(stdout);
expect(YASL_EVENT_DISPLAY_LOST, NULL, 10000);
- struct yasl_wayland_handles native;
- CHECK(yasl_wayland_get_native(cpu, &native) == -ENOTCONN && !native.display && !native.surface,
+ struct yasl_native native;
+ CHECK(yasl_surface_get_native(cpu, &native) == -ENOTCONN && !native.wl_display && !native.wl_surface,
"rejecting native handles while offline");
- CHECK(yasl_cpu_acquire(cpu, &buffer) == -ENOTCONN, "rejecting CPU acquisition while offline");
+ CHECK(yasl_cpu_present(cpu) == -ENOTCONN, "rejecting CPU presentation while offline");
CHECK(yasl_gl_make_current(gl) == -ENOTCONN, "rejecting GL binding while offline");
+ CHECK(yasl_gl_make_current(NULL) == 0, "detaching GL while offline");
#if TEST_VULKAN
CHECK(yasl_vulkan_destroy_surface(vk) == 0, "destroying Vulkan surface");
#endif
- CHECK(!yasl_surface_create(&(struct yasl_surface_options){.title="offline", .width=64, .height=64, .type=YASL_SURFACE_CPU, .flags=0}), "refusing windows while offline");
+ CHECK(!yasl_surface_create(&(struct yasl_surface_options){.title="offline", .width=64, .height=64}), "refusing windows while offline");
CHECK(errno == ENOTCONN, "reporting the disconnect");
puts("lost");
fflush(stdout);
expect(YASL_EVENT_DISPLAY_RESTORED, NULL, 15000);
- CHECK(yasl_wayland_get_native(cpu, &native) == 0 && native.display && native.surface,
+ CHECK(yasl_surface_get_native(cpu, &native) == 0 && native.wl_display && native.wl_surface,
"querying restored native handles");
expect(YASL_EVENT_REFRESH, cpu, 5000);
int rw, rh;
- CHECK(yasl_cpu_acquire(cpu, &buffer) == 0, "reacquire CPU buffer");
- rw=buffer.width; rh=buffer.height; pixels=buffer.pixels;
+ pixels = yasl_cpu_pixels(cpu, &rw, &rh);
CHECK(pixels && rw == w && rh == h, "keeping the window size");
CHECK(pixels[0] == 0xff336699u && pixels[(size_t)w * h - 1] == 0xff336699u, "keeping the pixels");
- CHECK((yasl_cpu_present(cpu, &buffer) == 0), "presenting after reconnect");
+ CHECK(yasl_cpu_present(cpu) == 0, "presenting after reconnect");
draw_gl(0.1f);
#if TEST_VULKAN
CHECK(vulkan_surface() != VK_NULL_HANDLE, "restored Vulkan handle");
@@ -123,7 +116,7 @@ int main(void)
#endif
/* A second window proves the new connection accepts creation. */
- CHECK(yasl_surface_create(&(struct yasl_surface_options){.title="after reconnect", .width=64, .height=64, .type=YASL_SURFACE_CPU, .flags=0}), "creating a window after reconnect");
+ CHECK(yasl_surface_create(&(struct yasl_surface_options){.title="after reconnect", .width=64, .height=64}), "creating a window after reconnect");
yasl_gl_make_current(NULL);
yasl_shutdown();
puts("restored");