platform/upstream/weston.git
8 years agoAdd safe_strtoint() helper
Bryce Harrington [Thu, 4 Aug 2016 00:40:51 +0000 (17:40 -0700)]
Add safe_strtoint() helper

Adds a safe strtol helper function, modeled loosely after Wayland
scanner's strtouint.  This encapsulates the various quirks of strtol
behavior, and streamlines the interface to just handling base-10 numbers
with a simple true/false error indicator and a uint32_t return by
reference.

Test cases are loosely derived from an earlier patch by Imran Zaman.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agooption-parser: Improve error checking for strtol call
Bryce Harrington [Thu, 4 Aug 2016 00:40:50 +0000 (17:40 -0700)]
option-parser: Improve error checking for strtol call

Make the error checking consistent with other strtol() calls.

Note that since strtol(nptr, &endptr) sets endptr == nptr if there were
no digits, this catches the case where the string was blank, so there's
no need to test *value != '\0'.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agoxwayland: Improve error checking for strtol call
Bryce Harrington [Thu, 4 Aug 2016 00:40:49 +0000 (17:40 -0700)]
xwayland: Improve error checking for strtol call

This updates the error checking for the strtol() call in xwayland's
create_lockfile to match other cases.  C.f. cbc05378 and other recent
patches.

A notable difference here is that the existing error checking was
verifying that exactly 10 digits were being read from the lock file,
but the fact that it's 10 digits is just an implementation detail for
how we're writing it.  The pid could be a shorter number of digits, and
would just be space-padded on the left.

This change allows the file to contain any number of digits, but it
can't be blank, all of the digits must be numeric, and the resulting
number must be within the accepted range.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agoStandardize error checking for strtol calls
Bryce Harrington [Thu, 4 Aug 2016 00:40:48 +0000 (17:40 -0700)]
Standardize error checking for strtol calls

This tightens up the strtol() error checking in several places where it
is used for parsing environment variables, and in the backlight
interface that is reading numbers from files under /sys/class/backlight.
All of these uses are expecting strings containing decimal numbers and
nothing else, so the error checking can all be tightened up and made
consistent with other strtol() calls.

This follows the error checking style used in Wayland
(c.f. wayland-client.c and scanner.c) and c.f. commit cbc05378.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agocompositor-x11: Use non-cast functions to retrieve backend and output objects
Armin Krezović [Mon, 1 Aug 2016 17:17:58 +0000 (19:17 +0200)]
compositor-x11: Use non-cast functions to retrieve backend and output objects

This uses container_of instead of explicit cast to retrieve
backend and output objects from generic weston_backend and
weston_output pointers.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocompositor-wayland: Use non-cast functions to retrieve backend and output objects
Armin Krezović [Mon, 1 Aug 2016 17:17:57 +0000 (19:17 +0200)]
compositor-wayland: Use non-cast functions to retrieve backend and output objects

This uses container_of instead of explicit cast to retrieve
backend and output objects from generic weston_backend and
weston_output pointers.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocompositor-rdp: Use non-cast functions to retrieve backend and output objects
Armin Krezović [Mon, 1 Aug 2016 17:17:56 +0000 (19:17 +0200)]
compositor-rdp: Use non-cast functions to retrieve backend and output objects

This uses container_of instead of explicit cast to retrieve
backend and output objects from generic weston_backend and
weston_output pointers.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocompositor-headless: Use non-cast functions to retrieve backend and output objects
Armin Krezović [Mon, 1 Aug 2016 17:17:55 +0000 (19:17 +0200)]
compositor-headless: Use non-cast functions to retrieve backend and output objects

This uses container_of instead of explicit cast to retrieve
backend and output objects from generic weston_backend and
weston_output pointers.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocompositor-drm: Do not exit when there are no outputs left
Armin Krezović [Fri, 29 Jul 2016 11:26:23 +0000 (13:26 +0200)]
compositor-drm: Do not exit when there are no outputs left

When there are no outputs left after a hotplug event, weston
will terminate. This isn't desired when trying to get weston
to work with zero outputs.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocompositor-drm: Do not return an error when no connectors are configured
Armin Krezović [Fri, 29 Jul 2016 11:26:22 +0000 (13:26 +0200)]
compositor-drm: Do not return an error when no connectors are configured

Returning an error when there are no connectors results in
weston terminating after that. That's not expected when
trying to get weston to start with zero drm outputs.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agolibweston: fix major in libweston.pc
Pekka Paalanen [Tue, 2 Aug 2016 08:35:39 +0000 (11:35 +0300)]
libweston: fix major in libweston.pc

Renames forgotten in "libweston: use new versioning scheme".

Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Quentin Glidic <sardemff7+git@sardemff7.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agoautomake: list static libraries before the shared ones
Emil Velikov [Fri, 22 Jul 2016 13:52:42 +0000 (14:52 +0100)]
automake: list static libraries before the shared ones

