• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
36 static const enum renderer_type renderers[] = {
37 	RENDERER_PIXMAN,
38 	RENDERER_GL,
39 };
40 
41 static enum test_result_code
fixture_setup(struct weston_test_harness * harness,const enum renderer_type * renderer)42 fixture_setup(struct weston_test_harness *harness,
43 	      const enum renderer_type *renderer)
44 {
45 	struct compositor_setup setup;
46 
47 	compositor_setup_defaults(&setup);
48 	setup.renderer = *renderer;
49 	setup.shell = SHELL_TEST_DESKTOP;
50 
51 	return weston_test_harness_execute_as_client(harness, &setup);
52 }
53 DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, renderers);
54 
55 
TEST(viewport_upscale_solid)56 TEST(viewport_upscale_solid)
57 {
58 	struct client *client;
59 	struct wp_viewport *viewport;
60 	pixman_color_t color;
61 	const int width = 256;
62 	const int height = 100;
63 	bool match;
64 
65 	color_rgb888(&color, 255, 128, 0);
66 
67 	client = create_client();
68 	client->surface = create_test_surface(client);
69 	viewport = client_create_viewport(client);
70 
71 	client->surface->buffer = create_shm_buffer_a8r8g8b8(client, 2, 2);
72 	fill_image_with_color(client->surface->buffer->image, &color);
73 
74 	/* Needs output scale != buffer scale to hit bilinear filter. */
75 	wl_surface_set_buffer_scale(client->surface->wl_surface, 2);
76 
77 	wp_viewport_set_destination(viewport, width, height);
78 	client->surface->width = width;
79 	client->surface->height = height;
80 
81 	move_client(client, 19, 19);
82 
83 	match = verify_screen_content(client, "viewport_upscale_solid", 0,
84 				      NULL, 0);
85 	assert(match);
86 
87 	wp_viewport_destroy(viewport);
88 	client_destroy(client);
89 }
90