tests: add output damage test

This test ensures that client submitted damage goes to the screen
correctly, regardless of output scale or transform.

The added quirk is explained in the test that uses it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 4 years ago
parent 1e365c8c4c
commit fbd4160474
  1. 2
      include/libweston/libweston.h
  2. 4
      libweston/renderer-gl/gl-renderer.c
  3. 1
      tests/meson.build
  4. 204
      tests/output-damage-test.c
  5. BIN
      tests/reference/output-damage_1-180-01.png
  6. BIN
      tests/reference/output-damage_1-180-02.png
  7. BIN
      tests/reference/output-damage_1-270-01.png
  8. BIN
      tests/reference/output-damage_1-270-02.png
  9. BIN
      tests/reference/output-damage_1-90-01.png
  10. BIN
      tests/reference/output-damage_1-90-02.png
  11. BIN
      tests/reference/output-damage_1-FLIPPED-01.png
  12. BIN
      tests/reference/output-damage_1-FLIPPED-02.png
  13. BIN
      tests/reference/output-damage_1-FLIPPED_180-01.png
  14. BIN
      tests/reference/output-damage_1-FLIPPED_180-02.png
  15. BIN
      tests/reference/output-damage_1-FLIPPED_270-01.png
  16. BIN
      tests/reference/output-damage_1-FLIPPED_270-02.png
  17. BIN
      tests/reference/output-damage_1-FLIPPED_90-01.png
  18. BIN
      tests/reference/output-damage_1-FLIPPED_90-02.png
  19. BIN
      tests/reference/output-damage_1-NORMAL-01.png
  20. BIN
      tests/reference/output-damage_1-NORMAL-02.png
  21. BIN
      tests/reference/output-damage_2-180-01.png
  22. BIN
      tests/reference/output-damage_2-180-02.png
  23. BIN
      tests/reference/output-damage_2-90-01.png
  24. BIN
      tests/reference/output-damage_2-90-02.png
  25. BIN
      tests/reference/output-damage_2-FLIPPED-01.png
  26. BIN
      tests/reference/output-damage_2-FLIPPED-02.png
  27. BIN
      tests/reference/output-damage_2-NORMAL-01.png
  28. BIN
      tests/reference/output-damage_2-NORMAL-02.png
  29. BIN
      tests/reference/output-damage_3-FLIPPED_270-01.png
  30. BIN
      tests/reference/output-damage_3-FLIPPED_270-02.png
  31. BIN
      tests/reference/output-damage_3-NORMAL-01.png
  32. BIN
      tests/reference/output-damage_3-NORMAL-02.png