The linker processes those in the order that they are given. Thus
as-it we can get unresolved symbols.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agolibweston: remove pkgincludedir variable from libweston.pc
Emil Velikov [Fri, 22 Jul 2016 13:51:52 +0000 (14:51 +0100)]
libweston: remove pkgincludedir variable from libweston.pc

Common practise it to provide the includes directly into Cflags, hence
the variable is not needed and we can remove it.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agolibweston: use new versioning scheme
Emil Velikov [Fri, 22 Jul 2016 13:51:51 +0000 (14:51 +0100)]
libweston: use new versioning scheme

Use the documented libweston-$major.so.0.$minor.$patch scheme.

An (almost) identical one is used by GLIB, GDK{2,3}, QT5, json-glib and
others.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agoREADME: Document versioning scheme, forward compatibility
Emil Velikov [Fri, 22 Jul 2016 13:51:50 +0000 (14:51 +0100)]
README: Document versioning scheme, forward compatibility

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agocompositor: Extend compositor user data
Armin Krezović [Mon, 1 Aug 2016 16:51:46 +0000 (18:51 +0200)]
compositor: Extend compositor user data

This patch makes the compositor user data a structure
which can be expanded with new fields when necessary.

v2:

Don't export to_wet_compositor

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoinclude stdint.h for int32_t/uint32_t
Jussi Kukkonen [Tue, 19 Jul 2016 11:16:27 +0000 (14:16 +0300)]
include stdint.h for int32_t/uint32_t

Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
8 years agogitignore: Ignore weston-confine client
Yong Bakos [Tue, 26 Jul 2016 22:09:06 +0000 (17:09 -0500)]
gitignore: Ignore weston-confine client

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoRe-apply "config-parser: Catch negative numbers assigned to unsigned config values"
Bryce Harrington [Fri, 15 Jul 2016 01:28:04 +0000 (18:28 -0700)]
Re-apply "config-parser: Catch negative numbers assigned to unsigned config values"

[With hexadecimal color values now handled via their own routine,
re-introduce the negative unsigned numbers fix.]

strtoul() has a side effect that when given a string representing a
negative number, it treats it as a high value hexadecimal.  IOW,
strtoul("-42", &val) sets val to 0xffffffd6.  This could potentially
result in unintended surprise behaviors.

Catch this by using strtol() and then manually check for the negative
value.  This logic is modelled after Wayland's strtouint().

Note that this change unfortunately reduces the range of parseable
numbers from [0,UINT_MAX] to [0,INT_MAX].  The current users of
weston_config_section_get_uint() are anticipating numbers far smaller
than either of these limits, so the change is believed to have no impact
in practice.

Also add a test case for negative numbers that catches this error
condition.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
8 years agoconfig-parser: Add weston_config_section_get_color
Bryce Harrington [Fri, 15 Jul 2016 01:28:03 +0000 (18:28 -0700)]
config-parser: Add weston_config_section_get_color

Previously weston_config_section_get_uint was serving dual purpose for
parsing both unsigned decimal integer values (ids, counts, seconds,
etc.)  and hexadecimal values (colors), by relying on strtoul's
auto-detection mechanism.

However, this usage is unable to catch certain kinds of error
conditions, such as specifying a negative number where an unsigned
should be used.  And for colors in particular, it would misparse hex
values if the leading 0x was omitted.  E.g. "background-color=99999999"
would render a near-black background (effectively 0x05f5e0ff) instead of
medium grey, and "background-color=ffffffff" would be treated as an
error rather than white.  "background-color=0x01234567",
"background-color=01234567", and "background-color=1234567" each
resulted in the value being parsed as hexadecimal, octal, and decimal
respectively, resulting in colors 0x01234567, 0x00053977, and 0x0012d687
being displayed.

This new routine forces hexadecimal to be used in all cases when parsing
color values, so "0x01234567" and "01234567" result in the same color
value, "99999999" is grey, and "ffffffff" is white.  It also requires
exactly 8 or 10 digits (other lengths likely indicate typos), or the
value "0" (black).

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
8 years agoclients/confine: Toggle maximized state with 'm'
Jonas Ådahl [Thu, 25 Jun 2015 09:45:01 +0000 (17:45 +0800)]
clients/confine: Toggle maximized state with 'm'

In order to test warping when pointer confinemen region changes, add
key binding to the maximized state without using the mouse.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoclients/confine: Add option for using a more complex confine region
Jonas Ådahl [Fri, 8 May 2015 06:18:11 +0000 (14:18 +0800)]
clients/confine: Add option for using a more complex confine region

By passing --complex-confine-region confine will draw an area looking
like a strange H in half transparent gray. This region will act as the
confine region when pointer confinement is activated (by right clicking).

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
8 years agowindow: Add API for manually set confine region
Jonas Ådahl [Fri, 8 May 2015 06:17:24 +0000 (14:17 +0800)]
window: Add API for manually set confine region

