1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
/*
* Copyright © 2020 Collabora, Ltd.
*
* 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 "config.h"
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include "weston-test-client-helper.h"
#include "weston-test-fixture-compositor.h"
#include "weston-test-assert.h"
#define TRANSFORM(x) WL_OUTPUT_TRANSFORM_ ## x, #x
#define RENDERERS(s, t) \
{ \
.renderer = WESTON_RENDERER_PIXMAN, \
.scale = s, \
.transform = WL_OUTPUT_TRANSFORM_ ## t, \
.transform_name = #t, \
.meta.name = "pixman " #s " " #t, \
}, \
{ \
.renderer = WESTON_RENDERER_GL, \
.scale = s, \
.transform = WL_OUTPUT_TRANSFORM_ ## t, \
.transform_name = #t, \
.meta.name = "GL " #s " " #t, \
}, \
{ \
.renderer = WESTON_RENDERER_VULKAN, \
.scale = s, \
.transform = WL_OUTPUT_TRANSFORM_ ## t, \
.transform_name = #t, \
.meta.name = "Vulkan " #s " " #t, \
}
struct setup_args {
struct fixture_metadata meta;
enum weston_renderer_type renderer;
int scale;
enum wl_output_transform transform;
const char *transform_name;
};
static const struct setup_args my_setup_args[] = {
RENDERERS(1, NORMAL),
RENDERERS(2, 90),
};
static enum test_result_code
fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg)
{
struct compositor_setup setup;
/* The width and height are chosen to produce 324x240 framebuffer, to
* emulate keeping the video mode constant.
* This resolution is divisible by 2 and 3.
* Headless multiplies the given size by scale.
*/
compositor_setup_defaults(&setup);
setup.renderer = arg->renderer;
setup.width = 324 / arg->scale;
setup.height = 240 / arg->scale;
setup.scale = arg->scale;
setup.transform = arg->transform;
setup.shell = SHELL_TEST_DESKTOP;
return weston_test_harness_execute_as_client(harness, &setup);
}
DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta);
struct buffer_args {
int scale;
enum wl_output_transform transform;
const char *transform_name;
};
static const struct buffer_args my_buffer_args[] = {
/* { 1, TRANSFORM(NORMAL) }, done in output-transforms-test.c */
{ 1, TRANSFORM(90) },
{ 1, TRANSFORM(180) },
{ 1, TRANSFORM(270) },
{ 1, TRANSFORM(FLIPPED) },
{ 1, TRANSFORM(FLIPPED_90) },
{ 1, TRANSFORM(FLIPPED_180) },
{ 1, TRANSFORM(FLIPPED_270) },
{ 2, TRANSFORM(NORMAL) },
/* { 2, TRANSFORM(90) }, done in output-transforms-test.c */
{ 2, TRANSFORM(180) },
{ 2, TRANSFORM(FLIPPED) },
{ 3, TRANSFORM(NORMAL) },
{ 3, TRANSFORM(FLIPPED_90) },
};
TEST_P(buffer_transform, my_buffer_args)
{
const struct buffer_args *bargs = data;
const struct setup_args *oargs;
struct client *client;
bool match;
char *refname;
int ret;
oargs = &my_setup_args[get_test_fixture_index()];
ret = asprintf(&refname, "output_%d-%s_buffer_%d-%s",
oargs->scale, oargs->transform_name,
bargs->scale, bargs->transform_name);
test_assert_int_gt(ret, 0);
testlog("%s: %s\n", get_test_name(), refname);
/*
* NOTE! The transform set below is a lie.
* Take that into account when analyzing screenshots.
*/
client = create_client();
client->surface = create_test_surface(client);
client->surface->width = 10000; /* used only for damage */
client->surface->height = 10000;
client->surface->buffer = client_buffer_from_image_file(client,
"basic-test-card",
bargs->scale);
wl_surface_set_buffer_scale(client->surface->wl_surface, bargs->scale);
wl_surface_set_buffer_transform(client->surface->wl_surface,
bargs->transform);
move_client(client, 19, 19);
match = verify_screen_content(client, refname, 0, NULL, 0, NULL,
NO_DECORATIONS);
test_assert_true(match);
client_destroy(client);
free(refname);
return RESULT_OK;
}
TEST_P(buffer_transform_split, my_buffer_args)
{
const struct buffer_args *bargs = data;
const struct setup_args *oargs;
struct client *client;
bool match;
char *refname;
int ret;
oargs = &my_setup_args[get_test_fixture_index()];
ret = asprintf(&refname, "output_%d-%s_buffer_%d-%s",
oargs->scale, oargs->transform_name,
bargs->scale, bargs->transform_name);
test_assert_int_gt(ret, 0);
testlog("%s: %s\n", get_test_name(), refname);
/*
* NOTE! The transform set below is a lie.
* Take that into account when analyzing screenshots.
*/
client = create_client();
client->surface = create_test_surface(client);
client->surface->width = 10000; /* used only for damage */
client->surface->height = 10000;
client->surface->buffer = client_buffer_from_image_file(client,
"basic-test-card",
bargs->scale);
move_client(client, 19, 19);
/*
* Commit scale and transform separately. Otherwise identical to the
* 'buffer_transform' test so the same validation images can be used.
*/
wl_surface_set_buffer_scale(client->surface->wl_surface, bargs->scale);
wl_surface_set_buffer_transform(client->surface->wl_surface,
bargs->transform);
wl_surface_commit(client->surface->wl_surface);
match = verify_screen_content(client, refname, 0, NULL, 0, NULL,
NO_DECORATIONS);
test_assert_true(match);
client_destroy(client);
free(refname);
return RESULT_OK;
}
|