#include <wayland-server.h>
#include <wayland-client.h>
+#include <libds/types/ds_surface.h>
#include <libds/compositor.h>
#include <libds/surface.h>
#include <libds/log.h>
}
static void
-test_surface_create_and_destroy(void)
+test_ds_surface_create_and_destroy(void)
{
struct test_server server = { .cb_called = false };
pid_t pid;
test_server_finish(&server.base);
}
+static void
+test_ds_surface_get_buffer_source_box(void)
+{
+ struct ds_surface surface = {
+ .current = {
+ .buffer_width = 1920,
+ .buffer_height = 1080,
+ .scale = 1,
+ .transform = WL_OUTPUT_TRANSFORM_NORMAL,
+ .viewport = {
+ .has_src = false,
+ .src = {
+ .x = 100,
+ .y = 100,
+ .width = 800,
+ .height = 600,
+ }
+ }
+ }
+ };
+
+ struct ds_fbox box;
+
+ ds_surface_get_buffer_source_box(&surface, &box);
+ assert(box.x == 0.0 && box.y == 0.0 && box.width == 1920.0 && box.height == 1080.0);
+
+ surface.current.viewport.has_src = true;
+ surface.current.transform = WL_OUTPUT_TRANSFORM_90;
+ ds_surface_get_buffer_source_box(&surface, &box);
+ assert(box.x == 100.0 && box.y == 180.0 && box.width == 600.0 && box.height == 800.0);
+
+ surface.current.scale = 2;
+ surface.current.buffer_width *= surface.current.scale;
+ surface.current.buffer_height *= surface.current.scale;
+ ds_surface_get_buffer_source_box(&surface, &box);
+ assert(box.x == 200.0 && box.y == 360.0 && box.width == 1200.0 && box.height == 1600.0);
+
+ surface.current.transform = WL_OUTPUT_TRANSFORM_270;
+ ds_surface_get_buffer_source_box(&surface, &box);
+ assert(box.x == 2440.0 && box.y == 200.0 && box.width == 1200.0 && box.height == 1600.0);
+
+ surface.current.transform = WL_OUTPUT_TRANSFORM_180;
+ ds_surface_get_buffer_source_box(&surface, &box);
+ assert(box.x == 2040.0 && box.y == 760.0 && box.width == 1600.0 && box.height == 1200.0);
+}
+
int
main(void)
{
- test_surface_create_and_destroy();
+ test_ds_surface_create_and_destroy();
+ test_ds_surface_get_buffer_source_box();
return 0;
}