We can use this to test more complex confine regions.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agoclients/confine: Reset motion lines on Backspace
Jonas Ådahl [Fri, 8 May 2015 05:54:44 +0000 (13:54 +0800)]
clients/confine: Reset motion lines on Backspace

Clear the white lines that is drawn by pointer motions. It makes it
easier to debug pointer movements as one won't need to restart confine
just to get a clean plate.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agoinput: Support non-rectangular pointer confine regions
Jonas Ådahl [Thu, 30 Apr 2015 09:56:37 +0000 (17:56 +0800)]
input: Support non-rectangular pointer confine regions

This patch adds support for when the resulting pointer confinement region
is not a rectangle.

Support for this is implemented by converting the rectangles of the
region into the regions outer border. Pointer motions are then clamped
to these borders in order to not escape the confinement region.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoclients/confine: Use pointer confinement to confine drawed line
Jonas Ådahl [Wed, 26 Nov 2014 09:47:29 +0000 (17:47 +0800)]
clients/confine: Use pointer confinement to confine drawed line

Use pointer confinement to make the line drawing not go outside the
drawing area. It is toggled with the letf pointer button.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agoclients: Fork clickdot as confine
Jonas Ådahl [Tue, 15 Mar 2016 10:14:00 +0000 (18:14 +0800)]
clients: Fork clickdot as confine

The new confine client will be used to demonstrate pointer confinement.
It is so far identical to clickdot except that it doesn't respond to
clicks.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
8 years agoclients/resizor: Use pointer locking for resizing window
Jonas Ådahl [Wed, 26 Nov 2014 09:40:42 +0000 (17:40 +0800)]
clients/resizor: Use pointer locking for resizing window

Resizes the window using pointer locking when holding the left pointer
button down. The pointer lock cursor position hint is used to warp the
pointer to the same position relative to the bottom right corner.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agoclients: Add API for pointer locking and pointer confinement
Jonas Ådahl [Tue, 25 Nov 2014 02:25:27 +0000 (10:25 +0800)]
clients: Add API for pointer locking and pointer confinement

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoImplement pointer locking and confinement
Jonas Ådahl [Fri, 22 Jul 2016 09:56:31 +0000 (17:56 +0800)]
Implement pointer locking and confinement

This patch implements the wp_pointer_constraints protocol used for
locking or confining a pointer. It consists of a new global object with
two requests; one for locking the surface to a position, one for
confining the pointer to a given region.

In this patch, only the locking part is fully implemented as in
specified in the protocol, while confinement is only implemented for
when the union of the passed region and the input region of the confined
surface is a single rectangle.

Note that the pointer constraints protocol is still unstable and as
such has the unstable protocol naming conventions applied.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniels@collabora.com>
8 years agoinput: Split out pointer button sending from grab handler
Jonas Ådahl [Fri, 22 Jul 2016 09:55:43 +0000 (17:55 +0800)]
input: Split out pointer button sending from grab handler

We'll use it elsewhere later.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoinput: Split out motion sending from default grab
Jonas Ådahl [Fri, 22 Jul 2016 09:54:55 +0000 (17:54 +0800)]
input: Split out motion sending from default grab

We'll reuse it later.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoweston-pointer: Add destroy signal
Jonas Ådahl [Fri, 22 Jul 2016 09:52:58 +0000 (17:52 +0800)]
weston-pointer: Add destroy signal

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agocompositor: Pass both surface and seat in activation signal
Jonas Ådahl [Fri, 22 Jul 2016 09:50:26 +0000 (17:50 +0800)]
compositor: Pass both surface and seat in activation signal

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agocompositor: Add surface commit signal
Jonas Ådahl [Fri, 22 Jul 2016 09:48:03 +0000 (17:48 +0800)]
compositor: Add surface commit signal

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoImplement the relative pointer protocol
Jonas Ådahl [Wed, 22 Oct 2014 19:21:17 +0000 (21:21 +0200)]
Implement the relative pointer protocol

A wp_relative_pointer object is an extension to the wl_pointer interface
only used for emitting relative pointer events. It will only emit events
when the parent pointer has focus.

To get a relative pointer object, use the get_relative_pointer request
of the global wp_relative_pointer_manager object.

The relative pointer protocol is currently an unstable protocol, so
unstable protocol naming conventions has been applied.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agoinput: Provide microsecond timestamps in motion events
Jonas Ådahl [Wed, 29 Jul 2015 06:18:02 +0000 (14:18 +0800)]
input: Provide microsecond timestamps in motion events

Provide timestamps with microsecond granularity if the backend can
provide it. Backends that can't should set it to 0.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agolibinput: Expose unaccelerated motion deltas in motion event struct
Jonas Ådahl [Tue, 21 Oct 2014 21:51:29 +0000 (23:51 +0200)]
libinput: Expose unaccelerated motion deltas in motion event struct

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agocompositor: Keep track of what views were activated by clicking
Jonas Ådahl [Sat, 18 Oct 2014 16:42:19 +0000 (18:42 +0200)]
compositor: Keep track of what views were activated by clicking

