blob: 7a8226beb1449e8f9a7bb51418e254a63a6ac336 [file] [log] [blame]
Pekka Paalanen4505f812020-03-11 17:43:44 +02001/*
2 * Copyright 2014, 2016, 2020 Collabora, Ltd.
3 * Copyright 2020 Zodiac Inflight Innovations
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26
27#include "config.h"
28
29#include <stdio.h>
30#include <string.h>
31#include <sys/mman.h>
32
33#include "weston-test-client-helper.h"
34#include "weston-test-fixture-compositor.h"
35
Pekka Paalanenef813882021-02-15 13:46:42 +020036struct setup_args {
37 struct fixture_metadata meta;
38 enum renderer_type renderer;
39};
40
41static const struct setup_args my_setup_args[] = {
42 {
43 .renderer = RENDERER_PIXMAN,
44 .meta.name = "pixman"
45 },
46 {
47 .renderer = RENDERER_GL,
48 .meta.name = "GL"
49 },
Pekka Paalanen4505f812020-03-11 17:43:44 +020050};
51
52static enum test_result_code
53fixture_setup(struct weston_test_harness *harness,
Pekka Paalanenef813882021-02-15 13:46:42 +020054 const struct setup_args *arg)
Pekka Paalanen4505f812020-03-11 17:43:44 +020055{
56 struct compositor_setup setup;
57
58 compositor_setup_defaults(&setup);
Pekka Paalanenef813882021-02-15 13:46:42 +020059 setup.renderer = arg->renderer;
Pekka Paalanen4505f812020-03-11 17:43:44 +020060 setup.shell = SHELL_TEST_DESKTOP;
61
62 return weston_test_harness_execute_as_client(harness, &setup);
63}
Pekka Paalanenef813882021-02-15 13:46:42 +020064DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta);
Pekka Paalanen4505f812020-03-11 17:43:44 +020065
66
67TEST(viewport_upscale_solid)
68{
69 struct client *client;
70 struct wp_viewport *viewport;
71 pixman_color_t color;
72 const int width = 256;
73 const int height = 100;
74 bool match;
75
76 color_rgb888(&color, 255, 128, 0);
77
78 client = create_client();
79 client->surface = create_test_surface(client);
80 viewport = client_create_viewport(client);
81
82 client->surface->buffer = create_shm_buffer_a8r8g8b8(client, 2, 2);
83 fill_image_with_color(client->surface->buffer->image, &color);
84
85 /* Needs output scale != buffer scale to hit bilinear filter. */
86 wl_surface_set_buffer_scale(client->surface->wl_surface, 2);
87
88 wp_viewport_set_destination(viewport, width, height);
89 client->surface->width = width;
90 client->surface->height = height;
91
92 move_client(client, 19, 19);
93
94 match = verify_screen_content(client, "viewport_upscale_solid", 0,
95 NULL, 0);
96 assert(match);
97
98 wp_viewport_destroy(viewport);
99 client_destroy(client);
100}