[PATCH weston 00/11] tests: wrap all pixel data with Pixman

Pekka Paalanen ppaalanen at gmail.com
Thu Jun 16 14:13:19 UTC 2016


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Hi,

I wanted to refactor the test code handling pixel buffers to use more
appropriate data structures. A key to that is to pick a representation of an
image. Our current representation cannot deal with arbitrary strides or pixel
formats other than a8r8g8b8.

There were three choices for the image struct:

1. write our own (NIH)

	This would make all image parameters easily accessible, and would be
	sufficient for the current uses. However, the moment we want to handle
	more than one pixel format, this approach becomes a swamp where every
	single new addition needs a ton of new code to handle. I also would
	really not want to reinvent yet another pixel format enumeration,
	though we could use wl_shm codes.

2. use Cairo

	Cairo surfaces are nice, and we already use Cairo for loading and
	saving PNG images for the tests. Cairo has good documentation, too.
	Cairo's main problem is an extremely limited set of supported pixel
	formats.

3. use Pixman

	We already use Pixman in Weston. Pixman is very stable software, with
	optimized image processing paths and supports tons of pixel formats.
	The downside is, Pixman's API is undocumented. However, learning a few
	commonly used functions takes you a long way.

I believe Pixman is the most future-proof approach, so I went with that, and
started doing everything in pixman_image_t's.

The patch series works in simple steps: first introduce a struct buffer, which
contains a pixman_image_t and a wl_buffer. Then a new buffer allocator
explicitly for a8r8g8b8 format is introduced, and each test is converted to it
in turn. The old allocator function is hidden once there are no more outside
callers to it, and refactored to remove the pixel format and stride
assumptions. Next, the image comparing, loading and saving APIs are converted
to Pixman images. Cairo remains used for PNG files. Screenshooting returns a
buffer rather than a surface. Finally as a completely new feature, a function
to visualize image differences is added.

An example of the image error visualisation is here:
https://people.collabora.com/~pq/internal-screenshot-error-00.png
The image represents the difference between a reference image and a
screenshot.  The red is wrong, the green is right, and the dark is ignored.

This series is a pre-requisite for a bunch of sub-surface screenshooting tests
I am developing.


Thanks,
pq

Pekka Paalanen (11):
  tests: introduce struct buffer for client-helper
  tests: event-test to use create_shm_buffer_a8r8g8b8()
  tests: internal-screenshot-test to use create_shm_buffer_a8r8g8b8()
  tests: ivi_layout-test to use create_shm_buffer_a8r8g8b8()
  tests: make create_shm_buffer() static
  tests: let create_shm_buffer() handle any format
  tests: rewrite check_surfaces_*() API
  tests: convert reference image loader to pixman
  tests: convert image saver to pixman
  tests: make screenshooting return a buffer
  tests: implement visualize_image_difference()

 Makefile.am                       |   2 +-
 configure.ac                      |   2 +-
 tests/event-test.c                |  26 +-
 tests/internal-screenshot-test.c  |  61 ++--
 tests/ivi_layout-test.c           |  10 +-
 tests/presentation-test.c         |   2 +-
 tests/viewporter-test.c           |   4 +-
 tests/weston-test-client-helper.c | 587 ++++++++++++++++++++++++++------------
 tests/weston-test-client-helper.h |  39 +--
 9 files changed, 488 insertions(+), 245 deletions(-)

-- 
2.7.3



More information about the wayland-devel mailing list