Adds a weston_view_activate() that can be passed an additional active
flag WESTON_ACTIVATE_CLICKED, that the shell passes when a view was
activated by clicking.

This allows shell-independent components implement heuristics depending
on how a view was activated.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agodesktop-shell: Pass a flag bitmask instead of bool to activate()
Jonas Ådahl [Sat, 18 Oct 2014 16:20:16 +0000 (18:20 +0200)]
desktop-shell: Pass a flag bitmask instead of bool to activate()

Although it currently only has one available flag, but that'll change.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agodesktop-shell: Make activate() take a view instead of surface
Jonas Ådahl [Sat, 18 Oct 2014 11:24:53 +0000 (13:24 +0200)]
desktop-shell: Make activate() take a view instead of surface

In preparation for further refactorings.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agodesktop-shell: Change switcher to track views
Jonas Ådahl [Sat, 18 Oct 2014 11:09:56 +0000 (13:09 +0200)]
desktop-shell: Change switcher to track views

Preparation for future refactorings.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agodesktop-shell: Track the black surface by its view
Jonas Ådahl [Sat, 18 Oct 2014 10:23:20 +0000 (12:23 +0200)]
desktop-shell: Track the black surface by its view

In preparation for further refactoring.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
8 years agoinput: Activate view no matter the keyboard focus
Jonas Ådahl [Tue, 15 Mar 2016 12:28:51 +0000 (20:28 +0800)]
input: Activate view no matter the keyboard focus

Activate a view even though it effectively may already be active.
Without this, in later patches, it won't be possibe to track what view
was activated by clicking last, as a view which surface already had
keyboard focus, won't be activated.

To keep avoiding sending xdg_surface.configure events, only change the
keyboard focus if the focus actually changed.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
8 years agoautomake: add missing git-version.h dependency
Emil Velikov [Mon, 4 Jul 2016 13:57:12 +0000 (14:57 +0100)]
automake: add missing git-version.h dependency

compositor/main.c depends on the header, while the dependency isn't
specified. Thus depending on the order of how things are build we could
get a build failure.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agoautomake: list the the builddir include before the srcdir
Emil Velikov [Mon, 4 Jul 2016 13:57:11 +0000 (14:57 +0100)]
automake: list the the builddir include before the srcdir

Otherwise we'll pick up the stale (in-tree) generated source(s) over the
fresh (out-of-tree) ones.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agoshared/platform.h: remove the local EGL platform (re)definitions
Emil Velikov [Mon, 4 Jul 2016 14:34:24 +0000 (15:34 +0100)]
shared/platform.h: remove the local EGL platform (re)definitions

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agogl-renderer: remove local EGL platform (re)definitions
Emil Velikov [Mon, 4 Jul 2016 14:34:23 +0000 (15:34 +0100)]
gl-renderer: remove local EGL platform (re)definitions

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoweston-egl-ext.h: add EGL platform definitions
Emil Velikov [Mon, 4 Jul 2016 14:34:22 +0000 (15:34 +0100)]
weston-egl-ext.h: add EGL platform definitions

Will allow us to consolidate the multiple definitions through the tree.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoclients/simple-egl: use weston_check_egl_extension over strstr
Emil Velikov [Mon, 4 Jul 2016 14:34:21 +0000 (15:34 +0100)]
clients/simple-egl: use weston_check_egl_extension over strstr

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoclients/nested: use weston_check_egl_extension over strstr
Emil Velikov [Mon, 4 Jul 2016 14:34:20 +0000 (15:34 +0100)]
clients/nested: use weston_check_egl_extension over strstr

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoshared/platform.h: use weston_check_egl_extension over strstr
Emil Velikov [Mon, 4 Jul 2016 14:34:19 +0000 (15:34 +0100)]
shared/platform.h: use weston_check_egl_extension over strstr

The later can give false positives.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agogl-renderer: move check_extension() to shared/
Emil Velikov [Mon, 4 Jul 2016 14:34:18 +0000 (15:34 +0100)]
gl-renderer: move check_extension() to shared/

... prefixing it with a "weston_". This way we can reuse it across the
board, instead of the current strstr. The latter of which can give us
false positives, thus it will be resolved with next commit(s).

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agolibweston: don't install shared/platform.h
Emil Velikov [Mon, 4 Jul 2016 14:34:17 +0000 (15:34 +0100)]
libweston: don't install shared/platform.h

The header contains a set of extension check (helpers), which do not
provide any compositor related functionality and are not required for
using libweston.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoshared/platform.h: add missing stdbool.h include
Emil Velikov [Mon, 4 Jul 2016 14:34:16 +0000 (15:34 +0100)]
shared/platform.h: add missing stdbool.h include

Required by the bool type, used through the header.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agosimple-egl: remove incomplete EGL_EXT_buffer_age definition
Emil Velikov [Mon, 4 Jul 2016 14:27:19 +0000 (15:27 +0100)]
simple-egl: remove incomplete EGL_EXT_buffer_age definition