@ -194,6 +194,8 @@ enum weston_hdcp_protection {
* \ingroup testharness * \ingroup testharness
*/ */
struct weston_testsuite_quirks { struct weston_testsuite_quirks {
/** Force GL-renderer to do a full upload of wl_shm buffers. */
bool gl_force_full_upload;
}; };
/** Weston test suite data that is given to compositor /** Weston test suite data that is given to compositor

@ -1572,6 +1572,8 @@ static GLenum gl_format_from_internal(GLenum internal_format)
static void static void
gl_renderer_flush_damage(struct weston_surface *surface) gl_renderer_flush_damage(struct weston_surface *surface)
{ {
const struct weston_testsuite_quirks *quirks =
&surface->compositor->test_data.test_quirks;
struct gl_surface_state *gs = get_surface_state(surface); struct gl_surface_state *gs = get_surface_state(surface);
struct weston_buffer *buffer = gs->buffer_ref.buffer; struct weston_buffer *buffer = gs->buffer_ref.buffer;
struct weston_view *view; struct weston_view *view;
@ -1607,7 +1609,7 @@ gl_renderer_flush_damage(struct weston_surface *surface)
data = wl_shm_buffer_get_data(buffer->shm_buffer); data = wl_shm_buffer_get_data(buffer->shm_buffer);
if (gs->needs_full_upload) { if (gs->needs_full_upload || quirks->gl_force_full_upload) {
glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS_EXT, 0);
wl_shm_buffer_begin_access(buffer->shm_buffer); wl_shm_buffer_begin_access(buffer->shm_buffer);

@ -142,6 +142,7 @@ tests = [
linux_explicit_synchronization_unstable_v1_protocol_c, linux_explicit_synchronization_unstable_v1_protocol_c,
], ],
}, },
{ 'name': 'output-damage', },
{ 'name': 'output-transforms', }, { 'name': 'output-transforms', },
{ 'name': 'plugin-registry', }, { 'name': 'plugin-registry', },
{ {

@ -0,0 +1,204 @@
/*
* 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"
#define RENDERERS(s, t) \
{ \
.renderer = RENDERER_PIXMAN, \
.scale = s, \
.transform = WL_OUTPUT_TRANSFORM_ ## t, \
.transform_name = #t, \
.meta.name = "pixman " #s " " #t, \
}, \
{ \
.renderer = RENDERER_GL, \
.scale = s, \
.transform = WL_OUTPUT_TRANSFORM_ ## t, \
.transform_name = #t, \
.meta.name = "GL " #s " " #t, \
}
struct setup_args {
struct fixture_metadata meta;
enum 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(1, 90),
RENDERERS(1, 180),
RENDERERS(1, 270),
RENDERERS(1, FLIPPED),
RENDERERS(1, FLIPPED_90),
RENDERERS(1, FLIPPED_180),
RENDERERS(1, FLIPPED_270),
RENDERERS(2, NORMAL),
RENDERERS(3, NORMAL),
RENDERERS(2, 90),
RENDERERS(2, 180),
RENDERERS(2, FLIPPED),
RENDERERS(3, FLIPPED_270),
};
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;
/*
* The test here works by swapping the whole wl_surface into a
* different color but lying that there is only a small damage area.
* Then the test checks that only the damage area gets the new color
* on screen.
*
* The following quirk forces GL-renderer to update the whole texture
* even for partial damage. Otherwise, GL-renderer would only copy the
* damaged area from the wl_shm buffer into a GL texture.
*
* Those output_damage tests where the surface is scaled up by the
* compositor will use bilinear texture sampling due to the policy
* in the renderers.
*
* Pixman renderer never makes copies of wl_shm buffers, so bilinear
* sampling there will always produce the expected result. However,
* with GL-renderer if the texture is not updated beyond the strict
* damage region, bilinear sampling will result in a blend of the old
* and new colors at the edges of the damage rectangles. This blend
* would be detrimental to testing the damage regions and would cause
* test failures due to reference image mismatch. What we actually
* want to see is the crisp outline of the damage rectangles.
*/
setup.test_quirks.gl_force_full_upload = true;
return weston_test_harness_execute_as_client(harness, &setup);
}
DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta);
static void
commit_buffer_with_damage(struct surface *surface,
struct buffer *buffer,
struct rectangle damage)
{
wl_surface_attach(surface->wl_surface, buffer->proxy, 0, 0);
wl_surface_damage(surface->wl_surface, damage.x, damage.y,
damage.width, damage.height);
wl_surface_commit(surface->wl_surface);
}
/*
* Test that Weston repaints exactly the damage a client sends to it.
*
* NOTE: This relies on the Weston implementation detail that Weston actually
* will repaint exactly the client's damage and nothing more. This is not
* generally true of Wayland compositors.
*/
TEST(output_damage)
{
#define COUNT_BUFS 3
const struct setup_args *oargs;
struct client *client;
bool match = true;
char *refname;
int ret;
struct buffer *buf[COUNT_BUFS];
pixman_color_t colors[COUNT_BUFS];
static const struct rectangle damages[COUNT_BUFS] = {
{ 0 /* full damage */ },
{ .x = 10, .y = 10, .width = 20, .height = 10 },
{ .x = 43, .y = 47, .width = 5, .height = 50 },
};
int i;
const int width = 140;
const int height = 110;
color_rgb888(&colors[0], 100, 100, 100); /* grey */
color_rgb888(&colors[1], 0, 255, 255); /* cyan */
color_rgb888(&colors[2], 0, 255, 0); /* green */
oargs = &my_setup_args[get_test_fixture_index()];
ret = asprintf(&refname, "output-damage_%d-%s",
oargs->scale, oargs->transform_name);
assert(ret);
testlog("%s: %s\n", get_test_name(), refname);
client = create_client();
client->surface = create_test_surface(client);
client->surface->width = width;
client->surface->height = height;
for (i = 0; i < COUNT_BUFS; i++) {
buf[i] = create_shm_buffer_a8r8g8b8(client, width, height);
fill_image_with_color(buf[i]->image, &colors[i]);
}
client->surface->buffer = buf[0];
move_client(client, 19, 19);
/*
* Each time we commit a buffer with a different color, the damage box
* should color just the box on the output.
*/
for (i = 1; i < COUNT_BUFS; i++) {
commit_buffer_with_damage(client->surface, buf[i], damages[i]);
if (!verify_screen_content(client, refname, i, NULL, i))
match = false;
}
assert(match);
for (i = 0; i < COUNT_BUFS; i++)
buffer_destroy(buf[i]);
client->surface->buffer = NULL;
client_destroy(client);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 857 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 876 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 842 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 842 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Loading…
Cancel
Save