A more complete alternative is already provided by the weston-egl-ext.h
header. The latter of which we already include.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agogl-renderer: remove EGL_EXT_image_dma_buf_import guards
Emil Velikov [Mon, 4 Jul 2016 14:27:18 +0000 (15:27 +0100)]
gl-renderer: remove EGL_EXT_image_dma_buf_import guards

We provide a (workaround) definition in weston-egl-ext.h, thus we don't
need any guards.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoweston-egl-ext.h: add GL_EXT_unpack_subimage definitions
Emil Velikov [Mon, 4 Jul 2016 14:27:17 +0000 (15:27 +0100)]
weston-egl-ext.h: add GL_EXT_unpack_subimage definitions

... and use it in gl-renderer.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoweston-egl-ext.h: add EGL_MESA_configless_context definitions
Emil Velikov [Mon, 4 Jul 2016 14:27:16 +0000 (15:27 +0100)]
weston-egl-ext.h: add EGL_MESA_configless_context definitions

... and use it in gl-renderer.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoweston-egl-ext.h: add EGL_EXT_swap_buffers_with_damage definitions
Emil Velikov [Mon, 4 Jul 2016 14:27:15 +0000 (15:27 +0100)]
weston-egl-ext.h: add EGL_EXT_swap_buffers_with_damage definitions

... and use it from simple-egl and gl-renderer.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoclient/nested: reuse weston-egl-ext.h declarations
Emil Velikov [Mon, 4 Jul 2016 14:27:13 +0000 (15:27 +0100)]
client/nested: reuse weston-egl-ext.h declarations

Rather than introducing a local copy of the
EGL_WL_create_wayland_buffer_from_image (re)definition, just use the
local header.

This also gives us access to EGL_WL_bind_wayland_display which is also
used in the client, yet the C file is missing a fall-back definition.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agoRevert "config-parser: Catch negative numbers assigned to unsigned config values"
Bryce Harrington [Wed, 13 Jul 2016 20:27:29 +0000 (13:27 -0700)]
Revert "config-parser: Catch negative numbers assigned to unsigned config values"

The reduction in range limits does have an effect for color values,
which are expressed as hexadecimal values from 0x00000000 to
0xFFFFFFFF.  By limiting the range to INT_MAX, color values of
0x80000000 and up are in fact lost.

This reverts commit 6351fb08c2e302f8696b2022830e5317e7219c39.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Yong Bakos <ybakos@humanoriented.com>
8 years agosystemd: Also force base-10 for the strtol() call
Bryce Harrington [Wed, 13 Jul 2016 02:03:01 +0000 (19:03 -0700)]
systemd: Also force base-10 for the strtol() call

This call is used to parse a time value expressed in usec's, which is
always decimal.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoRequire base-10 for strtol() calls
Bryce Harrington [Tue, 12 Jul 2016 23:51:27 +0000 (16:51 -0700)]
Require base-10 for strtol() calls

The third arg to strtol() specifies the base to assume for the number.
When 0 is passed, as is currently done in option-parser.c, hexadecimal
and octal numbers are permitted and automatically detected and
converted.

This change is an expansion of f6051cbab84c0e577473b67f0585c0f329eb80fe
to cover the remaining strtol() calls in Weston, where the routine is
being used to read fds and pids - which are always expressed in base-10.
It also changes the calls in config-parser, used by
weston_config_section_get_int(), which in turn is being used to read
scales, sizes, times, rates, and delays; these are all expressed in
base-10 numbers only.

The benefit of limiting this to base-10 is to eliminate surprises when
parsing numbers from the command line.  Also, by making the code
consistent with other usages of strtol, it may make it possible to
factor out the common code in the future.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agoInclude space in 'if ('
Bryce Harrington [Tue, 12 Jul 2016 23:59:05 +0000 (16:59 -0700)]
Include space in 'if ('

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
8 years agoconfig-parser: Catch negative numbers assigned to unsigned config values
Bryce Harrington [Tue, 12 Jul 2016 00:55:15 +0000 (17:55 -0700)]
config-parser: Catch negative numbers assigned to unsigned config values

strtoul() has a side effect that when given a string representing a
negative number, it returns a negated version as the value, and does not
flag an error.  IOW, strtoul("-42", &val) sets val to 42.  This could
potentially result in unintended surprise behaviors, such as if one were
to inadvertantly set a config param to -1 expecting that to disable it,
but with the result of setting the param to 1 instead.

Catch this by using strtol() and then manually check for the negative
value.  This logic is modelled after Wayland's strtouint().

Note that this change unfortunately reduces the range of parseable
numbers from [0,UINT_MAX] to [0,INT_MAX].  The current users of
weston_config_section_get_uint() are anticipating numbers far smaller
than either of these limits, so the change is believed to have no impact
in practice.

Also add a test case for negative numbers that catches this error
condition.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
8 years agordp: Check for non-digits and errno in strtol call
Bryce Harrington [Tue, 12 Jul 2016 00:02:44 +0000 (17:02 -0700)]
rdp: Check for non-digits and errno in strtol call

Improve error checking for situations like RDP_FD=42foo, or where the
provided number is out of range.

Suggestion by Yong Bakos.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
8 years agoRemove a wrong closing “extern "C"” in shared/xalloc.c
Emmanuel Gil Peyrot [Mon, 11 Jul 2016 16:31:59 +0000 (17:31 +0100)]
Remove a wrong closing “extern "C"” in shared/xalloc.c

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agordp: Check for non-numeric value in RDP_FD env var
Bryce Harrington [Sat, 9 Jul 2016 01:48:19 +0000 (18:48 -0700)]
rdp: Check for non-numeric value in RDP_FD env var

strtoul(nptr, endptr, ...) will set *endptr to nptr in the case of where
no digits were read from the string, and return 0.  Running with
RDP_FD=foo would thus result in fd=0 being specified to
freerdp_peer_new(), which is unlikely to be the user's intent.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agomulti-resource: Check for no digits in time description
Bryce Harrington [Sat, 9 Jul 2016 01:05:56 +0000 (18:05 -0700)]
multi-resource: Check for no digits in time description

strtoul(nptr, endptr, ...) will set *endptr to nptr in the case of where
no digits were read from the string.  E.g. "foo:bar" should trigger an
error, instead of being read as "0:0" and allowed through.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agooption-parser: Require integer option string values to be base-10
Bryce Harrington [Sat, 9 Jul 2016 00:44:10 +0000 (17:44 -0700)]
option-parser: Require integer option string values to be base-10

The third arg to strtol() specifies the base to assume for the number.
When 0 is passed, as is currently done in option-parser.c, hexadecimal
and octal numbers are permitted and automatically detected and
converted.

In weston and the weston clients and tests using option-parser.c, the
options are all things that can be expected to be specified in base 10:
widths, heights, counts, scales, font sizes, ports, ttys, connectors,
etc.  The subsurfaces client uses two modes, limited to values 0 and 1
only.  The zuc testsuite has a --random parameter for specifying a seed,
which is the only option where using hexadecimal or octal numbers might
conceivably happen.

The benefit of limiting this to base-10 is to eliminate surprises when
parsing numbers from the command line.  Also, by making the code
consistent with other usages of strtol/strtoul, it may make it possible
to factor out the common code in the future.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoconfig-parser: Improve error checks for strtol/strtoul calls
Bryce Harrington [Thu, 7 Jul 2016 21:08:28 +0000 (14:08 -0700)]
config-parser: Improve error checks for strtol/strtoul calls

Check errno, which is set of over/underflow, out of range, etc.  Also
check for empty strings (the usages covered in this patch already also
cover the case where there are non-digits present).  Set errno to 0
before making the strto*l call in case of pre-existing errors
(i.e. ENOTTY when running under the testsuite).

This follows the error checking style used in Wayland
(c.f. wayland-client.c and scanner.c).

In tests, also check errno, and add testcases for parsing '0'.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
8 years agoREADME: Fix grammar for 'an X*'
Bryce Harrington [Thu, 7 Jul 2016 17:53:17 +0000 (10:53 -0700)]
README: Fix grammar for 'an X*'

8 years agodmabuf: Fix grammar in a comment
Bryce Harrington [Wed, 6 Jul 2016 22:30:54 +0000 (15:30 -0700)]
dmabuf: Fix grammar in a comment

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
8 years agoxwayland: Grammar fixes
Bryce Harrington [Wed, 6 Jul 2016 22:25:19 +0000 (15:25 -0700)]
xwayland: Grammar fixes

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
8 years agoxwayland: Cleanup error message on spawn failure Signed-off-by: Bryce Harrington...
Bryce Harrington [Wed, 6 Jul 2016 22:18:46 +0000 (15:18 -0700)]
xwayland: Cleanup error message on spawn failure Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
8 years agoxwayland: Include missing config.h
Bryce Harrington [Wed, 6 Jul 2016 22:14:20 +0000 (15:14 -0700)]
xwayland: Include missing config.h

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
8 years agoREADME: Fix punctuation errors
Bryce Harrington [Wed, 6 Jul 2016 21:50:15 +0000 (14:50 -0700)]
README: Fix punctuation errors

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoREADME: minor the libweston ABI/API documentation
Emil Velikov [Mon, 4 Jul 2016 14:23:50 +0000 (15:23 +0100)]
README: minor the libweston ABI/API documentation

v2: Elaborate what is meant with "major ABI versions" (Pekka).

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> (v1)
8 years agoREADME: clarify libweston purpose/goals.
Emil Velikov [Mon, 4 Jul 2016 14:23:49 +0000 (15:23 +0100)]
README: clarify libweston purpose/goals.

v2: Rewrap, add a couple of missing words (Pekka).
v3: Use alternative wording (Yong).

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocompositor-x11: Flush xcb connection from x11_output_destroy()
Armin Krezović [Thu, 30 Jun 2016 04:29:00 +0000 (06:29 +0200)]
compositor-x11: Flush xcb connection from x11_output_destroy()

Current code flushes the connection when it receives
a delete window request. This means that a destroyed
window will remain available when X11 output gets
removed differently (ie, from a testing module).

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocompositor: Switch to new surface/view mapped checks
Armin Krezović [Thu, 30 Jun 2016 04:04:33 +0000 (06:04 +0200)]
compositor: Switch to new surface/view mapped checks

This patch makes use of new flags which were introduced
by previous patches to check if a surface/view is mapped

v2:

- Rebased to apply on git master
- Added comments with link to discussion about proposed
  changes for weston_{surface,view}_is_mapped()

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agotests: update for manual surface/view mapping
Armin Krezović [Thu, 30 Jun 2016 04:04:32 +0000 (06:04 +0200)]
tests: update for manual surface/view mapping

This is a follow up for weston-test to manually
set mapped status for views/surfaces it controls

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoivi-shell: update for manual surface/view mapping
Armin Krezović [Thu, 30 Jun 2016 04:04:31 +0000 (06:04 +0200)]
ivi-shell: update for manual surface/view mapping

This is a follow up for ivi-shell to manually
set mapped status for views/surfaces it controls

v2:

- Updated for changes in git master

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agofullscreen-shell: update for manual surface/view mapping
Armin Krezović [Thu, 30 Jun 2016 04:04:30 +0000 (06:04 +0200)]
fullscreen-shell: update for manual surface/view mapping

This is a follow up for fullscreen-shell to manually
set mapped status for views/surfaces it controls

v2:

- Add manual mapping to fs_output_apply_pending()

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agodesktop-shell: update for manual surface/view mapping
Armin Krezović [Thu, 30 Jun 2016 04:04:29 +0000 (06:04 +0200)]
desktop-shell: update for manual surface/view mapping

This is a follow up for desktop-shell to manually
set mapped status for views/surfaces it controls

v2:

- Add manual mapping to shell_fade_create_surface()
  and shell_ensure_fullscreen_black_view()

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocompositor: Untangle surface/view is_mapped from output assignments
Armin Krezović [Thu, 30 Jun 2016 04:04:28 +0000 (06:04 +0200)]
compositor: Untangle surface/view is_mapped from output assignments

Currently, weston assumes a surface/view is mapped if
it has an output assigned. In a zero outputs scenario,
this isn't really desirable.

This patch introduces a new flag to weston_surface and
weston_view, which has to be set manually to indicate
that a surface/view is mapped.

v2:

- Remove usage of new flags from
  weston_{view,surface}_is_mapped at this point. They
  will be added after all the implicit mappings have
  been introduced
- Unmap a surface before unmapping a view so the input
  foci is cleaned up properly
- Remove implicit view mapping from view_list_add
- Cosmetic fixes

v3:

- Rebased to apply on git master

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoxwayland: make the plugin usable by libweston compositors
Giulio Camuffo [Wed, 29 Jun 2016 09:54:27 +0000 (11:54 +0200)]
xwayland: make the plugin usable by libweston compositors

This patch follows a similar approach taken to detach the backends from
weston. But instead of passing a configuration struct when loading the
plugin, we use the plugin API registry to register an API, and to get it
in the compositor side.  This API allows to spawn the Xwayland process
in the compositor side, and to deal with signal handling.  A new
function is added in compositor.c to load and init the xwayland.so
plugin.

Also make sure to re-arm the SIGUSR1 when the X server quits.

Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
[Pekka: moved xwayland/weston-xwayland.c -> compositor/xwayland.c]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocompositor: add plugin-registry
Pekka Paalanen [Wed, 29 Jun 2016 09:54:26 +0000 (11:54 +0200)]
compositor: add plugin-registry

Implement a simple register and lookup for function tables. This is
intended for plugins to expose APIs to other plugins.

It has been very hard to arrange a plugin to be able to call into
another plugin without modifying Weston core to explicitly support each
case. This patch fixes that.

The tests all pass.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
8 years agoinput: Move weston_seat_set_keyboard_focus and document
Bryce Harrington [Thu, 30 Jun 2016 02:04:07 +0000 (19:04 -0700)]
input: Move weston_seat_set_keyboard_focus and document

Place it with the other weston_seat functions.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agoinput: Rename weston_surface_activate to weston_seat_set_keyboard_focus
Bryce Harrington [Thu, 30 Jun 2016 02:04:06 +0000 (19:04 -0700)]
input: Rename weston_surface_activate to weston_seat_set_keyboard_focus

The name suggests that it activates surfaces, but the code says it
rather just assigns keyboard focus.  Rename it for clarity, and so the
original function name could be used for something more appropriate
later.  Switch order of parameters since keyboard focus is a property of
the seat.  Update all callers as appropriate.

Change was asked for by pq, May 26, 2016:

 "This should be called weston_seat_set_keyboard_focus(seat, surface).
 Keyboard focus is a property of the seat."

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agotests: implement visualize_image_difference()
Pekka Paalanen [Thu, 2 Jun 2016 15:02:46 +0000 (18:02 +0300)]
tests: implement visualize_image_difference()

Useful for pointing out where the image comparisons fail.

Internal-screenshot-test is modified to save the visualization if the
test fails.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agotests: make screenshooting return a buffer
Pekka Paalanen [Fri, 27 May 2016 11:11:01 +0000 (14:11 +0300)]
tests: make screenshooting return a buffer

Screenshooting does not involve creating a wl_surface, so using struct
surface is superfluous.

Return a struct buffer instead. It could have been just a
pixman_image_t, but setting up proper destruction would be a bit more
work. Should not hurt to keep the wl_buffer around until the user is
ready to free the image.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agotests: convert image saver to pixman
Pekka Paalanen [Fri, 27 May 2016 10:54:35 +0000 (13:54 +0300)]
tests: convert image saver to pixman

This rewrites write_surface_as_png() into write_image_as_png(), which
operates on a pixman_image_t instead of a struct surface.

This is part of the migration to use pixman_image_t everywhere without
superfluous parameters/members.

Now the image saving handles more than just ARGB32 format, presumably.
At least it does not assume everything is always ARGB32.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agotests: convert reference image loader to pixman
Pekka Paalanen [Wed, 25 May 2016 08:47:41 +0000 (11:47 +0300)]
tests: convert reference image loader to pixman

This rewrites load_surface_from_png() to load_image_from_png(), to
return a pixman_image_t instead of a struct surface.

A loaded image has no need for wl_buffer or wl_surface or any of the
associated attributes. This is part of unifying to make everything use
pixman_image_t.

cairo_surface_flush() is added, because Cairo documentation for
cairo_image_surface_get_data() says you have to flush after drawing,
before using the data. It is unclear if loading a PNG counts as drawing,
so stay on the safe side.

load_image_from_png() now pays attention to the pixel format returned by
Cairo, which seems to come out as CAIRO_FORMAT_RGB24 in
internal-screenshot-test, not as CAIRO_FORMAT_ARGB32 as expected. I do
not know if Cairo actually guarantees the x8/a8 channel to be 0xff for
RGB24, but better to not trust it. Therefore the image is explicitly
converted to a8r8g8b8 as needed. This also adds support for loading A8
and RGB16_565 images, provided that Cairo delivers them.

The cairo surface is now wrapped directly into a pixman_image_t. If the
pixel format conversion is not needed, this eliminates a copy of the
image data. The Cairo surface will get automatically destroyed with the
Pixman image.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agotests: rewrite check_surfaces_*() API
Pekka Paalanen [Mon, 23 May 2016 14:42:27 +0000 (17:42 +0300)]
tests: rewrite check_surfaces_*() API

check_surfaces_geometry() is removed as it was not used by anything, and
unlikely would be.

check_surfaces_equal() is merged into check_surfaces_match_in_clip(),
passing a NULL clip means to compare whole images.

check_surfaces_match_in_clip() is converted to work on pixman_image_t
instead of struct surface. The function is only concerned about
comparing images in memory, and does not care about a wl_buffer or a
wl_surface.

The verbosity of image comparisons is greatly reduced. An image mismatch
no longer prints a flood of raw pixel values. This will be replaced
later with a function writing out an error image instead.

Degenerate comparisons are no longer accepted, be that clip outside
images or zero area. Those are an indication of a programmer error.

The pixel format assumptions are made more visible in the code.

A new internal helper image_check_get_roi() computes and verifies the
area to be compared. Image iterator helper makes it simpler to write
manual pixel-poking loops.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agotests: let create_shm_buffer() handle any format
Pekka Paalanen [Fri, 20 May 2016 15:30:03 +0000 (18:30 +0300)]
tests: let create_shm_buffer() handle any format

Change create_shm_buffer() to handle any pixel format known to Pixman.
Presumably in the future we might want to test e.g. RGB565 content with
screenshot tests.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agotests: make create_shm_buffer() static
Pekka Paalanen [Fri, 20 May 2016 15:10:02 +0000 (18:10 +0300)]
tests: make create_shm_buffer() static

No users remain outside the file. This will allow to fix the assumptions
in the function.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agotests: ivi_layout-test to use create_shm_buffer_a8r8g8b8()
Pekka Paalanen [Fri, 20 May 2016 15:01:05 +0000 (18:01 +0300)]
tests: ivi_layout-test to use create_shm_buffer_a8r8g8b8()

This removes the uses of create_shm_buffer() from this test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
8 years agotests: internal-screenshot-test to use create_shm_buffer_a8r8g8b8()
Pekka Paalanen [Fri, 20 May 2016 15:01:05 +0000 (18:01 +0300)]
tests: internal-screenshot-test to use create_shm_buffer_a8r8g8b8()

This removes the uses of create_shm_buffer() from this test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>